From e5c80d57b66b613c97da315ff7eb0d059021cb3b Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Thu, 2 Mar 2023 11:25:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amb/service/impl/AMHandServiceImpl.java | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java index 1ceb380..064ee79 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java @@ -787,6 +787,50 @@ public class AMHandServiceImpl implements AMHandService { if (StrUtil.equals(material_type, "1")) { status = "1"; } + + if (device_codes.size() > 2) { + throw new BadRequestException("所选设备个数不能大于2!"); + } + if (device_codes.size() == 2) { + //将数组转换为集合判断是否为同一排的库位,并按照库位顺序号排序 + List start_device_code_list = JSONArray.parseArray(device_codes.toJSONString(), String.class); + Collections.sort(start_device_code_list, new Comparator() { + @Override + public int compare(String s1, String s2) { + String start_i = s1.split("_")[0]; + String start_j = s2.split("_")[0]; + if (!StrUtil.equals(start_i, start_j)) { + throw new BadRequestException("请选择同一排待塑区库位!"); + } + int end_i = Integer.parseInt(s1.split("_")[s1.split("_").length - 1]); + int end_j = Integer.parseInt(s2.split("_")[s2.split("_").length - 1]); + if (end_i > end_j) { + return 1; + } else if (end_i < end_j) { + return -1; + } + return 0; + } + }); + String s = start_device_code_list.get(0); + String e = start_device_code_list.get(1); + String row_num = s.split("_")[0]; + int s_col_num = Integer.parseInt(s.split("_")[s.split("_").length - 1]); + int e_col_num = Integer.parseInt(e.split("_")[e.split("_").length - 1]); + device_codes = new JSONArray(); +// start_device_codes = JSONArray.parseArray(JSON.toJSONString(start_device_code_list)); + for (int i = s_col_num; i <= e_col_num; i++) { + String col_num = ""; + if (i < 10) { + col_num = "0" + i; + } else { + col_num = String.valueOf(i); + } + String point_code = row_num + "_" + col_num; + device_codes.add(point_code); + } + } + JSONObject map = new JSONObject(); if (StrUtil.equals(type, "1")) { map.put("material_type", material_type); @@ -907,7 +951,7 @@ public class AMHandServiceImpl implements AMHandService { // start_device_codes = JSONArray.parseArray(JSON.toJSONString(start_device_code_list)); for (int i = s_col_num; i <= e_col_num; i++) { String col_num = ""; - if (i < 10){ + if (i < 10) { col_num = "0" + i; } else { col_num = String.valueOf(i);