From 6439daf3ccfba6f0c6396e4a54e479a0996c1b13 Mon Sep 17 00:00:00 2001 From: liuxy Date: Fri, 3 Feb 2023 21:28:17 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pda/st/service/impl/PrintServiceImpl.java | 10 ++- .../src/main/java/org/nl/wms/pdm/wql/pdm.xls | Bin 249344 -> 249856 bytes .../impl/RawAssistIStorServiceImpl.java | 60 +++++++++++++++--- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java index 5d6828bd5..121c70358 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.*; +import java.util.HashMap; /** * @author liuxy @@ -83,6 +84,7 @@ public class PrintServiceImpl implements PrintService { String date_of_FG_inbound = jsonInbound.getString("date_of_fg_inbound"); //毛重 String box_weight = NumberUtil.round(box_jo.getString("box_weight"),2).toString(); +// String box_weight = NumberUtil.round(box_jo.getString("real_weight"),2).toString(); //生产日期:取此箱子中最晚的生产日期 JSONObject jsonProduction = subTab.query("package_box_sn = '" + box_no + "' order by date_of_production DESC").uniqueResult(0); String date_of_production = jsonProduction.getString("date_of_production"); @@ -211,7 +213,13 @@ public class PrintServiceImpl implements PrintService { //入库日期:取此箱子中最晚的入库日期 JSONObject jsonInbound= subTab.query("package_box_sn = '" + box_no + "' order by date_of_fg_inbound DESC").uniqueResult(0); String date_of_FG_inbound = jsonInbound.getString("date_of_fg_inbound"); - //毛重 + //更新实际重量 + double real_weight = whereJson.getDoubleValue("box_weight"); + HashMap map = new HashMap<>(); + map.put("real_weight",real_weight); + + subTab.update(map,"package_box_sn = '"+package_box_sn+"'"); + String box_weight = NumberUtil.round(whereJson.getString("box_weight"),2).toString(); //生产日期:取此箱子中最晚的生产日期 JSONObject jsonProduction = subTab.query("package_box_sn = '" + box_no + "' order by date_of_production DESC").uniqueResult(0); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/wql/pdm.xls b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/wql/pdm.xls index dd66267d3f0931375366a2188db48fd8408a7be9..88b2e50dedc5cb55dd3a03c09cad3f324f741156 100644 GIT binary patch delta 11523 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 RGXD@=KyDZd57E=j{txPhkx~Ev diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/RawAssistIStorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/RawAssistIStorServiceImpl.java index eaddce640..023398aa0 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/RawAssistIStorServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/RawAssistIStorServiceImpl.java @@ -852,21 +852,61 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { 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); + 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; } 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); + // 说明这排有任务在执行,新开一排 + //根据分切计划查询该订单物料大概还有多少未入 + row_map.put("flag", "12"); + JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + if (ObjectUtil.isEmpty(plan_rows)) { + plan_rows = new JSONArray(); + } + //查询该销售订单及行号有多少个生成状态的箱子 + row_map.put("flag", "27"); + JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0); + if (ObjectUtil.isEmpty(box_rows)) { + box_rows = new JSONArray(); + } + int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size(); + + //查询数量与订单物料箱子数量相近的一排 + JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "13").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num),block_num,row_num").process().uniqueResult(0); + if (ObjectUtil.isNotEmpty(empty_row)) { + String block_num2 = empty_row.getString("block_num"); + String row_num2 = empty_row.getString("row_num"); + String placement_type2 = empty_row.getString("placement_type"); + + if (placement_type.equals("02")) { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num2 + "' AND row_num = '" + row_num2 + "' AND placement_type = '" + placement_type2 + "' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq ASC").uniqueResult(0); + } else { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num2 + "' AND row_num = '" + row_num2 + "' AND placement_type = '" + placement_type2 + "'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0); + } + } else { + + //如果查询不到空的一排,则查询有空位双通的一排 + JSONObject have_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0); + + if (ObjectUtil.isNotEmpty(have_row)) { + String block_num3 = have_row.getString("block_num"); + String row_num3 = have_row.getString("row_num"); + + //判断该排是左边为空,还是右边为空 + JSONObject right_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq").uniqueResult(0); + JSONObject left_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq desc").uniqueResult(0); + if (StrUtil.isNotEmpty(right_str.getString("storagevehicle_code")) || !right_str.getString("lock_type").equals("1")) { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0); + } + if (StrUtil.isNotEmpty(left_str.getString("storagevehicle_code")) || !left_str.getString("lock_type").equals("1")) { + struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0); + } + } + + } - if (ObjectUtil.isNotEmpty(jsonAscStruct)) struct_jo = jsonAscStruct; } - } } else { //如果不存在相同订单物料的巷道 @@ -904,7 +944,7 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '" + placement_type + "'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0); } } else { - + //如果查询不到空的一排,则查询有空位双通的一排 JSONObject have_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0); From 00027e655d54df1632d8bd2ae19feb5545d9c77e Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Fri, 3 Feb 2023 22:20:08 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logPath_IS_UNDEFINED/ACS请求WMS/2023-02-03.0.log | 0 .../logPath_IS_UNDEFINED/ACS请求立库/2023-02-03.0.log | 0 .../AgvNdcOneDeviceDriver/2023-02-03.0.log | 0 .../logPath_IS_UNDEFINED/WMS下发ACS/2023-02-03.0.log | 0 .../logPath_IS_UNDEFINED/一楼NDC系统/2023-02-03.0.log | 0 .../logPath_IS_UNDEFINED/下发KEP信号/2023-02-03.0.log | 0 .../logPath_IS_UNDEFINED/立库请求ACS/2023-02-03.0.log | 0 .../StandardCoveyorControlWithScannerDeviceDriver.java | 1 + acs/nladmin-ui/src/views/system/monitor/device/index.vue | 6 +++--- 9 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 acs/nladmin-system/logPath_IS_UNDEFINED/ACS请求WMS/2023-02-03.0.log create mode 100644 acs/nladmin-system/logPath_IS_UNDEFINED/ACS请求立库/2023-02-03.0.log create mode 100644 acs/nladmin-system/logPath_IS_UNDEFINED/AgvNdcOneDeviceDriver/2023-02-03.0.log create mode 100644 acs/nladmin-system/logPath_IS_UNDEFINED/WMS下发ACS/2023-02-03.0.log create mode 100644 acs/nladmin-system/logPath_IS_UNDEFINED/一楼NDC系统/2023-02-03.0.log create mode 100644 acs/nladmin-system/logPath_IS_UNDEFINED/下发KEP信号/2023-02-03.0.log create mode 100644 acs/nladmin-system/logPath_IS_UNDEFINED/立库请求ACS/2023-02-03.0.log diff --git a/acs/nladmin-system/logPath_IS_UNDEFINED/ACS请求WMS/2023-02-03.0.log b/acs/nladmin-system/logPath_IS_UNDEFINED/ACS请求WMS/2023-02-03.0.log new file mode 100644 index 000000000..e69de29bb diff --git a/acs/nladmin-system/logPath_IS_UNDEFINED/ACS请求立库/2023-02-03.0.log b/acs/nladmin-system/logPath_IS_UNDEFINED/ACS请求立库/2023-02-03.0.log new file mode 100644 index 000000000..e69de29bb diff --git a/acs/nladmin-system/logPath_IS_UNDEFINED/AgvNdcOneDeviceDriver/2023-02-03.0.log b/acs/nladmin-system/logPath_IS_UNDEFINED/AgvNdcOneDeviceDriver/2023-02-03.0.log new file mode 100644 index 000000000..e69de29bb diff --git a/acs/nladmin-system/logPath_IS_UNDEFINED/WMS下发ACS/2023-02-03.0.log b/acs/nladmin-system/logPath_IS_UNDEFINED/WMS下发ACS/2023-02-03.0.log new file mode 100644 index 000000000..e69de29bb diff --git a/acs/nladmin-system/logPath_IS_UNDEFINED/一楼NDC系统/2023-02-03.0.log b/acs/nladmin-system/logPath_IS_UNDEFINED/一楼NDC系统/2023-02-03.0.log new file mode 100644 index 000000000..e69de29bb diff --git a/acs/nladmin-system/logPath_IS_UNDEFINED/下发KEP信号/2023-02-03.0.log b/acs/nladmin-system/logPath_IS_UNDEFINED/下发KEP信号/2023-02-03.0.log new file mode 100644 index 000000000..e69de29bb diff --git a/acs/nladmin-system/logPath_IS_UNDEFINED/立库请求ACS/2023-02-03.0.log b/acs/nladmin-system/logPath_IS_UNDEFINED/立库请求ACS/2023-02-03.0.log new file mode 100644 index 000000000..e69de29bb diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java index 7277df9df..950595ff7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java @@ -828,6 +828,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe jo.put("mode", mode); jo.put("move", move); jo.put("action", action); + jo.put("is_click", true); jo.put("isOnline", this.getIsonline()); jo.put("error", this.getError()); jo.put("isError", this.getIserror()); diff --git a/acs/nladmin-ui/src/views/system/monitor/device/index.vue b/acs/nladmin-ui/src/views/system/monitor/device/index.vue index 27daccefa..df82add74 100644 --- a/acs/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/system/monitor/device/index.vue @@ -97,13 +97,13 @@ - + - + @@ -309,7 +309,6 @@ export default { this.dialogFormVisible5 = true } else if (clickObj.data.driver_type === 'standard_conveyor_control_with_scanner') { this.dialogFormVisible5 = true - console.log('11111111111') } else { this.dialogFormVisible = true } @@ -322,6 +321,7 @@ export default { this.form.requireSucess = clickObj.data.requireSucess this.form.fullrequireSucess = clickObj.data.fullrequireSucess this.form.is_disable = clickObj.data.is_disable1 + this.form.applySucess = clickObj.data.applySucess }, moveShow(nodeData) { // 点击之后显示出来的数据----只需要设备信息 let item = '' From 2db47e8cbc255d7cab647cf9df7fba3f61d2cb88 Mon Sep 17 00:00:00 2001 From: ludj Date: Fri, 3 Feb 2023 22:57:19 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=8C=87=E4=BB=A4=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=BF=AD=E4=BB=A3=E5=99=A8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../standard_inspect/ReadUtil.java | 109 +- .../device/service/impl/ConveyorDevice.java | 58 - .../org/nl/acs/device/service/impl/Test.java | 18 - .../service/impl/InstructionServiceImpl.java | 49 +- .../nl/acs/opc/DeviceOpcProtocolRunable.java | 27 +- .../src/main/java/org/nl/acs/opc/OpcUtl.java | 25 - .../task/service/impl/TaskServiceImpl.java | 2904 +++++++++-------- 7 files changed, 1518 insertions(+), 1672 deletions(-) delete mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java delete mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/Test.java diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/standard_inspect/ReadUtil.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/standard_inspect/ReadUtil.java index 4ce2cdeff..cb22b1dbf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/standard_inspect/ReadUtil.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/standard_inspect/ReadUtil.java @@ -21,93 +21,10 @@ import org.openscada.opc.lib.list.ServerList; import java.net.UnknownHostException; import java.util.*; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; public class ReadUtil { - public static void main(String[] args) throws AlreadyConnectedException, JIException, UnknownHostException, NotConnectedException, DuplicateGroupException, AddFailedException, InterruptedException { - // 启动服务 - /* ItemProtocol ipl = new ItemProtocol(); - List list = ipl.getReadableItemDtos(); - List ls = new ArrayList<>(); - for (ItemDto dto : list) { - //ls.add("RD3.RD3.2265."+ dto.getCode()); - } - ls.add("DDJ1.DDJ1.DDJ1.heartbeat"); - ls.add("DDJ1.DDJ1.DDJ1.action"); - final Server server = getServer(); - Map map = read(ls, server); - *//*Map params=new HashMap<>(); - params.put("RD3.RD3.2265."+"mode","0"); - write(params, server);*//* - System.out.println(111);*/ - /* try { - test(); - } catch (InterruptedException e) { - e.printStackTrace(); - }*/ - - //List> maps = showAllOpcServer("192.168.81.207", "administrator", "123", ""); - - Server server = getServer(); - List itemString = new ArrayList(); - itemString.add("RD1.RD1.1005.test"); - Map map = read(itemString, server); - System.out.println(map.get("RD1.RD1.1005.test")); -// int[] a = (int[]) map.get("RD1.RD1.1005.test"); -// for(int i=0; i itemMap = new HashMap(); -// itemMap.put("RD1.RD1.1005.test", "1.2"); - - } - - /** - * 发布订阅测试 - */ - private static final int PERIOD = 100; - - private static final int SLEEP = 2000; - - public static void test() throws AlreadyConnectedException, JIException, UnknownHostException, AddFailedException, NotConnectedException, DuplicateGroupException, InterruptedException { - /*ConnectionInformation ci = new ConnectionInformation(); - ci.setHost("10.1.5.123"); - ci.setDomain(""); - ci.setUser("freud"); - ci.setPassword("password"); - ci.setClsid("F8582CF2-88FB-11D0-B850-00C0F0104305"); - - Server server = new Server(ci, - Executors.newSingleThreadScheduledExecutor());*/ - Server server = getServer(); - - // server.connect(); - - AccessBase access = new Async20Access(server, PERIOD, false); - - access.addItem("RD1.RD1.B21.mode", new DataCallback() { - - private int count; - - @SneakyThrows - public void changed(Item item, ItemState itemstate) { - System.out.println("[" + (++count) + "],ItemName:[" - + item.getId() + "],value:" + itemstate.getValue()); - System.out.println(itemstate.getValue().isArray()); - List listB = Arrays.asList(itemstate.getValue().toString()); - System.out.println(listB.get(0)); - - } - }); - - access.bind(); - Thread.sleep(SLEEP); - access.unbind(); - server.dispose(); - } public static Server getServer(String opc_id) { //OPC表【acs_opc】 @@ -134,28 +51,6 @@ public class ReadUtil { return server; } - public static Server getServer() { - //RD1.RD1.1028 - // 连接信息 - ConnectionInformation ci = new ConnectionInformation(); - ci.setHost("192.168.81.251"); - ci.setDomain(""); - ci.setUser("administrator"); - ci.setPassword("Huawei@123"); - ci.setClsid("7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729"); - final Server server = new Server(ci, Executors.newSingleThreadScheduledExecutor()); - try { - server.connect(); - } catch (UnknownHostException e) { - e.printStackTrace(); - } catch (JIException e) { - e.printStackTrace(); - } catch (AlreadyConnectedException e) { - e.printStackTrace(); - } - return server; - } - public static void write(Map strings, Server server) { try { //Group group = this.opcServerService.getServer(opcServiceCode); @@ -198,7 +93,6 @@ public class ReadUtil { public static Map read(List itemString, Server server) { HashMap map = new HashMap(); try { - //Group group = this.opcServerService.getServer(opcServiceCode); Group group = server.addGroup(); Map items = new LinkedHashMap(); Iterator is = itemString.iterator(); @@ -226,6 +120,7 @@ public class ReadUtil { } catch (Exception e) { e.printStackTrace(); } + return map; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java deleted file mode 100644 index 9a685f316..000000000 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.nl.acs.device.service.impl; - -import lombok.Data; -import lombok.SneakyThrows; -import org.nl.acs.instruction.service.dto.InstructionDto; -import org.nl.acs.opc.OpcUtl; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.acs.task.service.impl.TaskServiceImpl; - -@Data -public class ConveyorDevice { - - String id; - - int jobNo = -1; - - int lastjobNo = -1; - - String palletNo; - - InstructionDto inst; - - RecvThread rt; - - public ConveyorDevice(String id) { - if (id == null) { - throw new NullPointerException("ID is null"); - } else { - this.id = id; - } - System.out.println("id:" + id); - rt = new RecvThread(); - rt.run(); - } - - public void adviseData() { - System.out.println("test"); - } - - private class RecvThread implements Runnable { - - @SneakyThrows - @Override - public void run() { - System.out.println("test"); - String MODE = "RD1.RD1." + id + ".mode"; - String code = OpcUtl.read(MODE); - if ("2".equals(code)) { - TaskService taskserver = new TaskServiceImpl(); - TaskDto dto = new TaskDto(); - dto.setStart_point_code(id); - dto.setNext_point_code("1002"); - taskserver.create(dto); - } - } - } -} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/Test.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/Test.java deleted file mode 100644 index 8e73a4ec3..000000000 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.nl.acs.device.service.impl; - -import java.util.ArrayList; -import java.util.List; - -public class Test { - - public static void main(String[] args) { - String device = "1001,1002"; - List list = new ArrayList<>(); - list.add("1001"); - list.add("1002"); - for (int i = 0; i < list.size(); i++) { - ConveyorDevice condev = new ConveyorDevice(list.get(i).toString()); - } - - } -} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 4c688395a..f3901dfd0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -1089,12 +1089,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByLinkNumSend(String code) { - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) { return inst; } } + return null; } @@ -1102,8 +1104,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public List findByLinkNum(String code) { List list = new ArrayList<>(); - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { list.add(inst); } @@ -1113,19 +1116,22 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByLinkNumNoSend(String code) { - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { return inst; } } + return null; } @Override public Instruction findByCodeFromCache(String code) { - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); if (StrUtil.equals(code, inst.getInstruction_code())) { return inst; } @@ -1136,8 +1142,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByBarcodeFromCache(String barcode) { - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); if (StrUtil.equals(barcode, inst.getVehicle_code())) { return inst; } @@ -1147,9 +1154,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByIdFromCache(String id) { - - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); if (StrUtil.equals(id, inst.getInstruction_id())) { return inst; } @@ -1244,8 +1251,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Integer querySameDestinationInst(String devicecode) { int num = 0; - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); //处理空盘位站点 String next_code = inst.getNext_point_code(); if (next_code.indexOf(".") != -1) { @@ -1255,14 +1263,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu num = num + 1; } } + return num; } @Override public Integer querySameInstType(String inst_type) { int num = 0; - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); if (StrUtil.equals(inst.getInstruction_type(), inst_type)) { num = num + 1; } @@ -1273,8 +1283,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Integer querySameOriginInst(String devicecode) { int num = 0; - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); + Iterator it = instructions.iterator(); + while (it.hasNext()){ + Instruction inst = it.next(); //处理空盘位站点 String start_code = inst.getStart_point_code(); if (start_code.indexOf(".") != -1) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java index 2c06c54c7..49269e427 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java @@ -21,6 +21,8 @@ public class DeviceOpcProtocolRunable implements Runnable { String message; private Server server; + Group group; + public DeviceOpcProtocolRunable() { this.error_num = 0; this.message = null; @@ -62,13 +64,15 @@ public class DeviceOpcProtocolRunable implements Runnable { public void run() { while (true) { try { - server = OpcServerUtl.getServerWithOutException( + server = + OpcServerUtl.getServerWithOutException( this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); - Group group = server.addGroup(); + group = server.addGroup(); + List itemsString = new ArrayList(); Iterator it = this.protocols.iterator(); @@ -117,10 +121,12 @@ public class DeviceOpcProtocolRunable implements Runnable { label97: while (true) { -// System.out.println("label97"); + // System.out.println("label97"); long begin = System.currentTimeMillis(); Map itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0])); + //TODO 读完释放server可行否? + long end = System.currentTimeMillis(); log.trace("{} 开始记时{}", tag, DateUtil.now()); long duration = end - begin; @@ -135,12 +141,13 @@ public class DeviceOpcProtocolRunable implements Runnable { time_out = false; } + // A1_HK_04.A1_HK_04.A1_HK_04_3.door 列表 Set items = itemStatus.keySet(); Iterator var18 = items.iterator(); while (true) { -// System.out.println("label98"); Item item; + // A1_HK_04.A1_HK_04.A1_HK_04_3.door // 当前值 Object value; // 旧的值 @@ -155,6 +162,7 @@ public class DeviceOpcProtocolRunable implements Runnable { this.error_num = 0; this.message = null; } + // 所有信号读完并且没有变化的值 continue label97; } @@ -183,7 +191,6 @@ public class DeviceOpcProtocolRunable implements Runnable { log.info("信号{}变更从{}->{};信号快照:{}", new Object[] {item.getId(), his, value, sb}); } - System.out.println("设置值:【"+item.getId()+"】-->"+value); // 设置值 accessor_value.setValue(item.getId(), value); } @@ -197,6 +204,15 @@ public class DeviceOpcProtocolRunable implements Runnable { this.server = null; } + if (group != null) { + try { + group.clear(); + group.remove(); + } catch (Exception var6) { + } + this.group = null; + } + String error_message = "设备信息同步异常"; if (!StrUtil.equals(this.message, error_message)) { log.warn("", var30); @@ -215,5 +231,4 @@ public class DeviceOpcProtocolRunable implements Runnable { } } } - } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java index e03649e7f..3ed420b6d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java @@ -268,31 +268,6 @@ public class OpcUtl { return value; } - public static String read(String item) throws Exception { - System.out.println(item); - Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", ""); -// String byteItemString = "RD1.RD1.1001.mode"; - Group group = server.addGroup(); - Item byteItem = group.addItem(item); - ItemState itemState = null; - JIVariant value = null; - itemState = byteItem.read(true); - value = itemState.getValue(); - String data = OpcUtl.getValue(byteItem, itemState) + ""; - return data; - } - public static void main(String[] args) throws Exception { - Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", ""); - String byteItemString = "RD1.RD1.1001.mode"; - Group group = server.addGroup(); - Item byteItem = group.addItem(byteItemString); - ItemState itemState = null; - JIVariant value = null; - System.out.println(byteItem.getId()); - itemState = byteItem.read(true); - System.out.println(itemState.getQuality()); - System.out.println(getValue(byteItem, itemState)); - } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index a1fcaa4f7..7b43f2516 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -1,7 +1,5 @@ - package org.nl.acs.task.service.impl; - import cn.hutool.core.date.DateUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.IdUtil; @@ -61,1482 +59,1510 @@ import java.util.stream.Collectors; * @author ldjun * @description 服务实现 * @date 2021-03-18 - **/ + */ @Service @RequiredArgsConstructor @Slf4j public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { - List tasks = new ArrayList(); + List tasks = new ArrayList(); - @Autowired - DeviceAppService deviceAppService; - @Autowired - RouteLineService routelineserver; - @Autowired - AcsToWmsService acstowmsService; - @Autowired - TaskFeedbackService taskFeedbackService; - @Autowired - ParamService paramService; - @Autowired - XianGongAgvService agvService; - @Autowired - RouteLineService routeLineService; - @Autowired - DeviceAssignedService deviceAssignedService; - @Autowired - InstructionService instructionService; - @Autowired - StorageCellService storageCellService; + @Autowired DeviceAppService deviceAppService; + @Autowired RouteLineService routelineserver; + @Autowired AcsToWmsService acstowmsService; + @Autowired TaskFeedbackService taskFeedbackService; + @Autowired ParamService paramService; + @Autowired XianGongAgvService agvService; + @Autowired RouteLineService routeLineService; + @Autowired DeviceAssignedService deviceAssignedService; + @Autowired InstructionService instructionService; + @Autowired StorageCellService storageCellService; - @Override - public void autoInitial() throws Exception { - this.reload(); + @Override + public void autoInitial() throws Exception { + this.reload(); + } + + public synchronized void reload() { + this.tasks = this.queryAll("task_status <2 and is_delete =0 order by create_time"); + } + + @Override + public List queryAll(String whereJson) { + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONArray arr = wo.query(whereJson).getResultJSONArray(0); + List list = arr.toJavaList(TaskDto.class); + return list; + } + + @Override + public Map queryAll(Map whereJson, Pageable page) { + + // WQLObject wo = WQLObject.getWQLObject("acs_task"); + // ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time + // desc"); + HashMap map = new HashMap<>(); + map.put("flag", "1"); + String task_code = (String) whereJson.get("task_code"); + String vehicle_code = (String) whereJson.get("vehicle_code"); + String material_type = (String) whereJson.get("material_type"); + String status = (String) whereJson.get("status"); + String point_code = (String) whereJson.get("point_code"); + String is_over = (String) whereJson.get("is_over"); + if (!StrUtil.isEmpty(task_code)) { + map.put("task_code", task_code); + } + if (!StrUtil.isEmpty(vehicle_code)) { + map.put("vehicle_code", vehicle_code); + } + if (!StrUtil.isEmpty(material_type)) { + map.put("material_type", material_type); + } + if (!StrUtil.isEmpty(status)) { + map.put("status", status); + } + if (!StrUtil.isEmpty(point_code)) { + map.put("point_code", point_code); + } + if (!StrUtil.isEmpty(is_over)) { + map.put("is_over", is_over); + } + final JSONObject jo = + WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), ""); + return jo; + } + + @Override + public Map queryAllByCache(Map whereJson, Pageable page) { + this.reload(); + String task_code = (String) whereJson.get("task_code"); + String vehicle_code = (String) whereJson.get("vehicle_code"); + String material_type = (String) whereJson.get("material_type"); + String status = (String) whereJson.get("status"); + String point_code = (String) whereJson.get("point_code"); + String is_over = (String) whereJson.get("is_over"); + String task_type = (String) whereJson.get("task_type"); + List taskList = new ArrayList(); + + Iterator it = tasks.iterator(); + while (it.hasNext()) { + TaskDto task = it.next(); + if ("1".equals(is_over) && Integer.valueOf(task.getTask_status()) < 2) { + continue; + } + if (!"1".equals(is_over) && Integer.valueOf(task.getTask_status()) >= 2) { + continue; + } + if (!ObjectUtil.isEmpty(task_code) && !task.getTask_code().contains(task_code)) { + continue; + } + if (!ObjectUtil.isEmpty(status) && !task.getTask_status().equals(status)) { + continue; + } + if (!ObjectUtil.isEmpty(vehicle_code) && !task.getVehicle_code().contains(vehicle_code)) { + continue; + } + if (!ObjectUtil.isEmpty(material_type) && !task.getMaterial().equals(material_type)) { + continue; + } + if (!ObjectUtil.isEmpty(point_code) + && !(task.getStart_point_code().contains(point_code) + || task.getNext_point_code().contains(point_code))) { + continue; + } + if (!ObjectUtil.isEmpty(task_type) && !task.getTask_type().equals(task_type)) { + continue; + } + taskList.add(task); } - public synchronized void reload() { - this.tasks = this.queryAll("task_status <2 and is_delete =0 order by create_time"); + // 按照创建时间排序 + taskList = + taskList.stream() + .sorted( + (task1, task2) -> + DateUtil.compare( + DateUtil.parseDate(task1.getCreate_time()), + DateUtil.parse(task2.getCreate_time()))) + .collect(Collectors.toList()); + + Integer currentPageNumber = page.getPageNumber() + 1; + Integer pageMaxSize = page.getPageSize(); + List taskDtoList = + taskList.stream() + .skip((currentPageNumber - 1) * pageMaxSize) + .limit(pageMaxSize) + .collect(Collectors.toList()); + JSONObject jo = new JSONObject(); + jo.put("content", taskDtoList); + jo.put("totalElements", taskList.size()); + return jo; + } + + @Override + public Map getAll(Map whereJson, Pageable page) { + // WQLObject wo = WQLObject.getWQLObject("acs_task"); + // ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time + // desc"); + HashMap map = new HashMap<>(); + map.put("flag", "2"); + String task_code = (String) whereJson.get("task_code"); + String vehicle_code = (String) whereJson.get("vehicle_code"); + String material_type = (String) whereJson.get("material_type"); + String status = (String) whereJson.get("status"); + String point_code = (String) whereJson.get("point_code"); + String create_time = (String) whereJson.get("createTime"); + String end_time = (String) whereJson.get("end_time"); + if (!StrUtil.isEmpty(task_code)) { + map.put("task_code", task_code); } - - @Override - public List queryAll(String whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONArray arr = wo.query(whereJson).getResultJSONArray(0); - List list = arr.toJavaList(TaskDto.class); - return list; + if (!StrUtil.isEmpty(vehicle_code)) { + map.put("vehicle_code", vehicle_code); } - - @Override - public Map queryAll(Map whereJson, Pageable page) { - - //WQLObject wo = WQLObject.getWQLObject("acs_task"); - //ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time desc"); - HashMap map = new HashMap<>(); - map.put("flag", "1"); - String task_code = (String) whereJson.get("task_code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String is_over = (String) whereJson.get("is_over"); - if (!StrUtil.isEmpty(task_code)) { - map.put("task_code", task_code); - } - if (!StrUtil.isEmpty(vehicle_code)) { - map.put("vehicle_code", vehicle_code); - } - if (!StrUtil.isEmpty(material_type)) { - map.put("material_type", material_type); - } - if (!StrUtil.isEmpty(status)) { - map.put("status", status); - } - if (!StrUtil.isEmpty(point_code)) { - map.put("point_code", point_code); - } - if (!StrUtil.isEmpty(is_over)) { - map.put("is_over", is_over); - } - final JSONObject jo = WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), ""); - return jo; + if (!StrUtil.isEmpty(material_type)) { + map.put("material_type", material_type); } + if (!StrUtil.isEmpty(status)) { + map.put("status", status); + } + if (!StrUtil.isEmpty(point_code)) { + map.put("point_code", point_code); + } + if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) { + map.put("create_time", create_time); + map.put("end_time", end_time); + } + JSONObject jsonObject1 = + WQL.getWO("QTASK_QUERY") + .addParamMap(map) + .pageQuery(WqlUtil.getHttpContext(page), "create_time desc"); + JSONArray array = jsonObject1.getJSONArray("content"); + int totalElements = (Integer) jsonObject1.get("totalElements"); + JSONArray arr = new JSONArray(); + for (int i = 0; i < array.size(); i++) { + JSONObject jsonObject = (JSONObject) array.get(i); + jsonObject.put("hasChildren", true); + arr.add(jsonObject); + } + JSONObject jo = new JSONObject(); + jo.put("content", arr); + jo.put("totalElements", totalElements); + return jo; + } - @Override - public Map queryAllByCache(Map whereJson, Pageable page) { - this.reload(); - String task_code = (String) whereJson.get("task_code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String is_over = (String) whereJson.get("is_over"); - String task_type = (String) whereJson.get("task_type"); - List taskList = new ArrayList(); - for (int i = 0; i < tasks.size(); i++) { - TaskDto task = tasks.get(i); - if ("1".equals(is_over) && Integer.valueOf(task.getTask_status()) < 2) { - continue; - } - if (!"1".equals(is_over) && Integer.valueOf(task.getTask_status()) >= 2) { - continue; - } - if (!ObjectUtil.isEmpty(task_code) && !task.getTask_code().contains(task_code)) { - continue; - } - if (!ObjectUtil.isEmpty(status) && !task.getTask_status().equals(status)) { - continue; - } - if (!ObjectUtil.isEmpty(vehicle_code) && !task.getVehicle_code().contains(vehicle_code)) { - continue; - } - if (!ObjectUtil.isEmpty(material_type) && !task.getMaterial().equals(material_type)) { - continue; - } - if (!ObjectUtil.isEmpty(point_code) && !(task.getStart_point_code().contains(point_code) || task.getNext_point_code().contains(point_code))) { - continue; - } - if (!ObjectUtil.isEmpty(task_type) && !task.getTask_type().equals(task_type)) { - continue; - } - taskList.add(task); + @Override + public List queryAll(Map whereJson) { + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONArray arr = wo.query().getResultJSONArray(0); + List list = arr.toJavaList(TaskDto.class); + return list; + } + + @Override + public TaskDto findById(String task_id) { + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = wo.query("task_id ='" + task_id + "'").uniqueResult(0); + final TaskDto obj = json.toJavaObject(TaskDto.class); + return obj; + } + + @Override + public List queryAllUnfinished(Map whereJson) { + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONArray arr = wo.query("task_status < 2 ").getResultJSONArray(0); + List list = arr.toJavaList(TaskDto.class); + return list; + } + + @Override + public TaskDto findByCode(String code) { + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0); + final TaskDto obj = json.toJavaObject(TaskDto.class); + return obj; + } + + @Override + public List queryTaskByDeviceCode(String device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getStart_device_code().equals(device_code) + && StrUtil.equals(task.getTask_status(), "0")) { + list.add(task); + } + } + return list; + } + + @Override + public List queryTaskByStartDeviceCode(String start_device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (!StrUtil.equals(task.getTask_type(), "6")) { + continue; + } + if ((task.getStart_device_code().equals(start_device_code) + || task.getStart_device_code2().equals(start_device_code)) + && StrUtil.equals(task.getTask_status(), "0")) { + list.add(task); + } + } + return list; + } + + @Override + public List queryTaskByBackDeviceCode(String back_start_device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (!StrUtil.equals(task.getTask_type(), "6")) { + continue; + } + if (task.getStart_device_code().equals(back_start_device_code) + && StrUtil.equals(task.getTask_status(), "0")) { + list.add(task); + } + } + return list; + } + + @Override + public List queryTaskByDeviceCodeAndStatus(String device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getStart_device_code().equals(device_code) + && StrUtil.equals(task.getTask_status(), "1")) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + list.add(task); } + } + } + return list; + } - // 按照创建时间排序 - taskList = taskList - .stream() - .sorted((task1, task2) -> DateUtil.compare(DateUtil.parseDate(task1.getCreate_time()), DateUtil.parse(task2.getCreate_time()))) - .collect(Collectors.toList()); + public List queryTaskByStartAndIntStatus(String head_start_device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (!StrUtil.equals(task.getTask_type(), "6")) { + continue; + } + if ((task.getStart_device_code().equals(head_start_device_code) + || task.getStart_device_code2().equals(head_start_device_code)) + && StrUtil.equals(task.getTask_status(), "1")) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + list.add(task); + } + } + } + return list; + } + + public List queryTaskByNextAndIntStatus(String back_start_device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (!StrUtil.equals(task.getTask_type(), "6")) { + continue; + } + if ((task.getStart_device_code().equals(back_start_device_code)) + && StrUtil.equals(task.getTask_status(), "1")) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + list.add(task); + } + } + } + return list; + } + + @Override + public TaskDto queryTaskByLinkNum(String link_num) { + return null; + } + + @Override + public List queryByStauts(String status) { + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONArray arr = wo.query("task_status = '" + status + "'").getResultJSONArray(0); + List list = arr.toJavaList(TaskDto.class); + return list; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void create(TaskDto dto) throws Exception { + dto = foramte(dto); + if (!StrUtil.isEmpty(dto.getVehicle_code())) { + TaskDto vehicle_dto = this.findByContainer(dto.getVehicle_code()); + if (vehicle_dto != null) { + throw new WDKException("已存在该载具号的任务!"); + } + } + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + String task_uuid = dto.getTask_id(); + if (StrUtil.isEmpty(task_uuid)) { + dto.setTask_id(IdUtil.simpleUUID()); + } + String task_code = dto.getTask_code(); + if (StrUtil.isEmpty(task_code)) { + task_code = CodeUtil.getNewCode("TASK_NO"); + task_code = "-" + task_code; + } + String start_point_code = dto.getStart_point_code(); + String next_point_code = dto.getNext_point_code(); + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + String route_plan_code = dto.getRoute_plan_code(); + dto.setCreate_by(currentUsername); + dto.setUpdate_by(currentUsername); + dto.setUpdate_time(now); + dto.setCreate_time(now); + dto.setTask_code(task_code); + dto.setRoute_plan_code(route_plan_code); + dto.setTask_status("0"); + dto.setStart_device_code2(dto.getStart_point_code2()); + dto.setNext_device_code2(dto.getNext_point_code2()); + + if (StrUtil.isEmpty(dto.getPriority())) { + dto.setPriority("1"); + } + String plan_code = dto.getRoute_plan_code(); + // 判断起点终点设备类型 + String startDeviceType = deviceAppService.findDeviceTypeByCode(dto.getStart_device_code()); + String nextDeviceType = deviceAppService.findDeviceTypeByCode(dto.getNext_device_code()); + if (routelineserver + .getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code) + .size() + == 0) { + throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!"); + } + String createTaskCheck = paramService.findByCode(AcsConfig.CREATETASKCHECK).getValue(); + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device nextdevice = appService.findDeviceByCode(next_device_code); + Device startdevice = appService.findDeviceByCode(start_device_code); + dto.setMaterial(startdevice.getMaterial_type()); + if (StrUtil.equals(createTaskCheck, "1")) { + // 判断起点为输送设备 + if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {} + + if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {} + } else { + // 判断起点为输送设备 + if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {} + + if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) { + // if (nextdevice.getDeviceDriver() instanceof + // StandardOrdinarySiteDeviceDriver) { + // standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) + // nextdevice.getDeviceDriver(); + // if (nextdevice.getHas_goods() != 0) { + // throw new Exception("任务终点需满足无货!"); + // } + // } - Integer currentPageNumber = page.getPageNumber() + 1; - Integer pageMaxSize = page.getPageSize(); - List taskDtoList = taskList.stream().skip((currentPageNumber - 1) * pageMaxSize).limit(pageMaxSize).collect(Collectors.toList()); JSONObject jo = new JSONObject(); - jo.put("content", taskDtoList); - jo.put("totalElements", taskList.size()); - return jo; - } - - @Override - public Map getAll(Map whereJson, Pageable page) { - //WQLObject wo = WQLObject.getWQLObject("acs_task"); - //ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time desc"); - HashMap map = new HashMap<>(); - map.put("flag", "2"); - String task_code = (String) whereJson.get("task_code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String create_time = (String) whereJson.get("createTime"); - String end_time = (String) whereJson.get("end_time"); - if (!StrUtil.isEmpty(task_code)) { - map.put("task_code", task_code); - } - if (!StrUtil.isEmpty(vehicle_code)) { - map.put("vehicle_code", vehicle_code); - } - if (!StrUtil.isEmpty(material_type)) { - map.put("material_type", material_type); - } - if (!StrUtil.isEmpty(status)) { - map.put("status", status); - } - if (!StrUtil.isEmpty(point_code)) { - map.put("point_code", point_code); - } - if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) { - map.put("create_time", create_time); - map.put("end_time", end_time); - } - JSONObject jsonObject1 = WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time desc"); - JSONArray array = jsonObject1.getJSONArray("content"); - int totalElements = (Integer) jsonObject1.get("totalElements"); - JSONArray arr = new JSONArray(); - for (int i = 0; i < array.size(); i++) { - JSONObject jsonObject = (JSONObject) array.get(i); - jsonObject.put("hasChildren", true); - arr.add(jsonObject); - } - JSONObject jo = new JSONObject(); - jo.put("content", arr); - jo.put("totalElements", totalElements); - return jo; - } - - @Override - public List queryAll(Map whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONArray arr = wo.query().getResultJSONArray(0); - List list = arr.toJavaList(TaskDto.class); - return list; - } - - @Override - public TaskDto findById(String task_id) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = wo.query("task_id ='" + task_id + "'").uniqueResult(0); - final TaskDto obj = json.toJavaObject(TaskDto.class); - return obj; - } - - @Override - public List queryAllUnfinished(Map whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONArray arr = wo.query("task_status < 2 ").getResultJSONArray(0); - List list = arr.toJavaList(TaskDto.class); - return list; - } - - @Override - public TaskDto findByCode(String code) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0); - final TaskDto obj = json.toJavaObject(TaskDto.class); - return obj; - } - - @Override - public List queryTaskByDeviceCode(String device_code) { - List list = new ArrayList<>(); - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "0")) { - list.add(task); - } - } - return list; - } - - @Override - public List queryTaskByStartDeviceCode(String start_device_code) { - List list = new ArrayList<>(); - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (!StrUtil.equals(task.getTask_type(), "6")) { - continue; - } - if ((task.getStart_device_code().equals(start_device_code) || task.getStart_device_code2().equals(start_device_code)) && StrUtil.equals(task.getTask_status(), "0")) { - list.add(task); - } - } - return list; - } - - @Override - public List queryTaskByBackDeviceCode(String back_start_device_code) { - List list = new ArrayList<>(); - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (!StrUtil.equals(task.getTask_type(), "6")) { - continue; - } - if (task.getStart_device_code().equals(back_start_device_code) && StrUtil.equals(task.getTask_status(), "0")) { - list.add(task); - } - } - return list; - } - - @Override - public List queryTaskByDeviceCodeAndStatus(String device_code) { - List list = new ArrayList<>(); - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "1")) { - Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); - if (ObjectUtil.isNotEmpty(instruction)) { - list.add(task); - } - } - } - return list; - } - - - public List queryTaskByStartAndIntStatus(String head_start_device_code) { - List list = new ArrayList<>(); - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (!StrUtil.equals(task.getTask_type(), "6")) { - continue; - } - if ((task.getStart_device_code().equals(head_start_device_code) || task.getStart_device_code2().equals(head_start_device_code)) && StrUtil.equals(task.getTask_status(), "1")) { - Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); - if (ObjectUtil.isNotEmpty(instruction)) { - list.add(task); - } - } - } - return list; - } - - public List queryTaskByNextAndIntStatus(String back_start_device_code) { - List list = new ArrayList<>(); - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (!StrUtil.equals(task.getTask_type(), "6")) { - continue; - } - if ((task.getStart_device_code().equals(back_start_device_code)) && StrUtil.equals(task.getTask_status(), "1")) { - Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); - if (ObjectUtil.isNotEmpty(instruction)) { - list.add(task); - } - } - } - return list; - } - - @Override - public TaskDto queryTaskByLinkNum(String link_num) { - return null; - } - - @Override - public List queryByStauts(String status) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONArray arr = wo.query("task_status = '" + status + "'").getResultJSONArray(0); - List list = arr.toJavaList(TaskDto.class); - return list; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void create(TaskDto dto) throws Exception { - dto = foramte(dto); - if (!StrUtil.isEmpty(dto.getVehicle_code())) { - TaskDto vehicle_dto = this.findByContainer(dto.getVehicle_code()); - if (vehicle_dto != null) { - throw new WDKException("已存在该载具号的任务!"); - } - } - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - String task_uuid = dto.getTask_id(); - if (StrUtil.isEmpty(task_uuid)) { - dto.setTask_id(IdUtil.simpleUUID()); - } - String task_code = dto.getTask_code(); - if (StrUtil.isEmpty(task_code)) { - task_code = CodeUtil.getNewCode("TASK_NO"); - task_code = "-" + task_code; - } - String start_point_code = dto.getStart_point_code(); - String next_point_code = dto.getNext_point_code(); - String start_device_code = dto.getStart_device_code(); - String next_device_code = dto.getNext_device_code(); - String route_plan_code = dto.getRoute_plan_code(); - dto.setCreate_by(currentUsername); - dto.setUpdate_by(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setTask_code(task_code); - dto.setRoute_plan_code(route_plan_code); - dto.setTask_status("0"); - dto.setStart_device_code2(dto.getStart_point_code2()); - dto.setNext_device_code2(dto.getNext_point_code2()); - - if (StrUtil.isEmpty(dto.getPriority())) { - dto.setPriority("1"); - } - String plan_code = dto.getRoute_plan_code(); - //判断起点终点设备类型 - String startDeviceType = deviceAppService.findDeviceTypeByCode(dto.getStart_device_code()); - String nextDeviceType = deviceAppService.findDeviceTypeByCode(dto.getNext_device_code()); - if (routelineserver.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).size() == 0) { - throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!"); - } - String createTaskCheck = paramService.findByCode(AcsConfig.CREATETASKCHECK).getValue(); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device nextdevice = appService.findDeviceByCode(next_device_code); - Device startdevice = appService.findDeviceByCode(start_device_code); - dto.setMaterial(startdevice.getMaterial_type()); - if (StrUtil.equals(createTaskCheck, "1")) { - //判断起点为输送设备 - if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) { - - } - if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) { - } - } else { - //判断起点为输送设备 - if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) { - - } - - if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) { -// if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { -// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); -// if (nextdevice.getHas_goods() != 0) { -// throw new Exception("任务终点需满足无货!"); -// } -// } - - JSONObject jo = new JSONObject(); - JSONObject jo2 = new JSONObject(); - if (!StrUtil.isEmpty(dto.getMaterial())) { - if (!StrUtil.equals(dto.getMaterial(), "1")) { - jo.put("hasGoodStatus", "2"); - jo.put("material_type", dto.getMaterial()); - } else { - jo.put("hasGoodStatus", "1"); - jo.put("material_type", "1"); - } - - } else { - jo.put("hasGoodStatus", "1"); - jo.put("material_type", "1"); - } - jo.put("device_code", dto.getStart_device_code()); - jo.put("quantity", dto.getQuantity()); - jo.put("remark", dto.getRemark()); - jo.put("batch", startdevice.getBatch()); - jo.put("islock", "true"); - deviceService.changeDeviceStatus(jo); - Device deviceByCode = deviceAppService.findDeviceByCode(dto.getNext_device_code()); - jo2.put("device_code", dto.getNext_device_code()); - jo2.put("hasGoodStatus", deviceByCode.getHas_goods()); - jo2.put("quantity", deviceByCode.getQuantity()); - jo2.put("remark", deviceByCode.getRemark()); - jo2.put("material_type", deviceByCode.getMaterial_type()); - jo2.put("batch", deviceByCode.getBatch()); - jo2.put("islock", "true"); - deviceService.changeDeviceStatus(jo2); - } - } - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - tasks.add(dto); - } - - /** - * 常规任务保存 - * - * @param / - * @throws Exception - */ - @Override - public void ordinaryTaskCreate(JSONObject json) throws Exception { - JSONArray array = json.getJSONArray("data"); - - if (array.size() == 0) { - throw new RuntimeException("请选择起点"); - } - for (int i = 0; i < array.size(); i++) { - JSONObject arrjo = array.getJSONObject(i); - String material_type = arrjo.getString("material_type"); - String quantity = arrjo.getString("quantity"); - String remark = arrjo.getString("remark"); - TaskDto dto = new TaskDto(); - Map whereJson = (Map) array.get(i); - - //String device_code = (String) whereJson.get("device_code"); - String device_code = MapUtil.getStr(whereJson, "device_code"); - dto.setRoute_plan_code("one"); - String next_device_code = ""; - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(device_code, plan_uuid); - for (int j = 0; j < ja.size(); j++) { - JSONObject jo = (JSONObject) ja.get(j); - next_device_code = jo.get("next_device_code").toString(); - } - if (ObjectUtil.isNotEmpty(this.findByStartCode(device_code))) { - throw new WDKException("已存在该起点的任务!"); - } - if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) { - throw new RuntimeException("请填写物料信息!"); - } - dto.setStart_device_code(device_code); - dto.setStart_point_code(device_code); - dto.setNext_device_code(next_device_code); - dto.setNext_point_code(next_device_code); - dto.setRemark(remark); - dto.setMaterial(material_type); - create(dto); - } - } - - /** - * 特殊任务保存 - * - * @param / - * @throws Exception - */ - @Override - public void specialTaskCreate(JSONObject json) throws Exception { - - JSONArray array = json.getJSONArray("data1"); - JSONArray array2 = json.getJSONArray("data2"); - JSONArray array3 = json.getJSONArray("data3"); - if (array.size() != 0 && array3.size() != 0) { - throw new RuntimeException("只能选择一个终点"); - } - - for (int i = 0; i < array2.size(); i++) { - JSONObject arrjo = array2.getJSONObject(i); - String material_type = arrjo.getString("material_type"); - String quantity = arrjo.getString("quantity"); - String remark = arrjo.getString("remark"); - TaskDto dto = new TaskDto(); - Map whereJson; - Map whereJson2; - Map whereJson3; - if (array.size() != 0) { - whereJson = (Map) array.get(i); - } else { - whereJson = null; - } - if (array2.size() != 0) { - whereJson2 = (Map) array2.get(i); - } else { - whereJson2 = null; - } - if (array3.size() != 0) { - whereJson3 = (Map) array3.get(i); - } else { - whereJson3 = null; - } - String start_device_code = MapUtil.getStr(whereJson2, "device_code"); - String next_device_code = ""; - if (ObjectUtil.isEmpty(whereJson)) { - next_device_code = MapUtil.getStr(whereJson3, "device_code"); - } else { - next_device_code = MapUtil.getStr(whereJson, "device_code"); - } - - if (ObjectUtil.isNotEmpty(this.findByStartCode(start_device_code)) - || ObjectUtil.isNotEmpty(this.findByNextCode(next_device_code))) { - throw new WDKException("已存在该起点或终点的任务!"); - } - if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) { - throw new RuntimeException("请填写物料信息!"); - } - dto.setRoute_plan_code("two"); - dto.setStart_device_code(start_device_code); - dto.setStart_point_code(start_device_code); - dto.setNext_device_code(next_device_code); - dto.setNext_point_code(next_device_code); - dto.setRemark(remark); - dto.setMaterial(material_type); - create(dto); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(TaskDto dto) { - TaskDto entity = this.findById(dto.getTask_id()); - if (entity == null) { - throw new BadRequestException("被删除或无权限,操作失败!"); - } - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_by(currentUsername); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.update(json); - - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getTask_code().equals(dto.getTask_code())) { - iterator.remove(); - } - } - if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) { - tasks.add(dto); - } - //判断是否为WMS下发的任务,如果是反馈任务状态给WMS - String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); - if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); - JSONObject feed_jo = new JSONObject(); - feed_jo.put("task_id", entity.getExt_task_id()); - feed_jo.put("task_code", dto.getTask_code()); - feed_jo.put("task_status", dto.getTask_status()); - JSONArray ja = new JSONArray(); - ja.add(feed_jo); - String message = null; - HttpResponse body = null; - boolean flag = false; - try { - body = acstowmsService.feedbackTaskStatusToWms(ja); - } catch (Exception e) { - flag = true; - message = e.getMessage(); - e.printStackTrace(); - } finally { - - } - if (flag) { - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(message); - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setRemark(message); - taskFeedbackService.update(feefbackdto); - } - } else { - int status = body.getStatus(); - JSONObject jo = JSONObject.parseObject(body.body()); - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setError_code(String.valueOf(body.getStatus())); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getNext_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - if (status == 200) { - } else { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } - taskFeedbackService.update(feefbackdto); - } - } - - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteAll(String[] ids) throws Exception { - for (String task_id : ids) { - this.cancel(task_id); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void finish(String id) { - TaskDto entity = this.findById(id); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); - InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); - if (instdto != null) throw new BadRequestException("有指令未完成!"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setTask_status("2"); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - removeByCodeFromCache(entity.getTask_code()); - //判断是否为WMS下发的任务,如果是反馈任务状态给WMS - String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); - if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); - JSONObject feed_jo = new JSONObject(); - feed_jo.put("task_id", entity.getTask_id()); - feed_jo.put("task_code", entity.getTask_code()); - feed_jo.put("task_status", entity.getTask_status()); - JSONArray ja = new JSONArray(); - ja.add(feed_jo); - String message = null; - HttpResponse body = null; - boolean flag = false; - try { - body = acstowmsService.feedbackTaskStatusToWms(ja); - } catch (Exception e) { - flag = true; - message = e.getMessage(); - e.printStackTrace(); - } finally { - - } - if (flag) { - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(message); - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setRemark(message); - taskFeedbackService.update(feefbackdto); - } - } else { - int status = body.getStatus(); - JSONObject jo = JSONObject.parseObject(body.body()); - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setError_code(String.valueOf(body.getStatus())); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getNext_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.update(feefbackdto); - } - } - - } - //如果属于先知AGV,关闭运单序列 - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - try { - agvService.markComplete(entity.getTask_code()); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancel(String id) throws Exception { - TaskDto entity = this.findById(id); - if (entity == null) { - throw new BadRequestException("被删除或无权限,操作失败!"); - } - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); - InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); - if (instdto != null) { - throw new BadRequestException("有指令未完成!"); - } - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setTask_status("3"); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - //清理缓存 - for (int i = 0; i < tasks.size(); i++) { - TaskDto taskDto = tasks.get(i); - if (taskDto.getTask_id().equals(id)) { - tasks.remove(i); - } - } - //判断是否为WMS下发的任务,如果是反馈任务状态给WMS - String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); - if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - JSONObject feed_jo = new JSONObject(); - feed_jo.put("task_id", entity.getTask_id()); - feed_jo.put("task_code", entity.getTask_code()); - feed_jo.put("task_status", entity.getTask_status()); - JSONArray ja = new JSONArray(); - ja.add(feed_jo); - acstowmsService.feedbackTaskStatusToWms(ja); - } - List shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code()); - String type = shortPathsList.get(0).getType(); - // != 0 为agv任务 - if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - agvService.markComplete(entity.getTask_code()); - } - } - } - - @Override - public Instruction createTemporaryInst(TaskDto acsTask){ - if (acsTask == null) { - throw new BadRequestException("被删除或无权限,操作失败!"); - } - acsTask = foramte(acsTask); - ParamService paramService = SpringContextHolder.getBean(ParamService.class); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); -// InstructionDto inst = instructionservice.findByTaskid(acsTask, "instruction_status < 2 "); -// if (inst != null) { -// throw new BadRequestException("有指令未完成!"); -// } - - String taskid = acsTask.getTask_id(); - String taskcode = acsTask.getTask_code(); - String vehiclecode = acsTask.getVehicle_code(); - String priority = acsTask.getPriority(); - String start_point_code = acsTask.getStart_point_code(); - String start_device_code = acsTask.getStart_device_code(); - String route_plan_code = acsTask.getRoute_plan_code(); - String vehicleType = acsTask.getVehicle_type(); - //是否复合任务 =0非复合任务 - String compound_task = acsTask.getCompound_task(); - String next_point_code = acsTask.getNext_point_code(); - String next_device_code = acsTask.getNext_device_code(); - String start_point_code2 = acsTask.getStart_point_code2(); - String next_point_code2 = acsTask.getNext_point_code2(); - String agv_system_type = acsTask.getAgv_system_type(); - String task_type = acsTask.getTask_type(); - String from_x = acsTask.getFrom_x(); - String from_y = acsTask.getFrom_y(); - String from_z = acsTask.getFrom_z(); - String to_x = acsTask.getTo_x(); - String to_y = acsTask.getTo_y(); - String to_z = acsTask.getTo_z(); - - - /** - * 开始平均分解校验 - */ - String this_device_code = this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_device_code; - } - - if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); - } else { - next_point_code = next_device_code; - } - - Instruction instdto = new Instruction(); - if (StrUtil.isEmpty(instdto.getInstruction_code())) { - instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); - } - instdto.setInstruction_type(task_type); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(acsTask.getRemark()); - instdto.setMaterial(acsTask.getMaterial()); - instdto.setQuantity(acsTask.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - instdto.setVehicle_type(vehicleType); - instdto.setStart_point_code2(start_point_code2); - instdto.setStart_device_code2(start_point_code2); - instdto.setNext_device_code2(next_point_code2); - instdto.setNext_point_code2(next_point_code2); - instdto.setAgv_system_type(agv_system_type); - instdto.setFrom_x(from_x); - instdto.setFrom_y(from_y); - instdto.setFrom_z(from_z); - instdto.setTo_x(to_x); - instdto.setTo_y(to_y); - instdto.setTo_z(to_z); - - //判断agv系统 - //1、1楼叉车系统 - //2、2楼1区域AGV系统 - //3、2楼2区域AGV系统 - if (!StrUtil.equals(agv_system_type, "1")) { - // task_type - //1、生箔; Itype=1:取空,取满,放空,放满; - //2、分切 Itype=3取满、取空、放满、放空; - //3、普通任务 Itype=2:取货、放货; - //4、叉车任务 - //5、输送任务 - //6、行架 - //7、立库 - if (StrUtil.equals(task_type, "1")) { - instdto.setAgv_inst_type("1"); - } else if (StrUtil.equals(task_type, "3")) { - instdto.setAgv_inst_type("2"); - } else if (StrUtil.equals(task_type, "2")) { - instdto.setAgv_inst_type("3"); - } - } else { - instdto.setAgv_inst_type("4"); - } - return instdto; - } - - - - @Override - public Instruction createInst(String ids) throws Exception { - TaskDto acsTask = this.findById(ids); - if (acsTask == null) { - throw new BadRequestException("被删除或无权限,操作失败!"); - } - ParamService paramService = SpringContextHolder.getBean(ParamService.class); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); - InstructionDto inst = instructionservice.findByTaskid(ids, "instruction_status < 2 "); - if (inst != null) { - throw new BadRequestException("有指令未完成!"); - } - - String taskid = acsTask.getTask_id(); - String taskcode = acsTask.getTask_code(); - String vehiclecode = acsTask.getVehicle_code(); - String priority = acsTask.getPriority(); - String start_point_code = acsTask.getStart_point_code(); - String start_device_code = acsTask.getStart_device_code(); - String route_plan_code = acsTask.getRoute_plan_code(); - String vehicleType = acsTask.getVehicle_type(); - //是否复合任务 =0非复合任务 - String compound_task = acsTask.getCompound_task(); - String next_point_code = acsTask.getNext_point_code(); - String next_device_code = acsTask.getNext_device_code(); - String start_point_code2 = acsTask.getStart_point_code2(); - String next_point_code2 = acsTask.getNext_point_code2(); - String agv_system_type = acsTask.getAgv_system_type(); - String task_type = acsTask.getTask_type(); - /** - * 开始平均分解校验 - */ - String this_device_code = this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_device_code; - } - - if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); - } else { - next_point_code = next_device_code; - } - - Instruction instdto = new Instruction(); - instdto.setInstruction_type(task_type); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(acsTask.getRemark()); - instdto.setMaterial(acsTask.getMaterial()); - instdto.setQuantity(acsTask.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - instdto.setVehicle_type(vehicleType); - instdto.setStart_point_code2(start_point_code2); - instdto.setStart_device_code2(start_point_code2); - instdto.setNext_device_code2(next_point_code2); - instdto.setNext_point_code2(next_point_code2); - instdto.setAgv_system_type(agv_system_type); - //判断agv系统 - //1、1楼叉车系统 - //2、2楼1区域AGV系统 - //3、2楼2区域AGV系统 - if (!StrUtil.equals(agv_system_type, "1")) { - // task_type - //1、生箔; Itype=1:取空,取满,放空,放满; - //2、分切 Itype=3取满、取空、放满、放空; - //3、普通任务 Itype=2:取货、放货; - //4、叉车任务 - //5、输送任务 - //6、行架 - //7、立库 - if (StrUtil.equals(task_type, "1")) { - instdto.setAgv_inst_type("1"); - } else if (StrUtil.equals(task_type, "3")) { - instdto.setAgv_inst_type("2"); - } else if (StrUtil.equals(task_type, "2")) { - instdto.setAgv_inst_type("3"); - } - } else { - instdto.setAgv_inst_type("4"); - } - instructionservice.create2(instdto); - -// acsTask.setTask_status("1"); -// this.update(acsTask); - return instdto; - } - - @Override - public Instruction createInst(Instruction inst) throws Exception { - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); - - instructionservice.create2(inst); - return inst; - } - - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (TaskDto acsTask : all) { - Map map = new LinkedHashMap<>(); - map.put("任务号", acsTask.getTask_code()); - map.put("载具号", acsTask.getVehicle_code()); - map.put("载具类型", acsTask.getVehicle_type()); - map.put("任务类型", acsTask.getTask_type()); - map.put("任务状态", acsTask.getTask_status()); - map.put("任务优先级", acsTask.getPriority()); - map.put("创建类型", acsTask.getCreate_type()); - map.put("完成类型", acsTask.getFinish_type()); - map.put("执行描述编码", acsTask.getExecute_code()); - map.put("执行描述信息", acsTask.getExecute_message()); - map.put("起始点位编码", acsTask.getStart_point_code()); - map.put("起始设备编码", acsTask.getStart_device_code()); - map.put("目标点位编码", acsTask.getNext_point_code()); - map.put("目标设备编码", acsTask.getNext_device_code()); - map.put("排", acsTask.getFrom_x()); - map.put("列", acsTask.getFrom_y()); - map.put("层", acsTask.getFrom_z()); - map.put("排", acsTask.getTo_x()); - map.put("列", acsTask.getTo_y()); - map.put("层", acsTask.getTo_z()); - map.put("路由方案名称", acsTask.getRoute_plan_name()); - map.put("路由方案编码", acsTask.getRoute_plan_code()); - map.put("是否需要反馈上位系统", acsTask.getIs_needfeedback()); - map.put("备注", acsTask.getRemark()); - map.put("是否启用", acsTask.getIs_active()); - map.put("是否删除", acsTask.getIs_delete()); - map.put("创建者", acsTask.getCreate_by()); - map.put("创建时间", acsTask.getCreate_time()); - map.put("修改者", acsTask.getUpdate_by()); - map.put("修改时间", acsTask.getUpdate_time()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } - - @Override - public void createTaskByClick(JSONObject json) { - - } - - @Override - public int checkAllowCreate(String devicecode) { - Map map = new HashMap(); - List taskList = this.queryAllUnfinished(map); - int num = 0; - for (int i = 0; i < taskList.size(); i++) { - TaskDto onetask = taskList.get(i); - String next_code = onetask.getNext_point_code(); - if (StrUtil.equals(devicecode, next_code)) { - num = num + 1; - } - } - return num; - } - - @Override - public boolean removeByCodeFromCache(String code) { - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getTask_code().equals(code)) { - iterator.remove(); - return true; - } - } - return false; - } - - @Override - public List findAllTaskFromCache() { - return tasks; - } - - - public TaskDto findByContainer(String container_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); - if (StrUtil.equals(task.getVehicle_code(), container_code)) { - return task; - } - } - - return null; - } - - public TaskDto findByCodeFromCache(String task_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); - if (StrUtil.equals(task.getTask_code(), task_code)) { - return task; - } - } - return null; - } - - @Override - public TaskDto findByNextCode(String device_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); - if (StrUtil.equals(task.getNext_device_code(), device_code)) { - return task; - } - } - return null; - } - - @Override - public List findAllByNextCode(String device_code) { - return null; - } - - @Override - public Integer queryAllTaskMaterialQty(String device_code) { - return null; - } - - - @Override - public TaskDto findByStartCodeAndReady(String device_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); -// if (!StrUtil.equals(task.getTask_type(), "5")) { -// continue; -// } - if (StrUtil.equals(task.getStart_device_code(), device_code) && StrUtil.equals(task.getTask_status(), "0")) { - return task; - } - } - return null; - } - - @Override - public TaskDto findByStartCode(String device_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); - if (StrUtil.equals(task.getStart_device_code(), device_code)) { - return task; - } - } - return null; - } - - @Override - public TaskDto foramte(TaskDto task) { - String start_point_code = task.getStart_point_code(); - String next_point_code = task.getNext_point_code(); - String from_y = null; - String from_z = null; - String to_y = null; - String to_z = null; - if (StrUtil.contains(start_point_code, "-") && StrUtil.count(start_point_code, "-") == 2) { - String[] start_point = start_point_code.split("-"); - task.setFrom_x(start_point[0]); - task.setStart_device_code(start_point[0]); - if (Integer.parseInt(start_point[1]) < 10 && start_point[1].length() == 1) { - from_y = "0" + start_point[1]; - task.setFrom_y(from_y); - } else { - from_y = start_point[1]; - task.setFrom_y(from_y); - } - if (Integer.parseInt(start_point[2]) < 10 && start_point[2].length() == 1) { - from_z = "0" + start_point[2]; - task.setFrom_z(from_z); - } else if (start_point[2].length() == 2 ){ - from_z = start_point[2]; - task.setFrom_z(start_point[2]); - } else { - from_z = start_point[2]; - } - task.setStart_point_code(task.getStart_device_code() + "-" + from_y + "-" + from_z); - task.setStart_device_code(task.getStart_device_code()); + JSONObject jo2 = new JSONObject(); + if (!StrUtil.isEmpty(dto.getMaterial())) { + if (!StrUtil.equals(dto.getMaterial(), "1")) { + jo.put("hasGoodStatus", "2"); + jo.put("material_type", dto.getMaterial()); + } else { + jo.put("hasGoodStatus", "1"); + jo.put("material_type", "1"); + } } else { - String start_device = deviceAppService.findDeviceByCode(start_point_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - //如果point_device为货架,则不包含列层信息,需要重新拼接 - if (StrUtil.equals("storage", start_device)) { - if (StrUtil.isEmpty(task.getFrom_x())) { - throw new BadRequestException("货位信息起点需要包含列信息"); - } - if (StrUtil.isEmpty(task.getFrom_y())) { - throw new BadRequestException("货位信息起点需要包含层信息"); - } - if (Integer.parseInt(task.getFrom_y()) < 10 && task.getFrom_y().length() == 1) { - from_y = "0" + task.getFrom_y(); - task.setFrom_y(from_y); - } else { - from_y = task.getFrom_y(); - } - if (Integer.parseInt(task.getFrom_z()) < 10 && task.getFrom_z().length() == 1) { - from_z = "0" + task.getFrom_z(); - task.setFrom_z(from_z); - } else if (task.getFrom_z().length() == 2 ) { - from_z = task.getFrom_z(); - task.setFrom_z(from_z); - } else { - from_z = task.getFrom_z(); - } - task.setFrom_x(start_point_code); - task.setStart_point_code(start_point_code + "-" + from_y + "-" + from_z); - task.setStart_device_code(start_point_code); - } else { - task.setStart_device_code(start_point_code); - task.setStart_device_code(start_point_code); - } + jo.put("hasGoodStatus", "1"); + jo.put("material_type", "1"); } + jo.put("device_code", dto.getStart_device_code()); + jo.put("quantity", dto.getQuantity()); + jo.put("remark", dto.getRemark()); + jo.put("batch", startdevice.getBatch()); + jo.put("islock", "true"); + deviceService.changeDeviceStatus(jo); + Device deviceByCode = deviceAppService.findDeviceByCode(dto.getNext_device_code()); + jo2.put("device_code", dto.getNext_device_code()); + jo2.put("hasGoodStatus", deviceByCode.getHas_goods()); + jo2.put("quantity", deviceByCode.getQuantity()); + jo2.put("remark", deviceByCode.getRemark()); + jo2.put("material_type", deviceByCode.getMaterial_type()); + jo2.put("batch", deviceByCode.getBatch()); + jo2.put("islock", "true"); + deviceService.changeDeviceStatus(jo2); + } + } + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); - if (StrUtil.contains(next_point_code, "-") && StrUtil.count(next_point_code, "-") == 2) { - String[] next_point = next_point_code.split("-"); - task.setNext_device_code(next_point[0]); - task.setTo_x(next_point[0]); - if (Integer.parseInt(next_point[1]) < 10 && next_point[1].length() == 1) { - to_y = "0" + next_point[1]; - task.setTo_y(to_y); - } else { - to_y = next_point[1]; - task.setTo_y(to_y); - } - if (Integer.parseInt(next_point[2]) < 10 && next_point[2].length() == 1) { - to_z = "0" + next_point[2]; - task.setTo_z(to_z); - } else if ( next_point[2].length() == 2){ - to_z = next_point[2]; - task.setTo_z(to_z); - } else { - to_z = next_point[2]; - task.setTo_z(to_z); - } - task.setNext_point_code(task.getNext_device_code() + "-" + to_y + "-" + to_z); - task.setNext_device_code(task.getNext_device_code()); + wo.insert(json); + tasks.add(dto); + } + /** + * 常规任务保存 + * + * @param / + * @throws Exception + */ + @Override + public void ordinaryTaskCreate(JSONObject json) throws Exception { + JSONArray array = json.getJSONArray("data"); + + if (array.size() == 0) { + throw new RuntimeException("请选择起点"); + } + for (int i = 0; i < array.size(); i++) { + JSONObject arrjo = array.getJSONObject(i); + String material_type = arrjo.getString("material_type"); + String quantity = arrjo.getString("quantity"); + String remark = arrjo.getString("remark"); + TaskDto dto = new TaskDto(); + Map whereJson = (Map) array.get(i); + + // String device_code = (String) whereJson.get("device_code"); + String device_code = MapUtil.getStr(whereJson, "device_code"); + dto.setRoute_plan_code("one"); + String next_device_code = ""; + String plan_uuid = + WQLObject.getWQLObject("acs_route_plan") + .query("plan_code= '" + dto.getRoute_plan_code() + "'") + .uniqueResult(0) + .getString("plan_uuid"); + JSONArray ja = routelineserver.queryNextLine(device_code, plan_uuid); + for (int j = 0; j < ja.size(); j++) { + JSONObject jo = (JSONObject) ja.get(j); + next_device_code = jo.get("next_device_code").toString(); + } + if (ObjectUtil.isNotEmpty(this.findByStartCode(device_code))) { + throw new WDKException("已存在该起点的任务!"); + } + if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) { + throw new RuntimeException("请填写物料信息!"); + } + dto.setStart_device_code(device_code); + dto.setStart_point_code(device_code); + dto.setNext_device_code(next_device_code); + dto.setNext_point_code(next_device_code); + dto.setRemark(remark); + dto.setMaterial(material_type); + create(dto); + } + } + + /** + * 特殊任务保存 + * + * @param / + * @throws Exception + */ + @Override + public void specialTaskCreate(JSONObject json) throws Exception { + + JSONArray array = json.getJSONArray("data1"); + JSONArray array2 = json.getJSONArray("data2"); + JSONArray array3 = json.getJSONArray("data3"); + if (array.size() != 0 && array3.size() != 0) { + throw new RuntimeException("只能选择一个终点"); + } + + for (int i = 0; i < array2.size(); i++) { + JSONObject arrjo = array2.getJSONObject(i); + String material_type = arrjo.getString("material_type"); + String quantity = arrjo.getString("quantity"); + String remark = arrjo.getString("remark"); + TaskDto dto = new TaskDto(); + Map whereJson; + Map whereJson2; + Map whereJson3; + if (array.size() != 0) { + whereJson = (Map) array.get(i); + } else { + whereJson = null; + } + if (array2.size() != 0) { + whereJson2 = (Map) array2.get(i); + } else { + whereJson2 = null; + } + if (array3.size() != 0) { + whereJson3 = (Map) array3.get(i); + } else { + whereJson3 = null; + } + String start_device_code = MapUtil.getStr(whereJson2, "device_code"); + String next_device_code = ""; + if (ObjectUtil.isEmpty(whereJson)) { + next_device_code = MapUtil.getStr(whereJson3, "device_code"); + } else { + next_device_code = MapUtil.getStr(whereJson, "device_code"); + } + + if (ObjectUtil.isNotEmpty(this.findByStartCode(start_device_code)) + || ObjectUtil.isNotEmpty(this.findByNextCode(next_device_code))) { + throw new WDKException("已存在该起点或终点的任务!"); + } + if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) { + throw new RuntimeException("请填写物料信息!"); + } + dto.setRoute_plan_code("two"); + dto.setStart_device_code(start_device_code); + dto.setStart_point_code(start_device_code); + dto.setNext_device_code(next_device_code); + dto.setNext_point_code(next_device_code); + dto.setRemark(remark); + dto.setMaterial(material_type); + create(dto); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TaskDto dto) { + TaskDto entity = this.findById(dto.getTask_id()); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + dto.setUpdate_time(now); + dto.setUpdate_by(currentUsername); + + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.update(json); + + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getTask_code().equals(dto.getTask_code())) { + iterator.remove(); + } + } + if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) { + tasks.add(dto); + } + // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS + String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); + if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); + JSONObject feed_jo = new JSONObject(); + feed_jo.put("task_id", entity.getExt_task_id()); + feed_jo.put("task_code", dto.getTask_code()); + feed_jo.put("task_status", dto.getTask_status()); + JSONArray ja = new JSONArray(); + ja.add(feed_jo); + String message = null; + HttpResponse body = null; + boolean flag = false; + try { + body = acstowmsService.feedbackTaskStatusToWms(ja); + } catch (Exception e) { + flag = true; + message = e.getMessage(); + e.printStackTrace(); + } finally { + + } + if (flag) { + if (ObjectUtil.isEmpty(feefbackdto)) { + feefbackdto = new TaskFeedbackDto(); + feefbackdto.setTask_id(entity.getTask_id()); + feefbackdto.setTask_code(entity.getTask_code()); + feefbackdto.setTask_status(entity.getTask_status()); + feefbackdto.setVehicle_type(entity.getVehicle_type()); + feefbackdto.setVehicle_code(entity.getVehicle_code()); + feefbackdto.setStart_device_code(entity.getStart_device_code()); + feefbackdto.setStart_point_code(entity.getStart_point_code()); + feefbackdto.setNext_device_code(entity.getNext_device_code()); + feefbackdto.setNext_point_code(entity.getNext_point_code()); + feefbackdto.setError_code("400"); + feefbackdto.setIs_finished("0"); + feefbackdto.setRemark(message); + taskFeedbackService.create(feefbackdto); } else { - String next_device = deviceAppService.findDeviceByCode(next_point_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - if (StrUtil.equals("storage", next_device)) { - if (StrUtil.isEmpty(task.getTo_x())) { - throw new BadRequestException("货位信息终点需要包含列信息"); - } - if (StrUtil.isEmpty(task.getTo_y())) { - throw new BadRequestException("货位信息终点需要包含层信息"); - } - if (Integer.parseInt(task.getTo_y()) < 10 && task.getTo_y().length() == 1) { - to_y = "0" + task.getTo_y(); - task.setTo_y(to_y); - } else { - to_y = task.getTo_y(); - } - if (Integer.parseInt(task.getTo_z()) < 10 && task.getTo_z().length() == 1) { - to_z = "0" + task.getTo_z(); - task.setTo_z(to_z); - } else if (task.getTo_z().length() == 2){ - to_z = task.getTo_z(); - task.setTo_z(to_z); - } else { - to_z = task.getTo_z(); - } - task.setTo_x(next_point_code); - task.setNext_point_code(next_point_code + "-" + to_y + "-" + to_z); - task.setNext_device_code(next_point_code); - - } else { - task.setNext_device_code(next_point_code); - task.setNext_device_code(next_point_code); - - } + feefbackdto.setTask_status(entity.getTask_status()); + feefbackdto.setStart_device_code(entity.getStart_device_code()); + feefbackdto.setStart_point_code(entity.getStart_point_code()); + feefbackdto.setNext_device_code(entity.getNext_device_code()); + feefbackdto.setNext_point_code(entity.getNext_point_code()); + feefbackdto.setError_code("400"); + feefbackdto.setRemark(message); + taskFeedbackService.update(feefbackdto); } + } else { + int status = body.getStatus(); + JSONObject jo = JSONObject.parseObject(body.body()); + if (ObjectUtil.isEmpty(feefbackdto)) { + feefbackdto = new TaskFeedbackDto(); + feefbackdto.setTask_id(entity.getTask_id()); + feefbackdto.setTask_code(entity.getTask_code()); + feefbackdto.setTask_status(entity.getTask_status()); + feefbackdto.setVehicle_type(entity.getVehicle_type()); + feefbackdto.setVehicle_code(entity.getVehicle_code()); + feefbackdto.setError_code(String.valueOf(body.getStatus())); + feefbackdto.setStart_device_code(entity.getStart_device_code()); + feefbackdto.setStart_point_code(entity.getNext_point_code()); + feefbackdto.setNext_device_code(entity.getNext_device_code()); + feefbackdto.setNext_point_code(entity.getNext_point_code()); + if (status == 200) { + if (StrUtil.equals(entity.getTask_status(), "2")) { + feefbackdto.setIs_finished("1"); + } else { + feefbackdto.setIs_finished("0"); + } + } else { + feefbackdto.setIs_finished("0"); + feefbackdto.setRemark(jo.getString("message")); + } + taskFeedbackService.create(feefbackdto); + } else { + feefbackdto.setTask_status(entity.getTask_status()); + if (status == 200) { + } else { + if (StrUtil.equals(entity.getTask_status(), "2")) { + feefbackdto.setIs_finished("1"); + } else { + feefbackdto.setIs_finished("0"); + } + } + taskFeedbackService.update(feefbackdto); + } + } + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteAll(String[] ids) throws Exception { + for (String task_id : ids) { + this.cancel(task_id); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void finish(String id) { + TaskDto entity = this.findById(id); + if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); + if (instdto != null) throw new BadRequestException("有指令未完成!"); + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setTask_status("2"); + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + removeByCodeFromCache(entity.getTask_code()); + // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS + String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); + if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); + JSONObject feed_jo = new JSONObject(); + feed_jo.put("task_id", entity.getTask_id()); + feed_jo.put("task_code", entity.getTask_code()); + feed_jo.put("task_status", entity.getTask_status()); + JSONArray ja = new JSONArray(); + ja.add(feed_jo); + String message = null; + HttpResponse body = null; + boolean flag = false; + try { + body = acstowmsService.feedbackTaskStatusToWms(ja); + } catch (Exception e) { + flag = true; + message = e.getMessage(); + e.printStackTrace(); + } finally { + + } + if (flag) { + if (ObjectUtil.isEmpty(feefbackdto)) { + feefbackdto = new TaskFeedbackDto(); + feefbackdto.setTask_id(entity.getTask_id()); + feefbackdto.setTask_code(entity.getTask_code()); + feefbackdto.setTask_status(entity.getTask_status()); + feefbackdto.setVehicle_type(entity.getVehicle_type()); + feefbackdto.setVehicle_code(entity.getVehicle_code()); + feefbackdto.setStart_device_code(entity.getStart_device_code()); + feefbackdto.setStart_point_code(entity.getStart_point_code()); + feefbackdto.setNext_device_code(entity.getNext_device_code()); + feefbackdto.setNext_point_code(entity.getNext_point_code()); + feefbackdto.setError_code("400"); + feefbackdto.setIs_finished("0"); + feefbackdto.setRemark(message); + taskFeedbackService.create(feefbackdto); + } else { + feefbackdto.setTask_status(entity.getTask_status()); + feefbackdto.setStart_device_code(entity.getStart_device_code()); + feefbackdto.setStart_point_code(entity.getStart_point_code()); + feefbackdto.setNext_device_code(entity.getNext_device_code()); + feefbackdto.setNext_point_code(entity.getNext_point_code()); + feefbackdto.setError_code("400"); + feefbackdto.setRemark(message); + taskFeedbackService.update(feefbackdto); + } + } else { + int status = body.getStatus(); + JSONObject jo = JSONObject.parseObject(body.body()); + if (ObjectUtil.isEmpty(feefbackdto)) { + feefbackdto = new TaskFeedbackDto(); + feefbackdto.setTask_id(entity.getTask_id()); + feefbackdto.setTask_code(entity.getTask_code()); + feefbackdto.setTask_status(entity.getTask_status()); + feefbackdto.setVehicle_type(entity.getVehicle_type()); + feefbackdto.setVehicle_code(entity.getVehicle_code()); + feefbackdto.setError_code(String.valueOf(body.getStatus())); + feefbackdto.setStart_device_code(entity.getStart_device_code()); + feefbackdto.setStart_point_code(entity.getNext_point_code()); + feefbackdto.setNext_device_code(entity.getNext_device_code()); + feefbackdto.setNext_point_code(entity.getNext_point_code()); + if (status == 200) { + if (StrUtil.equals(entity.getTask_status(), "2")) { + feefbackdto.setIs_finished("1"); + } else { + feefbackdto.setIs_finished("0"); + } + } else { + feefbackdto.setIs_finished("0"); + feefbackdto.setRemark(jo.getString("message")); + } + taskFeedbackService.create(feefbackdto); + } else { + feefbackdto.setTask_status(entity.getTask_status()); + if (status == 200) { + if (StrUtil.equals(entity.getTask_status(), "2")) { + feefbackdto.setIs_finished("1"); + } else { + feefbackdto.setIs_finished("0"); + } + } else { + feefbackdto.setIs_finished("0"); + feefbackdto.setRemark(jo.getString("message")); + } + taskFeedbackService.update(feefbackdto); + } + } + } + // 如果属于先知AGV,关闭运单序列 + if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { + try { + agvService.markComplete(entity.getTask_code()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void cancel(String id) throws Exception { + TaskDto entity = this.findById(id); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); + if (instdto != null) { + throw new BadRequestException("有指令未完成!"); + } + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setTask_status("3"); + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + + Iterator it = tasks.iterator(); + // 清理缓存 + while (it.hasNext()){ + TaskDto taskDto = it.next(); + if (taskDto.getTask_id().equals(id)) { + tasks.remove(taskDto); + } + } + // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS + String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); + if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject feed_jo = new JSONObject(); + feed_jo.put("task_id", entity.getTask_id()); + feed_jo.put("task_code", entity.getTask_code()); + feed_jo.put("task_status", entity.getTask_status()); + JSONArray ja = new JSONArray(); + ja.add(feed_jo); + acstowmsService.feedbackTaskStatusToWms(ja); + } + List shortPathsList = + routeLineService.getShortPathLines( + entity.getStart_device_code(), + entity.getNext_device_code(), + entity.getRoute_plan_code()); + String type = shortPathsList.get(0).getType(); + // != 0 为agv任务 + if (!StrUtil.equals(type, "0")) { + if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { + agvService.markComplete(entity.getTask_code()); + } + } + } + + @Override + public Instruction createTemporaryInst(TaskDto acsTask) { + if (acsTask == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + acsTask = foramte(acsTask); + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + // InstructionDto inst = instructionservice.findByTaskid(acsTask, "instruction_status < 2 + // "); + // if (inst != null) { + // throw new BadRequestException("有指令未完成!"); + // } + + String taskid = acsTask.getTask_id(); + String taskcode = acsTask.getTask_code(); + String vehiclecode = acsTask.getVehicle_code(); + String priority = acsTask.getPriority(); + String start_point_code = acsTask.getStart_point_code(); + String start_device_code = acsTask.getStart_device_code(); + String route_plan_code = acsTask.getRoute_plan_code(); + String vehicleType = acsTask.getVehicle_type(); + // 是否复合任务 =0非复合任务 + String compound_task = acsTask.getCompound_task(); + String next_point_code = acsTask.getNext_point_code(); + String next_device_code = acsTask.getNext_device_code(); + String start_point_code2 = acsTask.getStart_point_code2(); + String next_point_code2 = acsTask.getNext_point_code2(); + String agv_system_type = acsTask.getAgv_system_type(); + String task_type = acsTask.getTask_type(); + String from_x = acsTask.getFrom_x(); + String from_y = acsTask.getFrom_y(); + String from_z = acsTask.getFrom_z(); + String to_x = acsTask.getTo_x(); + String to_y = acsTask.getTo_y(); + String to_z = acsTask.getTo_z(); + + /** 开始平均分解校验 */ + String this_device_code = + this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); + if (StrUtil.isEmpty(this_device_code)) { + List shortPathsList = + routeLineService.getShortPathLines( + start_device_code, acsTask.getNext_device_code(), route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; + } + } + next_device_code = pathlist.get(index); + } else { + next_device_code = this_device_code; + } + + if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { + next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); + } else { + next_point_code = next_device_code; + } + + Instruction instdto = new Instruction(); + if (StrUtil.isEmpty(instdto.getInstruction_code())) { + instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); + } + instdto.setInstruction_type(task_type); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(acsTask.getRemark()); + instdto.setMaterial(acsTask.getMaterial()); + instdto.setQuantity(acsTask.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setVehicle_code(vehiclecode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + instdto.setVehicle_type(vehicleType); + instdto.setStart_point_code2(start_point_code2); + instdto.setStart_device_code2(start_point_code2); + instdto.setNext_device_code2(next_point_code2); + instdto.setNext_point_code2(next_point_code2); + instdto.setAgv_system_type(agv_system_type); + instdto.setFrom_x(from_x); + instdto.setFrom_y(from_y); + instdto.setFrom_z(from_z); + instdto.setTo_x(to_x); + instdto.setTo_y(to_y); + instdto.setTo_z(to_z); + + // 判断agv系统 + // 1、1楼叉车系统 + // 2、2楼1区域AGV系统 + // 3、2楼2区域AGV系统 + if (!StrUtil.equals(agv_system_type, "1")) { + // task_type + // 1、生箔; Itype=1:取空,取满,放空,放满; + // 2、分切 Itype=3取满、取空、放满、放空; + // 3、普通任务 Itype=2:取货、放货; + // 4、叉车任务 + // 5、输送任务 + // 6、行架 + // 7、立库 + if (StrUtil.equals(task_type, "1")) { + instdto.setAgv_inst_type("1"); + } else if (StrUtil.equals(task_type, "3")) { + instdto.setAgv_inst_type("2"); + } else if (StrUtil.equals(task_type, "2")) { + instdto.setAgv_inst_type("3"); + } + } else { + instdto.setAgv_inst_type("4"); + } + return instdto; + } + + @Override + public Instruction createInst(String ids) throws Exception { + TaskDto acsTask = this.findById(ids); + if (acsTask == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + InstructionDto inst = instructionservice.findByTaskid(ids, "instruction_status < 2 "); + if (inst != null) { + throw new BadRequestException("有指令未完成!"); + } + + String taskid = acsTask.getTask_id(); + String taskcode = acsTask.getTask_code(); + String vehiclecode = acsTask.getVehicle_code(); + String priority = acsTask.getPriority(); + String start_point_code = acsTask.getStart_point_code(); + String start_device_code = acsTask.getStart_device_code(); + String route_plan_code = acsTask.getRoute_plan_code(); + String vehicleType = acsTask.getVehicle_type(); + // 是否复合任务 =0非复合任务 + String compound_task = acsTask.getCompound_task(); + String next_point_code = acsTask.getNext_point_code(); + String next_device_code = acsTask.getNext_device_code(); + String start_point_code2 = acsTask.getStart_point_code2(); + String next_point_code2 = acsTask.getNext_point_code2(); + String agv_system_type = acsTask.getAgv_system_type(); + String task_type = acsTask.getTask_type(); + /** 开始平均分解校验 */ + String this_device_code = + this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); + if (StrUtil.isEmpty(this_device_code)) { + List shortPathsList = + routeLineService.getShortPathLines( + start_device_code, acsTask.getNext_device_code(), route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; + } + } + next_device_code = pathlist.get(index); + } else { + next_device_code = this_device_code; + } + + if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { + next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); + } else { + next_point_code = next_device_code; + } + + Instruction instdto = new Instruction(); + instdto.setInstruction_type(task_type); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(acsTask.getRemark()); + instdto.setMaterial(acsTask.getMaterial()); + instdto.setQuantity(acsTask.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setVehicle_code(vehiclecode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + instdto.setVehicle_type(vehicleType); + instdto.setStart_point_code2(start_point_code2); + instdto.setStart_device_code2(start_point_code2); + instdto.setNext_device_code2(next_point_code2); + instdto.setNext_point_code2(next_point_code2); + instdto.setAgv_system_type(agv_system_type); + // 判断agv系统 + // 1、1楼叉车系统 + // 2、2楼1区域AGV系统 + // 3、2楼2区域AGV系统 + if (!StrUtil.equals(agv_system_type, "1")) { + // task_type + // 1、生箔; Itype=1:取空,取满,放空,放满; + // 2、分切 Itype=3取满、取空、放满、放空; + // 3、普通任务 Itype=2:取货、放货; + // 4、叉车任务 + // 5、输送任务 + // 6、行架 + // 7、立库 + if (StrUtil.equals(task_type, "1")) { + instdto.setAgv_inst_type("1"); + } else if (StrUtil.equals(task_type, "3")) { + instdto.setAgv_inst_type("2"); + } else if (StrUtil.equals(task_type, "2")) { + instdto.setAgv_inst_type("3"); + } + } else { + instdto.setAgv_inst_type("4"); + } + instructionservice.create2(instdto); + + // acsTask.setTask_status("1"); + // this.update(acsTask); + return instdto; + } + + @Override + public Instruction createInst(Instruction inst) throws Exception { + + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + + instructionservice.create2(inst); + return inst; + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TaskDto acsTask : all) { + Map map = new LinkedHashMap<>(); + map.put("任务号", acsTask.getTask_code()); + map.put("载具号", acsTask.getVehicle_code()); + map.put("载具类型", acsTask.getVehicle_type()); + map.put("任务类型", acsTask.getTask_type()); + map.put("任务状态", acsTask.getTask_status()); + map.put("任务优先级", acsTask.getPriority()); + map.put("创建类型", acsTask.getCreate_type()); + map.put("完成类型", acsTask.getFinish_type()); + map.put("执行描述编码", acsTask.getExecute_code()); + map.put("执行描述信息", acsTask.getExecute_message()); + map.put("起始点位编码", acsTask.getStart_point_code()); + map.put("起始设备编码", acsTask.getStart_device_code()); + map.put("目标点位编码", acsTask.getNext_point_code()); + map.put("目标设备编码", acsTask.getNext_device_code()); + map.put("排", acsTask.getFrom_x()); + map.put("列", acsTask.getFrom_y()); + map.put("层", acsTask.getFrom_z()); + map.put("排", acsTask.getTo_x()); + map.put("列", acsTask.getTo_y()); + map.put("层", acsTask.getTo_z()); + map.put("路由方案名称", acsTask.getRoute_plan_name()); + map.put("路由方案编码", acsTask.getRoute_plan_code()); + map.put("是否需要反馈上位系统", acsTask.getIs_needfeedback()); + map.put("备注", acsTask.getRemark()); + map.put("是否启用", acsTask.getIs_active()); + map.put("是否删除", acsTask.getIs_delete()); + map.put("创建者", acsTask.getCreate_by()); + map.put("创建时间", acsTask.getCreate_time()); + map.put("修改者", acsTask.getUpdate_by()); + map.put("修改时间", acsTask.getUpdate_time()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public void createTaskByClick(JSONObject json) {} + + @Override + public int checkAllowCreate(String devicecode) { + Map map = new HashMap(); + List taskList = this.queryAllUnfinished(map); + int num = 0; + for (int i = 0; i < taskList.size(); i++) { + TaskDto onetask = taskList.get(i); + String next_code = onetask.getNext_point_code(); + if (StrUtil.equals(devicecode, next_code)) { + num = num + 1; + } + } + return num; + } + + @Override + public boolean removeByCodeFromCache(String code) { + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getTask_code().equals(code)) { + iterator.remove(); + return true; + } + } + return false; + } + + @Override + public List findAllTaskFromCache() { + return tasks; + } + + public TaskDto findByContainer(String container_code) { + Iterator var3 = tasks.iterator(); + + while (var3.hasNext()) { + TaskDto task = (TaskDto) var3.next(); + if (StrUtil.equals(task.getVehicle_code(), container_code)) { return task; + } } - @Override - public void updateByCodeFromCache(TaskDto dto) { - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getTask_code().equals(dto.getTask_code())) { - iterator.remove(); - } + return null; + } + + public TaskDto findByCodeFromCache(String task_code) { + Iterator var3 = tasks.iterator(); + + while (var3.hasNext()) { + TaskDto task = (TaskDto) var3.next(); + if (StrUtil.equals(task.getTask_code(), task_code)) { + return task; + } + } + return null; + } + + @Override + public TaskDto findByNextCode(String device_code) { + Iterator var3 = tasks.iterator(); + + while (var3.hasNext()) { + TaskDto task = (TaskDto) var3.next(); + if (StrUtil.equals(task.getNext_device_code(), device_code)) { + return task; + } + } + return null; + } + + @Override + public List findAllByNextCode(String device_code) { + return null; + } + + @Override + public Integer queryAllTaskMaterialQty(String device_code) { + return null; + } + + @Override + public TaskDto findByStartCodeAndReady(String device_code) { + Iterator var3 = tasks.iterator(); + + while (var3.hasNext()) { + TaskDto task = (TaskDto) var3.next(); + // if (!StrUtil.equals(task.getTask_type(), "5")) { + // continue; + // } + if (StrUtil.equals(task.getStart_device_code(), device_code) + && StrUtil.equals(task.getTask_status(), "0")) { + return task; + } + } + return null; + } + + @Override + public TaskDto findByStartCode(String device_code) { + Iterator var3 = tasks.iterator(); + + while (var3.hasNext()) { + TaskDto task = (TaskDto) var3.next(); + if (StrUtil.equals(task.getStart_device_code(), device_code)) { + return task; + } + } + return null; + } + + @Override + public TaskDto foramte(TaskDto task) { + String start_point_code = task.getStart_point_code(); + String next_point_code = task.getNext_point_code(); + String from_y = null; + String from_z = null; + String to_y = null; + String to_z = null; + if (StrUtil.contains(start_point_code, "-") && StrUtil.count(start_point_code, "-") == 2) { + String[] start_point = start_point_code.split("-"); + task.setFrom_x(start_point[0]); + task.setStart_device_code(start_point[0]); + if (Integer.parseInt(start_point[1]) < 10 && start_point[1].length() == 1) { + from_y = "0" + start_point[1]; + task.setFrom_y(from_y); + } else { + from_y = start_point[1]; + task.setFrom_y(from_y); + } + if (Integer.parseInt(start_point[2]) < 10 && start_point[2].length() == 1) { + from_z = "0" + start_point[2]; + task.setFrom_z(from_z); + } else if (start_point[2].length() == 2) { + from_z = start_point[2]; + task.setFrom_z(start_point[2]); + } else { + from_z = start_point[2]; + } + task.setStart_point_code(task.getStart_device_code() + "-" + from_y + "-" + from_z); + task.setStart_device_code(task.getStart_device_code()); + + } else { + String start_device = + deviceAppService + .findDeviceByCode(start_point_code) + .getDeviceDriverDefination() + .getFitDeviceTypes() + .get(0) + .name(); + // 如果point_device为货架,则不包含列层信息,需要重新拼接 + if (StrUtil.equals("storage", start_device)) { + if (StrUtil.isEmpty(task.getFrom_x())) { + throw new BadRequestException("货位信息起点需要包含列信息"); } - tasks.add(dto); - } - - @Override - public String queryAssignedByDevice(String device_code, String task_nextdeice_code) { - List list = deviceAssignedService.queryAssignedBydevice(device_code, task_nextdeice_code); - int flag1 = 0; - String flag2 = null; - for (int i = 0; i < list.size(); i++) { - DeviceAssignedDto dto = list.get(i); - String inst_nextDevice_code = dto.getInst_nextdevice_code(); - String task_nextDevice_code = dto.getTask_nextdevice_code(); - String param = dto.getParam(); - JSONObject jo = JSON.parseObject(param); - String regEx = "[`~!@#$%^&*()+=|{}':;'\\[\\].<>/?~!@#¥%……&*()——+|{}【】':”“’。、?]"; - Pattern p = Pattern.compile(regEx); - Matcher m = p.matcher(inst_nextDevice_code); - String toSpeechText = m.replaceAll("").trim(); - - String[] str = toSpeechText.split(","); - List pathlist = Arrays.asList(str); - for (int j = 0; j < pathlist.size(); j++) { - String this_device_code = pathlist.get(j).toString(); - JSONObject data = JSON.parseObject(jo.getString(this_device_code)); - String limit = data.getString("limit"); - int num = instructionService.querySameDestinationInst(this_device_code); - if (num >= Integer.parseInt(limit)) { - continue; - } - if (j == 0) { - flag1 = num; - } - if (num <= flag1) { - flag2 = this_device_code; - } - } - + if (StrUtil.isEmpty(task.getFrom_y())) { + throw new BadRequestException("货位信息起点需要包含层信息"); } - if (!StrUtil.isEmpty(flag2)) { - return flag2; + if (Integer.parseInt(task.getFrom_y()) < 10 && task.getFrom_y().length() == 1) { + from_y = "0" + task.getFrom_y(); + task.setFrom_y(from_y); + } else { + from_y = task.getFrom_y(); } - return null; - } - - - @Override - public Integer querySameDeviceReadyTask(String start_device,String next_device,String status ) { - int num = 0; - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (StrUtil.equals(task.getStart_device_code(),start_device) && StrUtil.equals(task.getNext_device_code(),next_device) - && StrUtil.equals(task.getTask_status(),status)) { - num++; - } + if (Integer.parseInt(task.getFrom_z()) < 10 && task.getFrom_z().length() == 1) { + from_z = "0" + task.getFrom_z(); + task.setFrom_z(from_z); + } else if (task.getFrom_z().length() == 2) { + from_z = task.getFrom_z(); + task.setFrom_z(from_z); + } else { + from_z = task.getFrom_z(); } - - return num; + task.setFrom_x(start_point_code); + task.setStart_point_code(start_point_code + "-" + from_y + "-" + from_z); + task.setStart_device_code(start_point_code); + } else { + task.setStart_device_code(start_point_code); + task.setStart_device_code(start_point_code); + } } + if (StrUtil.contains(next_point_code, "-") && StrUtil.count(next_point_code, "-") == 2) { + String[] next_point = next_point_code.split("-"); + task.setNext_device_code(next_point[0]); + task.setTo_x(next_point[0]); + if (Integer.parseInt(next_point[1]) < 10 && next_point[1].length() == 1) { + to_y = "0" + next_point[1]; + task.setTo_y(to_y); + } else { + to_y = next_point[1]; + task.setTo_y(to_y); + } + if (Integer.parseInt(next_point[2]) < 10 && next_point[2].length() == 1) { + to_z = "0" + next_point[2]; + task.setTo_z(to_z); + } else if (next_point[2].length() == 2) { + to_z = next_point[2]; + task.setTo_z(to_z); + } else { + to_z = next_point[2]; + task.setTo_z(to_z); + } + task.setNext_point_code(task.getNext_device_code() + "-" + to_y + "-" + to_z); + task.setNext_device_code(task.getNext_device_code()); - @Override - public Integer querySameTaskByType(String taskType) { - int num = 0; - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getTask_type().equals(taskType) && task.getTask_status().equals("1")) { - num++; - } + } else { + String next_device = + deviceAppService + .findDeviceByCode(next_point_code) + .getDeviceDriverDefination() + .getFitDeviceTypes() + .get(0) + .name(); + if (StrUtil.equals("storage", next_device)) { + if (StrUtil.isEmpty(task.getTo_x())) { + throw new BadRequestException("货位信息终点需要包含列信息"); } + if (StrUtil.isEmpty(task.getTo_y())) { + throw new BadRequestException("货位信息终点需要包含层信息"); + } + if (Integer.parseInt(task.getTo_y()) < 10 && task.getTo_y().length() == 1) { + to_y = "0" + task.getTo_y(); + task.setTo_y(to_y); + } else { + to_y = task.getTo_y(); + } + if (Integer.parseInt(task.getTo_z()) < 10 && task.getTo_z().length() == 1) { + to_z = "0" + task.getTo_z(); + task.setTo_z(to_z); + } else if (task.getTo_z().length() == 2) { + to_z = task.getTo_z(); + task.setTo_z(to_z); + } else { + to_z = task.getTo_z(); + } + task.setTo_x(next_point_code); + task.setNext_point_code(next_point_code + "-" + to_y + "-" + to_z); + task.setNext_device_code(next_point_code); - return num; + } else { + task.setNext_device_code(next_point_code); + task.setNext_device_code(next_point_code); + } + } + return task; + } + + @Override + public void updateByCodeFromCache(TaskDto dto) { + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getTask_code().equals(dto.getTask_code())) { + iterator.remove(); + } + } + tasks.add(dto); + } + + @Override + public String queryAssignedByDevice(String device_code, String task_nextdeice_code) { + List list = + deviceAssignedService.queryAssignedBydevice(device_code, task_nextdeice_code); + int flag1 = 0; + String flag2 = null; + for (int i = 0; i < list.size(); i++) { + DeviceAssignedDto dto = list.get(i); + String inst_nextDevice_code = dto.getInst_nextdevice_code(); + String task_nextDevice_code = dto.getTask_nextdevice_code(); + String param = dto.getParam(); + JSONObject jo = JSON.parseObject(param); + String regEx = "[`~!@#$%^&*()+=|{}':;'\\[\\].<>/?~!@#¥%……&*()——+|{}【】':”“’。、?]"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(inst_nextDevice_code); + String toSpeechText = m.replaceAll("").trim(); + + String[] str = toSpeechText.split(","); + List pathlist = Arrays.asList(str); + for (int j = 0; j < pathlist.size(); j++) { + String this_device_code = pathlist.get(j).toString(); + JSONObject data = JSON.parseObject(jo.getString(this_device_code)); + String limit = data.getString("limit"); + int num = instructionService.querySameDestinationInst(this_device_code); + if (num >= Integer.parseInt(limit)) { + continue; + } + if (j == 0) { + flag1 = num; + } + if (num <= flag1) { + flag2 = this_device_code; + } + } + } + if (!StrUtil.isEmpty(flag2)) { + return flag2; + } + return null; + } + + @Override + public Integer querySameDeviceReadyTask(String start_device, String next_device, String status) { + int num = 0; + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (StrUtil.equals(task.getStart_device_code(), start_device) + && StrUtil.equals(task.getNext_device_code(), next_device) + && StrUtil.equals(task.getTask_status(), status)) { + num++; + } } - @Override - public Integer querySameOriginTask(String code) { - return null; + return num; + } + + @Override + public Integer querySameTaskByType(String taskType) { + int num = 0; + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getTask_type().equals(taskType) && task.getTask_status().equals("1")) { + num++; + } } - @Override - public Integer querySameDestinationTask(String code) { - return null; - } + return num; + } + @Override + public Integer querySameOriginTask(String code) { + return null; + } + @Override + public Integer querySameDestinationTask(String code) { + return null; + } } From a5e728d4d83eb60c9cee91b4ea3e8d4d0f7a7311 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Fri, 3 Feb 2023 22:59:22 +0800 Subject: [PATCH 4/7] 1 --- .../device/device_driver/DriverTypeEnum.java | 3 +- .../service/impl/DeviceServiceImpl.java | 4 + .../siemens_conveyor_ckk/ItemProtocol.java | 132 +++ .../SiemensConveyorCkkDefination.java | 64 ++ .../SiemensConveyorCkkDeviceDriver.java | 912 ++++++++++++++++++ .../driver/ExecutableDeviceDriver.java | 16 +- .../service/impl/LiKuToAcsServiceImpl.java | 4 +- .../common/InstructStatusEnum.java | 2 + .../service/impl/InstructionServiceImpl.java | 2 +- .../src/views/acs/device/config.vue | 5 +- .../device/driver/siemens_conveyor_ckk.vue | 513 ++++++++++ 11 files changed, 1644 insertions(+), 13 deletions(-) create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/ItemProtocol.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDefination.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java create mode 100644 acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor_ckk.vue diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 893c1e309..d4f54e4a7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -41,8 +41,9 @@ public enum DriverTypeEnum { PLUG_PULL_DEVICE_SITE(15, "plug_pull_device_site", "插拔轴站点", "conveyor"), - SIEMENS_CONVEYOR_LABELING(16, "siemens_conveyor_labeling", "西门子-输送机驱动-贴标", "conveyor"); + SIEMENS_CONVEYOR_LABELING(16, "siemens_conveyor_labeling", "西门子-输送机驱动-贴标", "conveyor"), + SIEMENS_CONVEYOR_CKK(17, "siemens_conveyor_ckk", "西门子-输送机驱动-出库口", "conveyor"); //驱动索引 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 1828cd986..30da2be0e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -24,6 +24,7 @@ import org.nl.acs.device_driver.DeviceDriverDefination; import org.nl.acs.device_driver.ScannerDeviceDriver; import org.nl.acs.device_driver.basedriver.oven_manipulator.OvenGantryManipulatorDeviceDriver; import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; +import org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver; import org.nl.acs.device_driver.basedriver.siemens_conveyor_labeling.SiemensConveyorLabelingDeviceDriver; import org.nl.acs.device_driver.basedriver.slit_two_manipulator.SlitTwoManipulatorDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; @@ -949,6 +950,9 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial } else if (device.getDeviceDriver() instanceof OvenGantryManipulatorDeviceDriver) { OvenGantryManipulatorDeviceDriver ovenGantryManipulatorDeviceDriver = (OvenGantryManipulatorDeviceDriver) device.getDeviceDriver(); ovenGantryManipulatorDeviceDriver.setDeviceStatus(form); + } else if (device.getDeviceDriver() instanceof SiemensConveyorCkkDeviceDriver) { + SiemensConveyorCkkDeviceDriver siemensConveyorCkkDeviceDriver = (SiemensConveyorCkkDeviceDriver) device.getDeviceDriver(); + siemensConveyorCkkDeviceDriver.setDeviceStatus(form); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/ItemProtocol.java new file mode 100644 index 000000000..6d64f74c0 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/ItemProtocol.java @@ -0,0 +1,132 @@ +package org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk; + +import cn.hutool.core.util.StrUtil; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Data +public class ItemProtocol { + + //心跳 + public static String item_heartbeat = "heartbeat"; + //工作模式 + public static String item_mode = "mode"; + //光电信号 + public static String item_move = "move"; + //托盘方向 + public static String item_carrier_direction = "carrier_direction"; + //报警 + public static String item_error = "error"; + //任务号 + public static String item_task = "task"; + + //下发命令 + public static String item_to_command = "to_command"; + //下发目标站 + public static String item_to_target = "to_target"; + //下发托盘类型 + public static String item_to_container_type = "to_container_type"; + //下发任务号 + public static String item_to_task = "to_task"; + //困扎次数 + public static String item_to_strap_times = "to_strap_times"; + //木箱长度 + public static String item_to_length = "to_length"; + //木箱宽度 + public static String item_to_weight = "to_weight"; + //木箱高度 + public static String item_to_height = "to_height"; + + + private SiemensConveyorCkkDeviceDriver driver; + + public ItemProtocol(SiemensConveyorCkkDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getMove() { + return this.getOpcIntegerValue(item_move); + } + + public int getCarrier_direction() { + return this.getOpcIntegerValue(item_carrier_direction); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isEmpty(value)) { + + } else { + return value; + } + return "0"; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB600.B2")); + list.add(new ItemDto(item_move, "光电信号", "DB600.B3")); + list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB600.B4")); + list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); + list.add(new ItemDto(item_task, "任务号", "DB600.D10")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4")); + list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB601.W6")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); + list.add(new ItemDto(item_to_strap_times, "困扎次数", "DB601.W12")); + list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W14")); + list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W16")); + list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W18")); + return list; + } + + @Override + public String toString() { + return ""; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDefination.java new file mode 100644 index 000000000..248dc8fa9 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDefination.java @@ -0,0 +1,64 @@ +package org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +/** + * 西门子-输送机驱动 + * + */ +@Service +public class SiemensConveyorCkkDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "siemens_conveyor_ckk"; + } + + @Override + public String getDriverName() { + return "西门子-输送机驱动-出库口"; + } + + @Override + public String getDriverDescription() { + return "西门子-输送机驱动-出库口"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new SiemensConveyorCkkDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return SiemensConveyorCkkDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.station); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java new file mode 100644 index 000000000..e562ef2c8 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java @@ -0,0 +1,912 @@ +package org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.AcsConfig; +import org.nl.acs.agv.server.NDCAgvService; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest; +import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.dto.RouteLineDto; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.modules.wql.util.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; + +/** + * 西门子-输送机驱动-出库口 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); + //当前指令 + Instruction inst = null; + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //托盘方向 + int carrier_direction = 0; + int last_carrier_direction = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + int agvphase = 0; + String task_code = null; + + int phase = 0; + int index = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date require_apply_labeling_time = new Date(); + private Date require_apply_strangulation_time = new Date(); + private Date require_empty_in_time = new Date(); + private Date require_empty_out_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + boolean requireApplyLabelingSuccess = false; + boolean requireApplyLaStrangulationSuccess = false; + boolean requireEmptyInSuccess = false; + boolean requireEmptyOutSuccess = false; + boolean requiresShipDeviceUpdate = true; + private int instruction_finished_time_out; + + int branchProtocol = 0; + String inst_message; + String last_inst_message; + + //当前指令 + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + String vehicle_code; + String last_vehicle_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + carrier_direction = this.itemProtocol.getCarrier_direction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + if (mode != last_mode) { + if (mode == 2) { + requireSucess = false; + requireApplyLabelingSuccess = false; + requireApplyLaStrangulationSuccess = false; + requireEmptyInSuccess = false; + requireEmptyOutSuccess = false; + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记"); + } + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + message = null; + if (move == 0 ) { + inst_message = null; + requireSucess = false; + this.clearWrite(); + } + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (carrier_direction != last_carrier_direction) { + logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + + if (move != 0 && task > 0) { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + if (inst != null) { + inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); + vehicle_code = inst.getVehicle_code(); + task_code = inst.getTask_code(); + if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { + inst.setInstruction_status("1"); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task); + } + if (StrUtil.equals(inst.getInstruction_status(), "1")) { + if (!StrUtil.equals(inst.getExecute_code(), this.device_code)) { + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } else { +// logServer.deviceExecuteLog(device_code, "", "", "输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task); + message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; + inst_message = null; + } + } + + } catch (Exception var17) { + inst_message = var17.getMessage(); + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage()); + } + +// if (!this.itemProtocol.getIsonline()) { +// this.setIsonline(false); +// this.setIserror(true); +// message = "信号量同步异常"; +// //未联机 +// } else + if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 +// } else if (error != 0) { +// this.setIsonline(false); +// this.setIserror(true); +// message = "有报警"; +// //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + Instruction instruction = null; + List toInstructions; + + + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + break; + case 2: + //申请任务 + if (move > 0 && !requireSucess) { + try { + instruction_require(); + } catch (Exception e) { + e.printStackTrace(); + } + } + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + } + } + last_mode = mode; + last_move = move; + last_carrier_direction = carrier_direction; + last_error = error; + last_task = task; + } + + private void shipDeviceUpdate() { + JSONObject param = new JSONObject() {{ + put("device_code", device_code); + }}; + + HttpResponse response = acsToWmsService.shipDeviceUpdate(param); + if (response == null || response.getStatus() == 200) { + this.requiresShipDeviceUpdate = true; + } + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + public void clearWrite() { + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", "0"); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", "0"); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "0"); + list.add(map3); + Map map4 = new HashMap(); + map4.put("code", "to_strap_times"); + map4.put("value", "0"); + list.add(map4); + Map map5 = new HashMap(); + map5.put("code", "to_length"); + map5.put("value", "0"); + list.add(map5); + Map map6 = new HashMap(); + map6.put("code", "to_weight"); + map6.put("value", "0"); + list.add(map6); + Map map7 = new HashMap(); + map7.put("code", "to_height"); + map7.put("value", "0"); + list.add(map7); + this.writing(list); + message = null; + vehicle_code = null; + } + + public boolean exe_business() { + return true; + } + + public synchronized boolean finish_instruction() throws Exception { + instructionService.finish(inst); +// requireSucess = false; + return true; + } + + + protected void thingToNothing() throws Exception { + requireSucess = false; + } + + + public void writing(String param, String value) { + + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + param; + //String opcservcerid = this.getDevice().getOpc_server_id(); +//Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + + itemMap.put(to_param, Integer.parseInt(value)); +// itemMap.put(to_param, Integer.parseInt(value)); + this.control(itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); + } + + public void executing(Server server, Map itemMap) { + this.control(itemMap); + } + + public void writing(int command) { + + //String opcservcerid = this.getDevice().getOpc_server_id(); +//Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + this.control(itemMap); + + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String carrier_direction = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } else if (this.getMode() == 4) { + mode = "申请捆扎中"; + } else if (this.getMode() == 5) { + mode = "申请贴标中"; + } else if (this.getMode() == 6) { + mode = "申请空盘入库中"; + } else if (this.getMode() == 7) { + mode = "申请空盘出库中"; + } else if (this.getMode() == 8) { + mode = "申请AGV任务中"; + } + + if (this.getMove() == 0) { + move = "无货"; + jo.put("hasGoods", false); + } else if (this.getMove() == 1) { + move = "有货"; + jo.put("hasGoods", true); + } else if (this.getMove() == 2) { + move = "有托盘有货"; + jo.put("hasGoods", true); + } + + if (this.carrier_direction == 1) { + carrier_direction = "正转"; + } else if (this.carrier_direction == 2) { + carrier_direction = "反转"; + } + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("carrier_direction", carrier_direction); + jo.put("task", task); + jo.put("last_task", last_task); + jo.put("task_code", task_code); + +// jo.put("barcode", barcode); +// jo.put("last_task", last_task); + jo.put("inst_message", this.inst_message); + jo.put("last_inst_message", this.last_inst_message); + jo.put("isOnline", this.getIsonline()); + jo.put("error", this.getError()); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("is_click", true); + jo.put("requireSucess", requireSucess); + jo.put("driver_type", "siemens_conveyor"); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + public void writing(List list) { + +// String opcservcerid = this.getDevice().getOpc_server_id(); +// Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + this.control(itemMap); + + } + + + /** + * 请求指令 + */ + public synchronized boolean instruction_require() { + Date date = new Date(); + if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return false; + } else { + this.instruction_require_time = date; + if (task > 0) { + Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); + if (ObjectUtil.isEmpty(instruction)) { + instruction = instructionService.findByCode(String.valueOf(task)); + } + if(StrUtil.equals(instruction.getInstruction_status(),"1")){ + if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { + vehicle_code = inst.getVehicle_code(); + inst.setExecute_device_code(this.device_code); + try { + finish_instruction(); + } catch (Exception e) { + e.printStackTrace(); + } + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); + } + } + } else { + logServer.deviceExecuteLog(device_code, "", "", "申请输送任务电气设备任务号:" + task + "异常"); + message = "申请输送任务电气设备任务号:" + task + "异常"; + return false; + } + + //判断是否存在起点相同 任务状态就绪的任务 + TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); + if (!ObjectUtil.isEmpty(taskdto)) { +// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) { +// return false; +// } + //需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 + Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); + if (ObjectUtil.isNotEmpty(inst)) { + List list = new ArrayList(); + Map map = new HashMap(); + + if (StrUtil.isNotEmpty(taskdto.getTo_z())) { + if (StrUtil.equals(taskdto.getTo_z(), "01")) { + map.put("code", "to_target"); + map.put("value", "102"); + } else if (StrUtil.equals(taskdto.getTo_z(), "02")) { + map.put("code", "to_target"); + map.put("value", "201"); + } else if (StrUtil.equals(taskdto.getTo_z(), "03")) { + map.put("code", "to_target"); + map.put("value", "301"); + } + } + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", inst.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + this.writing(list); + if (task != Integer.parseInt(inst.getInstruction_code())) { + this.writing(list); + message = "重新下发电气信号"; + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + } + message = "下发电气任务号成功"; + requireSucess = true; + return true; + } + + // type 5 输送任务 + if (!StrUtil.equals(taskdto.getTask_type(), "5")) { + return false; + } + String taskid = taskdto.getTask_id(); + String taskcode = taskdto.getTask_code(); + String vehiclecode = taskdto.getVehicle_code(); + String priority = taskdto.getPriority(); + String start_point_code = taskdto.getStart_point_code(); + String start_device_code = taskdto.getStart_device_code(); + String route_plan_code = taskdto.getRoute_plan_code(); + String next_device_code = ""; + + /** + * 开始平均分配 + */ + String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code()); + if (StrUtil.isEmpty(this_coevice_code)) { + List shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; + } + } + next_device_code = pathlist.get(index); + } else { + next_device_code = this_coevice_code; + } + //校验路由关系 + List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + if (ObjectUtils.isEmpty(shortPathsList)) { + throw new RuntimeException("路由不通!"); + } + + Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); + String next_point_code; + if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { + next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z(); + } else { + next_point_code = next_device_code; + } + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(taskdto.getRemark()); + instdto.setMaterial(taskdto.getMaterial()); + instdto.setQuantity(taskdto.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setVehicle_code(vehiclecode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + try { + instructionService.create(instdto); + } catch (Exception e) { + e.printStackTrace(); + log.error("指令创建失败!",e.getMessage()); + return false; + } + //创建指令后修改任务状态 + taskdto.setTask_status("1"); + taskserver.update(taskdto); + requireSucess = true; + String next_addr = nextdevice.getExtraValue().get("address").toString(); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", instdto.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + this.writing(list); + if (task != Integer.parseInt(inst.getInstruction_code())) { + this.writing(list); + message = "重新下发电气信号"; + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + } + } else { + //如果不存在则直接找对应指令 + Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); + if (ObjectUtil.isEmpty(inst)) { + return false; + } + + Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", inst.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + this.writing(list); + if (task != Integer.parseInt(inst.getInstruction_code())) { + this.writing(list); + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); + } + requireSucess = true; + } + return true; + } + } + + //申请贴标 + public synchronized void applyLabeling() { + Date date = new Date(); + if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_apply_labeling_time = date; + String vehicle_code = ""; + if (task > 0) { + Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); + vehicle_code = instruction.getVehicle_code(); + } else { + logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常"); + message = "申请贴标电气设备任务号:" + task + "异常"; + throw new RuntimeException("任务号为空!"); + } + if (StrUtil.isEmpty(vehicle_code)) { + logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "未找到载具号"); + message = "申请贴标电气设备任务号:" + task + "未找到载具号"; + throw new RuntimeException("载具号为空!"); + } + ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = + new ApplyLabelingAndBindingRequest(); + JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); + String start_point_code = null; + if (!ObjectUtil.isEmpty(device_json)) { + start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code"); + } + applyLabelingAndBindingRequest.setDevice_code(start_point_code); + applyLabelingAndBindingRequest.setType("1"); + applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); + ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); + + if (applyLabelingAndBindingResponse.getstatus() == 200) { + message = "申请贴标成功"; + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", "5"); + list.add(map); + this.writing(list); + this.writing(list); + message = "申请贴标下发电气信号成功"; + requireApplyLabelingSuccess = true; + } else { + message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage(); + } + } + } + + //申请捆扎 + @SneakyThrows + public synchronized void applyLaStrangulation() { + Date date = new Date(); + if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_apply_strangulation_time = date; + String vehicle_code = ""; + if (task > 0) { + Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); + if(ObjectUtil.isEmpty(instruction)){ + message = "申请捆扎电气设备任务号:" + task + "未找到对应指令"; + throw new RuntimeException("该电气任务号未找到对应指令!"); + } + vehicle_code = instruction.getVehicle_code(); + } else { + logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "异常"); + message = "申请捆扎电气设备任务号:" + task + "异常"; + throw new RuntimeException("任务号为空!"); + } + if (StrUtil.isEmpty(vehicle_code)) { + logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "未找到载具号"); + message = "申请捆扎电气设备任务号:" + task + "未找到载具号"; + throw new RuntimeException("载具号为空!"); + } + ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = + new ApplyLabelingAndBindingRequest(); + JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); + String start_point_code = null; + if (!ObjectUtil.isEmpty(device_json)) { + start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code"); + } + applyLabelingAndBindingRequest.setDevice_code(start_point_code); + applyLabelingAndBindingRequest.setType("2"); + applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); + ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); + if (applyLabelingAndBindingResponse.getstatus() == 200) { + if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) { + Map datas = applyLabelingAndBindingResponse.getData(); + String length = datas.get("box_length").toString(); + String width = datas.get("box_width").toString(); + String box_high = datas.get("box_high").toString(); + String bundle_times = datas.get("bundle_times").toString(); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_length"); + map.put("value", length); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_weight"); + map2.put("value", width); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_height"); + map3.put("value", box_high); + list.add(map3); + Map map4 = new HashMap(); + map4.put("code", "to_strap_times"); + map4.put("value", bundle_times); + list.add(map4); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", "4"); + list.add(map5); + this.writing(list); +// this.writing(list); + + message = "申请捆扎成功"; + requireSucess = true; + } else { + message = "未返回尺寸信息"; + } + + } else { + message = applyLabelingAndBindingResponse.getMessage(); + } + + } + } + + public synchronized void emptyIn() { + Date date = new Date(); + if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_empty_in_time = date; + + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + message = "申请空盘入库任务中..."; + JSONObject apply = new JSONObject(); + apply.put("device_code", device_code); + apply.put("type", "2"); + String str = acsToWmsService.applyTaskToWms(apply); + JSONObject jo = JSON.parseObject(str); + if (ObjectUtil.isEmpty(jo)) { + message = "申请空盘入库接口不通"; + requireEmptyInSuccess = true; + } else { + if (jo.getInteger("status") == 200) { + message = "申请空盘入库成功"; + requireEmptyInSuccess = true; + } else { + requireEmptyInSuccess = true; + message = "申请空盘入库失败," + jo.get("message").toString(); + } + } + + } + } + } + + public synchronized void applyAgvTask() { + Date date = new Date(); + if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.instruction_require_time = date; + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + Instruction instruction = instructionService.findByCode(String.valueOf(task)); + if(ObjectUtil.isEmpty(instruction)){ + message = "指令号"+task+"未找到对应指令"; + return; + } + message = "申请AGV搬运任务中..."; + JSONObject apply = new JSONObject(); + apply.put("device_code", device_code); + apply.put("type", "4"); + apply.put("vehicle_code", instruction.getVehicle_code()); + String str = acsToWmsService.applyTaskToWms(apply); + JSONObject jo = JSON.parseObject(str); + if (ObjectUtil.isEmpty(jo)) { + message = "申请AGV搬运任务接口不通"; + requireSucess = true; + } else { + if (jo.getInteger("status") == 200) { + message = "申请AGV搬运任务成功"; + requireSucess = true; + } else { + requireSucess = true; + message = "申请AGV搬运任务失败," + jo.get("message").toString(); + } + } + + } + } + } + + public synchronized void emptyOut() { + Date date = new Date(); + if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_empty_out_time = date; + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + message = "申请空盘出库任务中..."; + JSONObject apply = new JSONObject(); + apply.put("device_code", device_code); + apply.put("type", "3"); + String str = acsToWmsService.applyTaskToWms(apply); + JSONObject jo = JSON.parseObject(str); + if (ObjectUtil.isEmpty(jo)) { + message = "申请空盘出库接口不通"; + requireSucess = true; + } else { + if (jo.getInteger("status") == 200) { + message = "申请空盘出库成功"; + requireSucess = true; + } else { + requireSucess = true; + message = "申请空盘出库失败," + jo.get("message").toString(); + } + } + + } + } + } + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java index 326d18963..3e3fe95bf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java @@ -5,16 +5,16 @@ import org.nl.acs.device_driver.DeviceDriver; public interface ExecutableDeviceDriver extends DeviceDriver { default void executeAuto() { -// try { -// this.execute(); -// } catch (Throwable var6) { -// String message = "线程调用异常:" + var6.getMessage(); -// Log.error(message); -// } finally { -// } + try { this.execute(); + } catch (Throwable var6) { + String message = "线程调用异常:" + var6.getMessage(); + Log.error(message); + } finally { + } +// this.execute(); } - void execute(); + void execute() throws Exception; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java index 79149fc11..b9feaf4c8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java @@ -118,8 +118,8 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { inst.setCarno(carNo); instructionService.update(inst); } else if(StrUtil.equals(status,"3")){ - inst.setInstruction_status("2"); - instructionService.finish(inst.getInstruction_id()); +// inst.setInstruction_status("1"); +// instructionService.finish(inst.getInstruction_id()); } else if(StrUtil.equals(status,"4")){ //5 取消指令 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructStatusEnum.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructStatusEnum.java index dafc5d227..46c0b4614 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructStatusEnum.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructStatusEnum.java @@ -1,4 +1,6 @@ package org.nl.acs.instruction.common; public class InstructStatusEnum { + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index f3901dfd0..a27ae5eaf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -789,7 +789,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu deviceService.changeDeviceStatus(jo1); removeByCodeFromCache(dto.getInstruction_code()); - this.reload(); +// this.reload(); } } diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index 8877dfa29..e460f5d08 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -94,6 +94,8 @@ import hongxiang_device from '@/views/acs/device/driver/hongxiang_device' import hongxiang_conveyor from '@/views/acs/device/driver/hongxiang_conveyor' import plug_pull_device_site from '@/views/acs/device/driver/plug_pull_device_site' import siemens_conveyor_labeling from '@/views/acs/device/driver/siemens_conveyor_labeling' +import siemens_conveyor_ckk from '@/views/acs/device/driver/siemens_conveyor_ckk' + export default { name: 'DeviceConfig', @@ -118,7 +120,8 @@ export default { siemens_conveyor, slit_two_manipulator, plug_pull_device_site, - siemens_conveyor_labeling + siemens_conveyor_labeling, + siemens_conveyor_ckk }, dicts: ['device_type'], mixins: [crud], diff --git a/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor_ckk.vue b/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor_ckk.vue new file mode 100644 index 000000000..5ac1fdee1 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor_ckk.vue @@ -0,0 +1,513 @@ + + + + + From 580f9e1597afa3af138e5539323457f3bbf36b43 Mon Sep 17 00:00:00 2001 From: ludj Date: Fri, 3 Feb 2023 23:06:04 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=8C=87=E4=BB=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InstructionServiceImpl.java | 2642 +++++++++-------- 1 file changed, 1349 insertions(+), 1293 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index f3901dfd0..9efcd6577 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -1,7 +1,5 @@ - package org.nl.acs.instruction.service.impl; - import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; @@ -64,1390 +62,1448 @@ import java.util.stream.Collectors; * @author ldjun * @description 服务实现 * @date 2021-03-18 - **/ + */ @Service @RequiredArgsConstructor @Slf4j public class InstructionServiceImpl implements InstructionService, ApplicationAutoInitial { - List instructions = new CopyOnWriteArrayList(); + List instructions = new CopyOnWriteArrayList(); - @Autowired - DeviceAppService deviceAppService; - @Autowired - NDCAgvService ndcAgvService; - @Autowired - ParamService paramService; - @Autowired - RouteLineService routeLineService; - @Autowired - TaskService taskService; - @Autowired - AcsToLiKuService acsToLiKuService; + @Autowired DeviceAppService deviceAppService; + @Autowired NDCAgvService ndcAgvService; + @Autowired ParamService paramService; + @Autowired RouteLineService routeLineService; + @Autowired TaskService taskService; + @Autowired AcsToLiKuService acsToLiKuService; - @Override - public void autoInitial() { - this.reload(); + @Override + public void autoInitial() { + this.reload(); + } + + @Override + public synchronized void reload() { + this.instructions = this.queryAll("instruction_status <2 and is_delete =0"); + } + + @Override + public Map queryAll(Map whereJson, Pageable page) { + /*WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "instruction_status < 2 and is_delete =0 ", "update_time desc"); + */ + // this.reload(); + HashMap map = new HashMap<>(); + map.put("flag", "1"); + String code = (String) whereJson.get("code"); + String vehicle_code = (String) whereJson.get("vehicle_code"); + String material_type = (String) whereJson.get("material_type"); + String status = (String) whereJson.get("status"); + String point_code = (String) whereJson.get("point_code"); + String is_over = (String) whereJson.get("is_over"); + String instruction_type = (String) whereJson.get("instruction_type"); + if (!StrUtil.isEmpty(code)) { + map.put("code", code); + } + if (!StrUtil.isEmpty(vehicle_code)) { + map.put("vehicle_code", vehicle_code); + } + if (!StrUtil.isEmpty(material_type)) { + map.put("material_type", material_type); + } + if (!StrUtil.isEmpty(status)) { + map.put("status", status); + } + if (!StrUtil.isEmpty(point_code)) { + map.put("point_code", point_code); + } + if (!StrUtil.isEmpty(is_over)) { + map.put("is_over", is_over); + } + map.put("instruction_type", instruction_type); + + Integer currentPageNumber = page.getPageNumber() + 1; + Integer pageMaxSize = page.getPageSize(); + final JSONObject jo = + WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), ""); + JSONArray jsonArray = jo.getJSONArray("content"); + List instructions = jsonArray.toJavaList(Instruction.class); + List instDtoList = + instructions.stream() + .skip((currentPageNumber - 1) * pageMaxSize) + .limit(pageMaxSize) + .collect(Collectors.toList()); + jo.put("content", instDtoList); + jo.put("totalElements", jsonArray.size()); + return jo; + } + + @Override + public Map getAll(Map whereJson, Pageable page) { + HashMap map = new HashMap<>(); + map.put("flag", "2"); + String code = (String) whereJson.get("code"); + String vehicle_code = (String) whereJson.get("vehicle_code"); + String material_type = (String) whereJson.get("material_type"); + String status = (String) whereJson.get("status"); + String point_code = (String) whereJson.get("point_code"); + String create_time = (String) whereJson.get("createTime"); + String end_time = (String) whereJson.get("end_time"); + if (!StrUtil.isEmpty(code)) { + map.put("code", code); + } + if (!StrUtil.isEmpty(vehicle_code)) { + map.put("vehicle_code", vehicle_code); + } + if (!StrUtil.isEmpty(material_type)) { + map.put("material_type", material_type); + } + if (!StrUtil.isEmpty(status)) { + map.put("status", status); + } + if (!StrUtil.isEmpty(point_code)) { + map.put("point_code", point_code); + } + if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) { + map.put("create_time", create_time); + map.put("end_time", end_time); } - @Override - public synchronized void reload() { - this.instructions = this.queryAll("instruction_status <2 and is_delete =0"); + final JSONObject jo = + WQL.getWO("QINST_QUERY") + .addParamMap(map) + .pageQuery(WqlUtil.getHttpContext(page), "create_time desc"); + return jo; + } + + @Override + public Map getByTaskId(String id) { + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject jsonObject = wo.query("task_id='" + id + "'").pageResult(); + JSONArray content = jsonObject.getJSONArray("content"); + JSONArray array = new JSONArray(); + for (int i = 0; i < content.size(); i++) { + JSONObject jo = (JSONObject) content.get(i); + JSONObject ins = new JSONObject(); + ins.put("task_id", jo.get("instruction_id")); + ins.put("task_code", jo.get("instruction_code")); + ins.put("task_status", jo.get("instruction_status")); + ins.put("start_point_code", jo.get("start_point_code")); + ins.put("next_point_code", jo.get("next_point_code")); + ins.put("matarial", jo.get("matarial")); + ins.put("remark", jo.get("remark")); + ins.put("create_by", jo.get("create_by")); + ins.put("create_time", jo.get("create_time")); + array.add(ins); } + jsonObject.put("content", array); + return jsonObject; + } - @Override - public Map queryAll(Map whereJson, Pageable page) { - /*WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "instruction_status < 2 and is_delete =0 ", "update_time desc"); - */ -// this.reload(); - HashMap map = new HashMap<>(); - map.put("flag", "1"); - String code = (String) whereJson.get("code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String is_over = (String) whereJson.get("is_over"); - String instruction_type = (String) whereJson.get("instruction_type"); - if (!StrUtil.isEmpty(code)) { - map.put("code", code); - } - if (!StrUtil.isEmpty(vehicle_code)) { - map.put("vehicle_code", vehicle_code); - } - if (!StrUtil.isEmpty(material_type)) { - map.put("material_type", material_type); - } - if (!StrUtil.isEmpty(status)) { - map.put("status", status); - } - if (!StrUtil.isEmpty(point_code)) { - map.put("point_code", point_code); - } - if (!StrUtil.isEmpty(is_over)) { - map.put("is_over", is_over); - } - map.put("instruction_type", instruction_type); + @Override + public List queryAll(Map whereJson) { + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONArray arr = wo.query().getResultJSONArray(0); + List list = arr.toJavaList(Instruction.class); + return list; + } - Integer currentPageNumber = page.getPageNumber() + 1; - Integer pageMaxSize = page.getPageSize(); - final JSONObject jo = WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), ""); - JSONArray jsonArray = jo.getJSONArray("content"); - List instructions = jsonArray.toJavaList(Instruction.class); - List instDtoList = instructions.stream().skip((currentPageNumber - 1) * pageMaxSize).limit(pageMaxSize).collect(Collectors.toList()); - jo.put("content",instDtoList); - jo.put("totalElements",jsonArray.size()); - return jo; + @Override + public List queryAll(String whereJson) { + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONArray arr = wo.query(whereJson).getResultJSONArray(0); + List list = arr.toJavaList(Instruction.class); + return list; + } + + @Override + public Instruction findById(String instruction_id) { + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = wo.query("instruction_id ='" + instruction_id + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(json)) { + final Instruction obj = json.toJavaObject(Instruction.class); + return obj; } + return null; + } - @Override - public Map getAll(Map whereJson, Pageable page) { - HashMap map = new HashMap<>(); - map.put("flag", "2"); - String code = (String) whereJson.get("code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String create_time = (String) whereJson.get("createTime"); - String end_time = (String) whereJson.get("end_time"); - if (!StrUtil.isEmpty(code)) { - map.put("code", code); - } - if (!StrUtil.isEmpty(vehicle_code)) { - map.put("vehicle_code", vehicle_code); - } - if (!StrUtil.isEmpty(material_type)) { - map.put("material_type", material_type); - } - if (!StrUtil.isEmpty(status)) { - map.put("status", status); - } - if (!StrUtil.isEmpty(point_code)) { - map.put("point_code", point_code); - } - if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) { - map.put("create_time", create_time); - map.put("end_time", end_time); - } - - final JSONObject jo = WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time desc"); - return jo; + @Override + public Instruction findByCode(String code) { + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(json)) { + return null; } + final Instruction obj = json.toJavaObject(Instruction.class); + return obj; + } - @Override - public Map getByTaskId(String id) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject jsonObject = wo.query("task_id='" + id + "'").pageResult(); - JSONArray content = jsonObject.getJSONArray("content"); - JSONArray array = new JSONArray(); - for (int i = 0; i < content.size(); i++) { - JSONObject jo = (JSONObject) content.get(i); - JSONObject ins = new JSONObject(); - ins.put("task_id", jo.get("instruction_id")); - ins.put("task_code", jo.get("instruction_code")); - ins.put("task_status", jo.get("instruction_status")); - ins.put("start_point_code", jo.get("start_point_code")); - ins.put("next_point_code", jo.get("next_point_code")); - ins.put("matarial", jo.get("matarial")); - ins.put("remark", jo.get("remark")); - ins.put("create_by", jo.get("create_by")); - ins.put("create_time", jo.get("create_time")); - array.add(ins); + @Override + public Instruction findByTaskcode(String code) { + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0); + final Instruction obj = json.toJavaObject(Instruction.class); + return obj; + } + + @Override + public Instruction findByTaskcodeAndStatus(String code) { + Iterator var3 = instructions.iterator(); + while (var3.hasNext()) { + Instruction instruction = (Instruction) var3.next(); + if (StrUtil.equals(instruction.getTask_code(), code) + && StrUtil.equals(instruction.getInstruction_status(), "0")) { + return instruction; + } + } + return null; + } + + @Override + public Instruction findByTaskid(String id, String wherecaluse) { + if (!StrUtil.isEmpty(wherecaluse)) { + wherecaluse = " and " + wherecaluse; + } + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = wo.query("task_id ='" + id + "'" + wherecaluse).uniqueResult(0); + if (ObjectUtil.isNotEmpty(json)) { + return json.toJavaObject(Instruction.class); + } + return null; + } + + @Override + public void create(Instruction dto) { + Class var2 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + dto = foramte(dto); + String task_code = dto.getTask_code(); + TaskDto task = taskService.findByCodeFromCache(task_code); + + WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + if (StrUtil.isEmpty(dto.getRoute_plan_code())) { + dto.setRoute_plan_code(task.getRoute_plan_code()); + } + if (StrUtil.isEmpty(dto.getPriority())) { + dto.setPriority(task.getPriority()); + } + if (StrUtil.isEmpty(dto.getInstruction_code())) { + dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); + } + if (StrUtil.isEmpty(dto.getInstruction_id())) { + dto.setInstruction_id(IdUtil.simpleUUID()); + } + if (StrUtil.isEmpty(dto.getIs_send())) { + dto.setIs_send(task.getIs_send()); + } + if (StrUtil.isEmpty(dto.getLink_num())) { + dto.setIs_send(task.getLink_num()); + } + if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) { + dto.setInstruction_type(task.getTask_type()); + } else if (false) { + + } else { + dto.setInstruction_type("3"); + } + + // 起点设备与终点设备相同则为初始指令 + if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) { + if (!StrUtil.equals(dto.getCompound_inst(), "0") + && StrUtil.equals(task.getCompound_task(), "1")) { + dto.setCompound_inst("1"); + dto.setCompound_inst_data(task.getCompound_task_data()); } - jsonObject.put("content", array); - return jsonObject; - } + } - @Override - public List queryAll(Map whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONArray arr = wo.query().getResultJSONArray(0); - List list = arr.toJavaList(Instruction.class); - return list; - } + dto.setCreate_by(currentUsername); + dto.setUpdate_by(currentUsername); + dto.setUpdate_time(now); + dto.setCreate_time(now); + dto.setStart_parent_code(task.getStart_parent_code()); + dto.setNext_parent_code(task.getNext_parent_code()); - @Override - public List queryAll(String whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONArray arr = wo.query(whereJson).getResultJSONArray(0); - List list = arr.toJavaList(Instruction.class); - return list; - } + if (ObjectUtil.isNotEmpty(task.getTask_type())) { + dto.setInstruction_type(task.getTask_type()); + } - @Override - public Instruction findById(String instruction_id) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("instruction_id ='" + instruction_id + "'").uniqueResult(0); - if (ObjectUtil.isNotEmpty(json)) { - final Instruction obj = json.toJavaObject(Instruction.class); - return obj; + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); + Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); + + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; + + if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = + (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code())); + } + + try { + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + String route_plan_code = task.getRoute_plan_code(); + List shortPathsList = + routeLineService.getShortPathLines( + start_device_code, next_device_code, route_plan_code); + RouteLineDto route = null; + for (int i = 0; i < shortPathsList.size(); i++) { + RouteLineDto routeLineDto = shortPathsList.get(i); + String route_device = routeLineDto.getDevice_code(); + String route_next_device = routeLineDto.getNext_device_code(); + if (route_device.equals(dto.getStart_device_code()) + && route_next_device.equals(dto.getNext_device_code())) { + route = routeLineDto; + break; + } } - return null; - } - - @Override - public Instruction findByCode(String code) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0); - if (ObjectUtil.isEmpty(json)){ - return null; + if (ObjectUtil.isEmpty(route)) { + throw new BadRequestException("未查询到相关路由!"); } - final Instruction obj = json.toJavaObject(Instruction.class); - return obj; - } - - @Override - public Instruction findByTaskcode(String code) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0); - final Instruction obj = json.toJavaObject(Instruction.class); - return obj; - } - - @Override - public Instruction findByTaskcodeAndStatus(String code) { - Iterator var3 = instructions.iterator(); - while (var3.hasNext()) { - Instruction instruction = (Instruction) var3.next(); - if (StrUtil.equals(instruction.getTask_code(), code) - && StrUtil.equals(instruction.getInstruction_status(), "0")) { - return instruction; - } - } - return null; - } - - @Override - public Instruction findByTaskid(String id, String wherecaluse) { - if (!StrUtil.isEmpty(wherecaluse)) { - wherecaluse = " and " + wherecaluse; - } - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("task_id ='" + id + "'" + wherecaluse).uniqueResult(0); - if (ObjectUtil.isNotEmpty(json)) { - return json.toJavaObject(Instruction.class); - } - return null; - } - - @Override - public void create(Instruction dto) { - Class var2 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - dto = foramte(dto); - String task_code = dto.getTask_code(); - TaskDto task = taskService.findByCodeFromCache(task_code); - - WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - if (StrUtil.isEmpty(dto.getRoute_plan_code())) { - dto.setRoute_plan_code(task.getRoute_plan_code()); - } - if (StrUtil.isEmpty(dto.getPriority())) { - dto.setPriority(task.getPriority()); - } - if (StrUtil.isEmpty(dto.getInstruction_code())) { - dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); - } - if (StrUtil.isEmpty(dto.getInstruction_id())) { - dto.setInstruction_id(IdUtil.simpleUUID()); - } - if (StrUtil.isEmpty(dto.getIs_send())) { - dto.setIs_send(task.getIs_send()); - } - if (StrUtil.isEmpty(dto.getLink_num())) { - dto.setIs_send(task.getLink_num()); - } - if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) { - dto.setInstruction_type(task.getTask_type()); - } else if (false) { - + if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) { + // 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统 + if (!StrUtil.equals(task.getAgv_system_type(), "0") + && ObjectUtil.isNotEmpty(task.getAgv_system_type())) { + NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); + ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); + } else { + // Boolean result = createLkInst(task.getStorage_task_type(),dto); + Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(), dto); + if (StrUtil.equals(resp.result, "true")) { + dto.setSend_status("1"); } else { - dto.setInstruction_type("3"); + dto.setSend_status("2"); } - - - //起点设备与终点设备相同则为初始指令 - if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) { - if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) { - dto.setCompound_inst("1"); - dto.setCompound_inst_data(task.getCompound_task_data()); - } - } - - dto.setCreate_by(currentUsername); - dto.setUpdate_by(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setStart_parent_code(task.getStart_parent_code()); - dto.setNext_parent_code(task.getNext_parent_code()); - - if (ObjectUtil.isNotEmpty(task.getTask_type())) { - dto.setInstruction_type(task.getTask_type()); - } - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); - Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); - - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - - if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code())); - } - - try { - String start_device_code = dto.getStart_device_code(); - String next_device_code = dto.getNext_device_code(); - String route_plan_code = task.getRoute_plan_code(); - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - RouteLineDto route = null; - for (int i = 0; i < shortPathsList.size(); i++) { - RouteLineDto routeLineDto = shortPathsList.get(i); - String route_device = routeLineDto.getDevice_code(); - String route_next_device = routeLineDto.getNext_device_code(); - if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) { - route = routeLineDto; - break; - } - } - if (ObjectUtil.isEmpty(route)) { - throw new BadRequestException("未查询到相关路由!"); - } - if (StrUtil.equals(shortPathsList.get(0).getType(), "1")){ - // 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统 - if (!StrUtil.equals(task.getAgv_system_type(), "0") && ObjectUtil.isNotEmpty(task.getAgv_system_type())) { - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(),dto); - } else { - // Boolean result = createLkInst(task.getStorage_task_type(),dto); - Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(),dto); - if(StrUtil.equals(resp.result,"true")){ - dto.setSend_status("1"); - } else { - dto.setSend_status("2"); - } - } - } - } catch (Exception e) { - dto.setSend_status("2"); - e.printStackTrace(); - log.error(""); - } - - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - instructions.add(dto); + } } + } catch (Exception e) { + dto.setSend_status("2"); + e.printStackTrace(); + log.error(""); + } + + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.insert(json); + instructions.add(dto); + } + } + + @Override + public void create2(Instruction dto) throws Exception { + Class var2 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + dto = foramte(dto); + String task_code = dto.getTask_code(); + TaskDto task = taskService.findByCodeFromCache(task_code); + + WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + if (StrUtil.isEmpty(dto.getRoute_plan_code())) { + dto.setRoute_plan_code(task.getRoute_plan_code()); + } + if (StrUtil.isEmpty(dto.getPriority())) { + dto.setPriority(task.getPriority()); + } + if (StrUtil.isEmpty(dto.getInstruction_code())) { + dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); + } + if (StrUtil.isEmpty(dto.getInstruction_id())) { + dto.setInstruction_id(IdUtil.simpleUUID()); + } + if (StrUtil.isEmpty(dto.getIs_send())) { + dto.setIs_send(task.getIs_send()); + } + if (StrUtil.isEmpty(dto.getLink_num())) { + dto.setIs_send(task.getLink_num()); + } + if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) { + dto.setInstruction_type(task.getTask_type()); + } else if (false) { + + } else { + dto.setInstruction_type("3"); + } + + // 起点设备与终点设备相同则为初始指令 + if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) { + if (!StrUtil.equals(dto.getCompound_inst(), "0") + && StrUtil.equals(task.getCompound_task(), "1")) { + dto.setCompound_inst("1"); + dto.setCompound_inst_data(task.getCompound_task_data()); + } + } + + dto.setCreate_by(currentUsername); + dto.setUpdate_by(currentUsername); + dto.setUpdate_time(now); + dto.setCreate_time(now); + dto.setStart_parent_code(task.getStart_parent_code()); + dto.setNext_parent_code(task.getNext_parent_code()); + + if (ObjectUtil.isNotEmpty(task.getTask_type())) { + dto.setInstruction_type(task.getTask_type()); + } + + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); + Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); + + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; + + if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = + (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code())); + } + + try { + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + String route_plan_code = task.getRoute_plan_code(); + List shortPathsList = + routeLineService.getShortPathLines( + start_device_code, next_device_code, route_plan_code); + RouteLineDto route = null; + for (int i = 0; i < shortPathsList.size(); i++) { + RouteLineDto routeLineDto = shortPathsList.get(i); + String route_device = routeLineDto.getDevice_code(); + String route_next_device = routeLineDto.getNext_device_code(); + if (route_device.equals(dto.getStart_device_code()) + && route_next_device.equals(dto.getNext_device_code())) { + route = routeLineDto; + break; + } + } + if (ObjectUtil.isEmpty(route)) { + throw new BadRequestException("未查询到相关路由!"); + } + if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) { + // 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统 + if (!StrUtil.equals(task.getAgv_system_type(), "0") + && ObjectUtil.isNotEmpty(task.getAgv_system_type())) { + NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); + ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); + } else { + // Boolean result = createLkInst(task.getStorage_task_type(),dto); + } + } + } catch (Exception e) { + dto.setSend_status("2"); + e.printStackTrace(); + } + + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.insert(json); + instructions.add(dto); + } + } + + @Override + public void createAgain(Instruction dto) throws Exception { + Class var2 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + String task_code = dto.getTask_code(); + TaskDto task = taskService.findByCodeFromCache(task_code); + WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + if (StrUtil.isEmpty(dto.getRoute_plan_code())) { + dto.setRoute_plan_code(task.getRoute_plan_code()); + } + if (StrUtil.isEmpty(dto.getInstruction_code())) { + dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); + } + if (StrUtil.isEmpty(dto.getInstruction_id())) { + dto.setInstruction_id(IdUtil.simpleUUID()); + } + List shortPathsList = + routeLineService.getShortPathLines( + dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(shortPathsList)) { + throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通"); + } + String type = shortPathsList.get(0).getType(); + if (!StrUtil.equals(type, "0")) { + JSONObject instcheckjson = + instwo + .query( + " instruction_status <3 and next_point_code= '" + + dto.getNext_point_code() + + "'" + + " and start_point_code = '" + + dto.getStart_point_code() + + "'" + + " and task_id = '" + + dto.getTask_id() + + "'") + .uniqueResult(0); + if (instcheckjson != null) { + throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!"); + } + } + + if (!StrUtil.equals(dto.getCompound_inst(), "0") + && StrUtil.equals(task.getCompound_task(), "1")) { + dto.setCompound_inst("1"); + dto.setCompound_inst_data(task.getCompound_task_data()); + } + + dto.setCreate_by(currentUsername); + dto.setUpdate_by(currentUsername); + dto.setUpdate_time(now); + dto.setCreate_time(now); + + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.insert(json); + + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); + Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); + + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; + StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; + + if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) { + String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString(); + Device lamddevice = appService.findDeviceByCode(lamd_device); + } + + // != 0 为agv任务 + // if(!StrUtil.equals(type,"0")){ + // if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1")) + // { + // agvService.sendAgvInstToMagic(dto); + // } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), + // "2")) { + // agvService.sendAgvInstToNDC(dto); + // } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), + // "3")) { + // agvService.addOrderSequences(dto); + // } + // } + instructions.add(dto); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(Instruction dto) { + Class var2 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + dto.setUpdate_time(now); + dto.setUpdate_by(currentUsername); + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.update(json); + + // Iterator iterator = instructions.iterator(); + // while (iterator.hasNext()) { + // Instruction instruction = iterator.next(); + // if (instruction.getInstruction_code().equals(dto.getInstruction_code())) { + // iterator.remove(); + // } + // } + // if (StrUtil.equals(dto.getInstruction_status(), "0") || + // StrUtil.equals(dto.getInstruction_status(), "1")) { + // instructions.add(dto); + // } + this.reload(); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteAll(String[] ids) throws Exception { + for (String instruction_id : ids) { + this.cancel(instruction_id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (Instruction instruction : all) { + Map map = new LinkedHashMap<>(); + map.put("任务标识", instruction.getTask_id()); + map.put("指令编码", instruction.getInstruction_code()); + map.put("指令由哪台设备做", instruction.getExecute_device_code()); + map.put("执行状态", instruction.getExecute_status()); + map.put("执行状态描述", instruction.getExecute_status_description()); + map.put("下一条指令由哪台设备做", instruction.getFollow_device_code()); + map.put("指令类型", instruction.getInstruction_type()); + map.put("指令状态", instruction.getInstruction_status()); + map.put("创建类型", instruction.getCreate_type()); + map.put("完成类型", instruction.getFinish_type()); + map.put("优先级", instruction.getPriority()); + map.put("执行编码", instruction.getExecute_code()); + map.put("执行信息", instruction.getExecute_message()); + map.put("起始点位编码", instruction.getStart_point_code()); + map.put("起始设备编码", instruction.getStart_device_code()); + map.put("目标点位编码", instruction.getNext_point_code()); + map.put("目标设备编码", instruction.getNext_device_code()); + map.put("排", instruction.getFrom_x()); + map.put("列", instruction.getFrom_y()); + map.put("层", instruction.getFrom_z()); + map.put("排", instruction.getTo_x()); + map.put("列", instruction.getTo_y()); + map.put("层", instruction.getTo_z()); + map.put("最后一条指令标识", instruction.getLast_instruction_id()); + map.put("是否允许修改", instruction.getCan_modify()); + map.put("备注", instruction.getRemark()); + map.put("是否启用", instruction.getIs_active()); + map.put("是否删除", instruction.getIs_delete()); + map.put("创建者", instruction.getCreate_by()); + map.put("创建时间", instruction.getCreate_time()); + map.put("修改者", instruction.getUpdate_by()); + map.put("修改时间", instruction.getUpdate_time()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void finish(String id) { + Instruction entity = this.findById(id); + // if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setInstruction_status("2"); + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + String instnextdevice = entity.getNext_device_code(); + String insttaskid = entity.getTask_id(); + WQLObject taskwo = WQLObject.getWQLObject("acs_task"); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device startdevice = appService.findDeviceByCode(entity.getStart_device_code()); + if (ObjectUtils.isEmpty(startdevice)) { + log.debug("地址对应设备未找到"); + throw new BadRequestException("地址对应设备未找到"); + } + if (instnextdevice.indexOf(".") != -1) { + instnextdevice = instnextdevice.substring(0, instnextdevice.indexOf(".")); + } + Device device = appService.findDeviceByCode(instnextdevice); + if (device == null) { + log.debug("地址对应设备未找到"); + throw new BadRequestException("地址对应设备未找到"); + } + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + + JSONObject jo1 = new JSONObject(); + jo1.put("device_code", instnextdevice); + + String start_device_code = entity.getStart_device_code(); + + Device deviceByCode = deviceAppService.findDeviceByCode(start_device_code); + if (deviceByCode == null) { + log.debug("地址对应设备未找到"); + throw new BadRequestException("地址对应设备未找到"); } + jo1.put("hasGoodStatus", "1"); + jo1.put("material_type", startdevice.getMaterial_type()); - @Override - public void create2(Instruction dto) throws Exception { - Class var2 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - dto = foramte(dto); - String task_code = dto.getTask_code(); - TaskDto task = taskService.findByCodeFromCache(task_code); + jo1.put("quantity", startdevice.getQuantity()); + jo1.put("remark", startdevice.getRemark()); + jo1.put("batch", startdevice.getBatch()); + jo1.put("vehicle_code", entity.getVehicle_code()); + jo1.put("islock", "0"); + jo1.put("barrels_code", startdevice.getBarrels_code()); + jo1.put("cooperate_code", startdevice.getCooperate_code()); + jo1.put("powder_name", startdevice.getPowder_name()); + jo1.put("barrels_status", startdevice.getBarrels_status()); + deviceService.changeDeviceStatus(jo1); + // 如果是无光电的设备 指令完成变更起点、终点状态 + JSONObject jo = new JSONObject(); + jo.put("device_code", entity.getStart_device_code()); + jo.put("hasGoodStatus", "0"); + jo.put("material_type", ""); + jo.put("quantity", ""); + jo.put("remark", ""); + jo.put("batch", ""); + jo.put("islock", "0"); + deviceService.changeDeviceStatus(jo); - WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - if (StrUtil.isEmpty(dto.getRoute_plan_code())) { - dto.setRoute_plan_code(task.getRoute_plan_code()); - } - if (StrUtil.isEmpty(dto.getPriority())) { - dto.setPriority(task.getPriority()); - } - if (StrUtil.isEmpty(dto.getInstruction_code())) { - dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); - } - if (StrUtil.isEmpty(dto.getInstruction_id())) { - dto.setInstruction_id(IdUtil.simpleUUID()); - } - if (StrUtil.isEmpty(dto.getIs_send())) { - dto.setIs_send(task.getIs_send()); - } - if (StrUtil.isEmpty(dto.getLink_num())) { - dto.setIs_send(task.getLink_num()); - } - if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) { - dto.setInstruction_type(task.getTask_type()); - } else if (false) { - - } else { - dto.setInstruction_type("3"); - } - - - //起点设备与终点设备相同则为初始指令 - if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) { - if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) { - dto.setCompound_inst("1"); - dto.setCompound_inst_data(task.getCompound_task_data()); - } - } - - dto.setCreate_by(currentUsername); - dto.setUpdate_by(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setStart_parent_code(task.getStart_parent_code()); - dto.setNext_parent_code(task.getNext_parent_code()); - - if (ObjectUtil.isNotEmpty(task.getTask_type())) { - dto.setInstruction_type(task.getTask_type()); - } - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); - Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); - - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - - if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code())); - } - - try { - String start_device_code = dto.getStart_device_code(); - String next_device_code = dto.getNext_device_code(); - String route_plan_code = task.getRoute_plan_code(); - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - RouteLineDto route = null; - for (int i = 0; i < shortPathsList.size(); i++) { - RouteLineDto routeLineDto = shortPathsList.get(i); - String route_device = routeLineDto.getDevice_code(); - String route_next_device = routeLineDto.getNext_device_code(); - if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) { - route = routeLineDto; - break; - } - } - if (ObjectUtil.isEmpty(route)) { - throw new BadRequestException("未查询到相关路由!"); - } - if (StrUtil.equals(shortPathsList.get(0).getType(), "1")){ - // 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统 - if (!StrUtil.equals(task.getAgv_system_type(), "0") && ObjectUtil.isNotEmpty(task.getAgv_system_type())) { - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(),dto); - } else { -// Boolean result = createLkInst(task.getStorage_task_type(),dto); - } - } - } catch (Exception e) { - dto.setSend_status("2"); - e.printStackTrace(); - } - - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - instructions.add(dto); - } + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0); + TaskDto obj = taskjson.toJavaObject(TaskDto.class); + // =0 则不用再次请求 + if (StrUtil.equals(obj.getRequest_again(), "0")) { + if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) { + taskService.finish(obj.getTask_id()); + } else { + finishAndCreateNextInst(entity); + } } + removeByCodeFromCache(entity.getInstruction_code()); + this.reload(); + } + @Override + @Transactional(rollbackFor = Exception.class) + public void finish(Instruction dto) { + Class var2 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + String now = DateUtil.now(); + dto.setInstruction_status("2"); + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); - @Override - public void createAgain(Instruction dto) throws Exception { - Class var2 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - String task_code = dto.getTask_code(); - TaskDto task = taskService.findByCodeFromCache(task_code); - WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - if (StrUtil.isEmpty(dto.getRoute_plan_code())) { - dto.setRoute_plan_code(task.getRoute_plan_code()); - } - if (StrUtil.isEmpty(dto.getInstruction_code())) { - dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); - } - if (StrUtil.isEmpty(dto.getInstruction_id())) { - dto.setInstruction_id(IdUtil.simpleUUID()); - } - List shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code()); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通"); - } - String type = shortPathsList.get(0).getType(); - if (!StrUtil.equals(type, "0")) { - JSONObject instcheckjson = instwo.query(" instruction_status <3 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0); - if (instcheckjson != null) { - throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!"); - } - } - - if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) { - dto.setCompound_inst("1"); - dto.setCompound_inst_data(task.getCompound_task_data()); - } - - dto.setCreate_by(currentUsername); - dto.setUpdate_by(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); - Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); - - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - - if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) { - String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - - } - - - // != 0 为agv任务 -// if(!StrUtil.equals(type,"0")){ -// if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1")) { -// agvService.sendAgvInstToMagic(dto); -// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) { -// agvService.sendAgvInstToNDC(dto); -// } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { -// agvService.addOrderSequences(dto); -// } -// } - instructions.add(dto); + wo.update(json); + String instnextdevice = dto.getNext_device_code(); + String insttaskid = dto.getTask_id(); + WQLObject taskwo = WQLObject.getWQLObject("acs_task"); + JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0); + TaskDto obj = taskjson.toJavaObject(TaskDto.class); + // =0 则不用再次请求 + if (StrUtil.equals(obj.getRequest_again(), "0")) { + if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) { + taskService.finish(obj.getTask_id()); + } else { + finishAndCreateNextInst(dto); } + } + + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + Device device = appService.findDeviceByCode(instnextdevice); + if (device == null) { + log.debug("地址对应设备未找到"); + return; + } + // 如果是无光电的设备 放货任务完成需要变更有货状态 + // StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + // if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + // standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) + // device.getDeviceDriver(); + // standardOrdinarySiteDeviceDriver.setMove(2); + // } + + // 如果是无光电的设备 指令完成变更起点、终点状态 + JSONObject jo = new JSONObject(); + jo.put("device_code", dto.getStart_point_code()); + jo.put("hasGoodStatus", "0"); + jo.put("material_type", ""); + jo.put("batch", ""); + deviceService.changeDeviceStatus(jo); + + JSONObject jo1 = new JSONObject(); + jo1.put("device_code", dto.getNext_point_code()); + jo1.put("hasGoodStatus", "1"); + jo1.put("material_type", dto.getMaterial()); + jo1.put("batch", dto.getBatch()); + deviceService.changeDeviceStatus(jo1); + + removeByCodeFromCache(dto.getInstruction_code()); + this.reload(); } + } - @Override - @Transactional(rollbackFor = Exception.class) - public void update(Instruction dto) { - Class var2 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_by(currentUsername); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); + @Override + public void finishAndCreateNextInst(Instruction dto) { + dto = foramte(dto); + String device_code = dto.getNext_device_code(); + WQLObject taskwo = WQLObject.getWQLObject("acs_task"); + JSONObject taskjson = taskwo.query("task_id ='" + dto.getTask_id() + "'").uniqueResult(0); + TaskDto acsTask = taskjson.toJavaObject(TaskDto.class); + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + List list = + routeLineService.getShortPathLines( + dto.getNext_device_code(), acsTask.getNext_device_code(), acsTask.getRoute_plan_code()); + if (ObjectUtils.isEmpty(list)) { + throw new BadRequestException("路由不通"); + } + RouteLineDto routeLineDto = (RouteLineDto) list.get(0); + String[] path = routeLineDto.getPath().split("->"); + List pathlist = Arrays.asList(path); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(dto.getNext_device_code())) { + index = m + 1; + break; + } + } + String next_device_code = pathlist.get(index); + String start_device_code = dto.getNext_device_code(); + String start_point_code = null; + String next_point_code = null; + String start_device = + deviceAppService + .findDeviceByCode(start_device_code) + .getDeviceDriverDefination() + .getFitDeviceTypes() + .get(0) + .name(); + String next_device = + deviceAppService + .findDeviceByCode(next_device_code) + .getDeviceDriverDefination() + .getFitDeviceTypes() + .get(0) + .name(); + if (StrUtil.equals("storage", start_device)) { + start_point_code = start_device_code + "-" + acsTask.getFrom_y() + "-" + acsTask.getFrom_z(); + } else { + start_point_code = start_device_code; + } + if (StrUtil.equals("storage", next_device)) { + next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); + } else { + next_point_code = next_device_code; + } + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(acsTask.getRoute_plan_code()); + instdto.setRemark(acsTask.getRemark()); + instdto.setMaterial(acsTask.getMaterial()); + instdto.setQuantity(acsTask.getQuantity()); + instdto.setTask_id(acsTask.getTask_id()); + instdto.setTask_code(acsTask.getTask_code()); + instdto.setVehicle_code(acsTask.getVehicle_code()); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setPriority(acsTask.getPriority()); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(dto.getNext_device_code()); + try { + this.create(instdto); + } catch (Exception e) { + e.printStackTrace(); + log.error("完成并创建下一条指令", e.getMessage()); + } + } - wo.update(json); + @Override + public void cancel(String id) throws Exception { + Class var2 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + // flag= true时取消指令 + boolean flag = false; + Instruction entity = this.findById(id); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); + if (StrUtil.isEmpty(entity.getRoute_plan_code())) { + entity.setRoute_plan_code(task.getRoute_plan_code()); + } -// Iterator iterator = instructions.iterator(); -// while (iterator.hasNext()) { -// Instruction instruction = iterator.next(); -// if (instruction.getInstruction_code().equals(dto.getInstruction_code())) { -// iterator.remove(); -// } -// } -// if (StrUtil.equals(dto.getInstruction_status(), "0") || StrUtil.equals(dto.getInstruction_status(), "1")) { -// instructions.add(dto); -// } - this.reload(); + // != 0 为agv任务 1=magic 2=NDC 3=XZ,4=ZHEDA + if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1") + && !StrUtil.equals(entity.getSend_status(), "2")) { + MagicAgvService magicAgvService = SpringContextHolder.getBean(MagicAgvService.class); + magicAgvService.deleteAgvInst(entity.getInstruction_code()); + flag = true; + + } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) { + // NDC agv指令不当场取消指令,需要等agv上报 + if (!StrUtil.isEmpty(entity.getAgv_jobno())) { + ndcAgvService.deleteAgvInstToNDC(entity); + } else { + flag = true; } - } + } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3") + && !StrUtil.equals(entity.getSend_status(), "2")) { + XianGongAgvService xianGongAgvService = + SpringContextHolder.getBean(XianGongAgvService.class); + xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code()); + flag = true; + } else { + flag = true; + } - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteAll(String[] ids) throws Exception { - for (String instruction_id : ids) { - this.cancel(instruction_id); + if (flag) { + + if (StrUtil.equals(entity.getInstruction_type(), "7")) { + CancelTaskRequest cancelTaskRequest = new CancelTaskRequest(); + cancelTaskRequest.setOrderId(entity.getInstruction_code()); + cancelTaskRequest.setPalletCode(entity.getVehicle_code()); + cancelTaskRequest.setSrcLocation(entity.getStart_point_code()); + cancelTaskRequest.setDestLocation(entity.getNext_point_code()); + // 1 入库,2 出库,3 移库,4 空托盘入库,5 空托盘出库 + int type = 0; + if (StrUtil.equals(task.getStorage_task_type(), "1")) { + type = 1; + } else if (StrUtil.equals(task.getStorage_task_type(), "2")) { + type = 4; + } else if (StrUtil.equals(task.getStorage_task_type(), "3")) { + type = 2; + } else if (StrUtil.equals(task.getStorage_task_type(), "4")) { + type = 5; + } else if (StrUtil.equals(task.getStorage_task_type(), "5")) { + type = 3; + } + cancelTaskRequest.setTaskType(type); + acsToLiKuService.cancelTask(cancelTaskRequest); } - } - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (Instruction instruction : all) { - Map map = new LinkedHashMap<>(); - map.put("任务标识", instruction.getTask_id()); - map.put("指令编码", instruction.getInstruction_code()); - map.put("指令由哪台设备做", instruction.getExecute_device_code()); - map.put("执行状态", instruction.getExecute_status()); - map.put("执行状态描述", instruction.getExecute_status_description()); - map.put("下一条指令由哪台设备做", instruction.getFollow_device_code()); - map.put("指令类型", instruction.getInstruction_type()); - map.put("指令状态", instruction.getInstruction_status()); - map.put("创建类型", instruction.getCreate_type()); - map.put("完成类型", instruction.getFinish_type()); - map.put("优先级", instruction.getPriority()); - map.put("执行编码", instruction.getExecute_code()); - map.put("执行信息", instruction.getExecute_message()); - map.put("起始点位编码", instruction.getStart_point_code()); - map.put("起始设备编码", instruction.getStart_device_code()); - map.put("目标点位编码", instruction.getNext_point_code()); - map.put("目标设备编码", instruction.getNext_device_code()); - map.put("排", instruction.getFrom_x()); - map.put("列", instruction.getFrom_y()); - map.put("层", instruction.getFrom_z()); - map.put("排", instruction.getTo_x()); - map.put("列", instruction.getTo_y()); - map.put("层", instruction.getTo_z()); - map.put("最后一条指令标识", instruction.getLast_instruction_id()); - map.put("是否允许修改", instruction.getCan_modify()); - map.put("备注", instruction.getRemark()); - map.put("是否启用", instruction.getIs_active()); - map.put("是否删除", instruction.getIs_delete()); - map.put("创建者", instruction.getCreate_by()); - map.put("创建时间", instruction.getCreate_time()); - map.put("修改者", instruction.getUpdate_by()); - map.put("修改时间", instruction.getUpdate_time()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void finish(String id) { - Instruction entity = this.findById(id); - //if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); entity.setUpdate_time(now); entity.setUpdate_by(currentUsername); - entity.setInstruction_status("2"); + entity.setInstruction_status("3"); WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - String instnextdevice = entity.getNext_device_code(); - String insttaskid = entity.getTask_id(); - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device startdevice = appService.findDeviceByCode(entity.getStart_device_code()); - if (ObjectUtils.isEmpty(startdevice)) { - log.debug("地址对应设备未找到"); - throw new BadRequestException("地址对应设备未找到"); - } - if (instnextdevice.indexOf(".") != -1) { - instnextdevice = instnextdevice.substring(0, instnextdevice.indexOf(".")); - } - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - throw new BadRequestException("地址对应设备未找到"); - } DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", instnextdevice); - - String start_device_code = entity.getStart_device_code(); - - Device deviceByCode = deviceAppService.findDeviceByCode(start_device_code); - if (deviceByCode == null) { - log.debug("地址对应设备未找到"); - throw new BadRequestException("地址对应设备未找到"); - } - - jo1.put("hasGoodStatus", "1"); - jo1.put("material_type", startdevice.getMaterial_type()); - - jo1.put("quantity", startdevice.getQuantity()); - jo1.put("remark", startdevice.getRemark()); - jo1.put("batch", startdevice.getBatch()); - jo1.put("vehicle_code", entity.getVehicle_code()); - jo1.put("islock", "0"); - jo1.put("barrels_code", startdevice.getBarrels_code()); - jo1.put("cooperate_code", startdevice.getCooperate_code()); - jo1.put("powder_name", startdevice.getPowder_name()); - jo1.put("barrels_status", startdevice.getBarrels_status()); - deviceService.changeDeviceStatus(jo1); // 如果是无光电的设备 指令完成变更起点、终点状态 JSONObject jo = new JSONObject(); jo.put("device_code", entity.getStart_device_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("quantity", ""); - jo.put("remark", ""); - jo.put("batch", ""); - jo.put("islock", "0"); + if (StrUtil.equals(entity.getMaterial(), "1")) { + jo.put("hasGoodStatus", "1"); + } else if (!StrUtil.equals(entity.getMaterial(), "1") + && !StrUtil.isEmpty(entity.getMaterial())) { + jo.put("hasGoodStatus", "2"); + } else { + jo.put("hasGoodStatus", "0"); + } + jo.put("material_type", entity.getMaterial()); + jo.put("batch", entity.getBatch()); + jo.put("islock", "false"); deviceService.changeDeviceStatus(jo); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0); - TaskDto obj = taskjson.toJavaObject(TaskDto.class); - // =0 则不用再次请求 - if (StrUtil.equals(obj.getRequest_again(), "0")) { - if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) { - taskService.finish(obj.getTask_id()); - } else { - finishAndCreateNextInst(entity); - } - } + JSONObject jo1 = new JSONObject(); + jo1.put("device_code", entity.getNext_device_code()); + jo.put("hasGoodStatus", "0"); + jo.put("material_type", ""); + jo.put("batch", ""); + jo1.put("islock", "false"); + deviceService.changeDeviceStatus(jo1); + String instnextdevice = entity.getNext_device_code(); + Device device = appService.findDeviceByCode(instnextdevice); + if (device == null) { + log.debug("地址对应设备未找到"); + return; + } removeByCodeFromCache(entity.getInstruction_code()); - this.reload(); + } + this.reload(); } + } - @Override - @Transactional(rollbackFor = Exception.class) - public void finish(Instruction dto) { - Class var2 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - String now = DateUtil.now(); - dto.setInstruction_status("2"); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); + @Override + public void forceCancel(String id) throws Exception { + Class var2 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + // flag= true时取消指令 + boolean flag = false; + Instruction entity = this.findById(id); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); + if (StrUtil.isEmpty(entity.getRoute_plan_code())) { + entity.setRoute_plan_code(task.getRoute_plan_code()); + } + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setInstruction_status("3"); + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + // 如果是无光电的设备 指令完成变更起点、终点状态 + JSONObject jo = new JSONObject(); + jo.put("device_code", entity.getStart_device_code()); + if (StrUtil.equals(entity.getMaterial(), "1")) { + jo.put("hasGoodStatus", "1"); + } else if (!StrUtil.equals(entity.getMaterial(), "1") + && !StrUtil.isEmpty(entity.getMaterial())) { + jo.put("hasGoodStatus", "2"); + } else { + jo.put("hasGoodStatus", "0"); + } + jo.put("material_type", entity.getMaterial()); + jo.put("batch", entity.getBatch()); + jo.put("islock", "false"); + deviceService.changeDeviceStatus(jo); - wo.update(json); - String instnextdevice = dto.getNext_device_code(); - String insttaskid = dto.getTask_id(); - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0); - TaskDto obj = taskjson.toJavaObject(TaskDto.class); - // =0 则不用再次请求 - if (StrUtil.equals(obj.getRequest_again(), "0")) { - if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) { - taskService.finish(obj.getTask_id()); - } else { - finishAndCreateNextInst(dto); - } - } + JSONObject jo1 = new JSONObject(); + jo1.put("device_code", entity.getNext_device_code()); + jo.put("hasGoodStatus", "0"); + jo.put("material_type", ""); + jo.put("batch", ""); + jo1.put("islock", "false"); + deviceService.changeDeviceStatus(jo1); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - return; - } - // 如果是无光电的设备 放货任务完成需要变更有货状态 -// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; -// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { -// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); -// standardOrdinarySiteDeviceDriver.setMove(2); -// } - - // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", dto.getStart_point_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("batch", ""); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", dto.getNext_point_code()); - jo1.put("hasGoodStatus", "1"); - jo1.put("material_type", dto.getMaterial()); - jo1.put("batch", dto.getBatch()); - deviceService.changeDeviceStatus(jo1); - - removeByCodeFromCache(dto.getInstruction_code()); - this.reload(); - } + String instnextdevice = entity.getNext_device_code(); + Device device = appService.findDeviceByCode(instnextdevice); + if (device == null) { + log.debug("地址对应设备未找到"); + return; + } + removeByCodeFromCache(entity.getInstruction_code()); } + } - @Override - public void finishAndCreateNextInst(Instruction dto){ - dto = foramte(dto); - String device_code = dto.getNext_device_code(); - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - JSONObject taskjson = taskwo.query("task_id ='" + dto.getTask_id() + "'").uniqueResult(0); - TaskDto acsTask = taskjson.toJavaObject(TaskDto.class); - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); - List list = routeLineService.getShortPathLines(dto.getNext_device_code(), acsTask.getNext_device_code(), acsTask.getRoute_plan_code()); - if (ObjectUtils.isEmpty(list)) { - throw new BadRequestException("路由不通"); - } - RouteLineDto routeLineDto = (RouteLineDto) list.get(0); - String[] path = routeLineDto.getPath().split("->"); - List pathlist = Arrays.asList(path); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(dto.getNext_device_code())) { - index = m + 1; - break; - } - } - String next_device_code = pathlist.get(index); - String start_device_code = dto.getNext_device_code(); - String start_point_code = null; - String next_point_code = null; - String start_device = deviceAppService.findDeviceByCode(start_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - String next_device = deviceAppService.findDeviceByCode(next_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - if (StrUtil.equals("storage", start_device)) { - start_point_code = start_device_code + "-" + acsTask.getFrom_y() + "-" + acsTask.getFrom_z(); - } else { - start_point_code = start_device_code; - } - if (StrUtil.equals("storage", next_device)) { - next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(acsTask.getRoute_plan_code()); - instdto.setRemark(acsTask.getRemark()); - instdto.setMaterial(acsTask.getMaterial()); - instdto.setQuantity(acsTask.getQuantity()); - instdto.setTask_id(acsTask.getTask_id()); - instdto.setTask_code(acsTask.getTask_code()); - instdto.setVehicle_code(acsTask.getVehicle_code()); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(acsTask.getPriority()); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(dto.getNext_device_code()); - try { - this.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("完成并创建下一条指令",e.getMessage()); - } + @Override + public void cancelNOSendAgv(String id) throws Exception { + Class var2 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + // flag= true时取消指令 + Instruction entity = this.findById(id); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); + if (StrUtil.isEmpty(entity.getRoute_plan_code())) { + entity.setRoute_plan_code(task.getRoute_plan_code()); + } + + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setInstruction_status("3"); + WQLObject wo = WQLObject.getWQLObject("acs_instruction"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + + // 如果是无光电的设备 指令完成变更起点、终点状态 + JSONObject jo = new JSONObject(); + jo.put("device_code", entity.getStart_device_code()); + if (StrUtil.equals(entity.getMaterial(), "1")) { + jo.put("hasGoodStatus", "1"); + } else if (!StrUtil.equals(entity.getMaterial(), "1") + && !StrUtil.isEmpty(entity.getMaterial())) { + jo.put("hasGoodStatus", "2"); + } else { + jo.put("hasGoodStatus", "0"); + } + jo.put("material_type", entity.getMaterial()); + jo.put("batch", entity.getBatch()); + jo.put("islock", "false"); + deviceService.changeDeviceStatus(jo); + + JSONObject jo1 = new JSONObject(); + jo1.put("device_code", entity.getNext_device_code()); + jo.put("hasGoodStatus", "0"); + jo.put("material_type", ""); + jo.put("batch", ""); + jo1.put("islock", "false"); + deviceService.changeDeviceStatus(jo1); + + String instnextdevice = entity.getNext_device_code(); + Device device = appService.findDeviceByCode(instnextdevice); + if (device == null) { + log.debug("地址对应设备未找到"); + return; + } + + removeByCodeFromCache(entity.getInstruction_code()); } + } - @Override - public void cancel(String id) throws Exception { - Class var2 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - //flag= true时取消指令 - boolean flag = false; - Instruction entity = this.findById(id); - if (entity == null) { - throw new BadRequestException("被删除或无权限,操作失败!"); - } - TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); - if (StrUtil.isEmpty(entity.getRoute_plan_code())) { - entity.setRoute_plan_code(task.getRoute_plan_code()); - } - - // != 0 为agv任务 1=magic 2=NDC 3=XZ,4=ZHEDA - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1") - && !StrUtil.equals(entity.getSend_status(), "2")) { - MagicAgvService magicAgvService = SpringContextHolder.getBean(MagicAgvService.class); - magicAgvService.deleteAgvInst(entity.getInstruction_code()); - flag = true; - - } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) { - //NDC agv指令不当场取消指令,需要等agv上报 - if (!StrUtil.isEmpty(entity.getAgv_jobno())) { - ndcAgvService.deleteAgvInstToNDC(entity); - } else { - flag = true; - } - } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3") - && !StrUtil.equals(entity.getSend_status(), "2")) { - XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class); - xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code()); - flag = true; - } else { - flag = true; - } - - if (flag) { - - if(StrUtil.equals(entity.getInstruction_type(),"7")){ - CancelTaskRequest cancelTaskRequest = new CancelTaskRequest(); - cancelTaskRequest.setOrderId(entity.getInstruction_code()); - cancelTaskRequest.setPalletCode(entity.getVehicle_code()); - cancelTaskRequest.setSrcLocation(entity.getStart_point_code()); - cancelTaskRequest.setDestLocation(entity.getNext_point_code()); - //1 入库,2 出库,3 移库,4 空托盘入库,5 空托盘出库 - int type = 0; - if(StrUtil.equals(task.getStorage_task_type(),"1")){ - type = 1; - } else if (StrUtil.equals(task.getStorage_task_type(),"2")){ - type = 4; - } else if (StrUtil.equals(task.getStorage_task_type(),"3")){ - type = 2; - } else if (StrUtil.equals(task.getStorage_task_type(),"4")){ - type = 5; - } else if (StrUtil.equals(task.getStorage_task_type(),"5")){ - type = 3; - } - cancelTaskRequest.setTaskType(type); - acsToLiKuService.cancelTask(cancelTaskRequest); - } - - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setInstruction_status("3"); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - - // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", entity.getStart_device_code()); - if (StrUtil.equals(entity.getMaterial(), "1")) { - jo.put("hasGoodStatus", "1"); - } else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) { - jo.put("hasGoodStatus", "2"); - } else { - jo.put("hasGoodStatus", "0"); - } - jo.put("material_type", entity.getMaterial()); - jo.put("batch", entity.getBatch()); - jo.put("islock", "false"); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", entity.getNext_device_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("batch", ""); - jo1.put("islock", "false"); - deviceService.changeDeviceStatus(jo1); - - String instnextdevice = entity.getNext_device_code(); - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - return; - } - removeByCodeFromCache(entity.getInstruction_code()); - } - this.reload(); - } - } - - @Override - public void forceCancel(String id) throws Exception { - Class var2 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - //flag= true时取消指令 - boolean flag = false; - Instruction entity = this.findById(id); - if (entity == null) { - throw new BadRequestException("被删除或无权限,操作失败!"); - } - TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); - if (StrUtil.isEmpty(entity.getRoute_plan_code())) { - entity.setRoute_plan_code(task.getRoute_plan_code()); - } - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setInstruction_status("3"); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", entity.getStart_device_code()); - if (StrUtil.equals(entity.getMaterial(), "1")) { - jo.put("hasGoodStatus", "1"); - } else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) { - jo.put("hasGoodStatus", "2"); - } else { - jo.put("hasGoodStatus", "0"); - } - jo.put("material_type", entity.getMaterial()); - jo.put("batch", entity.getBatch()); - jo.put("islock", "false"); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", entity.getNext_device_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("batch", ""); - jo1.put("islock", "false"); - deviceService.changeDeviceStatus(jo1); - - String instnextdevice = entity.getNext_device_code(); - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - return; - } - removeByCodeFromCache(entity.getInstruction_code()); - } - - } - - - @Override - public void cancelNOSendAgv(String id) throws Exception { - Class var2 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - //flag= true时取消指令 - Instruction entity = this.findById(id); - if (entity == null) { - throw new BadRequestException("被删除或无权限,操作失败!"); - } - TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); - if (StrUtil.isEmpty(entity.getRoute_plan_code())) { - entity.setRoute_plan_code(task.getRoute_plan_code()); - } - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setInstruction_status("3"); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - - // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", entity.getStart_device_code()); - if (StrUtil.equals(entity.getMaterial(), "1")) { - jo.put("hasGoodStatus", "1"); - } else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) { - jo.put("hasGoodStatus", "2"); - } else { - jo.put("hasGoodStatus", "0"); - } - jo.put("material_type", entity.getMaterial()); - jo.put("batch", entity.getBatch()); - jo.put("islock", "false"); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", entity.getNext_device_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("batch", ""); - jo1.put("islock", "false"); - deviceService.changeDeviceStatus(jo1); - - String instnextdevice = entity.getNext_device_code(); - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - return; - } - - removeByCodeFromCache(entity.getInstruction_code()); - } - } - - - @Override - public Instruction findByLinkNumSend(String code) { - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) { - return inst; - } - } - - return null; - } - - - @Override - public List findByLinkNum(String code) { - List list = new ArrayList<>(); - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { - list.add(inst); - } - } - return list; - } - - @Override - public Instruction findByLinkNumNoSend(String code) { - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { - return inst; - } - } - - return null; - } - - @Override - public Instruction findByCodeFromCache(String code) { - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - if (StrUtil.equals(code, inst.getInstruction_code())) { - return inst; - } - } - return null; - } - - - @Override - public Instruction findByBarcodeFromCache(String barcode) { - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - if (StrUtil.equals(barcode, inst.getVehicle_code())) { - return inst; - } - } - return null; - } - - @Override - public Instruction findByIdFromCache(String id) { - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - if (StrUtil.equals(id, inst.getInstruction_id())) { - return inst; - } - } - return null; - } - - @Override - public Instruction foramte(Instruction inst) { - String start_point_code = inst.getStart_point_code(); - String next_point_code = inst.getNext_point_code(); - String start_device_code = ""; - String next_device_code = ""; - if (StrUtil.contains(start_point_code, ".")) { - String[] point = start_point_code.split("\\."); - start_device_code = point[0]; - } else { - start_device_code = start_point_code; - } - if (StrUtil.contains(next_point_code, ".")) { - String[] point = next_point_code.split("\\."); - next_device_code = point[0]; - } else { - next_device_code = next_point_code; - } - if (StrUtil.contains(start_point_code, "-") && StrUtil.count(start_point_code, "-") == 2) { - String[] start_point = start_point_code.split("-"); - inst.setFrom_x(start_point[0]); - inst.setStart_device_code(start_point[0]); - inst.setFrom_y(start_point[1]); - inst.setFrom_z(start_point[2]); - } else { - String start_device = deviceAppService.findDeviceByCode(start_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - if (StrUtil.equals("storage", start_device)) { - String[] start_point = start_point_code.split("-"); - inst.setFrom_x(start_point[0]); - inst.setStart_device_code(start_point[0]); - inst.setFrom_y(start_point[1]); - inst.setFrom_z(start_point[2]); - } else { - inst.setStart_device_code(start_device_code); - } - } - - if (StrUtil.contains(next_point_code, "-") && StrUtil.count(next_point_code, "-") == 2) { - String[] next_point = next_point_code.split("-"); - inst.setTo_x(next_point[0]); - inst.setNext_device_code(next_point[0]); - inst.setTo_y(next_point[1]); - inst.setTo_z(next_point[2]); - } else { - - String next_device = deviceAppService.findDeviceByCode(next_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - if (StrUtil.equals("storage", next_device)) { - String[] next_point = start_point_code.split("-"); - inst.setTo_x(next_point[0]); - inst.setNext_device_code(next_point[0]); - inst.setTo_y(next_point[1]); - inst.setTo_z(next_point[2]); - } else { - inst.setNext_device_code(next_device_code); - } - } + @Override + public Instruction findByLinkNumSend(String code) { + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) { return inst; + } } - @Override - public Instruction findByDeviceCodeFromCache(String devicecode) { + return null; + } - List instructionList = instructions; - ListUtil.sort(instructionList, new Comparator() { + @Override + public List findByLinkNum(String code) { + List list = new ArrayList<>(); + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { + list.add(inst); + } + } + return list; + } + + @Override + public Instruction findByLinkNumNoSend(String code) { + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { + return inst; + } + } + + return null; + } + + @Override + public Instruction findByCodeFromCache(String code) { + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(code, inst.getInstruction_code())) { + return inst; + } + } + return null; + } + + @Override + public Instruction findByBarcodeFromCache(String barcode) { + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(barcode, inst.getVehicle_code())) { + return inst; + } + } + return null; + } + + @Override + public Instruction findByIdFromCache(String id) { + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(id, inst.getInstruction_id())) { + return inst; + } + } + return null; + } + + @Override + public Instruction foramte(Instruction inst) { + String start_point_code = inst.getStart_point_code(); + String next_point_code = inst.getNext_point_code(); + String start_device_code = ""; + String next_device_code = ""; + if (StrUtil.contains(start_point_code, ".")) { + String[] point = start_point_code.split("\\."); + start_device_code = point[0]; + } else { + start_device_code = start_point_code; + } + if (StrUtil.contains(next_point_code, ".")) { + String[] point = next_point_code.split("\\."); + next_device_code = point[0]; + } else { + next_device_code = next_point_code; + } + if (StrUtil.contains(start_point_code, "-") && StrUtil.count(start_point_code, "-") == 2) { + String[] start_point = start_point_code.split("-"); + inst.setFrom_x(start_point[0]); + inst.setStart_device_code(start_point[0]); + inst.setFrom_y(start_point[1]); + inst.setFrom_z(start_point[2]); + } else { + String start_device = + deviceAppService + .findDeviceByCode(start_device_code) + .getDeviceDriverDefination() + .getFitDeviceTypes() + .get(0) + .name(); + if (StrUtil.equals("storage", start_device)) { + String[] start_point = start_point_code.split("-"); + inst.setFrom_x(start_point[0]); + inst.setStart_device_code(start_point[0]); + inst.setFrom_y(start_point[1]); + inst.setFrom_z(start_point[2]); + } else { + inst.setStart_device_code(start_device_code); + } + } + + if (StrUtil.contains(next_point_code, "-") && StrUtil.count(next_point_code, "-") == 2) { + String[] next_point = next_point_code.split("-"); + inst.setTo_x(next_point[0]); + inst.setNext_device_code(next_point[0]); + inst.setTo_y(next_point[1]); + inst.setTo_z(next_point[2]); + } else { + + String next_device = + deviceAppService + .findDeviceByCode(next_device_code) + .getDeviceDriverDefination() + .getFitDeviceTypes() + .get(0) + .name(); + if (StrUtil.equals("storage", next_device)) { + String[] next_point = start_point_code.split("-"); + inst.setTo_x(next_point[0]); + inst.setNext_device_code(next_point[0]); + inst.setTo_y(next_point[1]); + inst.setTo_z(next_point[2]); + } else { + inst.setNext_device_code(next_device_code); + } + } + return inst; + } + + @Override + public Instruction findByDeviceCodeFromCache(String devicecode) { + + List instructionList = instructions; + try { + ListUtil.sort( + instructionList, + new Comparator() { @Override public int compare(Instruction o1, Instruction o2) { - return o1.getCreate_time().compareTo(o2.getCreate_time()); - } - }); - for (int i = 0; i < instructionList.size(); i++) { - Instruction inst = instructionList.get(i); - if (StrUtil.equals(devicecode, inst.getStart_device_code()) && inst.getInstruction_status().equals("0")) { - return inst; + return o1.getCreate_time().compareTo(o2.getCreate_time()); } + }); + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(devicecode, inst.getStart_device_code()) + && inst.getInstruction_status().equals("0")) { + return inst; } - return null; + } + } catch (Exception e) { + log.warn("指令排序按照创建时间执执行失败!重新执行"); + //失败之后重新查找指令 + return findByDeviceCodeFromCache(devicecode); } - @Override - public List findAllInstFromCache() { - return instructions; + return null; + } + + @Override + public List findAllInstFromCache() { + return instructions; + } + + @Override + public Integer querySameDestinationInst(String devicecode) { + int num = 0; + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + // 处理空盘位站点 + String next_code = inst.getNext_point_code(); + if (next_code.indexOf(".") != -1) { + next_code = next_code.substring(0, next_code.indexOf(".")); + } + if (StrUtil.equals(devicecode, next_code)) { + num = num + 1; + } } + return num; + } - @Override - public Integer querySameDestinationInst(String devicecode) { - int num = 0; - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - //处理空盘位站点 - String next_code = inst.getNext_point_code(); - if (next_code.indexOf(".") != -1) { - next_code = next_code.substring(0, next_code.indexOf(".")); - } - if (StrUtil.equals(devicecode, next_code)) { - num = num + 1; - } - } - - return num; + @Override + public Integer querySameInstType(String inst_type) { + int num = 0; + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(inst.getInstruction_type(), inst_type)) { + num = num + 1; + } } + return num; + } - @Override - public Integer querySameInstType(String inst_type) { - int num = 0; - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - if (StrUtil.equals(inst.getInstruction_type(), inst_type)) { - num = num + 1; - } - } - return num; + @Override + public Integer querySameOriginInst(String devicecode) { + int num = 0; + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + // 处理空盘位站点 + String start_code = inst.getStart_point_code(); + if (start_code.indexOf(".") != -1) { + start_code = start_code.substring(0, start_code.indexOf(".")); + } + if (StrUtil.equals(devicecode, start_code)) { + num = num + 1; + } } + return num; + } - @Override - public Integer querySameOriginInst(String devicecode) { - int num = 0; - Iterator it = instructions.iterator(); - while (it.hasNext()){ - Instruction inst = it.next(); - //处理空盘位站点 - String start_code = inst.getStart_point_code(); - if (start_code.indexOf(".") != -1) { - start_code = start_code.substring(0, start_code.indexOf(".")); - } - if (StrUtil.equals(devicecode, start_code)) { - num = num + 1; - } - } - return num; + @Override + public boolean removeByCodeFromCache(String code) { + + Iterator iterator = instructions.iterator(); + while (iterator.hasNext()) { + Instruction instruction = iterator.next(); + if (instruction.getInstruction_code().equals(code)) { + iterator.remove(); + return true; + } } + return false; + } - @Override - public boolean removeByCodeFromCache(String code) { + @Override + public boolean createLkInst(String type, Instruction dto) { + Class var3 = TaskInstructionLock.class; + synchronized (TaskInstructionLock.class) { + // 入库 + AcsToLiKuService acsToLiKuService = SpringContextHolder.getBean(AcsToLiKuService.class); + Resp resp = null; + if (StrUtil.equals(type, "1")) { + InStoreRequest request = new InStoreRequest(); + request.setFloorNo(Integer.parseInt(dto.getTo_z())); + request.setType(1); + request.setPalletCode(dto.getVehicle_code()); + request.setOrderId(dto.getInstruction_code()); + request.setSrcLocation(dto.getStart_point_code()); + request.setDestLocation(dto.getNext_point_code()); + resp = acsToLiKuService.inStore(request); + // 空托入库 + } else if (StrUtil.equals(type, "2")) { + InStoreRequest request = new InStoreRequest(); + request.setFloorNo(Integer.parseInt(dto.getTo_z())); + request.setType(2); + request.setPalletCode(dto.getVehicle_code()); + request.setOrderId(dto.getInstruction_code()); + request.setSrcLocation(dto.getStart_point_code()); + request.setDestLocation(dto.getNext_point_code()); + resp = acsToLiKuService.inStore(request); + // 出库 + } else if (StrUtil.equals(type, "3")) { + OutStoreRequest outStore = new OutStoreRequest(); + BaseStoreRequest baseReq = new BaseStoreRequest(); + List list = new ArrayList(); + baseReq.setOrderId(dto.getInstruction_code()); + baseReq.setSrcLocation(dto.getStart_point_code()); + baseReq.setDestLocation(dto.getNext_point_code()); + baseReq.setFloorNo(Integer.parseInt(dto.getFrom_z())); + baseReq.setPalletCode(dto.getVehicle_code()); + list.add(baseReq); + outStore.setOrderInfos(list); + outStore.setGroupId(dto.getInstruction_code()); + resp = acsToLiKuService.outStore(outStore); + // 空托出库 + } else if (StrUtil.equals(type, "4")) { + EmptyVehicleOutStoreRequest emptyVehicleOutStoreRequest = new EmptyVehicleOutStoreRequest(); + emptyVehicleOutStoreRequest.setOrderId(dto.getInstruction_code()); + emptyVehicleOutStoreRequest.setFloorNo(Integer.parseInt(dto.getFrom_z())); + emptyVehicleOutStoreRequest.setSrcLocation(dto.getStart_point_code()); + emptyVehicleOutStoreRequest.setDestLocation(dto.getNext_point_code()); + emptyVehicleOutStoreRequest.setPalletCode(dto.getVehicle_code()); + resp = acsToLiKuService.emptyVehicleOutStore(emptyVehicleOutStoreRequest); + // 转库 + } else if (StrUtil.equals(type, "5")) { + MoveStoreRequest moveStoreRequest = new MoveStoreRequest(); + BaseStoreRequest baseReq = new BaseStoreRequest(); + List list = new ArrayList(); + baseReq.setFloorNo(Integer.parseInt(dto.getFrom_z())); + baseReq.setPalletCode(dto.getVehicle_code()); + baseReq.setOrderId(dto.getInstruction_code()); + baseReq.setSrcLocation(dto.getStart_point_code()); + baseReq.setDestLocation(dto.getNext_point_code()); + list.add(baseReq); + moveStoreRequest.setGroupId(dto.getInstruction_code()); + moveStoreRequest.setOrderInfos(list); + resp = acsToLiKuService.moveStore(moveStoreRequest); + } - Iterator iterator = instructions.iterator(); - while (iterator.hasNext()) { - Instruction instruction = iterator.next(); - if (instruction.getInstruction_code().equals(code)) { - iterator.remove(); - return true; - } + if (ObjectUtil.isNotEmpty(resp)) { + if (StrUtil.equals(resp.getResult(), "true")) { + dto.setSend_status("1"); + } else { + dto.setSend_status("2"); + dto.setRemark(resp.getData().toString()); + return false; } + } else { + dto.setSend_status("2"); + dto.setRemark("ERROR"); return false; + } + return true; + } + } + + public Instruction findByContainer(String container_code) { + Iterator var3 = instructions.iterator(); + + while (var3.hasNext()) { + Instruction instruction = (Instruction) var3.next(); + if (StrUtil.equals(instruction.getVehicle_code(), container_code)) { + return instruction; + } } + return null; + } - @Override - public boolean createLkInst(String type, Instruction dto) { - Class var3 = TaskInstructionLock.class; - synchronized(TaskInstructionLock.class) { - //入库 - AcsToLiKuService acsToLiKuService = SpringContextHolder.getBean(AcsToLiKuService.class); - Resp resp = null; - if(StrUtil.equals(type,"1")){ - InStoreRequest request = new InStoreRequest(); - request.setFloorNo(Integer.parseInt(dto.getTo_z())); - request.setType(1); - request.setPalletCode(dto.getVehicle_code()); - request.setOrderId(dto.getInstruction_code()); - request.setSrcLocation(dto.getStart_point_code()); - request.setDestLocation(dto.getNext_point_code()); - resp = acsToLiKuService.inStore(request); - //空托入库 - } else if (StrUtil.equals(type,"2")){ - InStoreRequest request = new InStoreRequest(); - request.setFloorNo(Integer.parseInt(dto.getTo_z())); - request.setType(2); - request.setPalletCode(dto.getVehicle_code()); - request.setOrderId(dto.getInstruction_code()); - request.setSrcLocation(dto.getStart_point_code()); - request.setDestLocation(dto.getNext_point_code()); - resp = acsToLiKuService.inStore(request); - //出库 - } else if (StrUtil.equals(type,"3")){ - OutStoreRequest outStore = new OutStoreRequest(); - BaseStoreRequest baseReq = new BaseStoreRequest(); - List list = new ArrayList(); - baseReq.setOrderId(dto.getInstruction_code()); - baseReq.setSrcLocation(dto.getStart_point_code()); - baseReq.setDestLocation(dto.getNext_point_code()); - baseReq.setFloorNo(Integer.parseInt(dto.getFrom_z())); - baseReq.setPalletCode(dto.getVehicle_code()); - list.add(baseReq); - outStore.setOrderInfos(list); - outStore.setGroupId(dto.getInstruction_code()); - resp = acsToLiKuService.outStore(outStore); - //空托出库 - } else if (StrUtil.equals(type,"4")) { - EmptyVehicleOutStoreRequest emptyVehicleOutStoreRequest = new EmptyVehicleOutStoreRequest(); - emptyVehicleOutStoreRequest.setOrderId(dto.getInstruction_code()); - emptyVehicleOutStoreRequest.setFloorNo(Integer.parseInt(dto.getFrom_z())); - emptyVehicleOutStoreRequest.setSrcLocation(dto.getStart_point_code()); - emptyVehicleOutStoreRequest.setDestLocation(dto.getNext_point_code()); - emptyVehicleOutStoreRequest.setPalletCode(dto.getVehicle_code()); - resp = acsToLiKuService.emptyVehicleOutStore(emptyVehicleOutStoreRequest); - //转库 - } else if (StrUtil.equals(type,"5")) { - MoveStoreRequest moveStoreRequest = new MoveStoreRequest(); - BaseStoreRequest baseReq = new BaseStoreRequest(); - List list = new ArrayList(); - baseReq.setFloorNo(Integer.parseInt(dto.getFrom_z())); - baseReq.setPalletCode(dto.getVehicle_code()); - baseReq.setOrderId(dto.getInstruction_code()); - baseReq.setSrcLocation(dto.getStart_point_code()); - baseReq.setDestLocation(dto.getNext_point_code()); - list.add(baseReq); - moveStoreRequest.setGroupId(dto.getInstruction_code()); - moveStoreRequest.setOrderInfos(list); - resp = acsToLiKuService.moveStore(moveStoreRequest); - } + /* + * 判断是否为整数 + * @param str 传入的字符串 + * @return 是整数返回true,否则返回false + */ + public static boolean isInteger(String str) { + Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); + return pattern.matcher(str).matches(); + } - if(ObjectUtil.isNotEmpty(resp)){ - if(StrUtil.equals(resp.getResult(),"true")){ - dto.setSend_status("1"); - } else { - dto.setSend_status("2"); - dto.setRemark(resp.getData().toString()); - return false; - } - } else { - dto.setSend_status("2"); - dto.setRemark("ERROR"); - return false; - } - return true; - } + @Override + public void init(String id) { + Instruction inst = this.findById(id); + if (inst == null) { + throw new BadRequestException("指令不存在或已删除"); + } + if ("2".equals(inst.getInstruction_status())) { + throw new BadRequestException("指令已经完成"); } + Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + DeviceDriver startDeviceDriver = startDevice.getDeviceDriver(); + if (startDeviceDriver instanceof SiemensConveyorDeviceDriver) { + Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); - public Instruction findByContainer(String container_code) { - Iterator var3 = instructions.iterator(); - - while (var3.hasNext()) { - Instruction instruction = (Instruction) var3.next(); - if (StrUtil.equals(instruction.getVehicle_code(), container_code)) { - return instruction; - } - } - - return null; - } - - /* - * 判断是否为整数 - * @param str 传入的字符串 - * @return 是整数返回true,否则返回false - */ - public static boolean isInteger(String str) { - Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); - return pattern.matcher(str).matches(); - } - - @Override - public void init(String id) { - Instruction inst = this.findById(id); - if (inst == null) { - throw new BadRequestException("指令不存在或已删除"); - } - if ("2".equals(inst.getInstruction_status())) { - throw new BadRequestException("指令已经完成"); - } - - Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code()); - DeviceDriver startDeviceDriver = startDevice.getDeviceDriver(); - if (startDeviceDriver instanceof SiemensConveyorDeviceDriver) { - Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); - - List> list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("code", "to_target"); - map.put("value", nextDevice.getExtraValue().get("address").toString()); - list.add(map); - Map map2 = new HashMap<>(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap<>(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - ((SiemensConveyorDeviceDriver) startDeviceDriver).writing(list); - } + List> list = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("code", "to_target"); + map.put("value", nextDevice.getExtraValue().get("address").toString()); + list.add(map); + Map map2 = new HashMap<>(); + map2.put("code", "to_task"); + map2.put("value", inst.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap<>(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + ((SiemensConveyorDeviceDriver) startDeviceDriver).writing(list); } + } } From 9f0f2dc969f86fc73e39eb3e33708166da74ea0f Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Fri, 3 Feb 2023 23:11:28 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InstructionServiceImpl.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index a27ae5eaf..4074436dc 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -1227,17 +1227,27 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu public Instruction findByDeviceCodeFromCache(String devicecode) { List instructionList = instructions; - ListUtil.sort(instructionList, new Comparator() { - @Override - public int compare(Instruction o1, Instruction o2) { - return o1.getCreate_time().compareTo(o2.getCreate_time()); - } - }); - for (int i = 0; i < instructionList.size(); i++) { - Instruction inst = instructionList.get(i); - if (StrUtil.equals(devicecode, inst.getStart_device_code()) && inst.getInstruction_status().equals("0")) { - return inst; + try { + ListUtil.sort( + instructionList, + new Comparator() { + @Override + public int compare(Instruction o1, Instruction o2) { + return o1.getCreate_time().compareTo(o2.getCreate_time()); + } + }); + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(devicecode, inst.getStart_device_code()) + && inst.getInstruction_status().equals("0")) { + return inst; + } } + } catch (Exception e) { + log.warn("指令排序按照创建时间执执行失败!重新执行"); + //失败之后重新查找指令 + return findByDeviceCodeFromCache(devicecode); } return null; } From 28f05f933e9cf75333987b15e5f4d608cd2e35e2 Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Sat, 4 Feb 2023 04:00:48 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DeviceServiceImpl.java | 4 +++ .../SiemensConveyorDeviceDriver.java | 8 ++--- .../SlitTwoManipulatorDeviceDriver.java | 12 ++++++++ ...CoveyorControlWithScannerDeviceDriver.java | 14 ++++++++- .../driver/ExecutableDeviceDriver.java | 16 +++++----- .../main/resources/config/application-dev.yml | 4 +-- .../src/main/resources/config/application.yml | 2 +- .../src/views/system/monitor/device/index.vue | 30 +++++++++++++++++-- 8 files changed, 72 insertions(+), 18 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 30da2be0e..a50e0ed89 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -953,6 +953,10 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial } else if (device.getDeviceDriver() instanceof SiemensConveyorCkkDeviceDriver) { SiemensConveyorCkkDeviceDriver siemensConveyorCkkDeviceDriver = (SiemensConveyorCkkDeviceDriver) device.getDeviceDriver(); siemensConveyorCkkDeviceDriver.setDeviceStatus(form); + } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver){ + StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver + = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); + standardCoveyorControlWithScannerDeviceDriver.setDeviceStatus(form); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java index 4f6e427d5..baf6c4e7c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java @@ -297,7 +297,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme break; case 6: //空托盘满垛入库申请 - if (move > 0 && !requireEmptyInSuccess) { + if (move > 0 && !requireSucess) { emptyIn(); } if (move > 0 && !requireSucess) { @@ -867,13 +867,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme JSONObject jo = JSON.parseObject(str); if (ObjectUtil.isEmpty(jo)) { message = "申请空盘入库接口不通"; - requireEmptyInSuccess = true; + requireSucess = true; } else { if (jo.getInteger("status") == 200) { message = "申请空盘入库成功"; - requireEmptyInSuccess = true; + requireSucess = true; } else { - requireEmptyInSuccess = true; + requireSucess = true; message = "申请空盘入库失败," + jo.get("message").toString(); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index 01e3a2272..f92cf519a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -1470,6 +1470,12 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl is_disable = "禁用"; } + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + jo.put("device_name", this.getDevice().getDevice_name()); jo.put("mode", mode); jo.put("status", status); @@ -1540,5 +1546,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl if (StrUtil.isNotEmpty(is_disable)) { this.setIs_disable(Integer.parseInt(is_disable)); } + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java index 950595ff7..d3c6646f8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java @@ -853,7 +853,19 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe @Override public void setDeviceStatus(JSONObject data) { - + String requestSucess = data.getString("requireSucess"); + System.out.println(requestSucess); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + String applySucess = data.getString("applySucess"); + if (StrUtil.equals(applySucess, "0")) { + this.applySucess = false; + } else if (StrUtil.equals(applySucess, "1")) { + this.applySucess = true; + } } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java index 3e3fe95bf..326d18963 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java @@ -5,16 +5,16 @@ import org.nl.acs.device_driver.DeviceDriver; public interface ExecutableDeviceDriver extends DeviceDriver { default void executeAuto() { - try { - this.execute(); - } catch (Throwable var6) { - String message = "线程调用异常:" + var6.getMessage(); - Log.error(message); - } finally { - } +// try { // this.execute(); +// } catch (Throwable var6) { +// String message = "线程调用异常:" + var6.getMessage(); +// Log.error(message); +// } finally { +// } + this.execute(); } - void execute() throws Exception; + void execute(); } diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index 063b473e2..da186d068 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -8,11 +8,11 @@ spring: driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy # url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_one_wcs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true username: ${DB_USER:root} # password: ${DB_PWD:P@ssw0rd} # password: ${DB_PWD:Root.123456} - password: ${DB_PWD:123456} + password: ${DB_PWD:password} # 初始连接数 initial-size: 5 diff --git a/acs/nladmin-system/src/main/resources/config/application.yml b/acs/nladmin-system/src/main/resources/config/application.yml index cfc52fe40..f943602c7 100644 --- a/acs/nladmin-system/src/main/resources/config/application.yml +++ b/acs/nladmin-system/src/main/resources/config/application.yml @@ -2,7 +2,7 @@ spring: freemarker: check-template-location: false profiles: - active: prod + active: dev jackson: time-zone: GMT+8 data: diff --git a/acs/nladmin-ui/src/views/system/monitor/device/index.vue b/acs/nladmin-ui/src/views/system/monitor/device/index.vue index df82add74..fc0af8e6f 100644 --- a/acs/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/system/monitor/device/index.vue @@ -85,6 +85,12 @@ 禁用 + + + + + +