This commit is contained in:
2024-03-19 14:49:14 +08:00
10 changed files with 505 additions and 2 deletions

View File

@@ -0,0 +1,57 @@
package org.nl.b_lms.pda.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.pda.service.ProductOutTwoService;
import org.nl.modules.logging.annotation.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author liuxy
* @date 2022-05-25
**/
@RestController
@RequestMapping("/api/twoPda/st")
@Slf4j
public class ProductOutTwoController {
@Autowired
private ProductOutTwoService productOutTwoService;
@PostMapping("/ivtQuery")
@Log("单据初始化查询")
@SaIgnore
public ResponseEntity<Object> ivtQuery(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(productOutTwoService.ivtQuery(whereJson), HttpStatus.OK);
}
@PostMapping("/ivtDtlQuery")
@Log("查询点位木箱")
@SaIgnore
public ResponseEntity<Object> ivtDtlQuery(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(productOutTwoService.ivtDtlQuery(whereJson), HttpStatus.OK);
}
@PostMapping("/ivtbBoxDtlQuery")
@Log("木箱明细")
@SaIgnore
public ResponseEntity<Object> ivtbBoxDtlQuery(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(productOutTwoService.ivtbBoxDtlQuery(whereJson), HttpStatus.OK);
}
@PostMapping("/outConfirm")
@Log("确认")
@SaIgnore
public ResponseEntity<Object> outConfirm(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(productOutTwoService.outConfirm(whereJson), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,42 @@
package org.nl.b_lms.pda.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.pda.service.VehicleTwoService;
import org.nl.modules.logging.annotation.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author liuxy
* @date 2022-05-25
**/
@RestController
@RequestMapping("/api/twoPda/vehicle")
@Slf4j
public class VehicleTwoController {
@Autowired
private VehicleTwoService vehicleTwoService;
@PostMapping("/vehicleIn")
@Log("入空载具")
@SaIgnore
public ResponseEntity<Object> vehicleIn(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(vehicleTwoService.vehicleIn(whereJson), HttpStatus.OK);
}
@PostMapping("/boxIn")
@Log("木箱入库")
@SaIgnore
public ResponseEntity<Object> boxIn(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(vehicleTwoService.boxIn(whereJson), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,48 @@
package org.nl.b_lms.pda.service;
import com.alibaba.fastjson.JSONObject;
/**
* @author liuxy
* @description 服务接口
* @date 2022-05-25
**/
public interface ProductOutTwoService {
/**
* 单据初始化查询
* @param whereJson {
* box_no: 木箱号
* bill_code: 单据号
* }
* @return JSONObject 返回前端参数
*/
JSONObject ivtQuery(JSONObject whereJson);
/**
* 查询点位木箱
* @param whereJson {
* box_no: 木箱号
* bill_code: 单据号
* }
* @return JSONObject 返回前端参数
*/
JSONObject ivtDtlQuery(JSONObject whereJson);
/**
* 木箱明细
* @param whereJson {
* box_no: 木箱号
* }
* @return JSONObject 返回前端参数
*/
JSONObject ivtbBoxDtlQuery(JSONObject whereJson);
/**
* 木箱明细
* @param whereJson {
* box_no: 木箱号
* }
* @return JSONObject 返回前端参数
*/
JSONObject outConfirm(JSONObject whereJson);
}

View File

@@ -0,0 +1,33 @@
package org.nl.b_lms.pda.service;
import com.alibaba.fastjson.JSONObject;
/**
* @author liuxy
* @description 服务接口
* @date 2022-05-25
**/
public interface VehicleTwoService {
/**
*
* @param whereJson {
* vehicle_code: 载具号
* vehicle_type: 载具类型
* point_code: 点位
* }
* @return JSONObject返回前端参数
*/
JSONObject vehicleIn(JSONObject whereJson);
/**
*
* @param whereJson {
* box_no: 木箱号
* vehicle_code: 载具号
* point_code: 点位
* }
* @return JSONObject返回前端参数~
*/
JSONObject boxIn(JSONObject whereJson);
}

View File

@@ -0,0 +1,95 @@
package org.nl.b_lms.pda.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.pda.service.ProductOutTwoService;
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxlashboundService;
import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxlashbound;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.pda.st.service.impl.ProductionOutServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
public class ProductOutTwoServiceImpl implements ProductOutTwoService {
/**
* 木箱绑定服务
*/
@Autowired
private IBstIvtBoxlashboundService iBstIvtBoxlashboundService;
@Override
public JSONObject ivtQuery(JSONObject whereJson) {
return new ProductionOutServiceImpl().ivtQuery(whereJson);
}
@Override
public JSONObject ivtDtlQuery(JSONObject whereJson) {
return new ProductionOutServiceImpl().ivtDtlQuery(whereJson);
}
@Override
public JSONObject ivtbBoxDtlQuery(JSONObject whereJson) {
return new ProductionOutServiceImpl().ivtbBoxDtlQuery(whereJson);
}
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject outConfirm(JSONObject whereJson) {
// 点位表
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
String box_no = whereJson.getString("box_no");
if (ObjectUtil.isEmpty(box_no)) {
throw new BadRequestException("木箱不能为空");
}
BstIvtBoxlashbound boundDao = iBstIvtBoxlashboundService.getOne(
new QueryWrapper<BstIvtBoxlashbound>().lambda()
.eq(BstIvtBoxlashbound::getBox_no, box_no)
);
if (ObjectUtil.isEmpty(boundDao)) {
throw new BadRequestException("此木箱没有经过自动捆扎,请手动解绑!");
}
// 查出所有捆绑在一起的木箱
List<BstIvtBoxlashbound> boundDaoList = iBstIvtBoxlashboundService.list(
new QueryWrapper<BstIvtBoxlashbound>().lambda()
.eq(BstIvtBoxlashbound::getBound_id, boundDao.getBound_id())
);
// 查询所在点位
String box_in = boundDaoList.stream()
.map(BstIvtBoxlashbound::getBox_no)
.collect(Collectors.joining("','"));
JSONObject jsonPoint = pointTab.query("vehicle_code IN ('" + box_in + "') and is_delete = '0' and is_used = '1' and point_type = '9'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonPoint)) {
throw new BadRequestException("请输入正确的木箱或查看点位是否存在");
}
// 解锁点位
jsonPoint.put("point_status", "1");
jsonPoint.put("lock_type", "1");
jsonPoint.put("vehicle_code", "");
pointTab.update(jsonPoint);
// 删除木箱绑定关系
iBstIvtBoxlashboundService.removeByIds(boundDaoList);
JSONObject result = new JSONObject();
result.put("message", "解绑成功!");
return result;
}
}

View File

@@ -0,0 +1,52 @@
package org.nl.b_lms.pda.service.impl;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.pda.service.VehicleTwoService;
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InBoxManageService;
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InVehicleManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Slf4j
public class VehicleTwoServiceImpl implements VehicleTwoService {
/**
* 入空载具服务
*/
@Autowired
private InVehicleManageService inVehicleManageService;
/**
* 入空木箱服务
*/
@Autowired
private InBoxManageService inBoxManageService;
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject vehicleIn(JSONObject whereJson) {
// 调用接口
whereJson.put("device_code", whereJson.getString("point_code"));
inVehicleManageService.inVehicle(whereJson);
JSONObject result = new JSONObject();
result.put("message", "入库成功!");
return result;
}
@Override
public JSONObject boxIn(JSONObject whereJson) {
// 调用接口
inBoxManageService.boxBinVehicle(whereJson);
JSONObject result = new JSONObject();
result.put("message", "入库成功!");
return result;
}
}

View File

@@ -0,0 +1,163 @@
package org.nl.b_lms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.sch.AcsTaskDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* 二期入木箱行架任务类
* Created by Lxy on 2024/1/19.
*/
public class TwoInBoxTrussTask extends AbstractAcsTask {
/**
* 处理类
*/
private final String THIS_CLASS = TwoInBoxTrussTask.class.getName();
@Override
public List<AcsTaskDto> addTask() {
/*
* 下发给ACS时需要特殊处理
*/
JSONArray arr = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0'").getResultJSONArray(0);
ArrayList<AcsTaskDto> resultList = new ArrayList<>();
for (int i = 0; i < arr.size(); i++) {
JSONObject json = arr.getJSONObject(i);
char dtl_type = json.getString("task_type").charAt(json.getString("task_type").length() - 1);
AcsTaskDto dto = AcsTaskDto.builder()
.ext_task_id(json.getString("task_id"))
.task_code(json.getString("task_code"))
.task_type(json.getString("acs_task_type"))
.start_device_code(json.getString("point_code1"))
.next_device_code(json.getString("point_code2"))
.vehicle_code(json.getString("vehicle_code"))
.priority(json.getString("priority"))
.class_type(json.getString("task_type"))
.dtl_type(String.valueOf(dtl_type))
.remark(json.getString("remark"))
.build();
resultList.add(dto);
}
return resultList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateTaskStatus(JSONObject taskObj, String status) {
// 任务表
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
// 更新任务的参数
JSONObject map = new JSONObject();
/*
* 1-执行中, 2-完成 ,0-acs取消
*/
// 执行中
if (status.equals(TaskStatusEnum.EXECUTING.getCode())) {
map.put("task_status", TaskStatusEnum.EXECUTING.getCode());
}
// 完成
if (status.equals(TaskStatusEnum.FINISHED.getCode())) {
map.put("task_status", TaskStatusEnum.FINISHED.getCode());
}
// 取消
if (status.equals(IOSEnum.IS_NOTANDYES.code(""))) {
if (taskObj.getIntValue("task_status") > Integer.valueOf(TaskStatusEnum.ISSUE.getCode())) {
throw new BadRequestException("任务已执行不能取消");
}
// 更新任务表删除字段
map.put("is_delete", IOSEnum.IS_NOTANDYES.code(""));
}
map.put("update_optid", SecurityUtils.getCurrentUserId());
map.put("update_optname", SecurityUtils.getCurrentNickName());
map.put("update_time", DateUtil.now());
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "task_id = '" + taskObj.getString("task_id") + "'");
}
@Override
public void findStartPoint() {
}
@Override
public void findNextPoint() {
}
@Override
@Transactional(rollbackFor = Exception.class)
public String createTask(JSONObject form) {
if (StrUtil.isBlank(form.getString("task_type"))) {
throw new BadRequestException("业务类型不能为空!");
}
if (StrUtil.isBlank(form.getString("start_device_code"))) {
throw new BadRequestException("起点不能为空!");
}
if (StrUtil.isBlank(form.getString("next_device_code"))) {
throw new BadRequestException("终点不能为空!");
}
JSONObject json = new JSONObject();
json.put("task_id", IdUtil.getSnowflake(1, 1).nextId());
json.put("task_code", IdUtil.getSnowflake(1, 1).nextId());
json.put("task_type", form.getString("task_type"));
json.put("vehicle_code", form.getString("vehicle_code"));
json.put("vehicle_code2", form.getString("vehicle_code2"));
json.put("vehicle_type", form.getString("vehicle_type"));
json.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
json.put("task_group_id", form.getLongValue("task_group_id"));
json.put("point_code1", form.getString("start_device_code"));
json.put("point_code2", form.getString("next_device_code"));
json.put("handle_class", this.getClass().getName());
json.put("create_id", SecurityUtils.getCurrentUserId());
json.put("create_name", SecurityUtils.getCurrentUsername());
json.put("create_time", DateUtil.now());
json.put("priority", "1");
json.put("acs_task_type", "7");
WQLObject.getWQLObject("SCH_BASE_Task").insert(json);
return json.getString("task_id");
}
@Override
@Transactional(rollbackFor = Exception.class)
public void forceFinish(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
}
@Override
public void cancel(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, IOSEnum.ACS_RESULT.code("取消"));
}
}

View File

@@ -171,6 +171,7 @@ public class TwoOutTask extends AbstractAcsTask {
json.put("task_type", form.getString("task_type"));
json.put("vehicle_code", form.getString("vehicle_code"));
json.put("vehicle_code2", form.getString("vehicle_code2"));
json.put("task_name", form.getString("task_name"));
json.put("point_code1", form.getString("point_code1"));
json.put("point_code2", form.getString("point_code2"));

View File

@@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor;
import org.nl.b_lms.sch.task.dao.SchBaseTask;
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
import org.nl.b_lms.sch.tasks.TwoInBoxTask;
import org.nl.b_lms.sch.tasks.TwoInBoxTrussTask;
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxinfoService;
import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxinfo;
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
@@ -142,7 +143,7 @@ public class InBoxManageServiceImpl implements InBoxManageService {
JSONObject mesBoxInfo = new JSONObject();
// 插入木箱信息表
iBstIvtBoxinfoService.mesInsert(mesBoxInfo);
// iBstIvtBoxinfoService.mesInsert(mesBoxInfo);
/*
* 插入木箱对应载具表
@@ -163,7 +164,17 @@ public class InBoxManageServiceImpl implements InBoxManageService {
jsonVeExt.put("device_uuid", IdUtil.getLongId());
veExtTab.insert(jsonVeExt);
// TODO 手持下发桁架任务
// 下发桁架任务
JSONObject taskParam = new JSONObject();
taskParam.put("task_type", "010713");
taskParam.put("start_device_code", whereJson.getString("point_code"));
taskParam.put("next_device_code", "1001");
taskParam.put("vehicle_code", whereJson.getString("box_no"));
taskParam.put("vehicle_code2", whereJson.getString("vehicle_code"));
TwoInBoxTrussTask taskBean = new TwoInBoxTrussTask();
taskBean.createTask(taskParam);
taskBean.immediateNotifyAcs(null);
}
@Override

View File

@@ -26,6 +26,7 @@ public interface InBoxManageService {
* @param whereJson{
* box_no 木箱号
* vehicle_code托盘号
* point_code起点点位
* }
*/
void boxBinVehicle(JSONObject whereJson);