diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/callEmpty/HnCallEmptyVehicleTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/callEmpty/HnCallEmptyVehicleTask.java index ff6bec8..518ad9b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/callEmpty/HnCallEmptyVehicleTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/callEmpty/HnCallEmptyVehicleTask.java @@ -26,7 +26,7 @@ import java.util.List; /** * @author: lyd - * @description: 混碾呼叫空托盘 + * @description: 混碾呼叫空盅 * @Date: 2022/11/9 */ @Service @@ -152,11 +152,8 @@ public class HnCallEmptyVehicleTask extends AbstractAcsTask { JSONObject taskObj = taskTab.query("is_delete='0' and point_code2 = '" + form.getString("point_code2") + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0); if (ObjectUtil.isNotEmpty(taskObj)) throw new BadRequestException("当前点位" + form.getString("point_code2") + "存在未完成的任务"); - String point_code2 = form.getString("point_code2"); - String sub_device_code = point_code2.substring(0, point_code2.indexOf("_")); - - String device_code = pointTab.query("point_code = '" + sub_device_code + "'").uniqueResult(0).getString("device_code"); + String device_code = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0).getString("device_code"); JSONObject workOrderObj = workOrderTab.query("device_code = '" + device_code + "' and order_status = '3' and is_delete ='0'").uniqueResult(0); if (ObjectUtil.isEmpty(workOrderObj)) throw new BadRequestException("该设备当前未生产或者已删除"); @@ -164,7 +161,7 @@ public class HnCallEmptyVehicleTask extends AbstractAcsTask { SchTaskDto dto = SchTaskDto.builder().task_id(org.nl.wms.util.IdUtil.getLongId()) .task_code(CodeUtil.getNewCode("TASK_CODE")) .task_type("") - .task_name("混碾机叫空载具") + .task_name("混碾机叫空盅") .task_status(TaskStatusEnum.SURE_END.getCode()) .point_code2(point_code2) .acs_task_type("2") @@ -174,6 +171,7 @@ public class HnCallEmptyVehicleTask extends AbstractAcsTask { .task_group_id(org.nl.wms.util.IdUtil.getLongId()) .handle_class(THIS_CLASS) .create_time(DateUtil.now()) + .request_param(form.toJSONString()) .build(); JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); taskTab.insert(json); @@ -192,17 +190,22 @@ public class HnCallEmptyVehicleTask extends AbstractAcsTask { public void findStartPoint() { WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); // 任务表 WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); // 点位表 + WQLObject workOrderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder"); // 工单表 JSONArray taskArr = taskTab.query("is_delete = '0' and handle_class = '" + this.THIS_CLASS + "' and task_status = '" + TaskStatusEnum.SURE_END.getCode() + "'").getResultJSONArray(0); for (int i = 0; i < taskArr.size(); i++) { // 创建任务 JSONObject taskObj = taskArr.getJSONObject(i); - String vehicle_type = taskObj.getString("vehicle_type"); + // 获取工单 + String point_code2 = taskObj.getString("point_code2"); + String device_code = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0).getString("device_code"); + JSONObject workOrderObj = workOrderTab.query("device_code = '" + device_code + "' and order_status = '3' and is_delete ='0'").uniqueResult(0); + JSONObject param1 = new JSONObject(); param1.put("flag", "1"); param1.put("region_code", "KLHJ"); - param1.put("vehicle_type", "%" + vehicle_type + "%"); - // 直接到困料货架找一个空载具 + param1.put("is_new", workOrderObj.getString("is_new")); + // 直接到困料货架找一个空载具 (需要区分新旧载具) JSONObject startPoint = WQL.getWO("QSCH_hnCallEmptyVehicle_01").addParamMap(param1).process().uniqueResult(0); if (ObjectUtil.isEmpty(startPoint)) { taskObj.put("remark", "困料货架无可用载具!"); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/callEmpty/wql/QSCH_hnCallEmptyVehicle_01.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/callEmpty/wql/QSCH_hnCallEmptyVehicle_01.wql index 2dcd046..9b9be89 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/callEmpty/wql/QSCH_hnCallEmptyVehicle_01.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/callEmpty/wql/QSCH_hnCallEmptyVehicle_01.wql @@ -14,9 +14,9 @@ ## 表字段对应输入参数 ################################################# 输入.flag TYPEAS s_string - 输入.region_code TYPEAS s_string - 输入.material_id TYPEAS s_string - 输入.vehicle_type TYPEAS s_string + 输入.region_code TYPEAS s_string + 输入.material_id TYPEAS s_string + 输入.is_new TYPEAS s_string [临时表] @@ -48,18 +48,18 @@ IF 输入.flag = "1" p.point_name FROM SCH_BASE_Point p + LEFT JOIN md_pb_vehicle vehicle ON vehicle.vehicle_code = p.vehicle_code WHERE lock_type = '1' AND is_used = '1' AND is_delete = '0' AND point_status = '2' - OPTION 输入.vehicle_type <> "" - p.can_vehicle_type like 输入.vehicle_type - ENDOPTION OPTION 输入.region_code <> "" p.region_code = 输入.region_code ENDOPTION - ORDER BY col_num,row_num,layer_num + OPTION 输入.is_new <> "" + vehicle.is_new = 输入.is_new + ENDOPTION ENDSELECT ENDQUERY ENDIF diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/sendEmpty/HnSendEmpVehicleTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/sendEmpty/HnSendEmpVehicleTask.java deleted file mode 100644 index cbe5126..0000000 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/sendEmpty/HnSendEmpVehicleTask.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.nl.wms.sch.tasks.sendEmpty; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.modules.common.exception.BadRequestException; -import org.nl.modules.common.utils.SecurityUtils; -import org.nl.modules.system.util.CodeUtil; -import org.nl.modules.wql.core.bean.WQLObject; -import org.nl.wms.sch.SchTaskDto; -import org.nl.wms.sch.manage.AbstractAcsTask; -import org.nl.wms.sch.manage.TaskStatusEnum; -import org.nl.wms.sch.tasks.AcsTaskDto; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * @author: lyd - * @description: 混碾送空盅 - * @Date: 2022/11/15 - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class HnSendEmpVehicleTask extends AbstractAcsTask { - private final String THIS_CLASS = HnSendEmpVehicleTask.class.getName(); - /** - * 添加任务进行下发 - * - * @return - */ - @Override - public List addTask() { - return null; - } - - /** - * @param taskObj 代表一条任务对象 - * @param status 代表wcs任务完成状态: //0:acs,取消,:执行中,2:完成 - * @return - * @discription wcs请求wms任务完成状态反馈接口, 比如agv从a点往b点走。生成任务的时候绑定b的物料信息,任务完成的时候,清除a的物料信息 - * @author ldjun - * @created 2019年4月17日 下午8:51:50 - */ - @Override - public void updateTaskStatus(JSONObject taskObj, String status) { - WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); - WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); - - String task_id = taskObj.getString("task_id"); - String point_code2 = taskObj.getString("point_code2"); - JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0); - - if (StrUtil.equals(status, "0")) { - // 取消删除任务 - if (StrUtil.equals(jsonTask.getString("task_status"), TaskStatusEnum.FINISHED.getCode())) { - throw new BadRequestException("已完成不能取消!"); - } - // 解锁终点位置 - if (ObjectUtil.isNotEmpty(point_code2)) { // 未找到终点的取消只需要完成任务就行 - JSONObject point2 = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0); - point2.put("lock_type", "1"); - pointTab.update(point2); - } - // 任务设置为完成 - jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode()); - jsonTask.put("remark", "已取消"); - taskTab.update(jsonTask); - } - - if (TaskStatusEnum.EXECUTING.getCode().equals(status)) { - // 更新任务状态为执行中 - jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode()); - jsonTask.put("update_time", DateUtil.now()); - jsonTask.put("car_no", taskObj.getString("car_no")); - taskTab.update(jsonTask); - } - - if (StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) { - // 更改任务状态为完成 - jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode()); - jsonTask.put("update_optid", SecurityUtils.getCurrentUserId()); - jsonTask.put("update_optname", SecurityUtils.getCurrentUsername()); - jsonTask.put("update_time", DateUtil.now()); - taskTab.update(jsonTask); - // 释放点位 - if (ObjectUtil.isNotEmpty(point_code2)) { // 防止只有确定起点的任务完成 - JSONObject point_2 = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0); - point_2.put("lock_type", "1"); - point_2.put("point_status", "2"); - point_2.put("vehicle_code", jsonTask.getString("vehicle_code")); - point_2.put("vehicle_qty", "1"); // 混碾送的空盅一个放一个位置,所以只设一个 - point_2.put("instorage_time", DateUtil.now()); - point_2.put("is_full", "1"); - point_2.put("ivt_qty", "0"); - point_2.put("pcsn", ""); - point_2.put("material_id", ""); - point_2.put("standing_time", "0"); - pointTab.update(point_2); - } - } - } - - /** - * @param form 创建任务需要的参数 - * @return 返回任务标识 - */ - @Override - public String createTask(JSONObject form) { - // 送到困料货架,盅 - WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); // 任务表 - - String point_code1 = form.getString("point_code1"); - - SchTaskDto dto = SchTaskDto.builder().task_id(org.nl.wms.util.IdUtil.getLongId()) - .task_code(CodeUtil.getNewCode("TASK_CODE")) - .task_type("") - .task_name("分拣空钢托盘入库") - .task_status(TaskStatusEnum.SURE_START.getCode()) - .point_code1(point_code1) - .vehicle_code(form.getString("vehicle_code")) - .vehicle_type(form.getString("vehicle_type")) - .vehicle_qty(form.getIntValue("qty")) - .handle_class(THIS_CLASS) - .create_time(DateUtil.now()) - .build(); - JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); - taskTab.insert(json); - this.immediateNotifyAcs(); - return String.valueOf(dto.getTask_id()); - } - - /** - * @return - * @discription 确定下一点位 - * @author ldjun - * @created 2020年6月12日 下午6:01:06 - */ - @Override - public void findNextPoint() { - // 找困料货架 - WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); - WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); - - JSONArray taskArr = taskTab.query("handle_class = '" + THIS_CLASS + "'and is_delete = '0' and task_status = '2'").getResultJSONArray(0); - for (int i = 0; i < taskArr.size(); i++) { - JSONObject taskObj = taskArr.getJSONObject(i); - // 直接找 - JSONObject endPoint = pointTab.query("region_code = 'KLHJ' AND lock_type = '1' AND is_used='1' AND point_type = '1'").uniqueResult(0); - if (ObjectUtil.isEmpty(endPoint)) { - taskObj.put("remark", "困料货架无可用货位!"); - taskObj.put("task_status", TaskStatusEnum.SURE_START.getCode()); - taskObj.put("update_time", DateUtil.now()); - taskTab.update(taskObj); - } else { - taskObj.put("update_time", DateUtil.now()); - taskObj.put("point_code2", endPoint.getString("point_code")); - taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode()); - taskTab.update(taskObj); - - //锁住终点 - endPoint.put("task_id", taskObj.getString("task_id")); - endPoint.put("lock_type", "2"); - pointTab.update(endPoint); - } - } - } - - /** - * @param task_id 任务标识 - * @return - * @discription 强制结束完成任务 - * @author ldjun - * @created 2020年6月19日 上午10:34:58 - */ - @Override - public void forceFinish(String task_id) { - - } - - /** - * 取消任务,货物搬回原点 - * - * @param task_id - */ - @Override - public void cancel(String task_id) { - - } -} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/sendEmpty/wql/QSCH_hnSendEmptyVehicle_01.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/sendEmpty/wql/QSCH_yzjSendEmptyVehicle_01.wql similarity index 100% rename from lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/sendEmpty/wql/QSCH_hnSendEmptyVehicle_01.wql rename to lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/sendEmpty/wql/QSCH_yzjSendEmptyVehicle_01.wql