diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java index 80ca668..645342d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java @@ -298,4 +298,6 @@ public interface DeviceService { * @param request */ void excelImport(MultipartFile file, HttpServletRequest request); + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index a50e0ed..cf12f86 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -2,6 +2,7 @@ package org.nl.acs.device.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.IdUtil; @@ -20,6 +21,7 @@ import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; import org.nl.acs.device.service.*; import org.nl.acs.device.service.dto.*; +import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.DeviceDriverDefination; import org.nl.acs.device_driver.ScannerDeviceDriver; import org.nl.acs.device_driver.basedriver.oven_manipulator.OvenGantryManipulatorDeviceDriver; @@ -35,6 +37,7 @@ import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.opc.DeviceManageDto; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.utils.FileUtil; import org.nl.modules.common.utils.RedisUtils; @@ -848,9 +851,13 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial } - //deviceAppService.reload(); + deviceAppService.removeDevice(device_code); + + deviceAppService.addDevice(device_code); } + + @Override public void changeDeviceStatus(JSONObject form) { String device_code = form.getString("device_code"); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/ItemProtocol.java index 9778ea0..ac4ee84 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/ItemProtocol.java @@ -272,7 +272,7 @@ public class ItemProtocol { public Float getOpcFloatValue(String protocol) { Float value = this.driver.getFloatValue(protocol); if (ObjectUtil.isEmpty(value)) { - log.error("读取错误!"); + } else { return value; } @@ -282,7 +282,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegerValue(protocol); if (value == null) { - log.error("读取错误!"); + } else { return value; } @@ -293,7 +293,7 @@ public class ItemProtocol { public short getOpcShortValue(String protocol) { Short value = this.driver.getShortValue(protocol); if (value == null) { - log.error("读取错误!"); + } else { return value; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java index 095a09c..d95bca2 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java @@ -2,6 +2,7 @@ package org.nl.acs.device_driver.basedriver.agv.xg_agv; 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; @@ -12,6 +13,7 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.route.service.RouteLineService; @@ -27,12 +29,12 @@ import java.util.Map; /** - * magic3.0 + * 仙工agv */ @Slf4j @Data @RequiredArgsConstructor -public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { +public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor { @Autowired RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); @Autowired @@ -60,8 +62,8 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device int DI12 = 0; int DO0 = 0; int DO1 = 0; - int DO2 = 0; - Float x = 0f; + int DO2 = 0; + Float x = 0f; Float y = 0f; Float angle = 0f; int navigation_address =0; @@ -106,7 +108,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device int last_continue_navigation =0; int last_cancle_navigation =0; int last_drum_run_status =0; - + String message = null; String device_code; Instruction inst = null; protected ItemProtocol itemProtocol = new ItemProtocol(this); @@ -150,16 +152,39 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device //获取最小电量 + if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("min_electric"))){ + message = "未配置最小电量"; + return; + } double min_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("min_electric")); //获取最大电量 + if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("cancle_electric"))){ + message = "未配置最大电量"; + return; + } double cancle_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("cancle_electric")); //可执行任务电量 + if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("task_electric"))){ + message = "未配置可执行任务电量"; + return; + } double task_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("task_electric")); //休息点 - int relax_point = Integer.parseInt((String)this.getDevice().getExtraValue().get("relax_point")); + if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("relax_point"))){ + message = "未配置休息点"; + return; + } + Device relax_point_device = deviceAppService.findDeviceByCode((String)this.getDevice().getExtraValue().get("relax_point")); + int relax_point = Integer.parseInt(relax_point_device.getAddress()); //充电点 - int charge_point = Integer.parseInt((String)this.getDevice().getExtraValue().get("charge_point")); + if(ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("charge_point"))){ + message = "未配置充电点"; + return; + } + Device charge_point_device = deviceAppService.findDeviceByCode((String)this.getDevice().getExtraValue().get("charge_point")); + int charge_point = Integer.parseInt(charge_point_device.getAddress()); List instList = instructionService.findAllInstFromCache(); + if(instList.size()>0){ inst = instList.get(0); } @@ -176,11 +201,12 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device } } else { // log.info("address:{},滚筒状态:{},车子状态:{},DI4:{},DO1:{},DO2:{},导航状态:{}",address,drum_run_status,stop,DI4,DO1,DO2,navigation_status); - int start_device_code = Integer.parseInt(inst.getStart_device_code()); - int next_device_code = Integer.parseInt(inst.getNext_device_code()); - Device start_device = deviceAppService.findDeviceByCode(String.valueOf(start_device_code)); - Device next_device = deviceAppService.findDeviceByCode(String.valueOf(next_device_code)); + + Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + int start_device_code = Integer.parseInt(start_device.getAddress()); + int next_device_code = Integer.parseInt(next_device.getAddress()); StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; //指令状态就绪 if(StrUtil.equals("0",inst.getInstruction_status())){ @@ -283,5 +309,23 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device ReadUtil.write(itemMap, server); } + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("message", this.getMessage()); + jo.put("is_click", true); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + + } + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceAppService.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceAppService.java index 7588763..cc3cd98 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceAppService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceAppService.java @@ -81,4 +81,8 @@ public interface DeviceAppService { */ String findDeviceTypeByCode(String deviceCode); + void removeDevice(String deviceCode); + + void addDevice(String deviceCode); + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceAppServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceAppServiceImpl.java index 7f1d710..9c88337 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceAppServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceAppServiceImpl.java @@ -341,5 +341,49 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn } + @Override + public void removeDevice(String deviceCode) { + + Iterator iterator = devices.iterator(); + while (iterator.hasNext()) { + Device device = iterator.next(); + if (StrUtil.equals(device.getDevice_code(), deviceCode)) { + iterator.remove(); + } + } + Iterator iterator2 = code_indexs.iterator(); + while (iterator2.hasNext()) { + String str = iterator2.next(); + if (StrUtil.equals(str, deviceCode)) { + iterator2.remove(); + } + } + + } + + @Override + public void addDevice(String deviceCode) { + List deviceManageDtos = this.deviceManageService.queryAllWithExtra(deviceCode); + int i = 0; + + for (int size = deviceManageDtos.size(); i < size; ++i) { + DeviceManageDto deviceManage = (DeviceManageDto) deviceManageDtos.get(i); + Device device = new Device(); + BeanUtil.copyProperties(deviceManage, device); + this.devices.add(device); + this.code_indexs.add(device.getDevice_code()); + + if (!StrUtil.isEmpty(device.getDriver_code())) { + DeviceDriverDefination defination = this.deviceDriverDefinationAppService.getDeviceDriverDefination(deviceManage.getDriver_code()); + if (defination != null) { + device.setDeviceDriverDefination(defination); + DeviceDriver driver = defination.getDriverInstance(device); + device.setDeviceDriver(driver); + + } + } + + } + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageService.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageService.java index f95b50b..a592f2a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageService.java @@ -4,4 +4,6 @@ import java.util.List; public interface DeviceManageService { List queryAllWithExtra(); + + List queryAllWithExtra(String device_code); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java index 3c673e1..8934a16 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java @@ -72,4 +72,69 @@ public class DeviceManageServiceImpl implements DeviceManageService { return devices; } + + @Override + public List queryAllWithExtra(String device_code) { + JSONArray arr = WQLObject.getWQLObject("acs_device").query("device_code = '" + device_code + " '").getResultJSONArray(0); + + JSONArray extArr = WQLObject.getWQLObject("acs_device_extra").query("device_code = '" + device_code + " '").getResultJSONArray(0); + + List extras = extArr.toJavaList(DeviceExtraManageDto.class); + + WQLObject runpointTab = WQLObject.getWQLObject("acs_device_runpoint"); + + WQLObject opcTab = WQLObject.getWQLObject("acs_opc"); + //OPC_PLC表【acs_opc_plc】 + WQLObject plcTab = WQLObject.getWQLObject("acs_opc_plc"); + List devices = new ArrayList<>(); + for (int i = 0; i < arr.size(); i++) { + JSONObject json = arr.getJSONObject(i); + DeviceManageDto device = json.toJavaObject(DeviceManageDto.class); + String opc_server_id = json.getString("opc_server_id"); + String opc_plc_id = json.getString("opc_plc_id"); + if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) { + //OPC表【acs_opc】 + JSONObject rb = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0); + if(ObjectUtil.isEmpty(rb)){ + System.out.println(device.getDevice_code()); + continue; + } + String opc_code= rb.getString("opc_code"); + device.setOpc_server_code(opc_code); + if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0))) + { + System.out.println(device.getDevice_code()); + continue; + } + String plc_code = plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0).getString("plc_code"); + device.setOpc_plc_code(plc_code); + } + devices.add(device); + } + + Iterator it = devices.iterator(); + + while (it.hasNext()) { + DeviceManageDto device = (DeviceManageDto) it.next(); + Iterator var5 = extras.iterator(); + while (var5.hasNext()) { + DeviceExtraManageDto extra = (DeviceExtraManageDto) var5.next(); + if (extra.getDevice_id().equals(device.getDevice_id())) { + device.getExtra().add(extra); + if (StrUtil.equals(extra.getExtra_code(), "station_manager") && StrUtil.equals(extra.getExtra_value().toString(), "true")) { + String has_goods = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("hasgoods"); + String material_type = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("material_type"); + String batch = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("batch"); + String islock = runpointTab.query("is_delete= '0' AND is_active= '1' AND device_id = '" + extra.getDevice_id() + "'").uniqueResult(0).getString("islock"); + device.setMaterial_type(material_type); + device.setHas_goods(Integer.parseInt(has_goods)); + device.setBatch(batch); + device.setIslock(islock); + } + } + } + } + + return devices; + } } diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index 40d7e8e..0aef796 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -133,7 +133,6 @@ export default { this.device_code = this.$route.params.device_code this.$nextTick(() => { get(this.device_code).then(data => { - debugger this.form = data.device // 默认是普通站点 // this.currentComponent = 'standard_ordinary_site' diff --git a/acs/nladmin-ui/src/views/acs/device/driver/agv/xg_agv.vue b/acs/nladmin-ui/src/views/acs/device/driver/agv/xg_agv.vue index e55cfa5..26832e4 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/agv/xg_agv.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/agv/xg_agv.vue @@ -172,6 +172,14 @@ /> + + + +