diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/OutTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/OutTask.java index b60cd7fcd..026209dd6 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/OutTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/tasks/OutTask.java @@ -18,6 +18,7 @@ import org.nl.wms.sch.manage.TaskStatusEnum; import org.nl.wms.sch.service.TaskService; import org.nl.wms.st.inbill.service.impl.InbillServiceImpl; import org.nl.wms.st.inbill.service.impl.RawAssistIStorServiceImpl; +import org.nl.wms.st.outbill.service.impl.CheckOutBillServiceImpl; import org.springframework.transaction.annotation.Transactional; import java.util.*; @@ -33,7 +34,7 @@ public class OutTask extends AbstractAcsTask { /* * 下发给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); + JSONArray arr = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0' order by sort_seq ASC").getResultJSONArray(0); ArrayList resultList = new ArrayList<>(); for (int i = 0; i < arr.size(); i++) { @@ -68,10 +69,26 @@ public class OutTask extends AbstractAcsTask { 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())) { + Long currentUserId = SecurityUtils.getCurrentUserId(); + String currentUsername = SecurityUtils.getCurrentUsername(); + + // 更改任务状态为完成 + jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode()); + jsonTask.put("update_optid", currentUserId); + jsonTask.put("update_optname", currentUsername); + jsonTask.put("update_time", DateUtil.now()); + taskTab.update(jsonTask); + + // 调用标识完成 + CheckOutBillServiceImpl checkOutBillService = new CheckOutBillServiceImpl(null); + checkOutBillService.finishTask(jsonTask); } } @@ -109,9 +126,6 @@ public class OutTask extends AbstractAcsTask { 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", "5"); - WQLObject.getWQLObject("SCH_BASE_Task").insert(json); return json.getString("task_id"); @@ -119,17 +133,9 @@ public class OutTask extends AbstractAcsTask { @Override @Transactional(rollbackFor = Exception.class) - public void forceFinish(String taskdtl_id) { - //任务表 - WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); - JSONObject task = wo_Task.query("task_status<>'99' and taskdtl_id='" + taskdtl_id + "'").uniqueResult(0); - if (task == null) { - throw new BadRequestException("查询不到操作的任务记录!"); - } - Map whereJson = new HashMap(); - whereJson.put("task_code", task.getString("task_code")); - RawAssistIStorServiceImpl inbillService = SpringContextHolder.getBean(RawAssistIStorServiceImpl.class); - inbillService.confirmTask(whereJson); + 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 diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java index 92a58f256..3de9820eb 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/StorPublicServiceImpl.java @@ -458,33 +458,8 @@ public class StorPublicServiceImpl implements StorPublicService { map.put("inv_type",""); map.put("inv_id",""); map.put("inv_code",""); - map.put("point_status","00"); - //是否清空载具 - if("1".equals(from.getString("is_free"))){ - map.put("storagevehicle_code",""); - map.put("vehicle_code",""); - map.put("point_status","00"); - map.put("storagevehicle_qty","0"); - map.put("storagevehicle_type",""); - map.put("storagevehicle_id",""); - map.put("is_emptyvehicle","0"); - }else{ - if (StrUtil.isNotEmpty(storagevehicle_code)) { - JSONObject Storage = wo_Storage.query("storagevehicle_code='"+storagevehicle_code+"'").uniqueResult(0); - if(ObjectUtil.isEmpty(Storage)){ - throw new BadRequestException(storagevehicle_code+"载具参数异常!"); - } - map.put("storagevehicle_code",Storage.getString("storagevehicle_code")); - map.put("storagevehicle_qty","1"); - map.put("vehicle_code",Storage.getString("storagevehicle_code")); - map.put("point_status","01"); - }else{ - map.put("is_emptyvehicle","0"); - if(StrUtil.isNotEmpty(jo.getString("storagevehicle_code"))){ - - } - } - } + map.put("point_status","1"); + map.put("storagevehicle_code",""); wo_Struct.update(map,"struct_id = '"+jo.getString("struct_id")+"'"); wo_Point.update(map,"point_id = '"+jo.getString("point_id")+"'"); }else{//锁定 diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java index 710f9abd0..73b68b130 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java @@ -17,6 +17,7 @@ import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.util.WqlUtil; import org.nl.wms.sch.manage.TaskStatusEnum; import org.nl.wms.sch.service.dto.TaskDto; +import org.nl.wms.sch.tasks.OutTask; import org.nl.wms.st.inbill.service.CheckOutBillService; import org.nl.wms.st.inbill.service.StorPublicService; import org.springframework.beans.factory.annotation.Autowired; @@ -959,13 +960,12 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); //出库主表 WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); + //仓位表 + WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr"); String struct_id = whereJson.getString("struct_id"); String point_code = whereJson.getString("point_code"); // 终点 String iostorinv_id = whereJson.getString("iostorinv_id"); - Long currentUserId = SecurityUtils.getCurrentUserId(); - String nickName = SecurityUtils.getCurrentNickName(); - String nowtime = DateUtil.now(); //查询主表信息 JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); @@ -973,9 +973,9 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { throw new BadRequestException("未查到相关出库单"); } - JSONObject point = wo_Point.query("lock_type='1' and (vehicle_code='' or vehicle_code IS NULL) and point_code='" + point_code + "'").uniqueResult(0); + JSONObject jsonPoint2 = wo_Point.query("lock_type='1' and (vehicle_code='' or vehicle_code IS NULL) and point_code='" + point_code + "'").uniqueResult(0); //如果终点站点被锁定或者有载具号,则不允许设置点位 - if (ObjectUtil.isEmpty(point)) { + if (ObjectUtil.isEmpty(jsonPoint2)) { throw new BadRequestException("该站点被锁定或者有载具号,不允许设置!"); } @@ -993,8 +993,6 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { throw new BadRequestException("分配明细不存在或已执行、完成、!"); } - HashMap map = new HashMap(); - String storagevehicle_code = dis.getString("storagevehicle_code"); String task_status = dis.getString("task_status"); String task_id = dis.getString("task_id"); @@ -1006,34 +1004,195 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { //若任务不为空,则为变更出库目的站点 JSONObject task = wo_Task.query("task_id='" + task_id + "'").uniqueResult(0); //更新任务 - task.put("point_code2", point.getString("point_code")); + task.put("point_code2", jsonPoint2.getString("point_code")); wo_Task.update(task); } else { /* * 生成任务: * 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’ - * a.如果有:有则只生成一条任务 - * b.没有:则生成生成 + * a.如果有:有则合并只生成一条任务 + * b.没有:则正常生成 * 2.判断此货位是否被挡住 * a.挡住:判断哪边的货位比较少 , 生成移库单 * b.没挡住:正常生成 */ - JSONObject jsonMap = new JSONObject(); - jsonMap.put("flag", "2"); - jsonMap.put("struct_id", dis.getString("struct_id")); + JSONObject jsonPoint1 = wo_Point.query("source_id = '" + dis.getString("struct_id") + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jsonPoint1)) throw new BadRequestException("起点点位不存在"); + // 创建任务 + JSONObject param = new JSONObject(); + param.put("task_type", "010301"); + param.put("vehicle_code", dis.getString("box_no")); + param.put("task_name", "task_name"); + param.put("point_code1", jsonPoint1.getString("point_code")); + param.put("point_code2", jsonPoint2.getString("point_code")); + param.put("material_id", dis.getString("material_id")); + param.put("task_group_id", ""); // 任务组 + param.put("sort_seq", ""); // 任务组顺序号 + OutTask outTask = new OutTask(); + String create_task_id = outTask.createTask(param); + + // 更新分配状态、任务标识、出库点位 + JSONObject jsonTask = wo_Task.query("task_id = '" + create_task_id + "'").uniqueResult(0); + JSONObject jsonUpdateMap = new JSONObject(); + jsonUpdateMap.put("work_status", "01"); + jsonUpdateMap.put("task_id", jsonTask.getLong("task_id")); + jsonUpdateMap.put("point_id", jsonPoint2.getLong("point_id")); + wo_dis.update(jsonUpdateMap, "iostorinvdis_id = '" + dis.getString("iostorinvdis_id") + "'"); + + // 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’ + JSONArray disArr = wo_dis.query("struct_id = '" + dis.getString("struct_id") + + "' and iostorinv_id = '" + dis.getString("iostorinv_id") + + "' and iostorinvdis_id <> '" + dis.getString("iostorinvdis_id") + + "' and work_status = '00'").getResultJSONArray(0); + + // 依次更新相同仓位的分配明细状态、任务标识、出库点位 + for (int i = 0; i < disArr.size(); i++) { + JSONObject jsonObject = disArr.getJSONObject(i); + jsonObject.put("work_status", "01"); + jsonObject.put("task_id", jsonTask.getLong("task_id")); + jsonObject.put("point_id", jsonPoint2.getLong("point_id")); + wo_dis.update(jsonObject); + } + + // 2.判断此货位是否被挡住 + JSONObject jsonAttr = attrTab.query("struct_id = '" + dis.getString("struct_id") + "'").uniqueResult(0); + + // 判断此仓位是‘双通’还是’单通‘ + if (StrUtil.equals(jsonAttr.getString("placement_type"), "01")) { + + JSONObject map = new JSONObject(); + map.put("flag", "2"); + map.put("struct_code", jsonAttr.getString("struct_code")); + map.put("sect_id", jsonAttr.getString("sect_id")); + + // 判断左边是否被挡住 + JSONObject jsonIsBlockL = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().uniqueResult(0); + + // 判断右边是否被挡住 + map.put("flag", "1"); + JSONObject jsonIsBlockR = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonIsBlockL) && ObjectUtil.isNotEmpty(jsonIsBlockR)) { + // 都被挡住判断哪边被挡住的货位少 + map.put("flag", "3"); + map.put("out_order_seq", jsonAttr.getString("out_order_seq")); + JSONArray jsonIsBlockAll = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().getResultJSONArray(0); + + int blockLeft = 0; // 左边个数 + int blockRigth = 0; // 右边个数 + for (int i = 0; i < jsonIsBlockAll.size(); i++) { + JSONObject json = jsonIsBlockAll.getJSONObject(i); + + if (i == 0) blockRigth = json.getIntValue("num"); + if (i == 1) blockRigth = json.getIntValue("num"); + } + + // 更新第一个任务 任务组、任务顺序号 + jsonTask.put("task_group_id", IdUtil.getSnowflake(1,1).nextId()); + jsonTask.put("sort_seq", 1); + wo_Task.update(jsonTask); + + JSONArray jsonAllBlockPoint = new JSONArray(); + if (blockLeft > blockRigth) { + // 从右边生成移库单 + map.put("flag", "4"); + map.put("block_num",jsonAttr.getString("block_num")); + map.put("row_num",jsonAttr.getString("row_num")); + + jsonAllBlockPoint = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().getResultJSONArray(0); + + } else { + // 从左边生成移库单 + map.put("flag", "5"); + map.put("block_num",jsonAttr.getString("block_num")); + map.put("row_num",jsonAttr.getString("row_num")); + + jsonAllBlockPoint = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().getResultJSONArray(0); + } + + for (int i = 0; i < jsonAllBlockPoint.size(); i++) { + JSONObject json = jsonAllBlockPoint.getJSONObject(i); + // TODO 创建移库单 + + // 生成任务 + JSONObject param2 = new JSONObject(); + param2.put("task_type", "010301"); + param2.put("vehicle_code", json.getString("storagevehicle_code")); + param2.put("task_name", "task_name"); + param2.put("point_code1", json.getString("point_code")); + param2.put("point_code2", ""); // TODO 移入仓位 + param2.put("task_group_id", jsonTask.getLongValue("task_group_id")); // 任务组 + param2.put("sort_seq", jsonTask.getIntValue("sort_seq") + i + 1); // 任务组顺序号 + outTask.createTask(param2); + } + + } + } else { + JSONObject map = new JSONObject(); + map.put("struct_code", jsonAttr.getString("struct_code")); + map.put("sect_id", jsonAttr.getString("sect_id")); + map.put("out_order_seq", jsonAttr.getString("out_order_seq")); + map.put("block_num",jsonAttr.getString("block_num")); + map.put("row_num",jsonAttr.getString("row_num")); + + JSONArray jsonAllBlockPoint = new JSONArray(); + if (StrUtil.equals(jsonAttr.getString("placement_type"), "02")) { + // 02-左通 + map.put("flag", "2"); + // 判断左边是否被挡住 + JSONObject jsonIsBlockL = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonIsBlockL)) { + // 更新第一个任务 任务组、任务顺序号 + jsonTask.put("task_group_id", IdUtil.getSnowflake(1,1).nextId()); + jsonTask.put("sort_seq", 1); + wo_Task.update(jsonTask); + // 从左边生成移库单 + map.put("flag", "5"); + jsonAllBlockPoint = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().getResultJSONArray(0); + } + } + + if (StrUtil.equals(jsonAttr.getString("placement_type"), "03")) { + // 03-右通 + map.put("flag", "1"); + JSONObject jsonIsBlockR = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().uniqueResult(0); + + // 判断左边是否被挡住 + if (ObjectUtil.isNotEmpty(jsonIsBlockR)) { + // 更新第一个任务 任务组、任务顺序号 + jsonTask.put("task_group_id", IdUtil.getSnowflake(1,1).nextId()); + jsonTask.put("sort_seq", 1); + wo_Task.update(jsonTask); + // 从右边生成移库单 + map.put("flag", "4"); + jsonAllBlockPoint = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().getResultJSONArray(0); + } + } + + for (int i = 0; i < jsonAllBlockPoint.size(); i++) { + JSONObject json = jsonAllBlockPoint.getJSONObject(i); + // TODO 创建移库单 + + // 生成任务 + JSONObject param2 = new JSONObject(); + param2.put("task_type", "010301"); + param2.put("vehicle_code", json.getString("storagevehicle_code")); + param2.put("task_name", "task_name"); + param2.put("point_code1", json.getString("point_code")); + param2.put("point_code2", ""); // TODO 移入仓位 + param2.put("task_group_id", jsonTask.getLongValue("task_group_id")); // 任务组 + param2.put("sort_seq", jsonTask.getIntValue("sort_seq") + i + 1); // 任务组顺序号 + outTask.createTask(param2); + } + } + // 下发 + outTask.immediateNotifyAcs(); } - - //更新分配表状态、任务号 - map.put("work_status", "01"); - map.put("task_id", task_id); - map.put("point_id", point.getString("point_id")); -// map.put("point_code", point.getString("point_code")); -// map.put("point_name", point.getString("point_name")); - wo_dis.update(map, "iostorinv_id='" + iostorinv_id + "' and storagevehicle_code='" + storagevehicle_code + "'"); } @Override @@ -1238,13 +1397,14 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { String iostorinv_id = form.getString("iostorinv_id"); Long currentUserId = SecurityUtils.getCurrentUserId(); String nickName = SecurityUtils.getCurrentNickName(); - String now = DateUtil.now(); + //查询主表信息 JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); if (ObjectUtil.isEmpty(jo_mst)) { throw new BadRequestException("未查到相关出库单"); } + //判断是否存在未确认状态的分配记录 JSONObject task = wo_dis.query("work_status <>'99' and iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); if (ObjectUtil.isNotEmpty(task)) { @@ -1256,6 +1416,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { throw new BadRequestException("存在未确认状态的出库分配记录,不允许强制确认!"); } } + //查询生成和未分配完的明细 JSONArray dtls = WQL.getWO("QST_IVT_CHECKOUTBILL") .addParam("flag", "2") @@ -1263,6 +1424,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { .addParam("iostorinv_id", iostorinv_id) .process() .getResultJSONArray(0); + if (dtls.size() != 0) { for (int i = 0; i < dtls.size(); i++) { JSONObject dtl = dtls.getJSONObject(i); @@ -1272,6 +1434,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { wo_dtl.update(map_dtl, "iostorinvdtl_id='" + dtl.getString("iostorinvdtl_id") + "'"); } } + HashMap map_mst = new HashMap<>(); map_mst.put("bill_status", "99"); map_mst.put("confirm_optid", currentUserId + ""); @@ -1318,17 +1481,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { from_start.put("struct_id", dis.getString("struct_id")); from_start.put("lock_type", "1"); from_start.put("storagevehicle_code", ""); -// from_start.put("vehicle_code", ""); - if ("02".equals(dis.getString("taskdtl_type"))) { - from_start.put("is_free", "1"); - } storPublicService.updateStructAndPoint(from_start); - //解锁终点 - /* JSONObject from_end = new JSONObject(); - from_end.put("point_code", dis.getString("point_code")); - from_end.put("struct_id", dis.getString("source_id")); - from_end.put("lock_type", "00"); - storPublicService.updateStructAndPoint(from_end);*/ } } @@ -1344,29 +1497,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { String nickName = SecurityUtils.getCurrentNickName(); String now = DateUtil.now(); - TaskDto checkOutBillAcsTask = null; - String task_id = whereJson.getString("task_id"); - String taskdtl_id = whereJson.getString("taskdtl_id"); - JSONObject result = null; - if (ObjectUtil.isNotEmpty(result)) { - String status = result.getString("status"); - if ("200".equals(status)) { - HashMap map = new HashMap<>(); - //更新分配表 - map.put("is_issued", "1"); - wo_dis.update(map, "task_id='" + task_id + "'"); - //更新任务为已下发 - map.put("task_status", "02"); - map.put("update_optid", currentUserId + ""); - map.put("update_optname", nickName); - map.put("update_time", now); - wo_Task.update(map, "taskdtl_id='" + taskdtl_id + "'"); - } else { - throw new BadRequestException("任务下发失败,请稍后重试!"); - } - } else { - throw new BadRequestException("任务下发失败,请稍后重试!"); - } + } @Override @@ -1384,51 +1515,38 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { String nickName = SecurityUtils.getCurrentNickName(); String now = DateUtil.now(); - JSONObject task = wo_Task.query("task_status<>'99' and task_id='" + task_id + "'").uniqueResult(0); + JSONObject task = wo_Task.query("task_status<>'07' and task_id='" + task_id + "'").uniqueResult(0); if (task == null) { throw new BadRequestException("查询不到操作的任务记录!"); } - String task_type = task.getString("task_type"); JSONObject dtljo = wo_dis.query("task_id='" + task_id + "'").uniqueResult(0); whereJson.put("iostorinv_id", dtljo.getString("iostorinv_id")); + HashMap map = new HashMap<>(); - //更新任务为完成 map.put("task_status", TaskStatusEnum.FINISHED.getCode()); map.put("finished_type", "01"); map.put("update_optid", currentUserId + ""); map.put("update_optname", nickName); map.put("update_time", now); - wo_Task.update(map, "task_id='" + task_id + "'"); - /* if ("05".equals(task_type)) {//拣选出库 - //更新分配表 - map.put("work_status", "02"); - wo_dis.update(map, "task_id='" + task_id + "'"); - } else if ("06".equals(task_type)) {//拣选回库 - map.put("work_status", "99"); - wo_dis.update(map, "task_id='" + task_id + "'"); - //判断是否还有未完成的明细 - JSONArray ja = wo_dtl.query("bill_status<>'99' and iostorinv_id='" + whereJson.getString("iostorinv_id") + "'").getResultJSONArray(0); - if (ja.size() == 0) { - this.confirm(whereJson); - } - } else {//全出 - map.put("work_status", "99"); - wo_dis.update(map, "task_id='" + task_id + "'"); - //判断是否还有未完成的明细 - JSONArray ja = wo_dtl.query("bill_status<>'99' and iostorinv_id='" + whereJson.getString("iostorinv_id") + "'").getResultJSONArray(0); - if (ja.size() == 0) { - this.confirm(whereJson); - } - }*/ - map.put("work_status", "99"); - wo_dis.update(map, "task_id='" + task_id + "'"); - // 更新明细为完成 - JSONObject jsonDtl = wo_dtl.query("iostorinvdtl_id = '" + whereJson.getString("iostorinvdtl_id") + "'").uniqueResult(0); - jsonDtl.put("bill_status", "99"); - wo_dtl.update(jsonDtl); + //更新任务为完成 + wo_Task.update(map, "task_id='" + task_id + "'"); + + // 查询此任务下所有的分配明细 + JSONArray disArr = wo_dis.query("task_id='" + task_id + "'").getResultJSONArray(0); + for (int i = 0; i < disArr.size(); i++) { + JSONObject jsonDis = disArr.getJSONObject(i); + // 更新分配明细为完成 + jsonDis.put("work_status","99"); + wo_dis.update(jsonDis); + + // 更新明细为完成 + JSONObject jsonDtl = wo_dtl.query("iostorinvdtl_id = '" + jsonDis.getString("iostorinvdtl_id") + "'").uniqueResult(0); + jsonDtl.put("bill_status", "99"); + wo_dtl.update(jsonDtl); + } //判断是否还有未完成的明细 JSONArray ja = wo_dtl.query("bill_status<>'99' and iostorinv_id='" + whereJson.getString("iostorinv_id") + "'").getResultJSONArray(0); @@ -1444,114 +1562,49 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); //出库分配表 WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis"); - //出库分配明细表 - WQLObject wo_DisDtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDisDtl"); //任务表 WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); //出库主表 WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); - //桶物料变动记录表 - WQLObject wo_BucketChangeFlow = WQLObject.getWQLObject("MD_PB_BucketChangeFlow"); - //桶记录表 - WQLObject wo_BucketRecord = WQLObject.getWQLObject("MD_PB_BucketRecord"); - String iostorinv_id = whereJson.getString("iostorinv_id"); - String taskdtl_id = whereJson.getString("taskdtl_id"); - HashMap map = new HashMap(); Long currentUserId = SecurityUtils.getCurrentUserId(); String nickName = SecurityUtils.getCurrentNickName(); - String now = DateUtil.now(); + + String iostorinv_id = whereJson.getString("iostorinv_id"); + String task_id = whereJson.getString("task_id"); + + // 更新任务状态 + JSONObject jsonTask = wo_Task.query("task_id ='" + task_id + "'").uniqueResult(0); + jsonTask.put("task_status", TaskStatusEnum.ISSUE.getCode()); + jsonTask.put("update_optid", currentUserId); + jsonTask.put("update_optname", nickName); + jsonTask.put("update_time", now); + wo_Task.update(jsonTask); + //查询主表信息 JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); if (ObjectUtil.isEmpty(jo_mst)) { throw new BadRequestException("未查到相关出库单"); } - if (jo_mst.getString("bill_status").equals("99")) { - throw new BadRequestException("已审核单据不允许取消完成!"); - } - JSONObject task = wo_Task.query("taskdtl_id='" + taskdtl_id + "'").uniqueResult(0); - String taskdtl_type = task.getString("taskdtl_type"); - String task_id = task.getString("task_id"); - if ("05".contains(taskdtl_type)) { - //查询拣选出库对应的拣选回库有没有先取消完成 - JSONObject task06 = wo_Task.query("task_status='99' and taskdtl_type='06' and task_id='" + task_id + "'").uniqueResult(0); - if (task06 != null) { - throw new BadRequestException("请先取消拣选出库对应的拣选回库指令!"); - } - } - //如果为拣选出库05 - if ("05,02".contains(taskdtl_type)) { - //更新任务为已下发 - map.put("task_status", "01"); - map.put("finished_type", ""); - map.put("update_optid", currentUserId + ""); - map.put("update_optname", nickName); - map.put("update_time", now); - wo_Task.update(map, "taskdtl_type='" + taskdtl_type + "' and task_id='" + task_id + "'"); - //查询生成和未分配完的明细 - JSONArray disdtls = WQL.getWO("QST_IVT_CHECKOUTBILL") - .addParam("flag", "8") - .addParam("task_id", task_id) - .process() - .getResultJSONArray(0); - if (disdtls.size() != 0) { - for (int i = 0; i < disdtls.size(); i++) { - JSONObject disdtl = disdtls.getJSONObject(i); - //更新桶记录相关表 - double real_qty_disDtl = disdtl.getDoubleValue("real_qty"); - String bucketunique = disdtl.getString("bucketunique"); - //查询桶记录 - JSONObject bucket = wo_BucketRecord.query("status='04' and bucketunique='" + bucketunique + "'").uniqueResult(0); - double storage_qty = bucket.getDoubleValue("storage_qty"); - //重量加回去 - storage_qty = storage_qty + real_qty_disDtl; - bucket.put("storage_qty", storage_qty); - bucket.put("outstor_optid", currentUserId); - bucket.put("outstor_optname", nickName); - bucket.put("outstor_time", now); - //更新桶记录表 - wo_BucketRecord.update(bucket); - //插入一条变动记录 - bucket.put("change_id", IdUtil.getSnowflake(1, 1).nextId() + ""); - bucket.put("bucket_code", bucketunique); - bucket.put("change_type_scode", "01"); - bucket.put("change_time", now); - bucket.put("rec_person", currentUserId); - bucket.put("change_qty", real_qty_disDtl); - bucket.put("result_qty", storage_qty); - wo_BucketChangeFlow.insert(bucket); - //清空分配明细表 - wo_DisDtl.delete("iostorinvdisdtl_id='" + disdtl.getString("iostorinvdisdtl_id") + "'"); - //倒推明细表、分配表实际数量 - JSONObject dis = wo_dis.query("iostorinvdis_id='" + disdtl.getString("iostorinvdis_id") + "'").uniqueResult(0); - dis.put("real_qty", dis.getDoubleValue("real_qty") - real_qty_disDtl); - dis.put("work_status", "01"); - dis.put("is_issued", "0"); - wo_dis.update(dis); - JSONObject dtl = wo_dtl.query("iostorinvdtl_id='" + disdtl.getString("iostorinvdtl_id") + "'").uniqueResult(0); - double real_qty = dtl.getDoubleValue("real_qty") - real_qty_disDtl; - if (real_qty == 0) { - dtl.put("bill_status", "40"); - } - wo_dtl.update(dtl); - } - } else { - map.put("work_status", "01"); - map.put("is_issued", "0"); - wo_dis.update(map, "task_id='" + task_id + "'"); - } - //更新主表状态 - this.updateMststatus(whereJson.getString("iostorinv_id")); - } else if ("06".equals(taskdtl_type)) {//如果为拣选回库 - //更新任务为已下发 - map.put("task_status", "01"); - map.put("finished_type", ""); - map.put("update_optid", currentUserId + ""); - map.put("update_optname", nickName); - map.put("update_time", now); - wo_Task.update(map, "taskdtl_type='06' and task_id='" + task_id + "'"); + if (jo_mst.getString("bill_status").equals("99")) { + throw new BadRequestException("已完成单据不允许取消完成!"); + } + + // 查询此任务下的所有分配明细 + JSONArray disArr = wo_dis.query("task_id ='" + task_id + "'").getResultJSONArray(0); + + for (int i = 0; i < disArr.size(); i++) { + JSONObject jsonDis = disArr.getJSONObject(i); + + // 更新分配明细状态 + jsonDis.put("work_status", "01"); + wo_dis.update(jsonDis); + + // 更新明细状态 + JSONObject jsonDtl = wo_dtl.query("iostorinvdtl_id = '" + jsonDis.getString("iostorinvdtl_id") + "'").uniqueResult(0); + jsonDtl.put("bill_status","40"); } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT01.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT01.wql index ccdc0b513..1b7b91496 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT01.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT01.wql @@ -148,7 +148,6 @@ FROM ST_IVT_StructIvt ivt LEFT JOIN ST_IVT_StructAttr attr ON attr.struct_id = ivt.struct_id - LEFT JOIN PDM_BI_SubPackageRelation sub ON attr.storagevehicle_code = sub.package_box_SN WHERE ivt.quality_scode = '01' AND attr.lock_type = '1' diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT02.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT02.wql index 5781e7ed6..30049aaa1 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT02.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT02.wql @@ -54,29 +54,6 @@ WHERE ivt.pcsn <> 输入.pcsn - OPTION 输入.struct_id <> "" - ivt.struct_id = 输入.struct_id - ENDOPTION - - ENDSELECT - ENDQUERY - ENDIF - - IF 输入.flag = "2" - QUERY - SELECT - ivt.*, - attr.storagevehicle_code AS box_no, - mater.base_unit_id AS qty_unit_id, - unit.unit_name AS qty_unit_name - FROM - ST_IVT_StructIvt ivt - LEFT JOIN ST_IVT_StructAttr attr ON ivt.struct_id = attr.struct_id - LEFT JOIN md_me_materialbase mater ON ivt.material_id = mater.material_id - LEFT JOIN md_pb_measureunit unit ON unit.measure_unit_id = mater.base_unit_id - WHERE - ivt.pcsn <> 输入.pcsn - OPTION 输入.struct_id <> "" ivt.struct_id = 输入.struct_id ENDOPTION diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT03.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT03.wql new file mode 100644 index 000000000..132afe190 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/ST_OUTIVT03.wql @@ -0,0 +1,250 @@ +[交易说明] + 交易名: 货位判断 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + 输入.struct_code TYPEAS s_string + 输入.sect_id TYPEAS s_string + 输入.out_order_seq TYPEAS s_string + 输入.block_num TYPEAS s_string + 输入.row_num TYPEAS s_string + +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + QUERY + SELECT + * + FROM + ( + SELECT + sa.block_num, + sa.row_num, + sa.placement_type, + sa.out_order_seq + FROM + st_ivt_structattr sa + WHERE + sa.is_delete = '0' + AND is_used = '1' + + OPTION 输入.struct_code <> "" + sa.struct_code = 输入.struct_code + ENDOPTION + + OPTION 输入.sect_id <> "" + sa.sect_id = 输入.sect_id + ENDOPTION + + ) a + WHERE + EXISTS ( + SELECT + * + FROM + ( + SELECT + block_num, + row_num, + placement_type, + out_order_seq + FROM + st_ivt_structattr sa3 + WHERE + IFNULL( sa3.storagevehicle_code, '' ) <> '' + ) c + WHERE + c.block_num = a.block_num + AND c.row_num = a.row_num + AND c.placement_type = a.placement_type + AND c.out_order_seq < a.out_order_seq + ) + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + * + FROM + ( + SELECT + sa.block_num, + sa.row_num, + sa.placement_type, + sa.out_order_seq + FROM + st_ivt_structattr sa + WHERE + sa.is_delete = '0' + AND is_used = '1' + + OPTION 输入.struct_code <> "" + sa.struct_code = 输入.struct_code + ENDOPTION + + OPTION 输入.sect_id <> "" + sa.sect_id = 输入.sect_id + ENDOPTION + ) a + WHERE + EXISTS ( + SELECT + * + FROM + ( + SELECT + block_num, + row_num, + placement_type, + sa2.out_order_seq + FROM + st_ivt_structattr sa2 + WHERE + IFNULL( sa2.storagevehicle_code, '' ) <> '' + ) b + WHERE + b.block_num = a.block_num + AND b.row_num = a.row_num + AND b.placement_type = a.placement_type + AND b.out_order_seq > a.out_order_seq + ) + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "3" + QUERY + SELECT + COUNT(*) AS num + FROM + st_ivt_structattr sa + INNER JOIN + ( + SELECT + a.block_num, + a.row_num + FROM + st_ivt_structattr a + WHERE + a.struct_code = 输入.struct_code + ) b ON b.block_num = sa.block_num + AND b.row_num = sa.row_num + WHERE + sa.out_order_seq < 输入.out_order_seq + AND IFNULL( sa.storagevehicle_code, '' ) <> '' + AND sa.lock_type = '1' + + UNION + + SELECT + COUNT(*) AS num + FROM + st_ivt_structattr sa + INNER JOIN + ( + SELECT + a.block_num, + a.row_num + FROM + st_ivt_structattr a + WHERE + a.struct_code = 输入.struct_code + ) b ON b.block_num = sa.block_num + AND b.row_num = sa.row_num + WHERE + sa.out_order_seq > 输入.out_order_seq + AND IFNULL( sa.storagevehicle_code, '' ) <> '' + AND sa.lock_type = '1' + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "4" + QUERY + SELECT + attr.*, + point.point_code + FROM + ST_IVT_StructAttr attr + LEFT JOIN SCH_BASE_Point point ON attr.struct_id = point.source_id + WHERE + attr.out_order_seq < 输入.out_order_seq + AND IFNULL(attr.storagevehicle_code,'') <> '' + AND attr.lock_type = '1' + + OPTION 输入.block_num <> "" + attr.block_num = 输入.block_num + ENDOPTION + + OPTION 输入.row_num <> "" + attr.row_num = 输入.row_num + ENDOPTION + + order by attr.out_order_seq DESC + + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "5" + QUERY + SELECT + attr.*, + point.point_code + FROM + ST_IVT_StructAttr attr + LEFT JOIN SCH_BASE_Point point ON attr.struct_id = point.source_id + WHERE + attr.out_order_seq > 输入.out_order_seq + AND IFNULL(attr.storagevehicle_code,'') <> '' + AND attr.lock_type = '1' + + OPTION 输入.block_num <> "" + attr.block_num = 输入.block_num + ENDOPTION + + OPTION 输入.row_num <> "" + attr.row_num = 输入.row_num + ENDOPTION + + order by attr.out_order_seq ASC + + ENDSELECT + ENDQUERY + ENDIF \ No newline at end of file diff --git a/lms/nladmin-ui/src/views/wms/st/outbill/TaskDialog.vue b/lms/nladmin-ui/src/views/wms/st/outbill/TaskDialog.vue index c7417c7ed..d11220987 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/TaskDialog.vue +++ b/lms/nladmin-ui/src/views/wms/st/outbill/TaskDialog.vue @@ -266,13 +266,14 @@ export default { this.currentDis = {} return } + debugger this.currentDis = current - if (current.task_status === '01') { + if (current.task_status === '04') { this.button1 = false } else { this.button1 = true } - if (current.task_status !== '99') { + if (current.task_status !== '07') { this.button2 = false this.button3 = true } else {