From aef28f43fe8298c427739b78e20ae0ed8e2c949b Mon Sep 17 00:00:00 2001 From: "ZHOUZ\\Noble'lift" <1014987728@qq.com> Date: Tue, 31 Oct 2023 09:30:48 +0800 Subject: [PATCH 1/8] =?UTF-8?q?dev:=E5=B9=B6=E5=8F=91=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=81=E6=95=B0=E5=AD=97=E5=AD=AA=E7=94=9F?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../szls/rest/LmsToBigScreenController.java | 24 ++++++ .../szls/service/LmsToBigScreenService.java | 3 + .../impl/LmsToBigScreenServiceImpl.java | 15 ++++ .../org/nl/wms/ext/wql/AUTO_QUERYTASK.wql | 76 ++++++++++++++++++- .../impl/ProductInstorServiceImpl.java | 4 +- .../impl/RawAssistIStorServiceImpl.java | 36 +++++---- .../nl/wms/stat/wql/ST_IVT_OUTBILLQUERY.wql | 4 +- 7 files changed, 142 insertions(+), 20 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/rest/LmsToBigScreenController.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/rest/LmsToBigScreenController.java index 36ebe730b..44f72a81e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/rest/LmsToBigScreenController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/rest/LmsToBigScreenController.java @@ -39,4 +39,28 @@ public class LmsToBigScreenController { return new ResponseEntity<>(LmsToBigScreenService.getStructInfo(jo), HttpStatus.OK); } + @PostMapping("/getMonthFreight") + @Log("当月发货运费信息") + @ApiOperation("当月发货运费信息") + @SaIgnore + public ResponseEntity getMonthFreight(@RequestBody JSONObject jo) { + return new ResponseEntity<>(LmsToBigScreenService.getMonthFreight(jo), HttpStatus.OK); + } + + @PostMapping("/getMonthYield") + @Log("当月产量信息") + @ApiOperation("当月产量信息") + @SaIgnore + public ResponseEntity getMonthYield(@RequestBody JSONObject jo) { + return new ResponseEntity<>(LmsToBigScreenService.getMonthYield(jo), HttpStatus.OK); + } + + @PostMapping("/getMonthDelivery") + @Log("当月发货信息") + @ApiOperation("当月发货信息") + @SaIgnore + public ResponseEntity getMonthDelivery(@RequestBody JSONObject jo) { + return new ResponseEntity<>(LmsToBigScreenService.getMonthDelivery(jo), HttpStatus.OK); + } + } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/service/LmsToBigScreenService.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/service/LmsToBigScreenService.java index 85cb78a4e..9cdf03dd4 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/service/LmsToBigScreenService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/service/LmsToBigScreenService.java @@ -8,4 +8,7 @@ public interface LmsToBigScreenService { JSONObject getDeviceInfo(JSONObject jo); JSONArray getStructInfo(JSONObject jo); + JSONArray getMonthFreight(JSONObject jo); + JSONArray getMonthYield(JSONObject jo); + JSONArray getMonthDelivery(JSONObject jo); } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/service/impl/LmsToBigScreenServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/service/impl/LmsToBigScreenServiceImpl.java index 316e78e9f..5ec65faaf 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/service/impl/LmsToBigScreenServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/szls/service/impl/LmsToBigScreenServiceImpl.java @@ -43,6 +43,21 @@ public class LmsToBigScreenServiceImpl implements LmsToBigScreenService { return json; } + @Override + public JSONArray getMonthFreight(JSONObject jo) { + return WQL.getWO("AUTO_QUERYTASK").addParam("flag","4").process().getResultJSONArray(0); + } + + @Override + public JSONArray getMonthYield(JSONObject jo) { + return WQL.getWO("AUTO_QUERYTASK").addParam("flag","5").process().getResultJSONArray(0); + } + + @Override + public JSONArray getMonthDelivery(JSONObject jo) { + return WQL.getWO("AUTO_QUERYTASK").addParam("flag","6").process().getResultJSONArray(0); + } + @Override public JSONArray getStructInfo(JSONObject jo) { JSONArray rows = WQLObject.getWQLObject("st_ivt_structattr").query("sect_code IN ('ZC01','KTP01','ZZ01','PD01')").getResultJSONArray(0); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/wql/AUTO_QUERYTASK.wql b/lms/nladmin-system/src/main/java/org/nl/wms/ext/wql/AUTO_QUERYTASK.wql index 511960fde..3138f7393 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/wql/AUTO_QUERYTASK.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/wql/AUTO_QUERYTASK.wql @@ -89,4 +89,78 @@ ENDSELECT ENDQUERY - ENDIF \ No newline at end of file + ENDIF + + IF 输入.flag = "4" + QUERY + SELECT + MAX( a.bill_type ) AS bill_type, + SUM( sub.box_weight ) AS total_qty, + MAX( a.bill_code ) AS bill_code, + MAX( a.estimated_freight ) AS estimated_freight, + MAX( a.run_freight ) AS run_freight, + MAX( a.unload_freight ) AS unload_freight, + MAX( a.other_freight ) AS other_freight, + MAX(a.input_time) input_time + FROM + st_ivt_iostorinv a + INNER JOIN ( + SELECT + mst.iostorinv_id, + dis.storagevehicle_code + FROM + st_ivt_iostorinv mst + LEFT JOIN st_ivt_iostorinvdis dis ON dis.iostorinv_id = mst.iostorinv_id + WHERE + ( mst.bill_type = '1004' OR mst.bill_type = '1001' ) + AND mst.bill_status = '99' + AND mst.is_delete = '0' + AND DATE_FORMAT( mst.input_time, '%Y-%m' ) = DATE_FORMAT( NOW(), '%Y-%m' ) + GROUP BY + dis.storagevehicle_code, + mst.iostorinv_id + ) b ON a.iostorinv_id = b.iostorinv_id + LEFT JOIN pdm_bi_subpackagerelationrecord sub ON sub.package_box_sn = b.storagevehicle_code + AND sub.bill_id = b.iostorinv_id + GROUP BY + a.iostorinv_id + ORDER BY + bill_code + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "5" + QUERY + SELECT + date_of_FG_inbound, + sum( net_weight ) AS qty + FROM + pdm_bi_subpackagerelation sub + WHERE + DATE_FORMAT( sub.date_of_FG_inbound, '%Y-%m' ) = DATE_FORMAT( NOW(), '%Y-%m' ) + GROUP BY + date_of_FG_inbound + ORDER BY + date_of_FG_inbound + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "6" + QUERY + SELECT + DATE_FORMAT( mst.input_time, '%Y-%m-%d' ) date, + sum( mst.total_qty ) total_qty + FROM + ST_IVT_IOStorInv mst + WHERE mst.bill_type IN ( '1001', '1004' ) + AND substr( mst.confirm_time, 1, 7 )<> '' + AND DATE_FORMAT( mst.input_time, '%Y-%m' ) = DATE_FORMAT( NOW(), '%Y-%m' ) + GROUP BY + DATE_FORMAT( mst.input_time, '%Y-%m-%d' ) + ORDER BY + date + ENDSELECT + ENDQUERY + ENDIF \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java index 732f1bd85..1f8510cd1 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/ProductInstorServiceImpl.java @@ -133,7 +133,7 @@ public class ProductInstorServiceImpl implements ProductInstorService { mst_jo.put("biz_date", DateUtil.now()); RLock lock = redissonClient.getLock("pda_ioIn"); - boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS); + boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); try { if (tryLock) { if (option.equals("1")) { @@ -330,6 +330,8 @@ public class ProductInstorServiceImpl implements ProductInstorService { inbillService.confirmDis(dis_form); } + }else { + throw new BadRequestException("其他木箱当前正在分配货位,请等待几秒再进行操作!"); } } finally { 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 746fbe704..913fece06 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 @@ -708,25 +708,29 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService { } RLock lock = redissonClient.getLock("all_div"); - boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS); + boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); try { - for (String vehicle_code : vehicle_set) { - HashMap map = new HashMap<>(); - map.put("flag", "4"); - map.put("iostorinv_id", iostorinv_id); - map.put("package_box_sn", vehicle_code); - JSONArray dtl_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(map).process().getResultJSONArray(0); - List list = new ArrayList<>(); - for (int i = 0; i < dtl_rows.size(); i++) { - JSONObject jo = dtl_rows.getJSONObject(i); - list.add(JSON.parseObject(jo.toString(),Map.class)); + if (tryLock) { + for (String vehicle_code : vehicle_set) { + HashMap map = new HashMap<>(); + map.put("flag", "4"); + map.put("iostorinv_id", iostorinv_id); + map.put("package_box_sn", vehicle_code); + JSONArray dtl_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(map).process().getResultJSONArray(0); + List list = new ArrayList<>(); + for (int i = 0; i < dtl_rows.size(); i++) { + JSONObject jo = dtl_rows.getJSONObject(i); + list.add(JSON.parseObject(jo.toString(),Map.class)); + } + Map dis_map = new HashMap<>(); + dis_map.put("tableMater",list); + dis_map.put("sect_id",sect_id); + dis_map.put("checked",true); + this.divStruct(dis_map); } - Map dis_map = new HashMap<>(); - dis_map.put("tableMater",list); - dis_map.put("sect_id",sect_id); - dis_map.put("checked",true); - this.divStruct(dis_map); + }else { + throw new BadRequestException("其他入库单当前正在分配货位,请等待几秒再进行操作!"); } }finally { if (tryLock) { diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/stat/wql/ST_IVT_OUTBILLQUERY.wql b/lms/nladmin-system/src/main/java/org/nl/wms/stat/wql/ST_IVT_OUTBILLQUERY.wql index 0cf92e9b4..1549fab3b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/stat/wql/ST_IVT_OUTBILLQUERY.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/stat/wql/ST_IVT_OUTBILLQUERY.wql @@ -84,7 +84,7 @@ WHERE b.io_type = '1' OPTION 输入.bill_type <> "" - b.bill_type = 输入.bill_type + b.bill_type IN 输入.bill_type ENDOPTION OPTION 输入.pcsn <> "" a.pcsn = 输入.pcsn @@ -187,7 +187,7 @@ WHERE b.io_type = '1' OPTION 输入.bill_type <> "" - b.bill_type = 输入.bill_type + b.bill_type IN 输入.bill_type ENDOPTION OPTION 输入.pcsn <> "" a.pcsn = 输入.pcsn From b5cd16b295a728f502f1bb8502e81047a560b164 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Tue, 31 Oct 2023 16:02:14 +0800 Subject: [PATCH 2/8] =?UTF-8?q?rev=20=E4=BF=A1=E5=8F=B7=E4=B8=8B=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OvenGantryManipulatorDeviceDriver.java | 4 +- ...CoveyorControlWithScannerDeviceDriver.java | 38 +++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java index 745870ba0..c9a4b4fb0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -383,7 +383,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i //存在行架->暂存的AGV任务 需要过滤 // 6 行架任务 8烘箱任务 - if(!StrUtil.equals(taskDto.getTask_type(),"6") || StrUtil.equals(taskDto.getTask_type(),"8")){ + if(!StrUtil.equals(taskDto.getTask_type(),"6") && !StrUtil.equals(taskDto.getTask_type(),"8")){ taskDto = null; continue; } @@ -478,7 +478,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i taskDtoList = this.sortTask(taskDtoList); task = taskDtoList.get(j); // 6 行架任务 8烘箱任务 - if(!StrUtil.equals(task.getTask_type(),"6") || StrUtil.equals(task.getTask_type(),"8")){ + if(!StrUtil.equals(task.getTask_type(),"6") && !StrUtil.equals(task.getTask_type(),"8")){ task = null; continue; } 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 4b31e481c..591b2e6b0 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 @@ -936,8 +936,16 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe + "." + param; Map itemMap = new HashMap(); itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try{ + this.checkcontrol(itemMap); + } catch (Exception e1){ + e1.printStackTrace(); + } + } } // 申请贴标 @@ -1017,6 +1025,21 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe } else { message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage(); logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:" + JSON.toJSONString(applyLabelingAndBindingResponse)); + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", "1011"); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_command"); + map2.put("value", "1"); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_task"); + map3.put("value", "0"); + list.add(map3); + this.writing(list); + requireSucess = true; } } @@ -1034,7 +1057,16 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe } } logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - this.control(itemMap); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try{ + this.checkcontrol(itemMap); + } catch (Exception e1){ + e1.printStackTrace(); + } + } } @Override From 772a6e8efa4f78b5963b9e5a90f9d63459a0ba64 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Thu, 2 Nov 2023 11:24:39 +0800 Subject: [PATCH 3/8] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9E=E7=BA=B8=E7=AE=A1?= =?UTF-8?q?=E5=BA=93=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/device_driver/DriverTypeEnum.java | 6 +- .../paper_tube_device2/ItemProtocol.java | 226 +++++++++++++++++ .../PaperTubeConveyor2Defination.java | 61 +++++ .../PaperTubeConveyor2DeviceDriver.java | 232 ++++++++++++++++++ ...CoveyorControlWithScannerDeviceDriver.java | 1 + .../wms/service/impl/WmsToAcsServiceImpl.java | 7 + 6 files changed, 532 insertions(+), 1 deletion(-) create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java 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 998f6f584..d0db77776 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 @@ -55,7 +55,11 @@ public enum DriverTypeEnum { PAPER_TUBE_DEVICE(22, "paper_tube_conveyor", "纸管库设备", "conveyor"), - DEVICE_STATUS(23,"device_status","立库设备状态","conveyor"); + DEVICE_STATUS(23,"device_status","立库设备状态","conveyor"), + + PACKAGE_MANIPULATOR(24,"package_manipulator","内包间行架机械手","station"), + + PAPER_TUBE_DEVICE2(22, "paper_tube_conveyor2", "纸管库设备2", "conveyor"); //驱动索引 private int index; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java new file mode 100644 index 000000000..9e975fe10 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java @@ -0,0 +1,226 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +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_out_seq_arr = "out_seq_arr"; + //出库数量数组 + public static String item_out_qty_arr = "out_qty_arr"; + //物料1 + public static String item_material1 = "material1"; + //物料2 + public static String item_material2 = "material2"; + //物料3 + public static String item_material3 = "material3"; + //物料4 + public static String item_material4 = "material4"; + //物料5 + public static String item_material5 = "material5"; + //物料6 + public static String item_material6 = "material6"; + //物料7 + public static String item_material7 = "material7"; + //物料8 + public static String item_material8 = "material8"; + //物料9 + public static String item_material9 = "material9"; + //物料10 + public static String item_material10 = "material10"; + //物料11 + public static String item_material11 = "material11"; + //物料12 + public static String item_material12 = "material12"; + //数量1 + public static String item_qty1 = "qty1"; + //数量2 + public static String item_qty2 = "qty2"; + //数量3 + public static String item_qty3 = "qty3"; + //数量4 + public static String item_qty4 = "qty4"; + //数量5 + public static String item_qty5 = "qty5"; + //数量6 + public static String item_qty6 = "qty6"; + //数量7 + public static String item_qty7 = "qty7"; + //数量8 + public static String item_qty8 = "qty8"; + //数量9 + public static String item_qty9 = "qty9"; + //数量10 + public static String item_qty10 = "qty10"; + //数量11 + public static String item_qty11 = "qty11"; + //数量12 + public static String item_qty12 = "qty12"; + + + //下发命令 + public static String item_to_command = "to_command"; + //下发目标站 + public static String item_to_target = "to_target"; + + public static String item_to_task = "to_task"; + public static String item_to_material1 = "to_material1"; + public static String item_to_out_qty1 = "to_out_qty1"; + public static String item_to_seq1 = "to_seq1"; + public static String item_to_position1 = "to_position1"; + + public static String item_to_material2 = "to_material2"; + public static String item_to_out_qty2 = "to_out_qty2"; + public static String item_to_seq2 = "to_seq2"; + public static String item_to_position2 = "to_position2"; + + public static String item_to_material3 = "to_material3"; + public static String item_to_out_qty3 = "to_out_qty3"; + public static String item_to_seq3 = "to_seq3"; + public static String item_to_position3 = "to_position3"; + + + private PaperTubeConveyor2DeviceDriver driver; + + public ItemProtocol(PaperTubeConveyor2DeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public String getMaterial1() { + return this.getOpcStringValue(item_material1); + } + + public String getMaterial2() { + return this.getOpcStringValue(item_material2); + } + + public String getMaterial3() { + return this.getOpcStringValue(item_material3); + } + + public String getMaterial4() { + return this.getOpcStringValue(item_material4); + } + + public String getMaterial5() { + return this.getOpcStringValue(item_material5); + } + + public String getMaterial6() { + return this.getOpcStringValue(item_material6); + } + + public String getMaterial7() { + return this.getOpcStringValue(item_material7); + } + + public String getMaterial8() { + return this.getOpcStringValue(item_material8); + } + + public String getMaterial9() { + return this.getOpcStringValue(item_material9); + } + + public String getMaterial10() { + return this.getOpcStringValue(item_material10); + } + + public String getMaterial11() { + return this.getOpcStringValue(item_material11); + } + + public String getMaterial12() { + return this.getOpcStringValue(item_material12); + } + + + public int getTotarget() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isBlank(value)) { + + } else { + return value; + } + return "0"; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB101.W0")); + list.add(new ItemDto(item_mode, "模式", "DB101.W2")); + + list.add(new ItemDto(item_error, "error", "DB101.W58")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_target , "下发仓位号", "DB102.W2")); + list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4")); + + return list; + } + + @Override + public String toString() { + return ""; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java new file mode 100644 index 000000000..5ae32d885 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java @@ -0,0 +1,61 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +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 PaperTubeConveyor2Defination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "paper_tube_conveyor2"; + } + + @Override + public String getDriverName() { + return "纸管库2"; + } + + @Override + public String getDriverDescription() { + return "纸管库2"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new PaperTubeConveyor2DeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return PaperTubeConveyor2DeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + 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/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java new file mode 100644 index 000000000..276a66c8f --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java @@ -0,0 +1,232 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.server.AgvService; +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.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.history.ErrorUtil; +import org.nl.acs.instruction.service.InstructionService; +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.task.service.TaskService; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 纸管库 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); + @Autowired + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + @Autowired + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); + @Autowired + AgvService agvService = SpringContextHolder.getBean(AgvService.class); + + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + private Date instruction_apply_time = new Date(); + private int instruction_require_time_out = 3000; + + int heartbeat = 0; + int mode = 0; + int inventory_qty =0; + int out_finish =0; + int error =0; + int to_command =0; + int to_target =0; + String material = null; + + Boolean isonline = true; + + Boolean iserror = false; + + //1-执行任务;2-取货完成;3-放货完成; + int flag; + + int last_mode = 0; + int last_inventory_qty =0; + int last_out_finish =0; + int last_error = 0; + String last_material = null; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + //请求成功标记 + Boolean requireSucess = false; + + @Override + public void execute() { + String message = null; + + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getHeartbeat(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTotarget(); + + if (mode != last_mode) { + this.setRequireSucess(false); + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + } else { + this.setIsonline(true); + } + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (inventory_qty != last_inventory_qty) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号inventory_qty:" + last_inventory_qty + "->" + inventory_qty); + } + if (out_finish != last_out_finish) { + if(out_finish == 1){ + this.writing(0); + this.writing("to_target","0"); + this.writing("to_out_qty","0"); + + } + logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); + } + if (!StrUtil.equals(material,last_material)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material:" + last_material + "->" + material); + } + if (error != last_error) { + if(error > 0){ + this.setIserror(true); + } else { + if(error > 0){ + this.setIserror(false); + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); + } + + + last_mode = mode; + last_inventory_qty = inventory_qty; + last_out_finish = out_finish; + last_error = error; + last_material = material; + } + + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; + + Map itemMap = new HashMap(); + this.control(itemMap); + } + + + public void writing(List list) { + + 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); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try{ + this.checkcontrol(itemMap); + } catch (Exception e1){ + e1.printStackTrace(); + } + } + + } + public void writing(String key, String param) { + + 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(param)); +// itemMap.put(to_param, Integer.parseInt(value)); + this.control(itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + param); + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + + 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 = "出库中"; + } + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); + jo.put("inventory_qty", inventory_qty); + jo.put("out_finish", out_finish); + jo.put("material", material); + jo.put("isOnline", this.getIsonline()); + + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } +} 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 591b2e6b0..23a9448d5 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 @@ -393,6 +393,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe last_error = error; last_move = move; last_task = task; + last_height = height; last_plcbarcode_length = plcbarcode_length; last_plcbarcode = plcbarcode; last_weight = weight; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index bfedc6cb0..4ac9b6396 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -1255,6 +1255,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { e.printStackTrace(); } + } else if(StrUtil.equals(type, "3")){ + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 3); + list.add(map); + paperTubeConveyorDeviceDriver.writing(list); } } From 84d12e41ddbd50211a7663ea983ab5c5eb91bfc7 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Fri, 3 Nov 2023 13:50:17 +0800 Subject: [PATCH 4/8] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9Elms=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/ApplyManipulatorActionRequest.java | 28 +++++++++++ .../data/ApplyManipulatorActionResponse.java | 48 +++++++++++++++++++ .../ext/wms/data/ApplyPaperActionRequest.java | 42 ++++++++++++++++ .../wms/data/ApplyPaperActionResponse.java | 14 ++++++ 4 files changed, 132 insertions(+) create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionResponse.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionRequest.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionResponse.java diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java new file mode 100644 index 000000000..9ee34077f --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java @@ -0,0 +1,28 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +@Data +public class ApplyManipulatorActionRequest extends BaseRequest { + private String vehicle_code; + private String device_code; + /** + * 2-尺寸交互反馈,反馈任务类型 + * 3-反馈新放货点 + * 4-反馈新取货点 + * 5-反馈二次放货点 + */ + private String type; + + /** + * 任务号 + */ + private String task_code; + + /** + * 气胀轴尺寸 3/6寸 + */ + private String size; + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionResponse.java new file mode 100644 index 000000000..be4283be7 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionResponse.java @@ -0,0 +1,48 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class ApplyManipulatorActionResponse extends BaseResponse { + + private Map data = new HashMap(); + + /** + * 放货点 + */ + private String put_device_code; + + /** + * 取货点 + */ + private String get_device_code; + + /** + * 二次放货点 + */ + private String put_device_code2; + + /** + * 下发的指令类型 + */ + private String detail_type; + + /** + * 气胀轴代数 + */ + private String version; + + /** + * 套管数量 + */ + private String bushing_num; + + /** + * 是否套管 + */ + private String is_bushing; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionRequest.java new file mode 100644 index 000000000..c289be887 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionRequest.java @@ -0,0 +1,42 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +@Data +public class ApplyPaperActionRequest extends BaseRequest { + + private String device_code; + + /** + * 1 纸管库出库申请 + * 2 套管请求 + */ + private String type; + + /** + * 任务号:输送任务号 + */ + private String task_code; + + + /** + * 出库物料1 + */ + private String material1; + + /** + * 出库物料2 + */ + private String material2; + + /** + * 出库物料数量1 + */ + private String qty1; + + /** + * 出库物料数量2 + */ + private String qty2; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionResponse.java new file mode 100644 index 000000000..71cd02ae2 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionResponse.java @@ -0,0 +1,14 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class ApplyPaperActionResponse extends BaseResponse { + + private Map data = new HashMap(); + + +} From 82c46653e651cc63242a981e0b060f1c1408501c Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Fri, 3 Nov 2023 14:32:40 +0800 Subject: [PATCH 5/8] =?UTF-8?q?rev=20=E6=96=B0=E5=A2=9E=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/task/service/dto/TaskDto.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index 7c5875db1..1353df4f9 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -307,6 +307,26 @@ public class TaskDto implements Serializable { */ private String next_height = "0"; + /** + * 行架任务类型 + */ + private String truss_type; + + + /** + * 气胀轴代数 + */ + private String version; + + /** + * 是否套管 + */ + private String is_bushing; + + //array device_code\material_code\qty + private String paper_array; + + @Override public String toString(){ From 2e634be0ce432e92d89f803aae716e17cc78c6d1 Mon Sep 17 00:00:00 2001 From: yanps Date: Tue, 7 Nov 2023 10:47:16 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E7=BA=B8=E7=AE=A1=E5=BA=93=E5=92=8C?= =?UTF-8?q?=E5=A5=97=E7=AE=A1=E5=B7=A5=E4=BD=8D=E9=A9=B1=E5=8A=A8=E7=BC=96?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- acs/nladmin-system/pom.xml | 10 +- .../device/device_driver/DriverTypeEnum.java | 4 +- .../paper_tube_device/ItemProtocol.java | 1 + .../PaperTubeConveyorDeviceDriver.java | 4 +- .../paper_tube_device2/ItemProtocol.java | 105 +++- .../PaperTubeConveyor2DeviceDriver.java | 508 ++++++++++++++++-- .../device_driver/driver/OpcDeviceDriver.java | 5 + .../acs/ext/wms/service/AcsToWmsService.java | 7 + .../wms/service/impl/AcsToWmsServiceImpl.java | 36 +- .../task/service/impl/TaskServiceImpl.java | 5 + .../main/resources/config/application-dev.yml | 2 +- .../src/views/acs/device/config.vue | 6 +- 12 files changed, 620 insertions(+), 73 deletions(-) diff --git a/acs/nladmin-system/pom.xml b/acs/nladmin-system/pom.xml index aa9a18954..32af48f4c 100644 --- a/acs/nladmin-system/pom.xml +++ b/acs/nladmin-system/pom.xml @@ -40,11 +40,11 @@ jansi 1.9 - + org.apache.commons @@ -90,6 +90,12 @@ org.openscada.utgard org.openscada.opc.lib 1.5.0 + + + org.bouncycastle + bcprov-jdk15on + + com.squareup.okhttp3 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 d0db77776..14685d63c 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 @@ -59,7 +59,9 @@ public enum DriverTypeEnum { PACKAGE_MANIPULATOR(24,"package_manipulator","内包间行架机械手","station"), - PAPER_TUBE_DEVICE2(22, "paper_tube_conveyor2", "纸管库设备2", "conveyor"); + PAPER_TUBE_DEVICE2(25, "paper_tube_conveyor2", "纸管库设备2", "conveyor"), + + CASING_STATION(26, "casing_station", "套管工位", "conveyor"); //驱动索引 private int index; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java index fdabd5ac7..dd690e4e8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java @@ -4,6 +4,7 @@ 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 org.nl.acs.device_driver.basedriver.paper_tube_device2.PaperTubeConveyor2DeviceDriver; import java.util.ArrayList; import java.util.List; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java index 07e25a1dc..e0b5f3136 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java @@ -123,7 +123,7 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple } if (out_finish != last_out_finish) { if(out_finish == 1){ - this.writing(0); + //this.writing(0); this.writing("to_target","0"); this.writing("to_out_qty","0"); @@ -197,7 +197,7 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple itemMap.put(to_param, Integer.parseInt(param)); // itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); + //this.control(itemMap); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + param); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java index 9e975fe10..8a14a2ad5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java @@ -1,8 +1,12 @@ package org.nl.acs.device_driver.basedriver.paper_tube_device2; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; import lombok.Data; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.formula.functions.T; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import java.util.ArrayList; @@ -82,7 +86,7 @@ public class ItemProtocol { public static String item_to_command = "to_command"; //下发目标站 public static String item_to_target = "to_target"; - + //下发任务号 public static String item_to_task = "to_task"; public static String item_to_material1 = "to_material1"; public static String item_to_out_qty1 = "to_out_qty1"; @@ -114,10 +118,40 @@ public class ItemProtocol { 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); + } + + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public String getItem_out_seq_arr() { + return this.getOpcStringValue(item_out_seq_arr); + } + + public List getItem_out_seq_arr1() { + return this.getOpcArrayValue1(item_out_seq_arr); + } + + public int[] getItem_out_qty_arr() { + return this.getOpcArrayValue(item_out_qty_arr); + } + + + public String getMaterial1() { return this.getOpcStringValue(item_material1); } @@ -200,12 +234,61 @@ public class ItemProtocol { return "0"; } + public int[] getOpcArrayValue(String protocol) { + int[] arrayValue = this.driver.getIntegeregerArrayValue(protocol); + if (ObjectUtil.isNull(arrayValue)) { + + } else { + return arrayValue; + } + return new int[3]; + } + + public List getOpcArrayValue1(String protocol) { + List arrayValue = this.driver.getArrayValue(protocol); + if (ObjectUtil.isNull(arrayValue)) { + + } else { + return arrayValue; + } + return new ArrayList(); + } + + public static List getReadableItemDtos() { ArrayList list = new ArrayList(); list.add(new ItemDto(item_heartbeat, "心跳", "DB101.W0")); - list.add(new ItemDto(item_mode, "模式", "DB101.W2")); - - list.add(new ItemDto(item_error, "error", "DB101.W58")); + list.add(new ItemDto(item_mode, "工作模式", "DB101.W2")); + list.add(new ItemDto(item_move, "光电信号", "DB101.W3")); + list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.W4")); + list.add(new ItemDto(item_error, "报警", "DB101.W58")); + list.add(new ItemDto(item_task, "任务号", "DB101.W68")); + list.add(new ItemDto(item_out_seq_arr, "出库顺序数组", "DB101.W5")); + list.add(new ItemDto(item_out_qty_arr, "出库数量数组", "DB101.W6")); + list.add(new ItemDto(item_material1, "物料1", "DB101.W7")); + list.add(new ItemDto(item_qty1, "数量1", "DB101.W19")); + list.add(new ItemDto(item_material2, "物料2", "DB101.W8")); + list.add(new ItemDto(item_qty2, "数量2", "DB101.W20")); + list.add(new ItemDto(item_material3, "物料3", "DB101.W9")); + list.add(new ItemDto(item_qty3, "数量3", "DB101.W21")); + list.add(new ItemDto(item_material4, "物料4", "DB101.W10")); + list.add(new ItemDto(item_qty4, "数量4", "DB101.W22")); + list.add(new ItemDto(item_material5, "物料5", "DB101.W11")); + list.add(new ItemDto(item_qty5, "数量5", "DB101.W23")); + list.add(new ItemDto(item_material6, "物料6", "DB101.W12")); + list.add(new ItemDto(item_qty6, "数量6", "DB101.W24")); + list.add(new ItemDto(item_material7, "物料7", "DB101.W13")); + list.add(new ItemDto(item_qty7, "数量7", "DB101.W25")); + list.add(new ItemDto(item_material8, "物料8", "DB101.W14")); + list.add(new ItemDto(item_qty8, "数量8", "DB101.W26")); + list.add(new ItemDto(item_material9, "物料9", "DB101.W15")); + list.add(new ItemDto(item_qty9, "数量9", "DB101.W27")); + list.add(new ItemDto(item_material10, "物料10", "DB101.W16")); + list.add(new ItemDto(item_qty10, "数量10", "DB101.W28")); + list.add(new ItemDto(item_material11, "物料11", "DB101.W17")); + list.add(new ItemDto(item_qty11, "数量11", "DB101.W29")); + list.add(new ItemDto(item_material12, "物料12", "DB101.W18")); + list.add(new ItemDto(item_qty12, "数量12", "DB101.W30")); return list; } @@ -213,7 +296,19 @@ public class ItemProtocol { ArrayList list = new ArrayList(); list.add(new ItemDto(item_to_target , "下发仓位号", "DB102.W2")); list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4")); - + list.add(new ItemDto(item_to_task, "下发任务号", "DB102.W1")); + list.add(new ItemDto(item_to_material1, "下发物料1", "DB102.W3")); + list.add(new ItemDto(item_to_out_qty1, "下发物料1数量", "DB102.W7")); + list.add(new ItemDto(item_to_seq1, "出库顺序1", "DB102.W10")); + list.add(new ItemDto(item_to_position1, "仓位1", "DB102.W13")); + list.add(new ItemDto(item_to_material2, "下发物料2", "DB102.W5")); + list.add(new ItemDto(item_to_out_qty2, "下发物料2数量", "DB102.W8")); + list.add(new ItemDto(item_to_seq2, "出库顺序2", "DB102.W11")); + list.add(new ItemDto(item_to_position2, "仓位2", "DB102.W14")); + list.add(new ItemDto(item_to_material3, "下发物料3", "DB102.W6")); + list.add(new ItemDto(item_to_out_qty3, "下发物料3数量", "DB102.W9")); + list.add(new ItemDto(item_to_seq3, "出库顺序3", "DB102.W12")); + list.add(new ItemDto(item_to_position3, "仓位3", "DB102.W15")); return list; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java index 276a66c8f..8bee5865e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java @@ -1,6 +1,12 @@ package org.nl.acs.device_driver.basedriver.paper_tube_device2; +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.json.JSON; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -11,24 +17,29 @@ 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.ApplyPaperActionRequest; +import org.nl.acs.ext.wms.data.ApplyPaperActionResponse; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.dto.DeviceErrorLogDto; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; 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.util.SpringContextHolder; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 纸管库 @@ -56,19 +67,57 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); @Autowired AgvService agvService = SpringContextHolder.getBean(AgvService.class); + @Autowired + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + private Date instruction_update_time = new Date(); + private Date require_apply_strangulation_time = new Date(); + private int instruction_update_time_out = 500; private Date instruction_require_time = new Date(); private Date instruction_finished_time = new Date(); private Date instruction_apply_time = new Date(); private int instruction_require_time_out = 3000; + //心跳 int heartbeat = 0; + int last_heartbeat = 0; + //工作模式 int mode = 0; - int inventory_qty =0; - int out_finish =0; - int error =0; - int to_command =0; - int to_target =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 inventory_qty = 0; + int out_finish = 0; + //下发命令 + int to_command = 0; + int last_to_command = 0; + //下发目标站 + int to_target = 0; + int last_to_target = 0; + //下发任务号 + int to_task = 0; + int last_to_task = 0; + + String item_out_seq_arr = null; + List item_out_seq_arr1 = null; + String last_item_out_seq_arr = null; + int[] item_out_qty_arr = null; + int[] last_item_out_qty_arr = null; + + //当前指令 + Instruction inst = null; + String material = null; Boolean isonline = true; @@ -78,13 +127,16 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl //1-执行任务;2-取货完成;3-放货完成; int flag; - int last_mode = 0; - int last_inventory_qty =0; - int last_out_finish =0; - int last_error = 0; - String last_material = null; + int last_inventory_qty = 0; + int last_out_finish = 0; + + String last_material = null; + String message = null; String device_code; + String task_code = null; + String vehicle_code; + String inst_message; @Override public Device getDevice() { @@ -96,57 +148,125 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl @Override public void execute() { - String message = null; + try { + String message = null; + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getHeartbeat(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + carrier_direction = this.itemProtocol.getCarrier_direction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTotarget(); + to_task = this.itemProtocol.getTo_task(); + //item_out_seq_arr1 = this.itemProtocol.getItem_out_seq_arr1(); + item_out_seq_arr = this.itemProtocol.getItem_out_seq_arr(); + item_out_qty_arr = this.itemProtocol.getItem_out_qty_arr(); - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getHeartbeat(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTotarget(); - if (mode != last_mode) { - this.setRequireSucess(false); - if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - } else { - this.setIsonline(true); + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); } - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (inventory_qty != last_inventory_qty) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号inventory_qty:" + last_inventory_qty + "->" + inventory_qty); - } - if (out_finish != last_out_finish) { - if(out_finish == 1){ - this.writing(0); - this.writing("to_target","0"); - this.writing("to_out_qty","0"); - + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); } - logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); - } - if (!StrUtil.equals(material,last_material)) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号material:" + last_material + "->" + material); - } - if (error != last_error) { - if(error > 0){ - this.setIserror(true); - } else { - if(error > 0){ - this.setIserror(false); + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + + if (mode != last_mode) { + JSONObject param = new JSONObject(); + param.put("device_code", this.device_code); + param.put("mode", Math.min(mode, 3)); + param.put("device_name", this.getDevice().getDevice_name()); + param.put("device_type", "1"); + param.put("product_area", paramService.findByCode("productArea").getValue()); + acsToWmsService.sendDeviceStatus(param); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + 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) { + if (error != 0) { + DeviceErrorLogDto dto = new DeviceErrorLogDto(); + dto.setDevice_code(device_code); + dto.setError_code(String.valueOf(error)); + String errorInfo = ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)); + dto.setError_info(errorInfo); + deviceErrorLogService.create(dto); } + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); } - logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); + 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) { + update_instruction_status(); + } + + } catch (Exception var17) { + var17.printStackTrace(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); } + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //纸管库申请任务 + switch (mode) { + case 1: + log.debug("弃用(留作兼容)"); + break; + case 2: + //申请任务 + if (move > 0 && !requireSucess) { + instruction_require(); + } + break; + case 3: + log.info("运行中"); + break; + case 4: + //申请出货 + if (move == 1 && !requireSucess) { + request_for_shipment(String.valueOf(mode), item_out_seq_arr, item_out_qty_arr); + } + break; + } + } + last_heartbeat = heartbeat; last_mode = mode; - last_inventory_qty = inventory_qty; - last_out_finish = out_finish; last_error = error; - last_material = material; + last_carrier_direction = carrier_direction; + last_task = task; + last_to_command = to_command; + last_to_target = to_target; + last_to_task = to_task; + last_item_out_seq_arr = item_out_seq_arr; + last_item_out_qty_arr = item_out_qty_arr; + } @@ -160,7 +280,6 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl public void writing(List list) { - Map itemMap = new HashMap(); for (int i = 0; i < list.size(); i++) { Object ob = list.get(i); @@ -176,28 +295,240 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl this.checkcontrol(itemMap); } catch (Exception e) { e.printStackTrace(); - try{ + try { this.checkcontrol(itemMap); - } catch (Exception e1){ + } catch (Exception e1) { e1.printStackTrace(); } } } + + public void writing(Map map) { + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map itemMap = new LinkedHashMap<>(); + map.forEach((key, value) -> { + if (ObjectUtil.isNotEmpty(value)) { + itemMap.put(getToParam() + key, value); + } + }); + if (ObjectUtil.isNotEmpty(itemMap)) { + this.control(itemMap); + logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); + } + } + + + public synchronized void request_for_shipment(String mode, String item_out_seq_arr, int[] item_out_qty_arr) { + 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); + } else { + this.require_apply_strangulation_time = date; + ApplyPaperActionRequest applyPaperActionRequest = new ApplyPaperActionRequest(); + applyPaperActionRequest.setDevice_code(this.device_code); + applyPaperActionRequest.setType("1"); + applyPaperActionRequest.setTask_code(String.valueOf(task)); + //获取出库顺序 + boolean contains = item_out_seq_arr.contains(","); + //String s = item_out_seq_arr.replaceAll("[\\[\\]]", ""); + if (contains) { + String[] split = item_out_seq_arr.split(","); + applyPaperActionRequest.setMaterial1(split[0]); + applyPaperActionRequest.setMaterial2(split[1]); + } else { + applyPaperActionRequest.setMaterial1(item_out_seq_arr); + } + /*if (item_out_qty_arr.length == 2) { + // 去除方括号 + applyPaperActionRequest.setMaterial1(String.valueOf(item_out_qty_arr[0])); + applyPaperActionRequest.setMaterial2(String.valueOf(item_out_qty_arr[1])); + } else if (item_out_qty_arr.length == 1) { + applyPaperActionRequest.setMaterial1(String.valueOf(item_out_qty_arr[0])); + }*/ + if (item_out_qty_arr.length >= 1 && item_out_qty_arr.length < 4) { + applyPaperActionRequest.setQty1(String.valueOf(item_out_qty_arr[0])); + applyPaperActionRequest.setQty2(String.valueOf(item_out_qty_arr[1])); + } + ApplyPaperActionResponse applyPaperActionResponse = acsToWmsService.applyPaperActionRequest(applyPaperActionRequest); + Map map3 = new HashMap(); + if (applyPaperActionResponse.getstatus() == 200) { + map3.put("to_command", "4"); + this.writing(map3); + requireSucess = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyPaperActionResponse); + message = "申请出货成功"; + } else { + message = applyPaperActionResponse.getMessage(); + map3.put("to_command", "5"); + this.writing(map3); + requireSucess = false; + message = "出库顺序错误"; + logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyPaperActionResponse); + } + } + } + + + /** + * 申请任务 + */ + 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; + //查找有没有对应的指令 + //找指令类型是10的 + Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); + if (ObjectUtil.isNull(inst)) { + return false; + } + if (ObjectUtil.isNotNull(inst) && "10".equals(inst.getInstruction_code())) { + Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + TaskDto taskDto = taskserver.findByCodeFromCache(inst.getTask_code()); + List paperArray = getPaperArray(taskDto.getPaper_array()); + if (ObjectUtil.isEmpty(inst)) { + return false; + } + Map map = new HashMap(); + if (paperArray.size() == 1) { + writeStatus(paperArray, map, 1); + } else if (paperArray.size() == 2) { + writeStatus(paperArray, map, 1); + writeStatus(paperArray, map, 2); + } else if (paperArray.size() == 3) { + writeStatus(paperArray, map, 1); + writeStatus(paperArray, map, 2); + writeStatus(paperArray, map, 3); + } + writeData(next_addr, inst, map); + this.writing(map); + requireSucess = true; + return true; + } else { + //判断是否有相同起点的,任务状态就绪的任务 + //任务类型是10 + TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); + if (ObjectUtil.isNull(taskdto)) { + return false; + } + List paperArray = getPaperArray(taskdto.getPaper_array()); + if (ObjectUtil.isNotNull(taskdto) && "10".equals(taskdto.getTask_type())) { + //判断指令的起点和当前的设备号相同 + if (!taskdto.getStart_device_code().equals(device_code)) { + return false; + } + //判断当前任务号是否存在指令 + Instruction inst1 = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); + Device nextdevice = deviceAppservice.findDeviceByCode(inst1.getNext_device_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + Device pointdevice = deviceAppservice.findDeviceByCode(inst1.getNext_point_code()); + String point_addr = pointdevice.getExtraValue().get("address").toString(); + //没有就创建指令 + String taskid = taskdto.getTask_id(); + String taskcode = taskdto.getTask_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(); + + 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); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_addr); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(point_addr); + 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; + Map map = new HashMap(); + if (paperArray.size() == 1) { + writeStatus(paperArray, map, 1); + } else if (paperArray.size() == 2) { + writeStatus(paperArray, map, 1); + writeStatus(paperArray, map, 2); + } else if (paperArray.size() == 3) { + writeStatus(paperArray, map, 1); + writeStatus(paperArray, map, 2); + writeStatus(paperArray, map, 3); + } + writeData(next_addr, instdto, map); + this.writing(map); + requireSucess = true; + return true; + } + //并且指令的起点和当前的设备号相同 + //找到就要下发数据 + //查找就绪状态的任务 + //并且任务的起点和当前的设备号相同 + //找到创建指令 + //入库顺序 + } + return false; + } + } + + public void writeData(String next_addr, Instruction instdto, Map map) { + map.put("to_target", next_addr); + map.put("to_task", instdto.getInstruction_code()); + map.put("to_command", "1"); + } + + public String getToParam() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + public void writeStatus(List paperArray, Map map, Integer status) { + Paper paper = paperArray.get(status); + map.put("to_material" + status, paper.getMeterial_code()); + map.put("to_out_qty" + status, paper.getQty()); + map.put("to_seq" + status, "1"); + map.put("to_position" + status, paper.getDevice_code()); + } + + public void writing(String key, String param) { 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); + //Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); itemMap.put(to_param, Integer.parseInt(param)); -// 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 + ",下发电气值:" + param); } + public synchronized boolean finish_instruction() throws Exception { + instructionService.finish(inst); + return true; + } + @Override public JSONObject getDeviceStatusName() { JSONObject jo = new JSONObject(); @@ -225,6 +556,65 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl return jo; } + /** + * 解析出库的顺序 + */ + public List getPaperArray(String paper_array) { + JSONArray jsonArray = JSONUtil.parseArray(paper_array); + List papers = jsonArray.toList(Paper.class); + return papers; + } + + + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + inst = checkInst(); + if (inst != null) { + //a点到b点,给状态说允许取货 + 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); + } + //当货物到达b点,实现完成指令 + if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0")) { + if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { + inst.setExecute_device_code(this.device_code); + finish_instruction(); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); + } + } + } + } + } + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } + + @Override public void setDeviceStatus(JSONObject data) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java index 04f4baedb..157d4f3f1 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java @@ -81,6 +81,11 @@ public interface OpcDeviceDriver extends DeviceDriver { return (String) this.getOpcValueAccessor().getValue(this.getItem(protocol)); } + default List getArrayValue(String protocol) { + return (List) this.getOpcValueAccessor().getValue(this.getItem(protocol)); + } + + default Object getValue(String protocol) { return this.getOpcValueAccessor().getValue(this.getItem(protocol)); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 8fab0c4a7..57d5fff79 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -98,6 +98,13 @@ public interface AcsToWmsService { */ ApplyLabelingAndBindingResponse applyLabelingAndBindingRequest(ApplyLabelingAndBindingRequest param); + /** + * 申请出纸管,套纸管 + * @param param + * @return + */ + ApplyPaperActionResponse applyPaperActionRequest(ApplyPaperActionRequest param); + LiKuApplyTakResponse liKuApplyTaskRequest(LiKuApplyTaskRequest liKuApplyTaskRequest); UpdateLKTaskResponse updateLKTaskRequest(UpdateLKTaskRequest updateLKTaskRequest); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 69a717c7f..00c9ec05f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -444,10 +444,42 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } finally { MDC.remove(log_file_type); } - - } + @Override + public ApplyPaperActionResponse applyPaperActionRequest(ApplyPaperActionRequest param) { + try { + MDC.put(log_file_type, log_type); + ApplyPaperActionResponse applyPaperActionResponse = new ApplyPaperActionResponse(); + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("applyPaperAction"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + log.info("ApplyPaperActionRequest----请求参数{}", param); + try { +// String result = ""; + String result = HttpRequest.post(url) + .body(JSON.toJSONString(param)) + .execute().body(); + JSONObject jsonObject = JSONObject.parseObject(result); + log.info("ApplyPaperActionResponse----返回参数{}", result); + applyPaperActionResponse = JSONObject.toJavaObject(jsonObject, ApplyPaperActionResponse.class); + } catch (Exception e) { + JSONObject map = new JSONObject(); + map.put("status", 400); + map.put("message", e.getMessage()); + return JSONObject.toJavaObject(map, ApplyPaperActionResponse.class); + } + } + return applyPaperActionResponse; + } finally { + MDC.remove(log_file_type); + } + } + + + @Override public LiKuApplyTakResponse liKuApplyTaskRequest(LiKuApplyTaskRequest param) { try { 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 e23b40625..0792a31cc 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 @@ -1186,6 +1186,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return null; } + /** + * 根据任务号查询任务 + * @param task_code + * @return + */ public TaskDto findByCodeFromCache(String task_code) { Iterator var3 = tasks.iterator(); 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 7a0351aed..acaab12ad 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -1,5 +1,5 @@ server: - port: 8010 + port: 8011 tomcat: accept-count: 1000 max-connections: 10000 diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index 8ccbaac84..f18b4a266 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -100,6 +100,8 @@ import photoelectric_inspection_site from '@/views/acs/device/driver/photoelectr import standard_autodoor from '@/views/acs/device/driver/standard_autodoor' import lamp_three_color from '@/views/acs/device/driver/lamp_three_color' import paper_tube_conveyor from '@/views/acs/device/driver/paper_tube_conveyor' +import paper_tube_conveyor2 from '@/views/acs/device/driver/paper_tube_conveyor2' +import casing_station from '@/views/acs/device/driver/casing_station' import device_status from '@/views/acs/device/driver/device_status' export default { @@ -132,7 +134,9 @@ export default { standard_autodoor, lamp_three_color, paper_tube_conveyor, - device_status + device_status, + paper_tube_conveyor2, + casing_station }, dicts: ['device_type'], mixins: [crud], From 4d53aaaf4e9adb04d7a1205c5b95a1a4b5d90314 Mon Sep 17 00:00:00 2001 From: yanps Date: Tue, 7 Nov 2023 10:57:10 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E7=BA=B8=E7=AE=A1=E5=BA=93=E5=92=8C?= =?UTF-8?q?=E5=A5=97=E7=AE=A1=E5=B7=A5=E4=BD=8D=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/device/driver/casing_station.vue | 500 ++++++++++++++++++ .../device/driver/paper_tube_conveyor2.vue | 500 ++++++++++++++++++ 2 files changed, 1000 insertions(+) create mode 100644 acs/nladmin-ui/src/views/acs/device/driver/casing_station.vue create mode 100644 acs/nladmin-ui/src/views/acs/device/driver/paper_tube_conveyor2.vue diff --git a/acs/nladmin-ui/src/views/acs/device/driver/casing_station.vue b/acs/nladmin-ui/src/views/acs/device/driver/casing_station.vue new file mode 100644 index 000000000..032907b97 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/casing_station.vue @@ -0,0 +1,500 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/paper_tube_conveyor2.vue b/acs/nladmin-ui/src/views/acs/device/driver/paper_tube_conveyor2.vue new file mode 100644 index 000000000..032907b97 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/paper_tube_conveyor2.vue @@ -0,0 +1,500 @@ + + + + + From d5c2a0bd3e2fff8b744a302965da60a1df5502d2 Mon Sep 17 00:00:00 2001 From: yanps Date: Tue, 7 Nov 2023 11:07:49 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=A5=97=E7=AE=A1=E5=B7=A5=E4=BD=8D?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CasingStationConveyorDeviceDriver.java | 408 ++++++++++++++++++ .../CasingStationDefination.java | 59 +++ .../casing_station/ItemProtocol.java | 125 ++++++ .../basedriver/paper_tube_device2/Paper.java | 19 + 4 files changed, 611 insertions(+) create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationConveyorDeviceDriver.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationDefination.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/ItemProtocol.java create mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/Paper.java diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationConveyorDeviceDriver.java new file mode 100644 index 000000000..48c33ca87 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationConveyorDeviceDriver.java @@ -0,0 +1,408 @@ +package org.nl.acs.device_driver.basedriver.casing_station; + +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 com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.server.AgvService; +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.ApplyPaperActionRequest; +import org.nl.acs.ext.wms.data.ApplyPaperActionResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.dto.DeviceErrorLogDto; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +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.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; + +/** + * 套管工位 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class CasingStationConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); + @Autowired + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + @Autowired + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); + @Autowired + AgvService agvService = SpringContextHolder.getBean(AgvService.class); + @Autowired + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + private Date instruction_update_time = new Date(); + private Date require_apply_casing_time = new Date(); + private int instruction_update_time_out = 500; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + private Date instruction_apply_time = new Date(); + private int instruction_require_time_out = 3000; + + //心跳 + int heartbeat = 0; + int last_heartbeat = 0; + //工作模式 + 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; + + String material1 = null; + String last_material1 = null; + + String material2 = null; + String last_material2 = null; + + + //下发命令 + int to_command = 0; + int last_to_command = 0; + + //当前指令 + Instruction inst = null; + + Boolean isonline = true; + + Boolean iserror = false; + //请求成功标记 + Boolean requireSucess = false; + + String message = null; + String device_code; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + try { + String message = null; + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getHeartbeat(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + carrier_direction = this.itemProtocol.getCarrier_direction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + material1 = this.itemProtocol.getMaterial1(); + material2 = this.itemProtocol.getMaterial2(); + + to_command = this.itemProtocol.getTo_command(); + + + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (!material1.equals(last_material1)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material1:" + last_material1 + "->" + material1); + } + if (!material2.equals(last_material2)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material2:" + last_material2 + "->" + material2); + } + + 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 (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + if (error != last_error) { + if (error != 0) { + DeviceErrorLogDto dto = new DeviceErrorLogDto(); + dto.setDevice_code(device_code); + dto.setError_code(String.valueOf(error)); + String errorInfo = ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)); + dto.setError_info(errorInfo); + deviceErrorLogService.create(dto); + } + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (mode != last_mode) { + JSONObject param = new JSONObject(); + param.put("device_code", this.device_code); + param.put("mode", Math.min(mode, 3)); + param.put("device_name", this.getDevice().getDevice_name()); + param.put("device_type", "1"); + param.put("product_area", paramService.findByCode("productArea").getValue()); + acsToWmsService.sendDeviceStatus(param); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + + if (move != 0 && task > 1) { + update_instruction_status(); + } + + } catch (Exception var17) { + var17.printStackTrace(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //纸管库申请任务 + switch (mode) { + case 1: + log.debug("弃用(留作兼容)"); + break; + case 2: + //申请任务 + /*if (move > 0 && !requireSucess) { + instruction_require(); + }*/ + break; + case 3: + log.info("运行中"); + break; + default: + if (move == 1 && !requireSucess) { + //申请套管校验 + apply_for_casing_inspection(material1, material2); + } + break; + } + } + last_heartbeat = heartbeat; + last_mode = mode; + last_move = move; + last_error = error; + last_carrier_direction = carrier_direction; + last_task = task; + last_material1 = material1; + last_material2 = material2; + last_to_command = to_command; + } + + + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + inst = checkInst(); + if (inst != null) { + 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") || StrUtil.equals(inst.getInstruction_status(), "0")) { + if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { + inst.setExecute_device_code(this.device_code); + finish_instruction(); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); + } + } + } + } + } + + /** + * 申请套管校验 + */ + public synchronized void apply_for_casing_inspection(String material1, String material2) { + Date date = new Date(); + if (date.getTime() - this.require_apply_casing_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + } else { + this.require_apply_casing_time = date; + ApplyPaperActionRequest applyPaperActionRequest = new ApplyPaperActionRequest(); + applyPaperActionRequest.setDevice_code(this.device_code); + applyPaperActionRequest.setType("2"); + applyPaperActionRequest.setTask_code(String.valueOf(task)); + //获取出库顺序 + applyPaperActionRequest.setMaterial1(material1); + applyPaperActionRequest.setMaterial2(material2); + ApplyPaperActionResponse applyPaperActionResponse = acsToWmsService.applyPaperActionRequest(applyPaperActionRequest); + Map map = new HashMap(); + if (applyPaperActionResponse.getstatus() == 200) { + map.put("code", "to_command"); + map.put("value", "4"); + this.writing(map); + requireSucess = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请套管,返回参数:" + applyPaperActionResponse); + message = "申请套管成功"; + } else { + message = applyPaperActionResponse.getMessage(); + map.put("code", "to_command"); + map.put("value", "5"); + this.writing(map); + requireSucess = false; + message = "纸管不匹配"; + logServer.deviceExecuteLog(this.device_code, "", "", "申请套管,返回参数:" + applyPaperActionResponse); + } + } + } + + + /** + * 申请任务 + */ + public synchronized void 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; + } else { + //没有就绪状态的任务,查询就绪状态的指令 + TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); + Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); + if (ObjectUtil.isNull(taskdto) && ObjectUtil.isNotNull(inst)) { + + } + } + } + + /** + * 完成指令 + * + * @return + * @throws Exception + */ + public synchronized boolean finish_instruction() throws Exception { + instructionService.finish(inst); + return true; + } + + @Override + public JSONObject getDeviceStatusName() throws Exception { + return null; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } + + public void writing(List list) { + 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); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try { + this.checkcontrol(itemMap); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + public void writing(Map map) { + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map itemMap = new LinkedHashMap<>(); + map.forEach((key, value) -> { + if (ObjectUtil.isNotEmpty(value)) { + itemMap.put(getToParam() + key, value); + } + }); + if (ObjectUtil.isNotEmpty(itemMap)) { + this.control(itemMap); + logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); + } + } + + public String getToParam() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationDefination.java new file mode 100644 index 000000000..158e279d5 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationDefination.java @@ -0,0 +1,59 @@ +package org.nl.acs.device_driver.basedriver.casing_station; + +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 CasingStationDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "casing_station"; + } + + @Override + public String getDriverName() { + return "套管工位"; + } + + @Override + public String getDriverDescription() { + return "套管工位"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new CasingStationConveyorDeviceDriver().setDevice(device).setDriverDefination(this)); + } + + @Override + public Class getDeviceDriverType() { + return CasingStationConveyorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + 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/casing_station/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/ItemProtocol.java new file mode 100644 index 000000000..feb67bc19 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/ItemProtocol.java @@ -0,0 +1,125 @@ +package org.nl.acs.device_driver.basedriver.casing_station; + +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"; + //物料1 + public static String item_material1 = "material1"; + //物料2 + public static String item_material2 = "material2"; + + //下发命令 + public static String item_to_command = "to_command"; + + public ItemProtocol(CasingStationConveyorDeviceDriver 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); + } + + public String getMaterial1() { + return this.getOpcStringValue(item_material1); + } + + public String getMaterial2() { + return this.getOpcStringValue(item_material2); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + Boolean isonline; + + private CasingStationConveyorDeviceDriver driver; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isBlank(value)) { + + } else { + return value; + } + return "0"; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB101.W0")); + list.add(new ItemDto(item_mode, "工作模式", "DB101.W2")); + list.add(new ItemDto(item_move, "光电信号", "DB101.W3")); + list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.W4")); + list.add(new ItemDto(item_error, "报警", "DB101.W58")); + list.add(new ItemDto(item_task, "任务号", "DB101.W6")); + list.add(new ItemDto(item_material1, "物料1", "DB101.W7")); + list.add(new ItemDto(item_material2, "物料1", "DB101.W8")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4")); + return list; + } + + @Override + public String toString() { + return ""; + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/Paper.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/Paper.java new file mode 100644 index 000000000..e088a576e --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/Paper.java @@ -0,0 +1,19 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Paper implements Serializable { + //设备号 + private String device_code; + // + private String meterial_code; + private String qty; + +}