diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java index ddb2ffe01..207d6df7e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java @@ -146,13 +146,6 @@ public interface CheckOutBillService { */ void setPoint(JSONObject whereJson); - /** - * 设置一个站点 - * - * @param whereJson / - */ - void oneSetPoint(JSONObject whereJson); - /** * 设置一个站点 * diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java index 02535025b..1070957c1 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java @@ -150,14 +150,6 @@ public class CheckOutBillController { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } - @PostMapping("/oneSetPoint") - @Log("设置一个站点") - - public ResponseEntity oneSetPoint(@RequestBody JSONObject whereJson) { - checkOutBillService.oneSetPoint(whereJson); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - @PostMapping("/oneSetPoint2") @Log("设置一个站点") 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 421770b89..7d31b2d3c 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 @@ -2454,643 +2454,6 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } } - @Override - @Transactional(rollbackFor = Exception.class) - public void oneSetPoint(JSONObject whereJson) { - //出库分配表 - WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis"); - //点位表 - WQLObject wo_Point = WQLObject.getWQLObject("SCH_BASE_Point"); - //任务表 - 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"); - - //查询主表信息 - JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); - if (ObjectUtil.isEmpty(jo_mst)) { - throw new BadRequestException("未查到相关出库单"); - } - - 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(jsonPoint2)) { - throw new BadRequestException("该站点被锁定或者有载具号,不允许设置!"); - } - - // 查询未生成和生成未下发的分配记录 - JSONObject dis = WQL.getWO("QST_IVT_CHECKOUTBILL") - .addParam("flag", "5") - .addParam("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id")) - .addParam("struct_id", struct_id) - .addParam("iostorinv_id", iostorinv_id) - .addParam("bill_status", "01") - .addParam("is_issued", "0") - .process() - .uniqueResult(0); - if (ObjectUtil.isEmpty(dis)) { - throw new BadRequestException("分配明细不存在或已执行、完成、!"); - } - - String task_status = dis.getString("task_status"); - String task_id = dis.getString("task_id"); - - if (StrUtil.isNotEmpty(task_status) && "05,06,07".contains(task_status)) { - throw new BadRequestException("该任务已执行,不可重新设置站点!"); - } - - if (ObjectUtil.isNotEmpty(task_id)) { - //若任务不为空,则为变更出库目的站点 - JSONObject task = wo_Task.query("task_id='" + task_id + "'").uniqueResult(0); - //更新任务 - task.put("point_code2", jsonPoint2.getString("point_code")); - wo_Task.update(task); - } else { - /* - * 生成任务: - * 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’ - * a.如果有:有则合并只生成一条任务 - * b.没有:则正常生成 - * 2.判断此货位是否被挡住 - * a.挡住:判断哪边的货位比较少 , 生成移库单 - * b.没挡住:正常生成 - */ - 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", "010503"); - 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", ""); // 任务组顺序号 - - 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); - boolean left_verify = true; - if (ObjectUtil.isEmpty(jsonIsBlockL)) { - left_verify = false; - /* String out_order_seq = NumberUtil.add(jsonAttr.getString("out_order_seq"), "1").toString(); - JSONObject json = attrTab.query("sect_id = '" + map.getString("sect_id") - + "' and out_order_seq = '" + out_order_seq - + "' and block_num = '" + jsonAttr.getString("block_num") - + "' and row_num = '" + jsonAttr.getString("row_num") + "'").uniqueResult(0); - if (ObjectUtil.isNotEmpty(json)) { - jsonAttr.put("placement_type","02"); - }*/ - jsonAttr.put("placement_type", "02"); - } else { - // 调用验证方法进行校验 - String out_order_seq = NumberUtil.add(jsonIsBlockL.getString("out_order_seq"), "1").toString(); - JSONObject jsonParam = attrTab.query("sect_id = '" + map.getString("sect_id") - + "' and out_order_seq = '" + out_order_seq - + "' and block_num = '" + jsonIsBlockL.getString("block_num") - + "' and row_num = '" + jsonIsBlockL.getString("row_num") + "'").uniqueResult(0); - - jsonParam.put("iostorinv_id", dis.getString("iostorinv_id")); - jsonParam.put("option", "2"); - left_verify = this.is_trueOrFalse(jsonParam); - - if (!left_verify) { - jsonParam.put("option", "3"); - boolean left_verify2 = this.is_trueOrFalse(jsonParam); - - if (left_verify2) { - jsonAttr.put("placement_type", "02"); - } - } else { - jsonParam.put("option", "4"); - boolean left_verify2 = this.is_trueOrFalse(jsonParam); - - if (left_verify2) { - jsonAttr.put("placement_type", "02"); - } - } - } - - // 判断右边是否被挡住 - map.put("flag", "1"); - JSONObject jsonIsBlockR = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().uniqueResult(0); - boolean right_verify = true; - if (ObjectUtil.isEmpty(jsonIsBlockR)) { - right_verify = false; - /* String out_order_seq = NumberUtil.sub(jsonAttr.getString("out_order_seq"), "1").toString(); - JSONObject json = attrTab.query("sect_id = '" + map.getString("sect_id") - + "' and out_order_seq = '" + out_order_seq - + "' and block_num = '" + jsonAttr.getString("block_num") - + "' and row_num = '" + jsonAttr.getString("row_num") + "'").uniqueResult(0); - if (ObjectUtil.isNotEmpty(json)) { - jsonAttr.put("placement_type","03"); - }*/ - jsonAttr.put("placement_type", "03"); - } else { - // 调用验证方法进行校验 - String out_order_seq = NumberUtil.sub(jsonIsBlockR.getString("out_order_seq"), "1").toString(); - JSONObject jsonParam = attrTab.query("sect_id = '" + map.getString("sect_id") - + "' and out_order_seq = '" + out_order_seq - + "' and block_num = '" + jsonIsBlockR.getString("block_num") - + "' and row_num = '" + jsonIsBlockR.getString("row_num") + "'").uniqueResult(0); - - jsonParam.put("iostorinv_id", dis.getString("iostorinv_id")); - jsonParam.put("option", "2"); - right_verify = this.is_trueOrFalse(jsonParam); - - if (!right_verify) { - jsonParam.put("option", "3"); - boolean right_verify2 = this.is_trueOrFalse(jsonParam); - - if (right_verify2) { - jsonAttr.put("placement_type", "03"); - } - } else { - jsonParam.put("option", "4"); - boolean right_verify2 = this.is_trueOrFalse(jsonParam); - - if (right_verify2) { - jsonAttr.put("placement_type", "03"); - } - } - } - - if (left_verify && right_verify) { - // 都被挡住判断哪边被挡住的货位少 - 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); - - JSONObject mapParam = new JSONObject();// 生成移库单传入参数 - JSONArray table = new JSONArray(); // 明细参数 - mapParam.put("bill_status", "10"); - mapParam.put("bill_type", "21"); - mapParam.put("buss_type", "21"); - mapParam.put("biz_date", DateUtil.today()); - mapParam.put("stor_code", "CP01"); - mapParam.put("stor_id", "1582991156504039424"); - mapParam.put("stor_name", "成品仓库"); - mapParam.put("is_task", "1"); - - // 查询移入货位 - JSONObject moveParam = new JSONObject(); - moveParam.put("box_no", json.getString("storagevehicle_code")); - moveParam.put("sect_id", RegionTypeEnum.ZZ01.getId()); - JSONObject jsonMove = rawAssistIStorService.autoDis(moveParam); - // 查询移出货位的库存物料 - JSONObject jsonMoveIvt = WQL.getWO("ST_OUTIVT03") - .addParam("flag", "6") - .addParam("struct_id", json.getString("struct_id")) - .process().uniqueResult(0); - - // 移库单明细 - JSONObject jsonMoveDtl = new JSONObject(); - jsonMoveDtl.put("is_task", "2"); - jsonMoveDtl.put("turnout_sect_id", json.getLongValue("sect_id")); - jsonMoveDtl.put("turnout_sect_code", json.getString("sect_code")); - jsonMoveDtl.put("turnout_sect_name", json.getString("sect_name")); - jsonMoveDtl.put("turnout_struct_id", json.getLongValue("struct_id")); - jsonMoveDtl.put("turnout_struct_code", json.getString("struct_code")); - jsonMoveDtl.put("turnout_struct_name", json.getString("struct_name")); - jsonMoveDtl.put("material_id", jsonMoveIvt.getLongValue("material_id")); - jsonMoveDtl.put("pcsn", jsonMoveIvt.getString("pcsn")); - jsonMoveDtl.put("quality_scode", "01"); - jsonMoveDtl.put("qty_unit_id", jsonMoveIvt.getLongValue("qty_unit_id")); - jsonMoveDtl.put("qty_unit_name", jsonMoveIvt.getString("unit_name")); - jsonMoveDtl.put("qty", jsonMoveIvt.getDoubleValue("canuse_qty")); - jsonMoveDtl.put("storagevehicle_code", json.getString("storagevehicle_code")); - jsonMoveDtl.put("turnin_sect_id", jsonMove.getLongValue("sect_id")); - jsonMoveDtl.put("turnin_sect_code", jsonMove.getString("sect_code")); - jsonMoveDtl.put("turnin_sect_name", jsonMove.getString("sect_name")); - jsonMoveDtl.put("turnin_struct_id", jsonMove.getLongValue("struct_id")); - jsonMoveDtl.put("turnin_struct_code", jsonMove.getString("struct_code")); - jsonMoveDtl.put("turnin_struct_name", jsonMove.getString("struct_name")); - jsonMoveDtl.put("source_billdtl_id", dis.getLongValue("iostorinvdis_id")); - - // 生成任务 - JSONObject param2 = new JSONObject(); - param2.put("task_type", "010503"); - 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", jsonMove.getString("struct_code")); - param2.put("task_group_id", jsonTask.getLongValue("task_group_id")); // 任务组 - param2.put("sort_seq", jsonTask.getIntValue("sort_seq") + i + 1); // 任务组顺序号 - String move_task_id = outTask.createTask(param2); - - // 回显移库明细任务id - jsonMoveDtl.put("task_id", move_task_id); - table.add(jsonMoveDtl); - // 更新任务处理类 - JSONObject jsonTaskMove = wo_Task.query("task_id = '" + move_task_id + "'").uniqueResult(0); - jsonTaskMove.put("task_type", "010505"); - jsonTaskMove.put("handle_class", HandMoveStorAcsTask.class.getName()); - wo_Task.update(jsonTaskMove); - - mapParam.put("tableData", table); - // 调用移库单新增方法 - if (ObjectUtil.isNotEmpty(jsonAllBlockPoint)) { - handMoveStorService.insertDtl2(mapParam); - } - } - - } else { - if (StrUtil.equals(jsonAttr.getString("placement_type"), "01")) { - throw new BadRequestException("任务生成失败,请重新选择"); - } - 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 jsonIsBlockL2 = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().uniqueResult(0); - - // 如果被挡住则进行校验 - boolean verify = true; - if (ObjectUtil.isEmpty(jsonIsBlockL2)) { - verify = false; - } else { - // 调用验证方法进行校验 - String out_order_seq = NumberUtil.add(jsonIsBlockL2.getString("out_order_seq"), "1").toString(); - JSONObject jsonParam = attrTab.query("sect_id = '" + map.getString("sect_id") - + "' and out_order_seq = '" + out_order_seq - + "' and block_num = '" + map.getString("block_num") - + "' and row_num = '" + map.getString("row_num") + "'").uniqueResult(0); - - jsonParam.put("iostorinv_id", dis.getString("iostorinv_id")); - jsonParam.put("option", "1"); - verify = this.is_trueOrFalse(jsonParam); - } - - if (verify) { - // 更新第一个任务 任务组、任务顺序号 - 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 jsonIsBlockR2 = WQL.getWO("ST_OUTIVT03").addParamMap(map).process().uniqueResult(0); - - // 如果被挡住则进行校验 - boolean verify = true; - if (ObjectUtil.isEmpty(jsonIsBlockR2)) { - verify = false; - } else { - // 调用验证方法进行校验 - String out_order_seq = NumberUtil.sub(jsonIsBlockR2.getString("out_order_seq"), "1").toString(); - JSONObject jsonParam = attrTab.query("sect_id = '" + map.getString("sect_id") - + "' and out_order_seq = '" + out_order_seq - + "' and block_num = '" + map.getString("block_num") - + "' and row_num = '" + map.getString("row_num") + "'").uniqueResult(0); - - jsonParam.put("iostorinv_id", dis.getString("iostorinv_id")); - jsonParam.put("option", "1"); - verify = this.is_trueOrFalse(jsonParam); - } - - if (verify) { - // 更新第一个任务 任务组、任务顺序号 - 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); - - JSONObject mapParam = new JSONObject();// 生成移库单传入参数 - JSONArray table = new JSONArray(); // 明细参数 - mapParam.put("bill_status", "10"); - mapParam.put("bill_type", "21"); - mapParam.put("buss_type", "21"); - mapParam.put("biz_date", DateUtil.today()); - mapParam.put("stor_code", "CP01"); - mapParam.put("stor_id", "1582991156504039424"); - mapParam.put("stor_name", "成品仓库"); - mapParam.put("is_task", "1"); - - // 查询移入货位 - JSONObject moveParam = new JSONObject(); - moveParam.put("box_no", json.getString("storagevehicle_code")); - moveParam.put("sect_id", RegionTypeEnum.ZZ01.getId()); - JSONObject jsonMove = rawAssistIStorService.autoDis(moveParam); - // 查询移出货位的库存物料 - JSONObject jsonMoveIvt = WQL.getWO("ST_OUTIVT03") - .addParam("flag", "6") - .addParam("struct_id", json.getString("struct_id")) - .process().uniqueResult(0); - - // 移库单明细 - JSONObject jsonMoveDtl = new JSONObject(); - jsonMoveDtl.put("is_task", "2"); - jsonMoveDtl.put("turnout_sect_id", json.getLongValue("sect_id")); - jsonMoveDtl.put("turnout_sect_code", json.getString("sect_code")); - jsonMoveDtl.put("turnout_sect_name", json.getString("sect_name")); - jsonMoveDtl.put("turnout_struct_id", json.getLongValue("struct_id")); - jsonMoveDtl.put("turnout_struct_code", json.getString("struct_code")); - jsonMoveDtl.put("turnout_struct_name", json.getString("struct_name")); - jsonMoveDtl.put("material_id", jsonMoveIvt.getLongValue("material_id")); - jsonMoveDtl.put("pcsn", jsonMoveIvt.getString("pcsn")); - jsonMoveDtl.put("quality_scode", "01"); - jsonMoveDtl.put("qty_unit_id", jsonMoveIvt.getLongValue("qty_unit_id")); - jsonMoveDtl.put("qty_unit_name", jsonMoveIvt.getString("unit_name")); - jsonMoveDtl.put("qty", jsonMoveIvt.getDoubleValue("canuse_qty")); - jsonMoveDtl.put("storagevehicle_code", json.getString("storagevehicle_code")); - jsonMoveDtl.put("turnin_sect_id", jsonMove.getLongValue("sect_id")); - jsonMoveDtl.put("turnin_sect_code", jsonMove.getString("sect_code")); - jsonMoveDtl.put("turnin_sect_name", jsonMove.getString("sect_name")); - jsonMoveDtl.put("turnin_struct_id", jsonMove.getLongValue("struct_id")); - jsonMoveDtl.put("turnin_struct_code", jsonMove.getString("struct_code")); - jsonMoveDtl.put("turnin_struct_name", jsonMove.getString("struct_name")); - jsonMoveDtl.put("source_billdtl_id", dis.getLongValue("iostorinvdis_id")); - - // 生成任务 - JSONObject param2 = new JSONObject(); - param2.put("task_type", "010503"); - 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", jsonMove.getString("struct_code")); - param2.put("task_group_id", jsonTask.getLongValue("task_group_id")); // 任务组 - param2.put("sort_seq", jsonTask.getIntValue("sort_seq") + i + 1); // 任务组顺序号 - String move_task_id = outTask.createTask(param2); - - // 回显移库明细任务id - jsonMoveDtl.put("task_id", move_task_id); - table.add(jsonMoveDtl); - // 更新任务处理类 - JSONObject jsonTaskMove = wo_Task.query("task_id = '" + move_task_id + "'").uniqueResult(0); - jsonTaskMove.put("task_type", "010505"); - jsonTaskMove.put("handle_class", HandMoveStorAcsTask.class.getName()); - wo_Task.update(jsonTaskMove); - - mapParam.put("tableData", table); - // 调用移库单新增方法 - if (ObjectUtil.isNotEmpty(jsonAllBlockPoint)) { - handMoveStorService.insertDtl2(mapParam); - } - } - } - } 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); - - // 如果被挡住则进行校验 - boolean verify = true; - if (ObjectUtil.isEmpty(jsonIsBlockL)) { - verify = false; - } else { - // 调用验证方法进行校验 - String out_order_seq = NumberUtil.add(jsonIsBlockL.getString("out_order_seq"), "1").toString(); - JSONObject jsonParam = attrTab.query("sect_id = '" + map.getString("sect_id") - + "' and out_order_seq = '" + out_order_seq - + "' and block_num = '" + map.getString("block_num") - + "' and row_num = '" + map.getString("row_num") + "'").uniqueResult(0); - - jsonParam.put("iostorinv_id", dis.getString("iostorinv_id")); - jsonParam.put("option", "1"); - verify = this.is_trueOrFalse(jsonParam); - } - - if (verify) { - // 更新第一个任务 任务组、任务顺序号 - 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); - - // 如果被挡住则进行校验 - boolean verify = true; - if (ObjectUtil.isEmpty(jsonIsBlockR)) { - verify = false; - } else { - // 调用验证方法进行校验 - String out_order_seq = NumberUtil.sub(jsonIsBlockR.getString("out_order_seq"), "1").toString(); - JSONObject jsonParam = attrTab.query("sect_id = '" + map.getString("sect_id") - + "' and out_order_seq = '" + out_order_seq - + "' and block_num = '" + map.getString("block_num") - + "' and row_num = '" + map.getString("row_num") + "'").uniqueResult(0); - - jsonParam.put("iostorinv_id", dis.getString("iostorinv_id")); - jsonParam.put("option", "1"); - verify = this.is_trueOrFalse(jsonParam); - } - - if (verify) { - // 更新第一个任务 任务组、任务顺序号 - 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); - - JSONObject mapParam = new JSONObject();// 生成移库单传入参数 - JSONArray table = new JSONArray(); // 明细参数 - mapParam.put("bill_status", "10"); - mapParam.put("bill_type", "21"); - mapParam.put("buss_type", "21"); - mapParam.put("biz_date", DateUtil.today()); - mapParam.put("stor_code", "CP01"); - mapParam.put("stor_id", "1582991156504039424"); - mapParam.put("stor_name", "成品仓库"); - mapParam.put("is_task", "1"); - - // 查询移入货位 - JSONObject moveParam = new JSONObject(); - moveParam.put("box_no", json.getString("storagevehicle_code")); - moveParam.put("sect_id", RegionTypeEnum.ZZ01.getId()); - JSONObject jsonMove = rawAssistIStorService.autoDis(moveParam); - // 查询移出货位的库存物料 - JSONObject jsonMoveIvt = WQL.getWO("ST_OUTIVT03") - .addParam("flag", "6") - .addParam("struct_id", json.getString("struct_id")) - .process().uniqueResult(0); - - // 移库单明细 - JSONObject jsonMoveDtl = new JSONObject(); - jsonMoveDtl.put("is_task", "2"); - jsonMoveDtl.put("turnout_sect_id", json.getLongValue("sect_id")); - jsonMoveDtl.put("turnout_sect_code", json.getString("sect_code")); - jsonMoveDtl.put("turnout_sect_name", json.getString("sect_name")); - jsonMoveDtl.put("turnout_struct_id", json.getLongValue("struct_id")); - jsonMoveDtl.put("turnout_struct_code", json.getString("struct_code")); - jsonMoveDtl.put("turnout_struct_name", json.getString("struct_name")); - jsonMoveDtl.put("material_id", jsonMoveIvt.getLongValue("material_id")); - jsonMoveDtl.put("pcsn", jsonMoveIvt.getString("pcsn")); - jsonMoveDtl.put("quality_scode", "01"); - jsonMoveDtl.put("qty_unit_id", jsonMoveIvt.getLongValue("qty_unit_id")); - jsonMoveDtl.put("qty_unit_name", jsonMoveIvt.getString("unit_name")); - jsonMoveDtl.put("qty", jsonMoveIvt.getDoubleValue("canuse_qty")); - jsonMoveDtl.put("storagevehicle_code", json.getString("storagevehicle_code")); - jsonMoveDtl.put("turnin_sect_id", jsonMove.getLongValue("sect_id")); - jsonMoveDtl.put("turnin_sect_code", jsonMove.getString("sect_code")); - jsonMoveDtl.put("turnin_sect_name", jsonMove.getString("sect_name")); - jsonMoveDtl.put("turnin_struct_id", jsonMove.getLongValue("struct_id")); - jsonMoveDtl.put("turnin_struct_code", jsonMove.getString("struct_code")); - jsonMoveDtl.put("turnin_struct_name", jsonMove.getString("struct_name")); - jsonMoveDtl.put("source_billdtl_id", dis.getLongValue("iostorinvdis_id")); - - // 生成任务 - JSONObject param2 = new JSONObject(); - param2.put("task_type", "010503"); - 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", jsonMove.getString("struct_code")); - param2.put("task_group_id", jsonTask.getLongValue("task_group_id")); // 任务组 - param2.put("sort_seq", jsonTask.getIntValue("sort_seq") + i + 1); // 任务组顺序号 - String move_task_id = outTask.createTask(param2); - - // 回显移库明细任务id - jsonMoveDtl.put("task_id", move_task_id); - table.add(jsonMoveDtl); - // 更新任务处理类 - JSONObject jsonTaskMove = wo_Task.query("task_id = '" + move_task_id + "'").uniqueResult(0); - jsonTaskMove.put("task_type", "010505"); - jsonTaskMove.put("handle_class", HandMoveStorAcsTask.class.getName()); - wo_Task.update(jsonTaskMove); - - mapParam.put("tableData", table); - // 调用移库单新增方法 - if (ObjectUtil.isNotEmpty(jsonAllBlockPoint)) { - handMoveStorService.insertDtl2(mapParam); - } - } - } - // 下发 - outTask.immediateNotifyAcs(null); - } - } - @Override @Transactional(rollbackFor = Exception.class) public void allSetPoint(JSONObject whereJson) { @@ -3668,90 +3031,190 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { @Override @Transactional(rollbackFor = Exception.class) public void oneSetPoint2(JSONObject whereJson) { - //出库分配表 - WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis"); - //点位表 - WQLObject wo_Point = WQLObject.getWQLObject("SCH_BASE_Point"); - //任务表 - WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); - //出库主表 - WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); - //仓位表 - WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr"); + TranUtil.openTransaction((req, allTransactionConsumer) -> { + allTransactionConsumer.accept("begin"); + //出库分配表 + WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis"); + //点位表 + WQLObject wo_Point = WQLObject.getWQLObject("SCH_BASE_Point"); + //任务表 + 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"); - String iostorinvdtl_id = whereJson.getString("iostorinvdtl_id"); - String iostorinvdis_id = whereJson.getString("iostorinvdis_id"); - boolean checked = whereJson.getBoolean("checked"); // 是否异常出库 - String point_id = ""; + String struct_id = whereJson.getString("struct_id"); + String point_code = whereJson.getString("point_code"); // 终点 + String iostorinv_id = whereJson.getString("iostorinv_id"); + String iostorinvdtl_id = whereJson.getString("iostorinvdtl_id"); + String iostorinvdis_id = whereJson.getString("iostorinvdis_id"); + boolean checked = whereJson.getBoolean("checked"); // 是否异常出库 + String point_id = ""; - //查询主表信息 - JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); - if (ObjectUtil.isEmpty(jo_mst)) { - throw new BadRequestException("未查到相关出库单"); - } + //查询主表信息 + JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jo_mst)) { + throw new BadRequestException("未查到相关出库单"); + } - 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(jsonPoint2)) { - throw new BadRequestException("该站点被锁定或者有载具号,不允许设置!"); - } - point_id = jsonPoint2.getString("point_id"); + 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(jsonPoint2)) { + throw new BadRequestException("该站点被锁定或者有载具号,不允许设置!"); + } + point_id = jsonPoint2.getString("point_id"); - // 查询未生成和生成未下发的分配记录 - JSONArray disArrOne = WQL.getWO("QST_IVT_CHECKOUTBILL") - .addParam("flag", "5") - .addParam("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id")) - .addParam("iostorinvdis_id", whereJson.getString("iostorinvdis_id")) - .addParam("struct_id", struct_id) - .addParam("iostorinv_id", iostorinv_id) - .addParam("bill_status", "01") - .addParam("is_issued", "0") - .process() - .getResultJSONArray(0); - if (ObjectUtil.isEmpty(disArrOne)) { - throw new BadRequestException("分配明细不存在或已执行、完成、!"); - } + // 查询未生成和生成未下发的分配记录 + JSONArray disArrOne = WQL.getWO("QST_IVT_CHECKOUTBILL") + .addParam("flag", "5") + .addParam("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id")) + .addParam("iostorinvdis_id", whereJson.getString("iostorinvdis_id")) + .addParam("struct_id", struct_id) + .addParam("iostorinv_id", iostorinv_id) + .addParam("bill_status", "01") + .addParam("is_issued", "0") + .process() + .getResultJSONArray(0); + if (ObjectUtil.isEmpty(disArrOne)) { + throw new BadRequestException("分配明细不存在或已执行、完成、!"); + } - // 取第一个 - JSONObject jsonNoe = disArrOne.getJSONObject(0); + // 取第一个 + JSONObject jsonNoe = disArrOne.getJSONObject(0); - JSONArray disRowArrNew = new JSONArray(); - String option = ""; // 1.左 2.右 - String placement_type = whereJson.getString("placement_type"); // 单通或双通 - // 双通 - if (StrUtil.equals(placement_type, "01")) { + JSONArray disRowArrNew = new JSONArray(); + String option = ""; // 1.左 2.右 + String placement_type = whereJson.getString("placement_type"); // 单通或双通 + // 双通 + if (StrUtil.equals(placement_type, "01")) { - /* - * 判断左边被挡住的个数多还是右边被挡住的个数多 - */ - // 判断右边边被挡住的个数 - JSONObject isNumMap = new JSONObject(); - isNumMap.put("flag", "3"); - isNumMap.put("block_num", jsonNoe.getString("block_num")); - isNumMap.put("row_num", jsonNoe.getString("row_num")); - isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); - JSONArray numArrFirst = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); - - // 调用共用方法计算被挡个数 - JSONArray rightNumArr = this.isNum(numArrFirst); - - // 判断左边被挡住的个数 - isNumMap.put("flag", "4"); - isNumMap.put("block_num", jsonNoe.getString("block_num")); - isNumMap.put("row_num", jsonNoe.getString("row_num")); - isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); - JSONArray numArrLast = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); - - // 调用共用方法计算被挡个数 - JSONArray leftNumArr = this.isNum(numArrLast); - // 判断哪边少 - if (rightNumArr.size() > leftNumArr.size()) { /* - * 左边开始 + * 判断左边被挡住的个数多还是右边被挡住的个数多 */ + // 判断右边边被挡住的个数 + JSONObject isNumMap = new JSONObject(); + isNumMap.put("flag", "3"); + isNumMap.put("block_num", jsonNoe.getString("block_num")); + isNumMap.put("row_num", jsonNoe.getString("row_num")); + isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); + JSONArray numArrFirst = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); + + // 调用共用方法计算被挡个数 + JSONArray rightNumArr = this.isNum(numArrFirst); + + // 判断左边被挡住的个数 + isNumMap.put("flag", "4"); + isNumMap.put("block_num", jsonNoe.getString("block_num")); + isNumMap.put("row_num", jsonNoe.getString("row_num")); + isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); + JSONArray numArrLast = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); + + // 调用共用方法计算被挡个数 + JSONArray leftNumArr = this.isNum(numArrLast); + // 判断哪边少 + if (rightNumArr.size() > leftNumArr.size()) { + /* + * 左边开始 + */ + // 查询仓位被锁住的货位 + isNumMap.put("flag", "5"); + isNumMap.put("block_num", jsonNoe.getString("block_num")); + isNumMap.put("row_num", jsonNoe.getString("row_num")); + isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); + JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); + + JSONArray numArr = this.isNum(isLockArr); + // 不为空则返回报错 + if (ObjectUtil.isNotEmpty(numArr)) { + String error = ""; + + for (int k = 0; k < numArr.size(); k++) { + JSONObject json = numArr.getJSONObject(k); + error += json.getString("struct_code") + ","; + } + + throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); + } + // 重新按照排序查询 + disRowArrNew = WQL.getWO("ST_OUTIVT04") + .addParam("flag", "22") + .addParam("iostorinvdtl_id", iostorinvdtl_id) + .addParam("iostorinvdis_id", iostorinvdis_id) + .process().getResultJSONArray(0); + + option = "1"; + + } else if (rightNumArr.size() < leftNumArr.size()) { + /* + * 右边开始 + */ + // 查询仓位被锁住的货位 + isNumMap.put("flag", "6"); + isNumMap.put("block_num", jsonNoe.getString("block_num")); + isNumMap.put("row_num", jsonNoe.getString("row_num")); + isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); + JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); + + JSONArray numArr = this.isNum(isLockArr); + // 不为空则返回报错 + if (ObjectUtil.isNotEmpty(numArr)) { + String error = ""; + + for (int k = 0; k < numArr.size(); k++) { + JSONObject json = numArr.getJSONObject(k); + error += json.getString("struct_code") + ","; + } + + throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); + } + + // 重新按照排序查询 + disRowArrNew = WQL.getWO("ST_OUTIVT04") + .addParam("flag", "2") + .addParam("iostorinvdtl_id", iostorinvdtl_id) + .addParam("iostorinvdis_id", iostorinvdis_id) + .process().getResultJSONArray(0); + + option = "2"; + } else { + /* + * 相等默认右边开始 + */ + // 查询仓位被锁住的货位 + isNumMap.put("flag", "6"); + isNumMap.put("block_num", jsonNoe.getString("block_num")); + isNumMap.put("row_num", jsonNoe.getString("row_num")); + isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); + JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); + + JSONArray numArr = this.isNum(isLockArr); + // 不为空则返回报错 + if (ObjectUtil.isNotEmpty(numArr)) { + String error = ""; + + for (int k = 0; k < numArr.size(); k++) { + JSONObject json = numArr.getJSONObject(k); + error += json.getString("struct_code") + ","; + } + + throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); + } + + // 重新按照排序查询 + disRowArrNew = WQL.getWO("ST_OUTIVT04") + .addParam("flag", "2") + .addParam("iostorinvdtl_id", iostorinvdtl_id) + .addParam("iostorinvdis_id", iostorinvdis_id) + .process().getResultJSONArray(0); + + option = "2"; + } + + } else if (StrUtil.equals(placement_type, "02")) { + // 左通 + + JSONObject isNumMap = new JSONObject(); // 查询仓位被锁住的货位 isNumMap.put("flag", "5"); isNumMap.put("block_num", jsonNoe.getString("block_num")); @@ -3769,7 +3232,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { error += json.getString("struct_code") + ","; } - throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); + throw new BadRequestException("仓位:" + error + "被锁定请等待下发任务并等待任务完成"); } // 重新按照排序查询 disRowArrNew = WQL.getWO("ST_OUTIVT04") @@ -3780,10 +3243,9 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { option = "1"; - } else if (rightNumArr.size() < leftNumArr.size()) { - /* - * 右边开始 - */ + } else if (StrUtil.equals(placement_type, "03")) { + // 右通 + JSONObject isNumMap = new JSONObject(); // 查询仓位被锁住的货位 isNumMap.put("flag", "6"); isNumMap.put("block_num", jsonNoe.getString("block_num")); @@ -3801,7 +3263,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { error += json.getString("struct_code") + ","; } - throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); + throw new BadRequestException("仓位:" + error + "被锁定请等待下发任务并等待任务完成!"); } // 重新按照排序查询 @@ -3812,287 +3274,195 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { .process().getResultJSONArray(0); option = "2"; + } + + /* + * 循环生成任务 + */ + boolean canOut = false; + int j = 0; + JSONObject jsonObject = disRowArrNew.getJSONObject(j); + + // 查询未被锁住的仓位 + JSONArray moveArr = new JSONArray(); + JSONObject map = new JSONObject(); + map.put("block_num", jsonObject.getString("block_num")); + map.put("row_num", jsonObject.getString("row_num")); + map.put("out_order_seq", jsonObject.getString("out_order_seq")); + + if (StrUtil.equals(option, "1")) { + // 左边 + map.put("flag", "7"); + moveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map).process().getResultJSONArray(0); } else { - /* - * 相等默认右边开始 - */ - // 查询仓位被锁住的货位 - isNumMap.put("flag", "6"); - isNumMap.put("block_num", jsonNoe.getString("block_num")); - isNumMap.put("row_num", jsonNoe.getString("row_num")); - isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); - JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); + // 右边 + map.put("flag", "8"); + moveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map).process().getResultJSONArray(0); + } - JSONArray numArr = this.isNum(isLockArr); - // 不为空则返回报错 - if (ObjectUtil.isNotEmpty(numArr)) { - String error = ""; + // 创建任务组 + long task_group_id = IdUtil.getSnowflake(1, 1).nextId(); - for (int k = 0; k < numArr.size(); k++) { - JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; + // 判断是否需要生成移库 + if (ObjectUtil.isNotEmpty(moveArr)) { + JSONObject moveParam = new JSONObject(); + moveParam.put("jsonAllBlockPoint", moveArr); + moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id")); + moveParam.put("task_group_id", task_group_id); + this.createMove(moveParam, allTransactionConsumer); + } + + // 判断是否是异常出库口 + if (checked) { + JSONObject jsonStartPoint = attrTab.query("struct_code = '" + jsonObject.getString("struct_code") + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jsonStartPoint)) { + throw new BadRequestException("起始点位异常!"); + } + + String layer_num = jsonStartPoint.getString("layer_num"); + + switch (layer_num) { + case "1": + point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_1").getValue(); + break; + case "2": + point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_2").getValue(); + break; + case "3": + point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_3").getValue(); + break; + default: + throw new BadRequestException("起点楼层异常:" + jsonStartPoint.getString("struct_code")); + } + point_id = wo_Point.query("point_code = '" + point_code + "'").uniqueResult(0).getString("point_id"); + } + allTransactionConsumer.accept(jsonObject.getString("struct_code")); + // 创建任务 + JSONObject param = new JSONObject(); + param.put("task_type", "010503"); + param.put("vehicle_code", jsonObject.getString("box_no")); + param.put("task_name", ""); + param.put("point_code1", jsonObject.getString("struct_code")); + param.put("point_code2", point_code); + param.put("material_id", jsonObject.getString("material_id")); + param.put("task_group_id", ""); // 任务组 + param.put("sort_seq", ""); // 任务组顺序号 + + 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", point_id); + wo_dis.update(jsonUpdateMap, "iostorinvdis_id = '" + jsonObject.getString("iostorinvdis_id") + "'"); + + // 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’ + JSONArray disArr = wo_dis.query("struct_id = '" + jsonObject.getString("struct_id") + + "' and iostorinv_id = '" + jsonObject.getString("iostorinv_id") + + "' and iostorinvdis_id <> '" + jsonObject.getString("iostorinvdis_id") + + "' and work_status = '00'").getResultJSONArray(0); + + // 依次更新相同仓位的分配明细状态、任务标识、出库点位 + for (int n = 0; n < disArr.size(); n++) { + JSONObject jsonObject2 = disArr.getJSONObject(n); + jsonObject2.put("work_status", "01"); + jsonObject2.put("task_id", jsonTask.getLong("task_id")); + jsonObject2.put("point_id", point_id); + wo_dis.update(jsonObject2); + } + + // 更新出库任务:任务组和顺序号 + JSONObject jsonTaskLast1 = wo_Task.query("task_group_id = '" + task_group_id + "' order by sort_seq DESC").uniqueResult(0); + jsonTask.put("task_group_id", task_group_id); + if (ObjectUtil.isEmpty(jsonTaskLast1)) { + jsonTask.put("sort_seq", 1); + } else { + jsonTask.put("sort_seq", jsonTaskLast1.getIntValue("sort_seq") + 1); + } + wo_Task.update(jsonTask); + + /* + * 判断下一个出库仓位是否相邻 + */ + int out_order_seq = jsonObject.getIntValue("out_order_seq"); + boolean canAdd = true; + int nextNum = j + 1; + while (canAdd) { + // 判断数组是否到头 + if (nextNum <= disRowArrNew.size() - 1) { + JSONObject jsonNext = disRowArrNew.getJSONObject(nextNum); + int out_order_seq_next = jsonNext.getIntValue("out_order_seq"); + if (Math.abs(out_order_seq_next - out_order_seq) != nextNum) { + // 下发当前任务组 + outTask.immediateNotifyAcs(null); + + // 更新任务组 + task_group_id = IdUtil.getSnowflake(1, 1).nextId(); + canAdd = false; + + } else { + // 查询此任务组最后一个生成的任务 + JSONObject jsonTaskLast = wo_Task.query("task_group_id = '" + task_group_id + "' order by sort_seq DESC").uniqueResult(0); + // 创建任务并添加到任务组 + allTransactionConsumer.accept(jsonNext.getString("struct_code")); + JSONObject param2 = new JSONObject(); + param2.put("task_type", "010503"); + param2.put("vehicle_code", jsonNext.getString("box_no")); + param2.put("task_name", ""); + param2.put("point_code1", jsonNext.getString("struct_code")); + param2.put("point_code2", point_code); + param2.put("material_id", jsonNext.getString("material_id")); + param2.put("task_group_id", task_group_id); // 任务组 + param2.put("sort_seq", jsonTaskLast.getIntValue("sort_seq") + 1); // 任务组顺序号 + + String create_task_id2 = outTask.createTask(param2); + + outTask.immediateNotifyAcs(null); + + // 更新分配状态、任务标识、出库点位 + JSONObject jsonTask2 = wo_Task.query("task_id = '" + create_task_id2 + "'").uniqueResult(0); + JSONObject jsonUpdateMap2 = new JSONObject(); + jsonUpdateMap2.put("work_status", "01"); + jsonUpdateMap2.put("task_id", jsonTask2.getLong("task_id")); + jsonUpdateMap2.put("point_id", point_id); + wo_dis.update(jsonUpdateMap2, "iostorinvdis_id = '" + jsonNext.getString("iostorinvdis_id") + "'"); + + // 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’ + JSONArray disArr2 = wo_dis.query("struct_id = '" + jsonNext.getString("struct_id") + + "' and iostorinv_id = '" + jsonNext.getString("iostorinv_id") + + "' and iostorinvdis_id <> '" + jsonNext.getString("iostorinvdis_id") + + "' and work_status = '00'").getResultJSONArray(0); + + // 依次更新相同仓位的分配明细状态、任务标识、出库点位 + for (int m = 0; m < disArr2.size(); m++) { + JSONObject jsonObject3 = disArr2.getJSONObject(m); + jsonObject3.put("work_status", "01"); + jsonObject3.put("task_id", jsonTask2.getLong("task_id")); + jsonObject3.put("point_id", point_id); + wo_dis.update(jsonObject3); + } + + nextNum++; } - - throw new BadRequestException("仓位:" + error + "被锁定且未下发任务,无法生成任务!"); - } - - // 重新按照排序查询 - disRowArrNew = WQL.getWO("ST_OUTIVT04") - .addParam("flag", "2") - .addParam("iostorinvdtl_id", iostorinvdtl_id) - .addParam("iostorinvdis_id", iostorinvdis_id) - .process().getResultJSONArray(0); - - option = "2"; - } - - } else if (StrUtil.equals(placement_type, "02")) { - // 左通 - - JSONObject isNumMap = new JSONObject(); - // 查询仓位被锁住的货位 - isNumMap.put("flag", "5"); - isNumMap.put("block_num", jsonNoe.getString("block_num")); - isNumMap.put("row_num", jsonNoe.getString("row_num")); - isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); - JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); - - JSONArray numArr = this.isNum(isLockArr); - // 不为空则返回报错 - if (ObjectUtil.isNotEmpty(numArr)) { - String error = ""; - - for (int k = 0; k < numArr.size(); k++) { - JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; - } - - throw new BadRequestException("仓位:" + error + "被锁定请等待下发任务并等待任务完成"); - } - // 重新按照排序查询 - disRowArrNew = WQL.getWO("ST_OUTIVT04") - .addParam("flag", "22") - .addParam("iostorinvdtl_id", iostorinvdtl_id) - .addParam("iostorinvdis_id", iostorinvdis_id) - .process().getResultJSONArray(0); - - option = "1"; - - } else if (StrUtil.equals(placement_type, "03")) { - // 右通 - JSONObject isNumMap = new JSONObject(); - // 查询仓位被锁住的货位 - isNumMap.put("flag", "6"); - isNumMap.put("block_num", jsonNoe.getString("block_num")); - isNumMap.put("row_num", jsonNoe.getString("row_num")); - isNumMap.put("out_order_seq", jsonNoe.getString("out_order_seq")); - JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0); - - JSONArray numArr = this.isNum(isLockArr); - // 不为空则返回报错 - if (ObjectUtil.isNotEmpty(numArr)) { - String error = ""; - - for (int k = 0; k < numArr.size(); k++) { - JSONObject json = numArr.getJSONObject(k); - error += json.getString("struct_code") + ","; - } - - throw new BadRequestException("仓位:" + error + "被锁定请等待下发任务并等待任务完成!"); - } - - // 重新按照排序查询 - disRowArrNew = WQL.getWO("ST_OUTIVT04") - .addParam("flag", "2") - .addParam("iostorinvdtl_id", iostorinvdtl_id) - .addParam("iostorinvdis_id", iostorinvdis_id) - .process().getResultJSONArray(0); - - option = "2"; - } - - /* - * 循环生成任务 - */ - boolean canOut = false; - int j = 0; - JSONObject jsonObject = disRowArrNew.getJSONObject(j); - - // 查询未被锁住的仓位 - JSONArray moveArr = new JSONArray(); - JSONObject map = new JSONObject(); - map.put("block_num", jsonObject.getString("block_num")); - map.put("row_num", jsonObject.getString("row_num")); - map.put("out_order_seq", jsonObject.getString("out_order_seq")); - - if (StrUtil.equals(option, "1")) { - // 左边 - map.put("flag", "7"); - moveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map).process().getResultJSONArray(0); - } else { - // 右边 - map.put("flag", "8"); - moveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map).process().getResultJSONArray(0); - } - - // 创建任务组 - long task_group_id = IdUtil.getSnowflake(1, 1).nextId(); - - // 判断是否需要生成移库 - if (ObjectUtil.isNotEmpty(moveArr)) { - JSONObject moveParam = new JSONObject(); - moveParam.put("jsonAllBlockPoint", moveArr); - moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id")); - moveParam.put("task_group_id", task_group_id); - this.createMove(moveParam, null); - } - - // 判断是否是异常出库口 - if (checked) { - JSONObject jsonStartPoint = attrTab.query("struct_code = '" + jsonObject.getString("struct_code") + "'").uniqueResult(0); - if (ObjectUtil.isEmpty(jsonStartPoint)) { - throw new BadRequestException("起始点位异常!"); - } - - String layer_num = jsonStartPoint.getString("layer_num"); - - switch (layer_num) { - case "1": - point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_1").getValue(); - break; - case "2": - point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_2").getValue(); - break; - case "3": - point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_3").getValue(); - break; - default: - throw new BadRequestException("起点楼层异常:" + jsonStartPoint.getString("struct_code")); - } - point_id = wo_Point.query("point_code = '" + point_code + "'").uniqueResult(0).getString("point_id"); - } - - // 创建任务 - JSONObject param = new JSONObject(); - param.put("task_type", "010503"); - param.put("vehicle_code", jsonObject.getString("box_no")); - param.put("task_name", ""); - param.put("point_code1", jsonObject.getString("struct_code")); - param.put("point_code2", point_code); - param.put("material_id", jsonObject.getString("material_id")); - param.put("task_group_id", ""); // 任务组 - param.put("sort_seq", ""); // 任务组顺序号 - - 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", point_id); - wo_dis.update(jsonUpdateMap, "iostorinvdis_id = '" + jsonObject.getString("iostorinvdis_id") + "'"); - - // 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’ - JSONArray disArr = wo_dis.query("struct_id = '" + jsonObject.getString("struct_id") + - "' and iostorinv_id = '" + jsonObject.getString("iostorinv_id") + - "' and iostorinvdis_id <> '" + jsonObject.getString("iostorinvdis_id") + - "' and work_status = '00'").getResultJSONArray(0); - - // 依次更新相同仓位的分配明细状态、任务标识、出库点位 - for (int n = 0; n < disArr.size(); n++) { - JSONObject jsonObject2 = disArr.getJSONObject(n); - jsonObject2.put("work_status", "01"); - jsonObject2.put("task_id", jsonTask.getLong("task_id")); - jsonObject2.put("point_id", point_id); - wo_dis.update(jsonObject2); - } - - // 更新出库任务:任务组和顺序号 - JSONObject jsonTaskLast1 = wo_Task.query("task_group_id = '" + task_group_id + "' order by sort_seq DESC").uniqueResult(0); - jsonTask.put("task_group_id", task_group_id); - if (ObjectUtil.isEmpty(jsonTaskLast1)) { - jsonTask.put("sort_seq", 1); - } else { - jsonTask.put("sort_seq", jsonTaskLast1.getIntValue("sort_seq") + 1); - } - wo_Task.update(jsonTask); - - /* - * 判断下一个出库仓位是否相邻 - */ - int out_order_seq = jsonObject.getIntValue("out_order_seq"); - boolean canAdd = true; - int nextNum = j + 1; - while (canAdd) { - // 判断数组是否到头 - if (nextNum <= disRowArrNew.size() - 1) { - JSONObject jsonNext = disRowArrNew.getJSONObject(nextNum); - int out_order_seq_next = jsonNext.getIntValue("out_order_seq"); - if (Math.abs(out_order_seq_next - out_order_seq) != nextNum) { - // 下发当前任务组 - outTask.immediateNotifyAcs(null); - - // 更新任务组 - task_group_id = IdUtil.getSnowflake(1, 1).nextId(); - canAdd = false; - } else { - // 查询此任务组最后一个生成的任务 - JSONObject jsonTaskLast = wo_Task.query("task_group_id = '" + task_group_id + "' order by sort_seq DESC").uniqueResult(0); - // 创建任务并添加到任务组 - JSONObject param2 = new JSONObject(); - param2.put("task_type", "010503"); - param2.put("vehicle_code", jsonNext.getString("box_no")); - param2.put("task_name", ""); - param2.put("point_code1", jsonNext.getString("struct_code")); - param2.put("point_code2", point_code); - param2.put("material_id", jsonNext.getString("material_id")); - param2.put("task_group_id", task_group_id); // 任务组 - param2.put("sort_seq", jsonTaskLast.getIntValue("sort_seq") + 1); // 任务组顺序号 - - String create_task_id2 = outTask.createTask(param2); - - // 更新分配状态、任务标识、出库点位 - JSONObject jsonTask2 = wo_Task.query("task_id = '" + create_task_id2 + "'").uniqueResult(0); - JSONObject jsonUpdateMap2 = new JSONObject(); - jsonUpdateMap2.put("work_status", "01"); - jsonUpdateMap2.put("task_id", jsonTask2.getLong("task_id")); - jsonUpdateMap2.put("point_id", point_id); - wo_dis.update(jsonUpdateMap2, "iostorinvdis_id = '" + jsonNext.getString("iostorinvdis_id") + "'"); - - // 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’ - JSONArray disArr2 = wo_dis.query("struct_id = '" + jsonNext.getString("struct_id") + - "' and iostorinv_id = '" + jsonNext.getString("iostorinv_id") + - "' and iostorinvdis_id <> '" + jsonNext.getString("iostorinvdis_id") + - "' and work_status = '00'").getResultJSONArray(0); - - // 依次更新相同仓位的分配明细状态、任务标识、出库点位 - for (int m = 0; m < disArr2.size(); m++) { - JSONObject jsonObject3 = disArr2.getJSONObject(m); - jsonObject3.put("work_status", "01"); - jsonObject3.put("task_id", jsonTask2.getLong("task_id")); - jsonObject3.put("point_id", point_id); - wo_dis.update(jsonObject3); - } - - nextNum++; + canAdd = false; + canOut = true; } - } else { - canAdd = false; - canOut = true; } - } - if (canOut) { - // 下发当前任务组 - outTask.immediateNotifyAcs(null); - disRowArrNew.clear(); + if (canOut) { + // 下发当前任务组 + outTask.immediateNotifyAcs(null); + disRowArrNew.clear(); - // 更新任务组 - task_group_id = IdUtil.getSnowflake(1, 1).nextId(); - } else { - } + // 更新任务组 + task_group_id = IdUtil.getSnowflake(1, 1).nextId(); + } else { + } + return null; + }, new JSONArray()); } @Transactional(rollbackFor = Exception.class) diff --git a/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue b/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue index 0b562af42..4c1801ede 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue +++ b/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue @@ -601,29 +601,6 @@ export default { }) } }, - oneSetPoint() { - if (this.form2.point_code === '') { - this.crud.notify('请先选择站点!', CRUD.NOTIFICATION_TYPE.INFO) - return - } - if (this.currentDis.point_code) { - this.crud.notify('站点已设置!', CRUD.NOTIFICATION_TYPE.INFO) - return - } - if (this.currentDis.work_status !== '00') { - this.crud.notify('任务已生成!', CRUD.NOTIFICATION_TYPE.INFO) - return - } - if (this.currentDis.iostorinvdis_id !== null) { - this.currentDis.point_code = this.form2.point_code - checkoutbill.oneSetPoint(this.currentDis).then(res => { - this.queryTableDdis(this.currentDis.iostorinvdtl_id) - this.crud.notify('设置成功!', CRUD.NOTIFICATION_TYPE.INFO) - }).catch(() => { - this.currentDis.point_code = '' - }) - } - }, oneSetPoint2() { if (this.form2.point_code === '') { this.crud.notify('请先选择站点!', CRUD.NOTIFICATION_TYPE.INFO)