diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java index 53a4345..e131250 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java @@ -69,6 +69,8 @@ public interface WmsToAcsService { */ JSONObject getTray(JSONArray whereJson); + JSONObject light(JSONArray whereJson); + /** * 获取点位 */ diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index c795c91..466e3d0 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -14,6 +14,7 @@ import org.nl.modules.system.util.CodeUtil; import org.nl.modules.wql.WQL; import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.util.SpringContextHolder; +import org.nl.wms.basedata.eum.StandStatus; import org.nl.wms.basedata.eum.TrueOrFalse; import org.nl.wms.basedata.eum.VehicleType; import org.nl.wms.basedata.service.dto.VehicleDto; @@ -24,7 +25,9 @@ import org.nl.wms.sch.task.call.empty.GTKCallEmptyTask; import org.nl.wms.sch.task.call.empty.HLCallEmptyTask; import org.nl.wms.sch.task.call.empty.YZCallEmptyTask; import org.nl.wms.sch.task.call.material.FJCallMaterialTask; +import org.nl.wms.sch.task.call.material.YZCallMaterialTask; import org.nl.wms.sch.task.send.empty.FJSendEmptyTask; +import org.nl.wms.sch.task.send.empty.YZSendEmptyTask; import org.nl.wms.sch.task.send.material.FJSendMaterialTask; import org.nl.wms.sch.task.send.material.HLSendMaterialTask; import org.nl.wms.sch.task.send.material.SZSendMaterialTask; @@ -68,6 +71,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { private final BTHCToPackageTask bthcToPackageTask; + private final YZCallMaterialTask yzCallMaterialTask; + + private final YZSendEmptyTask yzSendEmptyTask; + /** * task_id:任务标识 * task_code:任务编码 @@ -264,7 +271,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { vd.put("create_name", ACSSystem.nick_name); vd.put("create_time", now); vd.put("is_in_kiln", "0"); - vd.put("stand_status", "2"); + vd.put("stand_status", StandStatus.STANDING.value()); vd_table.insert(vd); method_param.put("vd", vd); @@ -310,6 +317,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { method_param.put("workorder", workorder); switch (region) { + case YZ: + task_code = yzCallMaterialTask.createTask(method_param); + break; case FJ: task_code = fjCallMaterialTask.createTask(method_param); break; @@ -319,19 +329,41 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { break; case "3": // 送空 - String vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code")); - if ("0000".equals(vehicle_code)) { - vehicle_code = point.getString("vehicle_code"); - if (StrUtil.isBlank(vehicle_code) || "0000".equals(vehicle_code)) { - throw new BadRequestException("载具编码不能为空!"); - } - } - method_param.put("vehicle_code", vehicle_code); + workorder = WQLObject + .getWQLObject("pdm_bd_workorder") + .query("is_delete = '0' AND device_code = '" + point.getString("device_code") + "' AND order_status = '3'") + .uniqueResult(0); + method_param.put("workorder", workorder); switch (region) { - case FJ: + case YZ: + String vehicle_type = point.getString("vehicle_type"); + if (StrUtil.isBlank(vehicle_type)) { + throw new BadRequestException("点位 [" + point_code + "] 无载具类型!"); + } + String vehicle_code = TaskUtils.formatVehicleCode(point.getString("vehicle_code")); + if ("0000".equals(vehicle_code)) { + throw new BadRequestException("点位 [" + point_code + "] 无载具编码!"); + } JSONObject vd_update = new JSONObject(); vd_update.put("is_delete", TrueOrFalse.TRUE.value()); + WQLObject + .getWQLObject("st_ivt_vehicle_detail") + .update(vd_update, "vehicle_type = " + vehicle_type + " AND vehicle_code = '" + vehicle_code + "'"); + + task_code = yzSendEmptyTask.createTask(method_param); + break; + case FJ: + vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code")); + if ("0000".equals(vehicle_code)) { + vehicle_code = point.getString("vehicle_code"); + if (StrUtil.isBlank(vehicle_code) || "0000".equals(vehicle_code)) { + throw new BadRequestException("载具编码不能为空!"); + } + } + method_param.put("vehicle_code", vehicle_code); + vd_update = new JSONObject(); + vd_update.put("is_delete", TrueOrFalse.TRUE.value()); WQLObject .getWQLObject("st_ivt_vehicle_detail") .update(vd_update, "vehicle_type = '2' AND vehicle_code = '" + vehicle_code + "'"); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java index 43768f8..a6be6b0 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java @@ -66,4 +66,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { return AcsUtil.notifyAcs(api, whereJson); } + @Override + public JSONObject light(JSONArray whereJson) { + String api = "api/wms/light"; + return AcsUtil.notifyAcs(api, whereJson); + } + } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/service/impl/WorkorderServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/service/impl/WorkorderServiceImpl.java index e31f214..c953859 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/service/impl/WorkorderServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/service/impl/WorkorderServiceImpl.java @@ -169,6 +169,13 @@ public class WorkorderServiceImpl implements WorkordeService { String now = DateUtil.now(); WQLObject wo = WQLObject.getWQLObject("PDM_BD_WorkOrder"); + JSONObject workorder = wo.query("is_delete = '0' AND workorder_id = " + ids[0]).uniqueResult(0); + if (ObjectUtil.isEmpty(workorder)) { + throw new BadRequestException("工单不存在或已删除!"); + } + if (workorder.getIntValue("order_status") > 1) { + throw new BadRequestException("工单已进入流程,无法删除!"); + } for (Long workorder_id : ids) { JSONObject param = new JSONObject(); param.put("workorder_id", String.valueOf(workorder_id)); @@ -190,13 +197,13 @@ public class WorkorderServiceImpl implements WorkordeService { .addParam("workorder_id", workorder_id) .process() .uniqueResult(0); - if (submit_obj.getIntValue("order_status") > 1) { + if (submit_obj.getIntValue("order_status") > 2) { throw new BadRequestException("工单已开工!"); } JSONObject workorder = WQLObject .getWQLObject("pdm_bd_workorder") - .query("is_delete = '0' AND device_id = '" + submit_obj.getString("device_id") + "' AND order_status IN ('2', '3')") + .query("is_delete = '0' AND device_id = '" + submit_obj.getString("device_id") + "' AND order_status = '3' AND workorder_id <> " + workorder_id) .uniqueResult(0); if (ObjectUtil.isNotEmpty(workorder)) { throw new BadRequestException("该设备正在执行其它工单!"); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoUpdateStandStatus.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoUpdateStandStatus.java new file mode 100644 index 0000000..9c9db86 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoUpdateStandStatus.java @@ -0,0 +1,89 @@ +package org.nl.wms.sch.manage; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.nl.modules.common.utils.CommonUtils; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.wms.basedata.eum.StandStatus; +import org.nl.wms.ext.acs.service.WmsToAcsService; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; + +/** + * @author zhangjiangwei + * @date 2023/05/10 10:48 + */ +@Slf4j +@RequiredArgsConstructor +@Component("autoUpdateStandStatus") +public class AutoUpdateStandStatus { + + private final WmsToAcsService wmsToAcsService; + + @SneakyThrows + public void run() { + JSONArray vds = WQL.getWO("MANAGE_QUERY").addParam("flag", "1").process().getResultJSONArray(0); + + if (ObjectUtil.isNotEmpty(vds)) { + ArrayList ids = new ArrayList<>(); + for (int i = 0; i < vds.size(); i++) { + JSONObject vd = vds.getJSONObject(i); + DateTime create_time = DateUtil.parse(vd.getString("create_time")); + DateTime time = DateUtil.offsetMinute(create_time, vd.getIntValue("standing_time")); + int compare = DateUtil.compare(DateUtil.date(), time); + if (compare >= 0) { + ids.add(vd.getLong("vd_id")); + } + } + + if (!ids.isEmpty()) { + JSONObject update = new JSONObject(); + update.put("stand_status", StandStatus.COMPLETED.value()); + WQLObject.getWQLObject("st_ivt_vehicle_detail").update(update, "vd_id IN " + CommonUtils.idsArrayToInStr(ids.toArray(new Long[0]))); + } + } + + vds = WQL.getWO("MANAGE_QUERY").addParam("flag", "2").process().getResultJSONArray(0); + + if (ObjectUtil.isNotEmpty(vds)) { + ArrayList ids = new ArrayList<>(); + for (int i = 0; i < vds.size(); i++) { + JSONObject vd = vds.getJSONObject(i); + DateTime create_time = DateUtil.parse(vd.getString("create_time")); + int threshold_time = vd.getIntValue("threshold_time"); + int standing_time = vd.getIntValue("standing_time"); + if (threshold_time != 0 && threshold_time < standing_time) { + DateTime time = DateUtil.offsetMinute(create_time, threshold_time); + int compare = DateUtil.compare(DateUtil.date(), time); + if (compare >= 0) { + ids.add(vd.getLong("vd_id")); + } + } + } + + if (!ids.isEmpty()) { + JSONObject update = new JSONObject(); + update.put("stand_status", StandStatus.TIMEOUT.value()); + WQLObject.getWQLObject("st_ivt_vehicle_detail").update(update, "vd_id IN " + CommonUtils.idsArrayToInStr(ids.toArray(new Long[0]))); + } + } + + JSONArray points = WQL.getWO("MANAGE_QUERY").addParam("flag", "3").process().getResultJSONArray(0); + if (ObjectUtil.isNotEmpty(vds)) { + JSONArray point_codes = new JSONArray(); + for (int i = 0; i < points.size(); i++) { + JSONObject point = points.getJSONObject(i); + point_codes.add(point.getString("point_code")); + } + wmsToAcsService.light(point_codes); + } + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/wql/MANAGE_QUERY.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/wql/MANAGE_QUERY.wql new file mode 100644 index 0000000..1decb7a --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/wql/MANAGE_QUERY.wql @@ -0,0 +1,87 @@ +[交易说明] + 交易名: manage + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + QUERY + SELECT + vd.*, + mb.standing_time + FROM + st_ivt_vehicle_detail vd + LEFT JOIN md_me_materialbase mb ON vd.material_id = mb.material_id + WHERE + vd.is_delete = '0' + AND vd.vehicle_type = '1' + AND vd.stand_status = '2' + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + vd.*, + mb.standing_time, + mb.threshold_time + FROM + st_ivt_vehicle_detail vd + LEFT JOIN md_me_materialbase mb ON vd.material_id = mb.material_id + WHERE + vd.is_delete = '0' + AND vd.vehicle_type = '1' + AND vd.stand_status IN ('3', '4') + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "3" + QUERY + SELECT + * + FROM + sch_base_point point + LEFT JOIN st_ivt_vehicle_detail vd ON point.vehicle_type = vd.vehicle_type + AND point.vehicle_code = vd.vehicle_code AND vd.is_delete = '0' + WHERE + point.region_code = 'KLHJ' + AND point.point_type = '2' + AND vd.stand_status > '2' + ENDSELECT + ENDQUERY + ENDIF \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/YZCallMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/YZCallMaterialTask.java new file mode 100644 index 0000000..89688fc --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/YZCallMaterialTask.java @@ -0,0 +1,231 @@ +package org.nl.wms.sch.task.call.material; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.wms.basedata.eum.TrueOrFalse; +import org.nl.wms.basedata.eum.VehicleType; +import org.nl.wms.sch.manage.*; +import org.nl.wms.sch.task.util.TaskUtils; +import org.springframework.stereotype.Component; + +/** + * @author zhangjiangwei + * @date 2023/05/10 10:04 + */ +@RequiredArgsConstructor +@Component +public class YZCallMaterialTask extends AbstractAcsTask { + + + @Override + public void updateTaskStatus(JSONObject task, String status) { + if (TaskStatus.EXECUTING.value().equals(status)) { + task.put("task_status", TaskStatus.EXECUTING.value()); + TaskUtils.addACSUpdateColum(task); + WQLObject.getWQLObject("sch_base_task").update(task); + } else if (TaskStatus.FINISHED.value().equals(status)) { + this.finishTask(task, OperationType.AUTO); + } else if (TaskStatus.CANCELLED.value().equals(status)) { + this.cancelTask(task, OperationType.AUTO); + } + } + + + @Override + public String createTask(JSONObject form) { + JSONObject point = form.getJSONObject("point"); + JSONObject workorder = form.getJSONObject("workorder"); + + JSONObject task = TaskUtils.buildTask( + "压制区叫料", + TaskType.CALL_MATERIAL.value(), + TaskStatus.SURE_END.value(), + null, + point.getString("point_code"), + null, + workorder.getString("material_id"), + VehicleType.CUP.value(), + null, + TrueOrFalse.trueOrFalse(workorder.getString("is_urgent")) ? 50 : 1, + YZCallMaterialTask.class.getName(), + form.getString("create_mode"), + form.getString("request_param"), + form.getString("create_id"), + form.getString("create_name") + ); + WQLObject.getWQLObject("sch_base_task").insert(task); + + point.put("lock_type", LockType.TASK_LOCKED.value()); + point.put("task_code", task.getString("task_code")); + TaskUtils.addFormUpdateColum(point, form); + WQLObject.getWQLObject("sch_base_point").update(point); + + return task.getString("task_code"); + } + + + @Override + public void findStartPoint() { + WQLObject task_table = WQLObject.getWQLObject("sch_base_task"); + JSONArray tasks = task_table + .query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_END.value() + "' AND handle_class = '" + YZCallMaterialTask.class.getName() + "'", "priority DESC, create_time ASC") + .getResultJSONArray(0); + if (ObjectUtil.isNotEmpty(tasks)) { + WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); + + for (int i = 0; i < tasks.size(); i++) { + JSONObject task = tasks.getJSONObject(i); + + JSONObject point = WQL + .getWO("CALL_MATERIAL_TASK") + .addParam("flag", "4") + .addParam("material_id", task.getString("material_id")) + .process() + .uniqueResult(0); + + if (ObjectUtil.isNotEmpty(point)) { + task.put("task_status", TaskStatus.START_AND_END.value()); + task.put("point_code1", point.getString("point_code")); + task.put("vehicle_code", TaskUtils.formatVehicleCode(point.getString("vehicle_code"))); + task.put("material_id", point.getString("material_id")); + task.put("remark", ""); + TaskUtils.addAutoUpdateColum(task); + task_table.update(task); + + JSONObject point_update = new JSONObject(); + point_update.put("lock_type", LockType.TASK_LOCKED.value()); + point_update.put("task_code", task.getString("task_code")); + TaskUtils.addAutoUpdateColum(point_update); + point_table.update(point_update, "point_id = " + point.getLongValue("point_id")); + } + } + } + } + + + @Override + public void forceFinish(String task_id) { + JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0); + if (ObjectUtil.isEmpty(task)) { + throw new BadRequestException("未找到任务!"); + } + this.finishTask(task, OperationType.MANUAL); + } + + + @Override + public void cancel(String task_id) { + JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0); + if (ObjectUtil.isEmpty(task)) { + throw new BadRequestException("未找到任务!"); + } + this.cancelTask(task, OperationType.MANUAL); + } + + + public void cancelTask(JSONObject task, OperationType operation_type) { + if (task.getIntValue("task_status") < Integer.parseInt(TaskStatus.FINISHED.value())) { + task.put("task_status", TaskStatus.CANCELLED.value()); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(task); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(task); + } + WQLObject.getWQLObject("sch_base_task").update(task); + + WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); + + String point_code1 = task.getString("point_code1"); + if (StrUtil.isNotBlank(point_code1)) { + JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(point1) + && LockType.TASK_LOCKED.value().equals(point1.getString("lock_type")) + && task.getString("task_code").equals(point1.getString("task_code"))) { + point1.put("lock_type", LockType.UNLOCKED.value()); + point1.put("task_code", ""); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(point1); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(point1); + } + point_table.update(point1); + } + } + + String point_code2 = task.getString("point_code2"); + if (StrUtil.isNotBlank(point_code2)) { + JSONObject point2 = new JSONObject(); + point2.put("lock_type", LockType.UNLOCKED.value()); + point2.put("task_code", ""); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(point2); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(point2); + } + point_table.update(point2, "point_code = '" + point_code2 + "'"); + } + } + } + + + public void finishTask(JSONObject task, OperationType operation_type) { + int current_task_status = task.getIntValue("task_status"); + if (current_task_status < Integer.parseInt(TaskStatus.FINISHED.value())) { + if (operation_type == OperationType.MANUAL + && current_task_status < Integer.parseInt(TaskStatus.START_AND_END.value())) { + throw new BadRequestException("只能手动完成 [确认起点和终点] 之后的任务!"); + } + + task.put("task_status", TaskStatus.FINISHED.value()); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(task); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(task); + } + WQLObject.getWQLObject("sch_base_task").update(task); + + WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); + + String point_code1 = task.getString("point_code1"); + if (StrUtil.isNotBlank(point_code1)) { + JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0); + if (LockType.TASK_LOCKED.value().equals(point1.getString("lock_type")) + && task.getString("task_code").equals(point1.getString("task_code"))) { + point1.put("lock_type", LockType.UNLOCKED.value()); + point1.put("task_code", ""); + point1.put("vehicle_type", ""); + point1.put("vehicle_code", ""); + point1.put("point_status", PointStatus.EMPTY.value()); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(point1); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(point1); + } + point_table.update(point1); + } + } + + String point_code2 = task.getString("point_code2"); + if (StrUtil.isNotBlank(point_code2)) { + JSONObject point2 = new JSONObject(); + point2.put("lock_type", LockType.UNLOCKED.value()); + point2.put("task_code", ""); + point2.put("vehicle_type", task.getString("vehicle_type")); + point2.put("vehicle_code", task.getString("vehicle_code")); + point2.put("point_status", PointStatus.NOT_EMPTY.value()); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(point2); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(point2); + } + point_table.update(point2, "point_code = '" + point_code2 + "'"); + } + } + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/wql/CALL_MATERIAL_TASK.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/wql/CALL_MATERIAL_TASK.wql index 16f1e35..666efde 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/wql/CALL_MATERIAL_TASK.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/wql/CALL_MATERIAL_TASK.wql @@ -104,3 +104,32 @@ ENDSELECT ENDQUERY ENDIF + + IF 输入.flag = "4" + QUERY + SELECT + point.*, + mb1.material_id + FROM + sch_base_point point + LEFT JOIN st_ivt_vehicle_detail vd ON point.vehicle_type = vd.vehicle_type + AND point.vehicle_code = vd.vehicle_code + AND vd.is_delete = '0' + LEFT JOIN md_me_materialbase mb1 ON vd.material_id = mb1.material_id + LEFT JOIN md_me_material_detail md ON mb1.material_code = md.bom_code + LEFT JOIN md_me_materialbase mb2 ON md.material_id = mb2.material_id + LEFT JOIN pdm_bd_workorder workorder ON vd.workorder_id = workorder.workorder_id + WHERE + point.is_used = '1' + AND point.lock_type = '1' + AND point.region_code = 'KLHJ' + AND point.point_type = '1' + AND point.point_status = '1' + AND point.vehicle_type = '1' + AND mb2.material_id = 输入.material_id + AND vd.stand_status IN ('3', '4') + ORDER BY + workorder.is_urgent DESC, vd.create_time ASC + ENDSELECT + ENDQUERY + ENDIF diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java index 9c5af69..0492a3e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java @@ -8,6 +8,7 @@ import lombok.RequiredArgsConstructor; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.wql.WQL; import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.wms.basedata.eum.TrueOrFalse; import org.nl.wms.basedata.eum.VehicleType; import org.nl.wms.sch.manage.*; import org.nl.wms.sch.task.util.TaskUtils; @@ -39,6 +40,11 @@ public class FJSendEmptyTask extends AbstractAcsTask { @Override public String createTask(JSONObject form) { JSONObject point = form.getJSONObject("point"); + JSONObject work_order = form.getJSONObject("workorder"); + int priority = 1; + if (ObjectUtil.isNotEmpty(work_order)) { + priority = TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1; + } JSONObject task = TaskUtils.buildTask( "分拣区送空", @@ -50,7 +56,7 @@ public class FJSendEmptyTask extends AbstractAcsTask { null, VehicleType.STEEL_TRAY.value(), form.getString("vehicle_code"), - 1, + priority, FJSendEmptyTask.class.getName(), form.getString("create_mode"), form.getString("request_param"), diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/YZSendEmptyTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/YZSendEmptyTask.java new file mode 100644 index 0000000..d3fafce --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/YZSendEmptyTask.java @@ -0,0 +1,231 @@ +package org.nl.wms.sch.task.send.empty; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.wms.basedata.eum.TrueOrFalse; +import org.nl.wms.basedata.eum.VehicleType; +import org.nl.wms.sch.manage.*; +import org.nl.wms.sch.task.util.TaskUtils; +import org.springframework.stereotype.Component; + +/** + * @author zhangjiangwei + * @date 2023/05/10 10:25 + */ +@RequiredArgsConstructor +@Component +public class YZSendEmptyTask extends AbstractAcsTask { + + + @Override + public void updateTaskStatus(JSONObject task, String status) { + if (TaskStatus.EXECUTING.value().equals(status)) { + task.put("task_status", TaskStatus.EXECUTING.value()); + TaskUtils.addACSUpdateColum(task); + WQLObject.getWQLObject("sch_base_task").update(task); + } else if (TaskStatus.FINISHED.value().equals(status)) { + this.finishTask(task, OperationType.AUTO); + } else if (TaskStatus.CANCELLED.value().equals(status)) { + this.cancelTask(task, OperationType.AUTO); + } + } + + + @Override + public String createTask(JSONObject form) { + JSONObject point = form.getJSONObject("point"); + JSONObject work_order = form.getJSONObject("workorder"); + int priority = 1; + if (ObjectUtil.isNotEmpty(work_order)) { + priority = TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1; + } + + JSONObject task = TaskUtils.buildTask( + "压制区送空", + TaskType.SEND_EMPTY.value(), + TaskStatus.SURE_START.value(), + point.getString("point_code"), + null, + null, + null, + point.getString("vehicle_type"), + point.getString("vehicle_code"), + priority, + YZSendEmptyTask.class.getName(), + form.getString("create_mode"), + form.getString("request_param"), + form.getString("create_id"), + form.getString("create_name") + ); + WQLObject.getWQLObject("sch_base_task").insert(task); + + point.put("lock_type", LockType.TASK_LOCKED.value()); + point.put("task_code", task.getString("task_code")); + TaskUtils.addFormUpdateColum(point, form); + WQLObject.getWQLObject("sch_base_point").update(point); + + return task.getString("task_code"); + } + + + @Override + public void findNextPoint() { + WQLObject task_table = WQLObject.getWQLObject("sch_base_task"); + JSONArray tasks = task_table + .query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_START.value() + "' AND handle_class = '" + YZSendEmptyTask.class.getName() + "'", "priority DESC, create_time ASC") + .getResultJSONArray(0); + if (ObjectUtil.isNotEmpty(tasks)) { + WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); + + for (int i = 0; i < tasks.size(); i++) { + JSONObject task = tasks.getJSONObject(i); + + JSONObject point = WQL + .getWO("SEND_EMPTY_TASK") + .addParam("flag", "2") + .process() + .uniqueResult(0); + + if (ObjectUtil.isNotEmpty(point)) { + task.put("task_status", TaskStatus.START_AND_END.value()); + task.put("point_code2", point.getString("point_code")); + task.put("remark", ""); + TaskUtils.addAutoUpdateColum(task); + task_table.update(task); + + point.put("lock_type", LockType.TASK_LOCKED.value()); + point.put("task_code", task.getString("task_code")); + TaskUtils.addAutoUpdateColum(point); + point_table.update(point); + } + } + } + } + + + @Override + public void forceFinish(String task_id) { + JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0); + if (ObjectUtil.isEmpty(task)) { + throw new BadRequestException("未找到任务!"); + } + this.finishTask(task, OperationType.MANUAL); + } + + + @Override + public void cancel(String task_id) { + JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0); + if (ObjectUtil.isEmpty(task)) { + throw new BadRequestException("未找到任务!"); + } + this.cancelTask(task, OperationType.MANUAL); + } + + + public void cancelTask(JSONObject task, OperationType operation_type) { + if (task.getIntValue("task_status") < Integer.parseInt(TaskStatus.FINISHED.value())) { + task.put("task_status", TaskStatus.CANCELLED.value()); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(task); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(task); + } + WQLObject.getWQLObject("sch_base_task").update(task); + + WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); + + String point_code1 = task.getString("point_code1"); + if (StrUtil.isNotBlank(point_code1)) { + JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0); + if (LockType.TASK_LOCKED.value().equals(point1.getString("lock_type")) + && task.getString("task_code").equals(point1.getString("task_code"))) { + point1.put("lock_type", LockType.UNLOCKED.value()); + point1.put("task_code", ""); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(point1); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(point1); + } + point_table.update(point1); + } + } + + String point_code2 = task.getString("point_code2"); + if (StrUtil.isNotBlank(point_code2)) { + JSONObject point2 = new JSONObject(); + point2.put("lock_type", LockType.UNLOCKED.value()); + point2.put("task_code", ""); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(point2); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(point2); + } + point_table.update(point2, "point_code = '" + point_code2 + "'"); + } + } + } + + + public void finishTask(JSONObject task, OperationType operation_type) { + int current_task_status = task.getIntValue("task_status"); + if (current_task_status < Integer.parseInt(TaskStatus.FINISHED.value())) { + if (operation_type == OperationType.MANUAL + && current_task_status < Integer.parseInt(TaskStatus.START_AND_END.value())) { + throw new BadRequestException("只能手动完成 [确认起点和终点] 之后的任务!"); + } + + task.put("task_status", TaskStatus.FINISHED.value()); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(task); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(task); + } + WQLObject.getWQLObject("sch_base_task").update(task); + + WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); + + String point_code1 = task.getString("point_code1"); + if (StrUtil.isNotBlank(point_code1)) { + JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(point1) + && LockType.TASK_LOCKED.value().equals(point1.getString("lock_type")) + && task.getString("task_code").equals(point1.getString("task_code"))) { + point1.put("lock_type", LockType.UNLOCKED.value()); + point1.put("task_code", ""); + point1.put("vehicle_type", ""); + point1.put("vehicle_code", ""); + point1.put("point_status", PointStatus.EMPTY.value()); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(point1); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(point1); + } + point_table.update(point1); + } + } + + String point_code2 = task.getString("point_code2"); + if (StrUtil.isNotBlank(point_code2)) { + JSONObject point2 = new JSONObject(); + point2.put("lock_type", LockType.UNLOCKED.value()); + point2.put("task_code", ""); + point2.put("vehicle_type", task.getString("vehicle_type")); + point2.put("vehicle_code", task.getString("vehicle_code")); + point2.put("point_status", PointStatus.NOT_EMPTY.value()); + if (operation_type == OperationType.AUTO) { + TaskUtils.addACSUpdateColum(point2); + } else if (operation_type == OperationType.MANUAL) { + TaskUtils.addCurrentUpdateColum(point2); + } + point_table.update(point2, "point_code = '" + point_code2 + "'"); + } + } + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql index e929233..30bfa1d 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql @@ -55,3 +55,19 @@ ENDSELECT ENDQUERY ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + * + FROM + sch_base_point + WHERE + is_used = '1' + AND lock_type = '1' + AND point_status = '0' + AND region_code = 'KLHJ' + AND point_type = '1' + ENDSELECT + ENDQUERY + ENDIF diff --git a/lms/nladmin-system/src/test/java/org/nl/test/TempTest.java b/lms/nladmin-system/src/test/java/org/nl/test/TempTest.java index 28ce95b..5e33959 100644 --- a/lms/nladmin-system/src/test/java/org/nl/test/TempTest.java +++ b/lms/nladmin-system/src/test/java/org/nl/test/TempTest.java @@ -1,17 +1,24 @@ package org.nl.test; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.junit.Test; import org.junit.runner.RunWith; +import org.nl.modules.common.utils.CommonUtils; import org.nl.modules.wql.WQL; import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.modules.wql.util.SpringContextHolder; +import org.nl.wms.basedata.eum.StandStatus; +import org.nl.wms.ext.acs.service.WmsToAcsService; import org.nl.wms.sch.manage.LockType; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import java.util.ArrayList; import java.util.Set; /** @@ -24,12 +31,58 @@ public class TempTest { @Test public void test01() { - JSONObject data = WQL - .getWO("SEND_MATERIAL_TASK") - .addParam("flag", "4") - .addParam("is_full", "0") - .process() - .uniqueResult(0); - System.out.println(data.getString("region_name")); + JSONArray vds = WQL.getWO("MANAGE_QUERY").addParam("flag", "1").process().getResultJSONArray(0); + + if (ObjectUtil.isNotEmpty(vds)) { + ArrayList ids = new ArrayList<>(); + for (int i = 0; i < vds.size(); i++) { + JSONObject vd = vds.getJSONObject(i); + DateTime create_time = DateUtil.parse(vd.getString("create_time")); + DateTime time = DateUtil.offsetMinute(create_time, vd.getIntValue("standing_time")); + int compare = DateUtil.compare(DateUtil.date(), time); + if (compare >= 0) { + ids.add(vd.getLong("vd_id")); + } + } + + JSONObject update = new JSONObject(); + update.put("stand_status", StandStatus.COMPLETED.value()); + WQLObject.getWQLObject("st_ivt_vehicle_detail").update(update, "vd_id IN " + CommonUtils.idsArrayToInStr(ids.toArray(new Long[0]))); + } + + vds = WQL.getWO("MANAGE_QUERY").addParam("flag", "2").process().getResultJSONArray(0); + + if (ObjectUtil.isNotEmpty(vds)) { + ArrayList ids = new ArrayList<>(); + for (int i = 0; i < vds.size(); i++) { + JSONObject vd = vds.getJSONObject(i); + DateTime create_time = DateUtil.parse(vd.getString("create_time")); + int threshold_time = vd.getIntValue("threshold_time"); + int standing_time = vd.getIntValue("standing_time"); + if (threshold_time != 0 && threshold_time < standing_time) { + DateTime time = DateUtil.offsetMinute(create_time, threshold_time); + int compare = DateUtil.compare(DateUtil.date(), time); + if (compare >= 0) { + ids.add(vd.getLong("vd_id")); + } + } + } + + if (!ids.isEmpty()) { + JSONObject update = new JSONObject(); + update.put("stand_status", StandStatus.TIMEOUT.value()); + WQLObject.getWQLObject("st_ivt_vehicle_detail").update(update, "vd_id IN " + CommonUtils.idsArrayToInStr(ids.toArray(new Long[0]))); + } + } + + JSONArray points = WQL.getWO("MANAGE_QUERY").addParam("flag", "3").process().getResultJSONArray(0); + if (ObjectUtil.isNotEmpty(vds)) { + JSONArray point_codes = new JSONArray(); + for (int i = 0; i < points.size(); i++) { + JSONObject point = points.getJSONObject(i); + point_codes.add(point.getString("point_code")); + } + SpringContextHolder.getBean(WmsToAcsService.class).light(point_codes); + } } } diff --git a/lms/nladmin-ui/src/utils/nladmin.js b/lms/nladmin-ui/src/utils/nladmin.js index 371bcb1..e6bc266 100644 --- a/lms/nladmin-ui/src/utils/nladmin.js +++ b/lms/nladmin-ui/src/utils/nladmin.js @@ -257,7 +257,7 @@ export function flexWidth(prop, tableData, title, num = 0) { const column_w = context.measureText(columnContent).width const title_w = context.measureText(title).width if (column_w < title_w) { - columnContent = title || '留四个字' + columnContent = title } // 计算最宽内容的列宽 const width = context.measureText(columnContent) diff --git a/lms/nladmin-ui/src/views/wms/pdm/workerorder/hl/index.vue b/lms/nladmin-ui/src/views/wms/pdm/workerorder/hl/index.vue index be2dacc..970ec02 100644 --- a/lms/nladmin-ui/src/views/wms/pdm/workerorder/hl/index.vue +++ b/lms/nladmin-ui/src/views/wms/pdm/workerorder/hl/index.vue @@ -136,8 +136,8 @@ - - + + @@ -177,7 +177,7 @@ - + - +