From 5342b5a657cf74e19721353bfb86ce5fe29639fe Mon Sep 17 00:00:00 2001 From: tuqiang <437016993@qq.com> Date: Tue, 2 Jan 2024 09:34:23 +0800 Subject: [PATCH] fix --- .../device/device_driver/DriverTypeEnum.java | 4 +- .../service/impl/DeviceServiceImpl.java | 213 ++++++- .../BoxManipulatorDefination.java | 60 ++ .../BoxManipulatorDeviceDriver.java | 396 +++++++++++++ .../StandardItemProtocol.java | 151 +++++ .../StandardManipulatorDefination.java | 4 +- .../StandardManipulatorDeviceDriver.java | 31 +- .../wms/service/impl/WmsToAcsServiceImpl.java | 11 + .../src/views/acs/device/config.vue | 5 +- .../acs/device/driver/box_manipulator.vue | 546 ++++++++++++++++++ 10 files changed, 1372 insertions(+), 49 deletions(-) create mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDefination.java create mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDeviceDriver.java create mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardItemProtocol.java create mode 100644 acs/nladmin-ui/src/views/acs/device/driver/box_manipulator.vue diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 22fa1f1..bcb23aa 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -46,7 +46,9 @@ public enum DriverTypeEnum { WITH_STATION_DEVICE_DRIVER(18, "with_station_device_driver", "输送线关联站点", "conveyor"), - STANDARD_MANIPULATOR(19, "standard_manipulator", "标准版-行架机械手", "station"); + STANDARD_MANIPULATOR(19, "standard_manipulator", "标准版-行架机械手", "station"), + + BOX_MANIPULATOR(20, "box_manipulator", "装箱行架机械手", "station"); /** diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 2282eb6..22581b3 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -18,7 +18,6 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.map.ListOrderedMap; import org.nl.acs.auto.initial.ApplicationAutoInitial; -import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; import org.nl.acs.device.domain.DeviceExtra; @@ -28,6 +27,10 @@ import org.nl.acs.device.domain.DeviceRunpoint; import org.nl.acs.device.service.mapper.DeviceRunpointMapper; import org.nl.acs.route.domain.RouteLine; import org.nl.acs.route.service.mapper.RouteLineMapper; +//import org.nl.acs.stage.domain.Stage; +//import org.nl.acs.stage.domain.StageActor; +//import org.nl.acs.stage.service.mapper.StageActorMapper; +//import org.nl.acs.stage.service.mapper.StageMapper; import org.nl.acs.storage_cell.domain.StorageCell; import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; import org.nl.acs.utils.ConvertUtil; @@ -78,6 +81,10 @@ import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; import org.springframework.data.domain.Pageable; import org.springframework.web.multipart.MultipartFile; @@ -94,20 +101,26 @@ import java.util.*; @Service @AllArgsConstructor @Slf4j +// @CacheConfig(cacheNames = DeviceService.CACHE_KEY) @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class DeviceServiceImpl extends CommonServiceImpl implements DeviceService, ApplicationAutoInitial { + // private final RedisUtils redisUtils; private final DeviceMapper deviceMapper; private final RouteLineMapper routeLineMapper; + // private final StageActorMapper stageActorMapper; private final StorageCellMapper storageCellMapper; private final DeviceExtraMapper deviceExtraMapper; private final DeviceRunpointMapper deviceRunpointMapper; + private final StageMapper stageMapper; private final DeviceExtraService deviceExtraService; private final OpcService opcService; + private final RedisUtils redisUtils; private final OpcPlcService opcPlcService; private final DeviceDriverDefinationAppService deviceDriverDefinationAppService; private final DeviceAppService deviceAppService; + private final ISysParamService paramService; private final ISysDictService iSysDictService; List storageCells = new ArrayList<>(); @@ -130,6 +143,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } @Override + // @Cacheable(key = "'id:' + #p0") public DeviceDto findById(String id) { return ConvertUtil.convert(getById(id), DeviceDto.class); } @@ -165,6 +179,47 @@ public class DeviceServiceImpl extends CommonServiceImpl i return this.removeByIds(set); } + /* + private void delCaches(String id) { + redisUtils.delByKey(CACHE_KEY + "::id:", id); + } + + private void delCaches(Set ids) { + for (String id: ids) { + delCaches(id); + } + }*/ + + /* + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (DeviceDto device : all) { + Map map = new LinkedHashMap<>(); + map.put("设备编码", device.getDeviceCode()); + map.put("设备名字", device.getDeviceName()); + map.put("设备类型", device.getDeviceType()); + map.put("所属区域", device.getRegion()); + map.put("生产厂家", device.getManufacturer()); + map.put("生产厂家电话", device.getManufacturerPhone()); + map.put("是否配置", device.getIsConfig()); + map.put("opcServer标识", device.getOpcServerId()); + map.put("opcPlc标识", device.getOpcPlcId()); + map.put("是否为路由设备", device.getIsRoute()); + map.put("设备驱动类型", device.getDriverCode()); + map.put("备注", device.getRemark()); + map.put("是否启用", device.getIsActive()); + map.put("顺序号", device.getSeqNum()); + map.put("是否删除", device.getIsDelete()); + map.put("创建者", device.getCreateBy()); + map.put("创建时间", device.getCreateTime()); + map.put("修改者", device.getUpdateBy()); + map.put("修改时间", device.getUpdateTime()); + map.put("地址号", device.getAddress()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + }*/ @Override public Map queryAll(Map whereJson, Pageable page) { @@ -213,7 +268,13 @@ public class DeviceServiceImpl extends CommonServiceImpl i return ConvertUtil.convertList(deviceList, DeviceDto.class); } - +// @Override +// public DeviceDto findById(String device_id) { +// WQLObject wo = WQLObject.getWQLObject("acs_device"); +// JSONObject json = wo.query("device_id ='" + device_id + "'").uniqueResult(0); +// final DeviceDto obj = json.toJavaObject(DeviceDto.class); +// return obj; +// } @Override public DeviceDto findByCode(String code) { @@ -226,10 +287,9 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override @Transactional(rollbackFor = Exception.class) public void create(DeviceDto dto) { - CommonFinalParam commonFinalParam = new CommonFinalParam(); String device_code = dto.getDevice_code(); DeviceDto deviceDto = this.findByCode(device_code); - if (deviceDto != null && commonFinalParam.getDELETE().equals(deviceDto.getIs_delete())) { + if (deviceDto != null && deviceDto.getIs_delete().equals("0")) { throw new BadRequestException(LangProcess.msg("error_checkExist", device_code)); } @@ -254,10 +314,10 @@ public class DeviceServiceImpl extends CommonServiceImpl i if (entity == null) { throw new BadRequestException(LangProcess.msg("error_sysAuth")); } - CommonFinalParam commonFinalParam = new CommonFinalParam(); + String device_code = dto.getDevice_code(); DeviceDto deviceDto = this.findByCode(device_code); - if (deviceDto != null && commonFinalParam.getDELETE().equals(deviceDto.getIs_delete()) + if (deviceDto != null && deviceDto.getIs_delete().equals("0") && !deviceDto.getDevice_id().equals(dto.getDevice_id())) { throw new BadRequestException(LangProcess.msg("error_checkExist", device_code)); } @@ -275,7 +335,14 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override @Transactional(rollbackFor = Exception.class) public void deleteAll(String[] ids) { +// WQLObject wo = WQLObject.getWQLObject("acs_device"); +// WQLObject storageTab = WQLObject.getWQLObject("acs_storage_cell"); +// //路由路线表【acs_route_line】 +// WQLObject routeLineTab = WQLObject.getWQLObject("acs_route_line"); +// //路由路线表【stage_actor】 +// WQLObject stageActorTab = WQLObject.getWQLObject("stage_actor"); for (String device_id : ids) { +// JSONObject deviceJson = wo.query("device_id = '" + device_id + "'").uniqueResult(0); Device deviceJson = new LambdaQueryChainWrapper<>(deviceMapper) .eq(Device::getDevice_id, device_id) .one(); @@ -284,6 +351,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } String device_code = deviceJson.getDevice_code(); log.debug("删除设备时候判断路由是否存在,如果存在,则不允许删除设备!"); +// JSONObject json = routeLineTab.query("device_code = '" + device_code + "' or next_device_code = '" + device_code + "'").uniqueResult(0); RouteLine json = new LambdaQueryChainWrapper<>(routeLineMapper) .eq(RouteLine::getDevice_code, device_code) .or().eq(RouteLine::getNext_device_code, device_code) @@ -292,7 +360,24 @@ public class DeviceServiceImpl extends CommonServiceImpl i throw new BadRequestException(LangProcess.msg("device_checkRoute", device_code)); } log.debug("删除舞台里面的设备!"); +// Map map = new HashMap<>(); +// map.put("device_id", ""); +// map.put("device_code", ""); +// map.put("device_name", ""); +// stageActorTab.update(map, "device_code = '" + device_code + "'"); +// stageActorMapper.lambdaUpdate().eq(StageActor::getDevice_code,device_code) +// .set(StageActor::getDevice_code,"") +// .set(StageActor::getDevice_name,"") +// .update(); log.debug("根据设备编码查询在缓存里面的舞台数据,并删除掉!"); +// JSONArray jsonArr = WQL.getWO("QStage_01").addParam("flag", "1").addParam("device_code", device_code).process().getResultJSONArray(0); + +// List stageList = stageMapper.selectByDeviceCode(device_code); +// for (int i = 0; i < stageList.size(); i++) { +// String stage_code = stageList.get(i).getStage_code(); +// redisUtils.del("stage:mst:" + stage_code); +// redisUtils.del("stage:dtl:" + stage_code); +// } log.debug("删除缓存里面的设备!"); Device deviceByCode = deviceAppService.findDeviceByCode(device_code); List allDevice = deviceAppService.findAllDevice(); @@ -305,22 +390,27 @@ public class DeviceServiceImpl extends CommonServiceImpl i } +// allDevice.remove(deviceByCode); log.info("设备删除成功!"); if (deviceByCode != null) { if (StrUtil.equals("storage", deviceByCode.getDeviceDriverDefination().getFitDeviceTypes().get(0).name())) { +// storageTab.delete("substring_index( storage_code,'-',1)= '" + device_code + "'"); storageCellMapper.deleteByStorageCode(device_code); } else { +// JSONObject data = storageTab.query("storage_code ='" + device_code + "'").uniqueResult(0); StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) .eq(StorageCell::getStorage_code, device_code) .one(); if (storageCell != null) { +// storageTab.delete("storage_code = '" + device_code + "'"); Map map = new HashMap<>(); map.put("storage_code", device_code); storageCellMapper.deleteByMap(map); } } } +// wo.delete("device_id = '" + device_id + "'"); Map map = new HashMap<>(); map.put("device_id", device_id); deviceMapper.deleteByMap(map); @@ -376,7 +466,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i datatype = "DWord"; } map.put("Data Type", datatype); - map.put("Respect Data Type", CommonFinalParam.ONE); + map.put("Respect Data Type", "1"); map.put("Client Access", "R/W"); map.put("Scan Rate", "100"); list.add(map); @@ -407,6 +497,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public JSONArray selectConveyorList() { //设备基础信息表【acs_device】 +// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND device_type = 'conveyor'").getResultJSONArray(0); List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) .apply("is_delete= '0' AND is_active= '1' AND device_type = 'conveyor'") .list(); @@ -532,11 +623,14 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public JSONArray selectDeviceListTwo() { //设备基础信息表【acs_device】 +// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND region = '2'", "seq_num").getResultJSONArray(0); List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) .apply("is_delete= '0' AND is_active= '1' AND region = '2'") .orderByAsc(Device::getSeq_num) .list(); JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList)); + //acs_device_extra +// WQLObject extraTab = WQLObject.getWQLObject("acs_device_extra"); JSONArray result = new JSONArray(); for (int i = 0; i < arr.size(); i++) { JSONObject obj = arr.getJSONObject(i); @@ -553,6 +647,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i json.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); } +// JSONArray extraArr = extraTab.query("device_id = '" + obj.getString("device_id") + "'").getResultJSONArray(0); List deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper) .eq(DeviceExtra::getDevice_id, obj.getString("device_id")) .list(); @@ -586,12 +681,14 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public JSONArray selectDeviceListThree() { //设备基础信息表【acs_device】 +// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND region = '3'", "seq_num").getResultJSONArray(0); List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) .apply("is_delete= '0' AND is_active= '1' AND region = '3'") .orderByAsc(Device::getSeq_num) .list(); JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList)); //acs_device_extra +// WQLObject extraTab = WQLObject.getWQLObject("acs_device_extra"); JSONArray result = new JSONArray(); for (int i = 0; i < arr.size(); i++) { JSONObject obj = arr.getJSONObject(i); @@ -608,6 +705,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i json.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); } +// JSONArray extraArr = extraTab.query("device_id = '" + obj.getString("device_id") + "'").getResultJSONArray(0); List deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper) .eq(DeviceExtra::getDevice_id, obj.getString("device_id")) .list(); @@ -644,13 +742,15 @@ public class DeviceServiceImpl extends CommonServiceImpl i JSONArray deviceInfo = new JSONArray(); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; +// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' and region != '' and is_config= 'true' ").getResultJSONArray(0); List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) .apply("is_delete= '0' AND is_active= '1' and region != '' and is_config= 'true' ") .list(); JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList)); JSONArray result = new JSONArray(); + // status=2 代表查询请求的设备 =3代表查询相应的设备 - if (CommonFinalParam.TWO.equals(status)) { + if (status.equals("2")) { for (int i = 0; i < arr.size(); i++) { JSONObject devicejo = new JSONObject(); JSONObject obj = arr.getJSONObject(i); @@ -672,7 +772,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } } } - } else if ("3".equals(status)) { + } else if (status.equals("3")) { for (int i = 0; i < arr.size(); i++) { JSONObject devicejo = new JSONObject(); JSONObject obj = arr.getJSONObject(i); @@ -715,6 +815,28 @@ public class DeviceServiceImpl extends CommonServiceImpl i } } } + + +// for(int i=0; i i dto.setDriver_code(parentForm.getString("driver_code")); dto.setOpc_plc_id(opc_plc_id); dto.setOpc_server_id(opc_server_id); + //dto.setIs_config("true"); if (StrUtil.isEmpty(address)) { dto.setAddress("0"); } else { @@ -772,8 +895,10 @@ public class DeviceServiceImpl extends CommonServiceImpl i //判断是否存在并开启站点管理 if (form.containsKey("station_manager")) { +// WQLObject wo = WQLObject.getWQLObject("acs_device_runpoint"); if ("true".equals(form.get("station_manager").toString())) { //判断数据库记录是否存在 不存在则新增 存在则修改 +// JSONObject json = wo.query("device_id ='" + device_id + "'").uniqueResult(0); DeviceRunpoint deviceRunpoint = new LambdaQueryChainWrapper<>(deviceRunpointMapper) .eq(DeviceRunpoint::getDevice_id, device_id) .one(); @@ -807,6 +932,8 @@ public class DeviceServiceImpl extends CommonServiceImpl i if (data1 != null) { //处理读的DB字段 //设备扩展表【acs_device_extra】 +// WQLObject wo = WQLObject.getWQLObject("acs_device_extra"); +// wo.delete("device_id = '" + device_id + "' and filed_type = '02'"); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(DeviceExtra::getDevice_id, device_id); wrapper.eq(DeviceExtra::getFiled_type, "02"); @@ -826,6 +953,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i param.put("device_code", device_code); param.put("create_by", SecurityUtils.getCurrentUsername()); param.put("create_time", DateUtil.now()); +// wo.insert(param); DeviceExtra entity = ConvertUtil.convert(param, DeviceExtra.class); deviceExtraMapper.insert(entity); } @@ -853,11 +981,13 @@ public class DeviceServiceImpl extends CommonServiceImpl i param.put("device_code", device_code); param.put("create_by", SecurityUtils.getCurrentUsername()); param.put("create_time", DateUtil.now()); +// wo.insert(param); DeviceExtra entity = ConvertUtil.convert(param, DeviceExtra.class); deviceExtraMapper.insert(entity); } } +// WQLObject wo = WQLObject.getWQLObject("acs_storage_cell"); if (StrUtil.equals(device_type, "storage")) { int x = form.getInteger("x"); int maxY = form.getInteger("maxY"); @@ -866,7 +996,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i int minZ = form.getInteger("minZ"); for (int i = minY; i <= maxY; i++) { for (int j = minZ; j <= maxZ; j++) { - +// JSONObject json = wo.query("storage_code='" + device_code + "-" + formatNum(i) + "-" + formatNum(j) + "'").uniqueResult(0); StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) .eq(StorageCell::getStorage_code, device_code + "-" + formatNum(i) + "-" + formatNum(j)) .one(); @@ -878,8 +1008,10 @@ public class DeviceServiceImpl extends CommonServiceImpl i celldto.setX(formatNum(x)); celldto.setY(formatNum(i)); celldto.setZ(formatNum(j)); + //celldto.setAddress(Integer.parseInt(CodeUtil.getNewCode("NDCADDRESS_NO"))); celldto.setCreate_by("init"); celldto.setCreate_time(SecurityUtils.getCurrentUsername()); +// wo.insert((JSONObject) JSONObject.toJSON(celldto)); StorageCell entity = ConvertUtil.convert(celldto, StorageCell.class); storageCellMapper.insert(entity); } @@ -890,6 +1022,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i if (StrUtil.equals(driver_code, "standard_emptypallet_site") && form.containsKey("max_emptypalletnum")) { int num = form.getInteger("max_emptypalletnum"); for (int i = 1; i < num + 1; i++) { +// JSONObject json = wo.query("storage_code ='" + device_code + "." + i + "'").uniqueResult(0); StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) .eq(StorageCell::getStorage_code, device_code + "." + i) .one(); @@ -904,11 +1037,13 @@ public class DeviceServiceImpl extends CommonServiceImpl i celldto.setAddress(Integer.parseInt(CodeUtil.getNewCode("NDCADDRESS_NO"))); celldto.setCreate_by("init"); celldto.setCreate_time(SecurityUtils.getCurrentUsername()); +// wo.insert((JSONObject) JSONObject.toJSON(celldto)); StorageCell entity = ConvertUtil.convert(celldto, StorageCell.class); storageCellMapper.insert(entity); } } } else { +// JSONObject json = wo.query("storage_code ='" + device_code + "'").uniqueResult(0); StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) .eq(StorageCell::getStorage_code, device_code) .one(); @@ -923,6 +1058,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i celldto.setAddress(Integer.parseInt(CodeUtil.getNewCode("NDCADDRESS_NO"))); celldto.setCreate_by("init"); celldto.setCreate_time(SecurityUtils.getCurrentUsername()); +// wo.insert((JSONObject) JSONObject.toJSON(celldto)); StorageCell entity = ConvertUtil.convert(celldto, StorageCell.class); storageCellMapper.insert(entity); } @@ -942,10 +1078,9 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public void changeDeviceStatus(JSONObject form) { - CommonFinalParam commonFinalParam = new CommonFinalParam(); String device_code = form.getString("device_code"); - if (StrUtil.contains(device_code, commonFinalParam.getBARRE()) && StrUtil.count(device_code, commonFinalParam.getBARRE()) == 2) { - String[] point = device_code.split(commonFinalParam.getBARRE()); + if (StrUtil.contains(device_code, "-") && StrUtil.count(device_code, "-") == 2) { + String[] point = device_code.split("-"); device_code = point[0]; } //需要数量 @@ -961,7 +1096,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i String islock = form.getString("islock"); String requireSucess = form.getString("requireSucess"); String fullrequireSucess = form.getString("fullrequireSucess"); - if (device_code.indexOf(commonFinalParam.getPOINT()) != -1) { + if (device_code.indexOf(".") != -1) { device_code = device_code.substring(0, device_code.indexOf(".")); } Device device = deviceAppService.findDeviceByCode(device_code); @@ -1006,10 +1141,13 @@ public class DeviceServiceImpl extends CommonServiceImpl i standardOrdinarySiteDeviceDriver.setBatch(""); device.setBatch(""); } +// WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint"); +// JSONObject json = runpointwo.query("device_code ='" + device_code + "'").uniqueResult(0); DeviceRunpoint deviceRunpoint = new LambdaQueryChainWrapper<>(deviceRunpointMapper) .eq(DeviceRunpoint::getDevice_code, device_code) .one(); if (!ObjectUtil.isEmpty(deviceRunpoint)) { +// DeviceRunpointDto obj = json.toJavaObject(DeviceRunpointDto.class); deviceRunpoint.setHasgoods(hasGoodStatus); deviceRunpoint.setMaterial_type(material_type); deviceRunpoint.setBatch(batch); @@ -1019,6 +1157,8 @@ public class DeviceServiceImpl extends CommonServiceImpl i device.setQuantity(quantity); device.setBatch(batch); device.setIslock(islock); +// JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj); +// runpointwo.update(updatejson, "device_code = '" + device_code + "'"); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(DeviceRunpoint::getDevice_code, device_code); deviceRunpointMapper.delete(wrapper); @@ -1241,6 +1381,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } +// JSONArray arr = WQLObject.getWQLObject("acs_device_extra").query("filed_type ='01' and device_id = '" + device_id + "'").getResultJSONArray(0); List deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper) .eq(DeviceExtra::getDevice_id, device_id) .eq(DeviceExtra::getFiled_type, "01") @@ -1295,6 +1436,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i //判断是否配置过 if (json.getBoolean("is_config")) { //设备扩展表【acs_device_extra】 +// JSONArray rs = WQLObject.getWQLObject("acs_device_extra").query("filed_type='02' and device_id = '" + device_id + "'", "order_seq").getResultJSONArray(0); List dList = new LambdaQueryChainWrapper<>(deviceExtraMapper) .eq(DeviceExtra::getDevice_id, device_id) .eq(DeviceExtra::getFiled_type, "02") @@ -1311,6 +1453,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i JSONObject readableItemJson = new JSONObject(); readableItemJson.put("code", itemDto.getCode()); readableItemJson.put("name", itemDto.getName()); + // readableItemJson.put("db",itemDto.getDb()); readableItemJsons.add(readableItemJson); } for (int i = 0; i < rs.size(); i++) { @@ -1347,6 +1490,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i r_arry.add(readableItemJson); } } +// JSONArray ws = WQLObject.getWQLObject("acs_device_extra").query("filed_type='03' and device_id = '" + device_id + "'", "order_seq").getResultJSONArray(0); List wsList = new LambdaQueryChainWrapper<>(deviceExtraMapper) .eq(DeviceExtra::getDevice_id, device_id) .eq(DeviceExtra::getFiled_type, "03") @@ -1362,6 +1506,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i JSONObject writeableItemJson = new JSONObject(); writeableItemJson.put("code", itemDto.getCode()); writeableItemJson.put("name", itemDto.getName()); + //writeableItemJson.put("db",itemDto.getDb()); writeableItemJsons.add(writeableItemJson); } for (int i = 0; i < ws.size(); i++) { @@ -1538,7 +1683,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } item.add(datatype); - item.add(CommonFinalParam.ONE); + item.add("1"); item.add("R/W"); item.add("100"); @@ -1578,7 +1723,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } item.add(datatype); - item.add(CommonFinalParam.ONE); + item.add("1"); item.add("R/W"); item.add("100"); @@ -1594,10 +1739,11 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public JSONArray selectDeviceListByType(String type) { - +// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' and device_type = '" + type + "' AND is_config = 'true'", "device_code").getResultJSONArray(0); +// return arr; List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) .eq(Device::getIs_delete, "0") - .eq(Device::getIs_active, CommonFinalParam.ONE) + .eq(Device::getIs_active, "1") .eq(Device::getDevice_type, type) .eq(Device::getIs_config, "true") .orderByAsc(Device::getDevice_code) @@ -1608,11 +1754,18 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public JSONObject queryStorageExtra(String device_code) { +// JSONObject device = WQLObject.getWQLObject("acs_device").query("device_code = '" + device_code + "'").uniqueResult(0); Device device = new LambdaQueryChainWrapper<>(deviceMapper) .eq(Device::getDevice_code, device_code) .one(); String device_id = device.getDevice_id(); +// WQLObject wo = WQLObject.getWQLObject("acs_device_extra"); JSONObject jo = new JSONObject(); +// jo.put("maxY", wo.query("device_id = '" + device_id + "' AND extra_code = 'maxY'").uniqueResult(0).getString("extra_value")); +// jo.put("minY", wo.query("device_id = '" + device_id + "' AND extra_code = 'minY'").uniqueResult(0).getString("extra_value")); +// jo.put("maxZ", wo.query("device_id = '" + device_id + "' AND extra_code = 'maxZ'").uniqueResult(0).getString("extra_value")); +// jo.put("minZ", wo.query("device_id = '" + device_id + "' AND extra_code = 'minZ'").uniqueResult(0).getString("extra_value")); +// jo.put("tunnel", wo.query("device_id = '" + device_id + "' AND extra_code = 'tunnel'").uniqueResult(0).getString("extra_value")); jo.put("maxY", new LambdaQueryChainWrapper<>(deviceExtraMapper).eq(DeviceExtra::getDevice_id, device_id).eq(DeviceExtra::getExtra_code, "maxY").one().getExtra_value()); jo.put("minY", new LambdaQueryChainWrapper<>(deviceExtraMapper).eq(DeviceExtra::getDevice_id, device_id).eq(DeviceExtra::getExtra_code, "minY").one().getExtra_value()); jo.put("maxZ", new LambdaQueryChainWrapper<>(deviceExtraMapper).eq(DeviceExtra::getDevice_id, device_id).eq(DeviceExtra::getExtra_code, "maxZ").one().getExtra_value()); @@ -1639,7 +1792,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } /** - * 加载货位信息 + * 加载货位信息 */ @Override public void reload() { @@ -1728,7 +1881,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i int numberSize = Integer.parseInt(form.getString("device_number")); List> list = new LinkedList<>(); - if ("db".equals(type)) { + if (type.equals("db")) { for (int i = 0; i < numberSize; i++) { int dbInterval = db_interval * i; Integer deviceCode = device_code + i; @@ -1760,7 +1913,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i String db = rs.getString("db"); String name = rs.getString("name"); if (i > 0) { - if ("心跳".equals(name)) { + if (name.equals("心跳")) { continue; } } @@ -1801,7 +1954,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } } } - } else if ("v".equals(type)) { + } else if (type.equals("v")) { for (int i = 0; i < numberSize; i++) { int dbInterval = db_interval * i; Integer deviceCode = device_code + i; @@ -1826,10 +1979,11 @@ public class DeviceServiceImpl extends CommonServiceImpl i String db = rs.getString("db"); String name = rs.getString("name"); if (i > 0) { - if ("心跳".equals(name)) { + if (name.equals("心跳")) { continue; } } + //String[] dbs = db.split("\\."); String startDB = db.substring(0, 2); String endDB = db.substring(2, db.length()); Integer endDBEnd = Integer.parseInt(endDB); @@ -1923,9 +2077,9 @@ public class DeviceServiceImpl extends CommonServiceImpl i //西门子200 if (!datatype.contains(".")) { String[] split = datatype.split(""); - if ("W".equals(split[1])) { + if (split[1].equals("W")) { datatype = "Word"; - } else if ("D".equals(split[1])) { + } else if (split[1].equals("D")) { datatype = "DWord"; } } else { @@ -1933,7 +2087,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } item.add(datatype); - item.add(CommonFinalParam.ONE); + item.add("1"); item.add("R/W"); item.add("100"); @@ -1968,7 +2122,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i //FX5U if (!datatype.contains(".")) { String[] split = datatype.split(""); - if ("D".equals(split[1])) { + if (split[1].equals("D")) { datatype = "Long"; } } else { @@ -1976,7 +2130,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } item.add(datatype); - item.add(CommonFinalParam.ONE); + item.add("1"); item.add("R/W"); item.add("100"); @@ -2006,6 +2160,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i } catch (Exception e) { e.printStackTrace(); } +// WQLObject wo = WQLObject.getWQLObject("acs_device"); // 调用用 hutool 方法读取数据 默认调用第一个sheet ExcelReader excelReader = ExcelUtil.getReader(inputStream); @@ -2053,6 +2208,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i param.put("update_time", now); param.put("region", region); +// wo.insert(param); Device entity = ConvertUtil.convert(param, Device.class); deviceMapper.insert(entity); } @@ -2072,6 +2228,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i JSONObject ws = wss.getJSONObject(j - 1); String db = ws.getString("db"); String name = ws.getString("name"); + //String[] dbs = db.split("\\."); String startDB = db.substring(0, 2); String endDB = db.substring(2, db.length()); Integer endDBEnd = Integer.parseInt(endDB); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDefination.java new file mode 100644 index 0000000..ab2f25e --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDefination.java @@ -0,0 +1,60 @@ +package org.nl.acs.device_driver.box_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.device_driver.manipulator.standard_manipulator.StandardItemProtocol; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class BoxManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "box_manipulator"; + } + + @Override + public String getDriverName() { + return "装箱行架机械手"; + } + + @Override + public String getDriverDescription() { + return "装箱行架机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new BoxManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return BoxManipulatorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.station); + return types; + } + + @Override + public List getReadableItemDtos() { + return StandardItemProtocol.getReadableItemDtos(); + } + + + + @Override + public List getWriteableItemDtos() { + return StandardItemProtocol.getWriteableItemDtos(); + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDeviceDriver.java new file mode 100644 index 0000000..7af0df6 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDeviceDriver.java @@ -0,0 +1,396 @@ +package org.nl.acs.device_driver.box_manipulator; + +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.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +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.device_driver.manipulator.standard_manipulator.StandardItemProtocol; +import org.nl.acs.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.List; + +/** + * 装箱行架机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class BoxManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + + protected StandardItemProtocol standardItemProtocol = new StandardItemProtocol("2"); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //行走列 + int walk_y = 0; + int last_walk_y = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + // x坐标 + float x_position = 0; + float last_x_position = 0; + // y坐标 + float y_position = 0; + float last_y_position = 0; + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_onset = 0; + int last_to_onset = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + private String error_type = "hxhj_error_type"; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + //当前指令 + Instruction inst = null; + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.standardItemProtocol.getMode(); + move = this.standardItemProtocol.getMove(); + action = this.standardItemProtocol.getAction(); + walk_y = this.standardItemProtocol.getWalk_y(); + error = this.standardItemProtocol.getError(); + task = this.standardItemProtocol.getTask(); + heartbeat = this.standardItemProtocol.getHeartbeat(); + to_command = this.standardItemProtocol.getTo_command(); + to_target = this.standardItemProtocol.getTo_target(); + to_task = this.standardItemProtocol.getTo_task(); + to_onset = this.standardItemProtocol.getTo_onset(); + x_position = this.standardItemProtocol.getX_position(); + y_position = this.standardItemProtocol.getY_position(); + + if (to_onset != last_to_onset) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (mode != last_mode) { + requireSucess = false; + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (walk_y != last_walk_y) { + logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + if (x_position != last_x_position) { + logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); + } + if (y_position != last_y_position) { + logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); + } + + // 更新指令状态 + if (mode == 3 && task > 0) { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改指令状态 + if (task > 0) { + Instruction inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status(CommonFinalParam.ONE); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } + } + } + + } catch (Exception var17) { + var17.printStackTrace(); + feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.standardItemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// boolean res = applyTask(); +// if (res) { +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; +// } + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = "未查找任务原因为:"; + if (mode != 2) { + remark = remark + "工作模式(mode)不是待机状态,"; + } + if (move != 0) { + remark = remark + "光电信号(move)为有货状态,"; + } + if (task != 0) { + remark = remark + "当前上报任务号(task)应该为0,"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } + last_mode = mode; + last_move = move; + last_action = action; + last_walk_y = walk_y; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_to_onset = to_onset; + last_x_position = x_position; + last_y_position = y_position; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } + + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = "取货中"; + } else if (this.getAction() == 2) { + action = "取货完成"; + } else if (this.getAction() == 3) { + action = "放货中"; + } else if (this.getAction() == 4) { + action = "放货完成"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("task", task); + jo.put("walk_y", walk_y); + jo.put("isOnline", this.getIsonline()); + jo.put("error", ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(this.getError()))); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + jo.put("x", x_position); + jo.put("y", y_position); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } + + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardItemProtocol.java new file mode 100644 index 0000000..1d3df4b --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardItemProtocol.java @@ -0,0 +1,151 @@ +package org.nl.acs.device_driver.manipulator.standard_manipulator; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.box_manipulator.BoxManipulatorDeviceDriver; + + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Data +public class StandardItemProtocol { + //心跳 + 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_walk_y = "walk_y"; + //任务号 + public static String item_task = "task"; + //报警 + public static String item_error = "error"; + //x轴坐标 + public static String item_x_position = "x_position"; + //y轴坐标 + public static String item_y_position = "y_position"; + + //下发命令 + public static String item_to_command = "to_command"; + //下发起始站 + public static String item_to_onset = "to_onset"; + //下发目标站 + public static String item_to_target = "to_target"; + //下发任务号 + public static String item_to_task = "to_task"; + + StandardManipulatorDeviceDriver standardManipulatorDeviceDriver; + BoxManipulatorDeviceDriver boxManipulatorDeviceDriver; + + private final String type; + + + public StandardItemProtocol(String type) { + this.type = type; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat,type); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode,type); + } + + public int getMove() { + return this.getOpcIntegerValue(item_move,type); + } + + public int getAction() { + return this.getOpcIntegerValue(item_action,type); + } + + public int getWalk_y() { + return this.getOpcIntegerValue(item_walk_y,type); + } + + public int getError() { + return this.getOpcIntegerValue(item_error,type); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task,type); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command,type); + } + + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target,type); + } + + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task,type); + } + + public int getTo_onset() { + return this.getOpcIntegerValue(item_to_onset,type); + } + + public int getX_position() { + return this.getOpcIntegerValue(item_x_position,type); + } + + public int getY_position() { + return this.getOpcIntegerValue(item_y_position,type); + } + + + Boolean isonline; + + public int getOpcIntegerValue(String protocol,String type) { + Integer value = null; + if ("1".equals(type)){ + value = this.standardManipulatorDeviceDriver.getIntegeregerValue(protocol); + }else if ("2".equals(type)){ + value = this.boxManipulatorDeviceDriver.getIntegeregerValue(protocol); + } + if (value == null) { + // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); + list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); + list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4")); + list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); + list.add(new ItemDto(item_task, "任务号", "DB1.D6")); + list.add(new ItemDto(item_x_position, "x坐标", "DB1.REAL10")); + list.add(new ItemDto(item_y_position, "y坐标", "DB1.REAL14")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); + list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); + return list; + } + +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java index b8fd9b8..4fa51c1 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java @@ -48,14 +48,14 @@ public class StandardManipulatorDefination implements OpcDeviceDriverDefination @Override public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); + return StandardItemProtocol.getReadableItemDtos(); } @Override public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); + return StandardItemProtocol.getWriteableItemDtos(); } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java index a00eb99..98cf1b8 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java @@ -17,7 +17,6 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.dto.DeviceErrorLogDto; import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.service.InstructionService; @@ -41,7 +40,7 @@ import java.util.List; @Data @RequiredArgsConstructor public class StandardManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); + protected StandardItemProtocol standardItemProtocol = new StandardItemProtocol("1"); @Autowired DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); @Autowired @@ -144,19 +143,19 @@ public class StandardManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp String message = null; try { device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - walk_y = this.itemProtocol.getWalk_y(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - heartbeat = this.itemProtocol.getHeartbeat(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTo_target(); - to_task = this.itemProtocol.getTo_task(); - to_onset = this.itemProtocol.getTo_onset(); - x_position = this.itemProtocol.getX_position(); - y_position = this.itemProtocol.getY_position(); + mode = this.standardItemProtocol.getMode(); + move = this.standardItemProtocol.getMove(); + action = this.standardItemProtocol.getAction(); + walk_y = this.standardItemProtocol.getWalk_y(); + error = this.standardItemProtocol.getError(); + task = this.standardItemProtocol.getTask(); + heartbeat = this.standardItemProtocol.getHeartbeat(); + to_command = this.standardItemProtocol.getTo_command(); + to_target = this.standardItemProtocol.getTo_target(); + to_task = this.standardItemProtocol.getTo_task(); + to_onset = this.standardItemProtocol.getTo_onset(); + x_position = this.standardItemProtocol.getX_position(); + y_position = this.standardItemProtocol.getY_position(); if (to_onset != last_to_onset) { logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); @@ -229,7 +228,7 @@ public class StandardManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } catch (Exception var17) { var17.printStackTrace(); feedMessage = var17.getMessage(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.standardItemProtocol)); } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index b651484..3f00b55 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -20,6 +20,7 @@ import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver; import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver; +import org.nl.acs.device_driver.box_manipulator.BoxManipulatorDeviceDriver; import org.nl.acs.device_driver.conveyor.hongxiang_conveyor.HongXiangStationDeviceDriver; import org.nl.acs.device_driver.conveyor.hongxiang_device.HongXiangConveyorDeviceDriver; import org.nl.acs.device_driver.manipulator.standard_manipulator.StandardManipulatorDeviceDriver; @@ -113,6 +114,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { JSONArray datas = JSONArray.parseArray(jsonObject); //标准版行架机械手 StandardManipulatorDeviceDriver standardManipulatorDeviceDriver; + //装箱行架机械手 + BoxManipulatorDeviceDriver boxManipulatorDeviceDriver; if (datas.size() == 0) { throw new BadRequestException("缺少输入参数!"); @@ -143,6 +146,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("x", standardManipulatorDeviceDriver.getX_position()); jo.put("y", standardManipulatorDeviceDriver.getY_position()); jo.put("error", standardManipulatorDeviceDriver.getError()); + } else if (device.getDeviceDriver() instanceof BoxManipulatorDeviceDriver){ + boxManipulatorDeviceDriver = (BoxManipulatorDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", boxManipulatorDeviceDriver.getDevice().getDevice_code()); + jo.put("device_name", boxManipulatorDeviceDriver.getDevice().getDevice_name()); + jo.put("status", Math.min(3, boxManipulatorDeviceDriver.getMode())); + jo.put("x", boxManipulatorDeviceDriver.getX_position()); + jo.put("y", boxManipulatorDeviceDriver.getY_position()); + jo.put("error", boxManipulatorDeviceDriver.getError()); } else { jo.put("device_code", parent_device_code); } diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index 903780e..2a9fd2a 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -104,6 +104,7 @@ import standard_station from '@/views/acs/device/driver/standard_station' import double_belt_conveyor from '@/views/acs/device/driver/double_belt_conveyor.vue' import with_station_device from '@/views/acs/device/driver/with_station_device.vue' import standard_manipulator from '@/views/acs/device/driver/standard_manipulator.vue' +import box_manipulator from '@/views/acs/device/driver/box_manipulator.vue' export default { name: 'DeviceConfig', components: { @@ -137,8 +138,8 @@ export default { slit_two_manipulator, double_belt_conveyor, with_station_device, - standard_manipulator - + standard_manipulator, + box_manipulator }, dicts: ['device_type'], mixins: [crud], diff --git a/acs/nladmin-ui/src/views/acs/device/driver/box_manipulator.vue b/acs/nladmin-ui/src/views/acs/device/driver/box_manipulator.vue new file mode 100644 index 0000000..f36f1c5 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/box_manipulator.vue @@ -0,0 +1,546 @@ + + + + +