From c2b2f6492c174da3904f6ab8d144c943af656e8f Mon Sep 17 00:00:00 2001 From: liuxy Date: Mon, 13 Feb 2023 23:11:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/service/impl/AcsToWmsServiceImpl.java | 90 ++++++++++++------- .../st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql | 4 +- 2 files changed, 59 insertions(+), 35 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index a505051ea..83a7012a4 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -265,47 +265,57 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { 3、任务下发,判断巷道的任务类型,只能为空盘入库或者无任务类型; * */ vehicle_code = CodeUtil.getNewCode("VEHICCLE_CODE_KTP"); - JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "21").process().uniqueResult(0); + JSONArray emptyArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "21").process().getResultJSONArray(0); JSONObject struct_jo = new JSONObject(); - if (ObjectUtil.isNotEmpty(empty_row)) { + for (int i = 0; i < emptyArr.size(); i++) { + JSONObject empty_row = emptyArr.getJSONObject(i); + String block_num = empty_row.getString("block_num"); String row_num = empty_row.getString("row_num"); String placement_type = empty_row.getString("placement_type"); - if (placement_type.equals("03")) { - // 右通 - struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0); - } else if (placement_type.equals("02")) { - // 左通 - struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0); - } else { - // 双通 + JSONArray isLock = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('4','5') AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0); - // 先倒序找到第一个托盘、判断上一个是否有货位 - JSONObject jsonDescBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0); - String out_order_seq = jsonDescBox.getString("out_order_seq"); - // 上一个货位顺序号 - String out_order_seq_desc = String.valueOf(NumberUtil.add(out_order_seq, "1")); - JSONObject jsonDescStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq = '" + out_order_seq_desc + "'").uniqueResult(0); - - if (ObjectUtil.isNotEmpty(jsonDescStruct)) { - struct_jo = jsonDescStruct; + if (ObjectUtil.isEmpty(isLock)) { + if (placement_type.equals("03")) { + // 右通 + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0); + break; + } else if (placement_type.equals("02")) { + // 左通 + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0); + break; } else { - // 没有就正序找到第一个托盘、判断上一个是否有货位 - JSONObject jsonAscBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0); - String out_order_seq2 = jsonAscBox.getString("out_order_seq"); - // 上一个货位顺序号 - String out_order_seq_asc = String.valueOf(NumberUtil.sub(out_order_seq2, "1")); - JSONObject jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq = '" + out_order_seq_asc + "'").uniqueResult(0); + // 双通 - if (ObjectUtil.isNotEmpty(jsonAscStruct)) { - struct_jo = jsonAscStruct; + // 先倒序找到第一个托盘、判断上一个是否有货位 + JSONObject jsonDescBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0); + String out_order_seq = jsonDescBox.getString("out_order_seq"); + // 上一个货位顺序号 + JSONObject jsonDescStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonDescStruct)) { + struct_jo = jsonDescStruct; + break; + } else { + // 没有就正序找到第一个托盘、判断上一个是否有货位 + JSONObject jsonAscBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0); + String out_order_seq2 = jsonAscBox.getString("out_order_seq"); + // 上一个货位顺序号 + JSONObject jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jsonAscStruct)) { + struct_jo = jsonAscStruct; + break; + } } } - + } else { + continue; } } + if (ObjectUtil.isEmpty(struct_jo)) { throw new BadRequestException("未查询到可用的空载具存放点位!"); } @@ -333,20 +343,31 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { b、没有,则优先找空的巷道;按空位置顺序分配; 3、任务下发,判断巷道的任务类型,只能为空盘入库或者无任务类型; * */ - JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "22").process().uniqueResult(0); + JSONArray empArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "22").process().getResultJSONArray(0); JSONObject struct_jo = new JSONObject(); - if (ObjectUtil.isNotEmpty(empty_row)) { + for (int i = 0; i < empArr.size(); i++) { + JSONObject empty_row = empArr.getJSONObject(i); + String block_num = empty_row.getString("block_num"); String row_num = empty_row.getString("row_num"); String placement_type = empty_row.getString("placement_type"); - if (placement_type.equals("01") || placement_type.equals("03")) { - struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq").uniqueResult(0); + JSONArray isLock = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('4','5') AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0); + + if (ObjectUtil.isEmpty(isLock)) { + if (placement_type.equals("01") || placement_type.equals("03")) { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq").uniqueResult(0); + break; + } else { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq desc").uniqueResult(0); + break; + } } else { - struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq desc").uniqueResult(0); + continue; } } + if (ObjectUtil.isEmpty(struct_jo)) { throw new BadRequestException("未查询到可用的空载具!"); } @@ -364,6 +385,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { map.put("lock_type", "4"); point_table.update(map, "point_code = '" + struct_jo.getString("struct_code") + "'"); struct_table.update(map, "struct_code = '" + struct_jo.getString("struct_code") + "'"); + + + } if (type.equals("4")) { //查询该木箱对应的包装关系 diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql index 008f849f0..21ee4861c 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/wql/QST_IVT_RAWASSISTISTOR.wql @@ -795,7 +795,7 @@ sa.row_num, sa.placement_type ORDER BY - sa.placement_type DESC + sa.block_num DESC ENDSELECT ENDQUERY ENDIF @@ -818,7 +818,7 @@ sa.row_num, sa.placement_type ORDER BY - sa.placement_type DESC + sa.block_num DESC ENDSELECT ENDQUERY ENDIF