fix: 修复货梯与供给线呼叫空盘任务相关问题

This commit is contained in:
2023-05-22 11:04:32 +08:00
parent 9b3622cf44
commit 53221592ed
5 changed files with 83 additions and 35 deletions

View File

@@ -209,7 +209,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
} else if (StrUtil.equals(type, "2")) { } else if (StrUtil.equals(type, "2")) {
// 2.共挤线满托入库: 调用物料入库处理类创建任务 // 2.共挤线满托入库: 调用物料入库处理类创建任务
if (ObjectUtil.isEmpty(material_num) || (StrUtil.equals(material_num, "0"))) if (ObjectUtil.isEmpty(material_num) || (StrUtil.equals(material_num, "0")))
throw new BadRequestException("物料数量不能为空或者为0"); material_num = "0";
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("point_code1", point_code); // 满料位 param.put("point_code1", point_code); // 满料位

View File

@@ -5,16 +5,22 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.system.service.impl.ParamServiceImpl; import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder; import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.log.LokiLogType;
import org.slf4j.MDC;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
/** /**
* ACS连接工具类: * ACS连接工具类:
*/ */
@Slf4j
public class AcsUtil { public class AcsUtil {
public static JSONObject notifyAcs(String api, JSONArray list) { public static JSONObject notifyAcs(String api, JSONArray list) {
MDC.put("log_file_type", LokiLogType.LMS_TO_ACS.getDesc());
log.info("请求接口: " + api + ", 数据:" + list);
//判断是否连接ACS系统 //判断是否连接ACS系统
String isConnect = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("is_connect_acs").getValue(); String isConnect = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("is_connect_acs").getValue();
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();

View File

@@ -269,8 +269,8 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
} else { } else {
// 空托盘暂存区没有就到养生A区找: 先找到出库等待点 // 空托盘暂存区没有就到养生A区找: 先找到出库等待点
JSONObject jsonEmpWait = pointTab.query("region_id = '" + RegionTypeEnum.YSAQKTPQ01.getId() + JSONObject jsonEmpWait = pointTab.query("region_id = '" + RegionTypeEnum.YSAQKTPQ01.getId() +
"' and col_num in ('9', '13') and can_vehicle_type = '" + vehicle_type + "' and col_num in ('9', '13') and can_vehicle_type like '%" + vehicle_type +
"' and is_used = '1' and is_delete = '0'").uniqueResult(0); "%' and is_used = '1' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEmpWait)) continue; if (ObjectUtil.isEmpty(jsonEmpWait)) continue;
JSONObject jsonStartPoint = pointTab.query("region_id = '" + jsonEmpWait.getString("region_id") + JSONObject jsonStartPoint = pointTab.query("region_id = '" + jsonEmpWait.getString("region_id") +

View File

@@ -50,11 +50,20 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
String point_code1 = jsonTask.getString("point_code1"); String point_code1 = jsonTask.getString("point_code1");
String point_code2 = jsonTask.getString("point_code2"); String point_code2 = jsonTask.getString("point_code2");
if (ObjectUtil.isNotEmpty(point_code1)) { if (ObjectUtil.isNotEmpty(point_code1)) {
JSONObject jsonPoint1 = pointTab.query("point_code ='" + point_code1 + "'").uniqueResult(0); // JSONObject jsonPoint1 = pointTab.query("point_code ='" + point_code1 + "'").uniqueResult(0);
jsonPoint1.put("point_status", "1"); // jsonPoint1.put("point_status", "1");
jsonPoint1.put("lock_type", "1"); // jsonPoint1.put("lock_type", "1");
jsonPoint1.put("update_time", DateUtil.now()); // jsonPoint1.put("update_time", DateUtil.now());
pointTab.update(jsonPoint1); // pointTab.update(jsonPoint1);
// 释放货梯
// 锁定所有当前货梯
String allPre = point_code1.substring(0, 5);
JSONObject param2 = new JSONObject();
param2.put("lock_type", "1");
param2.put("task_id", "");
param2.put("point_status", "1");
pointTab.update(param2, "point_code like '" + allPre + "%' " +
"AND point_code <> '" + allPre + "' ");
} }
if (ObjectUtil.isNotEmpty(point_code2)) { if (ObjectUtil.isNotEmpty(point_code2)) {
JSONObject jsonPoint2 = pointTab.query("point_code ='" + point_code2 + "'").uniqueResult(0); JSONObject jsonPoint2 = pointTab.query("point_code ='" + point_code2 + "'").uniqueResult(0);
@@ -88,6 +97,7 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
taskTab.update(jsonTask); taskTab.update(jsonTask);
String point_code3 = jsonTask.getString("point_code3"); String point_code3 = jsonTask.getString("point_code3");
String point_code1 = jsonTask.getString("point_code1");
String point_code = ""; String point_code = "";
// 更新终点判断point_code3是否为空为空就更新point_code2 // 更新终点判断point_code3是否为空为空就更新point_code2
if (ObjectUtil.isNotEmpty(point_code3)) { if (ObjectUtil.isNotEmpty(point_code3)) {
@@ -129,6 +139,14 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
if (ObjectUtil.isNotEmpty(jsonTask.getString("vehicle_code"))) { if (ObjectUtil.isNotEmpty(jsonTask.getString("vehicle_code"))) {
groupTab.delete("vehicle_code = '" + jsonTask.getString("vehicle_code") + "'"); groupTab.delete("vehicle_code = '" + jsonTask.getString("vehicle_code") + "'");
} }
// 锁定所有当前货梯
String allPre = point_code1.substring(0, 5);
JSONObject param2 = new JSONObject();
param2.put("lock_type", "1");
param2.put("task_id", "");
param2.put("point_status", "1");
pointTab.update(param2, "point_code like '" + allPre + "%' " +
"AND point_code <> '" + allPre + "' ");
} }
} }
@@ -142,6 +160,7 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
* 3.下发给ACS * 3.下发给ACS
*/ */
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); // 任务表 WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); // 任务表
WQLObject pointTab = WQLObject.getWQLObject("SCH_BASE_point"); // 点位表
//任务表【SCH_BASE_Task】 //任务表【SCH_BASE_Task】
//判断当前点是否有未完成的任务 //判断当前点是否有未完成的任务
@@ -150,6 +169,11 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
JSONObject taskObj = taskTab.query("is_delete='0' and point_code1 = '" + point_code1 + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0); JSONObject taskObj = taskTab.query("is_delete='0' and point_code1 = '" + point_code1 + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(taskObj)) throw new BadRequestException("当前点位" + point_code1 + "存在未完成的任务"); if (ObjectUtil.isNotEmpty(taskObj)) throw new BadRequestException("当前点位" + point_code1 + "存在未完成的任务");
// 判断是否锁定
JSONObject jsonObject = pointTab.query("point_code = '" + point_code1 + "'").uniqueResult(0);
if (jsonObject.getString("lock_type").equals("2")) {
throw new BadRequestException("当前点位" + point_code1 + "已被锁住");
}
SchTaskDto dto = SchTaskDto.builder().task_id(org.nl.wms.util.IdUtil.getLongId()) SchTaskDto dto = SchTaskDto.builder().task_id(org.nl.wms.util.IdUtil.getLongId())
.task_code(CodeUtil.getNewCode("TASK_CODE")) .task_code(CodeUtil.getNewCode("TASK_CODE"))
.task_type("") .task_type("")
@@ -163,6 +187,10 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
.build(); .build();
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
taskTab.insert(json); taskTab.insert(json);
// 锁住当前点货梯
jsonObject.put("lock_type", "2");
jsonObject.put("task_id", dto.getTask_id());
pointTab.update(jsonObject);
this.findNextPoint(); this.findNextPoint();
// this.immediateNotifyAcs(); // this.immediateNotifyAcs();
return String.valueOf(dto.getTask_id()); return String.valueOf(dto.getTask_id());
@@ -269,6 +297,12 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
JSONObject jsonEnd = pointTab.query("point_code = '" + endPoint + "'").uniqueResult(0); JSONObject jsonEnd = pointTab.query("point_code = '" + endPoint + "'").uniqueResult(0);
jsonEnd.put("lock_type", "2"); jsonEnd.put("lock_type", "2");
pointTab.update(jsonEnd); pointTab.update(jsonEnd);
// 锁住送当前货梯所有点
String allPre = jsonTask.getString("point_code1").substring(0, 5);
JSONObject param2 = new JSONObject();
param2.put("lock_type", "2");
param2.put("task_id", jsonTask.getString("task_id"));
pointTab.update(param2, "point_code like '" + allPre + "%' AND point_code <> '" + allPre + "'");
} }
} }
@@ -374,17 +408,6 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
"and lock_type = '1' and is_used = '1' and is_delete = '0' and point_status = '1'", "in_order_seq desc").uniqueResult(0); "and lock_type = '1' and is_used = '1' and is_delete = '0' and point_status = '1'", "in_order_seq desc").uniqueResult(0);
if (ObjectUtil.isNotEmpty(inOrderSeqDesc)) end_code = inOrderSeqDesc.getString("point_code"); if (ObjectUtil.isNotEmpty(inOrderSeqDesc)) end_code = inOrderSeqDesc.getString("point_code");
} }
// 为空就去养生A区的等待位
// JSONObject jsonEmpWait = pointTab.query("region_id = '" + RegionTypeEnum.YSAQKTPQ01.getId() + "' and col_num = '1' and can_vehicle_type = '" + vehicle_type + "' and lock_type = '1' and is_used = '1' and is_delete = '0' and point_status = '1'").uniqueResult(0);
//
// if (ObjectUtil.isNotEmpty(jsonEmpWait)) {
// // 判断是否有任务
// boolean is_point = this.isTask(jsonEmpWait.getString("point_code"));
// if (is_point) {
// JSONArray jsonEmpArr = pointTab.query("region_id = '" + RegionTypeEnum.YSAQKTPQ01.getId() + "' and row_num = '" + jsonEmpWait.getString("row_num") + "' and can_vehicle_type = '" + vehicle_type + "' and lock_type = '1' and is_used = '1' and is_delete = '0' and point_status = '1'").getResultJSONArray(0);
// if (ObjectUtil.isNotEmpty(jsonEmpArr)) end_code = jsonEmpWait.getString("point_code");
// }
// }
} }
} }

