From 3b0edf8b37ec680fe185a8831c96908175560c6a Mon Sep 17 00:00:00 2001 From: liuxy Date: Tue, 18 Oct 2022 11:06:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mps/service/impl/BakingServiceImpl.java | 238 +++++++++++------- .../wms/pda/mps/wql/PDA_OVENINANDOUT_01.wql | 23 ++ .../org/nl/wms/pda/mps/wql/PDA_RAWFOIL_01.wql | 3 +- .../org/nl/wms/sch/tasks/CallEmpReelTask.java | 4 +- .../org/nl/wms/sch/tasks/InCoolIvtTask.java | 155 ++++++++++++ .../java/org/nl/wms/sch/tasks/InHotTask.java | 164 ++++++++---- 6 files changed, 440 insertions(+), 147 deletions(-) create mode 100644 lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/InCoolIvtTask.java diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/service/impl/BakingServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/service/impl/BakingServiceImpl.java index 1994eae16..5afe99ed2 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/service/impl/BakingServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/service/impl/BakingServiceImpl.java @@ -15,6 +15,7 @@ import org.nl.modules.wql.WQL; import org.nl.modules.wql.core.bean.WQLObject; import org.nl.wms.pda.mps.service.BakingService; import org.nl.wms.sch.manage.RegionTypeEnum; +import org.nl.wms.sch.tasks.InCoolIvtTask; import org.nl.wms.sch.tasks.InHotTask; import org.nl.wms.sch.tasks.OutHotTask; import org.springframework.stereotype.Service; @@ -70,22 +71,22 @@ public class BakingServiceImpl implements BakingService { */ JSONObject jsonPointZc = pointTab.query("point_code = '" + point_code1 + "'").uniqueResult(0); if (ObjectUtil.isNotEmpty(jsonPointZc)) { - // 暂存区入烘箱 - - // 查询烘箱对应的空位 + /* + * 暂存区入烘箱 + */ + // 1.查询烘箱对应的空位 JSONObject jsonHotIvt = hosIvtTab.query("product_area = '" + jsonPointZc.getString("product_area") + "' and temperature = '" + temperature + "' and point_location = '"+jsonPointZc.getString("point_location")+"' and is_used = '1' and point_status = '01' order by point_code ASC").uniqueResult(0); if (ObjectUtil.isEmpty(jsonHotIvt)) throw new BadRequestException("烘烤区没有对应空位"); - // 创建暂存位 --> 烘烤区任务 + // 2.创建暂存位 --> 烘烤区任务 JSONObject param = new JSONObject(); param.put("type","2"); // 1- 冷却区入烘箱 2- 暂存位入烘箱 param.put("point_code1",point_code1); param.put("point_code2",jsonHotIvt.getString("point_code")); - // 创建冷却区 --> 暂存位的任务 InHotTask inHotTask = new InHotTask(null); String task_id = inHotTask.createTask(param); - // 插入明细明细 + // 3.插入明细明细 JSONObject jsonHotReMst = hosReMstTab.query("container_name = '" + container_name + "' and bill_status <> '50' and is_delete = '0'").uniqueResult(0); if (ObjectUtil.isEmpty(jsonHotReMst)) throw new BadRequestException("烘箱区出入主表不存在"); @@ -99,96 +100,108 @@ public class BakingServiceImpl implements BakingService { hotParam.put("oven_time",hours); this.createHotDtl(hotParam); - } - - // 1.根据冷却区此母卷的点位找到对应的暂存区、找到空位 - JSONObject jsonCoolIvt = coolIvtTab.query("container_name ='" + container_name + "' and is is_used = '1' and full_point_status = '02'").uniqueResult(0); - if (ObjectUtil.isEmpty(jsonCoolIvt)) throw new BadRequestException("母卷不存在"); - - String product_area = jsonCoolIvt.getString("product_area"); // 生产区域 - String point_location = jsonCoolIvt.getString("point_location"); // 位置 - String reging_id = ""; - - switch (product_area) { - case "A": - reging_id = RegionTypeEnum.A_HKZC.getId(); - break; - case "B": - reging_id = RegionTypeEnum.B_HKZC.getId(); - break; - case "C": - reging_id = RegionTypeEnum.C_HKZC.getId(); - break; - case "D": - reging_id = RegionTypeEnum.D_HKZC.getId(); - break; - } - JSONObject map = new JSONObject(); - map.put("flag", "1"); - map.put("reging_id", reging_id); - map.put("point_location", point_location); - - JSONArray pointArr = WQL.getWO("PDA_OVENINANDOUT_01").addParamMap(map).process().getResultJSONArray(0); - if (ObjectUtil.isEmpty(pointArr)) { - if (StrUtil.equals(point_location, "0")) map.put("point_location","1"); - if (StrUtil.equals(point_location, "1")) map.put("point_location","0"); - pointArr = WQL.getWO("PDA_OVENINANDOUT_01").addParamMap(map).process().getResultJSONArray(0); - - if (ObjectUtil.isEmpty(pointArr)) throw new BadRequestException("没有空暂存位"); - } - - // 2.判断暂存位是否有任务:找到无任务的暂存位 、查询烘箱对应的空位 - String point_code2 = ""; - for (int i = 0; i < pointArr.size(); i++) { - JSONObject jsonPoint = pointArr.getJSONObject(i); - String point_code = jsonPoint.getString("point_code"); - - JSONObject json_point_code1 = taskTab.query("point_code1 = '" + point_code + "' and task_status != '99' and is_delete = '0'").uniqueResult(0); - JSONObject json_point_code2 = taskTab.query("point_code2 = '" + point_code + "' and task_status != '99' and is_delete = '0'").uniqueResult(0); - JSONObject json_point_code3 = taskTab.query("point_code3 = '" + point_code + "' and task_status != '99' and is_delete = '0'").uniqueResult(0); - JSONObject json_point_code4 = taskTab.query("point_code4 = '" + point_code + "' and task_status != '99' and is_delete = '0'").uniqueResult(0); - if (ObjectUtil.isEmpty(json_point_code1) && ObjectUtil.isEmpty(json_point_code2) && ObjectUtil.isEmpty(json_point_code3) && ObjectUtil.isEmpty(json_point_code4)) { - point_code2 = point_code; - break; + // 4.下发任务 + JSONObject jsonObject = inHotTask.renotifyAcs(task_id); + if (StrUtil.equals(jsonObject.getString("status"), "200")) { + // 成功返回 更新任务状态 + JSONObject jsonTask = taskTab.query("task_id ='" + task_id + "'").uniqueResult(0); + jsonTask.put("task_status", "05"); + taskTab.update(jsonTask); } - } - if (ObjectUtil.isEmpty(point_code2)) throw new BadRequestException("没有空暂存位"); + } else { + /* + * 冷却区入烘箱 + */ + // 1.根据冷却区此母卷的点位找到对应的暂存区、找到空位 + JSONObject jsonCoolIvt = coolIvtTab.query("container_name ='" + container_name + "' and is is_used = '1' and full_point_status = '02' and cool_ivt_status = '01'").uniqueResult(0); + if (ObjectUtil.isEmpty(jsonCoolIvt)) throw new BadRequestException("母卷不存在"); - // 查询烘箱对应的空位 - JSONObject jsonHotIvt = hosIvtTab.query("product_area = '" + product_area + "' and temperature = '" + temperature + "' and point_location = '"+map.getString("point_location")+"' and is_used = '1' and point_status = '01' order by point_code ASC").uniqueResult(0); - if (ObjectUtil.isEmpty(jsonHotIvt)) throw new BadRequestException("烘烤区没有对应空位"); + String product_area = jsonCoolIvt.getString("product_area"); // 生产区域 + String point_location = jsonCoolIvt.getString("point_location"); // 位置 + String reging_id = ""; - // 3.创建冷却区 --> 烘烤区任务 - JSONObject param = new JSONObject(); - param.put("point_code1",point_code1); - param.put("point_code2",point_code2); - param.put("point_code3",jsonHotIvt.getString("point_code")); + switch (product_area) { + case "A": + reging_id = RegionTypeEnum.A_HKZC.getId(); + break; + case "B": + reging_id = RegionTypeEnum.B_HKZC.getId(); + break; + case "C": + reging_id = RegionTypeEnum.C_HKZC.getId(); + break; + case "D": + reging_id = RegionTypeEnum.D_HKZC.getId(); + break; + } + JSONObject map = new JSONObject(); + map.put("flag", "1"); + map.put("reging_id", reging_id); + map.put("point_location", point_location); - // 创建冷却区 --> 暂存位的任务 - InHotTask inHotTask = new InHotTask(null); - String task_id = inHotTask.createTask(param); + JSONArray pointArr = WQL.getWO("PDA_OVENINANDOUT_01").addParamMap(map).process().getResultJSONArray(0); + if (ObjectUtil.isEmpty(pointArr)) { + if (StrUtil.equals(point_location, "0")) map.put("point_location","1"); + if (StrUtil.equals(point_location, "1")) map.put("point_location","0"); + pointArr = WQL.getWO("PDA_OVENINANDOUT_01").addParamMap(map).process().getResultJSONArray(0); - // 4.插入烘箱区出入主表 和 明细表 - JSONObject hotParam = new JSONObject(); - hotParam.put("container_name",container_name); - hotParam.put("task_id",task_id); - // 创建主表 - String iostorinv_id = this.createHotIoMst(hotParam); - // 创建明细 - hotParam.put("iostorinv_id",iostorinv_id); - hotParam.put("start_point_code",point_code2); - hotParam.put("next_point_code",jsonHotIvt.getString("point_code")); - hotParam.put("temperature",temperature); - hotParam.put("oven_time",hours); - this.createHotDtl(hotParam); + if (ObjectUtil.isEmpty(pointArr)) throw new BadRequestException("没有空暂存位"); + } - // 5.下发任务 - JSONObject jsonObject = inHotTask.renotifyAcs(task_id); - if (StrUtil.equals(jsonObject.getString("status"), "200")) { - // 成功返回 更新任务状态 - JSONObject jsonTask = taskTab.query("task_id ='" + task_id + "'").uniqueResult(0); - jsonTask.put("task_status", "05"); - taskTab.update(jsonTask); + // 2.判断暂存位是否有任务:找到无任务的暂存位 、查询烘箱对应的空位 + String point_code2 = ""; + for (int i = 0; i < pointArr.size(); i++) { + JSONObject jsonPoint = pointArr.getJSONObject(i); + String point_code = jsonPoint.getString("point_code"); + + JSONObject json_point_code1 = taskTab.query("point_code1 = '" + point_code + "' and task_status != '99' and is_delete = '0'").uniqueResult(0); + JSONObject json_point_code2 = taskTab.query("point_code2 = '" + point_code + "' and task_status != '99' and is_delete = '0'").uniqueResult(0); + JSONObject json_point_code3 = taskTab.query("point_code3 = '" + point_code + "' and task_status != '99' and is_delete = '0'").uniqueResult(0); + JSONObject json_point_code4 = taskTab.query("point_code4 = '" + point_code + "' and task_status != '99' and is_delete = '0'").uniqueResult(0); + if (ObjectUtil.isEmpty(json_point_code1) && ObjectUtil.isEmpty(json_point_code2) && ObjectUtil.isEmpty(json_point_code3) && ObjectUtil.isEmpty(json_point_code4)) { + point_code2 = point_code; + break; + } + } + if (ObjectUtil.isEmpty(point_code2)) throw new BadRequestException("没有空暂存位"); + + // 查询烘箱对应的空位 + JSONObject jsonHotIvt = hosIvtTab.query("product_area = '" + product_area + "' and temperature = '" + temperature + "' and point_location = '"+map.getString("point_location")+"' and is_used = '1' and point_status = '01' order by point_code ASC").uniqueResult(0); + if (ObjectUtil.isEmpty(jsonHotIvt)) throw new BadRequestException("烘烤区没有对应空位"); + + // 3.创建冷却区 --> 烘烤区任务 + JSONObject param = new JSONObject(); + param.put("type","1"); // 1- 冷却区入烘箱 2- 暂存位入烘箱 + param.put("point_code1",point_code1); + param.put("point_code2",point_code2); + param.put("point_code3",jsonHotIvt.getString("point_code")); + + // 创建冷却区 --> 暂存位的任务 + InHotTask inHotTask = new InHotTask(null); + String task_id = inHotTask.createTask(param); + + // 4.插入烘箱区出入主表 和 明细表 + JSONObject hotParam = new JSONObject(); + hotParam.put("container_name",container_name); + hotParam.put("task_id",task_id); + // 创建主表 + String iostorinv_id = this.createHotIoMst(hotParam); + // 创建明细 + hotParam.put("iostorinv_id",iostorinv_id); + hotParam.put("start_point_code",point_code2); + hotParam.put("next_point_code",jsonHotIvt.getString("point_code")); + hotParam.put("temperature",temperature); + hotParam.put("oven_time",hours); + this.createHotDtl(hotParam); + + // 5.下发任务 + JSONObject jsonObject = inHotTask.renotifyAcs(task_id); + if (StrUtil.equals(jsonObject.getString("status"), "200")) { + // 成功返回 更新任务状态 + JSONObject jsonTask = taskTab.query("task_id ='" + task_id + "'").uniqueResult(0); + jsonTask.put("task_status", "05"); + taskTab.update(jsonTask); + } } } else if (StrUtil.equals(option, "2")) { // 出箱 @@ -272,6 +285,51 @@ public class BakingServiceImpl implements BakingService { @Override @Transactional public JSONObject inCoolIvt(JSONObject whereJson) { + WQLObject pointTab = WQLObject.getWQLObject("SCH_BASE_Point"); + WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); + + String point_code1 = whereJson.getString("point_code"); // 暂存位:起点 + String container_name = whereJson.getString("container_name"); // 母卷号 + + if (ObjectUtil.isEmpty(point_code1)) throw new BadRequestException("点位不能为空"); + if (ObjectUtil.isEmpty(container_name)) throw new BadRequestException("母卷号不能为空"); + + // 1.获取此暂存位的生产区域和上下位置 + JSONObject jsonPoint = pointTab.query("point_code = '" + point_code1 + "'").uniqueResult(0); + + // 2.找冷却区空货位 + JSONObject map = new JSONObject(); + map.put("flag", "2"); + map.put("product_area", jsonPoint.getString("product_area")); + map.put("point_location", jsonPoint.getString("point_location")); + + JSONObject jsonCooIvt = WQL.getWO("PDA_OVENINANDOUT_01").addParamMap(map).process().uniqueResult(0); + // 如果为空 + if (ObjectUtil.isEmpty(jsonCooIvt)) { + if (StrUtil.equals(jsonPoint.getString("point_location"), "0")) map.put("point_location","1"); + if (StrUtil.equals(jsonPoint.getString("point_location"), "1")) map.put("point_location","0"); + jsonCooIvt = WQL.getWO("PDA_OVENINANDOUT_01").addParamMap(map).process().uniqueResult(0); + } + if (ObjectUtil.isEmpty(jsonCooIvt)) throw new BadRequestException("冷却区空位不足"); + + // 3.创建任务 + JSONObject param = new JSONObject(); + param.put("point_code1", point_code1); + param.put("point_code2", jsonCooIvt.getString("point_code")); + param.put("container_name", container_name); + + InCoolIvtTask inCoolIvtTask = new InCoolIvtTask(null); + String task_id = inCoolIvtTask.createTask(param); + + // 4.下发任务 + JSONObject jsonObject = inCoolIvtTask.renotifyAcs(task_id); + if (StrUtil.equals(jsonObject.getString("status"), "200")) { + // 成功返回 更新任务状态 + JSONObject jsonTask = taskTab.query("task_id ='" + task_id + "'").uniqueResult(0); + jsonTask.put("task_status", "05"); + taskTab.update(jsonTask); + } + JSONObject result = new JSONObject(); result.put("message","操作成功!"); return result; diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/wql/PDA_OVENINANDOUT_01.wql b/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/wql/PDA_OVENINANDOUT_01.wql index 9b143815f..61994466b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/wql/PDA_OVENINANDOUT_01.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/wql/PDA_OVENINANDOUT_01.wql @@ -16,6 +16,7 @@ 输入.flag TYPEAS s_string 输入.reging_id TYPEAS s_string 输入.point_location TYPEAS s_string + 输入.product_area TYPEAS s_string [临时表] @@ -60,6 +61,28 @@ ENDOPTION + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + * + FROM + ST_IVT_CoolPointIvt + WHERE + is_used = '1' + AND full_point_status = '01' + + OPTION 输入.product_area <> "" + product_area = 输入.product_area + ENDOPTION + + OPTION 输入.point_location <> "" + point_location = 输入.point_location + ENDOPTION + ENDSELECT ENDQUERY ENDIF \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/wql/PDA_RAWFOIL_01.wql b/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/wql/PDA_RAWFOIL_01.wql index a34f8caa0..97bd5a206 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/wql/PDA_RAWFOIL_01.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/mps/wql/PDA_RAWFOIL_01.wql @@ -145,7 +145,8 @@ der.product_area AS product_area, der.update_time AS update_time, ivt.point_location, - ivt.product_area + ivt.product_area, + der.workorder_id FROM PDM_BI_RawFoilWorkOrder der LEFT JOIN st_ivt_sbpointivt ivt ON ivt.ext_code = der.resource_name diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/CallEmpReelTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/CallEmpReelTask.java index 5c3337bd1..8d0861569 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/CallEmpReelTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/CallEmpReelTask.java @@ -99,14 +99,14 @@ public class CallEmpReelTask extends AbstractAcsTask { jsonIvt2.put("workorder_id", jsonRaw.getString("workorder_id")); jsonIvt2.put("ivt_qty", jsonRaw.getString("productin_qty")); ivtTab.update(jsonIvt2); - +/* // 更新冷却区出入表 JSONObject jsonCool = coolTab.query("task_id = '" + task_id + "'").uniqueResult(0); jsonCool.put("bill_status","50"); jsonCool.put("confirm_optid", SecurityUtils.getCurrentUserId()); jsonCool.put("confirm_optname", SecurityUtils.getCurrentUsername()); jsonCool.put("confirm_time", DateUtil.now()); - coolTab.update(jsonCool); + coolTab.update(jsonCool);*/ } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/InCoolIvtTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/InCoolIvtTask.java new file mode 100644 index 000000000..e9e0fbbea --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/InCoolIvtTask.java @@ -0,0 +1,155 @@ +package org.nl.wms.sch.tasks; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +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.modules.wql.util.SpringContextHolder; +import org.nl.wms.sch.manage.AbstractAcsTask; +import org.nl.wms.sch.manage.TaskStatusEnum; +import org.nl.wms.sch.service.PointService; +import org.nl.wms.sch.service.dto.PointDto; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Slf4j +public class InCoolIvtTask extends AbstractAcsTask { + private final String THIS_CLASS = InCoolIvtTask.class.getName(); + private final CutConveyorTask conveyorTask; + + @Override + @Transactional + public void updateTaskStatus(JSONObject taskObj, String status) { + WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); // 任务表 + WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); // 点位表 + WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_CoolPointIvt"); // 冷却区库存表 + WQLObject coolTab = WQLObject.getWQLObject("ST_IVT_CoolRegionIO"); // 冷却区出入表 + WQLObject rawTab = WQLObject.getWQLObject("PDM_BI_RawFoilWorkOrder"); // 生箔工序工单表 + WQLObject hotMstTab = WQLObject.getWQLObject("ST_IVT_HotRegionIOMst"); // 烘箱出入主表 + + String task_id = taskObj.getString("task_id"); + JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0); + + if (StrUtil.equals(status,"0")) { + // 取消删除任务 + taskTab.delete("task_id = '"+task_id+"'"); + } + + if (TaskStatusEnum.EXECUTING.getCode().equals(status)) { + + // 更新任务状态为执行中 + jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode()); + jsonTask.put("update_time", DateUtil.now()); + 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); + + String point_code1 = jsonTask.getString("point_code1"); + String point_code2 = jsonTask.getString("point_code2"); + + PointService point = SpringContextHolder.getBean(PointService.class); + // 校验起点是否存在 + PointDto startDto = point.findByCode(point_code1); + if (ObjectUtil.isEmpty(startDto)) throw new BadRequestException("起点未找到可用点位:" + point_code1); + + // 校验终点是否存在 + JSONObject jsonIvt = ivtTab.query("point_code ='" + point_code2 + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jsonIvt)) throw new BadRequestException("终点未找到可用点位:" + point_code2); + + // 更新冷却库存状态 + JSONObject jsonHotMst = hotMstTab.query("container_name = '" + jsonTask.getString("material_code") + "'").uniqueResult(0); + + jsonIvt.put("full_point_status", "02"); + jsonIvt.put("cool_ivt_status", "03"); + jsonIvt.put("instorage_time", DateUtil.now()); + jsonIvt.put("container_name", jsonHotMst.getString("container_name")); + jsonIvt.put("workorder_id", jsonHotMst.getString("workorder_id")); + jsonIvt.put("ivt_qty", jsonHotMst.getString("qty")); + ivtTab.update(jsonIvt); + + // 更新烘烤出入主表为完成 + jsonHotMst.put("bill_status", "50"); + hotMstTab.update(jsonIvt); + } + } + + @Override + public void findStartPoint() { + + } + + @Override + public void findNextPoint() { + + } + + @Override + @Transactional + public String createTask(JSONObject form) { + WQLObject tab = WQLObject.getWQLObject("SCH_BASE_Task"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String currentUsername = SecurityUtils.getCurrentUsername(); + + String point_code1 = form.getString("point_code1"); + String point_code2 = form.getString("point_code2"); + if (conveyorTask.isSingleTask(point_code1)){ + throw new BadRequestException("点位:"+point_code1+"存在未完成的任务!"); + } + if (conveyorTask.isSingleTask(point_code2)){ + throw new BadRequestException("点位:"+point_code2+"存在未完成的任务!"); + } + + JSONObject json = new JSONObject(); + json.put("task_id",IdUtil.getSnowflake(1,1).nextId()); + json.put("task_code", CodeUtil.getNewCode("TASK_CODE")); + json.put("task_type", "010204"); + json.put("task_status", "01"); + json.put("point_code1", point_code1); + json.put("point_code2", point_code2); + json.put("material_code", form.getString("container_name")); + json.put("sort_seq", "1"); + json.put("handle_class", THIS_CLASS); + json.put("create_id", currentUserId); + json.put("create_name", currentUsername); + json.put("create_time", DateUtil.now()); + json.put("priority","1" ); + json.put("acs_task_type","4" ); + tab.insert(json); + + return json.getString("task_id"); + } + + @Override + @Transactional + 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 pullBack(String task_id) { + + } + + @Override + public void cancel(String task_id) { + + } + +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/InHotTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/InHotTask.java index 6e51de552..6c07b9568 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/InHotTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/InHotTask.java @@ -83,33 +83,56 @@ public class InHotTask extends AbstractAcsTask { // 更新主表: 什么时候更新主表 JSONObject jsonHotMst = hotMstTab.query("iostorinv_id = '" + jsonHotDtl.getString("iostorinv_id") + "'").uniqueResult(0); - // 更新冷却区库存状态 - JSONObject jsonCoolIvt = coolIvtTab.query("full_point_code = '" + jsonTask.getString("point_code1") + "'").uniqueResult(0); - String container_name = jsonCoolIvt.getString("container_name"); // 母卷号 - String workorder_id = jsonCoolIvt.getString("workorder_id"); // 母卷工单标识 - String ivt_qty = jsonCoolIvt.getString("ivt_qty"); // 库存 + // 判断此任务是否有三个点位 + if (ObjectUtil.isEmpty(jsonTask.getString("point_code3"))) { + /* + * 暂存区入烘箱任务 + */ + // 更新烘箱区库存状态 + JSONObject jsonHotIvt = hotIvtTab.query("point_code = '" + jsonTask.getString("point_code2") + "'").uniqueResult(0); + jsonHotIvt.put("point_status", "02"); + jsonHotIvt.put("container_name",jsonHotMst.getString("container_name")); + jsonHotIvt.put("workorder_id",jsonHotMst.getString("workorder_id") ); + jsonHotIvt.put("ivt_qty",jsonHotMst.getString("qty") ); + jsonHotIvt.put("instorage_time",DateUtil.now() ); + jsonHotIvt.put("update_optid", currentUserId); + jsonHotIvt.put("update_optname", currentUsername); + jsonHotIvt.put("update_time", DateUtil.now()); + hotIvtTab.update(jsonHotIvt); + } else { + /* + * 冷却区入烘箱任务 + */ - jsonCoolIvt.put("full_point_status", "01"); - jsonCoolIvt.put("container_name", ""); - jsonCoolIvt.put("workorder_id", ""); - jsonCoolIvt.put("ivt_qty", "0"); - jsonCoolIvt.put("instorage_time", ""); - jsonCoolIvt.put("update_optid", currentUserId); - jsonCoolIvt.put("update_optname", currentUsername); - jsonCoolIvt.put("update_time", DateUtil.now()); - coolIvtTab.update(jsonCoolIvt); + // 更新冷却区库存状态 + JSONObject jsonCoolIvt = coolIvtTab.query("full_point_code = '" + jsonTask.getString("point_code1") + "'").uniqueResult(0); + String container_name = jsonCoolIvt.getString("container_name"); // 母卷号 + String workorder_id = jsonCoolIvt.getString("workorder_id"); // 母卷工单标识 + String ivt_qty = jsonCoolIvt.getString("ivt_qty"); // 库存 + + jsonCoolIvt.put("full_point_status", "01"); + jsonCoolIvt.put("container_name", ""); + jsonCoolIvt.put("workorder_id", ""); + jsonCoolIvt.put("ivt_qty", "0"); + jsonCoolIvt.put("instorage_time", ""); + jsonCoolIvt.put("update_optid", currentUserId); + jsonCoolIvt.put("update_optname", currentUsername); + jsonCoolIvt.put("update_time", DateUtil.now()); + coolIvtTab.update(jsonCoolIvt); + + // 更新烘箱区库存状态 + JSONObject jsonHotIvt = hotIvtTab.query("point_code = '" + jsonTask.getString("point_code3") + "'").uniqueResult(0); + jsonHotIvt.put("point_status", "02"); + jsonHotIvt.put("container_name",container_name ); + jsonHotIvt.put("workorder_id",workorder_id ); + jsonHotIvt.put("ivt_qty",ivt_qty ); + jsonHotIvt.put("instorage_time",DateUtil.now() ); + jsonHotIvt.put("update_optid", currentUserId); + jsonHotIvt.put("update_optname", currentUsername); + jsonHotIvt.put("update_time", DateUtil.now()); + hotIvtTab.update(jsonHotIvt); + } - // 更新烘箱区库存状态 - JSONObject jsonHotIvt = hotIvtTab.query("point_code = '" + jsonTask.getString("point_code3") + "'").uniqueResult(0); - jsonHotIvt.put("point_status", "02"); - jsonHotIvt.put("container_name",container_name ); - jsonHotIvt.put("workorder_id",workorder_id ); - jsonHotIvt.put("ivt_qty",ivt_qty ); - jsonHotIvt.put("instorage_time",DateUtil.now() ); - jsonHotIvt.put("update_optid", currentUserId); - jsonHotIvt.put("update_optname", currentUsername); - jsonHotIvt.put("update_time", DateUtil.now()); - hotIvtTab.update(jsonHotIvt); } } @@ -130,36 +153,69 @@ public class InHotTask extends AbstractAcsTask { Long currentUserId = SecurityUtils.getCurrentUserId(); String currentUsername = SecurityUtils.getCurrentUsername(); - String point_code1 = form.getString("point_code1"); - String point_code2 = form.getString("point_code2"); - String point_code3 = form.getString("point_code3"); - if (conveyorTask.isSingleTask(point_code1)){ - throw new BadRequestException("点位:"+point_code1+"存在未完成的任务!"); - } - if (conveyorTask.isSingleTask(point_code2)){ - throw new BadRequestException("点位:"+point_code2+"存在未完成的任务!"); - } - if (conveyorTask.isSingleTask(point_code3)){ - throw new BadRequestException("点位:"+point_code3+"存在未完成的任务!"); - } - JSONObject json = new JSONObject(); - json.put("task_id",IdUtil.getSnowflake(1,1).nextId()); - json.put("task_code", CodeUtil.getNewCode("TASK_CODE")); - json.put("task_type", "010201"); - json.put("task_status", "01"); - json.put("point_code1", form.getString("point_code1")); - json.put("point_code2", form.getString("point_code2")); - json.put("point_code3", form.getString("point_code3")); - json.put("sort_seq", "1"); - json.put("handle_class", THIS_CLASS); - json.put("create_id", currentUserId); - json.put("create_name", currentUsername); - json.put("create_time", DateUtil.now()); - json.put("priority","1" ); - json.put("acs_task_type","1" ); - tab.insert(json); + String task_id = ""; - return json.getString("task_id"); + if (StrUtil.equals(form.getString("type"), "1")) { + String point_code1 = form.getString("point_code1"); + String point_code2 = form.getString("point_code2"); + String point_code3 = form.getString("point_code3"); + if (conveyorTask.isSingleTask(point_code1)){ + throw new BadRequestException("点位:"+point_code1+"存在未完成的任务!"); + } + if (conveyorTask.isSingleTask(point_code2)){ + throw new BadRequestException("点位:"+point_code2+"存在未完成的任务!"); + } + if (conveyorTask.isSingleTask(point_code3)){ + throw new BadRequestException("点位:"+point_code3+"存在未完成的任务!"); + } + JSONObject json = new JSONObject(); + json.put("task_id",IdUtil.getSnowflake(1,1).nextId()); + json.put("task_code", CodeUtil.getNewCode("TASK_CODE")); + json.put("task_type", "010201"); + json.put("task_status", "01"); + json.put("point_code1", form.getString("point_code1")); + json.put("point_code2", form.getString("point_code2")); + json.put("point_code3", form.getString("point_code3")); + json.put("sort_seq", "1"); + json.put("handle_class", THIS_CLASS); + json.put("create_id", currentUserId); + json.put("create_name", currentUsername); + json.put("create_time", DateUtil.now()); + json.put("priority","1" ); + json.put("acs_task_type","1" ); + tab.insert(json); + task_id = json.getString("task_id"); + } + + if (StrUtil.equals(form.getString("type"), "2")) { + String point_code1 = form.getString("point_code1"); + String point_code2 = form.getString("point_code2"); + + if (conveyorTask.isSingleTask(point_code1)){ + throw new BadRequestException("点位:"+point_code1+"存在未完成的任务!"); + } + if (conveyorTask.isSingleTask(point_code2)){ + throw new BadRequestException("点位:"+point_code2+"存在未完成的任务!"); + } + + JSONObject json = new JSONObject(); + json.put("task_id",IdUtil.getSnowflake(1,1).nextId()); + json.put("task_code", CodeUtil.getNewCode("TASK_CODE")); + json.put("task_type", "010203"); + json.put("task_status", "01"); + json.put("point_code1", form.getString("point_code1")); + json.put("point_code2", form.getString("point_code2")); + json.put("sort_seq", "1"); + json.put("handle_class", THIS_CLASS); + json.put("create_id", currentUserId); + json.put("create_name", currentUsername); + json.put("create_time", DateUtil.now()); + json.put("priority","1" ); + json.put("acs_task_type","1" ); + tab.insert(json); + task_id = json.getString("task_id"); + } + return task_id; } @Override