diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java index 37e474ec..d9348af8 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java @@ -49,4 +49,18 @@ public class AcsToWmsController { public ResponseEntity orderFinish(@RequestBody String string) { return new ResponseEntity<>(acsToWmsService.orderFinish(string), HttpStatus.OK); } + + @PostMapping("/feedDeviceStatusType") + @Log("向wms反馈设备状态") + @ApiOperation("向wms反馈设备状态") + public ResponseEntity feedDeviceStatusType(@RequestBody String string) { + return new ResponseEntity<>(acsToWmsService.feedDeviceStatusType(string), HttpStatus.OK); + } + + @PostMapping("/feedOrderRealQty") + @Log("向wms反订单实施数量") + @ApiOperation("向wms反订单实施数量") + public ResponseEntity feedOrderRealQty(@RequestBody String string) { + return new ResponseEntity<>(acsToWmsService.feedOrderRealQty(string), HttpStatus.OK); + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java index f3193a18..f16ec30c 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java @@ -39,4 +39,18 @@ public interface AcsToWmsService { * @return */ Map orderFinish(String string); + + /** + * ACS给WMS反馈设备状态状态 + * @param string + * @return + */ + Map feedDeviceStatusType(String string); + + /** + * ACS给WMS反馈订单实时数量 + * @param string + * @return + */ + Map feedOrderRealQty(String string); } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index 62453868..f26f76f4 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -2,6 +2,7 @@ package org.nl.wms.ext.acs.service.impl; import cn.hutool.core.date.DateUtil; import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -132,22 +133,74 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { public Map orderFinish(String string) { JSONObject orderJson = JSONObject.parseObject(string); String ext_order_id = orderJson.getString("ext_order_id"); - // JSONArray array = JSONArray.parseArray(string); + // JSONArray array = JSONArray.parseArray(string); String now = DateUtil.now(); WQLObject wo = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder"); JSONObject map = new JSONObject(); - map.put("produceorder_id",ext_order_id); - map.put("order_status","04"); + map.put("produceorder_id", ext_order_id); + map.put("order_status", "04"); map.put("update_optid", 1111111111); map.put("device_id", ""); map.put("update_optname", "acs"); map.put("update_time", now); map.put("realproduceend_date", now); - wo.update(map,"produceorder_id = '"+ext_order_id+"'"); + wo.update(map, "produceorder_id = '" + ext_order_id + "'"); JSONObject result = new JSONObject(); result.put("status", HttpStatus.OK.value()); result.put("message", "任务状态反馈成功!"); return result; } + @Override + public Map feedDeviceStatusType(String string) { + JSONObject param = JSONObject.parseObject(string); + String device_code = param.getString("device_code"); + String status_type = param.getString("status_type"); + String start_time = param.getString("start_time"); + Integer error_code = Integer.parseInt(param.getString("error_code")); + WQLObject wo = WQLObject.getWQLObject("pdm_bi_device"); + JSONObject device_json = wo.query("is_delete = '0' and is_active = '1' and device_code = '" + device_code + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(device_json)) { + String device_id = device_json.getString("device_id"); + WQLObject wo_status = WQLObject.getWQLObject("PDM_BI_DeviceRunStatusRecord"); + JSONObject status_json = wo_status.query("device_id = '" + device_id + "' and (end_time is null or end_time = '' )").uniqueResult(0); + if (ObjectUtil.isNotEmpty(status_json)){ + status_json.put("end_time", start_time); + wo_status.update(status_json); + } + JSONObject map = new JSONObject(); + map.put("record_id", IdUtil.getSnowflake(1, 1).nextId()); + map.put("device_id", device_id); + map.put("status_type", status_type); + map.put("start_time", start_time); + if (error_code > 0 && error_code < 50){ + map.put("err_status_id",error_code); + } else if (error_code > 50){ + map.put("err_status_id", error_code - 50); + } else { + map.put("err_status_id", null); + } + wo_status.insert(map); + } + JSONObject result = new JSONObject(); + result.put("status", HttpStatus.OK.value()); + result.put("message", "设备状态反馈成功"); + return result; + } + + @Override + public Map feedOrderRealQty(String string) { + JSONObject param = JSONObject.parseObject(string); + String order_code = param.getString("order"); + String real_qty = param.getString("real_qty"); + WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder"); + JSONObject map = new JSONObject(); + map.put("real_qty",real_qty); + wo.update(map,"produceorder_code = '"+order_code+"'"); + JSONObject result = new JSONObject(); + result.put("status", HttpStatus.OK.value()); + result.put("message", "设备状态反馈成功"); + return result; + } + } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/bigScreen/service/impl/ProductServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/bigScreen/service/impl/ProductServiceImpl.java index ebb82d35..7781d1bf 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/bigScreen/service/impl/ProductServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/ext/bigScreen/service/impl/ProductServiceImpl.java @@ -18,44 +18,42 @@ import java.util.Map; @RequiredArgsConstructor @Slf4j public class ProductServiceImpl implements ProductService { - private String now = DateUtil.now(); - private String today = DateUtil.today(); - //一个月的开始日期 - private String beginOfMonth = DateUtil.formatTime(DateUtil.beginOfMonth(DateUtil.parseDate(today))); @Override public Map planReached(Map param) { + String today = DateUtil.today(); //计算当天的计划达成 //01-弯头工段、02-综合工段、03-成品工段 Map map = new HashMap(); map.put("flag", "1"); map.put("produce_date", today); - map.put("worksection_type_scode","01"); + map.put("worksection_type_scode", "01"); JSONObject jo1 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0); - map.put("worksection_type_scode","02"); + map.put("worksection_type_scode", "02"); JSONObject jo2 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0); - map.put("worksection_type_scode","03"); + map.put("worksection_type_scode", "03"); JSONObject jo3 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0); JSONObject dayResult = new JSONObject(); - dayResult.put("jo1",jo1); - dayResult.put("jo2",jo2); - dayResult.put("jo3",jo3); + dayResult.put("jo1", jo1); + dayResult.put("jo2", jo2); + dayResult.put("jo3", jo3); //计算一个月的计划达成 + String beginOfMonth = DateUtil.formatTime(DateUtil.beginOfMonth(DateUtil.parseDate(today))); JSONObject monthResult = new JSONObject(); map.put("flag", "14"); map.put("end_produce_date", today); map.put("begin_produce_date", beginOfMonth); - map.put("worksection_type_scode","01"); + map.put("worksection_type_scode", "01"); JSONObject joo1 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0); - map.put("worksection_type_scode","02"); + map.put("worksection_type_scode", "02"); JSONObject joo2 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0); - map.put("worksection_type_scode","03"); + map.put("worksection_type_scode", "03"); JSONObject joo3 = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0); - monthResult.put("joo1",joo1); - monthResult.put("joo2",joo2); - monthResult.put("joo3",joo3); + monthResult.put("joo1", joo1); + monthResult.put("joo2", joo2); + monthResult.put("joo3", joo3); JSONObject returnjo = new JSONObject(); returnjo.put("code", "1"); returnjo.put("desc", "操作成功!"); @@ -66,6 +64,7 @@ public class ProductServiceImpl implements ProductService { @Override public Map productSchedule(Map param) { + String today = DateUtil.today(); //今日排产生产进度跟踪 Map map = new HashMap(); map.put("flag", "2"); @@ -81,6 +80,7 @@ public class ProductServiceImpl implements ProductService { @Override public Map output(Map param) { JSONObject result = new JSONObject(); + String today = DateUtil.today(); Map map = new HashMap(); // map.put("flag", "3"); map.put("flag", "7"); @@ -99,7 +99,7 @@ public class ProductServiceImpl implements ProductService { map.put("flag", "4"); int sum_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("count"); //统计延时工单 - map.put("product_date",today); + map.put("product_date", today); map.put("flag", "5"); int delayed_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("count"); @@ -121,13 +121,14 @@ public class ProductServiceImpl implements ProductService { //获取一周的日期 JSONArray dataArr = new JSONArray(); JSONArray results = new JSONArray(); + String now = DateUtil.now(); for (int i = 0; i < 7; i++) { DateTime dateTime = DateUtil.offsetDay(DateUtil.parse(now), -i); dataArr.add(dateTime.toString().substring(0, 10)); } for (int i = 0; i < dataArr.size(); i++) { JSONObject jo = new JSONObject(); - String date = dataArr.get(( dataArr.size()-i-1)).toString(); + String date = dataArr.get((dataArr.size() - i - 1)).toString(); //01-弯头工段、02-综合工段、03-成品工段 Map map = new HashMap(); @@ -142,7 +143,7 @@ public class ProductServiceImpl implements ProductService { map.put("worksection_type_scode", "03"); int end_product_qty = WQL.getWO("BIGSCREENPRODUCT").addParamMap(map).process().uniqueResult(0).getIntValue("real_qty"); jo.put("end_product_qty", end_product_qty); - jo.put("date",date.substring(5,date.length())); + jo.put("date", date.substring(5, date.length())); results.add(jo); } JSONObject returnjo = new JSONObject(); @@ -154,6 +155,7 @@ public class ProductServiceImpl implements ProductService { @Override public Map topHarvest(Map param) { + String today = DateUtil.today(); //今日Top10产量 Map map = new HashMap(); map.put("flag", "10"); @@ -169,6 +171,7 @@ public class ProductServiceImpl implements ProductService { @Override public Map monthHarvest(Map param) { //30天产量走势 + String now = DateUtil.now(); JSONArray dataArr = new JSONArray(); JSONArray results = new JSONArray(); for (int i = 0; i < 30; i++) { @@ -177,7 +180,7 @@ public class ProductServiceImpl implements ProductService { } for (int i = 0; i < dataArr.size(); i++) { JSONObject jo = new JSONObject(); - String date = dataArr.get(dataArr.size()-i-1).toString(); + String date = dataArr.get(dataArr.size() - i - 1).toString(); Map map = new HashMap(); map.put("flag", "9"); @@ -188,7 +191,7 @@ public class ProductServiceImpl implements ProductService { real_qty = jsonObject.getIntValue("real_qty"); } jo.put("real_qty", real_qty); - jo.put("date", date.substring(5,date.length())); + jo.put("date", date.substring(5, date.length())); results.add(jo); } JSONObject returnjo = new JSONObject(); @@ -200,6 +203,7 @@ public class ProductServiceImpl implements ProductService { @Override public Map unfinishOrder(Map param) { + String today = DateUtil.today(); Map map = new HashMap(); map.put("flag", "11"); map.put("produce_date", today); @@ -214,6 +218,9 @@ public class ProductServiceImpl implements ProductService { @Override public Map monthOrder(Map param) { //计算前9种物料产能 + String today = DateUtil.today(); + String beginOfMonth = DateUtil.formatTime(DateUtil.beginOfMonth(DateUtil.parseDate(today))); + Map map = new HashMap(); map.put("flag", "12"); map.put("produce_date", today); @@ -230,14 +237,15 @@ public class ProductServiceImpl implements ProductService { for (int i = 0; i < results.size(); i++) { count_num_flag = count_num_flag + results.getJSONObject(i).getIntValue("real_qty"); } + if (count_num_flag < sum_count) { + JSONObject joo = new JSONObject(); + joo.put("material_name", "其他"); + joo.put("material_spec", "其他"); + joo.put("real_qty", sum_count - count_num_flag); + results.add(joo); + } } - if (count_num_flag < sum_count) { - JSONObject joo = new JSONObject(); - joo.put("material_name", "其他"); - joo.put("material_spec", "其他"); - joo.put("real_qty", sum_count - count_num_flag); - results.add(joo); - } + JSONObject returnjo = new JSONObject(); returnjo.put("code", "1"); returnjo.put("desc", "操作成功!"); diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangElevatorWiringDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangElevatorWiringDevice.java new file mode 100644 index 00000000..e41fce37 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangElevatorWiringDevice.java @@ -0,0 +1,52 @@ +package org.nl.acs.common; + +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring.HailiangElevatorWiringDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache.HailiangEngravingCacheDeviceDriver; +import org.nl.acs.opc.Device; +import org.nl.acs.stage.service.utils.StageActorUtil; +import org.springframework.stereotype.Service; + +@Service("hailiang_elevator_wiring") +public class HailiangElevatorWiringDevice extends AbstractDriverService { + + @Override + public JSONObject getDeviceInfo(Device device) { + HailiangElevatorWiringDeviceDriver hailiangElevatorWiringDeviceDriver = (HailiangElevatorWiringDeviceDriver) device.getDeviceDriver(); + JSONObject jo = super.getCommonDeviceInfo(hailiangElevatorWiringDeviceDriver); + + String mode = ""; + String move = ""; + String action = ""; + if (hailiangElevatorWiringDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (hailiangElevatorWiringDeviceDriver.getMode() == 2) { + mode = "待机"; + } else if (hailiangElevatorWiringDeviceDriver.getMode() == 3) { + mode = "运行中"; + } + if (hailiangElevatorWiringDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (hailiangElevatorWiringDeviceDriver.getMove() == 1) { + move = "有货"; + } + if (hailiangElevatorWiringDeviceDriver.getAction() == 0) { + action = "禁止取放"; + } else if (hailiangElevatorWiringDeviceDriver.getAction() == 1) { + action = "允许取货"; + } else if (hailiangElevatorWiringDeviceDriver.getAction() == 2) { + action = "允许放货"; + } else if (hailiangElevatorWiringDeviceDriver.getAction() == 3) { + action = "允许取放"; + } + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("hasGoods", hailiangElevatorWiringDeviceDriver.getHasGoods()); + jo.put("isOnline", hailiangElevatorWiringDeviceDriver.getIsonline()); + jo.put("error", hailiangElevatorWiringDeviceDriver.getError()); + jo.put("isError", hailiangElevatorWiringDeviceDriver.getIserror()); + jo.put("message", hailiangElevatorWiringDeviceDriver.getMessage()); + return jo; + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangFoldingDiscSmartDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangFoldingDiscSmartDevice.java new file mode 100644 index 00000000..3eb4c3cf --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangFoldingDiscSmartDevice.java @@ -0,0 +1,41 @@ +package org.nl.acs.common; + +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring.HailiangElevatorWiringDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart.HailiangFoldingDiscSmartDeviceDriver; +import org.nl.acs.opc.Device; +import org.springframework.stereotype.Service; + +@Service("hailiang_foldingDisc_smart") +public class HailiangFoldingDiscSmartDevice extends AbstractDriverService { + + @Override + public JSONObject getDeviceInfo(Device device) { + HailiangFoldingDiscSmartDeviceDriver hailiangFoldingDiscSmartDeviceDriver = (HailiangFoldingDiscSmartDeviceDriver) device.getDeviceDriver(); + JSONObject jo = super.getCommonDeviceInfo(hailiangFoldingDiscSmartDeviceDriver); + + String mode = ""; + String move = ""; + + if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 2) { + mode = "待机"; + } + if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 1) { + move = "有货"; + } + jo.put("mode", mode); + jo.put("move", move); + jo.put("number", hailiangFoldingDiscSmartDeviceDriver.getNumber()); + jo.put("container_type", hailiangFoldingDiscSmartDeviceDriver.getContainer_type()); + jo.put("hasGoods", hailiangFoldingDiscSmartDeviceDriver.getHasGoods()); + jo.put("isOnline", hailiangFoldingDiscSmartDeviceDriver.getIsonline()); + jo.put("error", hailiangFoldingDiscSmartDeviceDriver.getError()); + jo.put("isError", hailiangFoldingDiscSmartDeviceDriver.getIserror()); + jo.put("message", hailiangFoldingDiscSmartDeviceDriver.getMessage()); + return jo; + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangPaintLineDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangPaintLineDevice.java new file mode 100644 index 00000000..300e5165 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangPaintLineDevice.java @@ -0,0 +1,60 @@ +package org.nl.acs.common; + +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_paint_line.HailiangPaintLineDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart.HailiangThreestationSmartDeviceDriver; +import org.nl.acs.opc.Device; +import org.springframework.stereotype.Service; + +@Service("hailiang_paint_line") +public class HailiangPaintLineDevice extends AbstractDriverService { + + @Override + public JSONObject getDeviceInfo(Device device) { + HailiangPaintLineDeviceDriver hailiangPaintLineDeviceDriver = (HailiangPaintLineDeviceDriver) device.getDeviceDriver(); + JSONObject jo = super.getCommonDeviceInfo(hailiangPaintLineDeviceDriver); + + String mode = ""; + String move = ""; + String action = ""; + if (hailiangPaintLineDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (hailiangPaintLineDeviceDriver.getMode() == 2) { + mode = "待机"; + } else if (hailiangPaintLineDeviceDriver.getMode() == 3) { + mode = "运行中"; + } else if (hailiangPaintLineDeviceDriver.getMode() == 5) { + mode = "下料位申请空盘"; + } else if (hailiangPaintLineDeviceDriver.getMode() == 6) { + mode = "下料位满拖申请"; + } else if (hailiangPaintLineDeviceDriver.getMode() == 7) { + mode = "上料位满拖申请"; + } else if (hailiangPaintLineDeviceDriver.getMode() == 8) { + mode = "上料位空托入库"; + } else if (hailiangPaintLineDeviceDriver.getMode() == 9) { + mode = "强制满垛入库请求"; + } + if (hailiangPaintLineDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (hailiangPaintLineDeviceDriver.getMove() == 1) { + move = "有货"; + } + if (hailiangPaintLineDeviceDriver.getAction() == 1) { + action = "允许取货"; + } else if (hailiangPaintLineDeviceDriver.getAction() == 2) { + action = "允许放货"; + } else if (hailiangPaintLineDeviceDriver.getAction() == 3) { + action = "允许取放"; + } + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("number", hailiangPaintLineDeviceDriver.getNumber()); + jo.put("hasGoods", hailiangPaintLineDeviceDriver.getHasGoods()); + jo.put("isOnline", hailiangPaintLineDeviceDriver.getIsonline()); + jo.put("error", hailiangPaintLineDeviceDriver.getError()); + jo.put("isError", hailiangPaintLineDeviceDriver.getIserror()); + jo.put("message", hailiangPaintLineDeviceDriver.getMessage()); + return jo; + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangThreestationSmartDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangThreestationSmartDevice.java new file mode 100644 index 00000000..5625b811 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangThreestationSmartDevice.java @@ -0,0 +1,55 @@ +package org.nl.acs.common; + +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring.HailiangElevatorWiringDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart.HailiangThreestationSmartDeviceDriver; +import org.nl.acs.opc.Device; +import org.springframework.stereotype.Service; + +@Service("hailiang_threestation_smart") +public class HailiangThreestationSmartDevice extends AbstractDriverService { + + @Override + public JSONObject getDeviceInfo(Device device) { + HailiangThreestationSmartDeviceDriver threestationSmartDeviceDriver = (HailiangThreestationSmartDeviceDriver) device.getDeviceDriver(); + JSONObject jo = super.getCommonDeviceInfo(threestationSmartDeviceDriver); + + String mode = ""; + String move = ""; + String action = ""; + if (threestationSmartDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (threestationSmartDeviceDriver.getMode() == 2) { + mode = "待机"; + } else if (threestationSmartDeviceDriver.getMode() == 3) { + mode = "运行中"; + } else if (threestationSmartDeviceDriver.getMode() == 4) { + mode = "申请空盘"; + } + if (threestationSmartDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (threestationSmartDeviceDriver.getMove() == 1) { + move = "有货"; + } + if (threestationSmartDeviceDriver.getAction() == 0) { + action = "禁止取放"; + } else if (threestationSmartDeviceDriver.getAction() == 1) { + action = "允许取货"; + } else if (threestationSmartDeviceDriver.getAction() == 2) { + action = "允许放货"; + } else if (threestationSmartDeviceDriver.getAction() == 3) { + action = "允许取放"; + } + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("number", threestationSmartDeviceDriver.getNumber()); + jo.put("container_type", threestationSmartDeviceDriver.getContainer_type()); + jo.put("hasGoods", threestationSmartDeviceDriver.getHasGoods()); + jo.put("isOnline", threestationSmartDeviceDriver.getIsonline()); + jo.put("error", threestationSmartDeviceDriver.getError()); + jo.put("isError", threestationSmartDeviceDriver.getIserror()); + jo.put("message", threestationSmartDeviceDriver.getMessage()); + return jo; + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 81925b28..5cbae371 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -63,9 +63,15 @@ public enum DriverTypeEnum { HAILIANG_XJ_PLC_TEST(27, "hailiang_xj_plc_test", "海亮-信捷PLC", "conveyor"), - HAILIANG_SMART_PLC_TEST(28, "hailiang_smart_plc_test", "海亮-西门子SMART200PLC", "conveyor"); + HAILIANG_SMART_PLC_TEST(28, "hailiang_smart_plc_test", "海亮-西门子SMART200PLC", "conveyor"), + HAILIANG_THREESTATION_SMART(29, "hailiang_threestation_smart", "海亮-三工位Smart200", "conveyor"), + HAILIANG_FOLDINGDISC_SMART(30, "hailiang_foldingDisc_smart", "海亮-叠盘位Smart200", "conveyor"), + + HAILIANG_ELEVATOR_WIRING(31, "hailiang_elevator_wiring", "海亮-货梯对接线", "conveyor"), + + HAILIANG_PAINT_LINE(32, "hailiang_paint_line", "海亮-油漆线", "conveyor"); //驱动索引 private int index; diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java index c973d9cb..857a9d8a 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java @@ -73,12 +73,12 @@ public class DeviceController { deviceService.downDeviceDBloadCSV(deviceService.queryDeviceProtocol(whereJson), response); } - @Log("导出欧姆龙设备协议CSV") - @ApiOperation("导出欧姆龙设备协议CSV") - @GetMapping(value = "/protocol/downloadoumulongCSV") + @Log("导出Smart设备协议CSV") + @ApiOperation("导出Smart设备协议CSV") + @GetMapping(value = "/protocol/downloadSmartCSV") //@PreAuthorize("@el.check('device:list')") public void downDeviceDBloadOumulongCSV(HttpServletResponse response, @RequestParam Map whereJson) throws IOException { - deviceService.downDeviceDBloadOumulongCSV(deviceService.queryDeviceProtocol(whereJson), response); + deviceService.downDeviceDBloadSmartCSV(deviceService.queryDeviceProtocol(whereJson), response); } @PostMapping diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java index ac201f58..8f37a03f 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java @@ -240,7 +240,7 @@ public interface DeviceService { void downDeviceDBloadCSV(JSONArray queryDeviceProtocol, HttpServletResponse response); - void downDeviceDBloadOumulongCSV(JSONArray queryDeviceProtocol, HttpServletResponse response); + void downDeviceDBloadSmartCSV(JSONArray queryDeviceProtocol, HttpServletResponse response); JSONArray selectDeviceListByType(String type); diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 79402867..45f1fb56 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -1455,7 +1455,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial } @Override - public void downDeviceDBloadOumulongCSV(JSONArray jsonarr, HttpServletResponse response) { + public void downDeviceDBloadSmartCSV(JSONArray jsonarr, HttpServletResponse response) { List cellList = new ArrayList<>(); for (int i = 0; i < jsonarr.size(); i++) { List item = new ArrayList(); @@ -1473,8 +1473,13 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial item.add(jo.get("extra_name")); String datatype = jo.getString("extra_name"); //西门子200 - if (datatype.indexOf(".") == -1) { - datatype = "Word"; + if (!datatype.contains(".")) { + String[] split = datatype.split(""); + if (split[1].equals("W")) { + datatype = "Word"; + } else if (split[1].equals("D")) { + datatype = "DWord"; + } } else { datatype = "Boolean"; } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDefination.java new file mode 100644 index 00000000..0c3534c7 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDefination.java @@ -0,0 +1,73 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring; + +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.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 海亮-货梯对接线 + */ +@Service +public class HailiangElevatorWiringDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hailiang_elevator_wiring"; + } + + @Override + public String getDriverName() { + return "海亮-货梯对接线"; + } + + @Override + public String getDriverDescription() { + return "海亮-货梯对接线"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HailiangElevatorWiringDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HailiangElevatorWiringDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "VW4")); + list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "VW6")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW8")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD10")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDeviceDriver.java new file mode 100644 index 00000000..aea7c06b --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDeviceDriver.java @@ -0,0 +1,252 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +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.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.LogServer; +import org.nl.acs.opc.Device; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.utils.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +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 HailiangElevatorWiringDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + LogServer logServer = SpringContextHolder.getBean(LogServer.class); + String container; + String container_type_desc; + String last_container_type_desc; + String last_container; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + + int mode = 0; + int error = 0; + int move = 0; + int task = 0; + int action = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + int last_action = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + boolean isFold = false; + private String assemble_check_tag; + + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + //备注 + String remark; + //物料 + String material; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //申请搬运任务 + private Boolean apply_handling = false; + //申请物料 + private Boolean apply_material = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + action = this.itemProtocol.getAction(); + move = this.itemProtocol.getMove(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); + logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); + logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move); + } + if (error != last_error) { + logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); + logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); + } + if (action != last_action) { + logServer.deviceLog(this.device_code,"action" ,String.valueOf(action)); + logServer.deviceLogToacs(this.device_code,"","","信号action:" + last_action + "->" + action); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + } + + switch (flag) { + //取货完成 + case 1: + writing(2); + return; + //放货完成 + case 2: + writing(3); + return; + + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + last_action = action; + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + + public boolean exe_business() { + return true; + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + + } + + public void writing(int type, int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_target; + String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_task; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + if (type == 1) { + itemMap.put(to_command, command); + } else if (type == 2) { + itemMap.put(to_target, command); + + } else if (type == 3) { + itemMap.put(to_task, command); + } + ReadUtil.write(itemMap, server); + + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/ItemProtocol.java new file mode 100644 index 00000000..1c7e841b --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/ItemProtocol.java @@ -0,0 +1,107 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring; + +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_action = "action"; + public static String item_error = "error"; + public static String item_task = "task"; + public static String item_to_command = "to_command"; + public static String item_to_target = "to_target"; + public static String item_to_task = "to_task"; + public static String item_weight = "weight"; + + private HailiangElevatorWiringDeviceDriver driver; + + public ItemProtocol(HailiangElevatorWiringDeviceDriver 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 getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getToTarget() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getToTask() { + return this.getOpcIntegerValue(item_to_task); + } + + //是否有货 + public int hasGoods(int move) { + return move; + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(item_move, "光电信号", "VW4")); + list.add(new ItemDto(item_action, "取放信号", "VW6")); + list.add(new ItemDto(item_error, "报警信号", "VW8")); + list.add(new ItemDto(item_task, "任务号", "VD10")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "VW102", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_target, "目标站", "VW104")); + list.add(new ItemDto(item_to_task, "任务号", "VD108")); + return list; + } + +} + diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/HailiangEngravingMachineDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/HailiangEngravingMachineDeviceDriver.java index b7b6b67d..64098a86 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/HailiangEngravingMachineDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/HailiangEngravingMachineDeviceDriver.java @@ -100,6 +100,7 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive int device_running_time = 0; //设备运转时间(S) int await_time = 0; //待机时间(S) int order = 0; //工单号 + int heartbeat = 0; //出入库模式 int operation_type = 0; @@ -125,6 +126,12 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive int last_device_running_time = 0; //设备运转时间(S) int last_await_time = 0; //待机时间(S) int last_order = 0; //工单号 + int last_heartbeat = 0; + + private long last_feedDeviceStatusTime = 0; + + int status_type = 0; + int last_status_type = 0; Boolean isonline = true; @@ -277,6 +284,10 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive if (one_now != last_one_now) { logServer.deviceLog(this.device_code,"one_now" ,String.valueOf(one_now)); logServer.deviceLogToacs(this.device_code,"","","信号one_now:" + last_one_now + "->" + one_now); + JSONObject map = new JSONObject(); + map.put("order",order); + map.put("real_qty",order_now); + acsToWmsService.feedOrderRealQty(map); } if (task != last_task) { logServer.deviceLog(this.device_code,"task" ,String.valueOf(task)); @@ -304,9 +315,36 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order); } - /* if (mode == 2 && move != 0 && task > 0) { + synchronized (this){ + long now_feedTime = System.currentTimeMillis(); + if (now_feedTime - last_feedDeviceStatusTime >= 10000){ + heartbeat = this.itemProtocol.getItem_heartbeat(); + if (heartbeat == last_heartbeat){ + status_type = 01; + } else { + status_type = 02; + if (error > 0) { + status_type = 05; + }else if (mode == 1 && order > 0) { + status_type = 03; + } else if (mode == 0 && order > 0) { + status_type = 04; + } + } + if (status_type != last_status_type) { + JSONObject map = new JSONObject(); + map.put("device_code", device_code); + map.put("status_type", "0" + status_type); + map.put("start_time", DateUtil.now()); + map.put("error_code",error); + acsToWmsService.feedDeviceStatusType(map); + last_status_type = status_type; + } + last_heartbeat = heartbeat; + last_feedDeviceStatusTime = now_feedTime; + } + } - }*/ } catch (Exception var17) { return; } @@ -475,6 +513,7 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive last_device_running_time = device_running_time; //设备运转时间(S) last_await_time = await_time; //待机时间(S) last_order = order; //工单号 + last_heartbeat = heartbeat; } public boolean exe_error() { diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDefination.java new file mode 100644 index 00000000..53ecc5c8 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDefination.java @@ -0,0 +1,74 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart; + +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.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 海亮-叠盘位Smart200 + */ +@Service +public class HailiangFoldingDiscSmartDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hailiang_foldingDisc_smart"; + } + + @Override + public String getDriverName() { + return "海亮-叠盘位Smart200"; + } + + @Override + public String getDriverDescription() { + return "海亮-叠盘位Smart200"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HailiangFoldingDiscSmartDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HailiangFoldingDiscSmartDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "VW4")); + list.add(new ItemDto(ItemProtocol.item_number, "数量", "VW6")); + list.add(new ItemDto(ItemProtocol.item_container_type, "托盘类型", "VW8")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW10")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD12")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDeviceDriver.java new file mode 100644 index 00000000..e85a3368 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDeviceDriver.java @@ -0,0 +1,257 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +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.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.LogServer; +import org.nl.acs.opc.Device; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.utils.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 海亮-叠盘位Smart200 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HailiangFoldingDiscSmartDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + LogServer logServer = SpringContextHolder.getBean(LogServer.class); + + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + + int mode = 0; + int error = 0; + int move = 0; + int task = 0; + int number = 0; + int container_type = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + int last_number = 0; + int last_container_type = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + boolean isFold = false; + private String assemble_check_tag; + + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + //备注 + String remark; + //物料 + String material; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //申请搬运任务 + private Boolean apply_handling = false; + //申请物料 + private Boolean apply_material = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + number = this.itemProtocol.getNumber(); + move = this.itemProtocol.getMove(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + container_type = this.itemProtocol.getContainer_type(); + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); + logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); + logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move); + } + if (error != last_error) { + logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); + logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); + } + if (number != last_number) { + logServer.deviceLog(this.device_code,"number" ,String.valueOf(number)); + logServer.deviceLogToacs(this.device_code,"","","信号number:" + last_number + "->" + number); + } + if (container_type != last_container_type) { + logServer.deviceLog(this.device_code,"container_type" ,String.valueOf(container_type)); + logServer.deviceLogToacs(this.device_code,"","","信号container_type:" + last_container_type + "->" + container_type); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + } + + switch (flag) { + //取货完成 + case 1: + writing(2); + return; + //放货完成 + case 2: + writing(3); + return; + + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + last_number = number; + last_container_type = container_type; + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + + public boolean exe_business() { + return true; + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + + } + + public void writing(int type, int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_target; + String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_task; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + if (type == 1) { + itemMap.put(to_command, command); + } else if (type == 2) { + itemMap.put(to_target, command); + + } else if (type == 3) { + itemMap.put(to_task, command); + } + ReadUtil.write(itemMap, server); + + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/ItemProtocol.java new file mode 100644 index 00000000..64dd0920 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/ItemProtocol.java @@ -0,0 +1,113 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart; + +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_number = "number"; + public static String item_container_type = "container_type"; + public static String item_error = "error"; + public static String item_task = "task"; + public static String item_to_command = "to_command"; + public static String item_to_target = "to_target"; + public static String item_to_task = "to_task"; + public static String item_weight = "weight"; + + private HailiangFoldingDiscSmartDeviceDriver driver; + + public ItemProtocol(HailiangFoldingDiscSmartDeviceDriver 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 getNumber() { + return this.getOpcIntegerValue(item_number); + } + + public int getContainer_type() { + return this.getOpcIntegerValue(item_container_type); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getToTarget() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getToTask() { + return this.getOpcIntegerValue(item_to_task); + } + + //是否有货 + public int hasGoods(int move) { + return move; + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(item_move, "光电信号", "VW4")); + list.add(new ItemDto(item_number, "数量", "VW6")); + list.add(new ItemDto(item_container_type, "托盘类型", "VW8")); + list.add(new ItemDto(item_error, "报警信号", "VW10")); + list.add(new ItemDto(item_task, "任务号", "VD12")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "VW52", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_target, "目标站", "VW54")); + list.add(new ItemDto(item_to_task, "任务号", "VD58")); + return list; + } + +} + diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/HailiangPackerStationDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/HailiangPackerStationDeviceDriver.java index 828d6630..5a84b27c 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/HailiangPackerStationDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/HailiangPackerStationDeviceDriver.java @@ -77,6 +77,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i String container; + int heartbeat = 0; int packer_ready = 0;//包装机就绪 int mode = 0;//模式 所有设备就绪 int move = 0;//有货 @@ -92,6 +93,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i int await_time = 0; //待机时间(S) int order = 0; //工单号 //出入库模式 + int last_heartbeat = 0; int operation_type = 0; int last_packer_ready = 0;//包装机就绪 int last_mode = 0;//模式 所有设备就绪 @@ -117,6 +119,11 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i private Date instruction_finished_time = new Date(); private Date instruction_apply_time = new Date(); private int instruction_require_time_out = 3000; + + + private long last_feedDeviceStatusTime = 0; + private long feedDeviceStatusTime = System.currentTimeMillis(); + //请求成功标记 Boolean requireSucess = false; Boolean fullrequireSucess = false; @@ -126,6 +133,9 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i private int instruction_finished_time_out; + int status_type = 0; + int last_status_type = 0; + int branchProtocol = 0; //备注 String remark; @@ -191,7 +201,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i logServer.deviceLog(this.device_code, "packer_ready", String.valueOf(packer_ready)); logServer.deviceLogToacs(this.device_code, "", "", "信号packer_ready:" + last_packer_ready + "->" + packer_ready); } - if (lack_req != last_lack_req) { + if (lack_req != last_lack_req) { if (lack_req == 0) { this.setRequireSucess(false); } @@ -226,6 +236,11 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i if (order_now != last_order_now) { logServer.deviceLog(this.device_code, "order_now", String.valueOf(order_now)); logServer.deviceLogToacs(this.device_code, "", "", "信号order_now:" + last_order_now + "->" + order_now); + JSONObject map = new JSONObject(); + map.put("order",order); + map.put("real_qty",order_now); + acsToWmsService.feedOrderRealQty(map); + System.out.println(device_code + "当前数量:" + order_now); } /* if (open_ready_time != last_open_ready_time) { @@ -245,9 +260,36 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i logServer.deviceLogToacs(this.device_code, "", "", "信号order:" + last_order + "->" + order); } - /* if (mode == 2 && move != 0 && task > 0) { + synchronized (this){ + long now_feedTime = System.currentTimeMillis(); + if (now_feedTime - last_feedDeviceStatusTime >= 10000){ + heartbeat = this.itemProtocol.getItem_heartbeat(); + if (heartbeat == last_heartbeat){ + status_type = 01; + } else { + status_type = 02; + if (error > 0) { + status_type = 05; + }else if (mode == 1 && order > 0) { + status_type = 03; + } else if (mode == 0 && order > 0) { + status_type = 04; + } + } + if (status_type != last_status_type) { + JSONObject map = new JSONObject(); + map.put("device_code", device_code); + map.put("status_type", "0" + status_type); + map.put("error_code",error); + map.put("start_time", DateUtil.now()); + acsToWmsService.feedDeviceStatusType(map); + last_status_type = status_type; + } + last_heartbeat = heartbeat; + last_feedDeviceStatusTime = now_feedTime; + } + } - }*/ } catch (Exception var17) { return; } @@ -306,7 +348,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i apply_task(); } } - if (!fullrequireSucess){ + if (!fullrequireSucess) { if (mode == 1 && req_task_empty == 1 && move == 1) { logServer.deviceLogToacs(this.device_code, "", "", device_code + ":,move:" + move + ",mode:" + mode + ",fullrequireSucess:" + fullrequireSucess + "开始申请请求取走空料斗任务"); apply_take_empty_task(); @@ -712,4 +754,9 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i public synchronized boolean apply_InEmpty() throws Exception { return false; } + + @Override + public String toString() { + return ""; + } } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/ItemProtocol.java index 8107c58c..4e2010a7 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/ItemProtocol.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/ItemProtocol.java @@ -167,5 +167,9 @@ public class ItemProtocol { return list; } + @Override + public String toString() { + return "ItemProtocol{}"; + } } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/HailiangPaintLineDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/HailiangPaintLineDefination.java new file mode 100644 index 00000000..3be39726 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/HailiangPaintLineDefination.java @@ -0,0 +1,74 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_paint_line; + +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.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 海亮-油漆线 + */ +@Service +public class HailiangPaintLineDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hailiang_paint_line"; + } + + @Override + public String getDriverName() { + return "海亮-油漆线"; + } + + @Override + public String getDriverDescription() { + return "海亮-油漆线"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HailiangPaintLineDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HailiangPaintLineDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "DB600.B3")); + list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B4")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); + list.add(new ItemDto(ItemProtocol.item_number, "数量", "DB600.B7")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/HailiangPaintLineDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/HailiangPaintLineDeviceDriver.java new file mode 100644 index 00000000..2e172188 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/HailiangPaintLineDeviceDriver.java @@ -0,0 +1,257 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_paint_line; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +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.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.LogServer; +import org.nl.acs.opc.Device; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.utils.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +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 HailiangPaintLineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + LogServer logServer = SpringContextHolder.getBean(LogServer.class); + + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + + int mode = 0; + int error = 0; + int move = 0; + int task = 0; + int action = 0; + int number = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + int last_action = 0; + int last_number = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + boolean isFold = false; + private String assemble_check_tag; + + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + //备注 + String remark; + //物料 + String material; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //申请搬运任务 + private Boolean apply_handling = false; + //申请物料 + private Boolean apply_material = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + action = this.itemProtocol.getAction(); + move = this.itemProtocol.getMove(); + number = this.itemProtocol.getNumber(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); + logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); + logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move); + } + if (error != last_error) { + logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); + logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); + } + if (action != last_action) { + logServer.deviceLog(this.device_code,"action" ,String.valueOf(action)); + logServer.deviceLogToacs(this.device_code,"","","信号action:" + last_action + "->" + action); + } + if (number != last_number) { + logServer.deviceLog(this.device_code,"number" ,String.valueOf(number)); + logServer.deviceLogToacs(this.device_code,"","","信号number:" + last_number + "->" + number); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + } + + switch (flag) { + //取货完成 + case 1: + writing(2); + return; + //放货完成 + case 2: + writing(3); + return; + + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + last_action = action; + last_number = number; + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + + public boolean exe_business() { + return true; + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + + } + + public void writing(int type, int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_target; + String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_task; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + if (type == 1) { + itemMap.put(to_command, command); + } else if (type == 2) { + itemMap.put(to_target, command); + + } else if (type == 3) { + itemMap.put(to_task, command); + } + ReadUtil.write(itemMap, server); + + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/ItemProtocol.java new file mode 100644 index 00000000..6bbb6308 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_paint_line/ItemProtocol.java @@ -0,0 +1,113 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_paint_line; + +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_action = "action"; + public static String item_error = "error"; + public static String item_number = "number"; + public static String item_task = "task"; + public static String item_to_command = "to_command"; + public static String item_to_target = "to_target"; + public static String item_to_task = "to_task"; + public static String item_weight = "weight"; + + private HailiangPaintLineDeviceDriver driver; + + public ItemProtocol(HailiangPaintLineDeviceDriver 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 getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getNumber() { + return this.getOpcIntegerValue(item_number); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getToTarget() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getToTask() { + return this.getOpcIntegerValue(item_to_task); + } + + //是否有货 + public int hasGoods(int move) { + return move; + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); + list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); + list.add(new ItemDto(item_move, "光电信号", "DB600.B3")); + list.add(new ItemDto(item_action, "取放信号", "DB600.B4")); + list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); + list.add(new ItemDto(item_number, "数量", "DB600.B7")); + list.add(new ItemDto(item_task, "任务号", "DB600.D8")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); + list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); + return list; + } + +} + diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/HailiangSpecialDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/HailiangSpecialDeviceDriver.java index 0efa50ad..d668e1e0 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/HailiangSpecialDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/HailiangSpecialDeviceDriver.java @@ -136,6 +136,12 @@ public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver impleme int last_line_ready = 0; //线体就绪 int last_device_online = 0; //专机联机 + int heartbeat = 0; + int last_heartbeat = 0; + private long last_feedDeviceStatusTime = 0; + int status_type = 0; + int last_status_type = 0; + Boolean isonline = true; int hasGoods = 0; String message = null; @@ -227,6 +233,7 @@ public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver impleme device_ready = this.itemProtocol.getItem_device_ready(); line_ready = this.itemProtocol.getItem_line_ready(); + if (mode != last_mode) { this.setRequireSucess(false); logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess); @@ -305,6 +312,11 @@ public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver impleme if (now_order_prod_num != last_now_order_prod_num) { logServer.deviceLog(this.device_code,"now_order_prod_num" ,String.valueOf(now_order_prod_num)); logServer.deviceLogToacs(this.device_code,"","","信号now_order_prod_num:" + last_now_order_prod_num + "->" + now_order_prod_num); + JSONObject map = new JSONObject(); + map.put("order",order); + map.put("real_qty",now_order_prod_num); + acsToWmsService.feedOrderRealQty(map); + System.out.println(device_code + "当前数量:" + now_order_prod_num); } if (full_number != last_full_number) { logServer.deviceLog(this.device_code,"full_number" ,String.valueOf(full_number)); @@ -338,10 +350,36 @@ public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver impleme logServer.deviceLog(this.device_code,"order_prod_allnum" ,String.valueOf(order_prod_allnum)); logServer.deviceLogToacs(this.device_code,"","","信号order_prod_allnum:" + last_order_prod_allnum + "->" + order_prod_allnum); } + synchronized (this){ + long now_feedTime = System.currentTimeMillis(); + if (now_feedTime - last_feedDeviceStatusTime >= 10000){ + heartbeat = this.itemProtocol.getHeartbeat(); + if (heartbeat == last_heartbeat){ + status_type = 01; + } else { + status_type = 02; + if (error > 0) { + status_type = 05; + }else if (mode == 1 && order > 0) { + status_type = 03; + } else if (mode == 0 && order > 0) { + status_type = 04; + } + } + if (status_type != last_status_type) { + JSONObject map = new JSONObject(); + map.put("device_code", device_code); + map.put("status_type", "0" + status_type); + map.put("start_time", DateUtil.now()); + map.put("error_code",error); + acsToWmsService.feedDeviceStatusType(map); + last_status_type = status_type; + } + last_feedDeviceStatusTime = now_feedTime; + last_heartbeat = heartbeat; + } + } -/* if (mode == 2 && move != 0 && task > 0) { - - }*/ } catch (Exception var17) { return; } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDefination.java new file mode 100644 index 00000000..f9a28640 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDefination.java @@ -0,0 +1,75 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart; + +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.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 海亮-三工位Smart200 + */ +@Service +public class HailiangThreestationSmartDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hailiang_threestation_smart"; + } + + @Override + public String getDriverName() { + return "海亮-三工位Smart200"; + } + + @Override + public String getDriverDescription() { + return "海亮-三工位Smart200"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HailiangThreestationSmartDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HailiangThreestationSmartDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "VW4")); + list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "VW6")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW8")); + list.add(new ItemDto(ItemProtocol.item_number, "数量", "VW10")); + list.add(new ItemDto(ItemProtocol.item_container_type, "托盘类型", "VW12")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD14")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDeviceDriver.java new file mode 100644 index 00000000..695ef72c --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDeviceDriver.java @@ -0,0 +1,277 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +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.device.device_driver.standard_inspect.ReadUtil; +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.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.LogServer; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.opc.WcsConfig; +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.util.CodeUtil; +import org.nl.utils.SpringContextHolder; +import org.nl.wql.core.bean.WQLObject; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 海亮-三工位Smart200 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HailiangThreestationSmartDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + LogServer logServer = SpringContextHolder.getBean(LogServer.class); + String container_type_desc; + String last_container_type_desc; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + + int mode = 0; + int error = 0; + int move = 0; + int task = 0; + int action = 0; + int number = 0; + int container_type = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + int last_action = 0; + int last_number = 0; + int last_container_type = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + boolean isFold = false; + private String assemble_check_tag; + + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + //备注 + String remark; + //物料 + String material; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //申请搬运任务 + private Boolean apply_handling = false; + //申请物料 + private Boolean apply_material = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + action = this.itemProtocol.getAction(); + move = this.itemProtocol.getMove(); + number = this.itemProtocol.getNumber(); + container_type = this.itemProtocol.getContainer_type(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); + logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); + logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move); + } + if (error != last_error) { + logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); + logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); + } + if (action != last_action) { + logServer.deviceLog(this.device_code,"action" ,String.valueOf(action)); + logServer.deviceLogToacs(this.device_code,"","","信号action:" + last_action + "->" + action); + } + if (container_type != last_container_type) { + logServer.deviceLog(this.device_code,"container_type" ,String.valueOf(container_type)); + logServer.deviceLogToacs(this.device_code,"","","信号container_type:" + last_container_type + "->" + container_type); + } + if (number != last_number) { + logServer.deviceLog(this.device_code,"number" ,String.valueOf(number)); + logServer.deviceLogToacs(this.device_code,"","","信号number:" + last_number + "->" + number); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + } + + switch (flag) { + //取货完成 + case 1: + writing(2); + return; + //放货完成 + case 2: + writing(3); + return; + + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + last_action = action; + last_number = number; + last_container_type = container_type; + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + + public boolean exe_business() { + return true; + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + + } + + public void writing(int type, int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_target; + String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_task; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + if (type == 1) { + itemMap.put(to_command, command); + } else if (type == 2) { + itemMap.put(to_target, command); + + } else if (type == 3) { + itemMap.put(to_task, command); + } + ReadUtil.write(itemMap, server); + + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/ItemProtocol.java new file mode 100644 index 00000000..c7ad6d31 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/ItemProtocol.java @@ -0,0 +1,119 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart; + +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_action = "action"; + public static String item_error = "error"; + public static String item_number = "number"; + public static String item_container_type = "container_type"; + public static String item_task = "task"; + public static String item_to_command = "to_command"; + public static String item_to_target = "to_target"; + public static String item_to_task = "to_task"; + public static String item_weight = "weight"; + + private HailiangThreestationSmartDeviceDriver driver; + + public ItemProtocol(HailiangThreestationSmartDeviceDriver 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 getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getNumber() { + return this.getOpcIntegerValue(item_number); + } + + public int getContainer_type() { + return this.getOpcIntegerValue(item_container_type); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getToTarget() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getToTask() { + return this.getOpcIntegerValue(item_to_task); + } + + //是否有货 + public int hasGoods(int move) { + return move; + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(item_move, "光电信号", "VW4")); + list.add(new ItemDto(item_action, "取放信号", "VW6")); + list.add(new ItemDto(item_error, "报警信号", "VW8")); + list.add(new ItemDto(item_number, "数量", "VW10")); + list.add(new ItemDto(item_container_type, "托盘类型", "VW12")); + list.add(new ItemDto(item_task, "任务号", "VD14")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "VW102", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_target, "目标站", "VW104")); + list.add(new ItemDto(item_to_task, "任务号", "VD108")); + return list; + } + +} + diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java index 635dda4e..d0c7c49e 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java @@ -95,4 +95,18 @@ public class AcsToWmsController { public ResponseEntity applyOutCacheLineTask(@RequestBody JSONObject param) { return new ResponseEntity<>(acstowmsService.applyOutCacheLineTask(param), HttpStatus.OK); } + + @PostMapping("/feedDeviceStatusType") + @Log("向wms反馈设备状态") + @ApiOperation("向wms反馈设备状态") + public ResponseEntity feedDeviceStatusType(@RequestBody JSONObject param) { + return new ResponseEntity<>(acstowmsService.feedDeviceStatusType(param), HttpStatus.OK); + } + + @PostMapping("/feedOrderRealQty") + @Log("向wms订单实时数量") + @ApiOperation("向wms订单实时数量") + public ResponseEntity feedOrderRealQty(@RequestBody JSONObject param) { + return new ResponseEntity<>(acstowmsService.feedOrderRealQty(param), HttpStatus.OK); + } } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 0f6361c7..8f95b8d1 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -116,4 +116,20 @@ public interface AcsToWmsService { * @return */ HttpResponse applyOutCacheLineTask(JSONObject param); + + /** + * 向wms反馈设备状态 + * + * @param param + * @return + */ + HttpResponse feedDeviceStatusType(JSONObject param); + + /** + * 向wms订单实时数量 + * + * @param param + * @return + */ + HttpResponse feedOrderRealQty(JSONObject param); } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 4ffa2ec2..ea9aad21 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -544,4 +544,68 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { return null; } + @Override + public HttpResponse feedDeviceStatusType(JSONObject param) { + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS).toString(), "1")) { + String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); + // TODO 还没向地址表中添加 feedDeviceStatusType + AddressDto addressDto = addressService.findByCode("feedDeviceStatusType"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + HttpResponse result = null; + log.info("feedbackOrderStatus----请求参数{}", param); + try { + result = HttpRequest.post(url) + .body(String.valueOf(param)) + .execute(); + String type = ""; + if (result.getStatus() == 200) { + type = "info"; + } else { + type = "error"; + } + logServer.log("", "feedDeviceStatusType", type, param.toString(), result.body(), String.valueOf(result.getStatus()), url, ""); + log.info("feedDeviceStatusType----返回参数{}", result); + } catch (Exception e) { + String msg = e.getMessage(); + //网络不通 + System.out.println(msg); + } + return result; + } + return null; + } + + @Override + public HttpResponse feedOrderRealQty(JSONObject param) { + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS).toString(), "1")) { + String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); + // TODO 还没向地址表中添加 feedDeviceStatusType + AddressDto addressDto = addressService.findByCode("feedOrderRealQty"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + HttpResponse result = null; + log.info("feedOrderRealQty----请求参数{}", param); + try { + result = HttpRequest.post(url) + .body(String.valueOf(param)) + .execute(); + String type = ""; + if (result.getStatus() == 200) { + type = "info"; + } else { + type = "error"; + } + logServer.log("", "feedOrderRealQty", type, param.toString(), result.body(), String.valueOf(result.getStatus()), url, ""); + log.info("feedOrderRealQty----返回参数{}", result); + } catch (Exception e) { + String msg = e.getMessage(); + //网络不通 + System.out.println(msg); + } + return result; + } + return null; + } + } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java index 4093cb03..33da0c4a 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java @@ -5,16 +5,13 @@ package org.nl.acs.order.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; -import org.nl.acs.config.AcsConfig; import org.nl.acs.device.service.DeviceExtraService; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine.HailiangEngravingMachineDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station.HailiangPackerStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_smart_plc_test.HailiangSmartplcTestDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device.HailiangSpecialDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; import org.nl.acs.order.service.ProduceshiftorderService; import org.nl.acs.order.service.dto.ProduceshiftorderDto; import org.nl.exception.BadRequestException; @@ -33,7 +30,6 @@ import javax.servlet.http.HttpServletResponse; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; -import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.nl.utils.SecurityUtils; diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java index 26422b5d..2561ad7f 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java @@ -22,14 +22,17 @@ import org.nl.acs.device_driver.basedriver.agv.utils.IAgv; import org.nl.acs.device_driver.basedriver.agv.utils.OneAgvPhase; import org.nl.acs.device_driver.basedriver.agv.utils.TwoAgvPhase; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station.HailiangCleaningMachineStorageStationDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring.HailiangElevatorWiringDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache.HailiangEngravingCacheDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine.HailiangEngravingMachineDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart.HailiangFoldingDiscSmartDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station.HailiangPackerStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device.HailiangSpecialDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_empty_station.HailiangSpecialEmptyStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_full_station.HailiangSpecialFullStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pick_station.HailiangSpecialPickStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart.HailiangThreestationSmartDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver; @@ -271,6 +274,7 @@ public class StageActorServiceImpl implements StageActorService { if (ObjectUtil.isNull(device)) { continue; } + if (ObjectUtil.isNotEmpty(device.getDeviceDriver())) { IDriverService driverService = applicationContext.getBean(device.getDeviceDriverDefination().getDriverCode(), IDriverService.class); obj.put("device_name", device.getDevice_name()); diff --git a/wcs/qd/src/views/acs/device/config.vue b/wcs/qd/src/views/acs/device/config.vue index 4480f3e2..bee59bfe 100644 --- a/wcs/qd/src/views/acs/device/config.vue +++ b/wcs/qd/src/views/acs/device/config.vue @@ -111,6 +111,10 @@ import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one' import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two' import hailiang_xj_plc_test from '@/views/acs/device/driver/hailiang_one/hailiang_xj_plc_test' import hailiang_smart_plc_test from '@/views/acs/device/driver/hailiang_one/hailiang_smart_plc_test' +import hailiang_threestation_smart from '@/views/acs/device/driver/hailiang_one/hailiang_threestation_smart' +import hailiang_foldingDisc_smart from '@/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart' +import hailiang_elevator_wiring from '@/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring' +import hailiang_paint_line from '@/views/acs/device/driver/hailiang_one/hailiang_paint_line' export default { name: 'DeviceConfig', @@ -122,7 +126,8 @@ export default { standard_photoelectric_inspect_site, agv_ndc_two, agv_ndc_one, hailiang_packer_station, hailiang_engraving_cache, hailiang_special_pick_station, hailiang_special_empty_station, hailiang_special_full_station, hailiang_special_pour_station, hailiang_special_device, hailiang_engraving_machine, hailiang_auto_cache_line, hailiang_cleaning_feeding_line, hailiang_cleaning_machine, hailiang_cleaning_machine_storage_station, - hailiang_xj_plc_test, hailiang_smart_plc_test }, + hailiang_xj_plc_test, hailiang_smart_plc_test, hailiang_threestation_smart, hailiang_foldingDisc_smart,hailiang_elevator_wiring, + hailiang_paint_line }, dicts: ['device_type'], mixins: [crud], data() { diff --git a/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring.vue b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring.vue new file mode 100644 index 00000000..9f1191a2 --- /dev/null +++ b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring.vue @@ -0,0 +1,487 @@ + + + + + diff --git a/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart.vue b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart.vue new file mode 100644 index 00000000..884c08fe --- /dev/null +++ b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart.vue @@ -0,0 +1,487 @@ + + + + + diff --git a/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_paint_line.vue b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_paint_line.vue new file mode 100644 index 00000000..015d6264 --- /dev/null +++ b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_paint_line.vue @@ -0,0 +1,487 @@ + + + + + diff --git a/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_threestation_smart.vue b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_threestation_smart.vue new file mode 100644 index 00000000..41d2800d --- /dev/null +++ b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_threestation_smart.vue @@ -0,0 +1,487 @@ + + + + + diff --git a/wcs/qd/src/views/acs/device/protocol/index.vue b/wcs/qd/src/views/acs/device/protocol/index.vue index b6e1ad0e..11f035cc 100644 --- a/wcs/qd/src/views/acs/device/protocol/index.vue +++ b/wcs/qd/src/views/acs/device/protocol/index.vue @@ -58,6 +58,17 @@ > 导出CSV + + 导出SMARTCSV + { + downloadFile(result, crud.title + '数据', 'csv') + this.downLoadcsvLoadingSmart = false + }).catch(() => { + this.downLoadcsvLoadingSmart = false + }) + }, // 钩子:在获取表格数据之前执行,false 则代表不获取数据 [CRUD.HOOK.beforeRefresh]() { return true