View File

@@ -54,14 +54,21 @@ public class YqxSendMaterialTask extends AbstractAcsTask {
if (StrUtil.equals(status, "0")) { if (StrUtil.equals(status, "0")) {
//取消任务,释放相关点位的锁 //取消任务,释放相关点位的锁
String point_code1 = jsonTask.getString("point_code1"); // String point_code1 = jsonTask.getString("point_code1");
String point_code2 = jsonTask.getString("point_code2"); String point_code2 = jsonTask.getString("point_code2");
JSONObject param = new JSONObject(); // JSONObject param = new JSONObject();
param.put("lock_type", "1"); // param.put("lock_type", "1");
param.put("task_id", ""); // param.put("task_id", "");
pointTab.update(param, "point_code = '" + point_code1 + "'"); // pointTab.update(param, "point_code = '" + point_code1 + "'");
pointTab.update(param, "point_code = '" + point_code2 + "'"); // pointTab.update(param, "point_code = '" + point_code2 + "'");
if (ObjectUtil.isNotEmpty(point_code2)) {
// 锁定所有当前货梯
String allPre = point_code2.substring(0, 5);
JSONObject param2 = new JSONObject();
param2.put("lock_type", "1");
param2.put("task_id", "");
pointTab.update(param2, "point_code like '" + allPre + "%' AND point_code <> '" + allPre + "'");
}
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode()); jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode());
jsonTask.put("remark", "已取消"); jsonTask.put("remark", "已取消");
taskTab.update(jsonTask); taskTab.update(jsonTask);
@@ -83,15 +90,24 @@ public class YqxSendMaterialTask extends AbstractAcsTask {
jsonTask.put("remark", "任务执行完成"); jsonTask.put("remark", "任务执行完成");
taskTab.update(jsonTask); taskTab.update(jsonTask);
//取消任务,释放相关点位的锁 //取消任务,释放相关点位的锁
String point_code1 = jsonTask.getString("point_code1"); // String point_code1 = jsonTask.getString("point_code1");
String point_code2 = jsonTask.getString("point_code2"); String point_code2 = jsonTask.getString("point_code2");
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("lock_type", "1"); param.put("lock_type", "1");
param.put("task_id", ""); param.put("task_id", "");
if (ObjectUtil.isNotEmpty(point_code2)) {
// 锁定所有当前货梯
String allPre = point_code2.substring(0, 5);
JSONObject param2 = new JSONObject();
param2.put("lock_type", "1");
param2.put("task_id", "");
pointTab.update(param2, "point_code like '" + allPre + "%' " +
"AND point_code <> '" + allPre + "' " +
"AND point_code <> '" + point_code2 + "'");
}
pointTab.update(param, "point_code = '" + point_code1 + "'"); // pointTab.update(param, "point_code = '" + point_code1 + "'");
param.put("point_status", "3"); param.put("point_status", "3");
pointTab.update(param, "point_code = '" + point_code2 + "'"); pointTab.update(param, "point_code = '" + point_code2 + "'");
@@ -121,15 +137,18 @@ public class YqxSendMaterialTask extends AbstractAcsTask {
taskObj.put("remark", "电梯无可用点"); taskObj.put("remark", "电梯无可用点");
taskObj.put("update_time", DateUtil.now()); taskObj.put("update_time", DateUtil.now());
taskTab.update(taskObj); taskTab.update(taskObj);
} else { } else { // 找到对应的货梯单位
//锁住点位 // 锁定所有当前货梯
endPoint.put("lock_type", "2"); String pointCode = endPoint.getString("point_code");
endPoint.put("task_id", task_id); String allPre = pointCode.substring(0, 5);
pointTab.update(endPoint); JSONObject param2 = new JSONObject();
param2.put("lock_type", "2");
param2.put("task_id", task_id);;
pointTab.update(param2, "point_code like '" + allPre + "%' AND point_code <> '" + allPre + "'");
//修改任务状态 //修改任务状态
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode()); taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
taskObj.put("point_code2", endPoint.getString("point_code")); taskObj.put("point_code2", pointCode);
taskObj.put("remark", ""); taskObj.put("remark", "");
taskObj.put("update_time", DateUtil.now()); taskObj.put("update_time", DateUtil.now());
taskTab.update(taskObj); taskTab.update(taskObj);