diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index d19ff62..044f1f7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -196,7 +196,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } else { //上报异常信息 //(不需要WCS反馈) - if (phase == 0x67) { + if (phase == 0x67 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74 || phase == 0x75) { device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); } else { device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); @@ -218,16 +218,15 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } } - } catch ( - Exception e) { + } catch ( Exception e) { System.out.println("OneAgv链接异常"); log.info("OneAgv链接异常"); log.error("agv连接出现异常:{}", e); logServer.deviceExecuteLog("1", "", "", "agv异常" + e.getMessage()); logServer.deviceExecuteLog("1", "", "", "agv异常" + e); - if (ObjectUtil.isNotEmpty(s)) { - s.close(); - } +// if (ObjectUtil.isNotEmpty(s)) { +// s.close(); +// } System.out.println(e.getMessage()); e.printStackTrace(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index ed8d522..3b14cc0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -1,6 +1,7 @@ package org.nl.acs.device_driver.basedriver.agv.ndcone; 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; @@ -23,6 +24,7 @@ import org.nl.acs.instruction.service.impl.InstructionServiceImpl; import org.nl.acs.log.LokiLog; import org.nl.acs.log.LokiLogType; import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.task.service.TaskService; @@ -43,7 +45,7 @@ import java.util.Map; @Slf4j @Data @RequiredArgsConstructor -public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { +public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor { ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); @@ -72,6 +74,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic int last_status = 0; int last_error = 0; + private Instruction instruction; + @LokiLog(type = LokiLogType.ACS_TO_LMS) public synchronized void processSocket(int[] arr) throws Exception { device_code = this.getDeviceCode(); @@ -94,10 +98,14 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); } if (ikey != 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - if (ObjectUtil.isEmpty(inst)){ - inst = instructionService.findByCode(String.valueOf(ikey)); + if (phase != 0x67 && phase != 0x71 && phase != 0x72 && phase != 0x73 && phase != 0x74 && phase != 0x75) { + inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); + this.instruction = inst; } +// inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); +// if (ObjectUtil.isEmpty(inst)){ +// inst = instructionService.findByCode(String.valueOf(ikey)); +// } } if (!ObjectUtil.isEmpty(link_inst)) { link_flag = true; @@ -108,13 +116,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic String emptyNum = null; String device_code = null; - if (phase == 0x67) { - //故障信息 - if (arr[18] * 256 + arr[19] == 0) { - - } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } +// if (phase == 0x67) { +// //故障信息 +// if (arr[18] * 256 + arr[19] == 0) { +// +// } +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } //普通站点 StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; @@ -142,9 +150,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic request.put("METHOD", "1"); request.put("AGVCODE", this.device_code); request.put("REQTIME", DateUtil.now()); - log.info("atrAgvCallback 请求参数:"+request.toJSONString()); + log.info("atrAgvCallback 请求参数:" + request.toJSONString()); String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); - log.info("atrAgvCallback 返回参数:"+str); + log.info("atrAgvCallback 返回参数:" + str); } } //到达取货点 @@ -218,9 +226,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic request.put("METHOD", "2"); request.put("AGVCODE", this.device_code); request.put("REQTIME", DateUtil.now()); - log.info("atrAgvCallback 请求参数:"+request.toJSONString()); - String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); - log.info("atrAgvCallback 返回参数:"+str); + log.info("atrAgvCallback 请求参数:" + request.toJSONString()); + String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 返回参数:" + str); } } @@ -307,9 +315,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic request.put("METHOD", "3"); request.put("AGVCODE", this.device_code); request.put("REQTIME", DateUtil.now()); - log.info("atrAgvCallback 请求参数:"+request.toJSONString()); + log.info("atrAgvCallback 请求参数:" + request.toJSONString()); String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); - log.info("atrAgvCallback 返回参数:"+str); + log.info("atrAgvCallback 返回参数:" + str); } } @@ -371,9 +379,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic request.put("METHOD", "4"); request.put("AGVCODE", this.device_code); request.put("REQTIME", DateUtil.now()); - log.info("atrAgvCallback 请求参数:"+request.toJSONString()); + log.info("atrAgvCallback 请求参数:" + request.toJSONString()); String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); - log.info("atrAgvCallback 返回参数:"+str); + log.info("atrAgvCallback 返回参数:" + str); } } @@ -420,9 +428,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); // data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); } @@ -444,6 +452,24 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } else if (phase == 0x51) {//离开交通灯区域 data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); + } else if (phase == 0x67) {//agv异常 + error = ikey; + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else if (phase == 0x71) { + //x坐标 + x = ikey; + } else if (phase == 0x72) { + //y坐标 + y = ikey; + } else if (phase == 0x73) { + //车辆角度 + angle = ikey; + } else if (phase == 0x74) { + //agv电量 + electric_qty = ikey; + } else if (phase == 0x75) { + //三色灯状态 + status = ikey; } if (!ObjectUtil.isEmpty(data)) { logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); @@ -451,4 +477,32 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } } + @Override + public JSONObject getDeviceStatusName() throws Exception { + JSONObject jo = new JSONObject(); + jo.put("REQCODE", IdUtil.getSnowflake().nextId()); + + jo.put("REQTIME", DateUtil.now()); + //agv编码 + jo.put("AGVCODE", this.getDevice().getDevice_code()); + //角度 + jo.put("AGVDIR", this.getAngle()); + //IP + jo.put("AGVIP", ObjectUtil.isEmpty(this.getDevice().getExtraValue()) ? "" : this.getDevice().getExtraValue().get("ip_address")); + //电量 + jo.put("AGVBATTERY", this.getElectric_qty()); + //x坐标 + jo.put("POSX", this.getX()); + //y坐标 + jo.put("POSY", this.getY()); + String status_name = this.status == 1 ? "关机" : this.status == 2 ? "工作中" : this.status == 3 ? "交通管制" : this.status == 4 ? "任务等待" : this.status == 5 ? "充电中" : this.status == 6 ? "故障中" : this.status == 7 ? "电量低" : "正常"; + //agv状态 + jo.put("STATUS", status_name); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 9276172..87af6e5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -229,7 +229,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByCode(String code) { WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0); + JSONObject json = wo.query("instruction_code ='" + code + "'", "create_time").uniqueResult(0); if (ObjectUtil.isEmpty(json)) { return null; } @@ -247,15 +247,15 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByTaskcodeAndStatus(String code) { - Iterator var3 = instructions.iterator(); - while (var3.hasNext()) { - Instruction instruction = (Instruction) var3.next(); - if (StrUtil.equals(instruction.getTask_code(), code) - && StrUtil.equals(instruction.getInstruction_status(), "0")) { - return instruction; - } + Iterator var3 = instructions.iterator(); + while (var3.hasNext()) { + Instruction instruction = (Instruction) var3.next(); + if (StrUtil.equals(instruction.getTask_code(), code) + && StrUtil.equals(instruction.getInstruction_status(), "0")) { + return instruction; } - return null; + } + return null; } @Override @@ -299,7 +299,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } dto.setInstruction_type("1"); - // 查询是否存在相同指令号 + // 查询是否存在相同指令号 // if (!StrUtil.isEmpty(dto.getVehicle_code() )) { // Instruction inst_dto = findByContainer(dto.getVehicle_code()); // if (inst_dto != null) { @@ -945,8 +945,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu return; } removeByCodeFromCache(entity.getInstruction_code()); + TaskDto taskDto = taskService.findByCodeFromCache(entity.getTask_code()); + if (taskDto != null) { + taskService.cancel(taskDto.getTask_id()); + } } -// this.reload(); } @Override @@ -1002,6 +1005,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu return; } removeByCodeFromCache(entity.getInstruction_code()); + TaskDto taskDto = taskService.findByCodeFromCache(entity.getTask_code()); + if (taskDto != null) { + taskService.cancel(taskDto.getTask_id()); + } } @Override @@ -1059,81 +1066,85 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } removeByCodeFromCache(entity.getInstruction_code()); + TaskDto taskDto = taskService.findByCodeFromCache(entity.getTask_code()); + if (taskDto != null) { + taskService.cancel(taskDto.getTask_id()); + } } @Override public Instruction findByLinkNumSend(String code) { - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) { - return inst; - } + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) { + return inst; } + } return null; } @Override public List findByLinkNum(String code) { - List list = new ArrayList<>(); - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { - list.add(inst); - } + List list = new ArrayList<>(); + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { + list.add(inst); } - return list; + } + return list; } @Override public Instruction findByLinkNumNoSend(String code) { - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { - return inst; - } + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) { + return inst; } + } - return null; + return null; } @Override public Instruction findByCodeFromCache(String code) { - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - if (StrUtil.equals(code, inst.getInstruction_code())) { - return inst; - } + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(code, inst.getInstruction_code())) { + return inst; } - return null; + } + return null; } @Override public Instruction findByBarcodeFromCache(String barcode) { - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - if (StrUtil.equals(barcode, inst.getVehicle_code())) { - return inst; - } + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(barcode, inst.getVehicle_code())) { + return inst; } - return null; + } + return null; } @Override public Instruction findByIdFromCache(String id) { - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - if (StrUtil.equals(id, inst.getInstruction_id())) { - return inst; - } + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(id, inst.getInstruction_id())) { + return inst; } - return null; + } + return null; } @Override @@ -1209,23 +1220,23 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByDeviceCodeFromCache(String devicecode) { - List instructionList = instructions; - ListUtil.sort( - instructionList, - new Comparator() { - @Override - public int compare(Instruction o1, Instruction o2) { - return o1.getCreate_time().compareTo(o2.getCreate_time()); - } - }); - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - if (StrUtil.equals(devicecode, inst.getStart_device_code()) - && inst.getInstruction_status().equals("0")) { - return inst; - } + List instructionList = instructions; + ListUtil.sort( + instructionList, + new Comparator() { + @Override + public int compare(Instruction o1, Instruction o2) { + return o1.getCreate_time().compareTo(o2.getCreate_time()); + } + }); + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(devicecode, inst.getStart_device_code()) + && inst.getInstruction_status().equals("0")) { + return inst; } + } return null; } @@ -1237,52 +1248,52 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Integer querySameDestinationInst(String devicecode) { - int num = 0; - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - // 处理空盘位站点 - String next_code = inst.getNext_point_code(); - if (next_code.indexOf(".") != -1) { - next_code = next_code.substring(0, next_code.indexOf(".")); - } - if (StrUtil.equals(devicecode, next_code)) { - num = num + 1; - } + int num = 0; + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + // 处理空盘位站点 + String next_code = inst.getNext_point_code(); + if (next_code.indexOf(".") != -1) { + next_code = next_code.substring(0, next_code.indexOf(".")); + } + if (StrUtil.equals(devicecode, next_code)) { + num = num + 1; } + } - return num; + return num; } @Override public Integer querySameInstType(String inst_type) { - int num = 0; - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - if (StrUtil.equals(inst.getInstruction_type(), inst_type)) { - num = num + 1; - } + int num = 0; + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(inst.getInstruction_type(), inst_type)) { + num = num + 1; } - return num; } + return num; + } @Override public Integer querySameOriginInst(String devicecode) { - int num = 0; - Iterator it = instructions.iterator(); - while (it.hasNext()) { - Instruction inst = it.next(); - // 处理空盘位站点 - String start_code = inst.getStart_point_code(); - if (start_code.indexOf(".") != -1) { - start_code = start_code.substring(0, start_code.indexOf(".")); - } - if (StrUtil.equals(devicecode, start_code)) { - num = num + 1; - } + int num = 0; + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + // 处理空盘位站点 + String start_code = inst.getStart_point_code(); + if (start_code.indexOf(".") != -1) { + start_code = start_code.substring(0, start_code.indexOf(".")); } - return num; + if (StrUtil.equals(devicecode, start_code)) { + num = num + 1; + } + } + return num; } @Override diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 11975ce..8bed9b3 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -764,9 +764,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { request.put("TASKTYPE", entity.getTask_type()); request.put("METHOD", "5"); request.put("REQTIME", DateUtil.now()); - log.info("atrAgvCallback 请求参数:"+request.toString()); + log.info("atrAgvCallback 请求参数:" + request.toString()); String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); - log.info("atrAgvCallback 返回参数:"+str); + log.info("atrAgvCallback 返回参数:" + str); } catch (Exception e) { e.printStackTrace(); throw new BadRequestException(e.getMessage()); @@ -814,6 +814,33 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { // }} removeByCodeFromCache(entity.getTask_code()); + // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS + String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); + if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); + System.out.println(feefbackdto == null); + JSONObject feed_jo = new JSONObject(); + feed_jo.put("task_id", entity.getTask_id()); + feed_jo.put("task_code", entity.getTask_code()); + feed_jo.put("task_status", entity.getTask_status()); + JSONArray ja = new JSONArray(); + ja.add(feed_jo); + try { + JSONObject request = new JSONObject(); + request.put("REQCODE", entity.getExt_task_id()); + request.put("TASKCODE", entity.getTask_code()); + request.put("TASKTYPE", entity.getTask_type()); + request.put("METHOD", "9"); + request.put("AGVCODE", instructionService.findByCode(entity.getTask_code()) == null ? "" : instructionService.findByCode(entity.getTask_code()).getCarno()); + request.put("REQTIME", DateUtil.now()); + log.info("atrAgvCallback 请求参数:" + request.toString()); + String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 返回参数:" + str); + } catch (Exception e) { + e.printStackTrace(); + throw new BadRequestException(e.getMessage()); + } + } List shortPathsList = routeLineService.getShortPathLines( entity.getStart_device_code(), diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoFeedAgvStatus.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoFeedAgvStatus.java new file mode 100644 index 0000000..bfa8f9c --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoFeedAgvStatus.java @@ -0,0 +1,50 @@ +package org.nl.modules.quartz.task; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceType; +import org.nl.acs.wsdl.org.tempuri.RTMSAGVSERVICE; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author: geng by + * @createDate: 2023/5/9 + */ +@Slf4j +@Component +public class AutoFeedAgvStatus { + + @Autowired + private DeviceAppService deviceAppService; + + public void run() throws Exception { + List devices = deviceAppService.findDevice(DeviceType.agv); + JSONArray data = new JSONArray(); + if (ObjectUtil.isNotEmpty(devices)) { + for (int i = 0; i < devices.size(); i++) { + Device device = devices.get(i); + Device agvDevice = deviceAppService.findDeviceByCode(device.getDevice_code()); + if (agvDevice.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { + AgvNdcOneDeviceDriver agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) agvDevice.getDeviceDriver(); + JSONObject jo = agvNdcOneDeviceDriver.getDeviceStatusName(); + data.add(jo); + } + } + try { + log.info("atrAgvCallback 请求参数:" + data.toJSONString()); + String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(data.toJSONString()); + log.info("atrAgvCallback 返回参数:" + str); + } catch (Exception e) { + log.error("atrAgvCallback,反馈失败:{}", e.getMessage()); + } + } + } +} diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index d4bbec2..d60d6ad 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -13,11 +13,11 @@ spring: driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy # url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:huaYan_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true username: ${DB_USER:root} # password: ${DB_PWD:P@ssw0rd} # password: ${DB_PWD:Root.123456} - password: ${DB_PWD:123456} + password: ${DB_PWD:password} # 初始连接数 initial-size: 5