diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java index 107d062..bd2582b 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java @@ -14,7 +14,6 @@ import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.impl.DeviceServiceImpl; -import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; @@ -25,7 +24,6 @@ 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.DeviceType; import org.nl.acs.task.service.TaskService; import org.nl.exception.BadRequestException; import org.nl.start.auto.run.NDCSocketConnectionAutoRun; @@ -996,108 +994,17 @@ public class AgvServiceImpl implements AgvService { @Override public String requestOpenOrCloseDoor(String device, String param) { - log.info("AGV请求开关门参数,设备:{},参数:{}", device, param); - int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); - switch (type) { - case 4: - acsToWmsService.applyOpenOrCloseDoor(device, param); - break; - default: - StandardAutodoorDeviceDriver autodoor; - Device doordevice = deviceAppService.findDeviceByCode(device); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver(); - if (StrUtil.equals("open", param)) { - autodoor.OpenOrClose("1"); - log.info("下发开门请求"); - - } else if (StrUtil.equals("close", param)) { - autodoor.OpenOrClose("2"); - log.info("下发关门请求"); - } - } - break; - - } return null; } @Override public String queryDoorStatus(String device) { - log.info("AGV查询自动门状态,参数:{}", device); - int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); - switch (type) { - case 4: - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASOTHERSYSTEM).toString(), "1")) { - String result = acsToWmsService.queryDoorsStatus().body(); - JSONArray ja = JSONArray.parseArray(result); - log.info("AGV查询自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - } - return null; - default: - if (StrUtil.equals("doors", device)) { - List list = deviceAppService.findDevice(DeviceType.autodoor); - JSONArray ja = new JSONArray(); - for (int i = 0; i < list.size(); i++) { - Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code()); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - String mes = null; - StandardAutodoorDeviceDriver autodoor; - if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver(); - mes = autodoor.getStatus(); - } - JSONObject jo = JSONObject.parseObject(mes); - ja.add(jo); - } - log.info("AGV查询自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - - } else { - Device doordevice = deviceAppService.findDeviceByCode(device); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - String mes = null; - StandardAutodoorDeviceDriver autodoor; - if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver(); - mes = autodoor.getStatus(); - } - JSONObject jo = JSONObject.parseObject(mes); - log.info("AGV查询自动门状态,反馈:{}", jo.toString()); - return jo.toString(); - } - } + return null; } @Override public String queryAllDoorStatus() { - log.info("AGV查询全部自动门状态"); - List list = deviceAppService.findDevice(DeviceType.autodoor); - JSONArray ja = new JSONArray(); - for (int i = 0; i < list.size(); i++) { - Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code()); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - String mes = null; - StandardAutodoorDeviceDriver autodoor; - if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver(); - mes = autodoor.getStatus(); - } - JSONObject jo = JSONObject.parseObject(mes); - ja.add(jo); - } - log.info("AGV查询全部自动门状态,反馈:{}", ja.toString()); - return ja.toString(); + return null; } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/AgvNdcOneDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/AgvNdcOneDevice.java deleted file mode 100644 index 0a11a7a..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/AgvNdcOneDevice.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.service.StorageCellService; -import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; -import org.nl.acs.device_driver.basedriver.agv.utils.IAgv; -import org.nl.acs.device_driver.basedriver.agv.utils.OneAgvPhase; -import org.nl.acs.opc.Device; -import org.nl.acs.stage.service.utils.StageActorUtil; -import org.nl.utils.SpringContextHolder; -import org.springframework.stereotype.Service; - -/** - * @author geng by - * 单工agv - */ -@Service("agv_ndc_one") -@RequiredArgsConstructor -@Slf4j -public class AgvNdcOneDevice extends AbstractDriverService { - private final StorageCellService storageCellService; - @Override - public JSONObject getDeviceInfo(Device device) { - AgvNdcOneDeviceDriver agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); - IAgv oneAgv = SpringContextHolder.getBean(OneAgvPhase.class); - JSONObject jo = new JSONObject(); - jo.put("address", StageActorUtil.getAddress(storageCellService.findByAddress(agvNdcOneDeviceDriver.getAgvaddr_copy() + ""))); - jo.put("phaseName", oneAgv.getPhaseName(agvNdcOneDeviceDriver.getPhase())); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/AgvNdcTwoDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/AgvNdcTwoDevice.java deleted file mode 100644 index 7127e11..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/AgvNdcTwoDevice.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.service.StorageCellService; -import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver; -import org.nl.acs.device_driver.basedriver.agv.utils.IAgv; -import org.nl.acs.device_driver.basedriver.agv.utils.TwoAgvPhase; -import org.nl.acs.opc.Device; -import org.nl.acs.stage.service.utils.StageActorUtil; -import org.nl.utils.SpringContextHolder; -import org.springframework.stereotype.Service; -/** - * @author geng by - * 双工agv - */ -@Service("agv_ndc_two") -@RequiredArgsConstructor -@Slf4j -public class AgvNdcTwoDevice extends AbstractDriverService { - private final StorageCellService storageCellService; - @Override - public JSONObject getDeviceInfo(Device device) { - AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); - IAgv twoAgv = SpringContextHolder.getBean(TwoAgvPhase.class); - JSONObject jo = new JSONObject(); - jo.put("address", StageActorUtil.getAddress(storageCellService.findByAddress(agvNdcTwoDeviceDriver.getAgvaddr_copy() + ""))); - jo.put("phaseName",twoAgv.getPhaseName(agvNdcTwoDeviceDriver.getPhase())); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangCleaningMachineStorageDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangCleaningMachineStorageDevice.java deleted file mode 100644 index c20ec6b..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangCleaningMachineStorageDevice.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station.HailiangCleaningMachineStorageStationDeviceDriver; -import org.nl.acs.opc.Device; -import org.springframework.stereotype.Service; - -/** - * @author geng by - * 清洗机 - */ -@Service("hailiang_cleaning_machine_storage_station") -public class HailiangCleaningMachineStorageDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangCleaningMachineStorageStationDeviceDriver hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangCleaningMachineStorageStationDeviceDriver, 0); - jo.put("isError", hailiangCleaningMachineStorageStationDeviceDriver.getIserror()); - jo.put("error", hailiangCleaningMachineStorageStationDeviceDriver.getError()); - jo.put("weight", hailiangCleaningMachineStorageStationDeviceDriver.getSilo_weight()); - jo.put("qty", hailiangCleaningMachineStorageStationDeviceDriver.getFull_number()); - jo.put("material", hailiangCleaningMachineStorageStationDeviceDriver.getMaterial()); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangEngravingCacheDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangEngravingCacheDevice.java deleted file mode 100644 index def9e66..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangEngravingCacheDevice.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -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; -/** - * @author geng by - * 刻字缓存位 - */ -@Service("hailiang_engraving_cache") -public class HailiangEngravingCacheDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangEngravingCacheDeviceDriver hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangEngravingCacheDeviceDriver); - jo.put("move", StageActorUtil.getCacheMove(hailiangEngravingCacheDeviceDriver.getMove())); - jo.put("is_click", true); - jo.put("device_type",device.getDevice_type()); - jo.put("driver_type",device.getDeviceDriverDefination().getDriverCode()); - jo.put("material_type",device.getMaterial_type()); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangEngravingMachineDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangEngravingMachineDevice.java deleted file mode 100644 index bae8ec7..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangEngravingMachineDevice.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine.HailiangEngravingMachineDeviceDriver; -import org.nl.acs.opc.Device; -import org.nl.acs.stage.service.utils.StageActorUtil; -import org.springframework.stereotype.Service; -/** - * @author geng by - * 刻字机 - */ -@Service("hailiang_engraving_machine") -public class HailiangEngravingMachineDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangEngravingMachineDeviceDriver hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangEngravingMachineDeviceDriver); - jo.put("empty_req",StageActorUtil.getIsOrNo(hailiangEngravingMachineDeviceDriver.getEmpty_req())); - jo.put("full_req", StageActorUtil.getIsOrNo(hailiangEngravingMachineDeviceDriver.getFull_req())); - jo.put("error", hailiangEngravingMachineDeviceDriver.getError()); - jo.put("material_type", device.getMaterial_type()); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangPackerStationDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangPackerStationDevice.java deleted file mode 100644 index adcf708..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangPackerStationDevice.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station.HailiangPackerStationDeviceDriver; -import org.nl.acs.opc.Device; -import org.nl.acs.stage.service.utils.StageActorUtil; -import org.springframework.stereotype.Service; -/** - * @author geng by - * 包装机 - */ -@Service("hailiang_packer_station") -public class HailiangPackerStationDevice extends AbstractDriverService { - HailiangPackerStationDeviceDriver hailiangPackerStationDeviceDriver; - @Override - public JSONObject getDeviceInfo(Device device) { - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangPackerStationDeviceDriver); - jo.put("material_type",device.getMaterial_type()); - jo.put("lack_req", StageActorUtil.getIsOrNo(hailiangPackerStationDeviceDriver.getLack_req())); - jo.put("empty_req", StageActorUtil.getIsOrNo(hailiangPackerStationDeviceDriver.getReq_task_empty())); - jo.put("is_click", true); - jo.put("device_type",device.getDevice_type()); - Boolean requireSucess = hailiangPackerStationDeviceDriver.getRequireSucess(); - jo.put("requestSucess",StageActorUtil.getRequestSucess(requireSucess)); - jo.put("requireSucess",StageActorUtil.getRequireSucess(requireSucess)); - Boolean fullrequireSucess = hailiangPackerStationDeviceDriver.getFullrequireSucess(); - jo.put("fullrequestSucess",StageActorUtil.getRequestSucess(fullrequireSucess)); - jo.put("fullrequireSucess",StageActorUtil.getRequireSucess(fullrequireSucess)); - jo.put("driver_type",device.getDeviceDriverDefination().getDriverCode()); - return jo; - } - - @Override - public Integer getDbValue(Device device,String dbName){ - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - return super.getDbValue(hailiangPackerStationDeviceDriver,dbName); - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialDevice.java deleted file mode 100644 index 616c13c..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialDevice.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device.HailiangSpecialDeviceDriver; -import org.nl.acs.opc.Device; -import org.springframework.stereotype.Service; - -import java.util.Map; -/** - * @author geng by - * 专机 - */ -@Service("hailiang_special_device") -public class HailiangSpecialDevice extends AbstractDriverService{ - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangSpecialDeviceDriver hailiangSpecialDeviceDriver = (HailiangSpecialDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangSpecialDeviceDriver,0); - jo.put("isError", hailiangSpecialDeviceDriver.getIserror()); - jo.put("error", hailiangSpecialDeviceDriver.getError()); - jo.put("empty_is_lack", hailiangSpecialDeviceDriver.getEmpty_is_lack()); - jo.put("empty_is_finish", hailiangSpecialDeviceDriver.getEmpty_is_finish()); - jo.put("full_ready_req_agv", hailiangSpecialDeviceDriver.getFull_ready_req_agv()); - jo.put("full_out", hailiangSpecialDeviceDriver.getFull_out()); - jo.put("finish", hailiangSpecialDeviceDriver.getFinish()); - jo.put("order_compel_finish", hailiangSpecialDeviceDriver.getOrder_compel_finish()); - jo.put("now_order_prod_num", hailiangSpecialDeviceDriver.getNow_order_prod_num()); - jo.put("now_one_prod_num", hailiangSpecialDeviceDriver.getNow_one_box_num()); - jo.put("task", hailiangSpecialDeviceDriver.getTask()); - jo.put("full_number", hailiangSpecialDeviceDriver.getFull_number()); - jo.put("storage_stock_num", hailiangSpecialDeviceDriver.getStorage_stock_num()); - jo.put("line_stock_num", hailiangSpecialDeviceDriver.getLine_stock_num()); - jo.put("order_prod_allnum", hailiangSpecialDeviceDriver.getOrder_prod_allnum()); - jo.put("order", hailiangSpecialDeviceDriver.getOrder()); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialEmptyDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialEmptyDevice.java deleted file mode 100644 index 3ad6b47..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialEmptyDevice.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_empty_station.HailiangSpecialEmptyStationDeviceDriver; -import org.nl.acs.opc.Device; -import org.nl.acs.stage.service.utils.StageActorUtil; -import org.springframework.stereotype.Service; -/** - * @author geng by - * 空料口 - */ -@Service("hailiang_special_empty_station") -public class HailiangSpecialEmptyDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangSpecialEmptyStationDeviceDriver hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangSpecialEmptyStationDeviceDriver,0); - jo.put("move", StageActorUtil.getMove(hailiangSpecialEmptyStationDeviceDriver.getMove())); - jo.put("hasGoods", StageActorUtil.getHasGoods(hailiangSpecialEmptyStationDeviceDriver.getMove(),0)); - jo.put("isError", hailiangSpecialEmptyStationDeviceDriver.getIserror()); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialFullDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialFullDevice.java deleted file mode 100644 index 592ce2d..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialFullDevice.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_full_station.HailiangSpecialFullStationDeviceDriver; -import org.nl.acs.opc.Device; -import org.nl.acs.stage.service.utils.StageActorUtil; -import org.springframework.stereotype.Service; -/** - * @author geng by - * 满料口 - */ -@Service("hailiang_special_full_station") -public class HailiangSpecialFullDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangSpecialFullStationDeviceDriver hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangSpecialFullStationDeviceDriver); - jo.put("isError", hailiangSpecialFullStationDeviceDriver.getIserror()); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialPickDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialPickDevice.java deleted file mode 100644 index 08211b4..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialPickDevice.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pick_station.HailiangSpecialPickStationDeviceDriver; -import org.nl.acs.opc.Device; -import org.springframework.stereotype.Service; -/** - * @author geng by - * 接料口 - */ -@Service("hailiang_special_pick_station") -public class HailiangSpecialPickDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangSpecialPickStationDeviceDriver hailiangSpecialPickStationDeviceDriver = (HailiangSpecialPickStationDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangSpecialPickStationDeviceDriver, 0); - jo.put("isError", hailiangSpecialPickStationDeviceDriver.getIserror()); - jo.put("full_number", hailiangSpecialPickStationDeviceDriver.getFull_number()); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialPourDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialPourDevice.java deleted file mode 100644 index 2697c14..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangSpecialPourDevice.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver; -import org.nl.acs.opc.Device; -import org.springframework.stereotype.Service; - -/** - * @author geng by - * 倒料 - */ -@Service("hailiang_special_pour_station") -public class HailiangSpecialPourDevice extends AbstractDriverService { - - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangSpecialPourStationDeviceDriver hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangSpecialPourStationDeviceDriver,0); - jo.put("isError", hailiangSpecialPourStationDeviceDriver.getIserror()); - jo.put("full_number", hailiangSpecialPourStationDeviceDriver.getFull_number()); - jo.put("storage_stock_num", hailiangSpecialPourStationDeviceDriver.getStorage_stock_num()); - jo.put("line_stock_num", hailiangSpecialPourStationDeviceDriver.getLine_stock_num()); - return jo; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangxjplcDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangxjplcDevice.java deleted file mode 100644 index 542b232..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangxjplcDevice.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_xj_plc_test.HailiangHailiangxjplcTestDeviceDriver; -import org.nl.acs.opc.Device; -import org.springframework.stereotype.Service; - -/** - * @author geng by - * 海亮-海亮迅捷plc测试 - */ -@Service("hailiang_xj_plc_test") -public class HailiangxjplcDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - HailiangHailiangxjplcTestDeviceDriver hailiangHailiangxjplcTestDeviceDriver = (HailiangHailiangxjplcTestDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(hailiangHailiangxjplcTestDeviceDriver,0); - jo.put("heartbeat",hailiangHailiangxjplcTestDeviceDriver.getHeartbeat()); - jo.put("error",hailiangHailiangxjplcTestDeviceDriver.getError()); - jo.put("error_num",hailiangHailiangxjplcTestDeviceDriver.getError_num()); - jo.put("open_time",hailiangHailiangxjplcTestDeviceDriver.getOpen_time()); - jo.put("close_time",hailiangHailiangxjplcTestDeviceDriver.getClose_time()); - jo.put("ready_time",hailiangHailiangxjplcTestDeviceDriver.getReady_time()); - jo.put("running_time",hailiangHailiangxjplcTestDeviceDriver.getRunning_time()); - jo.put("error_time",hailiangHailiangxjplcTestDeviceDriver.getError_time()); - jo.put("voltage",hailiangHailiangxjplcTestDeviceDriver.getVoltage()); - jo.put("temperature",hailiangHailiangxjplcTestDeviceDriver.getTemperature()); - jo.put("current",hailiangHailiangxjplcTestDeviceDriver.getCurrent()); - jo.put("material",hailiangHailiangxjplcTestDeviceDriver.getMaterial()); - jo.put("lack_material",hailiangHailiangxjplcTestDeviceDriver.getLack_material()); - jo.put("full_material",hailiangHailiangxjplcTestDeviceDriver.getFull_material()); - jo.put("storage_qty",hailiangHailiangxjplcTestDeviceDriver.getStorage_qty()); - jo.put("feeding_qty",hailiangHailiangxjplcTestDeviceDriver.getFeeding_qty()); - jo.put("blanking_qty",hailiangHailiangxjplcTestDeviceDriver.getBlanking_qty()); - jo.put("qualified_qty",hailiangHailiangxjplcTestDeviceDriver.getQualified_qty()); - jo.put("unqualified_qty",hailiangHailiangxjplcTestDeviceDriver.getUnqualified_qty()); - jo.put("finish",hailiangHailiangxjplcTestDeviceDriver.getFinish()); - jo.put("task",hailiangHailiangxjplcTestDeviceDriver.getTask()); - jo.put("noload_electricity_consumption",hailiangHailiangxjplcTestDeviceDriver.getNoload_electricity_consumption()); - jo.put("prod_electricity_consumption",hailiangHailiangxjplcTestDeviceDriver.getProd_electricity_consumption()); - jo.put("gas_consumption",hailiangHailiangxjplcTestDeviceDriver.getGas_consumption()); - jo.put("water_consumption",hailiangHailiangxjplcTestDeviceDriver.getWater_consumption()); - jo.put("oil_level",hailiangHailiangxjplcTestDeviceDriver.getOil_level()); - jo.put("pause",hailiangHailiangxjplcTestDeviceDriver.getPause()); - jo.put("is_click",true); - jo.put("driver_type","hailiang_xj_plc_test"); - jo.put("monthly_electricity_consumption",hailiangHailiangxjplcTestDeviceDriver.getMonthly_electricity_consumption()); - 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 81925b2..2db1f62 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 @@ -13,57 +13,17 @@ public enum DriverTypeEnum { INSPECT_SITE(2, "standard_inspect_site", "检测站点", "conveyor"), - AUTODOOR(3, "standard_autodoor", "标准版-自动门", "autodoor"), + STORAGE(3, "standard_storage", "标准版-货架", "storage"), - LAMP_THREE_COLOR(4, "lamp_three_color", "标准版-三色灯", "三色灯"), + SCANNER(4, "standard_scanner", "标准版-扫码器", "scanner"), - STORAGE(5, "standard_storage", "标准版-货架", "storage"), + INSPECT_CONVEYOR_CONTROL_WITH_SCANNER(5, "standard_conveyor_control_with_scanner", "标准版-输送机-控制点-关联扫码", "conveyor"), - SCANNER(6, "standard_scanner", "标准版-扫码器", "scanner"), + INSPECT_CONVEYOR_CONTROL(6, "standard_conveyor_control", "标准版-输送机-控制点", "conveyor"), - INSPECT_CONVEYOR_CONTROL_WITH_SCANNER(7, "standard_conveyor_control_with_scanner", "标准版-输送机-控制点-关联扫码", "conveyor"), + INSPECT_CONVEYOR_MONITOR(7, "standard_conveyor_monitor", "标准版-输送机-监控点", "conveyor"), - INSPECT_CONVEYOR_CONTROL(8, "standard_conveyor_control", "标准版-输送机-控制点", "conveyor"), - - INSPECT_CONVEYOR_MONITOR(9, "standard_conveyor_monitor", "标准版-输送机-监控点", "conveyor"), - - HAILIANG_PACKING(10, "hailiang_packing", "海亮包装项目-包装机", "conveyor"), - - HAILIANG_LABELING(11, "hailiang_labeling", "海亮包装项目-贴标机", "conveyor"), - - HAILIANG_COATING(12, "hailiang_coating", "海亮包装项目-裹膜机", "conveyor"), - - HAILIANG_SPECIAL_EMPTY_STATION(13, "hailiang_special_empty_station", "海亮专机空料点", "conveyor"), - - HAILIANG_SPECIAL_PICK_STATION(14, "hailiang_special_pick_station", "海亮专机接料点", "conveyor"), - - HAILIANG_SPECIAL_FULL_STATION(15, "hailiang_special_full_station", "海亮专机满料点", "conveyor"), - - HAILIANG_SPECIAL_POUR_STATION(16, "hailiang_special_pour_station", "海亮专机倒料点", "conveyor"), - - HAILIANG_SPECIAL_DEVICE(17, "hailiang_special_device", "海亮专机设备", "conveyor"), - - HAILIANG_AUTO_CACHE_LINE(18, "hailiang_auto_cache_line", "海亮自动缓存线", "conveyor"), - - HAILIANG_ENGRAVING_MACHINE(19, "hailiang_engraving_machine", "海亮-激光刻字工位", "conveyor"), - - HAILIANG_CLEANING_MACHINE_STORAGE_STATION(20, "hailiang_cleaning_machine_storage_station", "海亮-清洗机储料仓", "conveyor"), - - HAILIANG_CLEANING_MACHINE(21, "hailiang_cleaning_machine", "海亮-清洗机", "conveyor"), - - HAILIANG_CLEANING_FEEDING_LINE(22, "hailiang_cleaning_feeding_line", "海亮-清洗上料线体", "conveyor"), - - AGV_NDC_ONE(23, "agv_ndc_one", "NDC单工位AGV", "agv"), - - AGV_NDC_TWO(24, "agv_ndc_two", "NDC双工位AGV", "agv"), - - HAILIANG_ENGRAVING_CACHE(25, "hailiang_engraving_cache", "海亮-刻字缓存位", "conveyor"), - - HAILIANG_PACKER_STATION(26, "hailiang_packer_station", "海亮-包装机工位", "conveyor"), - - 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(8, "hailiang_smart_plc_test", "永裕共挤线-西门子SMART200PLC", "conveyor"); 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 7940286..54aa8e5 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 @@ -21,8 +21,6 @@ import org.nl.acs.device.service.*; import org.nl.acs.device.service.dto.*; import org.nl.acs.device_driver.DeviceDriverDefination; import org.nl.acs.device_driver.ScannerDeviceDriver; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache.HailiangEngravingCacheDeviceDriver; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station.HailiangPackerStationDeviceDriver; import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; @@ -868,9 +866,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; //检测站点 StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - //刻字缓存位 - HailiangEngravingCacheDeviceDriver hailiangEngravingCacheDeviceDriver; - HailiangPackerStationDeviceDriver hailiangPackerStationDeviceDriver; if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); if (!StrUtil.isEmpty(hasGoodStatus)) { @@ -929,47 +924,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial device.setMaterial_type(material_type); device.setBatch(batch); } - - else if (device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) device.getDeviceDriver(); - WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint"); - JSONObject json = runpointwo.query("device_code ='" + device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(json)) { - DeviceRunpointDto obj = json.toJavaObject(DeviceRunpointDto.class); - obj.setHasgoods(hasGoodStatus); - obj.setMaterial_type(material_type); - obj.setBatch(batch); - obj.setIslock(islock); - hailiangEngravingCacheDeviceDriver.setMaterial(material_type); - if (hailiangEngravingCacheDeviceDriver.getMove() != Integer.parseInt(hasGoodStatus)){ - hailiangEngravingCacheDeviceDriver.writing("to_cache_write",hasGoodStatus); - } - hailiangEngravingCacheDeviceDriver.setHasGoods(Integer.parseInt(hasGoodStatus)); - device.setHas_goods(Integer.parseInt(hasGoodStatus)); - device.setMaterial_type(material_type); - hailiangEngravingCacheDeviceDriver.setMaterial(material_type); - JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj); - runpointwo.update(updatejson, "device_code = '" + device_code + "'"); - } - } - else if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) { - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - if(StrUtil.isNotEmpty(requireSucess)) { - if (requireSucess.equals("0")){ - hailiangPackerStationDeviceDriver.setRequireSucess(false); - } else { - hailiangPackerStationDeviceDriver.setRequireSucess(true); - } - } - if(StrUtil.isNotEmpty(fullrequireSucess)) { - if (fullrequireSucess.equals("0")){ - hailiangPackerStationDeviceDriver.setFullrequireSucess(false); - } else { - hailiangPackerStationDeviceDriver.setFullrequireSucess(true); - } - } - } - } @Override diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDefination.java deleted file mode 100644 index ccb93c9..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.basedriver.agv.ndcone; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * NDC单工位AGV - */ -@Service -public class AgvNdcOneDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "agv_ndc_one"; - } - - @Override - public String getDriverName() { - return "NDC单工位AGV"; - } - - @Override - public String getDriverDescription() { - return "NDC单工位AGV"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new AgvNdcOneDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return AgvNdcOneDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.agv); - return types; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java deleted file mode 100644 index e3a1128..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ /dev/null @@ -1,477 +0,0 @@ -package org.nl.acs.device_driver.basedriver.agv.ndcone; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.config.server.impl.AcsConfigServiceImpl; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_auto_cache_line.HailiangAutoCacheLineDeviceDriver; -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_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_packer_station.HailiangPackerStationDeviceDriver; -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.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.log.service.LogServer; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.start.auto.run.NDCSocketConnectionAutoRun; -import org.nl.start.auto.run.OneNDCSocketConnectionAutoRun; -import org.nl.utils.SpringContextHolder; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * NDC单工位AGV - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { - - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - org.nl.acs.agv.server.AgvService AgvService = SpringContextHolder.getBean(AgvService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - int agvaddr = 0; - int agvaddr_copy = 0; - int weight = 0; - String device_code = ""; - int phase = 0; - - int x = 0; //x坐标 - int y = 0; //y坐标 - int angle = 0; //角度 - int electric_qty = 0; //电量 - int status = 0; //三色灯状态 - int error = 0; //车辆故障 - - int last_x = 0; - int last_y = 0; - int last_angle = 0; - int last_electric_qty = 0; - int last_status = 0; - int last_error = 0; - public synchronized void processSocket(int[] arr) throws Exception { - device_code = this.getDeviceCode(); - byte[] data = null; - phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - //任务号 - int ikey = arr[26] * 256 + arr[27]; - //站点号 - agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - Instruction link_inst = null; - List insts = null; - boolean link_flag = false; - Device agv_device = null; - if (carno != 0) { - agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); - } - if (ikey != 0) { - insts = instructionService.findByLinkNum(String.valueOf(ikey)); - } - if (!ObjectUtil.isEmpty(link_inst)) { - link_flag = true; - } - logServer.deviceLogToacs(this.device_code,"","","接收AGV上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - - Device device = null; - String old_device_code = null; - String emptyNum = null; - String device_code = null; - - if(phase==0x67) { - //故障信息 - if(arr[18]*256+arr[19]==0){ - - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //刻字缓存位 - HailiangEngravingCacheDeviceDriver hailiangEngravingCacheDeviceDriver; - //刻字机工位 - HailiangEngravingMachineDeviceDriver hailiangEngravingMachineDeviceDriver; - //包装机工位 - HailiangPackerStationDeviceDriver hailiangPackerStationDeviceDriver; - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - //货架 - StandardStorageDeviceDriver standardStorageDeviceDriver; - - //开始任务/上报订单号 - if (phase == 0x02) { - for (Instruction inst : insts) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //请求取货 - } else if (phase == 0x03) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceLogToacs(this.device_code,"","","agv地址参数有误,phase:" + phase ); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - logServer.deviceLogToacs(this.device_code,"","",agvaddr+"对应设备号为空"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - logServer.deviceLogToacs(this.device_code,"","","未找到关联编号对应的指令"+ikey); - break; - } - - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) { - hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver(); - hailiangEngravingMachineDeviceDriver.setAgvphase(phase); - hailiangEngravingMachineDeviceDriver.setIndex(index); - hailiangEngravingMachineDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) device.getDeviceDriver(); - hailiangEngravingCacheDeviceDriver.setAgvphase(phase); - hailiangEngravingCacheDeviceDriver.setIndex(index); - hailiangEngravingCacheDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) { - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - hailiangPackerStationDeviceDriver.setAgvphase(phase); - hailiangPackerStationDeviceDriver.setIndex(index); - hailiangPackerStationDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - } else if (phase == 0x65) {//param,重量待定 - //1、得到重量信息 - int weight = (arr[18] * 256 + arr[19]) * 10; - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - // 4010 待处理 - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - inst.setWeight(String.valueOf(weight)); - } - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //取货完毕/取满框完毕1/点对点取货完毕 - } else if (phase == 0x64) {//param,agv货位id待定 - //1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备 - agvaddr = arr[18] * 256 + arr[19]; - agvaddr_copy = agvaddr; - data = AgvService.sendAgvOneModeInst(phase, index, 0); - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //取货完毕 - } else if (phase == 0x05) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceLogToacs(this.device_code,"","","agv地址参数有误,phase:" + phase ); - return; - } - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - logServer.deviceLogToacs(this.device_code,"","","对应设备号为空"+device_code); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - logServer.deviceLogToacs(this.device_code,"","","未找到关联编号对应的指令"+ikey); - break; - } - - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) { - hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver(); - hailiangEngravingMachineDeviceDriver.setAgvphase(phase); - hailiangEngravingMachineDeviceDriver.setIndex(index); - hailiangEngravingMachineDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) device.getDeviceDriver(); - hailiangEngravingCacheDeviceDriver.setAgvphase(phase); - hailiangEngravingCacheDeviceDriver.setIndex(index); - hailiangEngravingCacheDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) { - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - hailiangPackerStationDeviceDriver.setAgvphase(phase); - hailiangPackerStationDeviceDriver.setIndex(index); - hailiangPackerStationDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //请求放货 - } else if (phase == 0x07) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceLogToacs(this.device_code,"","","agv地址参数有误,phase:" + phase ); - return; - } - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getNext_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) { - hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver(); - hailiangEngravingMachineDeviceDriver.setAgvphase(phase); - hailiangEngravingMachineDeviceDriver.setIndex(index); - hailiangEngravingMachineDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) device.getDeviceDriver(); - hailiangEngravingCacheDeviceDriver.setAgvphase(phase); - hailiangEngravingCacheDeviceDriver.setIndex(index); - hailiangEngravingCacheDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) { - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - hailiangPackerStationDeviceDriver.setAgvphase(phase); - hailiangPackerStationDeviceDriver.setIndex(index); - hailiangPackerStationDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //放货完成 - } else if (phase == 0x09) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceLogToacs(this.device_code,"","","agv地址参数有误,phase:" + phase ); - return; - } - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getNext_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) { - hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver(); - hailiangEngravingMachineDeviceDriver.setAgvphase(phase); - hailiangEngravingMachineDeviceDriver.setIndex(index); - hailiangEngravingMachineDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) device.getDeviceDriver(); - hailiangEngravingCacheDeviceDriver.setAgvphase(phase); - hailiangEngravingCacheDeviceDriver.setIndex(index); - hailiangEngravingCacheDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) { - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - hailiangPackerStationDeviceDriver.setAgvphase(phase); - hailiangPackerStationDeviceDriver.setIndex(index); - hailiangPackerStationDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - } else if (phase == 0x71){ - x = ikey; - if (x != last_x){ - logServer.deviceLog(this.device_code, "x", String.valueOf(x)); - } - } else if (phase == 0x72){ - y = ikey; - if (y != last_y){ - logServer.deviceLog(this.device_code, "y", String.valueOf(y)); - } - } else if (phase == 0x73){ - angle = last_angle; - if (angle != last_angle){ - logServer.deviceLog(this.device_code, "angle", String.valueOf(angle)); - } - } else if (phase == 0x74){ - electric_qty = ikey; - if (electric_qty != last_electric_qty){ - logServer.deviceLog(this.device_code, "electric_qty", String.valueOf(electric_qty)); - } - } else if (phase == 0x75){ - status = ikey; - if (status != last_status){ - logServer.deviceLog(this.device_code, "status", String.valueOf(status)); - } - } else if (phase == 0x76){ - error = ikey; - if (error != last_error){ - logServer.deviceLog(this.device_code, "error", String.valueOf(error)); - } - } - if (!ObjectUtil.isEmpty(data)) { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - OneNDCSocketConnectionAutoRun.write(data); - } - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDefination.java deleted file mode 100644 index c67d99d..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.basedriver.agv.ndctwo; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * NDC双工位AGV - */ -@Service -public class AgvNdcTwoDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "agv_ndc_two"; - } - - @Override - public String getDriverName() { - return "NDC双工位AGV"; - } - - @Override - public String getDriverDescription() { - return "NDC双工位AGV"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new AgvNdcTwoDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return AgvNdcTwoDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.agv); - return types; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java deleted file mode 100644 index c0123e8..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ /dev/null @@ -1,738 +0,0 @@ -package org.nl.acs.device_driver.basedriver.agv.ndctwo; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.config.server.impl.AcsConfigServiceImpl; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_auto_cache_line.HailiangAutoCacheLineDeviceDriver; -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_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.driver.AbstractDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.log.service.LogServer; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.start.auto.run.AutoRunService; -import org.nl.start.auto.run.NDCSocketConnectionAutoRun; -import org.nl.utils.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 双工位诺宝AGV - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { - - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - AgvService AgvService = SpringContextHolder.getBean(AgvService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - int agvaddr = 0; - int agvaddr_copy = 0; - int weight = 0; - String device_code = ""; - int phase = 0; - - int x = 0; //x坐标 - int y = 0; //y坐标 - int angle = 0; //角度 - int electric_qty = 0; //电量 - int status = 0; //三色灯状态 - int error = 0; //车辆故障 - - int last_x = 0; - int last_y = 0; - int last_angle = 0; - int last_electric_qty = 0; - int last_status = 0; - int last_error = 0; - public synchronized void processSocket(int[] arr) throws Exception { - device_code = this.getDeviceCode(); - logServer.deviceLogToacs(this.device_code,"","","接收AGV上报信息:" + arr); - - byte[] data = null; - phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - //任务号 - int ikey = arr[26] * 256 + arr[27]; - //站点号 - agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - Instruction link_inst = null; - List insts = null; - boolean link_flag = false; - Device agv_device = null; - if (carno != 0) { - agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); - } - if (ikey != 0) { - insts = instructionService.findByLinkNum(String.valueOf(ikey)); - } - if (!ObjectUtil.isEmpty(link_inst)) { - link_flag = true; - } - log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - logServer.deviceLogToacs(this.device_code,"","","接收AGV上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - - Device device = null; - String old_device_code = null; - String emptyNum = null; - String device_code = null; - - if(phase==0x67) { - //故障信息 - if(arr[18]*256+arr[19]==0){ - - } - return; - } - - //海亮专机设备空框位 - HailiangSpecialEmptyStationDeviceDriver hailiangSpecialEmptyStationDeviceDriver; - //海亮专机设备满框位 - HailiangSpecialFullStationDeviceDriver hailiangSpecialFullStationDeviceDriver; - //海亮专机设备接框位 - HailiangSpecialPickStationDeviceDriver hailiangSpecialPickStationDeviceDriver; - //海亮专机设备倒料位 - HailiangSpecialPourStationDeviceDriver hailiangSpecialPourStationDeviceDriver; - //自动缓存线 - HailiangAutoCacheLineDeviceDriver hailiangAutoCacheLineDeviceDriver; - //清洗倒料 - HailiangCleaningMachineStorageStationDeviceDriver hailiangCleaningMachineStorageStationDeviceDriver; - - //开始任务/上报订单号 - if (phase == 0x02) { - for (Instruction inst : insts) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //到达取货点1 - } else if (phase == 0x03) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialFullStationDeviceDriver) { - hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialFullStationDeviceDriver.setAgvphase(phase); - hailiangSpecialFullStationDeviceDriver.setIndex(index); - hailiangSpecialFullStationDeviceDriver.setInst(inst); - } - } - } - - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - } else if (phase == 0x65) {//param,重量待定 - //1、得到重量信息 - int weight = (arr[18] * 256 + arr[19]) * 10; - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - // 4010 待处理 - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - inst.setWeight(String.valueOf(weight)); - } - } - data = AgvService.sendAgvTwoModeInst(phase, index, 0); - - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //取货完毕/取满框完毕1/点对点取货完毕 - } else if (phase == 0x64) {//param,agv货位id待定 - //1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备 - agvaddr = arr[18] * 256 + arr[19]; - agvaddr_copy = agvaddr; - data = AgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //取货点1取货完毕 - } else if (phase == 0x05) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialFullStationDeviceDriver) { - hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialFullStationDeviceDriver.setAgvphase(phase); - hailiangSpecialFullStationDeviceDriver.setIndex(index); - hailiangSpecialFullStationDeviceDriver.setInst(inst); - } - } - - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //到达取货点2 - } else if (phase == 0x07) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialFullStationDeviceDriver) { - hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialFullStationDeviceDriver.setAgvphase(phase); - hailiangSpecialFullStationDeviceDriver.setIndex(index); - hailiangSpecialFullStationDeviceDriver.setInst(inst); - } - } - - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //取货点2取货完毕 - } else if (phase == 0x09) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialFullStationDeviceDriver) { - hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialFullStationDeviceDriver.setAgvphase(phase); - hailiangSpecialFullStationDeviceDriver.setIndex(index); - hailiangSpecialFullStationDeviceDriver.setInst(inst); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //自动缓存线--到达送满框1 - } else if (phase == 0x0A) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - - - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - - //到达倒料点1 - } else if (phase == 0x0B) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - - if (StrUtil.equals(inst.getPut_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) { - hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialPourStationDeviceDriver.setAgvphase(phase); - hailiangSpecialPourStationDeviceDriver.setIndex(index); - hailiangSpecialPourStationDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) { - hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver(); - hailiangCleaningMachineStorageStationDeviceDriver.setAgvphase(phase); - hailiangCleaningMachineStorageStationDeviceDriver.setIndex(index); - hailiangCleaningMachineStorageStationDeviceDriver.setInst(inst); - } - } - - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //自动缓存线--送满框完毕1 - } else if (phase == 0x0C) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getPut_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) { - hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver(); - if (hailiangSpecialEmptyStationDeviceDriver.getMove() == 0 - && hailiangSpecialEmptyStationDeviceDriver.getError() == 0 && - hailiangSpecialEmptyStationDeviceDriver.getAllready() == 1) { - inst.setExecute_status("4"); - instructionService.update(inst); - data = AgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - log.info("AGV请求放货设备{}条件不满足,无法反馈", device_code); - } - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //倒料点1倒料完毕 - } else if (phase == 0x0D) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - - if (StrUtil.equals(inst.getPut_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) { - hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialPourStationDeviceDriver.setAgvphase(phase); - hailiangSpecialPourStationDeviceDriver.setIndex(index); - hailiangSpecialPourStationDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) { - hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver(); - hailiangCleaningMachineStorageStationDeviceDriver.setAgvphase(phase); - hailiangCleaningMachineStorageStationDeviceDriver.setIndex(index); - hailiangCleaningMachineStorageStationDeviceDriver.setInst(inst); - } - - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //自动缓存线--到达取空框1 - } else if (phase == 0x0E) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //到达倒料点2 - } else if (phase == 0x0F) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - - if (StrUtil.equals(inst.getPut_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) { - hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialPourStationDeviceDriver.setAgvphase(phase); - hailiangSpecialPourStationDeviceDriver.setIndex(index); - hailiangSpecialPourStationDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) { - hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver(); - hailiangCleaningMachineStorageStationDeviceDriver.setAgvphase(phase); - hailiangCleaningMachineStorageStationDeviceDriver.setIndex(index); - hailiangCleaningMachineStorageStationDeviceDriver.setInst(inst); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //倒料点2倒料完毕 - } else if (phase == 0x11) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getPut_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) { - hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialPourStationDeviceDriver.setAgvphase(phase); - hailiangSpecialPourStationDeviceDriver.setIndex(index); - hailiangSpecialPourStationDeviceDriver.setInst(inst); - } - if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) { - hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver(); - hailiangCleaningMachineStorageStationDeviceDriver.setAgvphase(phase); - hailiangCleaningMachineStorageStationDeviceDriver.setIndex(index); - hailiangCleaningMachineStorageStationDeviceDriver.setInst(inst); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //到达送箱点1 - } else if (phase == 0x13) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getNext_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) { - hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialEmptyStationDeviceDriver.setAgvphase(phase); - hailiangSpecialEmptyStationDeviceDriver.setIndex(index); - hailiangSpecialEmptyStationDeviceDriver.setInst(inst); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //送箱点1送箱完毕 - } else if (phase == 0x15) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getNext_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) { - hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialEmptyStationDeviceDriver.setAgvphase(phase); - hailiangSpecialEmptyStationDeviceDriver.setIndex(index); - hailiangSpecialEmptyStationDeviceDriver.setInst(inst); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //到达送箱点2 - } else if (phase == 0x17) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - if (StrUtil.equals(inst.getNext_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) { - hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialEmptyStationDeviceDriver.setAgvphase(phase); - hailiangSpecialEmptyStationDeviceDriver.setIndex(index); - hailiangSpecialEmptyStationDeviceDriver.setInst(inst); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //送箱完毕/送空框完毕2 - } else if (phase == 0x19) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - for (Instruction inst : insts) { - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - break; - } - - if (StrUtil.equals(inst.getNext_device_code(), device_code)) { - if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) { - hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver(); - hailiangSpecialEmptyStationDeviceDriver.setAgvphase(phase); - hailiangSpecialEmptyStationDeviceDriver.setIndex(index); - hailiangSpecialEmptyStationDeviceDriver.setInst(inst); - } - } - } - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - //自动缓存线--到达送满框1 - } else if (phase == 0x0A) { - - //到达倒料点1 - } else if (phase == 0x0B) { - - ///自动缓存线--送满框完毕1 - } else if (phase == 0x0C) { - - //倒料完毕 - } else if (phase == 0x0D) { - - //自动缓存线--到达取空框1 - } else if (phase == 0x0E) { - - //到达倒料点2 - } else if (phase == 0x0F) { - - //自动缓存线--取空框完毕1 - } else if (phase == 0x10) { - - //自动缓存线--到达送满框2 - } else if (phase == 0x21) { - - //自动缓存线--送满框完毕2 - } else if (phase == 0x23) { - - //自动缓存线--到达取空框2 - } else if (phase == 0x25) { - - //自动缓存线--取空框完毕2 - } else if (phase == 0x27) { - - //请求删除任务 - } else if (phase == 0x30) { - - data = AgvService.sendAgvTwoModeInst(143, index, 0); - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + phase + "反馈:"+data); - - } else if (phase == 0x71){ - x = ikey; - if (x != last_x){ - logServer.deviceLog(this.device_code, "x", String.valueOf(x)); - } - } else if (phase == 0x72){ - y = ikey; - if (y != last_y){ - logServer.deviceLog(this.device_code, "y", String.valueOf(y)); - } - } else if (phase == 0x73){ - angle = last_angle; - if (angle != last_angle){ - logServer.deviceLog(this.device_code, "angle", String.valueOf(angle)); - } - } else if (phase == 0x74){ - electric_qty = ikey; - if (electric_qty != last_electric_qty){ - logServer.deviceLog(this.device_code, "electric_qty", String.valueOf(electric_qty)); - } - } else if (phase == 0x75){ - status = ikey; - if (status != last_status){ - logServer.deviceLog(this.device_code, "status", String.valueOf(status)); - } - } else if (phase == 0x76){ - error = ikey; - if (error != last_error){ - logServer.deviceLog(this.device_code, "error", String.valueOf(error)); - } - } - - if (!ObjectUtil.isEmpty(data)) { - NDCSocketConnectionAutoRun.write(data); - } - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/HailiangAutoCacheLineDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/HailiangAutoCacheLineDefination.java deleted file mode 100644 index eda087b..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/HailiangAutoCacheLineDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_auto_cache_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 HailiangAutoCacheLineDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_auto_cache_line"; - } - - @Override - public String getDriverName() { - return "海亮-自动缓存线"; - } - - @Override - public String getDriverDescription() { - return "海亮-自动缓存线"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangAutoCacheLineDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangAutoCacheLineDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/HailiangAutoCacheLineDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/HailiangAutoCacheLineDeviceDriver.java deleted file mode 100644 index b92345d..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/HailiangAutoCacheLineDeviceDriver.java +++ /dev/null @@ -1,512 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_auto_cache_line; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.config.server.AcsConfigService; -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.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.service.LogServer; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -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; - -/** - * 海亮自动缓存线 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangAutoCacheLineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - - //开始条码匹配 - int matching_barcode = 0; - //准备位就绪 - int prepare_ready = 0; - //对接位入箱就绪 - int in_ready = 0; - //对接位入箱完成 - int in_finish = 0; - //对接位出箱就绪 - int out_ready = 0; - //任务完成 - int task_finish = 0; - //盘点中 - int checking = 0; - //盘点完成 - int check_finish =0; - //盘点强制完成 - int check_compel_finish =0; - //匹配条码失败 - int matching_barcode_fail =0; - //专机暂停 - int pause = 0; - //提升机条码目的层 - int hoist_target_layer =0; - //任务类型 - int task_type =0; - - int material_spec1,material_spec2,material_spec3,material_spec4,material_spec5,material_spec6,material_spec7, - material_spec8,material_spec9,material_spec10; - - //准备位条码 - int prepare_barcode =0; - //对接位条码 - int docking_barcode =0; - //提升机条码 - int hoist_barcode =0; - - int one_floor_barcode1,one_floor_barcode2,one_floor_barcode3,one_floor_barcode4,one_floor_barcode5,one_floor_barcode6, - one_floor_barcode7,one_floor_barcode8,one_floor_barcode9,one_floor_barcode10; - - int two_floor_barcode1,two_floor_barcode2,two_floor_barcode3,two_floor_barcode4,two_floor_barcode5,two_floor_barcode6, - two_floor_barcode7,two_floor_barcode8,two_floor_barcode9,two_floor_barcode10; - - int three_floor_barcode1,three_floor_barcode2,three_floor_barcode3,three_floor_barcode4,three_floor_barcode5, - three_floor_barcode6,three_floor_barcode7,three_floor_barcode8,three_floor_barcode9,three_floor_barcode10; - - - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task_finish = 0; - int last_task = 0; - //开始条码匹配 - int last_matching_barcode = 0; - //准备位就绪 - int last_prepare_ready = 0; - //对接位入箱就绪 - int last_in_ready = 0; - //对接位入箱完成 - int last_in_finish = 0; - //对接位出箱就绪 - int last_out_ready = 0; - //盘点中 - int last_checking = 0; - //盘点完成 - int last_check_finish =0; - //盘点强制完成 - int last_check_compel_finish =0; - //匹配条码失败 - int last_matching_barcode_fail =0; - //专机暂停 - int last_pause = 0; - //提升机条码目的层 - int last_hoist_target_layer =0; - //任务类型 - int last_task_type =0; - - - int hasGoods = 0; - Boolean isonline = false; - Boolean iserror = false; - Boolean task_finish_flag = false; - String material_spec = null; - String last_material_spec = null; - - boolean requireSucess = false; - - int one_barcode1,one_barcode2,one_barcode3,one_barcode4,one_barcode5,one_barcode6,one_barcode7,one_barcode8, - one_barcode9,one_barcode10; - int two_barcode1,two_barcode2,two_barcode3,two_barcode4,two_barcode5,two_barcode6,two_barcode7,two_barcode8, - two_barcode9,two_barcode10; - int three_barcode1,three_barcode2,three_barcode3,three_barcode4,three_barcode5,three_barcode6,three_barcode7, - three_barcode8,three_barcode9,three_barcode10; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag = 0; - - String device_code; - //agv 执行动作 - int agv_phase =0 ; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - error = this.itemProtocol.getError(); - mode = this.itemProtocol.getMode(); - hasGoods = this.itemProtocol.getItem_move(); - task = this.itemProtocol.getTask(); - matching_barcode = this.itemProtocol.getItem_matching_barcode(); - prepare_ready = this.itemProtocol.getItem_prepare_ready(); - in_ready = this.itemProtocol.getItem_in_ready(); - in_finish = this.itemProtocol.getItem_in_finish(); - out_ready = this.itemProtocol.getItem_out_ready(); - task_finish = this.itemProtocol.getItem_task_finish(); - checking = this.itemProtocol.getItem_checking(); - check_finish = this.itemProtocol.getItem_check_finish(); - check_compel_finish = this.itemProtocol.getItem_check_compel_finish(); - matching_barcode_fail = this.itemProtocol.getItem_matching_barcode_fail(); - pause = this.itemProtocol.getItem_pause(); - hoist_target_layer = this.itemProtocol.getItem_hoist_target_layer(); - task_type = this.itemProtocol.getItem_task_type(); - material_spec1 = this.itemProtocol.getItem_material_spec1(); - material_spec2 = this.itemProtocol.getItem_material_spec2(); - material_spec3 = this.itemProtocol.getItem_material_spec3(); - material_spec4 = this.itemProtocol.getItem_material_spec4(); - material_spec5 = this.itemProtocol.getItem_material_spec5(); - material_spec6 = this.itemProtocol.getItem_material_spec6(); - material_spec7 = this.itemProtocol.getItem_material_spec7(); - material_spec8 = this.itemProtocol.getItem_material_spec8(); - material_spec9 = this.itemProtocol.getItem_material_spec9(); - material_spec10 = this.itemProtocol.getItem_material_spec10(); - prepare_barcode = this.itemProtocol.getItem_prepare_barcode(); - docking_barcode = this.itemProtocol.getItem_docking_barcode(); - hoist_barcode = this.itemProtocol.getItem_hoist_barcode(); - one_floor_barcode1 = this.itemProtocol.getItem_one_floor_barcode1(); - one_floor_barcode2 = this.itemProtocol.getItem_one_floor_barcode2(); - one_floor_barcode3 = this.itemProtocol.getItem_one_floor_barcode3(); - one_floor_barcode4 = this.itemProtocol.getItem_one_floor_barcode4(); - one_floor_barcode5 = this.itemProtocol.getItem_one_floor_barcode5(); - one_floor_barcode6 = this.itemProtocol.getItem_one_floor_barcode6(); - one_floor_barcode7 = this.itemProtocol.getItem_one_floor_barcode7(); - one_floor_barcode8 = this.itemProtocol.getItem_one_floor_barcode8(); - one_floor_barcode9 = this.itemProtocol.getItem_one_floor_barcode9(); - one_floor_barcode10 = this.itemProtocol.getItem_one_floor_barcode10(); - two_floor_barcode1 = this.itemProtocol.getItem_two_floor_barcode1(); - two_floor_barcode2 = this.itemProtocol.getItem_two_floor_barcode2(); - two_floor_barcode3 = this.itemProtocol.getItem_two_floor_barcode3(); - two_floor_barcode4 = this.itemProtocol.getItem_two_floor_barcode4(); - two_floor_barcode5 = this.itemProtocol.getItem_two_floor_barcode5(); - two_floor_barcode6 = this.itemProtocol.getItem_two_floor_barcode6(); - two_floor_barcode7 = this.itemProtocol.getItem_two_floor_barcode7(); - two_floor_barcode8 = this.itemProtocol.getItem_two_floor_barcode8(); - two_floor_barcode9 = this.itemProtocol.getItem_two_floor_barcode9(); - two_floor_barcode10 = this.itemProtocol.getItem_two_floor_barcode10(); - three_floor_barcode1 = this.itemProtocol.getItem_three_floor_barcode1(); - three_floor_barcode2 = this.itemProtocol.getItem_three_floor_barcode2(); - three_floor_barcode3 = this.itemProtocol.getItem_three_floor_barcode3(); - three_floor_barcode4 = this.itemProtocol.getItem_three_floor_barcode4(); - three_floor_barcode5 = this.itemProtocol.getItem_three_floor_barcode5(); - three_floor_barcode6 = this.itemProtocol.getItem_three_floor_barcode6(); - three_floor_barcode7 = this.itemProtocol.getItem_three_floor_barcode7(); - three_floor_barcode8 = this.itemProtocol.getItem_three_floor_barcode8(); - three_floor_barcode9 = this.itemProtocol.getItem_three_floor_barcode9(); - three_floor_barcode10 = this.itemProtocol.getItem_three_floor_barcode10(); - - material_spec = stringToascii(material_spec1)+stringToascii(material_spec2)+stringToascii(material_spec3) - +stringToascii(material_spec4)+stringToascii(material_spec5)+stringToascii(material_spec6)+ - stringToascii(material_spec7)+stringToascii(material_spec8)+stringToascii(material_spec9)+ - stringToascii(material_spec10); - - if(StrUtil.equals(material_spec,last_material_spec)){ - logServer.deviceLog(this.device_code,"material_spec" ,String.valueOf(material_spec)); - logServer.deviceLogToacs(this.device_code,"","","信号material_spec:" + last_material_spec + "->" + material_spec); - } - - if (mode != last_mode) { - this.setRequireSucess(false); - logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess); - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - 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(task_finish != last_task_finish){ - if(task_finish == 1){ - writing("item_to_task_finish","1"); - } - logServer.deviceLog(this.device_code,"task_finish" ,String.valueOf(task_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号task_finish:" + last_task_finish + "->" + task_finish); - } - - - if (task != last_task) { - logServer.deviceLog(this.device_code,"task" ,String.valueOf(task)); - logServer.deviceLogToacs(this.device_code,"","","信号task:" + last_task + "->" + task); - } - if (matching_barcode != last_matching_barcode) { - logServer.deviceLog(this.device_code,"matching_barcode" ,String.valueOf(matching_barcode)); - logServer.deviceLogToacs(this.device_code,"","","信号matching_barcode:" + last_matching_barcode + "->" + matching_barcode); - } - if (prepare_ready != last_prepare_ready) { - logServer.deviceLog(this.device_code,"prepare_ready" ,String.valueOf(prepare_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号prepare_ready:" + last_prepare_ready + "->" + prepare_ready); - } - if (in_ready != last_in_ready) { - logServer.deviceLog(this.device_code,"in_ready" ,String.valueOf(in_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号in_ready:" + last_in_ready + "->" + in_ready); - } - if (in_finish != last_in_finish) { - logServer.deviceLog(this.device_code,"in_finish" ,String.valueOf(in_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号in_finish:" + last_in_finish + "->" + in_finish); - } - if (out_ready != last_out_ready) { - logServer.deviceLog(this.device_code,"out_ready" ,String.valueOf(out_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号out_ready:" + last_out_ready + "->" + out_ready); - } - if (checking != last_checking) { - logServer.deviceLog(this.device_code,"checking" ,String.valueOf(checking)); - logServer.deviceLogToacs(this.device_code,"","","信号checking:" + last_checking + "->" + checking); - } - if (check_finish != last_check_finish) { - logServer.deviceLog(this.device_code,"check_finish" ,String.valueOf(check_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号check_finish:" + last_check_finish + "->" + check_finish); - } - if (check_compel_finish != last_check_compel_finish) { - logServer.deviceLog(this.device_code,"check_compel_finish" ,String.valueOf(check_compel_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号check_compel_finish:" + last_check_compel_finish + "->" + check_compel_finish); - } - if (matching_barcode_fail != last_matching_barcode_fail) { - logServer.deviceLog(this.device_code,"matching_barcode_fail" ,String.valueOf(matching_barcode_fail)); - logServer.deviceLogToacs(this.device_code,"","","信号matching_barcode_fail:" + last_matching_barcode_fail + "->" + matching_barcode_fail); - } - if (pause != last_pause) { - logServer.deviceLog(this.device_code,"pause" ,String.valueOf(pause)); - logServer.deviceLogToacs(this.device_code,"","","信号pause:" + last_pause + "->" + pause); - } - if (hoist_target_layer != last_hoist_target_layer) { - logServer.deviceLog(this.device_code,"hoist_target_layer" ,String.valueOf(hoist_target_layer)); - logServer.deviceLogToacs(this.device_code,"","","信号hoist_target_layer:" + last_hoist_target_layer + "->" + hoist_target_layer); - } - if (task_type != last_task_type) { - logServer.deviceLog(this.device_code,"task_type" ,String.valueOf(task_type)); - logServer.deviceLogToacs(this.device_code,"","","信号task_type:" + last_task_type + "->" + task_type); - } - - - - if( prepare_ready == 1 && move ==0 && in_ready ==0 && in_finish ==0 && ( agv_phase==0x0A || agv_phase==0x21) ){ - -// if(this.准备位条码==this.条码异常值) -// { -// debug(d.getID()+" 准备位条码异常"); -// return; -// } - writing("item_to_agv_put_ready","1"); - - } - - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - } - - - - - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_task_finish = task_finish; - last_material_spec = material_spec; - last_matching_barcode = matching_barcode; - last_prepare_ready = prepare_ready; - last_in_ready = in_ready; - last_in_finish = in_finish; - last_out_ready = out_ready; - last_checking = checking; - last_check_finish =check_finish; - last_check_compel_finish =check_compel_finish; - last_matching_barcode_fail =matching_barcode_fail; - last_pause = pause; - last_hoist_target_layer =hoist_target_layer; - last_task_type =task_type; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - } - - public void writing(int command) {} - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - - } - - - public String stringToascii(int num) - { - String str=""; - switch (num) - { - case 48: str="0";break; - case 49: str="1";break; - case 50: str="2";break; - case 51: str="3";break; - case 52: str="4";break; - case 53: str="5";break; - case 54: str="6";break; - case 55: str="7";break; - case 56: str="8";break; - case 57: str="9";break; - case 65: str="A";break; - case 66: str="B";break; - case 67: str="C";break; - case 68: str="D";break; - case 69: str="E";break; - case 70: str="F";break; - case 71: str="G";break; - case 72: str="H";break; - case 73: str="I";break; - case 74: str="J";break; - case 75: str="K";break; - case 76: str="L";break; - case 77: str="M";break; - case 78: str="N";break; - case 79: str="O";break; - case 80: str="P";break; - case 81: str="Q";break; - case 82: str="R";break; - case 83: str="S";break; - case 84: str="T";break; - case 85: str="U";break; - case 86: str="V";break; - case 87: str="W";break; - case 88: str="X";break; - case 89: str="Y";break; - case 90: str="Z";break; - case 97: str="a";break; - case 98: str="b";break; - case 99: str="c";break; - case 100: str="d";break; - case 101: str="e";break; - case 102: str="f";break; - case 103: str="g";break; - case 104: str="h";break; - case 105: str="i";break; - case 106: str="j";break; - case 107: str="k";break; - case 108: str="l";break; - case 109: str="m";break; - case 110: str="n";break; - case 111: str="o";break; - case 112: str="p";break; - case 113: str="q";break; - case 114: str="r";break; - case 115: str="s";break; - case 116: str="t";break; - case 117: str="u";break; - case 118: str="v";break; - case 119: str="w";break; - case 120: str="x";break; - case 121: str="y";break; - case 122: str="z";break; - - case 40: str="(";break; - case 41: str=")";break; - case 43: str="+";break; - case 45: str="-";break; - case 47: str="/";break; - case 91: str="[";break; - case 93: str="]";break; - case 95: str="_";break; - default: str="*"; - } - return str; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/ItemProtocol.java deleted file mode 100644 index dd951b7..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_auto_cache_line/ItemProtocol.java +++ /dev/null @@ -1,682 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_auto_cache_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_error = "error"; - //开始条码匹配 - public static String item_matching_barcode = "matching_barcode"; - //对接位有货 - public static String item_move = "move"; - //准备位就绪 - public static String item_prepare_ready = "prepare_ready"; - //对接位入箱就绪 - public static String item_in_ready = "in_ready"; - //对接位入箱完成 - public static String item_in_finish = "in_finish"; - //对接位出箱就绪 - public static String item_out_ready = "out_ready"; - //任务完成 - public static String item_task_finish = "task_finish"; - //盘点中 - public static String item_checking = "checking"; - //盘点完成 - public static String item_check_finish = "check_finish"; - //盘点强制完成 - public static String item_check_compel_finish = "check_compel_finish"; - //匹配条码失败 - public static String item_matching_barcode_fail = "matching_barcode_fail"; - //专机暂停 - public static String item_pause = "pause"; - //提升机条码目的层 - public static String item_hoist_target_layer = "hoist_target_layer"; - //任务类型 - public static String item_task_type = "task_type"; - //物料规格 - public static String item_material_spec1= "material_spec1"; - - public static String item_material_spec2= "material_spec2"; - - public static String item_material_spec3= "material_spec3"; - - public static String item_material_spec4= "material_spec4"; - - public static String item_material_spec5= "material_spec5"; - - public static String item_material_spec6= "material_spec6"; - - public static String item_material_spec7= "material_spec7"; - - public static String item_material_spec8= "material_spec8"; - - public static String item_material_spec9= "material_spec9"; - - public static String item_material_spec10= "material_spec10"; - //准备位条码 - public static String item_prepare_barcode = "prepare_barcode"; - //对接位条码 - public static String item_docking_barcode = "docking_barcode"; - //任务号 - public static String item_task = "task"; - //提升机条码 - public static String item_hoist_barcode = "hoist_barcode"; - - - //一层条码 - public static String item_one_floor_barcode1 = "one_floor_barcode1"; - - public static String item_one_floor_barcode2 = "one_floor_barcode2"; - - public static String item_one_floor_barcode3 = "one_floor_barcode3"; - - public static String item_one_floor_barcode4 = "one_floor_barcode4"; - - public static String item_one_floor_barcode5 = "one_floor_barcode5"; - - public static String item_one_floor_barcode6 = "one_floor_barcode6"; - - public static String item_one_floor_barcode7 = "one_floor_barcode7"; - - public static String item_one_floor_barcode8 = "one_floor_barcode8"; - - public static String item_one_floor_barcode9 = "one_floor_barcode9"; - - public static String item_one_floor_barcode10 = "one_floor_barcode10"; - //二层条码 - public static String item_two_floor_barcode1 = "two_floor_barcode1"; - - public static String item_two_floor_barcode2 = "two_floor_barcode2"; - - public static String item_two_floor_barcode3 = "two_floor_barcode3"; - - public static String item_two_floor_barcode4 = "two_floor_barcode4"; - - public static String item_two_floor_barcode5 = "two_floor_barcode5"; - - public static String item_two_floor_barcode6 = "two_floor_barcode6"; - - public static String item_two_floor_barcode7 = "two_floor_barcode7"; - - public static String item_two_floor_barcode8 = "two_floor_barcode8"; - - public static String item_two_floor_barcode9 = "two_floor_barcode9"; - - public static String item_two_floor_barcode10 = "two_floor_barcode10"; - //三层条码 - public static String item_three_floor_barcode1 = "three_floor_barcode1"; - - public static String item_three_floor_barcode2 = "three_floor_barcode2"; - - public static String item_three_floor_barcode3 = "three_floor_barcode3"; - - public static String item_three_floor_barcode4 = "three_floor_barcode4"; - - public static String item_three_floor_barcode5 = "three_floor_barcode5"; - - public static String item_three_floor_barcode6 = "three_floor_barcode6"; - - public static String item_three_floor_barcode7 = "three_floor_barcode7"; - - public static String item_three_floor_barcode8 = "three_floor_barcode8"; - - public static String item_three_floor_barcode9 = "three_floor_barcode9"; - - public static String item_three_floor_barcode10 = "three_floor_barcode10"; - - //设备开关 - public static String item_to_open = "to_open"; - //开始匹配条码 - public static String item_to_open_check_barcode = "to_open_check_barcode"; - //任务类型 - public static String item_to_task_type = "to_task_type"; - //放货就绪 - public static String item_to_agv_put_ready = "to_agv_put_ready"; - //放货完成 - public static String item_to_agv_put_finish = "to_agv_put_finish"; - //准备位到对接位 - public static String item_to_prepare_docking = "to_prepare_docking"; - //取货就绪 - public static String item_to_agv_get_ready = "to_agv_get_ready"; - //放货完成 - public static String item_to_agv_get_finish = "to_agv_get_finish"; - //任务完成 - public static String item_to_task_finish = "to_task_finish"; - //专机暂停 - public static String item_to_pause = "to_pause"; - //优先层 - public static String item_to_priority_layer = "to_priority_layer"; - //开始盘点 - public static String item_to_start_checking = "to_start_checking"; - //盘点完成清零 - public static String item_to_check_finish = "to_check_finish"; - //暂停出箱匹配 - public static String item_to_pause_out_check = "to_pause_out_check"; - - //物料规格 - public static String item_to_material_spec1= "to_material_spec1"; - - public static String item_to_material_spec2= "to_material_spec2"; - - public static String item_to_material_spec3= "to_material_spec3"; - - public static String item_to_material_spec4= "to_material_spec4"; - - public static String item_to_material_spec5= "to_material_spec5"; - - public static String item_to_material_spec6= "to_material_spec6"; - - public static String item_to_material_spec7= "to_material_spec7"; - - public static String item_to_material_spec8= "to_material_spec8"; - - public static String item_to_material_spec9= "to_material_spec9"; - - public static String item_to_material_spec10= "to_material_spec10"; - - public static String item_to_material_spec11= "to_material_spec11"; - - public static String item_to_material_spec12= "to_material_spec12"; - - public static String item_to_material_spec13= "to_material_spec13"; - - public static String item_to_material_spec14= "to_material_spec14"; - - public static String item_to_material_spec15= "to_material_spec15"; - - public static String item_to_material_spec16= "to_material_spec16"; - - public static String item_to_material_spec17= "to_material_spec17"; - - public static String item_to_material_spec18= "to_material_spec18"; - - public static String item_to_material_spec19= "to_material_spec19"; - - public static String item_to_material_spec20= "to_material_spec20"; - - //准备位条码准备 - public static String item_to_prepare_barcode_write = "to_prepare_barcode_write"; - //对接位条码准备 - public static String item_to_docking_barcode_write = "to_docking_barcode_write"; - //任务号 - public static String item_to_task = "to_task"; - //条码 - public static String item_to_barcode1 = "to_barcode1"; - - public static String item_to_barcode2 = "to_barcode2"; - - public static String item_to_barcode3 = "to_barcode3"; - - public static String item_to_barcode4 = "to_barcode4"; - - public static String item_to_barcode5 = "to_barcode5"; - - public static String item_to_barcode6 = "to_barcode6"; - - public static String item_to_barcode7 = "to_barcode7"; - - public static String item_to_barcode8 = "to_barcode8"; - - public static String item_to_barcode9 = "to_barcode9"; - - public static String item_to_barcode10 = "to_barcode10"; - - public static String item_to_barcode11 = "to_barcode11"; - - public static String item_to_barcode12 = "to_barcode12"; - - public static String item_to_barcode13 = "to_barcode13"; - - public static String item_to_barcode14 = "to_barcode14"; - - public static String item_to_barcode15 = "to_barcode15"; - - public static String item_to_barcode16 = "to_barcode16"; - - public static String item_to_barcode17 = "to_barcode17"; - - public static String item_to_barcode18 = "to_barcode18"; - - public static String item_to_barcode19 = "to_barcode19"; - - public static String item_to_barcode20 = "to_barcode20"; - - public static String item_to_barcode21 = "to_barcode21"; - - public static String item_to_barcode22 = "to_barcode22"; - - public static String item_to_barcode23 = "to_barcode23"; - - public static String item_to_barcode24 = "to_barcode24"; - - public static String item_to_barcode25 = "to_barcode25"; - - public static String item_to_barcode26 = "to_barcode26"; - - public static String item_to_barcode27 = "to_barcode27"; - - public static String item_to_barcode28 = "to_barcode28"; - - public static String item_to_barcode29 = "to_barcode29"; - - public static String item_to_barcode30 = "to_barcode30"; - - - - private HailiangAutoCacheLineDeviceDriver driver; - - public ItemProtocol(HailiangAutoCacheLineDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getItem_matching_barcode() { - return this.getOpcIntegerValue(item_matching_barcode); - } - - public int getItem_move() { - return this.getOpcIntegerValue(item_move); - } - - public int getItem_prepare_ready() { - return this.getOpcIntegerValue(item_prepare_ready); - } - - public int getItem_in_ready() { - return this.getOpcIntegerValue(item_in_ready); - } - - public int getItem_in_finish() { - return this.getOpcIntegerValue(item_in_finish); - } - - public int getItem_out_ready() { - return this.getOpcIntegerValue(item_out_ready); - } - - public int getItem_task_finish() { - return this.getOpcIntegerValue(item_task_finish); - } - - public int getItem_checking() { - return this.getOpcIntegerValue(item_checking); - } - - public int getItem_check_finish() { - return this.getOpcIntegerValue(item_check_finish); - } - - public int getItem_check_compel_finish() { - return this.getOpcIntegerValue(item_check_compel_finish); - } - - public int getItem_matching_barcode_fail() { - return this.getOpcIntegerValue(item_matching_barcode_fail); - } - - public int getItem_pause() { - return this.getOpcIntegerValue(item_pause); - } - - public int getItem_hoist_target_layer() { - return this.getOpcIntegerValue(item_hoist_target_layer); - } - - public int getItem_task_type() { - return this.getOpcIntegerValue(item_task_type); - } - - public int getItem_material_spec1() { - return this.getOpcIntegerValue(item_material_spec1); - } - - public int getItem_material_spec2() { - return this.getOpcIntegerValue(item_material_spec2); - } - - public int getItem_material_spec3() { - return this.getOpcIntegerValue(item_material_spec3); - } - - public int getItem_material_spec4() { - return this.getOpcIntegerValue(item_material_spec4); - } - - public int getItem_material_spec5() { - return this.getOpcIntegerValue(item_material_spec5); - } - - public int getItem_material_spec6() { - return this.getOpcIntegerValue(item_material_spec6); - } - - public int getItem_material_spec7() { - return this.getOpcIntegerValue(item_material_spec7); - } - - public int getItem_material_spec8() { - return this.getOpcIntegerValue(item_material_spec8); - } - - public int getItem_material_spec9() { - return this.getOpcIntegerValue(item_material_spec9); - } - - public int getItem_material_spec10() { - return this.getOpcIntegerValue(item_material_spec10); - } - - public int getItem_prepare_barcode() { - return this.getOpcIntegerValue(item_prepare_barcode); - } - - public int getItem_docking_barcode() { - return this.getOpcIntegerValue(item_docking_barcode); - } - - public int getItem_task() { - return this.getOpcIntegerValue(item_task); - } - - public int getItem_hoist_barcode() { - return this.getOpcIntegerValue(item_hoist_barcode); - } - - public int getItem_one_floor_barcode1() { - return this.getOpcIntegerValue(item_one_floor_barcode1); - } - - public int getItem_one_floor_barcode2() { - return this.getOpcIntegerValue(item_one_floor_barcode2); - } - - public int getItem_one_floor_barcode3() { - return this.getOpcIntegerValue(item_one_floor_barcode3); - } - - public int getItem_one_floor_barcode4() { - return this.getOpcIntegerValue(item_one_floor_barcode4); - } - - public int getItem_one_floor_barcode5() { - return this.getOpcIntegerValue(item_one_floor_barcode5); - } - - public int getItem_one_floor_barcode6() { - return this.getOpcIntegerValue(item_one_floor_barcode6); - } - - public int getItem_one_floor_barcode7() { - return this.getOpcIntegerValue(item_one_floor_barcode7); - } - - public int getItem_one_floor_barcode8() { - return this.getOpcIntegerValue(item_one_floor_barcode8); - } - - public int getItem_one_floor_barcode9() { - return this.getOpcIntegerValue(item_one_floor_barcode9); - } - - public int getItem_one_floor_barcode10() { - return this.getOpcIntegerValue(item_one_floor_barcode10); - } - - public int getItem_two_floor_barcode1() { - return this.getOpcIntegerValue(item_two_floor_barcode1); - } - - public int getItem_two_floor_barcode2() { - return this.getOpcIntegerValue(item_two_floor_barcode2); - } - - public int getItem_two_floor_barcode3() { - return this.getOpcIntegerValue(item_two_floor_barcode3); - } - - public int getItem_two_floor_barcode4() { - return this.getOpcIntegerValue(item_two_floor_barcode4); - } - - public int getItem_two_floor_barcode5() { - return this.getOpcIntegerValue(item_two_floor_barcode5); - } - - public int getItem_two_floor_barcode6() { - return this.getOpcIntegerValue(item_two_floor_barcode6); - } - - public int getItem_two_floor_barcode7() { - return this.getOpcIntegerValue(item_two_floor_barcode7); - } - - public int getItem_two_floor_barcode8() { - return this.getOpcIntegerValue(item_two_floor_barcode8); - } - - public int getItem_two_floor_barcode9() { - return this.getOpcIntegerValue(item_two_floor_barcode9); - } - - public int getItem_two_floor_barcode10() { - return this.getOpcIntegerValue(item_two_floor_barcode10); - } - - public int getItem_three_floor_barcode1() { - return this.getOpcIntegerValue(item_three_floor_barcode1); - } - - public int getItem_three_floor_barcode2() { - return this.getOpcIntegerValue(item_three_floor_barcode2); - } - - public int getItem_three_floor_barcode3() { - return this.getOpcIntegerValue(item_three_floor_barcode3); - } - - public int getItem_three_floor_barcode4() { - return this.getOpcIntegerValue(item_three_floor_barcode4); - } - - public int getItem_three_floor_barcode5() { - return this.getOpcIntegerValue(item_three_floor_barcode5); - } - - public int getItem_three_floor_barcode6() { - return this.getOpcIntegerValue(item_three_floor_barcode6); - } - - public int getItem_three_floor_barcode7() { - return this.getOpcIntegerValue(item_three_floor_barcode7); - } - - public int getItem_three_floor_barcode8() { - return this.getOpcIntegerValue(item_three_floor_barcode8); - } - - public int getItem_three_floor_barcode9() { - return this.getOpcIntegerValue(item_three_floor_barcode9); - } - - public int getItem_three_floor_barcode10() { - return this.getOpcIntegerValue(item_three_floor_barcode10); - } - - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_mode, "手自动状态", "DB1.B0.0", Boolean.valueOf(true))); - list.add(new ItemDto(item_matching_barcode, "开始条码匹配", "DB1.B1.0")); - list.add(new ItemDto(item_move, "对接位有货", "DB1.B1.2")); - list.add(new ItemDto(item_prepare_ready, "准备位就绪", "DB1.B1.3")); - list.add(new ItemDto(item_in_ready, "对接位入箱就绪", "DB1.B1.4")); - list.add(new ItemDto(item_in_finish, "对接位入箱完成", "DB1.B1.5")); - list.add(new ItemDto(item_out_ready, "对接位出箱就绪", "DB1.B1.6")); - list.add(new ItemDto(item_task_finish, "任务完成", "DB1.B2.0")); - list.add(new ItemDto(item_checking, "盘点中", "DB1.B2.1")); - list.add(new ItemDto(item_check_finish, "盘点完成", "DB1.B2.2")); - list.add(new ItemDto(item_check_compel_finish, "盘点强制完成", "DB1.B2.3")); - list.add(new ItemDto(item_matching_barcode_fail, "匹配条码失败", "DB1.B2.4")); - list.add(new ItemDto(item_pause, "暂停", "DB1.B2.5")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W4")); - list.add(new ItemDto(item_hoist_target_layer, "提升机条码目的层", "DB1.W6")); - list.add(new ItemDto(item_task_type, "任务类型", "DB1.W8")); - list.add(new ItemDto(item_material_spec1, "物料规格1", "DB1.W10")); - list.add(new ItemDto(item_material_spec2, "物料规格2", "DB1.W12")); - list.add(new ItemDto(item_material_spec3, "物料规格3", "DB1.W14")); - list.add(new ItemDto(item_material_spec4, "物料规格4", "DB1.W16")); - list.add(new ItemDto(item_material_spec5, "物料规格5", "DB1.W18")); - list.add(new ItemDto(item_material_spec6, "物料规格6", "DB1.W20")); - list.add(new ItemDto(item_material_spec7, "物料规格7", "DB1.W22")); - list.add(new ItemDto(item_material_spec8, "物料规格8", "DB1.W24")); - list.add(new ItemDto(item_material_spec9, "物料规格9", "DB1.W26")); - list.add(new ItemDto(item_material_spec10, "物料规格10", "DB1.W28")); - list.add(new ItemDto(item_prepare_barcode, "准备位条码", "DB1.D84")); - list.add(new ItemDto(item_docking_barcode, "对接位条码", "DB1.D88")); - list.add(new ItemDto(item_task, "任务号", "DB1.D92")); - list.add(new ItemDto(item_hoist_barcode, "提升机条码", "DB1.D96")); - list.add(new ItemDto(item_one_floor_barcode1, "一层条码1", "DB1.D124")); - list.add(new ItemDto(item_one_floor_barcode2, "一层条码2", "DB1.D128")); - list.add(new ItemDto(item_one_floor_barcode3, "一层条码3", "DB1.D132")); - list.add(new ItemDto(item_one_floor_barcode4, "一层条码4", "DB1.D136")); - list.add(new ItemDto(item_one_floor_barcode5, "一层条码5", "DB1.D140")); - list.add(new ItemDto(item_one_floor_barcode6, "一层条码6", "DB1.D144")); - list.add(new ItemDto(item_one_floor_barcode7, "一层条码7", "DB1.D148")); - list.add(new ItemDto(item_one_floor_barcode8, "一层条码8", "DB1.D152")); - list.add(new ItemDto(item_one_floor_barcode9, "一层条码9", "DB1.D156")); - list.add(new ItemDto(item_one_floor_barcode10, "一层条码10", "DB1.D160")); - list.add(new ItemDto(item_two_floor_barcode1, "二层条码1", "DB1.D164")); - list.add(new ItemDto(item_two_floor_barcode2, "二层条码2", "DB1.D168")); - list.add(new ItemDto(item_two_floor_barcode3, "二层条码3", "DB1.D172")); - list.add(new ItemDto(item_two_floor_barcode4, "二层条码4", "DB1.D176")); - list.add(new ItemDto(item_two_floor_barcode5, "二层条码5", "DB1.D180")); - list.add(new ItemDto(item_two_floor_barcode6, "二层条码6", "DB1.D184")); - list.add(new ItemDto(item_two_floor_barcode7, "二层条码7", "DB1.D188")); - list.add(new ItemDto(item_two_floor_barcode8, "二层条码8", "DB1.D192")); - list.add(new ItemDto(item_two_floor_barcode9, "二层条码9", "DB1.D196")); - list.add(new ItemDto(item_two_floor_barcode10, "二层条码10", "DB1.D200")); - list.add(new ItemDto(item_three_floor_barcode1, "三层条码1", "DB1.D204")); - list.add(new ItemDto(item_three_floor_barcode2, "三层条码2", "DB1.D208")); - list.add(new ItemDto(item_three_floor_barcode3, "三层条码3", "DB1.D212")); - list.add(new ItemDto(item_three_floor_barcode4, "三层条码4", "DB1.D216")); - list.add(new ItemDto(item_three_floor_barcode5, "三层条码5", "DB1.D220")); - list.add(new ItemDto(item_three_floor_barcode6, "三层条码6", "DB1.D224")); - list.add(new ItemDto(item_three_floor_barcode7, "三层条码7", "DB1.D228")); - list.add(new ItemDto(item_three_floor_barcode8, "三层条码8", "DB1.D232")); - list.add(new ItemDto(item_three_floor_barcode9, "三层条码9", "DB1.D236")); - list.add(new ItemDto(item_three_floor_barcode10, "三层条码10", "DB1.D240")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_open, "设备开关", "DB1.W4")); - list.add(new ItemDto(item_to_open_check_barcode, "开始匹配条码", "DB1.W6")); - list.add(new ItemDto(item_to_task_type, "任务类型", "DB1.W8")); - list.add(new ItemDto(item_to_agv_put_ready, "放货就绪", "DB1.W10")); - list.add(new ItemDto(item_to_agv_put_finish, "放货完成", "DB1.W12")); - list.add(new ItemDto(item_to_prepare_docking, "准备位到对接位", "DB1.W14")); - list.add(new ItemDto(item_to_agv_get_ready, "取货就绪", "DB1.W16")); - list.add(new ItemDto(item_to_agv_get_finish, "取货完成", "DB1.W18")); - list.add(new ItemDto(item_to_task_finish, "任务完成", "DB1.W20")); - list.add(new ItemDto(item_to_pause, "专机暂停", "DB1.W22")); - list.add(new ItemDto(item_to_priority_layer, "优先层", "DB1.W24")); - list.add(new ItemDto(item_to_start_checking, "开始盘点", "DB1.W28")); - list.add(new ItemDto(item_to_check_finish, "盘点完成清零", "DB1.W30")); - list.add(new ItemDto(item_to_pause_out_check, "暂停出箱匹配", "DB1.W34")); - list.add(new ItemDto(item_to_material_spec1, "物料规格1", "DB1.W40")); - list.add(new ItemDto(item_to_material_spec2, "物料规格2", "DB1.W42")); - list.add(new ItemDto(item_to_material_spec3, "物料规格3", "DB1.W44")); - list.add(new ItemDto(item_to_material_spec4, "物料规格4", "DB1.W46")); - list.add(new ItemDto(item_to_material_spec5, "物料规格5", "DB1.W48")); - list.add(new ItemDto(item_to_material_spec6, "物料规格6", "DB1.W50")); - list.add(new ItemDto(item_to_material_spec7, "物料规格7", "DB1.W52")); - list.add(new ItemDto(item_to_material_spec8, "物料规格8", "DB1.W54")); - list.add(new ItemDto(item_to_material_spec9, "物料规格9", "DB1.W56")); - list.add(new ItemDto(item_to_material_spec10, "物料规格10", "DB1.W58")); - list.add(new ItemDto(item_to_material_spec11, "物料规格11", "DB1.W60")); - list.add(new ItemDto(item_to_material_spec12, "物料规格12", "DB1.W62")); - list.add(new ItemDto(item_to_material_spec13, "物料规格13", "DB1.W64")); - list.add(new ItemDto(item_to_material_spec14, "物料规格14", "DB1.W66")); - list.add(new ItemDto(item_to_material_spec15, "物料规格15", "DB1.W68")); - list.add(new ItemDto(item_to_material_spec16, "物料规格16", "DB1.W70")); - list.add(new ItemDto(item_to_material_spec17, "物料规格17", "DB1.W72")); - list.add(new ItemDto(item_to_material_spec18, "物料规格18", "DB1.W74")); - list.add(new ItemDto(item_to_material_spec19, "物料规格19", "DB1.W76")); - list.add(new ItemDto(item_to_material_spec20, "物料规格20", "DB1.W78")); - list.add(new ItemDto(item_to_prepare_barcode_write, "准备位条码准备", "DB1.D84")); - list.add(new ItemDto(item_to_docking_barcode_write, "对接位条码准备", "DB1.D88")); - list.add(new ItemDto(item_to_task, "任务号", "DB1.D92")); - list.add(new ItemDto(item_to_barcode1, "条码1", "DB1.D96")); - list.add(new ItemDto(item_to_barcode2, "条码2", "DB1.D100")); - list.add(new ItemDto(item_to_barcode3, "条码3", "DB1.D104")); - list.add(new ItemDto(item_to_barcode4, "条码4", "DB1.D108")); - list.add(new ItemDto(item_to_barcode5, "条码5", "DB1.D112")); - list.add(new ItemDto(item_to_barcode6, "条码6", "DB1.D116")); - list.add(new ItemDto(item_to_barcode7, "条码7", "DB1.D120")); - list.add(new ItemDto(item_to_barcode8, "条码8", "DB1.D124")); - list.add(new ItemDto(item_to_barcode9, "条码9", "DB1.D128")); - list.add(new ItemDto(item_to_barcode10, "条码10", "DB1.D132")); - list.add(new ItemDto(item_to_barcode11, "条码11", "DB1.D136")); - list.add(new ItemDto(item_to_barcode12, "条码12", "DB1.D140")); - list.add(new ItemDto(item_to_barcode13, "条码13", "DB1.D144")); - list.add(new ItemDto(item_to_barcode14, "条码14", "DB1.D148")); - list.add(new ItemDto(item_to_barcode15, "条码15", "DB1.D152")); - list.add(new ItemDto(item_to_barcode16, "条码16", "DB1.D156")); - list.add(new ItemDto(item_to_barcode17, "条码17", "DB1.D160")); - list.add(new ItemDto(item_to_barcode18, "条码18", "DB1.D164")); - list.add(new ItemDto(item_to_barcode19, "条码19", "DB1.D168")); - list.add(new ItemDto(item_to_barcode20, "条码20", "DB1.D172")); - list.add(new ItemDto(item_to_barcode21, "条码21", "DB1.D176")); - list.add(new ItemDto(item_to_barcode22, "条码22", "DB1.D180")); - list.add(new ItemDto(item_to_barcode23, "条码23", "DB1.D184")); - list.add(new ItemDto(item_to_barcode24, "条码24", "DB1.D188")); - list.add(new ItemDto(item_to_barcode25, "条码25", "DB1.D192")); - list.add(new ItemDto(item_to_barcode26, "条码26", "DB1.D196")); - list.add(new ItemDto(item_to_barcode27, "条码27", "DB1.D200")); - list.add(new ItemDto(item_to_barcode28, "条码28", "DB1.D204")); - list.add(new ItemDto(item_to_barcode29, "条码29", "DB1.D208")); - list.add(new ItemDto(item_to_barcode30, "条码30", "DB1.D212")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_feeding_line/HailiangCleaningFeedingLineDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_feeding_line/HailiangCleaningFeedingLineDefination.java deleted file mode 100644 index c2ebf12..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_feeding_line/HailiangCleaningFeedingLineDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_feeding_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 HailiangCleaningFeedingLineDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_cleaning_feeding_line"; - } - - @Override - public String getDriverName() { - return "海亮-清洗上料线体"; - } - - @Override - public String getDriverDescription() { - return "海亮-清洗上料线体"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangCleaningFeedingLineDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangCleaningFeedingLineDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_feeding_line/HailiangCleaningFeedingLineDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_feeding_line/HailiangCleaningFeedingLineDriver.java deleted file mode 100644 index 4afbdf3..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_feeding_line/HailiangCleaningFeedingLineDriver.java +++ /dev/null @@ -1,386 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_feeding_line; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.config.server.AcsConfigService; -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.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -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.order.service.ProduceshiftorderService; -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.Map; - -/** - * 海亮-清洗上料线体 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangCleaningFeedingLineDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.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 is_open = 0; //是否启动 开机状态 - int in_ready = 0; //入料就绪 - int all_ready = 0; //所有设备就绪 - int task_finish = 0; //任务完成 - int allowed_in = 0; //清洗机允许上料 - int error = 0; //报警信号 - int in_pcsn = 0; //上料批次号 - //出入库模式 - int operation_type = 0; - int last_mode = 0; //线体状态 - int last_is_open = 0; //是否启动 开机状态 - int last_in_ready = 0; //入料就绪 - int last_all_ready = 0; //所有设备就绪 - int last_task_finish = 0; //任务完成 - int last_allowed_in = 0; //清洗机允许上料 - int last_error = 0; //报警信号 - int last_in_pcsn = 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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getItem_mode(); - is_open = this.itemProtocol.getItem_is_open(); - in_ready = this.itemProtocol.getItem_in_ready(); - all_ready = this.itemProtocol.getItem_all_ready(); - task_finish = this.itemProtocol.getItem_task_finish(); - allowed_in = this.itemProtocol.getItem_allowed_in(); - error = this.itemProtocol.getItem_error(); - in_pcsn = this.itemProtocol.getItem_in_pcsn(); - if (mode != last_mode) { - this.setRequireSucess(false); - logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess); - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (is_open != last_is_open) { - logServer.deviceLog(this.device_code,"is_open" ,String.valueOf(is_open)); - logServer.deviceLogToacs(this.device_code,"","","信号is_open:" + last_is_open + "->" + is_open); - } - if (in_ready != last_in_ready) { - logServer.deviceLog(this.device_code,"in_ready" ,String.valueOf(in_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号in_ready:" + last_in_ready + "->" + in_ready); - } - if (all_ready != last_all_ready) { - logServer.deviceLog(this.device_code,"all_ready" ,String.valueOf(all_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号all_ready:" + last_all_ready + "->" + all_ready); - } - if (task_finish != last_task_finish) { - logServer.deviceLog(this.device_code,"task_finish" ,String.valueOf(task_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号task_finish:" + last_task_finish + "->" + task_finish); - } - if (allowed_in != last_allowed_in) { - logServer.deviceLog(this.device_code,"allowed_in" ,String.valueOf(allowed_in)); - logServer.deviceLogToacs(this.device_code,"","","信号allowed_in:" + last_allowed_in + "->" + allowed_in); - } - if (in_pcsn != last_in_pcsn) { - logServer.deviceLog(this.device_code,"in_pcsn" ,String.valueOf(in_pcsn)); - logServer.deviceLogToacs(this.device_code,"","","信号in_pcsn:" + last_in_pcsn + "->" + in_pcsn); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - - - } 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 = ""; - - if(!requireSucess){ - /* if ( mode == 1 && move != 0 && task > 0) { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,move:"+move+",requireSucess:" + requireSucess + "开始申请任务"); - apply_task(); - }*/ - } - - - - } - last_mode = mode; //线体状态 - last_is_open = is_open; //是否启动 开机状态 - last_in_ready = in_ready; //入料就绪 - last_all_ready = all_ready; //所有设备就绪 - last_task_finish = task_finish; //任务完成 - last_allowed_in = allowed_in; //清洗机允许上料 - last_error = error; //报警信号 - last_in_pcsn = in_pcsn; //上料批次号 - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - logServer.deviceLogToacs(this.device_code,"","","光电信号切换,刷新请求标记:"+this.requireSucess); - - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } - -/* public synchronized boolean apply_task() throws Exception { - Boolean flag = false; - //通过路由找到所有的目标设备 - //找到当前设备生产的物料,并且判断下个工序生产的物料相同 - //判断是否已经有前往这个工位的任务 - List list = routeLineService.getShortPathLinesByCode(this.device_code,"normal"); - ProduceshiftorderDto order = produceshiftorderService.findOrderByDeviceCode(this.device_code); - //查找当前工单对应的物料编号 - String cpbh = order.getMaterial_code(); - HailiangSpecialPourStationDeviceDriver hailiangSpecialPourStationDeviceDriver; - //遍历路由,找到对应所有的物料进行匹配 - for(int i=0;i getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_mode, "线体状态", "DB1.X0.0")); - list.add(new ItemDto(item_is_open, "开机状态", "DB1.X0.1")); - list.add(new ItemDto(item_in_ready, "入料就绪", "DB1.X0.7")); - list.add(new ItemDto(item_all_ready, "所有设备就绪", "DB1.X1.0")); - list.add(new ItemDto(item_task_finish, "任务完成", "DB1.X1.1")); - list.add(new ItemDto(item_allowed_in, "清洗机允许上料", "DB1.X1.2")); - list.add(new ItemDto(item_error, "报警信号", "DB1.w4")); - list.add(new ItemDto(item_in_pcsn, "上料批次号", "DB1.D156")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_open, "设备开关", "DB2.W4")); - list.add(new ItemDto(item_to_compel_finished, "强制完成", "DB2.W6")); - list.add(new ItemDto(item_to_dis_weight, "称重禁用", "DB2.W8")); - list.add(new ItemDto(item_to_in_confirm_req, "上料请求确认", "DB2.W40")); - list.add(new ItemDto(item_to_in_confirm_finish, "上料命令确认完毕", "DB2.W72")); - list.add(new ItemDto(item_to_confirm_finished, "确认完成", "DB2.W74")); - list.add(new ItemDto(item_to_pcsn, "批次号", "DB2.D84")); - list.add(new ItemDto(item_to_all_num, "上料总数量", "DB2.D232")); - list.add(new ItemDto(item_to_all_weight, "上料总重量", "DB2.D232")); - list.add(new ItemDto(item_to_del_task, "任务删除", "DB2.D232")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine/HailiangCleaningMachineDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine/HailiangCleaningMachineDefination.java deleted file mode 100644 index d570db5..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine/HailiangCleaningMachineDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine; - -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 HailiangCleaningMachineDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_cleaning_machine"; - } - - @Override - public String getDriverName() { - return "海亮-清洗机"; - } - - @Override - public String getDriverDescription() { - return "海亮-清洗机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangCleaningMachineDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangCleaningMachineDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine/HailiangCleaningMachineDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine/HailiangCleaningMachineDeviceDriver.java deleted file mode 100644 index c5b2763..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine/HailiangCleaningMachineDeviceDriver.java +++ /dev/null @@ -1,426 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.config.server.AcsConfigService; -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.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.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.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -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.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 HailiangCleaningMachineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.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 running = 0; //是否运行 - int prepare = 0; //是否准备 - int ready = 0; //是否就绪 - int order_finish = 0; //订单完成 - int error = 0; //报警信号 - int open_ready_time = 0; //开机准备时间(S) - int device_running_time = 0; //设备运转时间(S) - int await_time = 0; //待机时间(S) - int order = 0; //工单号 - int order_real_time = 0; //订单实时 - int is_start = 0; //是否开始 - int pause = 0; //是否暂停 - //出入库模式 - int operation_type = 0; - int last_running = 0; //是否运行 - int last_prepare = 0; //是否准备 - int last_ready = 0; //是否就绪 - int last_order_finish = 0; //订单完成 - int last_error = 0; //报警信号 - int last_open_ready_time = 0; //开机准备时间(S) - int last_device_running_time = 0; //设备运转时间(S) - int last_await_time = 0; //待机时间(S) - int last_order = 0; //工单号 - int last_order_real_time = 0; //订单实时 - int last_is_start = 0; //是否开始 - int last_pause = 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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - running = this.itemProtocol.getItem_running(); - prepare = this.itemProtocol.getItem_prepare(); - ready = this.itemProtocol.getItem_ready(); - order_finish = this.itemProtocol.getItem_order_finish(); - error = this.itemProtocol.getItem_error(); - open_ready_time = this.itemProtocol.getItem_open_ready_time(); - device_running_time = this.itemProtocol.getItem_device_running_time(); - await_time = this.itemProtocol.getItem_await_time(); - order = this.itemProtocol.getItem_order(); - order_real_time = this.itemProtocol.getItem_order_real_time(); - is_start = this.itemProtocol.getItem_is_start(); - pause = this.itemProtocol.getItem_pause(); - if (running != last_running) { - logServer.deviceLog(this.device_code,"running" ,String.valueOf(running)); - logServer.deviceLogToacs(this.device_code,"","","信号running:" + last_running + "->" + running); - } - if (prepare != last_prepare) { - logServer.deviceLog(this.device_code,"prepare" ,String.valueOf(prepare)); - logServer.deviceLogToacs(this.device_code,"","","信号prepare:" + last_prepare + "->" + prepare); - } - if (ready != last_ready) { - logServer.deviceLog(this.device_code,"ready" ,String.valueOf(ready)); - logServer.deviceLogToacs(this.device_code,"","","信号ready:" + last_ready + "->" + ready); - } - if (order_finish != last_order_finish) { - logServer.deviceLog(this.device_code,"order_finish" ,String.valueOf(order_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号order_finish:" + last_order_finish + "->" + order_finish); - } - if (open_ready_time != last_open_ready_time) { - logServer.deviceLog(this.device_code,"open_ready_time" ,String.valueOf(open_ready_time)); - logServer.deviceLogToacs(this.device_code,"","","信号open_ready_time:" + last_open_ready_time + "->" + open_ready_time); - } - if (device_running_time != last_device_running_time) { - logServer.deviceLog(this.device_code,"device_running_time" ,String.valueOf(device_running_time)); - logServer.deviceLogToacs(this.device_code,"","","信号device_running_time:" + last_device_running_time + "->" + device_running_time); - } - if (await_time != last_await_time) { - logServer.deviceLog(this.device_code,"await_time" ,String.valueOf(await_time)); - logServer.deviceLogToacs(this.device_code,"","","信号await_time:" + last_await_time + "->" + await_time); - } - if (order != last_order) { - logServer.deviceLog(this.device_code,"order" ,String.valueOf(order)); - logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order); - } - if (order_real_time != last_order_real_time) { - logServer.deviceLog(this.device_code,"order_real_time" ,String.valueOf(order_real_time)); - logServer.deviceLogToacs(this.device_code,"","","信号order_real_time:" + last_order_real_time + "->" + order_real_time); - } - if (is_start != last_is_start) { - logServer.deviceLog(this.device_code,"is_start" ,String.valueOf(is_start)); - logServer.deviceLogToacs(this.device_code,"","","信号is_start:" + last_is_start + "->" + is_start); - } - if (pause != last_pause) { - logServer.deviceLog(this.device_code,"pause" ,String.valueOf(pause)); - logServer.deviceLogToacs(this.device_code,"","","信号pause:" + last_pause + "->" + pause); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - - - } 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 = ""; - - if(!requireSucess){ - /* if ( mode == 1 && move != 0 && task > 0) { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,move:"+move+",requireSucess:" + requireSucess + "开始申请任务"); - apply_task(); - }*/ - } - - - - } - last_running = running; //是否运行 - last_prepare = prepare; //是否准备 - last_ready = ready; //是否就绪 - last_order_finish = order_finish; //订单完成 - last_error = error; //报警信号 - last_open_ready_time = open_ready_time; //开机准备时间(S) - last_device_running_time = device_running_time; //设备运转时间(S) - last_await_time = await_time; //待机时间(S) - last_order = order; //工单号 - last_order_real_time = order_real_time; //订单实时 - last_is_start = is_start; //是否开始 - last_pause = pause; //是否暂停 - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - logServer.deviceLogToacs(this.device_code,"","","光电信号切换,刷新请求标记:"+this.requireSucess); - - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } - -/* public synchronized boolean apply_task() throws Exception { - Boolean flag = false; - //通过路由找到所有的目标设备 - //找到当前设备生产的物料,并且判断下个工序生产的物料相同 - //判断是否已经有前往这个工位的任务 - List list = routeLineService.getShortPathLinesByCode(this.device_code,"normal"); - ProduceshiftorderDto order = produceshiftorderService.findOrderByDeviceCode(this.device_code); - //查找当前工单对应的物料编号 - String cpbh = order.getMaterial_code(); - HailiangSpecialPourStationDeviceDriver hailiangSpecialPourStationDeviceDriver; - //遍历路由,找到对应所有的物料进行匹配 - for(int i=0;i getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_running, "是否运行", "DB1.X0.3")); - list.add(new ItemDto(item_prepare, "是否准备", "DB1.X0.5")); - list.add(new ItemDto(item_ready, "是否就绪", "DB1.X0.6")); - list.add(new ItemDto(item_order_finish, "订单完成", "DB1.X1.3")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W68")); - list.add(new ItemDto(item_open_ready_time, "开机准备时间(S)", "DB1.D144")); - list.add(new ItemDto(item_device_running_time, "设备运转时间(S)", "DB1.D148")); - list.add(new ItemDto(item_await_time, "待机时间(S)", "DB1.D152")); - list.add(new ItemDto(item_order, "工单号", "DB1.D160")); - list.add(new ItemDto(item_order_real_time, "订单实时", "DB1.D284")); - list.add(new ItemDto(item_is_start, "是否开始", "DB1.D288")); - list.add(new ItemDto(item_pause, "是否暂停", "DB1.D292")); - return list; - } - - //订单生产总量 - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_open, "设备开关", "DB2.W76")); - list.add(new ItemDto(item_to_clear, "产量清零", "DB2.W78")); - list.add(new ItemDto(item_to_confirm_finished, "订单确认完成", "DB2.W80")); - list.add(new ItemDto(item_to_order, "工单号", "DB2.D160")); - list.add(new ItemDto(item_to_order_prod_num, "订单生产总量", "DB2.D224")); - list.add(new ItemDto(item_to_start_end, "开始结束", "DB2.D228")); - list.add(new ItemDto(item_to_pause, "暂停恢复", "DB2.D232")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine_storage_station/HailiangCleaningMachineStorageStationDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine_storage_station/HailiangCleaningMachineStorageStationDefination.java deleted file mode 100644 index 24dadef..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine_storage_station/HailiangCleaningMachineStorageStationDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮清洗机储料仓 - */ -@Service -public class HailiangCleaningMachineStorageStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_cleaning_machine_storage_station"; - } - - @Override - public String getDriverName() { - return "海亮-清洗机储料仓"; - } - - @Override - public String getDriverDescription() { - return "海亮-清洗机储料仓"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangCleaningMachineStorageStationDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangCleaningMachineStorageStationDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine_storage_station/HailiangCleaningMachineStorageStationDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine_storage_station/HailiangCleaningMachineStorageStationDeviceDriver.java deleted file mode 100644 index 55bf62d..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_cleaning_machine_storage_station/HailiangCleaningMachineStorageStationDeviceDriver.java +++ /dev/null @@ -1,416 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.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.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -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.start.auto.run.NDCSocketConnectionAutoRun; -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 HailiangCleaningMachineStorageStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.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 running = 0; //是否运行 - int is_open = 0; //是否启动 - int error = 0; //报警信号 - int silo_weight = 0; //储料仓重量 - int full_number = 0; //储料仓总数量 - int silo_material_no = 0; //储料仓物物料号 - //出入库模式 - int operation_type = 0; - int last_running = 0; //是否运行 - int last_is_open = 0; //是否启动 - int last_error = 0; //报警信号 - int last_silo_weight = 0; //储料仓重量 - int last_full_number = 0; //储料仓总数量 - int last_silo_material_no = 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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - - int agvphase=0; - int index =0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getItem_error(); - running = this.itemProtocol.getItem_running(); - is_open = this.itemProtocol.getItem_is_open(); - silo_weight = this.itemProtocol.getItem_silo_weight(); - full_number = this.itemProtocol.getItem_full_number(); - silo_material_no = this.itemProtocol.getItem_silo_material_no(); - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - if (running != last_running) { - logServer.deviceLog(this.device_code,"running" ,String.valueOf(running)); - logServer.deviceLogToacs(this.device_code,"","","信号running:" + last_running + "->" + running); - } - if (is_open != last_is_open) { - logServer.deviceLog(this.device_code,"is_open" ,String.valueOf(is_open)); - logServer.deviceLogToacs(this.device_code,"","","信号is_open:" + last_is_open + "->" + is_open); - } - if (silo_weight != last_silo_weight) { - logServer.deviceLog(this.device_code,"silo_weight" ,String.valueOf(silo_weight)); - logServer.deviceLogToacs(this.device_code,"","","信号silo_weight:" + last_silo_weight + "->" + silo_weight); - } - if (full_number != last_full_number) { - logServer.deviceLog(this.device_code,"full_number" ,String.valueOf(full_number)); - logServer.deviceLogToacs(this.device_code,"","","信号full_number:" + last_full_number + "->" + full_number); - } - if (silo_material_no != last_silo_material_no) { - logServer.deviceLog(this.device_code,"silo_material_no" ,String.valueOf(silo_material_no)); - logServer.deviceLogToacs(this.device_code,"","","信号silo_material_no:" + last_silo_material_no + "->" + silo_material_no); - } - - } 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 = "未联机"; - //有报警 -// } - if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - - if(!requireSucess){ - /* if ( mode == 1 && move != 0 && task > 0) { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,move:"+move+",requireSucess:" + requireSucess + "开始申请任务"); - apply_task(); - }*/ - } - - if(agvphase == 0x0B || agvphase == 0x0F ) - { - if(error == 0 && ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("3"); - instructionService.update(inst); - writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvTwoModeInst(agvphase, index, 0); - NDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - }else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因error:"+error+",inst"+inst); - - } - } - - if(agvphase == 0x0D || agvphase == 0x11){ - if(error == 0 && ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("4"); - instructionService.update(inst); - byte[] data = agvService.sendAgvTwoModeInst(agvphase, index, 0); - NDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - }else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因error:"+error+",inst"+inst); - - } - } - - } - last_running = running; - last_is_open = is_open; //是否启动 - last_error = error; //报警信号 - last_silo_weight = silo_weight; //储料仓重量 - last_full_number = full_number; //储料仓总数量 - last_silo_material_no = silo_material_no; //储料仓物物料号 - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - logServer.deviceLogToacs(this.device_code,"","","光电信号切换,刷新请求标记:"+this.requireSucess); - - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } - - public synchronized boolean apply_task() throws Exception { - Boolean flag = false; - //通过路由找到所有的目标设备 - //找到当前设备生产的物料,并且判断下个工序生产的物料相同 - //判断是否已经有前往这个工位的任务 - List list = routeLineService.getShortPathLinesByCode(this.device_code,"normal"); - ProduceshiftorderDto order = produceshiftorderService.findOrderByDeviceCode(this.device_code); - //查找当前工单对应的物料编号 - String cpbh = order.getMaterial_code(); - HailiangSpecialPourStationDeviceDriver hailiangSpecialPourStationDeviceDriver; - //遍历路由,找到对应所有的物料进行匹配 - for(int i=0;i getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_mode, "模式", "DB1.W36")); - list.add(new ItemDto(item_running, "是否运行", "DB1.B2.0")); - list.add(new ItemDto(item_is_open, "是否启动", "DB1.B1.0")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W38")); - list.add(new ItemDto(item_silo_weight, "储料仓重量", "DB1.D84")); - list.add(new ItemDto(item_full_number, "储料仓总数量", "DB1.D164")); - list.add(new ItemDto(item_silo_material_no, "储料仓物料号", "DB1.D224")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_open_weight, "储料仓开始称重", "DB2.W10")); - list.add(new ItemDto(item_to_feeding, "储料仓上料", "DB2.W42")); - list.add(new ItemDto(item_to_material_no, "储料仓料号", "DB2.D92")); - list.add(new ItemDto(item_to_dumping_num, "储料仓倒料数量", "DB2.D164")); - list.add(new ItemDto(item_to_peel, "储料仓去皮", "DB2.W364")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/HailiangEngravingCacheDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/HailiangEngravingCacheDefination.java deleted file mode 100644 index 9b28f7a..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/HailiangEngravingCacheDefination.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮刻字缓存位 - */ -@Service -public class HailiangEngravingCacheDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_engraving_cache"; - } - - @Override - public String getDriverName() { - return "海亮-刻字缓存位"; - } - - @Override - public String getDriverDescription() { - return "海亮-刻字缓存位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangEngravingCacheDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangEngravingCacheDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/HailiangEngravingCacheDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/HailiangEngravingCacheDeviceDriver.java deleted file mode 100644 index 64c9734..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/HailiangEngravingCacheDeviceDriver.java +++ /dev/null @@ -1,424 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.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.WcsConfig; -import org.nl.acs.order.service.ProduceshiftorderService; -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.start.auto.run.OneNDCSocketConnectionAutoRun; -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; - -/** - * 海亮刻字缓存位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangEngravingCacheDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @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 - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.class); - - String container; - - int move = 0;//光电信号 - int mode = 0;//模式 - //出入库模式 - int operation_type = 0; - int last_move = 0;//光电信号 - int last_mode = 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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - int agvphase = 0; - int index = 0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - move = this.itemProtocol.getItem_move();//光电信号 - mode = this.itemProtocol.getItem_mode();//模式 - if (mode != last_mode) { - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - if (move == 1) { - thingToNothing(); - } - this.setRequireSucess(false); - logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); - logServer.deviceLogToacs(this.device_code,"","","信号move(取反):" + last_move + "->" + move); - } - - - /* if (mode == 2 && move != 0 && task > 0) { - - }*/ - } 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 { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - if(agvphase == 0x03) - { - if(ObjectUtil.isNotEmpty(inst) && move != 0){ - inst.setExecute_status("1"); - instructionService.update(inst); - //writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "move=" +move + ",等待反馈,inst:"+inst); - - } - } - - if(agvphase == 0x05){ - if(ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("2"); - instructionService.update(inst); - writing("to_cache_write", "0"); - this.setMaterial(""); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,inst为空"); - - } - } - - if(agvphase == 0x07){ - if(ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("5"); - instructionService.update(inst); - //writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,inst为空"); - } - } - - if(agvphase == 0x09){ - if(ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("6"); - instructionService.update(inst); - // TODO 指令中根据起始点位驱动类型判断空满 - String start_device_code = inst.getStart_device_code(); - log.warn("起点设备为:{}",start_device_code); - String next_device_code = inst.getNext_device_code(); - log.warn("终点设备为:{}",next_device_code); - Device start_device = deviceAppservice.findDeviceByCode(start_device_code); - Device next_device = deviceAppservice.findDeviceByCode(next_device_code); - if (start_device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver){ - writing("to_cache_write", "2"); - this.setMaterial(inst.getMaterial()); - next_device.setMaterial_type(inst.getMaterial()); - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "起点位置刻字机,缓存位解锁成功"); - } - if (start_device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver){ - writing("to_cache_write", "1"); - this.setMaterial(""); - next_device.setMaterial_type(""); - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "起点位置包装机,缓存位解锁成功"); - } - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,inst为空"); - - } - } - } - last_move = move ;//光电信号 - last_mode = mode ;//光电信号 - } - - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.setRequireSucess(false); - this.setApplySucess(false); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - } - - public void writing(int type, int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - logServer.deviceLogToacs(this.device_code,"","","下发信号:" + key + ",value:"+value); - ReadUtil.write(itemMap, server); - } - - public boolean instruction_apply() throws Exception { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("1"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() throws Exception { - return false; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/ItemProtocol.java deleted file mode 100644 index 6b7c1a4..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_cache/ItemProtocol.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache; - -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_move = "move";//光电信号 - public static String item_mode = "mode";//模式 - - // - public static String item_to_cache_write = "to_cache_write"; - - - - private HailiangEngravingCacheDeviceDriver driver; - - public ItemProtocol(HailiangEngravingCacheDeviceDriver driver) { - this.driver = driver; - } - - - public int getItem_heartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - public int getItem_move() { - return this.getOpcIntegerValue(item_move); - } - public int getItem_mode() { - return this.getOpcIntegerValue(item_mode); - } - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_move, "光电信号", "DB1.W22")); - list.add(new ItemDto(item_mode, "模式", "DB1.B0.6")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_cache_write, "刻字缓存写", "DB2.W22")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/HailiangEngravingMachineDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/HailiangEngravingMachineDefination.java deleted file mode 100644 index a8f4088..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/HailiangEngravingMachineDefination.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮刻字机工位 - */ -@Service -public class HailiangEngravingMachineDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_engraving_machine"; - } - - @Override - public String getDriverName() { - return "海亮-刻字机工位"; - } - - @Override - public String getDriverDescription() { - return "海亮-刻字机工位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangEngravingMachineDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangEngravingMachineDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/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 deleted file mode 100644 index b7b6b67..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/HailiangEngravingMachineDeviceDriver.java +++ /dev/null @@ -1,787 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.basedriver.hailiang_one.hailiang_engraving_cache.HailiangEngravingCacheDeviceDriver; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.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.WcsConfig; -import org.nl.acs.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -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.exception.BadRequestException; -import org.nl.modules.system.util.CodeUtil; -import org.nl.start.auto.run.OneNDCSocketConnectionAutoRun; -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 org.springframework.util.unit.DataUnit; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 海亮刻字机工位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @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 - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.class); - String container; - - int status = 0;//线体状态 - int is_open = 0;//线体开机状态 - int is_running = 0;//刻字机运行状态 - int empty_req = 0;//空箱请求 - int move = 0;//有货 - int full_req = 0;//满箱请求 - int full_finish = 0;//满箱完成 - int order_finish = 0;//订单完成 - int engraving_prepare = 0;//刻字机准备 - int engraving_ready = 0;//刻字机就绪 - int line_ready = 0;//线体就绪 - int mode = 0;//模式 所有设备就绪 - int error = 0; //报警信号 - int order_now = 0; //订单实时 - int one_now = 0; //每框实时 - int task = 0; //任务号 - int port_full_num = 0; //出料口满框数量 - int lettering_silo_number = 0; //刻字机储料仓数量 - int open_ready_time = 0; //开机准备时间(S) - int device_running_time = 0; //设备运转时间(S) - int await_time = 0; //待机时间(S) - int order = 0; //工单号 - - //出入库模式 - int operation_type = 0; - int last_status = 0;//线体状态 - int last_is_open = 0;//线体开机状态 - int last_is_running = 0;//刻字机运行状态 - int last_empty_req = 0;//空箱请求 - int last_move = 0;//有货 - int last_full_req = 0;//满箱请求 - int last_full_finish = 0;//满箱完成 - int last_order_finish = 0;//订单完成 - int last_engraving_prepare = 0;//刻字机准备 - int last_engraving_ready = 0;//刻字机就绪 - int last_line_ready = 0;//线体就绪 - int last_mode = 0;//模式 所有设备就绪 - int last_error = 0; //报警信号 - int last_order_now = 0; //订单实时 - int last_one_now = 0; //每框实时 - int last_task = 0; //任务号 - int last_port_full_num = 0; //出料口满框数量 - int last_lettering_silo_number = 0; //刻字机储料仓数量 - int last_open_ready_time = 0; //开机准备时间(S) - int last_device_running_time = 0; //设备运转时间(S) - int last_await_time = 0; //待机时间(S) - int last_order = 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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - int agvphase = 0; - int index = 0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getItem_mode();//模式 所有设备就绪 - status = this.itemProtocol.getItem_status();//线体状态 - is_open = this.itemProtocol.getItem_is_open();//线体开机状态 - is_running = this.itemProtocol.getItem_is_running();//刻字机运行状态 - empty_req = this.itemProtocol.getItem_empty_req();//空箱请求 - move = this.itemProtocol.getItem_move();//有货 - full_req = this.itemProtocol.getItem_full_req();//满箱请求 - full_finish = this.itemProtocol.getItem_full_finish();//满箱完成 - order_finish = this.itemProtocol.getItem_order_finish();//订单完成 - engraving_prepare = this.itemProtocol.getItem_engraving_prepare();//刻字机准备 - engraving_ready = this.itemProtocol.getItem_engraving_ready();//刻字机就绪 - line_ready = this.itemProtocol.getItem_line_ready();//线体就绪 - error = this.itemProtocol.getItem_error(); //报警信号 - order_now = this.itemProtocol.getItem_order_now(); //订单实时 - one_now = this.itemProtocol.getItem_one_now(); //每框实时 - task = this.itemProtocol.getItem_task(); //任务号 - port_full_num = this.itemProtocol.getItem_port_full_num(); //出料口满框数量 - lettering_silo_number = this.itemProtocol.getItem_lettering_silo_number(); //刻字机储料仓数量 - open_ready_time = this.itemProtocol.getItem_open_ready_time(); //开机准备时间(S) - device_running_time = this.itemProtocol.getItem_device_running_time(); //设备运转时间(S) - await_time = this.itemProtocol.getItem_await_time(); //待机时间(S) - order = this.itemProtocol.getItem_order(); //工单号 - if (mode != last_mode) { - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - thingToNothing(); - this.setRequireSucess(false); - logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); - logServer.deviceLogToacs(this.device_code,"","","信号move(取反):" + last_move + "->" + move); - } - if (status != last_status) { - logServer.deviceLog(this.device_code,"status" ,String.valueOf(status)); - logServer.deviceLogToacs(this.device_code,"","","信号status:" + last_status + "->" + status); - } - if (is_open != last_is_open) { - logServer.deviceLog(this.device_code,"is_open" ,String.valueOf(is_open)); - logServer.deviceLogToacs(this.device_code,"","","信号is_open:" + last_is_open + "->" + is_open); - } - if (is_running != last_is_running) { - logServer.deviceLog(this.device_code,"is_running" ,String.valueOf(is_running)); - logServer.deviceLogToacs(this.device_code,"","","信号is_running:" + last_is_running + "->" + is_running); - } - if (empty_req != last_empty_req) { - logServer.deviceLog(this.device_code,"empty_req" ,String.valueOf(empty_req)); - logServer.deviceLogToacs(this.device_code,"","","信号empty_req:" + last_empty_req + "->" + empty_req); - } - if (full_req != last_full_req) { - logServer.deviceLog(this.device_code,"full_req" ,String.valueOf(full_req)); - logServer.deviceLogToacs(this.device_code,"","","信号full_req:" + last_full_req + "->" + full_req); - } - if (full_finish != last_full_finish) { - logServer.deviceLog(this.device_code,"full_finish" ,String.valueOf(full_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号full_finish:" + last_full_finish + "->" + full_finish); - } - if (order_finish != last_order_finish) { - logServer.deviceLog(this.device_code,"order_finish" ,String.valueOf(order_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号order_finish:" + last_order_finish + "->" + order_finish); - } - if (engraving_prepare != last_engraving_prepare) { - logServer.deviceLog(this.device_code,"engraving_prepare" ,String.valueOf(engraving_prepare)); - logServer.deviceLogToacs(this.device_code,"","","信号engraving_prepare:" + last_engraving_prepare + "->" + engraving_prepare); - } - if (engraving_ready != last_engraving_ready) { - logServer.deviceLog(this.device_code,"engraving_ready" ,String.valueOf(engraving_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号engraving_ready:" + last_engraving_ready + "->" + engraving_ready); - } - if (line_ready != last_line_ready) { - logServer.deviceLog(this.device_code,"line_ready" ,String.valueOf(line_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号line_ready:" + last_line_ready + "->" + line_ready); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - 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); - } - 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); - } - if (task != last_task) { - logServer.deviceLog(this.device_code,"task" ,String.valueOf(task)); - logServer.deviceLogToacs(this.device_code,"","","信号task:" + last_task + "->" + task); - } - if (port_full_num != last_port_full_num) { - logServer.deviceLog(this.device_code,"port_full_num" ,String.valueOf(port_full_num)); - logServer.deviceLogToacs(this.device_code,"","","信号port_full_num:" + last_port_full_num + "->" + port_full_num); - } - if (lettering_silo_number != last_lettering_silo_number) { - logServer.deviceLog(this.device_code,"lettering_silo_number" ,String.valueOf(lettering_silo_number)); - logServer.deviceLogToacs(this.device_code,"","","信号lettering_silo_number:" + last_lettering_silo_number + "->" + lettering_silo_number); - } - if (open_ready_time != last_open_ready_time) { - logServer.deviceLog(this.device_code,"open_ready_time" ,String.valueOf(open_ready_time)); - } - if (device_running_time != last_device_running_time) { - logServer.deviceLog(this.device_code,"device_running_time" ,String.valueOf(device_running_time)); - } - if (await_time != last_await_time) { - logServer.deviceLog(this.device_code,"await_time" ,String.valueOf(await_time)); - } - if (order != last_order) { - logServer.deviceLog(this.device_code,"order" ,String.valueOf(order)); - logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order); - } - - /* if (mode == 2 && move != 0 && task > 0) { - - }*/ - } 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); - - if ( mode == 1 && order_finish == 1 && order > 0){ - ProduceshiftorderDto dto = new ProduceshiftorderDto(); - dto.setOrder_code(order + ""); - dto.setOrder_status("2"); - ProduceshiftorderDto deviceInfo = produceshiftorderService.findOrderByDeviceCode(this.device_code); - if(deviceInfo != null){ - if (StrUtil.isNotEmpty(deviceInfo.getExt_order_id())) { - String ext_order_id = deviceInfo.getExt_order_id(); - JSONObject param = new JSONObject(); - param.put("ext_order_id",ext_order_id); - acsToWmsService.feedbackOrderStatus(param); - logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单的外部标识:"+ext_order_id); - }else { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单的没有外部标识"); - } - }else { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单信息为空"); - } - produceshiftorderService.updateByOrderCode(dto); - this.writing("to_confirm_finished","1"); - this.writing("to_clear","1"); - this.writing("to_pause","1"); - logServer.deviceLogToacs(this.device_code,"","",device_code+":,任务确认完成,电器信号写入成功"); - }else { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,move:"+move + ",order_finish>"+ order_finish +",last_order_finish>"+last_order_finish); - } - - if(!requireSucess){ -// if ( move == 1 && mode == 1 && order > 0 && full_number>0 ) { - - if ( move == 1 && mode == 1 && full_req == 1 ) { -// if ( full_req == 1 ) { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,move:"+move+",requireSucess:" + requireSucess + "开始申请任务"); - - apply_task(); - } else { - logServer.deviceLogToacs(this.device_code,"","","不满足下发满框请求任务条件,mode:"+mode+"move:"+move+"full_req:"+full_req); - - } - - if (move == 0 && mode == 1 && empty_req == 1){ -// if (empty_req == 1) { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,move:"+move+",requireSucess:" + requireSucess + "开始申请空箱请求任务"); - apply_empty_task(); - }else { - logServer.deviceLogToacs(this.device_code,"","","不满足下发空框请求任务条件,mode:"+mode+"move:"+move+"empty_req:"+empty_req); - - } - - }else { - logServer.deviceLogToacs(this.device_code,"","","是否请求成功:requireSucess:"+requireSucess); - } - - if(agvphase == 0x03) - { - if(ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("1"); - instructionService.update(inst); - //writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,inst为空"); - - } - } - - if(agvphase == 0x05){ - if(ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("2"); - instructionService.update(inst); - writing("to_cache_write", "0"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,inst为空"); - - } - } - - if(agvphase == 0x07){ - if(ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("5"); - instructionService.update(inst); - //writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,inst为空"); - } - } - - if(agvphase == 0x09){ - if(ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("6"); - instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,inst为空"); - - } - } - - - } - last_status = status;//线体状态 - last_is_open = is_open;//线体开机状态 - last_is_running = is_running;//刻字机运行状态 - last_empty_req = empty_req;//空箱请求 - last_move = move;//有货 - last_full_req = full_req;//满箱请求 - last_full_finish = full_finish;//满箱完成 - last_order_finish = order_finish;//订单完成 - last_engraving_prepare = engraving_prepare;//刻字机准备 - last_engraving_ready = engraving_ready;//刻字机就绪 - last_line_ready = line_ready;//线体就绪 - last_mode = mode;//模式 所有设备就绪 - last_error = error; //报警信号 - last_order_now = order_now; //订单实时 - last_one_now = one_now; //每框实时 - last_task = task; //任务号 - last_port_full_num = port_full_num; //出料口满框数量 - last_lettering_silo_number = lettering_silo_number; //刻字机储料仓数量 - last_open_ready_time = open_ready_time; //开机准备时间(S) - last_device_running_time = device_running_time; //设备运转时间(S) - last_await_time = await_time; //待机时间(S) - last_order = order; //工单号 - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.setRequireSucess(false); - this.setApplySucess(false); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - public synchronized boolean apply_empty_task() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - Boolean flag = false; - List list = routeLineService.getPathLinesByCode(this.device_code, "normal"); - if (ObjectUtil.isEmpty(list)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":未找到对应路由"); - throw new BadRequestException(this.device_code + ":未找到对应路由"); - } - HailiangEngravingCacheDeviceDriver hailiangEngravingCacheDeviceDriver; - for (int i = 0; i < list.size(); i++) { - RouteLineDto dto = list.get(i); - String start_device_code = dto.getDevice_code(); - Device route_link_device = deviceAppservice.findDeviceByCode(start_device_code); - if (route_link_device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) route_link_device.getDeviceDriver(); - if (hailiangEngravingCacheDeviceDriver.getMove() != 1){ - continue; - } - int num = taskserver.querySameOriginTask(start_device_code); - if(num != 0){ - continue; - } - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - //onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_type("7"); - onedto.setTask_status("0"); - onedto.setPriority("1"); - onedto.setStart_device_code(start_device_code); - onedto.setStart_point_code(start_device_code); - onedto.setNext_device_code(this.getDevice().getDevice_code()); - onedto.setNext_point_code(this.getDevice().getDevice_code()); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - - try { - taskserver.create(onedto); - flag = true; - break; - } catch (Exception e) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务成功"); - } - } - //生成任务成功 - if (flag) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":专机生成任务成功"); - requireSucess = true; - } else { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":条件不满足未找到起点设备"); - } - } - return true; - } - - public synchronized boolean apply_task() throws Exception { - WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint"); - - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - Boolean flag = false; - List list = routeLineService.getShortPathLinesByCode(this.device_code, "normal"); - if (ObjectUtil.isEmpty(list)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":未找到对应路由"); - throw new BadRequestException(this.device_code + ":未找到对应路由"); - } - String link_device = this.getDevice().getExtraValue().get("link_device_code").toString(); - ProduceshiftorderDto order = produceshiftorderService.findOrderByDeviceCode(link_device); - if (ObjectUtil.isEmpty(order)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":关联设备" + link_device + "未找到对应设备工单"); - throw new BadRequestException(this.device_code + ":关联设备" + link_device + "未找到对应设备工单"); - } - if (order.getIs_needmove().equals("0")){ - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":关联设备" + link_device + "工单,不需要agv搬运"); - return false; - } - //查找当前工单对应的物料编号 - String cpbh = order.getMaterial_code(); - - HailiangEngravingCacheDeviceDriver hailiangEngravingCacheDeviceDriver; - for (int i = 0; i < list.size(); i++) { - RouteLineDto dto = list.get(i); - String next_device_code = dto.getNext_device_code(); - Device route_link_device = deviceAppservice.findDeviceByCode(next_device_code); - - if (route_link_device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) route_link_device.getDeviceDriver(); - if (hailiangEngravingCacheDeviceDriver.getMove() != 0){ - continue; - } - int num = taskserver.querySameDestinationTask(next_device_code); - if(num != 0){ - continue; - } - //判断缓存位是否锁定 - JSONObject jsonObject = runpointwo.query("device_code = '" + next_device_code + "' and islock = '1'").uniqueResult(0); - if (ObjectUtil.isNotEmpty(jsonObject)){ - continue; - } - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - //onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_type("6"); - onedto.setTask_status("0"); - onedto.setPriority("1"); - onedto.setMaterial(cpbh); - // TODO 任务中物料数量要不要赋值 - onedto.setQuantity(order.getQty() + ""); - onedto.setStart_device_code(this.getDevice().getDevice_code()); - onedto.setStart_point_code(this.getDevice().getDevice_code()); - onedto.setNext_device_code(next_device_code); - onedto.setNext_point_code(next_device_code); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - try { - taskserver.create(onedto); - //任务创建成功 锁定 - JSONObject map = new JSONObject(); - map.put("islock","1"); - map.put("update_by","auto"); - map.put("update_time", DateUtil.now()); - runpointwo.update(map,"device_code = '" + next_device_code + "'"); - flag = true; - break; - } catch (Exception e) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务成功"); - } - } - //生成任务成功 - if (flag) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":刻字机满料请求任务生成成功"); - requireSucess = true; - } else { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":条件不满足未找到起点设备"); - } - } - return true; - } - - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - } - - public void writing(int type, int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - logServer.deviceLogToacs(this.device_code,"","","下发信号:" + key + ",value:"+value); - ReadUtil.write(itemMap, server); - } - - public boolean instruction_apply() throws Exception { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() throws Exception { - return false; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/ItemProtocol.java deleted file mode 100644 index d39ad32..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_engraving_machine/ItemProtocol.java +++ /dev/null @@ -1,228 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine; - -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_status = "status";//线体状态 - public static String item_is_open = "is_open";//线体开机状态 - public static String item_is_running = "is_running";//刻字机运行状态 - public static String item_empty_req = "empty_req";//空箱请求 - public static String item_move = "move";//有货 - public static String item_full_req = "full_req";//满箱请求 - public static String item_full_finish = "full_finish";//满箱完成 - public static String item_order_finish = "order_finish";//订单完成 - public static String item_engraving_prepare = "engraving_prepare";//刻字机准备 - public static String item_engraving_ready = "engraving_ready";//刻字机就绪 - public static String item_line_ready = "line_ready";//线体就绪 - public static String item_mode = "mode";//模式 所有设备就绪 - public static String item_error = "error"; //报警信号 - public static String item_order_now = "order_now"; //订单实时 - public static String item_one_now = "one_now"; //每框实时 - public static String item_task = "task"; //任务号 - public static String item_port_full_num = "port_full_num"; //出料口满框数量 - public static String item_lettering_silo_number = "lettering_silo_number"; //刻字机储料仓数量 - public static String item_open_ready_time = "open_ready_time"; //开机准备时间(S) - public static String item_device_running_time = "device_running_time"; //设备运转时间(S) - public static String item_await_time = "await_time"; //待机时间(S) - public static String item_order = "order"; //工单号 - - //开机 - public static String item_to_open = "to_open"; - //AGV放空箱完成 - public static String item_to_agv_empty_finish = "to_agv_empty_finish"; - //刻字信息 - public static String item_to_engraving_info = "to_engraving_info"; - //产量清零 - public static String item_to_clear = "to_clear"; - //确认完成(订单完成状态置零) - public static String item_to_confirm_finished = "to_confirm_finished"; - //暂停 - public static String item_to_pause = "to_pause"; - //工单强制完成 - public static String item_to_order_compel_finished = "to_order_compel_finished"; - //订单生产总量 - public static String item_to_order_prod_num = "to_order_prod_num"; - //每框接料数量 - public static String item_to_one_box_num = "to_one_box_num"; - //任务号 - public static String item_to_task = "to_task"; - //刻字机倒料数量 - public static String item_to_dumping_num = "to_to_dumping_num"; - //工单号 - public static String item_to_order = "to_order"; - - - private HailiangEngravingMachineDeviceDriver driver; - - public ItemProtocol(HailiangEngravingMachineDeviceDriver driver) { - this.driver = driver; - } - - - public int getItem_heartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getItem_status() { - return this.getOpcIntegerValue(item_status); - } - - public int getItem_is_open() { - return this.getOpcIntegerValue(item_is_open); - } - - public int getItem_is_running() { - return this.getOpcIntegerValue(item_is_running); - } - - public int getItem_empty_req() { - return this.getOpcIntegerValue(item_empty_req); - } - - public int getItem_move() { - return this.getOpcIntegerValue(item_move); - } - - public int getItem_full_req() { - return this.getOpcIntegerValue(item_full_req); - } - - public int getItem_full_finish() { - return this.getOpcIntegerValue(item_full_finish); - } - - public int getItem_order_finish() { - return this.getOpcIntegerValue(item_order_finish); - } - - public int getItem_engraving_prepare() { - return this.getOpcIntegerValue(item_engraving_prepare); - } - - public int getItem_engraving_ready() { - return this.getOpcIntegerValue(item_engraving_ready); - } - - public int getItem_line_ready() { - return this.getOpcIntegerValue(item_line_ready); - } - - public int getItem_mode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getItem_error() { - return this.getOpcIntegerValue(item_error); - } - - public int getItem_order_now() { - return this.getOpcIntegerValue(item_order_now); - } - - public int getItem_one_now() { - return this.getOpcIntegerValue(item_one_now); - } - - public int getItem_task() { - return this.getOpcIntegerValue(item_task); - } - - public int getItem_port_full_num() { - return this.getOpcIntegerValue(item_port_full_num); - } - - public int getItem_lettering_silo_number() { - return this.getOpcIntegerValue(item_lettering_silo_number); - } - - public int getItem_open_ready_time() { - return this.getOpcIntegerValue(item_open_ready_time); - } - - public int getItem_device_running_time() { - return this.getOpcIntegerValue(item_device_running_time); - } - - public int getItem_await_time() { - return this.getOpcIntegerValue(item_await_time); - } - - public int getItem_order() { - return this.getOpcIntegerValue(item_order); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_status, "线体状态", "DB1.B0.0")); - list.add(new ItemDto(item_is_open, "线体开机状态", "DB1.B0.1")); - list.add(new ItemDto(item_is_running, "刻字机运行状态", "DB1.B0.3")); - list.add(new ItemDto(item_empty_req, "空箱请求", "DB1.B0.5")); - list.add(new ItemDto(item_move, "光电信号", "DB1.B0.7")); - list.add(new ItemDto(item_full_req, "满箱请求", "DB1.B1.0")); - list.add(new ItemDto(item_full_finish, "满箱完成", "DB1.B1.1")); - list.add(new ItemDto(item_order_finish, "订单完成", "DB1.B1.2")); - list.add(new ItemDto(item_engraving_prepare, "刻字机准备", "DB1.B1.3")); - list.add(new ItemDto(item_engraving_ready, "刻字机就绪", "DB1.B1.4")); - list.add(new ItemDto(item_line_ready, "线体就绪", "DB1.B1.5")); - list.add(new ItemDto(item_mode, "模式", "DB1.B1.6")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W4")); - list.add(new ItemDto(item_order_now, "订单实时", "DB1.D84")); - list.add(new ItemDto(item_one_now, "每框实时", "DB1.D88")); - list.add(new ItemDto(item_task, "任务号", "DB1.D92")); - list.add(new ItemDto(item_port_full_num, "出料口满框数量", "DB1.D96")); - list.add(new ItemDto(item_lettering_silo_number, "刻字机储料仓数量", "DB1.D100")); - list.add(new ItemDto(item_open_ready_time, "开机准备时间", "DB1.D108")); - list.add(new ItemDto(item_device_running_time, "设备运转时间", "DB1.D112")); - list.add(new ItemDto(item_await_time, "待机时间", "DB1.D116")); - list.add(new ItemDto(item_order, "工单号", "DB1.D160")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_open, "设备开关", "DB2.W4", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_agv_empty_finish, "AGV放空箱完成", "DB2.W8")); - list.add(new ItemDto(item_to_engraving_info, "刻字信息", "DB2.W10")); - list.add(new ItemDto(item_to_clear, "当前产量清零", "DB2.W12")); - list.add(new ItemDto(item_to_confirm_finished, "确认完成", "DB2.W14")); - list.add(new ItemDto(item_to_pause, "暂停", "DB2.W16")); - list.add(new ItemDto(item_to_order_compel_finished, "工单强制完成", "DB2.W82")); - list.add(new ItemDto(item_to_order_prod_num, "订单生产总量", "DB2.D84")); - list.add(new ItemDto(item_to_one_box_num, "每箱接料数量", "DB2.D88")); - list.add(new ItemDto(item_to_task, "任务号", "DB2.D92")); - list.add(new ItemDto(item_to_dumping_num, "刻字机倒料数量", "DB2.D100")); - list.add(new ItemDto(item_to_order, "工单号", "DB2.D160")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/HailiangPackerStationDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/HailiangPackerStationDefination.java deleted file mode 100644 index b72ab03..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/HailiangPackerStationDefination.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮包装机工位 - */ -@Service -public class HailiangPackerStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_packer_station"; - } - - @Override - public String getDriverName() { - return "海亮-包装机工位"; - } - - @Override - public String getDriverDescription() { - return "海亮-包装机工位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangPackerStationDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangPackerStationDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/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 deleted file mode 100644 index 828d663..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/HailiangPackerStationDeviceDriver.java +++ /dev/null @@ -1,715 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.basedriver.hailiang_one.hailiang_engraving_cache.HailiangEngravingCacheDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.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.WcsConfig; -import org.nl.acs.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -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.exception.BadRequestException; -import org.nl.modules.system.util.CodeUtil; -import org.nl.start.auto.run.OneNDCSocketConnectionAutoRun; -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; - -/** - * 海亮包装机工位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @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 - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.class); - - String container; - - int packer_ready = 0;//包装机就绪 - int mode = 0;//模式 所有设备就绪 - int move = 0;//有货 - int order_finish = 0;//订单完成 - int lack_req = 0;//缺料请求 - int hopper_already = 0;//料斗已就位 - int req_task_empty = 0;//请求取空料斗 - int hopper_removed = 0;//料斗已取走 - int error = 0; //报警信号 - int order_now = 0; //订单实时 - int open_ready_time = 0; //开机准备时间(S) - int device_running_time = 0; //设备运转时间(S) - int await_time = 0; //待机时间(S) - int order = 0; //工单号 - //出入库模式 - int operation_type = 0; - int last_packer_ready = 0;//包装机就绪 - int last_mode = 0;//模式 所有设备就绪 - int last_move = 0;//有货 - int last_order_finish = 0;//订单完成 - int last_lack_req = 0;//缺料请求 - int last_hopper_already = 0;//料斗已就位 - int last_req_task_empty = 0;//请求取空料斗 - int last_hopper_removed = 0;//料斗已取走 - int last_error = 0; //报警信号 - int last_order_now = 0; //订单实时 - int last_open_ready_time = 0; //开机准备时间(S) - int last_device_running_time = 0; //设备运转时间(S) - int last_await_time = 0; //待机时间(S) - int last_order = 0; //工单号 - - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - Boolean fullrequireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - String device_code; - - int agvphase = 0; - int index = 0; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - packer_ready = this.itemProtocol.getItem_packer_ready();//包装机就绪 - lack_req = this.itemProtocol.getItem_lack_req();//缺料请求 - hopper_already = this.itemProtocol.getItem_hopper_already();//料斗已就位 - req_task_empty = this.itemProtocol.getItem_req_task_empty();//请求取空料斗 - hopper_removed = this.itemProtocol.getItem_hopper_removed();//料斗已取走 - mode = this.itemProtocol.getItem_mode();//模式 所有设备就绪 - move = this.itemProtocol.getItem_move();//有货 - order_finish = this.itemProtocol.getItem_order_finish();//订单完成 - error = this.itemProtocol.getItem_error(); //报警信号 - order_now = this.itemProtocol.getItem_order_now(); //订单实时 - open_ready_time = this.itemProtocol.getItem_open_ready_time(); //开机准备时间(S) - device_running_time = this.itemProtocol.getItem_device_running_time(); //设备运转时间(S) - await_time = this.itemProtocol.getItem_await_time(); //待机时间(S) - order = this.itemProtocol.getItem_order(); //工单号 - if (mode != last_mode) { - 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 (packer_ready != last_packer_ready) { - 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 == 0) { - this.setRequireSucess(false); - } - logServer.deviceLog(this.device_code, "lack_req", String.valueOf(lack_req)); - logServer.deviceLogToacs(this.device_code, "", "", "信号lack_req:" + last_lack_req + "->" + lack_req); - } - if (hopper_already != last_hopper_already) { - logServer.deviceLog(this.device_code, "hopper_already", String.valueOf(hopper_already)); - logServer.deviceLogToacs(this.device_code, "", "", "信号hopper_already:" + last_hopper_already + "->" + hopper_already); - } - if (req_task_empty != last_req_task_empty) { - if (req_task_empty == 0) { - this.setFullrequireSucess(false); - } - logServer.deviceLog(this.device_code, "req_task_empty", String.valueOf(req_task_empty)); - logServer.deviceLogToacs(this.device_code, "", "", "信号req_task_empty:" + last_req_task_empty + "->" + req_task_empty); - } - if (hopper_removed != last_hopper_removed) { - logServer.deviceLog(this.device_code, "hopper_removed", String.valueOf(hopper_removed)); - logServer.deviceLogToacs(this.device_code, "", "", "信号hopper_removed:" + last_hopper_removed + "->" + hopper_removed); - } - - if (order_finish != last_order_finish) { - logServer.deviceLog(this.device_code, "order_finish", String.valueOf(order_finish)); - logServer.deviceLogToacs(this.device_code, "", "", "信号order_finish:" + last_order_finish + "->" + order_finish); - } - - if (error != last_error) { - logServer.deviceLog(this.device_code, "error", String.valueOf(error)); - logServer.deviceLogToacs(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - 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); - } - -/* if (open_ready_time != last_open_ready_time) { - logServer.deviceLog(this.device_code, "open_ready_time", String.valueOf(open_ready_time)); - logServer.deviceLogToacs(this.device_code, "", "", "信号open_ready_time:" + last_open_ready_time + "->" + open_ready_time); - }*/ -/* if (device_running_time != last_device_running_time) { - logServer.deviceLog(this.device_code, "device_running_time", String.valueOf(device_running_time)); - logServer.deviceLogToacs(this.device_code, "", "", "信号device_running_time:" + last_device_running_time + "->" + device_running_time); - }*/ - if (await_time != last_await_time) { - logServer.deviceLog(this.device_code, "await_time", String.valueOf(await_time)); - logServer.deviceLogToacs(this.device_code, "", "", "信号await_time:" + last_await_time + "->" + await_time); - } - if (order != last_order) { - logServer.deviceLog(this.device_code, "order", String.valueOf(order)); - logServer.deviceLogToacs(this.device_code, "", "", "信号order:" + last_order + "->" + order); - } - - /* if (mode == 2 && move != 0 && task > 0) { - - }*/ - } 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; - - if (mode == 1 && order_finish != last_order_finish && order_finish == 1 && order > 0) { - ProduceshiftorderDto dto = new ProduceshiftorderDto(); - dto.setOrder_code(order + ""); - dto.setOrder_status("2"); - ProduceshiftorderDto deviceInfo = produceshiftorderService.findOrderByDeviceCode(this.device_code); - if (deviceInfo != null) { - if (StrUtil.isNotEmpty(deviceInfo.getExt_order_id())) { - String ext_order_id = deviceInfo.getExt_order_id(); - JSONObject param = new JSONObject(); - param.put("ext_order_id", ext_order_id); - acsToWmsService.feedbackOrderStatus(param); - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":,对应的工单的外部标识:" + ext_order_id); - } else { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":,对应的工单的没有外部标识"); - } - } else { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":,对应的工单信息为空"); - } - produceshiftorderService.updateByOrderCode(dto); - this.writing("to_confirm_finished", "1"); - this.writing("to_clear", "1"); - this.writing("to_pause", "1"); - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":,任务确认完成,电器信号写入成功"); - } - - if (ObjectUtil.isEmpty(inst)) { - if (!requireSucess) { - if (mode == 1 && lack_req == 1 && move == 0) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":,move:" + move + ",mode:" + mode + ",requireSucess:" + requireSucess + "开始申请缺料请求任务"); - apply_task(); - } - } - 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(); - } - } - } - - - if (agvphase == 0x03) { - //&& lack_req =1 缺料请求 先不判断 - /*if( move == 1 && error == 0 && ObjectUtil.isNotEmpty(inst)){*/ - inst.setExecute_status("1"); - instructionService.update(inst); - //writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功"); - /* } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因move:"+move+",error:"+error+",inst"+inst); - - }*/ - } - - if (agvphase == 0x05) { - if (move == 0 && error == 0 && ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("2"); - instructionService.update(inst); - //writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - writing("to_agv_take_finish", "1"); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈,原因move:" + move + ",error:" + error + ",inst" + inst); - } - } - - if (agvphase == 0x07) { - if (move == 0 && error == 0 && ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("5"); - instructionService.update(inst); - //writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈,原因move:" + move + ",error:" + error + ",inst" + inst); - - } - } - - if (agvphase == 0x09) { - if (move == 1 && error == 0 && ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("6"); - instructionService.update(inst); - writing("to_agv_release_finish", "1"); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0); - OneNDCSocketConnectionAutoRun.write(data); - String next_device_code = inst.getNext_device_code(); - Device next_device = deviceAppservice.findDeviceByCode(next_device_code); - next_device.setMaterial_type(inst.getMaterial()); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈,move:" + move + ",error:" + error + ",inst:" + inst); - - } - } - } - last_packer_ready = packer_ready;//包装机就绪 - last_lack_req = lack_req;//缺料请求 - last_hopper_already = hopper_already;//料斗已就位 - last_req_task_empty = req_task_empty;//请求取空料斗 - last_hopper_removed = hopper_removed;//料斗已取走 - last_move = move;//有货 - last_order_finish = order_finish;//订单完成 - last_mode = mode;//模式 所有设备就绪 - last_error = error; //报警信号 - last_order_now = order_now; //订单实时 - last_open_ready_time = open_ready_time; //开机准备时间(S) - last_device_running_time = device_running_time; //设备运转时间(S) - last_await_time = await_time; //待机时间(S) - last_order = order; //工单号 - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public synchronized boolean apply_take_empty_task() throws Exception { - WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint"); - - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - Boolean flag = false; - List list = routeLineService.getShortPathLinesByCode(this.device_code, "normal"); - if (ObjectUtil.isEmpty(list)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":未找到对应路由"); - throw new BadRequestException(this.device_code + ":未找到对应路由"); - } - String link_device = this.getDevice().getExtraValue().get("link_device_code").toString(); - ProduceshiftorderDto order = produceshiftorderService.findOrderByDeviceCode(link_device); - if (ObjectUtil.isEmpty(order)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":关联设备" + link_device + "未找到对应设备工单"); - throw new BadRequestException(this.device_code + ":关联设备" + link_device + "未找到对应设备工单"); - } - HailiangEngravingCacheDeviceDriver hailiangEngravingCacheDeviceDriver; - for (int i = 0; i < list.size(); i++) { - RouteLineDto dto = list.get(i); - String next_device_code = dto.getNext_device_code(); - Device route_link_device = deviceAppservice.findDeviceByCode(next_device_code); - if (route_link_device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) route_link_device.getDeviceDriver(); - if (hailiangEngravingCacheDeviceDriver.getMove() != 0) { - continue; - } - //querySameDestinationTask 查询是否有相同终点的任务 - int num = taskserver.querySameDestinationTask(next_device_code); - int numE = taskserver.querySameOriginTask(this.getDevice_code()); - if (num != 0 || numE != 0) { - continue; - } - //判断缓存位是否锁定 - JSONObject jsonObject = runpointwo.query("device_code = '" + next_device_code + "' and islock = '1'").uniqueResult(0); - if (ObjectUtil.isNotEmpty(jsonObject)) { - logServer.deviceLogToacs(this.device_code, "", "", "对应路由设备," + next_device_code + "已锁定"); - continue; - } - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - //onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_type("7"); - onedto.setTask_status("0"); - onedto.setPriority("1"); - onedto.setStart_device_code(this.getDevice().getDevice_code()); - onedto.setStart_point_code(this.getDevice().getDevice_code()); - onedto.setNext_device_code(next_device_code); - onedto.setNext_point_code(next_device_code); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - try { - taskserver.create(onedto); - //任务创建成功 锁定 - JSONObject map = new JSONObject(); - map.put("islock", "1"); - map.put("update_by", "auto"); - map.put("update_time", DateUtil.now()); - runpointwo.update(map, "device_code = '" + next_device_code + "'"); - flag = true; - break; - } catch (Exception e) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - } - } - //生成任务成功 - if (flag) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":取走空料斗任务创建成功"); - fullrequireSucess = true; - } else { - //如果都没有则调用mes接口申请入缓存线 - //生成任务 - //前往缓存线 - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":分配任务缓存线"); - } - } - return true; - } - - public synchronized boolean apply_task() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - Boolean flag = false; - List list = routeLineService.getPathLinesByCode(this.device_code, "normal"); - if (ObjectUtil.isEmpty(list)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":未找到对应路由"); - throw new BadRequestException(this.device_code + ":未找到对应路由"); - } - String link_device = this.getDevice().getExtraValue().get("link_device_code").toString(); - ProduceshiftorderDto order = produceshiftorderService.findOrderByDeviceCode(link_device); - if (ObjectUtil.isEmpty(order)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":关联设备" + link_device + "未找到对应设备工单"); - throw new BadRequestException(this.device_code + ":关联设备" + link_device + "未找到对应设备工单"); - } - - if (StrUtil.isNotEmpty(order.getIs_needmove()) && order.getIs_needmove().equals("0")) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":关联设备" + link_device + "工单,不需要agv搬运"); - return false; - } - //查找当前工单对应的物料编号 - String cpbh = order.getMaterial_code(); - - HailiangEngravingCacheDeviceDriver hailiangEngravingCacheDeviceDriver; - for (int i = 0; i < list.size(); i++) { - RouteLineDto dto = list.get(i); - String start_device_code = dto.getDevice_code(); - Device route_link_device = deviceAppservice.findDeviceByCode(start_device_code); - if (route_link_device.getDeviceDriver() instanceof HailiangEngravingCacheDeviceDriver) { - hailiangEngravingCacheDeviceDriver = (HailiangEngravingCacheDeviceDriver) route_link_device.getDeviceDriver(); - if (hailiangEngravingCacheDeviceDriver.getMove() == 0 || hailiangEngravingCacheDeviceDriver.getMove() == 1) { - continue; - } - //querySameOriginTask 查询是否有相同起点的任务 - int num = taskserver.querySameOriginTask(start_device_code); - int numN = taskserver.querySameDestinationTask(this.getDevice_code()); - if (num != 0 || numN != 0) { - continue; - } - String material = route_link_device.getMaterial_type(); - if (StrUtil.isEmpty(material)) { - logServer.deviceLogToacs(this.device_code, "", "", hailiangEngravingCacheDeviceDriver.getDevice_code() + ":缓存位物料为空"); - continue; - } - if (material.equals(cpbh)) { - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - //onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_type("7"); - onedto.setTask_status("0"); - onedto.setPriority("1"); - // TODO 任务中物料数量要不要赋值 - onedto.setQuantity(order.getQty() + ""); - onedto.setStart_device_code(start_device_code); - onedto.setStart_point_code(start_device_code); - onedto.setNext_device_code(this.getDevice().getDevice_code()); - onedto.setNext_point_code(this.getDevice().getDevice_code()); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - try { - taskserver.create(onedto); - flag = true; - break; - } catch (Exception e) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - } - } - } - - //生成任务成功 - if (flag) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":缺料请求任务生成成功"); - requireSucess = true; - } else { - //如果都没有则调用mes接口申请入缓存线 - //生成任务 - //前往缓存线 - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":分配任务缓存线"); - } - } - return true; - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - } - - public void writing(int type, int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - logServer.deviceLogToacs(this.device_code, "", "", "下发信号:" + key + ",value:" + value); - ReadUtil.write(itemMap, server); - } - - public boolean instruction_apply() throws Exception { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("1"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() throws Exception { - return false; - } -} 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 deleted file mode 100644 index 8107c58..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_packer_station/ItemProtocol.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station; - -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_packer_ready = "packer_ready";//包装机就绪 - public static String item_mode = "mode";//模式 所有设备就绪 - public static String item_move = "move";//有货 - public static String item_order_finish = "order_finish";//订单完成 - public static String item_lack_req = "lack_req";//缺料请求 - public static String item_hopper_already = "hopper_already";//料斗已就位 - public static String item_req_task_empty = "req_task_empty";//请求取空料斗 - public static String item_hopper_removed = "hopper_removed";//料斗已取走 - public static String item_error = "error"; //报警信号 - public static String item_order_now = "order_now"; //订单实时 - public static String item_open_ready_time = "open_ready_time"; //开机准备时间(S) - public static String item_device_running_time = "device_running_time"; //设备运转时间(S) - public static String item_await_time = "await_time"; //待机时间(S) - public static String item_order = "order"; //工单号 - - //开机 - public static String item_to_open = "to_open"; - //AGV放货完成 - public static String item_to_agv_release_finish = "to_agv_release_finish"; - //AGV取货完成 - public static String item_to_agv_take_finish = "to_agv_take_finish"; - //产量清零 - public static String item_to_clear = "to_clear"; - //确认完成(订单完成状态置零) - public static String item_to_confirm_finished = "to_confirm_finished"; - //工单强制完成 - public static String item_to_order_compel_finished = "to_order_compel_finished"; - //订单生产总量 - public static String item_to_order_prod_num = "to_order_prod_num"; - //工单号 - public static String item_to_order = "to_order"; - - - private HailiangPackerStationDeviceDriver driver; - - public ItemProtocol(HailiangPackerStationDeviceDriver driver) { - this.driver = driver; - } - - - public int getItem_heartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getItem_move() { - return this.getOpcIntegerValue(item_move); - } - - - public int getItem_order_finish() { - return this.getOpcIntegerValue(item_order_finish); - } - - - public int getItem_mode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getItem_error() { - return this.getOpcIntegerValue(item_error); - } - - public int getItem_order_now() { - return this.getOpcIntegerValue(item_order_now); - } - - - public int getItem_open_ready_time() { - return this.getOpcIntegerValue(item_open_ready_time); - } - - public int getItem_device_running_time() { - return this.getOpcIntegerValue(item_device_running_time); - } - - public int getItem_await_time() { - return this.getOpcIntegerValue(item_await_time); - } - - public int getItem_order() { - return this.getOpcIntegerValue(item_order); - } - - public int getItem_packer_ready() { - return this.getOpcIntegerValue(item_packer_ready); - } - - public int getItem_lack_req() { - return this.getOpcIntegerValue(item_lack_req); - } - - public int getItem_hopper_already() { - return this.getOpcIntegerValue(item_hopper_already); - } - - public int getItem_req_task_empty() { - return this.getOpcIntegerValue(item_req_task_empty); - } - - public int getItem_hopper_removed() { - return this.getOpcIntegerValue(item_hopper_removed); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_packer_ready, "包装机就绪", "DB1.B0.5")); - list.add(new ItemDto(item_mode, "模式", "DB1.B0.6")); - list.add(new ItemDto(item_move, "光电信号", "DB1.B1.0")); - list.add(new ItemDto(item_order_finish, "订单完成", "DB1.B1.5")); - list.add(new ItemDto(item_lack_req, "缺料请求", "DB1.B2.0")); - list.add(new ItemDto(item_hopper_already, "料斗已到位", "DB1.B2.1")); - list.add(new ItemDto(item_req_task_empty, "请求取空料斗", "DB1.B2.6")); - list.add(new ItemDto(item_hopper_removed, "料斗已取走", "DB1.B2.7")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W4")); - list.add(new ItemDto(item_order_now, "订单实时", "DB1.D84")); - list.add(new ItemDto(item_open_ready_time, "开机准备时间", "DB1.D108")); - list.add(new ItemDto(item_device_running_time, "设备运转时间", "DB1.D112")); - list.add(new ItemDto(item_await_time, "待机时间", "DB1.D116")); - list.add(new ItemDto(item_order, "工单号", "DB1.D160")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_open, "设备开关", "DB2.W4", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_agv_release_finish, "AGV放货完成", "DB2.W6")); - list.add(new ItemDto(item_to_agv_take_finish, "AGV取货完成", "DB2.W8")); - list.add(new ItemDto(item_to_clear, "当前产量清零", "DB2.W12")); - list.add(new ItemDto(item_to_confirm_finished, "确认完成", "DB2.W14")); - list.add(new ItemDto(item_to_order_compel_finished, "工单强制完成", "DB2.W82")); - list.add(new ItemDto(item_to_order_prod_num, "订单生产总量", "DB2.D84")); - list.add(new ItemDto(item_to_order, "工单号", "DB2.D160")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java deleted file mode 100644 index 2a8ed64..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java +++ /dev/null @@ -1,303 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_smart_plc_test; - -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -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.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -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.Map; - -/** - * 海亮清洗机储料仓 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.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 heartbeat = 0; - int mode =0; - int error =0; - int error_num =0; - int open_time =0; - int close_time =0; - int ready_time =0; - int running_time =0; - int error_time =0; - int voltage =0; - int temperature =0; - int current =0; - int material =0; - int lack_material =0; - int full_material =0; - int storage_qty =0; - int feeding_qty =0; - int blanking_qty =0; - int qualified_qty =0; - int unqualified_qty =0; - int finish =0; - int task =0; - int noload_electricity_consumption =0; - int prod_electricity_consumption =0; - int gas_consumption =0; - int water_consumption =0; - int oil_level =0; - int monthly_electricity_consumption =0; - int pause =0; - - - int last_mode =0; - int last_error =0; - int last_error_num =0; - int last_open_time =0; - int last_close_time =0; - int last_ready_time =0; - int last_running_time =0; - int last_error_time =0; - int last_voltage =0; - int last_temperature =0; - int last_current =0; - int last_material =0; - int last_lack_material =0; - int last_full_material =0; - int last_storage_qty =0; - int last_feeding_qty =0; - int last_blanking_qty =0; - int last_qualified_qty =0; - int last_unqualified_qty =0; - int last_finish =0; - int last_task =0; - int last_noload_electricity_consumption =0; - int last_prod_electricity_consumption =0; - int last_gas_consumption =0; - int last_water_consumption =0; - int last_oil_level =0; - int last_monthly_electricity_consumption =0; - int last_pause =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; - - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag = 0; - - - int agvphase=0; - int index =0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - error = this.itemProtocol.getItem_error(); - error_num = this.itemProtocol.getItem_error_num(); - open_time = this.itemProtocol.getItem_open_time(); - close_time = this.itemProtocol.getItem_close_time(); - ready_time = this.itemProtocol.getItem_ready_time(); - running_time = this.itemProtocol.getItem_running_time(); - error_time = this.itemProtocol.getItem_error_time(); - voltage = this.itemProtocol.getItem_voltage(); - temperature = this.itemProtocol.getItem_temperature(); - current = this.itemProtocol.getItem_current(); - material = this.itemProtocol.getItem_material(); - lack_material = this.itemProtocol.getItem_lack_material(); - full_material = this.itemProtocol.getItem_full_material(); - storage_qty = this.itemProtocol.getItem_storage_qty(); - feeding_qty = this.itemProtocol.getItem_feeding_qty(); - blanking_qty = this.itemProtocol.getItem_blanking_qty(); - qualified_qty = this.itemProtocol.getItem_qualified_qty(); - unqualified_qty = this.itemProtocol.getItem_unqualified_qty(); - finish = this.itemProtocol.getItem_finish(); - task = this.itemProtocol.getItem_task(); - noload_electricity_consumption = this.itemProtocol.getItem_noload_electricity_consumption(); - prod_electricity_consumption = this.itemProtocol.getItem_prod_electricity_consumption(); - gas_consumption = this.itemProtocol.getItem_gas_consumption(); - water_consumption = this.itemProtocol.getItem_water_consumption(); - oil_level = this.itemProtocol.getItem_oil_level(); - monthly_electricity_consumption = this.itemProtocol.getItem_monthly_electricity_consumption(); - pause = this.itemProtocol.getItem_pause(); - - if (mode != last_mode) { - this.setRequireSucess(false); - logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess); - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - - if (finish != last_finish) { - logServer.deviceLog(this.device_code,"finish" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号finish:" + last_finish + "->" + finish); - if(finish == 1){ - ProduceshiftorderDto deviceInfo = produceshiftorderService.findOrderByDeviceCode(this.device_code); - deviceInfo.setOrder_status("2"); - produceshiftorderService.updateByOrderCode(deviceInfo); - } - } - last_finish = finish; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - logServer.deviceLogToacs(this.device_code,"","","光电信号切换,刷新请求标记:"+this.requireSucess); - - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/ItemProtocol.java deleted file mode 100644 index ecc8e3d..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/ItemProtocol.java +++ /dev/null @@ -1,248 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_smart_plc_test; - -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_error = "error"; - public static String item_error_num = "error_num"; - public static String item_open_time = "open_time"; - public static String item_close_time = "close_time"; // - public static String item_ready_time = "ready_time"; // - public static String item_running_time = "running_time"; - public static String item_error_time = "error_time"; - public static String item_voltage = "voltage"; - public static String item_temperature = "temperature"; - public static String item_current = "current"; - public static String item_material = "material"; - public static String item_lack_material = "lack_material"; - public static String item_full_material = "full_material"; - public static String item_storage_qty = "storage_qty"; - public static String item_feeding_qty = "feeding_qty"; - public static String item_blanking_qty = "blanking_qty"; - public static String item_qualified_qty = "qualified_qty"; - public static String item_unqualified_qty = "unqualified_qty"; - public static String item_finish = "finish"; - public static String item_task = "task"; - public static String item_noload_electricity_consumption = "noload_electricity_consumption"; - public static String item_prod_electricity_consumption = "prod_electricity_consumption"; - public static String item_gas_consumption = "gas_consumption"; - public static String item_water_consumption = "water_consumption"; - public static String item_oil_level = "oil_level"; - public static String item_monthly_electricity_consumption = "monthly_electricity_consumption"; - public static String item_pause = "pause"; - - - - public static String item_to_heartbeat = "to_heartbeat";// - public static String item_to_command = "to_command";// - public static String item_to_feeding = "to_feeding";// - public static String item_to_task = "to_task";// - public static String item_to_pause= "to_pause";// - public static String item_to_clear = "to_clear";// - public static String item_to_finish = "to_finish";// - public static String item_to_open = "to_open";// - public static String item_to_close = "to_close";// - public static String item_to_material = "to_material";// - public static String item_to_qty = "to_qty";// - - - private HailiangSmartplcTestDeviceDriver driver; - - public ItemProtocol(HailiangSmartplcTestDeviceDriver driver) { - this.driver = driver; - } - - public int getItem_heartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getItem_mode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getItem_error() { - return this.getOpcIntegerValue(item_error); - } - - public int getItem_error_num() { - return this.getOpcIntegerValue(item_error_num); - } - - public int getItem_open_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getItem_close_time() { - return this.getOpcIntegerValue(item_close_time); - } - - public int getItem_ready_time() { - return this.getOpcIntegerValue(item_ready_time); - } - - public int getItem_running_time() { - return this.getOpcIntegerValue(item_running_time); - } - - public int getItem_error_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getItem_voltage() { - return this.getOpcIntegerValue(item_voltage); - } - - public int getItem_temperature() { - return this.getOpcIntegerValue(item_temperature); - } - - public int getItem_current() { - return this.getOpcIntegerValue(item_current); - } - - public int getItem_material() { - return this.getOpcIntegerValue(item_material); - } - - public int getItem_lack_material() { - return this.getOpcIntegerValue(item_lack_material); - } - - public int getItem_full_material() { - return this.getOpcIntegerValue(item_full_material); - } - - public int getItem_storage_qty() { - return this.getOpcIntegerValue(item_storage_qty); - } - - public int getItem_feeding_qty() { - return this.getOpcIntegerValue(item_feeding_qty); - } - - public int getItem_blanking_qty() { - return this.getOpcIntegerValue(item_blanking_qty); - } - - public int getItem_qualified_qty() { - return this.getOpcIntegerValue(item_qualified_qty); - } - - public int getItem_unqualified_qty() { - return this.getOpcIntegerValue(item_unqualified_qty); - } - - public int getItem_finish() { - return this.getOpcIntegerValue(item_finish); - } - - public int getItem_task() { - return this.getOpcIntegerValue(item_task); - } - - public int getItem_noload_electricity_consumption() { - return this.getOpcIntegerValue(item_noload_electricity_consumption); - } - - public int getItem_prod_electricity_consumption() { - return this.getOpcIntegerValue(item_prod_electricity_consumption); - } - - public int getItem_gas_consumption() { - return this.getOpcIntegerValue(item_gas_consumption); - } - - public int getItem_water_consumption() { - return this.getOpcIntegerValue(item_water_consumption); - } - - public int getItem_oil_level() { - return this.getOpcIntegerValue(item_oil_level); - } - - public int getItem_monthly_electricity_consumption() { - return this.getOpcIntegerValue(item_monthly_electricity_consumption); - } - - public int getItem_pause() { - return this.getOpcIntegerValue(item_pause); - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "VW0")); - list.add(new ItemDto(item_mode, "模式", "VW2")); - list.add(new ItemDto(item_error, "故障", "VW4")); - list.add(new ItemDto(item_error_num, "故障次数", "VD6")); - list.add(new ItemDto(item_open_time, "开机时间", "VD8")); - list.add(new ItemDto(item_close_time, "关机时间", "VD12")); - list.add(new ItemDto(item_ready_time, "待机时间", "VD16")); - list.add(new ItemDto(item_running_time, "生产时间", "VD20")); - list.add(new ItemDto(item_error_time, "故障时间", "VD24")); - list.add(new ItemDto(item_temperature, "温度", "VD28")); - list.add(new ItemDto(item_voltage, "电压", "VD32")); - list.add(new ItemDto(item_current, "电流", "VD36")); - list.add(new ItemDto(item_material, "当前生产产品编号", "VD40")); - list.add(new ItemDto(item_lack_material, "生产缺料信号", "VD44")); - list.add(new ItemDto(item_full_material, "生产满料信号", "VD48")); - list.add(new ItemDto(item_storage_qty, "储料斗数量", "VD52")); - list.add(new ItemDto(item_feeding_qty, "上料数量", "VD56")); - list.add(new ItemDto(item_blanking_qty, "下料数量", "VD60")); - list.add(new ItemDto(item_qualified_qty, "当前生产合格品数量", "VD64")); - list.add(new ItemDto(item_unqualified_qty, "当前生产不合格数量", "VD68")); - list.add(new ItemDto(item_finish, "生产完成", "VD72")); - list.add(new ItemDto(item_task, "任务号", "VD76")); - list.add(new ItemDto(item_noload_electricity_consumption, "空载电能耗(未生产时)", "VD80")); - list.add(new ItemDto(item_prod_electricity_consumption, "生产电能耗", "VD84")); - list.add(new ItemDto(item_gas_consumption, "气压能耗", "VD88")); - list.add(new ItemDto(item_water_consumption, "水流量能耗", "VD92")); - list.add(new ItemDto(item_oil_level, "当前液压油位", "VD96")); - list.add(new ItemDto(item_monthly_electricity_consumption, "本月总电能耗", "VD100")); - list.add(new ItemDto(item_pause, "设备暂停", "VD104")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_heartbeat, "心跳", "VW200")); - list.add(new ItemDto(item_to_command, "下发命令", "VW202")); - list.add(new ItemDto(item_to_feeding, "下发命令", "VW204")); - list.add(new ItemDto(item_to_task, "任务号", "VW208")); - list.add(new ItemDto(item_to_pause, "生产暂停", "VW212")); - list.add(new ItemDto(item_to_clear, "当前产量清零", "VW216")); - list.add(new ItemDto(item_to_finish, "强制完成", "VW220")); - list.add(new ItemDto(item_to_open, "设备开机", "VW224")); - list.add(new ItemDto(item_to_close, "设备关机", "VW228")); - list.add(new ItemDto(item_to_material, "当前任务生产物料", "VW232")); - list.add(new ItemDto(item_to_qty, "当前任务生产数量", "VW236")); - return list; - } - - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/HailiangSpecialDeviceDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/HailiangSpecialDeviceDefination.java deleted file mode 100644 index 5817df3..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/HailiangSpecialDeviceDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device; - -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 HailiangSpecialDeviceDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_special_device"; - } - - @Override - public String getDriverName() { - return "海亮-专机设备"; - } - - @Override - public String getDriverDescription() { - return "海亮-专机设备"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangSpecialDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangSpecialDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/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 deleted file mode 100644 index 0efa50a..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/HailiangSpecialDeviceDriver.java +++ /dev/null @@ -1,564 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.config.server.AcsConfigService; -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.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -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.WcsConfig; -import org.nl.acs.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -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; - -/** - * 海亮专机设备 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @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 - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.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 is_open = 0; - int running = 0; - int finish = 0; - int all_ready = 0; - int order_compel_finish = 0; - int order = 0; - int now_order_prod_num = 0; - int full_number = 0; - int now_one_box_num = 0; - int storage_stock_num = 0; - int line_stock_num = 0; - int open_ready_time = 0; - int device_running_time = 0; - int await_time = 0; - int order_prod_allnum = 0; - int empty_is_lack = 0; //空箱位缺箱 - int device_is_running = 0; //专机运行状态 - int empty_is_finish = 0; //空位完成 - int full_ready_req_agv = 0; //满箱位就绪,请求AGV - int full_out = 0; //满箱已运出满箱位 - int device_prepare = 0; //专机准备中 - int device_ready = 0; //专机就绪 - int line_ready = 0; //线体就绪 - int device_online = 0; //专机联机 - //出入库模式 - int operation_type = 0; - int last_mode = 0; - int last_error = 0; -/* int last_move = 0;*/ - int last_task = 0; - int last_is_open = 0; - int last_running = 0; - int last_finish = 0; - int last_all_ready = 0; - int last_order_compel_finish = 0; - int last_order = 0; - int last_now_order_prod_num = 0; - int last_full_number = 0; - int last_now_one_box_num = 0; - int last_storage_stock_num = 0; - int last_line_stock_num = 0; - int last_open_ready_time = 0; - int last_device_running_time = 0; - int last_await_time = 0; - int last_order_prod_allnum = 0; - int last_empty_is_lack = 0; //空箱位缺箱 - int last_device_is_running = 0; //专机运行状态 - int last_empty_is_finish = 0; //空位完成 - int last_full_ready_req_agv = 0; //满箱位就绪,请求AGV - int last_full_out = 0; //满箱已运出满箱位 - int last_device_prepare = 0; //专机准备中 - int last_device_ready = 0; //专机就绪 - int last_line_ready = 0; //线体就绪 - int last_device_online = 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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - is_open = this.itemProtocol.getIsOpen(); - running = this.itemProtocol.getRunning(); - all_ready = this.itemProtocol.getAllReady(); - order = this.itemProtocol.getOrder(); - mode = this.itemProtocol.getItem_mode(); - finish = this.itemProtocol.getItem_finish(); - order_compel_finish = this.itemProtocol.getItem_order_compel_finish(); - now_order_prod_num = this.itemProtocol.getItem_now_order_prod_num(); - full_number = this.itemProtocol.getItem_full_number(); - now_one_box_num = this.itemProtocol.getItem_now_one_box_num(); - storage_stock_num = this.itemProtocol.getItem_storage_stock_num(); - line_stock_num = this.itemProtocol.getItem_line_stock_num(); - open_ready_time = this.itemProtocol.getItem_open_ready_time(); - device_running_time = this.itemProtocol.getItem_device_running_time(); - await_time = this.itemProtocol.getItem_await_time(); - order_prod_allnum = this.itemProtocol.getItem_order_prod_allnum(); - empty_is_lack = this.itemProtocol.getItem_empty_is_lack(); - device_is_running = this.itemProtocol.getItem_device_is_running(); - empty_is_finish = this.itemProtocol.getItem_empty_is_finish(); - full_ready_req_agv = this.itemProtocol.getItem_full_ready_req_agv(); - full_out = this.itemProtocol.getItem_full_out(); - device_prepare = this.itemProtocol.getItem_device_prepare(); - 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); - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (empty_is_lack != last_empty_is_lack) { - logServer.deviceLog(this.device_code,"empty_is_lack" ,String.valueOf(empty_is_lack)); - logServer.deviceLogToacs(this.device_code,"","","信号empty_is_lack:" + last_empty_is_lack + "->" + empty_is_lack); - } - if (device_is_running != last_device_is_running) { - logServer.deviceLog(this.device_code,"device_is_running" ,String.valueOf(device_is_running)); - logServer.deviceLogToacs(this.device_code,"","","信号device_is_running:" + last_device_is_running + "->" + device_is_running); - } - if (empty_is_finish != last_empty_is_finish) { - logServer.deviceLog(this.device_code,"empty_is_finish" ,String.valueOf(empty_is_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号empty_is_finish:" + last_empty_is_finish + "->" + empty_is_finish); - } - if (full_ready_req_agv != last_full_ready_req_agv) { - logServer.deviceLog(this.device_code,"full_ready_req_agv" ,String.valueOf(full_ready_req_agv)); - logServer.deviceLogToacs(this.device_code,"","","信号full_ready_req_agv:" + last_full_ready_req_agv + "->" + full_ready_req_agv); - } - if (full_out != last_full_out) { - logServer.deviceLog(this.device_code,"full_out" ,String.valueOf(full_out)); - logServer.deviceLogToacs(this.device_code,"","","信号full_out:" + last_full_out + "->" + full_out); - } - if (device_prepare != last_device_prepare) { - logServer.deviceLog(this.device_code,"device_prepare" ,String.valueOf(device_prepare)); - logServer.deviceLogToacs(this.device_code,"","","信号device_prepare:" + last_device_prepare + "->" + device_prepare); - } - if (device_ready != last_device_ready) { - logServer.deviceLog(this.device_code,"device_ready" ,String.valueOf(device_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号device_ready:" + last_device_ready + "->" + device_ready); - } - if (line_ready != last_line_ready) { - logServer.deviceLog(this.device_code,"line_ready" ,String.valueOf(line_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号line_ready:" + last_line_ready + "->" + line_ready); - } - if (device_online != last_device_online) { - logServer.deviceLog(this.device_code,"device_online" ,String.valueOf(device_online)); - logServer.deviceLogToacs(this.device_code,"","","信号device_online:" + last_device_online + "->" + device_online); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - if (task != last_task) { - logServer.deviceLog(this.device_code,"task" ,String.valueOf(task)); - logServer.deviceLogToacs(this.device_code,"","","信号task:" + last_task + "->" + task); - } - - if (is_open != last_is_open) { - logServer.deviceLog(this.device_code,"is_open" ,String.valueOf(is_open)); - logServer.deviceLogToacs(this.device_code,"","","信号is_open:" + last_is_open + "->" + is_open); - } - if (running != last_running) { - logServer.deviceLog(this.device_code,"running" ,String.valueOf(running)); - logServer.deviceLogToacs(this.device_code,"","","信号running:" + last_running + "->" + running); - } - if (finish != last_finish) { - logServer.deviceLog(this.device_code,"finish" ,String.valueOf(finish)); - logServer.deviceLogToacs(this.device_code,"","","信号finish:" + last_finish + "->" + finish); - } - if (all_ready != last_all_ready) { - logServer.deviceLog(this.device_code,"all_ready" ,String.valueOf(all_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号all_ready:" + last_all_ready + "->" + all_ready); - } - if (order_compel_finish != last_order_compel_finish) { - logServer.deviceLog(this.device_code,"order_compel_finish" ,String.valueOf(order_compel_finish)); - logServer.deviceLogToacs(this.device_code,"","","信号order_compel_finish:" + last_order_compel_finish + "->" + order_compel_finish); - } - if (order != last_order) { - logServer.deviceLog(this.device_code,"order" ,String.valueOf(order)); - logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order); - } - 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); - } - if (full_number != last_full_number) { - logServer.deviceLog(this.device_code,"full_number" ,String.valueOf(full_number)); - logServer.deviceLogToacs(this.device_code,"","","信号full_number:" + last_full_number + "->" + full_number); - } - if (now_one_box_num != last_now_one_box_num) { - logServer.deviceLog(this.device_code,"now_one_box_num" ,String.valueOf(now_one_box_num)); - logServer.deviceLogToacs(this.device_code,"","","信号now_one_box_num:" + last_now_one_box_num + "->" + now_one_box_num); - } - if (storage_stock_num != last_storage_stock_num) { - logServer.deviceLog(this.device_code,"storage_stock_num" ,String.valueOf(storage_stock_num)); - logServer.deviceLogToacs(this.device_code,"","","信号storage_stock_num:" + last_storage_stock_num + "->" + storage_stock_num); - } - if (line_stock_num != last_line_stock_num) { - logServer.deviceLog(this.device_code,"line_stock_num" ,String.valueOf(line_stock_num)); - logServer.deviceLogToacs(this.device_code,"","","信号line_stock_num:" + last_line_stock_num + "->" + line_stock_num); - } - if (open_ready_time != last_open_ready_time) { - logServer.deviceLog(this.device_code,"open_ready_time" ,String.valueOf(task)); - logServer.deviceLogToacs(this.device_code,"","","信号task:" + last_task + "->" + task); - } - if (device_running_time != last_device_running_time) { - logServer.deviceLog(this.device_code,"device_running_time" ,String.valueOf(device_running_time)); - logServer.deviceLogToacs(this.device_code,"","","信号device_running_time:" + last_device_running_time + "->" + device_running_time); - } - if (await_time != last_await_time) { - logServer.deviceLog(this.device_code,"await_time" ,String.valueOf(await_time)); - logServer.deviceLogToacs(this.device_code,"","","信号await_time:" + last_await_time + "->" + await_time); - } - if (order_prod_allnum != last_order_prod_allnum) { - 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); - } - -/* if (mode == 2 && move != 0 && task > 0) { - - }*/ - } catch (Exception var17) { - return; - } - if(1 != 1){ -// 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; - - if ( mode == 1 && finish != last_finish && finish == 1 && order > 0){ - ProduceshiftorderDto dto = new ProduceshiftorderDto(); - dto.setOrder_code(order + ""); - dto.setOrder_status("2"); - ProduceshiftorderDto deviceInfo = produceshiftorderService.findOrderByDeviceCode(this.device_code); - if(deviceInfo != null){ - if (StrUtil.isNotEmpty(deviceInfo.getExt_order_id())) { - String ext_order_id = deviceInfo.getExt_order_id(); - JSONObject param = new JSONObject(); - param.put("ext_order_id",ext_order_id); - acsToWmsService.feedbackOrderStatus(param); - logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单的外部标识:"+ext_order_id); - }else { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单的没有外部标识"); - } - }else { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单信息为空"); - } - produceshiftorderService.updateByOrderCode(dto); - this.writing("to_confirm_finished","1"); - this.writing("to_clear","1"); - this.writing("to_pause","1"); - } else { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,order_finish>"+ finish +",last_finish>"+last_finish); - } - } - last_mode = mode; - last_error = error; - /* last_move = move;*/ - last_task = task; - last_is_open = is_open; - last_running = running ; - last_finish = finish; - last_all_ready = all_ready; - last_order_compel_finish = order_compel_finish; - last_order = order; - last_now_order_prod_num = now_order_prod_num; - last_full_number = full_number; - last_now_one_box_num = now_one_box_num; - last_storage_stock_num = storage_stock_num; - last_line_stock_num = line_stock_num; - last_open_ready_time = open_ready_time; - last_device_running_time = device_running_time; - last_await_time = await_time; - last_order_prod_allnum = order_prod_allnum; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - - } - - public void writing(String param, String value) { - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + param; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_param, Integer.parseInt(value)); - ReadUtil.write(itemMap, server); - logServer.deviceLogToacs(this.device_code,"","","下发信号:" + param + ":" + value); - } - - - - - public boolean instruction_apply() throws Exception { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() throws Exception { - return false; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/ItemProtocol.java deleted file mode 100644 index aae58eb..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_device/ItemProtocol.java +++ /dev/null @@ -1,263 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device; - -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_is_open = "is_open";// 线体是否启动 - public static String item_running = "running"; //是否运行 - public static String item_finish = "finish";// 订单完成 - public static String item_all_ready = "all_ready"; //所有设备就绪 - public static String item_order_compel_finish = "order_compel_finish"; // 订单强制完成 - public static String item_order = "order"; //订单号 - public static String item_error = "error"; //报警信号 - public static String item_task = "task"; //任务号 - public static String item_now_order_prod_num = "now_order_prod_num"; //当前生产总量 - public static String item_full_number = "full_number"; //出料口满框数量 - public static String item_now_one_box_num = "now_one_prod_num"; //每框数量 - public static String item_storage_stock_num = "storage_stock_num"; //储料仓库存数量 - public static String item_line_stock_num = "line_stock_num"; //线体库存数量 - public static String item_open_ready_time = "open_ready_time";//开机准备时间(S) - public static String item_device_running_time = "device_running_time";//设备运行时间(S) - public static String item_await_time = "await_time";//待机时间(S) - public static String item_order_prod_allnum = "order_prod_allnum";//订单生产总量 - - public static String item_empty_is_lack = "empty_is_lack"; //空箱位缺箱 - public static String item_device_is_running = "device_is_running"; //专机运行状态 - public static String item_empty_is_finish = "empty_is_finish"; //空位完成 - public static String item_full_ready_req_agv = "full_ready_req_agv"; //满箱位就绪,请求AGV - public static String item_full_out = "full_out"; //满箱已运出满箱位 - public static String item_device_prepare = "device_prepare"; //专机准备中 - public static String item_device_ready = "device_prepare"; //专机就绪 - public static String item_line_ready = "line_ready"; //线体就绪 - - - //开机 - public static String item_to_open = "to_open"; - //产量清零 - public static String item_to_clear = "to_clear"; - //确认完成(订单完成状态置零) - public static String item_to_confirm_finished = "to_confirm_finished"; - //暂停 - public static String item_to_pause = "to_pause"; - //工单强制完成 - public static String item_to_order_compel_finished = "to_order_compel_finished"; - //订单生产总量 - public static String item_to_order_prod_num = "to_order_prod_num"; - //每框接料数量 - public static String item_to_one_box_num = "to_one_box_num"; - //倒料数量 - public static String item_to_out_num = "to_out_num"; - //工单号 - public static String item_to_order = "to_order"; - //agvAGV空位就绪 - public static String item_to_empty_ready = "to_empty_ready"; - //agvAGV满位就绪 - public static String item_to_full_ready = "to_full_ready"; - //agvAGV取货完成 - public static String item_to_pick_finish = "to_pick_finish"; - //任务号 - public static String item_to_task = "to_task"; - - private HailiangSpecialDeviceDriver driver; - - public ItemProtocol(HailiangSpecialDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getIsOpen() { - return this.getOpcIntegerValue(item_is_open); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getRunning() { return this.getOpcIntegerValue(item_running);} - - public int getAllReady() { return this.getOpcIntegerValue(item_all_ready);} - - public int getOrder() { return this.getOpcIntegerValue(item_order);} - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getItem_mode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getItem_finish() { - return this.getOpcIntegerValue(item_finish); - } - - public int getItem_order_compel_finish() { - return this.getOpcIntegerValue(item_order_compel_finish); - } - - public int getItem_now_order_prod_num() { - return this.getOpcIntegerValue(item_now_order_prod_num); - } - - public int getItem_full_number() { - return this.getOpcIntegerValue(item_full_number); - } - - public int getItem_now_one_box_num() { - return this.getOpcIntegerValue(item_now_one_box_num); - } - - public int getItem_storage_stock_num() { - return this.getOpcIntegerValue(item_storage_stock_num); - } - - public int getItem_line_stock_num() { - return this.getOpcIntegerValue(item_line_stock_num); - } - - public int getItem_open_ready_time() { - return this.getOpcIntegerValue(item_open_ready_time); - } - - public int getItem_device_running_time() { - return this.getOpcIntegerValue(item_device_running_time); - } - - public int getItem_await_time() { - return this.getOpcIntegerValue(item_await_time); - } - - public int getItem_order_prod_allnum() { - return this.getOpcIntegerValue(item_order_prod_allnum); - } - - public int getItem_empty_is_lack() { - return this.getOpcIntegerValue(item_empty_is_lack); - } - - public int getItem_device_is_running() { - return this.getOpcIntegerValue(item_device_is_running); - } - - public int getItem_empty_is_finish() { - return this.getOpcIntegerValue(item_empty_is_finish); - } - - public int getItem_full_ready_req_agv() { - return this.getOpcIntegerValue(item_full_ready_req_agv); - } - - public int getItem_full_out() { - return this.getOpcIntegerValue(item_full_out); - } - - public int getItem_device_prepare() { - return this.getOpcIntegerValue(item_device_prepare); - } - - public int getItem_device_ready() { - return this.getOpcIntegerValue(item_device_ready); - } - - public int getItem_line_ready() { - return this.getOpcIntegerValue(item_line_ready); - } - - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static String getField_desc(String item){ - String field_desc = ""; - List readlist = getReadableItemDtos(); - List writelist = getWriteableItemDtos(); - for(int i=0;i getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_mode, "手自动状态", "DB1.B1.7", Boolean.valueOf(true))); - list.add(new ItemDto(item_is_open, "线体是否启动", "DB1.B0.1")); - list.add(new ItemDto(item_running, "是否运行", "DB1.B0.6")); - list.add(new ItemDto(item_all_ready, "所有设备就绪", "DB1.B1.6")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W4")); - list.add(new ItemDto(item_order_compel_finish, "订单强制完成", "DB1.B2.0")); - list.add(new ItemDto(item_now_order_prod_num, "当前生产总量", "DB1.D84")); - list.add(new ItemDto(item_now_one_box_num, "每框箱数量", "DB1.D99")); - list.add(new ItemDto(item_full_number, "出料口满框数量", "DB1.D96")); - list.add(new ItemDto(item_storage_stock_num, "储料仓库存数量", "DB1.D100")); - list.add(new ItemDto(item_line_stock_num, "线体库存数量", "DB1.D104")); - list.add(new ItemDto(item_open_ready_time, "开机准备时间(S)", "DB1.D108")); - list.add(new ItemDto(item_device_running_time, "设备运行时间(S)", "DB1.D112")); - list.add(new ItemDto(item_await_time, "待机时间(S)", "DB1.D116")); - list.add(new ItemDto(item_order_prod_allnum, "订单生产总量", "DB1.D120")); - list.add(new ItemDto(item_task, "任务号", "DB1.D22")); - list.add(new ItemDto(item_empty_is_lack, "空箱位缺箱", "DB1.B0.5")); - list.add(new ItemDto(item_device_is_running, "专机运行状态", "DB1.B0.3")); - list.add(new ItemDto(item_empty_is_finish, "空位完成", "DB1.B0.7")); - list.add(new ItemDto(item_full_ready_req_agv, "满箱位就绪,请求AGV", "DB1.B1.0")); - list.add(new ItemDto(item_full_out, "满箱已运出满箱位", "DB1.B1.1")); - list.add(new ItemDto(item_device_prepare, "专机准备中", "DB1.B1.3")); - list.add(new ItemDto(item_device_ready, "专机就绪", "DB1.B1.4")); - list.add(new ItemDto(item_line_ready, "线体就绪", "DB1.B1.5")); - list.add(new ItemDto(item_order, "工单号", "DB1.D160")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_open, "设备开关", "DB2.W4", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_clear, "当前产量清零", "DB2.W12")); - list.add(new ItemDto(item_to_confirm_finished, "确认完成", "DB2.W14")); - list.add(new ItemDto(item_to_pause, "暂停", "DB2.W16")); - list.add(new ItemDto(item_to_order_compel_finished, "工单强制完成", "DB2.W82")); - list.add(new ItemDto(item_to_order_prod_num, "订单生产总量", "DB2.D84")); - list.add(new ItemDto(item_to_one_box_num, "每箱接料数量", "DB2.D88")); - list.add(new ItemDto(item_to_out_num, "倒料数量", "DB2.D96")); - list.add(new ItemDto(item_to_order, "工单号", "DB2.D160")); - list.add(new ItemDto(item_to_empty_ready, "AGV空位就绪", "DB2.W6")); - list.add(new ItemDto(item_to_full_ready, "AGV满位就绪", "DB2.W8")); - list.add(new ItemDto(item_to_pick_finish, "AGV取货完成", "DB2.W10")); - list.add(new ItemDto(item_to_task, "任务号", "DB2.D92")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/HailiangSpecialEmptyStationDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/HailiangSpecialEmptyStationDefination.java deleted file mode 100644 index 848d15f..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/HailiangSpecialEmptyStationDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_empty_station; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮专机设备空框位 - */ -@Service -public class HailiangSpecialEmptyStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_special_empty_station"; - } - - @Override - public String getDriverName() { - return "海亮-专机设备空框位"; - } - - @Override - public String getDriverDescription() { - return "海亮-专机设备空框位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangSpecialEmptyStationDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangSpecialEmptyStationDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/HailiangSpecialEmptyStationDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/HailiangSpecialEmptyStationDeviceDriver.java deleted file mode 100644 index 88c5de3..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/HailiangSpecialEmptyStationDeviceDriver.java +++ /dev/null @@ -1,426 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_empty_station; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -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.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.start.auto.run.NDCSocketConnectionAutoRun; -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; - -/** - * 海亮专机设备空框位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangSpecialEmptyStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @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 - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.class); - - String container; - - int agvphase = 0; - int index = 0; - String device_code; - - int mode = 0; - int status = 0; - int move = 0; - int finish = 0; - int allready = 0; - int order = 0; - int error = 0; - int task = 0; - int running = 0; - //出入库模式 - int operation_type = 0; - int last_mode = 0; - int last_status = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_all_ready = 0; - int last_order = 0; - int last_finish = 0; - int last_running = 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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - status = this.itemProtocol.getStatus(); - task = this.itemProtocol.getTask(); - allready = this.itemProtocol.getAllReady(); - mode = this.itemProtocol.getMode(); - finish = this.itemProtocol.getFinish(); - order = this.itemProtocol.getOrder(); - hasGoods = this.itemProtocol.getMove(); - running = this.itemProtocol.getRunning(); - if (mode != last_mode) { - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - if (move == 1) { - thingToNothing(); - } - this.setRequireSucess(false); - logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); - logServer.deviceLogToacs(this.device_code,"","","信号move(取反):" + last_move + "->" + move); - } - if (status != last_status) { - logServer.deviceLog(this.device_code,"status" ,String.valueOf(status)); - logServer.deviceLogToacs(this.device_code,"","","信号status:" + last_status + "->" + status); - } - if (task != last_task) { - logServer.deviceLog(this.device_code,"task" ,String.valueOf(task)); - logServer.deviceLogToacs(this.device_code,"","","信号task:" + last_task + "->" + task); - } - if (running != last_running) { - logServer.deviceLog(this.device_code,"running" ,String.valueOf(running)); - logServer.deviceLogToacs(this.device_code,"","","信号running:" + last_running + "->" + running); - } - if (allready != last_all_ready) { - logServer.deviceLog(this.device_code,"allready" ,String.valueOf(allready)); - logServer.deviceLogToacs(this.device_code,"","","信号all_ready:" + last_all_ready + "->" + allready); - } - if (finish != last_finish) { - logServer.deviceLog(this.device_code,"finish" ,String.valueOf(finish)); - logServer.deviceLogToacs(this.device_code,"","","信号finish:" + last_finish + "->" + finish); - } - if (order != last_order) { - logServer.deviceLog(this.device_code,"order" ,String.valueOf(order)); - logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - - if (mode == 2 && move != 0 && task > 0) { - - } - } 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; - //请求放空箱 - if(agvphase == 0x13 || agvphase == 0x17 ) - { - if(error == 0 && move== 1 && ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("5"); - instructionService.update(inst); - writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvTwoModeInst(agvphase, index, 0); - NDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - }else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因move:"+move+",error:"+error+",inst"+inst); - } - } - //放空箱完成 - if(agvphase == 0x15 || agvphase == 0x19){ - if(error == 0 && move== 1 && ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("6"); - instructionService.update(inst); - byte[] data = agvService.sendAgvTwoModeInst(agvphase, index, 0); - NDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - }else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因move:"+move+",error:"+error+",inst"+inst); - } - } - } - last_mode = mode; - last_status = status; - last_error = error; - last_move = move; - last_task = task; - last_all_ready = allready; - last_finish = finish; - last_order = order; - last_running = running; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.setRequireSucess(false); - this.setApplySucess(false); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - } - - public void writing(int type, int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } - - public boolean instruction_apply() throws Exception { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() throws Exception { - return false; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/ItemProtocol.java deleted file mode 100644 index 2095478..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_empty_station/ItemProtocol.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_empty_station; - -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_running = "running"; - public static String item_status = "status"; - public static String item_finish = "finish"; - public static String item_all_ready = "all_ready"; - public static String item_order = "order"; - public static String item_error = "error"; - public static String item_task = "task"; - - public static String item_to_agv_ready = "to_agv_ready"; - - public static String item_to_agv_finish = "to_agv_finish"; - - private HailiangSpecialEmptyStationDeviceDriver driver; - - public ItemProtocol(HailiangSpecialEmptyStationDeviceDriver 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 getRunning() { - return this.getOpcIntegerValue(item_running); - } - - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getFinish() { return this.getOpcIntegerValue(item_finish);} - - public int getAllReady() { return this.getOpcIntegerValue(item_all_ready);} - - public int getOrder() { return this.getOpcIntegerValue(item_order);} - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_mode, "是否启动", "DB1.B0.1")); - list.add(new ItemDto(item_status, "手自动状态", "DB1.B0.0", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号(取反)", "DB1.B0.5")); - list.add(new ItemDto(item_running, "空位运行", "DB1.B0.6")); - list.add(new ItemDto(item_finish, "是否完成", "DB1.B0.7")); - list.add(new ItemDto(item_all_ready, "所有设备就绪", "DB1.B1.6")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W4")); - list.add(new ItemDto(item_task, "任务号", "DB1.D22")); - list.add(new ItemDto(item_order, "工单号", "DB1.D160")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_agv_ready, "AGV就绪", "DB2.W6", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/HailiangSpecialFullStationDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/HailiangSpecialFullStationDefination.java deleted file mode 100644 index 4503023..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/HailiangSpecialFullStationDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_full_station; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮专机设备满框位 - */ -@Service -public class HailiangSpecialFullStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_special_full_station"; - } - - @Override - public String getDriverName() { - return "海亮-专机设备满框位"; - } - - @Override - public String getDriverDescription() { - return "海亮-专机设备满框位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangSpecialFullStationDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangSpecialFullStationDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/HailiangSpecialFullStationDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/HailiangSpecialFullStationDeviceDriver.java deleted file mode 100644 index 0f177bb..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/HailiangSpecialFullStationDeviceDriver.java +++ /dev/null @@ -1,675 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_full_station; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.basedriver.hailiang_one.hailiang_auto_cache_line.HailiangAutoCacheLineDeviceDriver; -import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_feeding_line.HailiangCleaningFeedingLineDefination; -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_special_pour_station.HailiangSpecialPourStationDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.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.WcsConfig; -import org.nl.acs.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -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.exception.BadRequestException; -import org.nl.modules.system.util.CodeUtil; -import org.nl.start.auto.run.NDCSocketConnectionAutoRun; -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; - -/** - * 海亮专机设备满框位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangSpecialFullStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.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 move = 0; - int status = 0; - int finish = 0; - int allready = 0; - int order = 0; - int error = 0; - int task = 0; - int full_number = 0; - //出入库模式 - int operation_type = 0; - int last_mode = 0; - int last_status = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_all_ready = 0; - int last_order = 0; - int last_finish = 0; - int last_full_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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - int agvphase = 0; - int index = 0; - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - allready = this.itemProtocol.getAllReady(); - mode = this.itemProtocol.getMode(); - finish = this.itemProtocol.getFinish(); - order = this.itemProtocol.getOrder(); - hasGoods = this.itemProtocol.getMove(); - full_number = this.itemProtocol.getFull_number(); - - if (mode != last_mode) { - this.setRequireSucess(false); - logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess); - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); - logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move); - } - if (status != last_status) { - logServer.deviceLog(this.device_code,"status" ,String.valueOf(status)); - logServer.deviceLogToacs(this.device_code,"","","信号status:" + last_status + "->" + status); - } - if (full_number != last_full_number) { - logServer.deviceLog(this.device_code,"full_number" ,String.valueOf(full_number)); - logServer.deviceLogToacs(this.device_code,"","","信号full_number:" + last_full_number + "->" + full_number); - } - if (task != last_task) { - logServer.deviceLog(this.device_code,"task" ,String.valueOf(task)); - logServer.deviceLogToacs(this.device_code,"","","信号task:" + last_task + "->" + task); - } - if (allready != last_all_ready) { - logServer.deviceLog(this.device_code,"allready" ,String.valueOf(allready)); - logServer.deviceLogToacs(this.device_code,"","","信号all_ready:" + last_all_ready + "->" + allready); - } - if (finish != last_finish) { - logServer.deviceLog(this.device_code,"finish" ,String.valueOf(finish)); - logServer.deviceLogToacs(this.device_code,"","","信号finish:" + last_finish + "->" + finish); - } - if (order != last_order) { - logServer.deviceLog(this.device_code,"order" ,String.valueOf(order)); - logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - - } 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 = ""; - - if(!requireSucess){ -// if ( move == 1 && mode == 1 && order > 0 && full_number>0 ) { - - if ( move == 1 && mode == 1 ) { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,move:"+move+",requireSucess:" + requireSucess + "开始申请任务"); - apply_task(); - } else { - logServer.deviceLogToacs(this.device_code,"","",device_code+":,move:"+move+",requireSucess:" + requireSucess + "申请任务失败,不符合条件"); - } - } else { - logServer.deviceLogToacs(this.device_code,"","","是否请求成功:requireSucess:"+requireSucess); - - } - - if(agvphase == 0x03 || agvphase == 0x07 ) - { - if(move ==1 && error == 0 && allready ==1 && full_number>0 && ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("1"); - instructionService.update(inst); - writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvTwoModeInst(agvphase, index, 0); - NDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因move:"+move+",error:"+error+",inst"+inst+",allready:"+allready+",full_number:"+full_number); - - - } - } - - if(agvphase == 0x05 || agvphase == 0x09){ - if(move ==0 && error == 0 && allready ==1 && full_number>0 && ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("2"); - instructionService.update(inst); - writing("to_agv_finish", "1"); - byte[] data = agvService.sendAgvTwoModeInst(agvphase, index, 0); - NDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "反馈成功"); - - } else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因move:"+move+",error:"+error+",inst"+inst+",allready:"+allready+",full_number:"+full_number); - - - } - } - - } - last_mode = mode; - last_status = status; - last_error = error; - last_move = move; - last_task = task; - last_all_ready = allready; - last_finish = finish; - last_order = order; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - logServer.deviceLogToacs(this.device_code,"","","光电信号切换,刷新请求标记:"+this.requireSucess); - - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } - - public synchronized boolean apply_task() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - Boolean flag = false; - //通过路由找到所有的目标设备 - //找到当前设备生产的物料,并且判断下个工序生产的物料相同 - //判断是否已经有前往这个工位的任务 - List list = routeLineService.getShortPathLinesByCode(this.device_code, "normal"); - if (ObjectUtil.isEmpty(list)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":未找到对应路由"); - throw new BadRequestException(this.device_code + ":未找到对应路由"); - } - //link_device tw 满料位设备关联的设备tw - String link_device = this.getDevice().getExtraValue().get("link_device_code").toString(); - //empty_device 满料位对应的空料位 - String empty_device = this.getDevice().getExtraValue().get("empty_device_code").toString(); - //通过满料位设备关联的设备tw查找订单 - ProduceshiftorderDto order = produceshiftorderService.findOrderByDeviceCode(link_device); - if (ObjectUtil.isEmpty(order)) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":关联设备" + link_device + "未找到对应设备工单"); - throw new BadRequestException(this.device_code + ":关联设备" + link_device + "未找到对应设备工单"); - } - //判断是否需要agv搬运 - if (order.getIs_needmove().equals("0")){ - requireSucess = true; - logServer.deviceLogToacs(this.device_code,"","","不需要agv搬运,工单号:"+order.getOrder_code()); - return true; - } - //查找当前工单对应的物料编号 - String cpbh = order.getMaterial_code(); - HailiangSpecialPourStationDeviceDriver hailiangSpecialPourStationDeviceDriver; - HailiangCleaningMachineStorageStationDeviceDriver hailiangCleaningMachineStorageStationDeviceDriver; - HailiangAutoCacheLineDeviceDriver hailiangAutoCacheLineDeviceDriver; - String clear_storage_device =null; - //遍历路由,找到对应所有的物料进行匹配 - for (int i = 0; i < list.size(); i++) { - RouteLineDto dto = list.get(i); - //找到路由对应工位 清洗机设备编号 - String route_device_code = dto.getNext_device_code(); - Device route_link_device = deviceAppservice.findDeviceByCode(route_device_code); - //找到路由工位对应设备 - String route_link_device_code = (String)route_link_device.getExtraValue().get("link_device_code"); - if(StrUtil.isEmpty(route_link_device_code)){ - continue; - } - //找到路由工位对应设备对应的工单 - ProduceshiftorderDto route_order = produceshiftorderService.findOrderByDeviceCode(route_link_device_code); - //找到对应设备工单 - if (ObjectUtil.isNotEmpty(route_order)) { - //找到生产产品一样的设备 - if (StrUtil.equals(route_order.getMaterial_code(), cpbh)) { - //所有到这个倒料位上任务的总数量 - int allnum = taskserver.queryAllTaskMaterialQty(route_link_device_code); - //查询此工位是否需要补料 - //获取此工位允许的最大上料数量 - int max_num = Integer.parseInt(route_link_device.getExtraValue().get("max_num").toString()); - //判断设备是专机倒料位 - if (route_link_device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) { - hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) route_link_device.getDeviceDriver(); - if (hailiangSpecialPourStationDeviceDriver.getMode() != 1) { - continue; - } - //获取储料仓库存数量 - int stock_num = hailiangSpecialPourStationDeviceDriver.getStorage_stock_num(); - //此款数量+储料仓库存数量 < 下工序允许最大数量 则通过 - if (allnum + full_number + stock_num < max_num) { - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_status("0"); - onedto.setPriority("101"); - onedto.setAgv_system_type("1"); - onedto.setTask_type("1"); - onedto.setStart_device_code(this.getDevice().getDevice_code()); - onedto.setStart_point_code(this.getDevice().getDevice_code()); - onedto.setPut_device_code(route_device_code); - onedto.setPut_point_code(route_device_code); - onedto.setNext_point_code(empty_device); - onedto.setNext_device_code(empty_device); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - - try { - taskserver.create(onedto); - flag = true; - break; - } catch (Exception e) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务成功"); - } else { - //打印日志 - continue; - } - } - - } - else if (route_link_device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver){ - JSONObject json = new JSONObject(); - json.put("device_code",device_code); - json.put("type","1"); - HttpResponse httpResponse = acsToWmsService.applyInCacheLineTask(json); - JSONObject jsonObject = JSONObject.parseObject(httpResponse.body()); - String ext_task_id = jsonObject.getString("ext_task_id"); - String task_code = jsonObject.getString("task_code"); - String start_device_code = jsonObject.getString("start_device_code"); - String put_device_code = jsonObject.getString("put_device_code"); - String next_device_code = jsonObject.getString("next_device_code"); - String task_type = jsonObject.getString("task_type"); - String barcodeArr = jsonObject.getString("barcodeArr"); - String[] barcodeArrs = barcodeArr.split("\\,"); - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - onedto.setExt_task_id(ext_task_id); - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_status("0"); - onedto.setPriority("101"); - onedto.setAgv_system_type("1"); - onedto.setTask_type(task_type); - onedto.setTask_id(IdUtil.simpleUUID()); - onedto.setTask_code(task_code); - onedto.setStart_device_code(start_device_code); - onedto.setStart_point_code(start_device_code); - onedto.setPut_device_code(put_device_code); - onedto.setPut_point_code(put_device_code); - onedto.setNext_point_code(next_device_code); - onedto.setNext_device_code(next_device_code); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - try { - taskserver.create(onedto); - flag = true; - } catch (Exception e) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - } - } else { - //清洗倒料位是没有工单的 - if (route_link_device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) { - //优先判断是否有相同的物料 - //优先找相同的物料的倒料位,然后判断最大重量是否可放,如果都没有则找个空的位置 - //需要在这个驱动中设置允许最大重量,如果当前重量超过了,则不能倒料 - hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) route_link_device.getDeviceDriver(); - String material = route_link_device.getMaterial(); - int maxWeight = Integer.parseInt(route_link_device.getExtraValue().get("max_weight").toString()); - //此处需要考虑已有任务的情况 - if (StrUtil.equals(material,cpbh) && hailiangCleaningMachineStorageStationDeviceDriver.getSilo_weight() < maxWeight ){ - clear_storage_device = route_link_device.getDevice_code(); - //直接生成任务 - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_status("0"); - onedto.setAgv_system_type("1"); - onedto.setTask_type("1"); - onedto.setPriority("101"); - onedto.setStart_device_code(this.getDevice().getDevice_code()); - onedto.setStart_point_code(this.getDevice().getDevice_code()); - onedto.setPut_device_code(route_device_code); - onedto.setPut_point_code(route_device_code); - onedto.setNext_point_code(empty_device); - onedto.setNext_device_code(empty_device); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - - try { - taskserver.create(onedto); - route_link_device.setMaterial(cpbh); - hailiangCleaningMachineStorageStationDeviceDriver.setMaterial(cpbh); - flag = true; - break; - } catch (Exception e) { - route_link_device.setMaterial(""); - hailiangCleaningMachineStorageStationDeviceDriver.setMaterial(""); - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务成功"); - break; - } - } - } - } - - if(StrUtil.isEmpty(clear_storage_device)){ - //表示没有该物料工位 直接寻找空位倒料 - for (int i = 0; i < list.size(); i++) { - RouteLineDto dto = list.get(i); - //找到路由对应工位 - String route_device_code = dto.getNext_device_code(); - Device route_link_device = deviceAppservice.findDeviceByCode(route_device_code); - if (route_link_device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) { - hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) route_link_device.getDeviceDriver(); - //寻找空位倒料 - String material = route_link_device.getMaterial(); - if (StrUtil.isEmpty(material)){ - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_status("0"); - onedto.setPriority("101"); - onedto.setAgv_system_type("1"); - onedto.setTask_type("1"); - onedto.setStart_device_code(this.getDevice().getDevice_code()); - onedto.setStart_point_code(this.getDevice().getDevice_code()); - onedto.setPut_device_code(route_device_code); - onedto.setPut_point_code(route_device_code); - onedto.setNext_point_code(empty_device); - onedto.setNext_device_code(empty_device); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - try { - taskserver.create(onedto); - //将当前工单物料赋给对应的清洗路由工位 - route_link_device.setMaterial(cpbh); - hailiangCleaningMachineStorageStationDeviceDriver.setMaterial(cpbh); - flag = true; - break; - } catch (Exception e) { - route_link_device.setMaterial(""); - hailiangCleaningMachineStorageStationDeviceDriver.setMaterial(""); - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - break; - } - } - } - } - - //生成任务成功 - if (flag) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":专机生成任务成功"); - requireSucess = true; - } else { - //如果都没有则调用mes接口申请入缓存线 - //生成任务 - //前往缓存线 - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":分配任务缓存线"); - } - } - return true; - } - - public synchronized boolean applyInCacheLineTask() throws Exception { - Boolean flag = false; - - //生成任务成功 - if (flag) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":专机生成任务成功"); - requireSucess = true; - } else { - //如果都没有则调用mes接口申请入缓存线 - //生成任务 - //前往缓存线 - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":分配任务缓存线"); - } - - return true; - } - - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/ItemProtocol.java deleted file mode 100644 index 68d6694..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_full_station/ItemProtocol.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_full_station; - -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_status = "status"; - public static String item_finish = "finish"; - public static String item_all_ready = "all_ready"; - public static String item_order = "order"; - public static String item_error = "error"; - public static String item_task = "task"; - public static String item_full_number = "full_number"; - - public static String item_to_agv_ready = "to_agv_ready"; - - public static String item_to_agv_finish = "to_agv_finish"; - - private HailiangSpecialFullStationDeviceDriver driver; - - public ItemProtocol(HailiangSpecialFullStationDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMove() { - return this.getOpcIntegerValue(item_move); - } - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getFinish() { return this.getOpcIntegerValue(item_finish);} - - public int getAllReady() { return this.getOpcIntegerValue(item_all_ready);} - - public int getOrder() { return this.getOpcIntegerValue(item_order);} - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getFull_number() { - return this.getOpcIntegerValue(item_full_number); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - //System.out.println(driver.getDevice_code()+":" + protocol+"数据同步异常"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_mode, "是否启动", "DB1.B0.1")); - list.add(new ItemDto(item_move, "光电开关信号", "DB1.B1.0")); - list.add(new ItemDto(item_status, "手自动状态", "DB1.B0.0", Boolean.valueOf(true))); - list.add(new ItemDto(item_finish, "是否完成", "DB1.B0.7")); - list.add(new ItemDto(item_all_ready, "所有设备就绪", "DB1.B1.6")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W4")); - list.add(new ItemDto(item_task, "任务号", "DB1.D22")); - list.add(new ItemDto(item_order, "工单号", "DB1.D160")); - list.add(new ItemDto(item_full_number, "出料口满框数量", "DB1.D96")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_agv_ready, "AGV就绪", "DB2.W8", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_agv_finish, "AGV完成", "DB2.W10", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/HailiangSpecialPickStationDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/HailiangSpecialPickStationDefination.java deleted file mode 100644 index bc2464c..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/HailiangSpecialPickStationDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pick_station; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮专机设备接框位 - */ -@Service -public class HailiangSpecialPickStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_special_pick_station"; - } - - @Override - public String getDriverName() { - return "海亮-专机设备接框位"; - } - - @Override - public String getDriverDescription() { - return "海亮-专机设备接框位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangSpecialPickStationDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangSpecialPickStationDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/HailiangSpecialPickStationDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/HailiangSpecialPickStationDeviceDriver.java deleted file mode 100644 index e300a5c..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/HailiangSpecialPickStationDeviceDriver.java +++ /dev/null @@ -1,406 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pick_station; - -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.config.server.AcsConfigService; -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.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -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.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; - -/** - * 海亮专机设备接框位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangSpecialPickStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @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 - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @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 status = 0; - int error = 0; - int task = 0; - int finish = 0; - int order = 0; - int full_number = 0; - //出入库模式 - int operation_type = 0; - int last_mode = 0; - int last_status = 0; - int last_error = 0; - int last_task = 0; - int last_finish = 0; - int last_order = 0; - int last_full_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 Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - mode = this.itemProtocol.getMode(); - status = this.itemProtocol.getStatus(); - order = this.itemProtocol.getOrder(); - finish = this.itemProtocol.getFinish(); - full_number = this.itemProtocol.getFull_number(); - - if (mode != last_mode) { - this.setRequireSucess(false); - logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess); - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (status != last_status) { - logServer.deviceLog(this.device_code,"status" ,String.valueOf(status)); - logServer.deviceLogToacs(this.device_code,"","","信号status:" + last_status + "->" + status); - } - if (task != last_task) { - logServer.deviceLog(this.device_code,"task" ,String.valueOf(task)); - logServer.deviceLogToacs(this.device_code,"","","信号task:" + last_task + "->" + task); - } - if (full_number != last_full_number) { - logServer.deviceLog(this.device_code,"full_number" ,String.valueOf(full_number)); - logServer.deviceLogToacs(this.device_code,"","","信号full_number:" + last_full_number + "->" + full_number); - } - if (finish != last_finish) { - logServer.deviceLog(this.device_code,"finish" ,String.valueOf(finish)); - logServer.deviceLogToacs(this.device_code,"","","信号finish:" + last_finish + "->" + finish); - } - if (order != last_order) { - logServer.deviceLog(this.device_code,"order" ,String.valueOf(order)); - logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - -/* if (mode == 2 && move != 0 && task > 0) { - - }*/ - } 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("设备运转模式:等待工作"); - break; - case 2: - //申请任务 - - break; - case 3: - - break; - case 4: - //叫料 - - break; - case 5: - //申请空盘 - /* if (move == 0 && !requireSucess) { - apply_OutEmpty(); - }*/ - break; - case 6: - //申请入库 - /* if (move != 0 && !applySucess) { - instruction_apply(); - } - if (move != 0 && !requireSucess) { - apply_InEmpty(); - }*/ - break; - } - - - } - last_mode = mode; - last_status = status; - last_error = error; - last_task = task; - last_full_number = full_number; - last_finish = finish; - last_order = order; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) {} - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } - - public boolean instruction_apply() throws Exception { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() throws Exception { - return false; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/ItemProtocol.java deleted file mode 100644 index 305c9f4..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pick_station/ItemProtocol.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pick_station; - -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_finish = "finish"; - public static String item_order = "order"; - public static String item_error = "error"; - public static String item_full_number = "full_number"; - public static String item_task = "task"; - public static String item_status = "status"; - - public static String item_to_agv_ready = "to_agv_ready"; - - public static String item_to_agv_finish = "to_agv_finish"; - - - private HailiangSpecialPickStationDeviceDriver driver; - - public ItemProtocol(HailiangSpecialPickStationDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getFinish() { return this.getOpcIntegerValue(item_finish);} - - public int getOrder() { return this.getOpcIntegerValue(item_order);} - - public int getFull_number() { return this.getOpcIntegerValue(item_full_number);} - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_mode, "是否启动", "DB1.B0.1")); - list.add(new ItemDto(item_status, "手自动状态", "DB1.B0.0", Boolean.valueOf(true))); - list.add(new ItemDto(item_finish, "是否完成", "DB1.B0.7")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W4")); - list.add(new ItemDto(item_task, "任务号", "DB1.D22")); - list.add(new ItemDto(item_full_number, "出料口满框数量", "DB1.D96")); - list.add(new ItemDto(item_order, "工单号", "DB1.D160")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/HailiangSpecialPourStationDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/HailiangSpecialPourStationDefination.java deleted file mode 100644 index fa86a6f..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/HailiangSpecialPourStationDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pour_station; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮专机设备倒料位 - */ -@Service -public class HailiangSpecialPourStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_special_pour_station"; - } - - @Override - public String getDriverName() { - return "海亮-专机设备倒料位"; - } - - @Override - public String getDriverDescription() { - return "海亮-专机设备倒料位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangSpecialPourStationDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangSpecialPourStationDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/HailiangSpecialPourStationDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/HailiangSpecialPourStationDeviceDriver.java deleted file mode 100644 index 37ade75..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/HailiangSpecialPourStationDeviceDriver.java +++ /dev/null @@ -1,515 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pour_station; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -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.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.start.auto.run.NDCSocketConnectionAutoRun; -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; - -/** - * 海亮专机设备倒料位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HailiangSpecialPourStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @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 - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.class); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - private Date instruction_require_time = new Date(); - private int instruction_require_time_out = 3000; - int mode = 0; - int error = 0; - int task = 0; - int status = 0; - int running = 0; - int finish = 0; - int all_ready = 0; - int storage_stock_num = 0; - int line_stock_num = 0; - int order = 0; - int full_number = 0; - //出入库模式 - int operation_type = 0; - int last_mode = 0; - int last_error = 0; - int last_task = 0; - int last_status = 0; - int last_running = 0; - int last_finish = 0; - int last_all_ready = 0; - int last_storage_stock_num = 0; - int last_line_stock_num = 0; - int last_order = 0; - int last_full_number = 0; - - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - private Date instruction_apply_time = new Date(); - int agvphase=0; - int index =0; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - 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 = 0; - - String device_code; - - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - status = this.itemProtocol.getStatus(); - running = this.itemProtocol.getRunning(); - finish = this.itemProtocol.getFinish(); - all_ready = this.itemProtocol.getAllReady(); - storage_stock_num = this.itemProtocol.getStorage_stock_num(); - line_stock_num = this.itemProtocol.getLine_stock_num(); - order = this.itemProtocol.getOrder(); - full_number = this.itemProtocol.getFull_number(); - if (mode != last_mode) { - this.setRequireSucess(false); - logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess); - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (task != last_task) { - logServer.deviceLog(this.device_code,"task" ,String.valueOf(task)); - logServer.deviceLogToacs(this.device_code,"","","信号task:" + last_task + "->" + task); - } - if (full_number != last_full_number) { - logServer.deviceLog(this.device_code,"full_number" ,String.valueOf(full_number)); - logServer.deviceLogToacs(this.device_code,"","","信号full_number:" + last_full_number + "->" + full_number); - } - if (finish != last_finish) { - logServer.deviceLog(this.device_code,"finish" ,String.valueOf(finish)); - logServer.deviceLogToacs(this.device_code,"","","信号finish:" + last_finish + "->" + finish); - } - if (order != last_order) { - logServer.deviceLog(this.device_code,"order" ,String.valueOf(order)); - logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - if (status != last_status) { - logServer.deviceLog(this.device_code,"status" ,String.valueOf(status)); - logServer.deviceLogToacs(this.device_code,"","","信号status:" + last_status + "->" + status); - } - if (storage_stock_num != last_storage_stock_num) { - logServer.deviceLog(this.device_code,"storage_stock_num" ,String.valueOf(storage_stock_num)); - logServer.deviceLogToacs(this.device_code,"","","信号storage_stock_num:" + last_storage_stock_num + "->" + storage_stock_num); - } - if (all_ready != last_all_ready) { - logServer.deviceLog(this.device_code,"all_ready" ,String.valueOf(all_ready)); - logServer.deviceLogToacs(this.device_code,"","","信号all_ready:" + last_all_ready + "->" + all_ready); - } - if (line_stock_num != last_line_stock_num) { - logServer.deviceLog(this.device_code,"line_stock_num" ,String.valueOf(line_stock_num)); - logServer.deviceLogToacs(this.device_code,"","","信号line_stock_num:" + last_line_stock_num + "->" + line_stock_num); - } - if (running != last_running) { - logServer.deviceLog(this.device_code,"running" ,String.valueOf(running)); - logServer.deviceLogToacs(this.device_code,"","","信号running:" + last_running + "->" + running); - } - - - } 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; - - if(!requireSucess){ - if ( mode == 1) { - logServer.deviceLogToacs(this.device_code,"","",device_code+":requireSucess:" + requireSucess + "开始申请任务"); - applyOutCacheLineTask(); - } else { - logServer.deviceLogToacs(this.device_code,"","",device_code+":requireSucess:" + requireSucess + "申请任务失败,不符合条件"); - } - } else { - logServer.deviceLogToacs(this.device_code,"","","是否请求成功:requireSucess:"+requireSucess); - - } - - if(agvphase == 0x0B || agvphase == 0x0F ) - { - if(error == 0 && ObjectUtil.isNotEmpty(inst)){ - inst.setExecute_status("3"); - instructionService.update(inst); - writing("to_agv_ready", "1"); - byte[] data = agvService.sendAgvTwoModeInst(agvphase, index, 0); - NDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - }else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因error:"+error+",inst"+inst); - - } - } - - if(agvphase == 0x0D || agvphase == 0x11){ - if(error == 0 && ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("4"); - instructionService.update(inst); - writing("item_to_pour_num", inst.getQuantity()); - byte[] data = agvService.sendAgvTwoModeInst(agvphase, index, 0); - agvphase = 0; - index = 0; - }else { - logServer.deviceLogToacs(this.device_code,"","","agvphase:" + agvphase + "等待反馈,原因error:"+error+",inst"+inst); - } - } - - } - last_mode = mode; - last_error = error; - last_task = task; - last_status = status; - last_running = running; - last_finish = finish; - last_all_ready = all_ready; - last_storage_stock_num = storage_stock_num; - last_line_stock_num = line_stock_num; - last_order = order; - last_full_number = full_number; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public synchronized boolean applyOutCacheLineTask() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - Boolean flag = false; - Device device = deviceAppservice.findDeviceByCode(device_code); - Integer min_num = Integer.parseInt(device.getExtraValue().get("min_num")+""); - if (storage_stock_num < min_num ){ - JSONObject json = new JSONObject(); - json.put("device_code",device_code); - json.put("type","2"); - HttpResponse httpResponse = acsToWmsService.applyOutCacheLineTask(json); - String body = httpResponse.body(); - JSONObject jsonObject = JSONObject.parseObject(body); - String ext_task_id = jsonObject.getString("ext_task_id"); - String task_code = jsonObject.getString("task_code"); - String start_device_code = jsonObject.getString("start_device_code"); - String put_device_code = jsonObject.getString("put_device_code"); - String next_device_code = jsonObject.getString("next_device_code"); - String task_type = jsonObject.getString("task_type"); - TaskDto onedto = new TaskDto(); - String now = DateUtil.now(); - onedto.setTask_id(IdUtil.simpleUUID()); - onedto.setQuantity(String.valueOf(full_number)); - onedto.setCreate_by(this.getDevice().getDevice_code()); - onedto.setUpdate_by(this.getDevice().getDevice_code()); - onedto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - onedto.setTask_code("-" + taskcode); - onedto.setTask_status("0"); - onedto.setPriority("101"); - onedto.setAgv_system_type("1"); - onedto.setTask_type(task_type); - onedto.setExt_task_id(ext_task_id); - onedto.setTask_id(IdUtil.simpleUUID()); - onedto.setTask_code(task_code); - onedto.setStart_device_code(start_device_code); - onedto.setStart_point_code(start_device_code); - onedto.setPut_device_code(put_device_code); - onedto.setPut_point_code(put_device_code); - onedto.setNext_point_code(next_device_code); - onedto.setNext_device_code(next_device_code); - onedto.setUpdate_time(now); - onedto.setCreate_time(now); - try { - taskserver.create(onedto); - flag = true; - } catch (Exception e) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":创建任务失败," + String.valueOf(e.getMessage())); - } - } - //生成任务成功 - if (flag) { - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":专机生成任务成功"); - requireSucess = true; - } else { - //如果都没有则调用mes接口申请入缓存线 - //生成任务 - //前往缓存线 - logServer.deviceLogToacs(this.device_code, "", "", device_code + ":分配任务缓存线"); - } - } - - return true; - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) {} - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - } - - public void writing(int type, int command) { - - - } - - public boolean instruction_apply() throws Exception { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() throws Exception { - return false; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/ItemProtocol.java deleted file mode 100644 index e2fa98a..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_special_pour_station/ItemProtocol.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pour_station; - -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_status = "status"; - public static String item_running = "running"; - public static String item_finish = "finish"; - public static String item_all_ready = "all_ready"; - public static String item_storage_stock_num = "storage_stock_num"; - public static String item_line_stock_num = "line_stock_num"; - public static String item_order = "order"; - public static String item_error = "error"; - public static String item_full_number = "full_number"; - public static String item_task = "task"; - - public static String item_to_pour_num = "to_item_pour_num"; - - private HailiangSpecialPourStationDeviceDriver driver; - - public ItemProtocol(HailiangSpecialPourStationDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getRunning() { return this.getOpcIntegerValue(item_running);} - - public int getFinish() { return this.getOpcIntegerValue(item_finish);} - - public int getAllReady() { return this.getOpcIntegerValue(item_all_ready);} - - public int getOrder() { return this.getOpcIntegerValue(item_order);} - - public int getFull_number() { return this.getOpcIntegerValue(item_full_number);} - public int getLine_stock_num() { return this.getOpcIntegerValue(item_line_stock_num);} - public int getStorage_stock_num() { return this.getOpcIntegerValue(item_storage_stock_num);} - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.D82")); - list.add(new ItemDto(item_mode, "是否启动", "DB1.B0.1")); - list.add(new ItemDto(item_status, "手自动状态", "DB1.B0.0", Boolean.valueOf(true))); - list.add(new ItemDto(item_running, "是否运行", "DB1.B0.6")); - list.add(new ItemDto(item_all_ready, "所有设备就绪", "DB1.B1.6")); - list.add(new ItemDto(item_error, "报警信号", "DB1.W4")); - list.add(new ItemDto(item_full_number, "出料口满框数量", "DB1.D96")); - list.add(new ItemDto(item_storage_stock_num, "储料仓库存数量", "DB1.D100")); - list.add(new ItemDto(item_line_stock_num, "线体库存数量", "DB1.D104")); - list.add(new ItemDto(item_task, "任务号", "DB1.D22")); - list.add(new ItemDto(item_order, "工单号", "DB1.D160")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_pour_num, "倒料数量", "DB1.D96")); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/HailiangHailiangxjplcTestDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/HailiangHailiangxjplcTestDeviceDriver.java deleted file mode 100644 index a1463ea..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/HailiangHailiangxjplcTestDeviceDriver.java +++ /dev/null @@ -1,300 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_xj_plc_test; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.server.AcsConfigService; -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.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.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.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -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.start.auto.run.NDCSocketConnectionAutoRun; -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 HailiangHailiangxjplcTestDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - LogServer logServer = SpringContextHolder.getBean(LogServer.class); - @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.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 heartbeat = 0; - int mode =0; - int error =0; - int error_num =0; - int open_time =0; - int close_time =0; - int ready_time =0; - int running_time =0; - int error_time =0; - int voltage =0; - int temperature =0; - int current =0; - int material =0; - int lack_material =0; - int full_material =0; - int storage_qty =0; - int feeding_qty =0; - int blanking_qty =0; - int qualified_qty =0; - int unqualified_qty =0; - int finish =0; - int task =0; - int noload_electricity_consumption =0; - int prod_electricity_consumption =0; - int gas_consumption =0; - int water_consumption =0; - int oil_level =0; - int monthly_electricity_consumption =0; - int pause =0; - - - int last_mode =0; - int last_error =0; - int last_error_num =0; - int last_open_time =0; - int last_close_time =0; - int last_ready_time =0; - int last_running_time =0; - int last_error_time =0; - int last_voltage =0; - int last_temperature =0; - int last_current =0; - int last_material =0; - int last_lack_material =0; - int last_full_material =0; - int last_storage_qty =0; - int last_feeding_qty =0; - int last_blanking_qty =0; - int last_qualified_qty =0; - int last_unqualified_qty =0; - int last_finish =0; - int last_task =0; - int last_noload_electricity_consumption =0; - int last_prod_electricity_consumption =0; - int last_gas_consumption =0; - int last_water_consumption =0; - int last_oil_level =0; - int last_monthly_electricity_consumption =0; - int last_pause =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; - - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag = 0; - - - int agvphase=0; - int index =0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - error = this.itemProtocol.getItem_error(); - error_num = this.itemProtocol.getItem_error_num(); - open_time = this.itemProtocol.getItem_open_time(); - close_time = this.itemProtocol.getItem_close_time(); - ready_time = this.itemProtocol.getItem_ready_time(); - running_time = this.itemProtocol.getItem_running_time(); - error_time = this.itemProtocol.getItem_error_time(); - voltage = this.itemProtocol.getItem_voltage(); - temperature = this.itemProtocol.getItem_temperature(); - current = this.itemProtocol.getItem_current(); - material = this.itemProtocol.getItem_material(); - lack_material = this.itemProtocol.getItem_lack_material(); - full_material = this.itemProtocol.getItem_full_material(); - storage_qty = this.itemProtocol.getItem_storage_qty(); - feeding_qty = this.itemProtocol.getItem_feeding_qty(); - blanking_qty = this.itemProtocol.getItem_blanking_qty(); - qualified_qty = this.itemProtocol.getItem_qualified_qty(); - unqualified_qty = this.itemProtocol.getItem_unqualified_qty(); - finish = this.itemProtocol.getItem_finish(); - task = this.itemProtocol.getItem_task(); - noload_electricity_consumption = this.itemProtocol.getItem_noload_electricity_consumption(); - prod_electricity_consumption = this.itemProtocol.getItem_prod_electricity_consumption(); - gas_consumption = this.itemProtocol.getItem_gas_consumption(); - water_consumption = this.itemProtocol.getItem_water_consumption(); - oil_level = this.itemProtocol.getItem_oil_level(); - monthly_electricity_consumption = this.itemProtocol.getItem_monthly_electricity_consumption(); - pause = this.itemProtocol.getItem_pause(); - - if (mode != last_mode) { - this.setRequireSucess(false); - logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess); - logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); - logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); - } - if (error != last_error) { - logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); - logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); - } - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - logServer.deviceLogToacs(this.device_code,"","","光电信号切换,刷新请求标记:"+this.requireSucess); - - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - } - - public void writing(String key, String value) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, value); - ReadUtil.write(itemMap, server); - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/HailiangxjplcTestDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/HailiangxjplcTestDefination.java deleted file mode 100644 index 6a7411a..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/HailiangxjplcTestDefination.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_xj_plc_test; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮迅捷plc测试 - */ -@Service -public class HailiangxjplcTestDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_xj_plc_test"; - } - - @Override - public String getDriverName() { - return "海亮-海亮迅捷plc测试"; - } - - @Override - public String getDriverDescription() { - return "海亮-海亮迅捷plc测试"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HailiangHailiangxjplcTestDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HailiangHailiangxjplcTestDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/ItemProtocol.java deleted file mode 100644 index 0dfa78b..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_xj_plc_test/ItemProtocol.java +++ /dev/null @@ -1,248 +0,0 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_xj_plc_test; - -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_error = "error"; - public static String item_error_num = "error_num"; - public static String item_open_time = "open_time"; - public static String item_close_time = "close_time"; // - public static String item_ready_time = "ready_time"; // - public static String item_running_time = "running_time"; - public static String item_error_time = "error_time"; - public static String item_voltage = "voltage"; - public static String item_temperature = "temperature"; - public static String item_current = "current"; - public static String item_material = "material"; - public static String item_lack_material = "lack_material"; - public static String item_full_material = "full_material"; - public static String item_storage_qty = "storage_qty"; - public static String item_feeding_qty = "feeding_qty"; - public static String item_blanking_qty = "blanking_qty"; - public static String item_qualified_qty = "qualified_qty"; - public static String item_unqualified_qty = "unqualified_qty"; - public static String item_finish = "finish"; - public static String item_task = "task"; - public static String item_noload_electricity_consumption = "noload_electricity_consumption"; - public static String item_prod_electricity_consumption = "prod_electricity_consumption"; - public static String item_gas_consumption = "gas_consumption"; - public static String item_water_consumption = "water_consumption"; - public static String item_oil_level = "oil_level"; - public static String item_monthly_electricity_consumption = "monthly_electricity_consumption"; - public static String item_pause = "pause"; - - - - public static String item_to_heartbeat = "to_heartbeat";// - public static String item_to_command = "to_command";// - public static String item_to_feeding = "to_feeding";// - public static String item_to_task = "to_task";// - public static String item_to_pause= "to_pause";// - public static String item_to_clear = "to_clear";// - public static String item_to_finish = "to_finish";// - public static String item_to_open = "to_open";// - public static String item_to_close = "to_close";// - public static String item_to_material = "to_material";// - public static String item_to_qty = "to_qty";// - - - private HailiangHailiangxjplcTestDeviceDriver driver; - - public ItemProtocol(HailiangHailiangxjplcTestDeviceDriver driver) { - this.driver = driver; - } - - public int getItem_heartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getItem_mode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getItem_error() { - return this.getOpcIntegerValue(item_error); - } - - public int getItem_error_num() { - return this.getOpcIntegerValue(item_error_num); - } - - public int getItem_open_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getItem_close_time() { - return this.getOpcIntegerValue(item_close_time); - } - - public int getItem_ready_time() { - return this.getOpcIntegerValue(item_ready_time); - } - - public int getItem_running_time() { - return this.getOpcIntegerValue(item_running_time); - } - - public int getItem_error_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getItem_voltage() { - return this.getOpcIntegerValue(item_voltage); - } - - public int getItem_temperature() { - return this.getOpcIntegerValue(item_temperature); - } - - public int getItem_current() { - return this.getOpcIntegerValue(item_current); - } - - public int getItem_material() { - return this.getOpcIntegerValue(item_material); - } - - public int getItem_lack_material() { - return this.getOpcIntegerValue(item_lack_material); - } - - public int getItem_full_material() { - return this.getOpcIntegerValue(item_full_material); - } - - public int getItem_storage_qty() { - return this.getOpcIntegerValue(item_storage_qty); - } - - public int getItem_feeding_qty() { - return this.getOpcIntegerValue(item_feeding_qty); - } - - public int getItem_blanking_qty() { - return this.getOpcIntegerValue(item_blanking_qty); - } - - public int getItem_qualified_qty() { - return this.getOpcIntegerValue(item_qualified_qty); - } - - public int getItem_unqualified_qty() { - return this.getOpcIntegerValue(item_unqualified_qty); - } - - public int getItem_finish() { - return this.getOpcIntegerValue(item_mode); - } - - public int getItem_task() { - return this.getOpcIntegerValue(item_task); - } - - public int getItem_noload_electricity_consumption() { - return this.getOpcIntegerValue(item_noload_electricity_consumption); - } - - public int getItem_prod_electricity_consumption() { - return this.getOpcIntegerValue(item_prod_electricity_consumption); - } - - public int getItem_gas_consumption() { - return this.getOpcIntegerValue(item_gas_consumption); - } - - public int getItem_water_consumption() { - return this.getOpcIntegerValue(item_water_consumption); - } - - public int getItem_oil_level() { - return this.getOpcIntegerValue(item_oil_level); - } - - public int getItem_monthly_electricity_consumption() { - return this.getOpcIntegerValue(item_monthly_electricity_consumption); - } - - public int getItem_pause() { - return this.getOpcIntegerValue(item_pause); - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "45203")); - list.add(new ItemDto(item_mode, "模式", "45205")); - list.add(new ItemDto(item_error, "故障", "45207")); - list.add(new ItemDto(item_error_num, "故障次数", "45209")); - list.add(new ItemDto(item_open_time, "开机时间", "45213")); - list.add(new ItemDto(item_close_time, "关机时间", "45217")); - list.add(new ItemDto(item_ready_time, "待机时间", "45221")); - list.add(new ItemDto(item_running_time, "生产时间", "45225")); - list.add(new ItemDto(item_error_time, "故障时间", "45229")); - list.add(new ItemDto(item_temperature, "温度", "45233")); - list.add(new ItemDto(item_voltage, "电压", "45237")); - list.add(new ItemDto(item_current, "电流", "45241")); - list.add(new ItemDto(item_material, "当前生产产品编号", "45245")); - list.add(new ItemDto(item_lack_material, "生产缺料信号", "45249")); - list.add(new ItemDto(item_full_material, "生产满料信号", "45253")); - list.add(new ItemDto(item_storage_qty, "储料斗数量", "45257")); - list.add(new ItemDto(item_feeding_qty, "上料数量", "45261")); - list.add(new ItemDto(item_blanking_qty, "下料数量", "45265")); - list.add(new ItemDto(item_qualified_qty, "当前生产合格品数量", "45269")); - list.add(new ItemDto(item_unqualified_qty, "当前生产不合格数量", "45273")); - list.add(new ItemDto(item_finish, "生产完成", "45277")); - list.add(new ItemDto(item_task, "任务号", "45281")); - list.add(new ItemDto(item_noload_electricity_consumption, "空载电能耗(未生产时)", "45285")); - list.add(new ItemDto(item_prod_electricity_consumption, "生产电能耗", "45289")); - list.add(new ItemDto(item_gas_consumption, "气压能耗", "45293")); - list.add(new ItemDto(item_water_consumption, "水流量能耗", "452967")); - list.add(new ItemDto(item_oil_level, "当前液压油位", "45301")); - list.add(new ItemDto(item_monthly_electricity_consumption, "本月总电能耗", "45305")); - list.add(new ItemDto(item_pause, "设备暂停", "45309")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_heartbeat, "心跳", "45703")); - list.add(new ItemDto(item_to_command, "下发命令", "45705")); - list.add(new ItemDto(item_to_feeding, "下发命令", "45707")); - list.add(new ItemDto(item_to_task, "任务号", "45711")); - list.add(new ItemDto(item_to_pause, "生产暂停", "45715")); - list.add(new ItemDto(item_to_clear, "当前产量清零", "45719")); - list.add(new ItemDto(item_to_finish, "强制完成", "45723")); - list.add(new ItemDto(item_to_open, "设备开机", "45727")); - list.add(new ItemDto(item_to_close, "设备关机", "45731")); - list.add(new ItemDto(item_to_material, "当前任务生产物料", "45735")); - list.add(new ItemDto(item_to_qty, "当前任务生产数量", "45739")); - return list; - } - - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java similarity index 94% rename from wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java rename to wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java index 73e03b4..64017e2 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_smart_plc_test; +package org.nl.acs.device_driver.basedriver.hailiang_smart_plc_test; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device_driver.DeviceDriver; diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java new file mode 100644 index 0000000..c5a1dbf --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java @@ -0,0 +1,102 @@ +package org.nl.acs.device_driver.basedriver.hailiang_smart_plc_test; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.server.AgvService; +import org.nl.acs.config.server.AcsConfigService; +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.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +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.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.Map; + +/** + * 海亮清洗机储料仓 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); + @Autowired + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + @Autowired + AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); + @Autowired + LogServer logServer = SpringContextHolder.getBean(LogServer.class); + @Autowired + AgvService agvService = SpringContextHolder.getBean(AgvService.class); + + int heartbeat = 0; + int mode = 0; + int move = 0; + int action = 0; + int error = 0; + int number = 0; + int container_type = 0; + int task = 0; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getItem_heartbeat(); + mode = this.itemProtocol.getItem_mode(); + move = this.itemProtocol.getItem_mode(); + action = this.itemProtocol.getItem_action(); + error = this.itemProtocol.getItem_error(); + number = this.itemProtocol.getItem_number(); + container_type = this.itemProtocol.getItem_container_type(); + task = this.itemProtocol.getItem_task(); + + } + + public void writing(int command) { + + } + + public void writing(String key, String value) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + key; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, value); + ReadUtil.write(itemMap, server); + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/ItemProtocol.java new file mode 100644 index 0000000..4c9da20 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/ItemProtocol.java @@ -0,0 +1,105 @@ +package org.nl.acs.device_driver.basedriver.hailiang_smart_plc_test; + +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_target = "to_target";// + public static String item_to_command = "to_command";// + public static String item_to_task = "to_task";// + + + private HailiangSmartplcTestDeviceDriver driver; + + public ItemProtocol(HailiangSmartplcTestDeviceDriver driver) { + this.driver = driver; + } + + public int getItem_heartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getItem_mode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getItem_move() { + return this.getOpcIntegerValue(item_move); + } + + public int getItem_action() { + return this.getOpcIntegerValue(item_action); + } + + public int getItem_error() { + return this.getOpcIntegerValue(item_action); + } + + public int getItem_number() { + return this.getOpcIntegerValue(item_number); + } + + public int getItem_container_type() { + return this.getOpcIntegerValue(item_container_type); + } + + public int getItem_task() { + return this.getOpcIntegerValue(item_task); + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(item_mode, "模式", "VW2")); + 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")); + 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/lamp_three_color/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lamp_three_color/ItemProtocol.java deleted file mode 100644 index 1320960..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lamp_three_color/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.basedriver.lamp_three_color; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private LampThreecolorDeviceDriver driver; - - public ItemProtocol(LampThreecolorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - //log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); - list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lamp_three_color/LampThreecolorDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lamp_three_color/LampThreecolorDefination.java deleted file mode 100644 index 57f583c..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lamp_three_color/LampThreecolorDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.basedriver.lamp_three_color; - -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 LampThreecolorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lamp_three_color"; - } - - @Override - public String getDriverName() { - return "标准版-三色灯"; - } - - @Override - public String getDriverDescription() { - return "标准版-三色灯"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LampThreecolorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LampThreecolorDeviceDriver.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.B1", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); - 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/lamp_three_color/LampThreecolorDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lamp_three_color/LampThreecolorDeviceDriver.java deleted file mode 100644 index ab5b311..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lamp_three_color/LampThreecolorDeviceDriver.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.nl.acs.device_driver.basedriver.lamp_three_color; - -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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -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.Map; - -/** - * 检测站点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - 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"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - 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; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - } - last_action = action; - last_mode = mode; - last_error = error; - //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); - -// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); - - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_inspect_site.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); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - } - - public synchronized void OpenOrClose(String type) { - - writing(Integer.parseInt(type)); - - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDefination.java deleted file mode 100644 index 568a69e..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.basedriver.manipulator_inspect_site_NDC; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 区域管制设备交互站点-NDC - */ -@Service -public class ManipulatorInspectSiteNDCDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "manipulator_inspect_site_NDC"; - } - - @Override - public String getDriverName() { - return "区域管制站点-NDC"; - } - - @Override - public String getDriverDescription() { - return "区域管制站点-NDC"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new ManipulatorInspectSiteNDCDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return ManipulatorInspectSiteNDCDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDeviceDriver.java deleted file mode 100644 index 8e6d4a3..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDeviceDriver.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nl.acs.device_driver.basedriver.manipulator_inspect_site_NDC; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; - - -/** - * 区域管制设备交互站点-NDC - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class ManipulatorInspectSiteNDCDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - String relevance_device_code; - - @Override - public void execute() { - } -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java deleted file mode 100644 index 6303cd7..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.basedriver.standard_autodoor; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private StandardAutodoorDeviceDriver driver; - - public ItemProtocol(StandardAutodoorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); - list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDefination.java deleted file mode 100644 index 0025bda..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.basedriver.standard_autodoor; - -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 StandardAutodoorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_autodoor"; - } - - @Override - public String getDriverName() { - return "标准版-自动门"; - } - - @Override - public String getDriverDescription() { - return "标准版-自动门"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardAutodoorDeviceDriver.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.B1", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); - 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/standard_autodoor/StandardAutodoorDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDeviceDriver.java deleted file mode 100644 index 0cd742a..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/StandardAutodoorDeviceDriver.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.nl.acs.device_driver.basedriver.standard_autodoor; - -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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -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.Map; - -/** - * 自动门驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - 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"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - Boolean iserror = false; - - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - 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; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - //this.execute_log.setContainer(""); - } - last_action = action; - last_mode = mode; - last_error = error; - //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); - -// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - public void writeing(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); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - - } - - public synchronized void OpenOrClose(String type) { - - //开门 - if ("1".equals(type)) { - writeing(1); - } else { - writeing(2); - } - - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java index 5d4c9ec..5d1497e 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java @@ -1,11 +1,6 @@ package org.nl.acs.device_driver.basedriver.standard_ordinary_site; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -16,28 +11,18 @@ import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; 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.order.service.ProduceshiftorderService; 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.start.auto.run.OneNDCSocketConnectionAutoRun; import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; import org.springframework.beans.factory.annotation.Autowired; -import java.math.BigDecimal; import java.util.Date; @@ -67,8 +52,6 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple @Autowired LogServer logServer = SpringContextHolder.getBean(LogServer.class); @Autowired - ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class); - @Autowired AgvService agvService = SpringContextHolder.getBean(AgvService.class); Integer hasGoods = 0; diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/traffic_light/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/traffic_light/ItemProtocol.java deleted file mode 100644 index 500fbd3..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/traffic_light/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.basedriver.traffic_light; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private TrafficLightDeviceDriver driver; - - public ItemProtocol(TrafficLightDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - //log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "D00000")); - list.add(new ItemDto(item_mode, "工作状态", "D00010", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "D00012")); - list.add(new ItemDto(item_error, "报警信号", "D00014")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "D00016", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/traffic_light/TrafficLightDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/traffic_light/TrafficLightDefination.java deleted file mode 100644 index 4d03f82..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/traffic_light/TrafficLightDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.basedriver.traffic_light; - -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; - -/** - * 标准版-交通灯-欧姆龙plc - */ -@Service -public class TrafficLightDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "traffic_light"; - } - - @Override - public String getDriverName() { - return "标准版-交通灯-欧姆龙plc"; - } - - @Override - public String getDriverDescription() { - return "标准版-交通灯-欧姆龙plc"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new TrafficLightDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return TrafficLightDeviceDriver.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, "心跳", "D00000")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "D00010", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "D00012")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "D00014")); - 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/traffic_light/TrafficLightDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/traffic_light/TrafficLightDeviceDriver.java deleted file mode 100644 index 161d101..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/traffic_light/TrafficLightDeviceDriver.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.nl.acs.device_driver.basedriver.traffic_light; - -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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -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.Map; - -/** - * 标准版-交通灯-欧姆龙plc - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class TrafficLightDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - 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"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - 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; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - } - last_action = action; - last_mode = mode; - last_error = error; - - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - 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); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - } - - public synchronized void OpenOrClose(String type) { - - writing(Integer.parseInt(type)); - - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/HaiLiangCoatingDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/HaiLiangCoatingDefination.java deleted file mode 100644 index bd12db8..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/HaiLiangCoatingDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_coating; - -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 HaiLiangCoatingDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lamp_three_color"; - } - - @Override - public String getDriverName() { - return "标准版-三色灯"; - } - - @Override - public String getDriverDescription() { - return "标准版-三色灯"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HaiLiangCoatingDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HaiLiangCoatingDeviceDriver.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.B1", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/HaiLiangCoatingDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/HaiLiangCoatingDeviceDriver.java deleted file mode 100644 index e723f3d..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/HaiLiangCoatingDeviceDriver.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_coating; - -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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -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.Map; - -/** - * 海亮-裹膜机驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HaiLiangCoatingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - 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"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - 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; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - } - last_action = action; - last_mode = mode; - last_error = error; - //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); - -// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); - - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_inspect_site.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); - //log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - } - - public synchronized void OpenOrClose(String type) { - - writing(Integer.parseInt(type)); - - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/ItemProtocol.java deleted file mode 100644 index cce09b0..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_coating/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_coating; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private HaiLiangCoatingDeviceDriver driver; - - public ItemProtocol(HaiLiangCoatingDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - //log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); - list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/HaiLiangLabelingDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/HaiLiangLabelingDefination.java deleted file mode 100644 index 971bf41..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/HaiLiangLabelingDefination.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_labeling; - -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 HaiLiangLabelingDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_labeling"; - } - - @Override - public String getDriverName() { - return "海亮-贴标机"; - } - - @Override - public String getDriverDescription() { - return "海亮-贴标机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HaiLiangLabelingDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HaiLiangLabelingDeviceDriver.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_mode, "工作状态", "V100.1", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "V100.0")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VB101")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/HaiLiangLabelingDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/HaiLiangLabelingDeviceDriver.java deleted file mode 100644 index 1c9547f..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/HaiLiangLabelingDeviceDriver.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_labeling; - -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_driver.DeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.opc.Device; -import org.openscada.opc.lib.da.Server; - -import java.util.HashMap; -import java.util.Map; - -/** - * 海亮贴标机驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HaiLiangLabelingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - int move = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int branchProtocol = 0; - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - } - // 打印就绪 - if (mode == 1 && error == 0) { - - } - - //打印完成 - if (action == 1) { - - } - last_action = action; - last_mode = mode; - last_error = error; - - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_inspect_site.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); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - } - - public synchronized void OpenOrClose(String type) { - writing(Integer.parseInt(type)); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/ItemProtocol.java deleted file mode 100644 index 455eb8a..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_labeling/ItemProtocol.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_labeling; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private HaiLiangLabelingDeviceDriver driver; - - public ItemProtocol(HaiLiangLabelingDeviceDriver driver) { - this.driver = driver; - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - //log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_mode, "工作状态", "V100.1", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "V100.0")); - list.add(new ItemDto(item_error, "报警信号", "VB101")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "V102.0", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_lettering/HaiLiangLetteringDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_lettering/HaiLiangLetteringDefination.java deleted file mode 100644 index 6214d2f..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_lettering/HaiLiangLetteringDefination.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_lettering; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 海亮刻字机驱动 - */ -@Service -public class HaiLiangLetteringDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "hailiang_lettering"; - } - - @Override - public String getDriverName() { - return "海亮-激光刻字机"; - } - - @Override - public String getDriverDescription() { - return "海亮-激光刻字机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HaiLiangLetteringDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HaiLiangLetteringDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_lettering/HaiLiangLetteringDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_lettering/HaiLiangLetteringDeviceDriver.java deleted file mode 100644 index ce0c6c2..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_lettering/HaiLiangLetteringDeviceDriver.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_lettering; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.utils.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; - - -/** - * - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HaiLiangLetteringDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - Integer hasGoods = 0; - int error = 0; - Boolean iserror = false; - Boolean islock = false; - - int branchProtocol = 0; - int last_branchProtocol = 0; - //是否需要输入物料 - String input_material = "0"; - //备注 - String remark = ""; - //数量 - String qty = ""; - //是否在线 - Boolean is_online = true; - //批次 - String batch = ""; - //物料 - String material = ""; - //目标点位 - String purpose = ""; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - boolean requireSucess = false; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - // 1取货完成 2放货完成 3进入区域 4离开区域 - private int flag; - - //人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0 - private int manua_confirm = 0; - - String devicecode; - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - - String message; - - // 1就绪 2下发刻字 3 刻字完成 - int status; - - int mode = 2; - - int move; - - int action; - - int ioaction; - - @Override - public void execute() { - hasGoods = this.getDevice().getHas_goods(); - material = this.getDevice().getMaterial_type(); - batch = this.getDevice().getBatch(); - devicecode = this.getDeviceCode(); - if (branchProtocol != last_branchProtocol) { - requireSucess = false; - } - switch (branchProtocol) { - case 1: - break; - //呼叫请求 - case 2: - - break; - //响应生成任务 - case 3: - - break; - } - } - - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/HaiLiangPackingDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/HaiLiangPackingDefination.java deleted file mode 100644 index a48b487..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/HaiLiangPackingDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_packing; - -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 HaiLiangPackingDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lamp_three_color"; - } - - @Override - public String getDriverName() { - return "标准版-三色灯"; - } - - @Override - public String getDriverDescription() { - return "标准版-三色灯"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HaiLiangPackingDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return HaiLiangPackingDeviceDriver.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.B1", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/HaiLiangPackingDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/HaiLiangPackingDeviceDriver.java deleted file mode 100644 index 7760e52..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/HaiLiangPackingDeviceDriver.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_packing; - -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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -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.Map; - -/** - * 海亮-包装机驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HaiLiangPackingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - 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"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - 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; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - } - last_action = action; - last_mode = mode; - last_error = error; - //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); - -// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); - - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.basedriver.standard_inspect_site.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); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - } - - public synchronized void OpenOrClose(String type) { - - writing(Integer.parseInt(type)); - - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/ItemProtocol.java deleted file mode 100644 index e904060..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_packing/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.hailiang.hailiang_packing; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private HaiLiangPackingDeviceDriver driver; - - public ItemProtocol(HaiLiangPackingDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - //log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); - list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index d45d192..9376c62 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -70,20 +70,6 @@ public class WmsToAcsController { return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK); } - @PostMapping("/order") - @Log("wms下发acs工单") - @ApiOperation("wms下发acs工单") - public ResponseEntity actionOrder(@RequestBody String whereJson){ - return new ResponseEntity<>(wmstoacsService.actionOrder(whereJson), HttpStatus.OK); - } - - @PostMapping("/orderStatusUpdate") - @Log("工单状态变更") - @ApiOperation("工单状态变更") - public ResponseEntity orderStatusUpdate(@RequestBody String whereJson){ - return new ResponseEntity<>(wmstoacsService.orderStatusUpdate(whereJson), HttpStatus.OK); - } - @PostMapping("/queryDeviceDBValue") @Log("查询设备DB值") @ApiOperation("查询设备DB值") diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index 4c001b2..f9e6347 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -55,20 +55,6 @@ public interface WmsToAcsService { */ Map queryDevice(String jsonObject) throws Exception; - /** - * wms下发工单 - * @param whereJson - * @return - */ - Map actionOrder(String whereJson); - - /** - * 工单状态变更 - * @param whereJson - * @return - */ - Map orderStatusUpdate(String whereJson); - /** * 查询设备DB值 * @param whereJson diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 1b4236e..f6b6d4a 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -1,6 +1,5 @@ package org.nl.acs.ext.wms.service.impl; -import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONArray; @@ -11,10 +10,6 @@ import org.nl.acs.common.IDriverService; import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.device.service.DeviceService; -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_special_device.HailiangSpecialDeviceDriver; -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; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; @@ -27,22 +22,16 @@ import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceExtraManageDto; -import org.nl.acs.order.service.ProduceshiftorderService; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; -import org.nl.exception.BadRequestException; import org.nl.exception.WDKException; -import org.nl.modules.system.util.CodeUtil; import org.nl.utils.SpringContextHolder; import org.nl.wql.core.bean.WQLObject; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -58,7 +47,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { private final DeviceService deviceService; private final DeviceAppService deviceAppService; private final RouteLineService routeLineService; - private final ProduceshiftorderService produceshiftorderService; @Override public Map createFromWms(String param) { @@ -155,7 +143,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (!StrUtil.isEmpty(task_uuid)) { jo.put("ext_task_id", task_uuid); } - + TaskDto task_dto = jo.toJavaObject(TaskDto.class); try { taskService.create(task_dto); @@ -310,8 +298,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver; //扫码器 StandardScannerDeviceDriver standardScannerDeviceDriver; - //自动门 - StandardAutodoorDeviceDriver standardAutodoorDeviceDriver; if (datas.size() == 0) { List list = deviceService.findCacheDevice(); @@ -335,14 +321,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("requestSucess", standardCoveyorControlDeviceDriver.getRequireSucess()); jo.put("applySucess", standardCoveyorControlDeviceDriver.getApplySucess()); jo.put("message", standardCoveyorControlDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardAutodoorDeviceDriver.getMode()); - jo.put("action", standardAutodoorDeviceDriver.getAction()); - jo.put("isOnline", true); - jo.put("error", standardAutodoorDeviceDriver.getError()); - jo.put("isError", standardAutodoorDeviceDriver.getIserror()); } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); jo.put("device_code", device.getDevice_code()); @@ -460,14 +438,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("requestSucess", standardCoveyorControlDeviceDriver.getRequireSucess()); jo.put("applySucess", standardCoveyorControlDeviceDriver.getApplySucess()); jo.put("message", standardCoveyorControlDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardAutodoorDeviceDriver.getMode()); - jo.put("action", standardAutodoorDeviceDriver.getAction()); - jo.put("isOnline", true); - jo.put("error", standardAutodoorDeviceDriver.getError()); - jo.put("isError", standardAutodoorDeviceDriver.getIserror()); } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); jo.put("device_code", device.getDevice_code()); @@ -572,148 +542,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { return resultJson; } - @Override - @Transactional(rollbackFor = Exception.class) - public Map actionOrder(String whereJson) { - JSONArray datas = JSONArray.parseArray(whereJson); - log.info("actionOrder--------------:输入参数" + datas.toString()); - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - for (int i = 0; i < datas.size(); i++) { - JSONObject param = datas.getJSONObject(i); - String ext_order_id = param.getString("ext_order_id"); - if (StrUtil.isEmpty(ext_order_id)) { - throw new BadRequestException("外部标识不能为空"); - } - String order_code = param.getString("order_code"); - if (StrUtil.isEmpty(order_code)) { - order_code = CodeUtil.getNewCode("ORDER_NO"); - } else { - JSONObject jsonObject = wo.query("is_deleted = '0' and order_code = '" + order_code + "'").uniqueResult(0); - if (ObjectUtil.isNotEmpty(jsonObject)) { - throw new BadRequestException("工单编码不能重复"); - } - } - String qty = param.getString("qty"); - if (StrUtil.isEmpty(qty)) { - throw new BadRequestException("生产数量不能为空"); - } - String material_uuid = param.getString("material_uuid"); - if (StrUtil.isEmpty(material_uuid)) { - throw new BadRequestException("物料标识不能为空"); - } - String material_code = param.getString("material_code"); - if (StrUtil.isEmpty(material_code)) { - throw new BadRequestException("物料编码不能为空"); - } - String material_name = param.getString("material_name"); - if (StrUtil.isEmpty(material_name)) { - throw new BadRequestException("物料名称不能为空"); - } - String material_spec = param.getString("material_spec"); - String device_code = param.getString("device_code"); - if (StrUtil.isEmpty(device_code)) { - throw new BadRequestException("设备编码不能为空"); - } - String is_needmove = param.getString("is_needmove"); - ProduceshiftorderDto dto = new ProduceshiftorderDto(); - dto.setExt_order_id(ext_order_id); - dto.setOrder_code(order_code); - dto.setQty(BigDecimal.valueOf(Long.parseLong(qty))); - dto.setMaterial_uuid(material_uuid); - dto.setMaterial_code(material_code); - dto.setMaterial_name(material_name); - dto.setMaterial_spec(material_spec); - dto.setDevice_code(device_code); - dto.setIs_needmove(is_needmove); - dto.setCreate_by("mes"); - dto.setUpdate_by("mes"); - produceshiftorderService.create(dto); - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - log.info("actionOrder--------------:输出参数" + resultJson.toString()); - return resultJson; - } - - @Override - public Map orderStatusUpdate(String whereJson) { - JSONArray datas = JSONArray.parseArray(whereJson); - log.info("orderStatusUpdate--------------:输入参数" + datas.toString()); - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - for (int i = 0; i < datas.size(); i++) { - JSONObject jsonObject = datas.getJSONObject(i); - String ext_order_id = jsonObject.getString("ext_order_id"); - String type = jsonObject.getString("type"); - JSONObject json = wo.query("ext_order_id = '" + ext_order_id + "'").uniqueResult(0); - ProduceshiftorderDto obj = JSONObject.toJavaObject(json, ProduceshiftorderDto.class); - Device device = deviceAppService.findDeviceByCode(obj.getDevice_code()); - HailiangSpecialDeviceDriver hailiangSpecialDeviceDriver; - HailiangPackerStationDeviceDriver hailiangPackerStationDeviceDriver; - HailiangEngravingMachineDeviceDriver hailiangEngravingMachineDeviceDriver; - if (device.getDeviceDriver() instanceof HailiangSpecialDeviceDriver){ - hailiangSpecialDeviceDriver = (HailiangSpecialDeviceDriver) device.getDeviceDriver(); - //暂停 - if (type.equals("1")){ - hailiangSpecialDeviceDriver.writing("to_pause","1"); - } - //恢复 - if (type.equals("2")){ - hailiangSpecialDeviceDriver.writing("to_pause","0"); - } - //强制完成 - if (type.equals("3")){ - hailiangSpecialDeviceDriver.writing("to_order_compel_finished","0"); - obj.setOrder_status("3"); - obj.setUpdate_by("mes"); - obj.setUpdate_time(DateUtil.now()); - produceshiftorderService.update(obj); - } - } - if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver){ - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - //强制完成 - if (type.equals("3")){ - hailiangPackerStationDeviceDriver.writing("to_order_compel_finished","1"); - obj.setOrder_status("3"); - obj.setOrder_status("3"); - obj.setUpdate_by("mes"); - produceshiftorderService.update(obj); - } - } - if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver){ - hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver(); - //暂停 - if (type.equals("1")){ - hailiangEngravingMachineDeviceDriver.writing("to_pause","1"); - } - //恢复 - if (type.equals("2")){ - hailiangEngravingMachineDeviceDriver.writing("to_pause","0"); - } - //强制完成 - if (type.equals("3")){ - hailiangEngravingMachineDeviceDriver.writing("to_order_compel_finished","0"); - obj.setOrder_status("3"); - obj.setUpdate_by("mes"); - obj.setUpdate_time(DateUtil.now()); - produceshiftorderService.update(obj); - } - } - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - log.info("orderStatusUpdate--------------:输出参数" + resultJson.toString()); - return resultJson; - } @Override public Map queryDeviceDBValue(String whereJson) { JSONArray datas = JSONArray.parseArray(whereJson); log.info("orderStatusUpdate--------------:输入参数" + datas.toString()); JSONObject map = new JSONObject(); - if (datas.size() > 0){ + if (datas.size() > 0) { for (int i = 0; i < datas.size(); i++) { JSONObject jsonObject = datas.getJSONObject(i); String device_code = jsonObject.getString("device_code"); @@ -724,14 +559,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { DeviceExtraManageDto deviceExtraManageDto = extra.get(j); String deviceCode = deviceExtraManageDto.getDevice_code(); String extra_name = deviceExtraManageDto.getExtra_name(); - if (deviceCode.equals(device_code) && extra_name.equals(dbName)){ + if (deviceCode.equals(device_code) && extra_name.equals(dbName)) { String extra_code = deviceExtraManageDto.getExtra_code(); String[] split = extra_code.split("\\."); extra_code = split[split.length - 1]; - extra_code = extra_code.substring(0,1).toUpperCase()+extra_code.substring(1); + extra_code = extra_code.substring(0, 1).toUpperCase() + extra_code.substring(1); IDriverService driverService = applicationContext.getBean(device.getDeviceDriverDefination().getDriverCode(), IDriverService.class); Integer dbValue = driverService.getDbValue(device, extra_code); - map.put(dbName,dbValue); + map.put(dbName, dbValue); break; } } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 370a92a..6caf817 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -17,15 +17,11 @@ import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.impl.DeviceServiceImpl; -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.lamp_three_color.LampThreecolorDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; -import org.nl.acs.device_driver.basedriver.traffic_light.TrafficLightDeviceDriver; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.opc.Device; @@ -34,7 +30,6 @@ import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.route.service.impl.RouteLineServiceImpl; -import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.exception.BadRequestException; @@ -207,7 +202,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu public Instruction findById(String instruction_id) { WQLObject wo = WQLObject.getWQLObject("acs_instruction"); JSONObject json = wo.query("instruction_id ='" + instruction_id + "'").uniqueResult(0); - if(ObjectUtil.isNotEmpty(json)){ + if (ObjectUtil.isNotEmpty(json)) { final Instruction obj = json.toJavaObject(Instruction.class); return obj; } @@ -237,8 +232,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } WQLObject wo = WQLObject.getWQLObject("acs_instruction"); JSONObject json = wo.query("task_id ='" + id + "'" + wherecaluse).uniqueResult(0); - if (ObjectUtil.isNotEmpty(json)) + if (ObjectUtil.isNotEmpty(json)) { return json.toJavaObject(Instruction.class); + } return null; } @@ -288,27 +284,27 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto.setStart_parent_code(task.getStart_parent_code()); dto.setNext_parent_code(task.getNext_parent_code()); // 1 双工agv系统 2叉车agv系统 - if(StrUtil.equals(task.getAgv_system_type(),"1") ){ + if (StrUtil.equals(task.getAgv_system_type(), "1")) { dto.setAgv_system_type("1"); - } else if(StrUtil.equals(task.getAgv_system_type(),"2") ) { + } else if (StrUtil.equals(task.getAgv_system_type(), "2")) { dto.setAgv_system_type("2"); } - if(StrUtil.equals(task.getTask_type(),"1")){ + if (StrUtil.equals(task.getTask_type(), "1")) { dto.setAgv_inst_type("1"); - } else if(StrUtil.equals(task.getTask_type(),"2")){ + } else if (StrUtil.equals(task.getTask_type(), "2")) { dto.setAgv_inst_type("2"); - } else if(StrUtil.equals(task.getTask_type(),"3")){ + } else if (StrUtil.equals(task.getTask_type(), "3")) { dto.setAgv_inst_type("3"); - } else if(StrUtil.equals(task.getTask_type(),"4")){ + } else if (StrUtil.equals(task.getTask_type(), "4")) { dto.setAgv_inst_type("4"); - } else if(StrUtil.equals(task.getTask_type(),"5")){ + } else if (StrUtil.equals(task.getTask_type(), "5")) { dto.setAgv_inst_type("5"); - } else if(StrUtil.equals(task.getTask_type(),"6")){ + } else if (StrUtil.equals(task.getTask_type(), "6")) { dto.setAgv_inst_type("1"); - } else if(StrUtil.equals(task.getTask_type(),"7")){ + } else if (StrUtil.equals(task.getTask_type(), "7")) { dto.setAgv_inst_type("2"); - } else if(StrUtil.equals(task.getTask_type(),"8")){ + } else if (StrUtil.equals(task.getTask_type(), "8")) { dto.setAgv_inst_type("3"); } @@ -317,7 +313,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver; StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; @@ -354,9 +349,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu * 7 不去称重平台称重PS20 agvtype:2 * 8 RT20 agvtype:3 */ - if(StrUtil.equals("1",dto.getAgv_system_type())){ - agvService.sendAgvTwoInstToNDC(dto,null); - } else if(StrUtil.equals("2",dto.getAgv_system_type())){ + if (StrUtil.equals("1", dto.getAgv_system_type())) { + agvService.sendAgvTwoInstToNDC(dto, null); + } else if (StrUtil.equals("2", dto.getAgv_system_type())) { agvService.sendAgvOneInstToNDC(dto); } dto.setSend_status("1"); @@ -395,7 +390,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public void createTwoInst(Instruction dto, Instruction dto2) throws Exception { WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); - if(ObjectUtils.isNotEmpty(dto)){ + if (ObjectUtils.isNotEmpty(dto)) { dto = foramte(dto); String task_code = dto.getTask_code(); TaskDto task = taskService.findByCodeFromCache(task_code); @@ -440,7 +435,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto.setNext_parent_code(task.getNext_parent_code()); } - if(ObjectUtils.isNotEmpty(dto2)){ + if (ObjectUtils.isNotEmpty(dto2)) { dto2 = foramte(dto2); String task_code2 = dto2.getTask_code(); TaskDto task2 = taskService.findByCodeFromCache(task_code2); @@ -501,36 +496,36 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu * 7 不去称重平台称重PS20 agvtype:2 * 8 RT20 agvtype:3 */ - if(StrUtil.equals("1",dto.getInstruction_type())){ - agvService.sendAgvTwoInstToNDC(dto,dto2); + if (StrUtil.equals("1", dto.getInstruction_type())) { + agvService.sendAgvTwoInstToNDC(dto, dto2); dto.setSend_status("1"); dto2.setSend_status("1"); - } else if(StrUtil.equals("2",dto.getInstruction_type())){ + } else if (StrUtil.equals("2", dto.getInstruction_type())) { dto.setSend_status("1"); - agvService.sendAgvTwoInstToNDC(dto,null); - } else if(StrUtil.equals("3",dto.getInstruction_type())){ + agvService.sendAgvTwoInstToNDC(dto, null); + } else if (StrUtil.equals("3", dto.getInstruction_type())) { - } else if(StrUtil.equals("4",dto.getInstruction_type())){ + } else if (StrUtil.equals("4", dto.getInstruction_type())) { - } else if(StrUtil.equals("5",dto.getInstruction_type())){ + } else if (StrUtil.equals("5", dto.getInstruction_type())) { - } else if(StrUtil.equals("6",dto.getInstruction_type())){ + } else if (StrUtil.equals("6", dto.getInstruction_type())) { dto.setSend_status("1"); agvService.sendAgvOneInstToNDC(dto); - } else if(StrUtil.equals("7",dto.getInstruction_type())){ + } else if (StrUtil.equals("7", dto.getInstruction_type())) { agvService.sendAgvOneInstToNDC(dto); dto.setSend_status("1"); - } else if(StrUtil.equals("8",dto.getInstruction_type())){ + } else if (StrUtil.equals("8", dto.getInstruction_type())) { dto.setSend_status("1"); agvService.sendAgvOneInstToNDC(dto); } } } catch (Exception e) { - if(ObjectUtil.isNotEmpty(dto)){ + if (ObjectUtil.isNotEmpty(dto)) { dto.setSend_status("2"); } - if(ObjectUtil.isNotEmpty(dto2)){ + if (ObjectUtil.isNotEmpty(dto2)) { dto2.setSend_status("2"); } e.printStackTrace(); @@ -596,7 +591,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; //将指令赋予对象 下发指令号给电气 @@ -616,10 +610,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString(); Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(2); - } } @@ -752,16 +742,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu log.debug("地址对应设备未找到"); throw new BadRequestException("地址对应设备未找到"); } - if(deviceByCode.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver){ - jo1.put("hasGoodStatus", "2"); - jo1.put("material_type",startdevice.getMaterial_type()); - } else if (deviceByCode.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver){ - jo1.put("hasGoodStatus", "1"); - jo1.put("material_type", ""); - } else { - jo1.put("hasGoodStatus", "1"); - jo1.put("material_type",startdevice.getMaterial_type()); - } + + jo1.put("hasGoodStatus", "1"); + jo1.put("material_type", startdevice.getMaterial_type()); + jo1.put("quantity", startdevice.getQuantity()); jo1.put("remark", startdevice.getRemark()); jo1.put("batch", startdevice.getBatch()); @@ -795,27 +779,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu finishAndCreateNextInst(entity); } } - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - //交通灯 - TrafficLightDeviceDriver trafficLightDeviceDriver; - //变更三色灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(0); - } - } - //变更交通灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof TrafficLightDeviceDriver) { - trafficLightDeviceDriver = (TrafficLightDeviceDriver) lamddevice.getDeviceDriver(); - trafficLightDeviceDriver.writing(2); - } - } + removeByCodeFromCache(entity.getInstruction_code()); } @@ -870,19 +834,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu jo1.put("material_type", dto.getMaterial()); jo1.put("batch", dto.getBatch()); deviceService.changeDeviceStatus(jo1); - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - - - //变更三色灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(0); - } - } removeByCodeFromCache(dto.getInstruction_code()); @@ -954,7 +905,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu //flag= true时取消指令 boolean flag = false; Instruction entity = this.findById(id); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); if (StrUtil.isEmpty(entity.getRoute_plan_code())) { entity.setRoute_plan_code(task.getRoute_plan_code()); @@ -1022,16 +975,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu log.debug("地址对应设备未找到"); return; } - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - //变更三色灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(0); - } - } removeByCodeFromCache(entity.getInstruction_code()); } @@ -1041,7 +984,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu public void cancelNOSendAgv(String id) throws Exception { //flag= true时取消指令 Instruction entity = this.findById(id); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); if (StrUtil.isEmpty(entity.getRoute_plan_code())) { entity.setRoute_plan_code(task.getRoute_plan_code()); @@ -1087,16 +1032,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu log.debug("地址对应设备未找到"); return; } - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - //变更三色灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(0); - } - } + removeByCodeFromCache(entity.getInstruction_code()); } @@ -1106,7 +1042,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu public Instruction findByLinkNumSend(String code) { for (int i = 0; i < this.instructions.size(); i++) { Instruction inst = instructions.get(i); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(),"1")) { + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) { return inst; } } @@ -1115,11 +1051,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override - public List findByLinkNum(String code) { + public List findByLinkNum(String code) { List list = new ArrayList<>(); for (int i = 0; i < this.instructions.size(); i++) { Instruction inst = instructions.get(i); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(),"0")) { + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { list.add(inst); } } @@ -1130,7 +1066,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu public Instruction findByLinkNumNoSend(String code) { for (int i = 0; i < this.instructions.size(); i++) { Instruction inst = instructions.get(i); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(),"0")) { + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { return inst; } } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java deleted file mode 100644 index 739e507..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java +++ /dev/null @@ -1,95 +0,0 @@ - -package org.nl.acs.order.rest; - - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -import org.nl.acs.order.service.ProduceshiftorderService; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.nl.annotation.Log; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.Map; -import lombok.extern.slf4j.Slf4j; - -/** -* @author geng by -* @date 2022-06-06 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "工单信息管理") -@RequestMapping("/api/produceshiftorder") -@Slf4j -public class ProduceshiftorderController { - - private final ProduceshiftorderService produceshiftorderService; - - @GetMapping - @Log("查询工单信息") - @ApiOperation("查询工单信息") - //@PreAuthorize("@el.check('produceshiftorder:list')") - public ResponseEntity query(@RequestParam Map whereJson, Pageable page){ - return new ResponseEntity<>(produceshiftorderService.queryAll(whereJson,page),HttpStatus.OK); - } - - @PostMapping - @Log("新增工单信息") - @ApiOperation("新增工单信息") - //@PreAuthorize("@el.check('produceshiftorder:add')") - public ResponseEntity create(@Validated @RequestBody ProduceshiftorderDto dto){ - produceshiftorderService.create(dto); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @PutMapping - @Log("修改工单信息") - @ApiOperation("修改工单信息") - //@PreAuthorize("@el.check('produceshiftorder:edit')") - public ResponseEntity update(@Validated @RequestBody ProduceshiftorderDto dto){ - produceshiftorderService.update(dto); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Log("删除工单信息") - @ApiOperation("删除工单信息") - //@PreAuthorize("@el.check('produceshiftorder:del')") - @DeleteMapping - public ResponseEntity delete(@RequestBody String[] ids) { - produceshiftorderService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("导出工单信息") - @ApiOperation("导出工单信息") - @GetMapping(value = "/download") - //@PreAuthorize("@el.check('produceshiftorder:list')") - public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException { - produceshiftorderService.download(produceshiftorderService.queryAll(whereJson), response); - } - - @PostMapping("/finishd") - @Log("工单强制完成") - @ApiOperation("工单强制完成") - //@PreAuthorize("@el.check('produceshiftorder:add')") - public ResponseEntity finishd(@RequestBody JSONObject param){ - produceshiftorderService.finishd(param); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @PostMapping("/synchron") - @Log("工单同步") - @ApiOperation("工单同步") - //@PreAuthorize("@el.check('produceshiftorder:add')") - public ResponseEntity synchron(){ - produceshiftorderService.synchron(); - return new ResponseEntity<>(HttpStatus.CREATED); - } -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java deleted file mode 100644 index 571976d..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java +++ /dev/null @@ -1,110 +0,0 @@ - -package org.nl.acs.order.service; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.order.service.dto.ProduceshiftorderDto; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @description 服务接口 -* @author geng by -* @date 2022-06-06 -**/ -public interface ProduceshiftorderService { - - /** - * 查询数据分页 - * @param whereJson 条件 - * @param page 分页参数 - * @return Map - */ - Map queryAll(Map whereJson, Pageable page); - - /** - * 查询数据 - * @param whereJson 条件 - * @return Map - */ - List queryAll(String whereJson); - - - /** - * 查询所有数据不分页 - * @param whereJson 条件参数 - * @return List - */ - List queryAll(Map whereJson); - - /** - * 根据ID查询 - * @param order_id ID - * @return Produceshiftorder - */ - ProduceshiftorderDto findById(String order_id); - - /** - * 根据编码查询 - * @param code code - * @return Produceshiftorder - */ - ProduceshiftorderDto findByCode(String code); - - - /** - * 创建 - * @param dto / - */ - void create(ProduceshiftorderDto dto); - - /** - * 编辑 - * @param dto / - */ - void update(ProduceshiftorderDto dto); - - /** - * 编辑 - * @param dto / - */ - void updateByOrderCode(ProduceshiftorderDto dto); - - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(String[] ids); - - /** - * 导出数据 - * @param dtos 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List dtos, HttpServletResponse response) throws IOException; - - /** - * 工单强制完成 - * @param param - */ - void finishd(JSONObject param); - - /** - * 数据同步 - */ - void reload(); - - List findAllOrderFromCache(); - - ProduceshiftorderDto findOrderByDeviceCode(String device_code); - - /** - * 工单同步 - */ - void synchron(); - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderDto.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderDto.java deleted file mode 100644 index d27df6b..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderDto.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.nl.acs.order.service.dto; - -import lombok.Data; - import java.math.BigDecimal; -import java.io.Serializable; - -/** -* @description / -* @author geng by -* @date 2022-06-06 -**/ -@Data -public class ProduceshiftorderDto implements Serializable { - - /** 工单标识 */ - private String order_id; - - /** 工单编码 */ - private String order_code; - - /** 工单状态 */ - private String order_status; - - /** 下料数量 */ - private BigDecimal qty; - - /** 每框接料数量 */ - private BigDecimal one_qty; - - /** 物料编码 */ - private String material_code; - - /** 物料名称 */ - private String material_name; - - /** 物料标识 */ - private String material_uuid; - - /** 规格型号 */ - private String material_spec; - - /** 创建者 */ - private String create_by; - - /** 创建时间 */ - private String create_time; - - /** 修改者 */ - private String update_by; - - /** 修改时间 */ - private String update_time; - - /** 是否删除 */ - private String is_deleted; - - /** 工单外部标识 */ - private String ext_order_id; - - /** 设备编号 */ - private String device_code; - - /** 是否下发AGV */ - private String is_needmove; - -} 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 deleted file mode 100644 index 4093cb0..0000000 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java +++ /dev/null @@ -1,368 +0,0 @@ - -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; -import org.nl.modules.system.util.CodeUtil; -import org.nl.start.auto.initial.ApplicationAutoInitial; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import org.springframework.data.domain.Pageable; - -import java.math.BigDecimal; -import java.util.*; -import java.io.IOException; -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; -import org.nl.wql.core.bean.ResultBean; -import org.nl.wql.core.bean.WQLObject; -import org.nl.wql.util.WqlUtil; -import org.nl.utils.FileUtil; -import lombok.extern.slf4j.Slf4j; - -/** - * @author geng by - * @description 服务实现 - * @date 2022-06-06 - **/ -@Service -@RequiredArgsConstructor -@Slf4j -public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, ApplicationAutoInitial { - - private final org.nl.acs.opc.DeviceAppService DeviceAppService; - private final DeviceExtraService deviceExtraService; - - List order = new ArrayList(); - - @Autowired - AcsToWmsService acsToWmsService; - - @Override - public void autoInitial() throws Exception { - this.reload(); - } - - public synchronized void reload() { - this.order = this.queryAll(" order_status !='2' and order_status !='3' and is_deleted =0"); - } - - @Override - public List queryAll(String whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - JSONArray arr = wo.query(whereJson).getResultJSONArray(0); - List list = arr.toJavaList(ProduceshiftorderDto.class); - return list; - } - - @Override - public Map queryAll(Map whereJson, Pageable page) { - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "is_deleted = '0' and order_status != '2' and order_status != '3'", "update_time desc"); - final JSONObject json = rb.pageResult(); - return json; - } - - @Override - public List queryAll(Map whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - JSONArray arr = wo.query().getResultJSONArray(0); - List list = arr.toJavaList(ProduceshiftorderDto.class); - return list; - } - - @Override - public ProduceshiftorderDto findById(String order_id) { - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - JSONObject json = wo.query("order_id ='" + order_id + "'").uniqueResult(0); - final ProduceshiftorderDto obj = (ProduceshiftorderDto) JSONObject.toJavaObject(json, ProduceshiftorderDto.class); - return obj; - } - - @Override - public ProduceshiftorderDto findByCode(String code) { - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - JSONObject json = wo.query("order_code ='" + code + "'").uniqueResult(0); - final ProduceshiftorderDto obj = (ProduceshiftorderDto) JSONObject.toJavaObject(json, ProduceshiftorderDto.class); - return obj; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void create(ProduceshiftorderDto dto) { - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - Device device = DeviceAppService.findDeviceByCode(dto.getDevice_code()); - if (ObjectUtil.isEmpty(device)) { - throw new BadRequestException("未找到对应设备:" + dto.getDevice_code()); - } - JSONArray resultJSONArray = wo.query("is_deleted = '0' and order_status in ('0', '1') and device_code = '" + dto.getDevice_code() + "'").getResultJSONArray(0); - if (ObjectUtil.isNotEmpty(resultJSONArray)) { - throw new BadRequestException("该设备已存在未完成工单,不能下发"); - } - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setOrder_id(IdUtil.simpleUUID()); - if (StrUtil.isEmpty(dto.getOrder_code())) { - String order_no = CodeUtil.getNewCode("ORDER_NO"); - dto.setOrder_code(order_no); - } - dto.setOrder_status("0"); - if (StrUtil.isEmpty(dto.getCreate_by())) { - dto.setCreate_by(currentUsername); - } - if (StrUtil.isEmpty(dto.getUpdate_by())) { - dto.setUpdate_by(currentUsername); - } - dto.setCreate_time(now); - dto.setUpdate_time(now); - String is_needmove = dto.getIs_needmove(); - - //海亮专机 - HailiangSpecialDeviceDriver hailiangSpecialDeviceDriver; - //刻字机 - HailiangEngravingMachineDeviceDriver hailiangEngravingMachineDeviceDriver; - //包装机 - HailiangPackerStationDeviceDriver hailiangPackerStationDeviceDriver; - //smart200 - HailiangSmartplcTestDeviceDriver hailiangSmartplcTestDeviceDriver; - if (device.getDeviceDriver() instanceof HailiangSpecialDeviceDriver) { - hailiangSpecialDeviceDriver = (HailiangSpecialDeviceDriver) device.getDeviceDriver(); - //专机下发工单信号:倒料数量(-99999) 当前产量清零(1) 订单生产总量 每箱接料数量 工单号 - - String extra_value = hailiangSpecialDeviceDriver.getExtraValue().get("one_qty").toString(); - - if(StrUtil.equals(is_needmove,"1")){ - if (ObjectUtil.isEmpty(extra_value)) { - throw new BadRequestException("满料框数量为空"); - } - } else { - extra_value = "99999"; - } - dto.setOne_qty(BigDecimal.valueOf((Long.parseLong(extra_value)))); - hailiangSpecialDeviceDriver.writing("to_clear", "1"); - hailiangSpecialDeviceDriver.writing("to_pause", "0"); - hailiangSpecialDeviceDriver.writing("to_one_box_num", extra_value); - hailiangSpecialDeviceDriver.writing("to_order_prod_num", dto.getQty().toString()); - hailiangSpecialDeviceDriver.writing("to_out_num", "0"); - hailiangSpecialDeviceDriver.writing("to_order", dto.getOrder_code()); - } - - if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver){ - hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver(); - String extra_value = hailiangEngravingMachineDeviceDriver.getExtraValue().get("one_qty").toString(); - - if(StrUtil.equals(is_needmove,"1")){ - if (ObjectUtil.isEmpty(extra_value)) { - throw new BadRequestException("满料框数量为空"); - } - } else { - extra_value = "99999"; - } - dto.setOne_qty(BigDecimal.valueOf((Long.parseLong(extra_value)))); - hailiangEngravingMachineDeviceDriver.writing("to_clear", "1"); - hailiangEngravingMachineDeviceDriver.writing("to_one_box_num", extra_value); - hailiangEngravingMachineDeviceDriver.writing("to_order_prod_num", dto.getQty().toString()); - hailiangEngravingMachineDeviceDriver.writing("to_order", dto.getOrder_code()); - } - - if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver){ - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - hailiangPackerStationDeviceDriver.writing("to_clear", "1"); - hailiangPackerStationDeviceDriver.writing("to_order_prod_num", dto.getQty().toString()); - hailiangPackerStationDeviceDriver.writing("to_order", dto.getOrder_code()); - } - - if (device.getDeviceDriver() instanceof HailiangSmartplcTestDeviceDriver) { - hailiangSmartplcTestDeviceDriver = (HailiangSmartplcTestDeviceDriver) device.getDeviceDriver(); - hailiangSmartplcTestDeviceDriver.writing("to_clear", "1"); - hailiangSmartplcTestDeviceDriver.writing("to_qty", dto.getQty().toString()); - hailiangSmartplcTestDeviceDriver.writing("to_task", dto.getOrder_code()); - hailiangSmartplcTestDeviceDriver.writing("to_material", dto.getMaterial_code()); - hailiangSmartplcTestDeviceDriver.writing("to_pause","0"); - } - - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - wo.insert(json); - order.add(dto); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(ProduceshiftorderDto dto) { - ProduceshiftorderDto entity = this.findById(dto.getOrder_id()); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_by(currentUsername); - - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - wo.update(json); - Iterator iterator = order.iterator(); - while (iterator.hasNext()) { - ProduceshiftorderDto instruction = iterator.next(); - if (instruction.getOrder_code().equals(dto.getOrder_code())) { - iterator.remove(); - } - } - if (StrUtil.equals(dto.getOrder_status(), "0") || StrUtil.equals(dto.getOrder_status(), "1")) { - order.add(dto); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateByOrderCode(ProduceshiftorderDto dto) { - ProduceshiftorderDto entity = this.findByCode(dto.getOrder_code()); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setOrder_status(dto.getOrder_status()); - entity.setUpdate_by(currentUsername); - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json, "order_code = '" + dto.getOrder_code() + "'"); - Iterator iterator = order.iterator(); - while (iterator.hasNext()) { - ProduceshiftorderDto oneorder = iterator.next(); - if (oneorder.getOrder_code().equals(dto.getOrder_code())) { - iterator.remove(); - } - } - if (StrUtil.equals(dto.getOrder_status(), "0") || StrUtil.equals(dto.getOrder_status(), "1")) { - order.add(dto); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteAll(String[] ids) { - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - for (String order_id : ids) { - wo.delete("order_id = '" + order_id + "'"); - Iterator iterator = order.iterator(); - while (iterator.hasNext()) { - ProduceshiftorderDto instruction = iterator.next(); - if (instruction.getOrder_id().equals(order_id)) { - iterator.remove(); - } - } - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (ProduceshiftorderDto produceshiftorder : all) { - Map map = new LinkedHashMap<>(); - map.put("工单编码", produceshiftorder.getOrder_code()); - map.put("工单状态", produceshiftorder.getOrder_status()); - map.put("下料数量", produceshiftorder.getQty()); - map.put("物料编码", produceshiftorder.getMaterial_code()); - map.put("物料名称", produceshiftorder.getMaterial_name()); - map.put("物料标识", produceshiftorder.getMaterial_uuid()); - map.put("规格型号", produceshiftorder.getMaterial_spec()); - map.put("创建者", produceshiftorder.getCreate_by()); - map.put("创建时间", produceshiftorder.getCreate_time()); - map.put("修改者", produceshiftorder.getUpdate_by()); - map.put("修改时间", produceshiftorder.getUpdate_time()); - map.put("是否删除", produceshiftorder.getIs_deleted()); - map.put("工单外部标识", produceshiftorder.getExt_order_id()); - map.put("设备编号", produceshiftorder.getDevice_code()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void finishd(JSONObject param) { - param = param.getJSONObject("data"); - String now = DateUtil.now(); - String order_id = param.getString("order_id"); - String ext_order_id = param.getString("ext_order_id"); - if (StrUtil.isNotEmpty(ext_order_id)) { - // TODO - param.put("status", "3"); - param.put("type", "2"); - acsToWmsService.feedbackOrderStatus(param); - } - Device device = DeviceAppService.findDeviceByCode(param.getString("device_code")); - HailiangSpecialDeviceDriver hailiangSpecialDeviceDriver; - HailiangPackerStationDeviceDriver hailiangPackerStationDeviceDriver; - HailiangEngravingMachineDeviceDriver hailiangEngravingMachineDeviceDriver; - if (device.getDeviceDriver() instanceof HailiangSpecialDeviceDriver) { - hailiangSpecialDeviceDriver = (HailiangSpecialDeviceDriver) device.getDeviceDriver(); - hailiangSpecialDeviceDriver.writing("to_order_compel_finished", "1"); - } - if (device.getDeviceDriver() instanceof HailiangPackerStationDeviceDriver) { - hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver(); - hailiangPackerStationDeviceDriver.writing("to_order_compel_finished", "1"); - } - if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) { - hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver(); - hailiangEngravingMachineDeviceDriver.writing("to_order_compel_finished", "1"); - } - JSONObject map = new JSONObject(); - map.put("order_id", order_id); - map.put("order_status", "3"); - map.put("update_by", SecurityUtils.getNickName()); - map.put("update_time", now); - WQLObject wo = WQLObject.getWQLObject("acs_produceshiftorder"); - wo.update(map); - Iterator iterator = order.iterator(); - while (iterator.hasNext()) { - ProduceshiftorderDto instruction = iterator.next(); - if (instruction.getOrder_code().equals(param.getString("order_code"))) { - iterator.remove(); - } - } - } - - @Override - public List findAllOrderFromCache() { - return order; - } - - @Override - public ProduceshiftorderDto findOrderByDeviceCode(String device_code) { - for (int i = 0; i < this.order.size(); i++) { - ProduceshiftorderDto dto = order.get(i); - if (StrUtil.equals(device_code, dto.getDevice_code())) { - return dto; - } - } - return null; - } - - @Override - public void synchron() { - this.reload(); - } - -} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls deleted file mode 100644 index 89d456d..0000000 Binary files a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls and /dev/null differ 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 26422b5..87a7f9c 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 @@ -14,36 +14,11 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.common.IDriverService; import org.nl.acs.device.service.StorageCellService; -import org.nl.acs.device.service.dto.StorageCellDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; -import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver; -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_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_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.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; -import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_scanner.StandardScannerDeviceDriver; -import org.nl.acs.device_driver.hailiang.hailiang_packing.HaiLiangPackingDeviceDriver; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.stage.service.StageActorService; import org.nl.acs.stage.service.dto.StageActorDto; -import org.nl.acs.stage.service.utils.StageActorUtil; import org.nl.exception.BadRequestException; import org.nl.utils.FileUtil; import org.nl.utils.RedisUtils; @@ -132,7 +107,9 @@ public class StageActorServiceImpl implements StageActorService { @Transactional(rollbackFor = Exception.class) public void update(StageActorDto dto) { StageActorDto entity = this.findById(dto.getActor_uuid()); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateAGVTwoInst.java b/wcs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateAGVTwoInst.java index 3f48504..cc67007 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateAGVTwoInst.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateAGVTwoInst.java @@ -7,17 +7,12 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.log.LogMarkerTypeEnum; @@ -26,7 +21,6 @@ import org.nl.utils.SpringContextHolder; import org.springframework.stereotype.Component; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.Date; import java.util.List; diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/LetteringSocketConnectionAutoRun.java b/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/LetteringSocketConnectionAutoRun.java index 6b59e2d..04b39cb 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/LetteringSocketConnectionAutoRun.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/LetteringSocketConnectionAutoRun.java @@ -32,14 +32,17 @@ public class LetteringSocketConnectionAutoRun extends AbstractAutoRunnable { this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); } + @Override public String getCode() { return LetteringSocketConnectionAutoRun.class.getSimpleName(); } + @Override public String getName() { return "海亮激光刻字在线连接"; } + @Override public void autoRun() throws IOException { AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class); diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java b/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java index e711d98..f39e75b 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java @@ -7,7 +7,6 @@ import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.config.server.impl.AcsConfigServiceImpl; import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.instruction.service.InstructionService; @@ -57,14 +56,17 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); } + @Override public String getCode() { return NDCSocketConnectionAutoRun.class.getSimpleName(); } + @Override public String getName() { return "双工NDC在线连接"; } + @Override public void autoRun() { try { AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class); @@ -92,8 +94,9 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { for (int i = 0; i < count; i++) { int temp = b[i]; - if (temp < 0) + if (temp < 0) { temp += 256; + } arr[i] = temp; StringBuffer bs1 = new StringBuffer("0"); bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); @@ -118,7 +121,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { List insts = null; boolean link_flag = false; Device agv_device = null; - if(carno != 0){ + if (carno != 0) { agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); } if (ikey != 0) { @@ -133,9 +136,6 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { String device_code = null; - // - AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; - //开始任务/上报订单号 if (phase == 0x01) { for (Instruction inst : insts) { @@ -156,10 +156,10 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { } data = AgvService.sendAgvTwoModeInst(phase, index, 0); - } else if(phase == 0x30){ + } else if (phase == 0x30) { data = AgvService.sendAgvTwoModeInst(143, index, 0); - } else if(phase == 0xFF){ + } else if (phase == 0xFF) { for (Instruction inst : insts) { if (!ObjectUtil.isEmpty(inst)) { @@ -170,20 +170,15 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { } else { - if(phase == 0x67){ + if (phase == 0x67) { device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); } else { device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); } - if(ObjectUtil.isEmpty(device)){ + if (ObjectUtil.isEmpty(device)) { return; } - if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); - - agvNdcTwoDeviceDriver.processSocket(arr); - } } if (!ObjectUtil.isEmpty(data)) { write(data); diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/OneNDCSocketConnectionAutoRun.java b/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/OneNDCSocketConnectionAutoRun.java index 20d1bd0..8a64768 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/OneNDCSocketConnectionAutoRun.java @@ -7,7 +7,6 @@ import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.config.server.impl.AcsConfigServiceImpl; import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.instruction.service.InstructionService; @@ -57,14 +56,17 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); } + @Override public String getCode() { return OneNDCSocketConnectionAutoRun.class.getSimpleName(); } + @Override public String getName() { return "单工NDC在线连接"; } + @Override public void autoRun() throws IOException { System.out.println("OneAgv链接开始"); AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class); @@ -96,8 +98,9 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { for (int i = 0; i < count; i++) { int temp = b[i]; - if (temp < 0) + if (temp < 0) { temp += 256; + } arr[i] = temp; StringBuffer bs1 = new StringBuffer("0"); bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); @@ -122,7 +125,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { List insts = null; boolean link_flag = false; Device agv_device = null; - if(carno != 0){ + if (carno != 0) { agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); } if (ikey != 0) { @@ -137,9 +140,6 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { String device_code = null; - // - AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; - //开始任务/上报订单号 if (phase == 0x01) { for (Instruction inst : insts) { @@ -160,10 +160,10 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else if(phase == 0x30){ + } else if (phase == 0x30) { data = AgvService.sendAgvOneModeInst(143, index, 0); - } else if(phase == 0xFF) { + } else if (phase == 0xFF) { for (Instruction inst : insts) { if (!ObjectUtil.isEmpty(inst)) { @@ -172,25 +172,20 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } data = AgvService.sendAgvOneModeInst(phase, index, 0); - }else if(phase == 0x50){//离开区域 + } else if (phase == 0x50) {//离开区域 data = AgvService.sendAgvOneModeInst(phase, index, 0); - }else if(phase == 0x51){//离开区域 + } else if (phase == 0x51) {//离开区域 data = AgvService.sendAgvOneModeInst(phase, index, 0); } else { - if(phase == 0x67){ + if (phase == 0x67) { device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); } else { device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); } - if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { - agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); - - agvNdcOneDeviceDriver.processSocket(arr); - } } if (!ObjectUtil.isEmpty(data)) { write(data); @@ -203,7 +198,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } catch (Exception e) { System.out.println("OneAgv链接异常"); - if(ObjectUtil.isNotEmpty(s)){ + if (ObjectUtil.isNotEmpty(s)) { s.close(); } System.out.println(e.getMessage()); diff --git a/wcs/qd/src/api/acs/order/produceshiftorder.js b/wcs/qd/src/api/acs/order/produceshiftorder.js deleted file mode 100644 index 1c478c4..0000000 --- a/wcs/qd/src/api/acs/order/produceshiftorder.js +++ /dev/null @@ -1,42 +0,0 @@ -import request from '@/utils/request' - -export function add(data) { - return request({ - url: 'api/produceshiftorder', - method: 'post', - data - }) -} - -export function del(ids) { - return request({ - url: 'api/produceshiftorder/', - method: 'delete', - data: ids - }) -} - -export function edit(data) { - return request({ - url: 'api/produceshiftorder', - method: 'put', - data - }) -} - -export function finishd(data) { - return request({ - url: 'api/produceshiftorder/finishd', - method: 'post', - data - }) -} - -export function synchron() { - return request({ - url: 'api/produceshiftorder/synchron', - method: 'post' - }) -} - -export default { add, edit, del, finishd, synchron } diff --git a/wcs/qd/src/views/acs/device/config.vue b/wcs/qd/src/views/acs/device/config.vue index 4480f3e..0638433 100644 --- a/wcs/qd/src/views/acs/device/config.vue +++ b/wcs/qd/src/views/acs/device/config.vue @@ -43,8 +43,8 @@ @@ -75,54 +75,25 @@ import { get, selectDriverCodeList } from '@/api/acs/device/driverConfig' import { getDicts } from '@/api/system/dict' import standard_inspect_site from './driver/standard_inspect_site' import standard_ordinary_site from './driver/standard_ordinary_site' -import weighing_site from './driver/weighing_site' -import machines_site from './driver/machines_site' -import lamp_three_color from './driver/lamp_three_color' -import standard_autodoor from './driver/standard_autodoor' -import standard_emptypallet_site from './driver/standard_emptypallet_site' -import standard_manipulator_inspect_site from './driver/standard_manipulator_inspect_site' -import standard_special_inspect_site from './driver/standard_special_inspect_site' -import special_ordinary_site from './driver/special_ordinary_site' import standard_storage from '@/views/acs/device/driver/standard_storage' import standard_scanner from '@/views/acs/device/driver/standard_scanner' import standard_conveyor_control_with_scanner from '@/views/acs/device/driver/standard_conveyor_control_with_scanner' -import standard_conveyor_control_with_plcscanner from '@/views/acs/device/driver/standard_conveyor_control_with_plcscanner' import standard_conveyor_control from '@/views/acs/device/driver/standard_conveyor_control' import standard_conveyor_monitor from '@/views/acs/device/driver/standard_conveyor_monitor' -import non_line_manipulator_inspect_site from '@/views/acs/device/driver/non_line_manipulator_inspect_site' -import non_line_inspect_site from '@/views/acs/device/driver/non_line_inspect_site' -import manipulator_inspect_site_NDC from '@/views/acs/device/driver/manipulator_inspect_site_NDC' -import standard_manipulator_stacking_site from '@/views/acs/device/driver/standard_manipulator_stacking_site' -import standard_photoelectric_inspect_site from '@/views/acs/device/driver/standard_photoelectric_inspect_site' - -import hailiang_special_pick_station from '@/views/acs/device/driver/hailiang_one/hailiang_special_pick_station' -import hailiang_special_empty_station from '@/views/acs/device/driver/hailiang_one/hailiang_special_empty_station' -import hailiang_special_full_station from '@/views/acs/device/driver/hailiang_one/hailiang_special_full_station' -import hailiang_special_pour_station from '@/views/acs/device/driver/hailiang_one/hailiang_special_pour_station' -import hailiang_special_device from '@/views/acs/device/driver/hailiang_one/hailiang_special_device' -import hailiang_engraving_machine from '@/views/acs/device/driver/hailiang_one/hailiang_engraving_machine' -import hailiang_engraving_cache from '@/views/acs/device/driver/hailiang_one/hailiang_engraving_cache' -import hailiang_packer_station from '@/views/acs/device/driver/hailiang_one/hailiang_packer_station' -import hailiang_auto_cache_line from '@/views/acs/device/driver/hailiang_one/hailiang_auto_cache_line' -import hailiang_cleaning_feeding_line from '@/views/acs/device/driver/hailiang_one/hailiang_cleaning_feeding_line' -import hailiang_cleaning_machine from '@/views/acs/device/driver/hailiang_one/hailiang_cleaning_machine' -import hailiang_cleaning_machine_storage_station from '@/views/acs/device/driver/hailiang_one/hailiang_cleaning_machine_storage_station' -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' export default { name: 'DeviceConfig', - components: { standard_ordinary_site, standard_inspect_site, standard_autodoor, - standard_emptypallet_site, standard_manipulator_inspect_site, standard_special_inspect_site, - lamp_three_color, standard_storage, special_ordinary_site, standard_scanner, standard_conveyor_control_with_scanner, - standard_conveyor_control_with_plcscanner, standard_conveyor_control, standard_conveyor_monitor, weighing_site, machines_site, non_line_manipulator_inspect_site, - non_line_inspect_site, manipulator_inspect_site_NDC, standard_manipulator_stacking_site, - 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 }, + components: { + standard_ordinary_site, + standard_inspect_site, + standard_storage, + standard_scanner, + standard_conveyor_control_with_scanner, + standard_conveyor_control, + standard_conveyor_monitor, + hailiang_smart_plc_test + }, dicts: ['device_type'], mixins: [crud], data() { diff --git a/wcs/qd/src/views/acs/order/index.vue b/wcs/qd/src/views/acs/order/index.vue deleted file mode 100644 index 8f8c6c9..0000000 --- a/wcs/qd/src/views/acs/order/index.vue +++ /dev/null @@ -1,215 +0,0 @@ - - - - -