diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 566b9d9..0cae2c0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -1,36 +1,26 @@ package org.nl.acs.agv.server.impl; -import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.agv.server.dto.AgvDto; import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; -import org.nl.acs.auto.run.TwoNDC2SocketConnectionAutoRun; -import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.impl.DeviceServiceImpl; import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.LokiLog; import org.nl.acs.log.LokiLogType; import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.DeviceType; -import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.system.service.ParamService; import org.nl.modules.wql.util.SpringContextHolder; import org.springframework.stereotype.Service; import java.util.HashMap; -import java.util.List; import java.util.Map; @Slf4j @@ -83,170 +73,61 @@ public class NDCAgvServiceImpl implements NDCAgvService { @Override public void sendAgvInstToNDC(String agv_system_type, Instruction inst) { if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { - if (!StrUtil.equals(agv_system_type, "1")) { - String instcode = inst.getInstruction_code(); - int type = Integer.parseInt(inst.getAgv_inst_type()); - int priority = Integer.parseInt(inst.getPriority()) + 128; - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); - int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); - int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2()); - int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2()); - byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); - byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); - byte typehigh = (byte) IntToHexHigh(type); - byte typelow = (byte) IntToHexLow(type); - byte qhdhigh = (byte) IntToHexHigh(startAddress); - byte qhdlow = (byte) IntToHexLow(startAddress); - byte qhdhigh2 = (byte) IntToHexHigh(startAddress2); - byte qhdlow2 = (byte) IntToHexLow(startAddress2); - byte fhdhigh = (byte) IntToHexHigh(nextAddress); - byte fhdlow = (byte) IntToHexLow(nextAddress); - byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2); - byte fhdlow2 = (byte) IntToHexLow(nextAddress2); - byte prioritylow = (byte) IntToHexLow(priority); - - String str = "十进制下发:"; - String str1 = "十六进制下发:"; - str += "ikey:" + (Integer.parseInt(instcode)); - str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); - - str += "/type:" + (type); - str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); - - str += "/qhd:" + (startAddress); - str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); - str += "/fhd:" + (nextAddress); - str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); - - str += "/qhd2:" + (startAddress2); - str1 += "/qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF); - str += "/fhd2:" + (nextAddress2); - str1 += "/fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF); - - str += "/priority:" + (priority); - str1 += "/priority:" + hexToString(prioritylow & 0xFF); - - System.out.println(str); - System.out.println(str1); - byte[] b = new byte[]{}; - if (type == 1) { - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X16, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X12, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) qhdhigh2, (byte) qhdlow2, - (byte) fhdhigh, (byte) fhdlow, - (byte) fhdhigh2, (byte) fhdlow2 - }; - } else if (type == 2) { - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X16, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X12, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) 0X00, (byte) 0X00, - (byte) fhdhigh, (byte) fhdlow, - (byte) 0X00, (byte) 0X00 - }; - } else if (type == 3) { - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X16, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X12, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) qhdhigh2, (byte) qhdlow2, - (byte) fhdhigh, (byte) fhdlow, - (byte) fhdhigh2, (byte) fhdlow2 - }; - } - log.info("下发AGV作业指令--{}", str1); - if (StrUtil.equals(agv_system_type,"2")){ - TwoNDCSocketConnectionAutoRun.write(b); - } else if (StrUtil.equals(agv_system_type,"3")){ - TwoNDC2SocketConnectionAutoRun.write(b); - } - System.out.println("下发agv指令数据:" + Bytes2HexString(b)); - } else { - - String instcode = inst.getInstruction_code(); - int type = Integer.parseInt(inst.getInstruction_type()); - int priority = Integer.parseInt(inst.getPriority()) + 128; - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); - int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); - - byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); - byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); - byte typehigh = (byte) IntToHexHigh(type); - byte typelow = (byte) IntToHexLow(type); - byte qhdhigh = (byte) IntToHexHigh(startAddress); - byte qhdlow = (byte) IntToHexLow(startAddress); - byte fhdhigh = (byte) IntToHexHigh(nextAddress); - byte fhdlow = (byte) IntToHexLow(nextAddress); - byte prioritylow = (byte) IntToHexLow(priority); - - String str = "十进制下发:"; - String str1 = "十六进制下发:"; - str += "ikey:" + (Integer.parseInt(instcode)); - str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); - - str += "/type:" + (type); - str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); - - str += "/qhd:" + (startAddress); - str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); - str += "/fhd:" + (nextAddress); - str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); - - str += "/priority:" + (priority); - str1 += "/priority:" + hexToString(prioritylow & 0xFF); - - System.out.println(str); - System.out.println(str1); - - byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X12, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X0E, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) fhdhigh, (byte) fhdlow - }; - log.info("下发AGV作业指令--{}", str1); - OneNDCSocketConnectionAutoRun.write(b); - System.out.println("下发agv指令数据:" + Bytes2HexString(b)); - } + String instcode = inst.getInstruction_code(); + int type = Integer.parseInt(inst.getInstruction_type()); + int priority = Integer.parseInt(inst.getPriority()) + 128; + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); + int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); + + byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); + byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); + byte typehigh = (byte) IntToHexHigh(type); + byte typelow = (byte) IntToHexLow(type); + byte qhdhigh = (byte) IntToHexHigh(startAddress); + byte qhdlow = (byte) IntToHexLow(startAddress); + byte fhdhigh = (byte) IntToHexHigh(nextAddress); + byte fhdlow = (byte) IntToHexLow(nextAddress); + byte prioritylow = (byte) IntToHexLow(priority); + + String str = "十进制下发:"; + String str1 = "十六进制下发:"; + str += "ikey:" + (Integer.parseInt(instcode)); + str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); + + str += "/type:" + (type); + str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); + + str += "/qhd:" + (startAddress); + str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); + str += "/fhd:" + (nextAddress); + str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); + + str += "/priority:" + (priority); + str1 += "/priority:" + hexToString(prioritylow & 0xFF); + + System.out.println(str); + System.out.println(str1); + + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X12, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X0E, + (byte) 0X01, prioritylow, + (byte) 0X00, (byte) 0X01, + (byte) ikeyhigh, (byte) ikeylow, + (byte) ikeyhigh, (byte) ikeylow, + (byte) typehigh, (byte) typelow, + (byte) qhdhigh, (byte) qhdlow, + (byte) fhdhigh, (byte) fhdlow + }; + log.info("下发AGV作业指令--{}", str1); + log.info("下发AGV作业指令--{}", Bytes2HexString(b)); + OneNDCSocketConnectionAutoRun.write(b); + System.out.println("下发agv指令数据:" + Bytes2HexString(b)); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDC2SocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDC2SocketConnectionAutoRun.java deleted file mode 100644 index c79eaa7..0000000 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDC2SocketConnectionAutoRun.java +++ /dev/null @@ -1,243 +0,0 @@ -package org.nl.acs.auto.run; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.modules.system.service.ParamService; -import org.nl.modules.system.service.impl.ParamServiceImpl; -import org.nl.modules.wql.util.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.net.Socket; -import java.util.Date; - -import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; - - -@Slf4j -@Component -public class TwoNDC2SocketConnectionAutoRun extends AbstractAutoRunnable { - - Socket s; - String ip = "192.168.46.225"; - int port = 1234; - static DataOutputStream dos; - static DataInputStream dis; - private int recordTimeOut = 10000; - private Date recordTime; - String[] ERROR = new String[]{ - "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", - "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", - "抬叉停止"}; - boolean bConnected = true; - - boolean isReConnect = false; - - @Autowired - ParamService paramService; - @Autowired - AutoRunService autoRunService; - - - public TwoNDC2SocketConnectionAutoRun() { - this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); - } - - public String getCode() { - return TwoNDC2SocketConnectionAutoRun.class.getSimpleName(); - } - - public String getName() { - return "2楼2区域AGV系统"; - } - - public void autoRun() { - - try { - System.out.println("2楼2区域AGV系统链接开始"); - ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - ip = paramService.findByCode(AcsConfig.AGVURL22).getValue(); - port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT22).getValue()); - byte[] b = new byte[1028]; - s = new Socket(ip, port); - System.out.println("2楼2区域AGV链接成功"); - dos = new DataOutputStream(s.getOutputStream()); - dis = new DataInputStream(s.getInputStream()); - - while (bConnected) { - int count = dis.read(b); - - if (count == -1) { - break; - } - - int[] arr = new int[count]; - StringBuffer bs = new StringBuffer(); - - for (int i = 0; i < count; i++) { - int temp = b[i]; - if (temp < 0) - temp += 256; - arr[i] = temp; - StringBuffer bs1 = new StringBuffer("0"); - bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); - } - - System.out.println("收到请求参数:" + bs); - boolean flag = false; - if (arr[8] * 256 + arr[9] == 0x73) { - byte[] data = null; - System.out.println("接收agv上报信息:" + bs); - //执行阶段 - int phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - //任务号 - int ikey = arr[26] * 256 + arr[27]; - //站点号 - int agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - Instruction inst = null; - if (ikey != 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - } - log.info("接收agv上报信息:" + bs); - log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - Device device = null; - String device_code = null; - String old_device_code = null; - String emptyNum = null; - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - device = deviceAppService.findDeviceByCode(device_code); - } - - AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; - //开始任务 - if (phase == 0x01) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("1"); - inst.setAgv_jobno(String.valueOf(index)); - inst.setSend_status("1"); - instructionService.update(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } - flag = true; - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x14) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - inst.setInstruction_status("2"); - instructionService.finish(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } - //请求删除任务 - //(需要WCS反馈) - else if (phase == 0x30) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0); - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - //上报异常信息 - //(不需要WCS反馈) - if(phase == 0x67){ - device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); - } else { - device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); - } - if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); - agvNdcTwoDeviceDriver.processSocket(arr); - } - } - if (!ObjectUtil.isEmpty(data)) { - write(data); - } - - } else { - System.out.println("agv上报不是0073类型动作,不处理"); - } - } - - } catch (Exception e) { - - - } finally { - - - } - - } - - - @Override - public void stop() { - super.after(); - try { - s.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - public static void write(byte[] b) { - try { - log.info("下发agv数据:" + Bytes2HexString(b)); - System.out.println("下发agv数据:" + Bytes2HexString(b)); - dos.write(b); - dos.flush(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } -} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java deleted file mode 100644 index 9224c15..0000000 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java +++ /dev/null @@ -1,245 +0,0 @@ -package org.nl.acs.auto.run; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; -import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.modules.system.service.ParamService; -import org.nl.modules.system.service.impl.ParamServiceImpl; -import org.nl.modules.wql.util.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.net.Socket; -import java.util.Date; -import java.util.List; - -import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; - - -@Slf4j -@Component -public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { - - Socket s; - String ip = "192.168.46.225"; - int port = 1234; - static DataOutputStream dos; - static DataInputStream dis; - private int recordTimeOut = 10000; - private Date recordTime; - String[] ERROR = new String[]{ - "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", - "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", - "抬叉停止"}; - boolean bConnected = true; - - boolean isReConnect = false; - - @Autowired - ParamService paramService; - @Autowired - AutoRunService autoRunService; - - - public TwoNDCSocketConnectionAutoRun() { - this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); - } - - public String getCode() { - return TwoNDCSocketConnectionAutoRun.class.getSimpleName(); - } - - public String getName() { - return "2楼1区域AGV系统"; - } - - public void autoRun() { - - try { - System.out.println("2楼1区域AGV系统链接开始"); - ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - ip = paramService.findByCode(AcsConfig.AGVURL2).getValue(); - port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue()); - byte[] b = new byte[1028]; - s = new Socket(ip, port); - System.out.println("2楼1区域Agv链接成功"); - dos = new DataOutputStream(s.getOutputStream()); - dis = new DataInputStream(s.getInputStream()); - - while (bConnected) { - int count = dis.read(b); - - if (count == -1) { - break; - } - - int[] arr = new int[count]; - StringBuffer bs = new StringBuffer(); - - for (int i = 0; i < count; i++) { - int temp = b[i]; - if (temp < 0) - temp += 256; - arr[i] = temp; - StringBuffer bs1 = new StringBuffer("0"); - bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); - } - - System.out.println("收到请求参数:" + bs); - boolean flag = false; - if (arr[8] * 256 + arr[9] == 0x73) { - byte[] data = null; - System.out.println("接收agv上报信息:" + bs); - //执行阶段 - int phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - //任务号 - int ikey = arr[26] * 256 + arr[27]; - //站点号 - int agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - Instruction inst = null; - if (ikey != 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - } - log.info("接收agv上报信息:" + bs); - log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - Device device = null; - String device_code = null; - String old_device_code = null; - String emptyNum = null; - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - device = deviceAppService.findDeviceByCode(device_code); - } - - AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; - //开始任务 - if (phase == 0x01) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("1"); - inst.setAgv_jobno(String.valueOf(index)); - inst.setSend_status("1"); - instructionService.update(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } - flag = true; - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x14) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - inst.setInstruction_status("2"); - instructionService.finish(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } - //请求删除任务 - //(需要WCS反馈) - else if (phase == 0x30) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0); - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - //上报异常信息 - //(不需要WCS反馈) - if(phase == 0x67){ - device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); - } else { - device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); - } - if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); - agvNdcTwoDeviceDriver.processSocket(arr); - } - } - if (!ObjectUtil.isEmpty(data)) { - write(data); - } - - } else { - System.out.println("agv上报不是0073类型动作,不处理"); - } - } - - } catch (Exception e) { - - - } finally { - - - } - - } - - - @Override - public void stop() { - super.after(); - try { - s.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - public static void write(byte[] b) { - try { - log.info("下发agv数据:" + Bytes2HexString(b)); - System.out.println("下发agv数据:" + Bytes2HexString(b)); - dos.write(b); - dos.flush(); - } catch (IOException e) { - // TODO Auto-generated catch block - 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 fb84fcf..ed8d522 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 @@ -142,7 +142,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic request.put("METHOD", "1"); request.put("AGVCODE", this.device_code); request.put("REQTIME", DateUtil.now()); - new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 请求参数:"+request.toJSONString()); + String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 返回参数:"+str); } } //到达取货点 @@ -216,7 +218,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic request.put("METHOD", "2"); request.put("AGVCODE", this.device_code); request.put("REQTIME", DateUtil.now()); - new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 请求参数:"+request.toJSONString()); + String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 返回参数:"+str); } } @@ -303,7 +307,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic request.put("METHOD", "3"); request.put("AGVCODE", this.device_code); request.put("REQTIME", DateUtil.now()); - new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 请求参数:"+request.toJSONString()); + String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 返回参数:"+str); } } @@ -365,7 +371,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic request.put("METHOD", "4"); request.put("AGVCODE", this.device_code); request.put("REQTIME", DateUtil.now()); - new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 请求参数:"+request.toJSONString()); + String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + log.info("atrAgvCallback 返回参数:"+str); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java index 1965d29..39250a5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java @@ -6,8 +6,6 @@ import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.auto.run.TwoNDC2SocketConnectionAutoRun; -import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; @@ -469,9 +467,9 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic if (!ObjectUtil.isEmpty(data)) { logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); if (StrUtil.equals(inst.getAgv_system_type(), "2")) { - TwoNDCSocketConnectionAutoRun.write(data); +// TwoNDCSocketConnectionAutoRun.write(data); } else if (StrUtil.equals(inst.getAgv_system_type(), "3")) { - TwoNDC2SocketConnectionAutoRun.write(data); +// TwoNDC2SocketConnectionAutoRun.write(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 6cd6b4f..9276172 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 @@ -297,15 +297,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu if (StrUtil.isEmpty(dto.getLink_num())) { dto.setIs_send(task.getLink_num()); } - if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) { - dto.setInstruction_type(task.getTask_type()); - } else if (false) { + dto.setInstruction_type("1"); - } else { - dto.setInstruction_type("3"); - } - - // 查询是否存在相同指令号 + // 查询是否存在相同指令号 // if (!StrUtil.isEmpty(dto.getVehicle_code() )) { // Instruction inst_dto = findByContainer(dto.getVehicle_code()); // if (inst_dto != null) { @@ -328,11 +322,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto.setCreate_time(now); dto.setStart_parent_code(task.getStart_parent_code()); dto.setNext_parent_code(task.getNext_parent_code()); - - if (ObjectUtil.isNotEmpty(task.getTask_type())) { - dto.setInstruction_type(task.getTask_type()); - } - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); @@ -369,22 +358,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu wo.insert(json); instructions.add(dto); - if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) { - // 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统 - if (!StrUtil.equals(task.getAgv_system_type(), "0") - && ObjectUtil.isNotEmpty(task.getAgv_system_type())) { - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); - } else { - // Boolean result = createLkInst(task.getStorage_task_type(),dto); - Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(), dto); - if (StrUtil.equals(resp.result, "true")) { - dto.setSend_status("1"); - } else { - dto.setSend_status("2"); - } - } - } + NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); + ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); } catch (Exception e) { dto.setSend_status("2"); wo.update((JSONObject) JSONObject.toJSON(dto)); @@ -481,14 +456,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu throw new BadRequestException("未查询到相关路由!"); } if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) { - // 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统 - if (!StrUtil.equals(task.getAgv_system_type(), "0") - && ObjectUtil.isNotEmpty(task.getAgv_system_type())) { - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); - } else { - // Boolean result = createLkInst(task.getStorage_task_type(),dto); - } + NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); + ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); } } catch (Exception e) { dto.setSend_status("2"); 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 a8666af..11975ce 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 @@ -699,93 +699,24 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { tasks.add(dto); } // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS - String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); - if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); - JSONObject feed_jo = new JSONObject(); - feed_jo.put("task_id", entity.getExt_task_id()); - feed_jo.put("task_code", dto.getTask_code()); - feed_jo.put("task_status", dto.getTask_status()); - JSONArray ja = new JSONArray(); - ja.add(feed_jo); - String message = null; - HttpResponse body = null; - boolean flag = false; - try { - body = acstowmsService.feedbackTaskStatusToWms(ja); - } catch (Exception e) { - flag = true; - message = e.getMessage(); - e.printStackTrace(); - } finally { - - } - if (flag) { - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(message); - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setRemark(message); - taskFeedbackService.update(feefbackdto); - } - } else { - int status = body.getStatus(); - JSONObject jo = JSONObject.parseObject(body.body()); - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setError_code(String.valueOf(body.getStatus())); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getNext_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - if (status == 200) { - } else { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } - taskFeedbackService.update(feefbackdto); - } - } - } +// String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); +// if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { +// try { +// JSONObject request = new JSONObject(); +// request.put("REQCODE", entity.getExt_task_id()); +// request.put("TASKCODE", entity.getTask_code()); +// request.put("PODCODE", entity.getVehicle_code()); +// request.put("TASKTYPE", entity.getTask_type()); +// request.put("METHOD", "5"); +// 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()); +// } +// } } @@ -833,7 +764,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { request.put("TASKTYPE", entity.getTask_type()); request.put("METHOD", "5"); request.put("REQTIME", DateUtil.now()); - new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); + 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()); @@ -1111,29 +1044,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { instdto.setNext_device_code2(next_point_code2); instdto.setNext_point_code2(next_point_code2); instdto.setAgv_system_type(agv_system_type); - // 判断agv系统 - // 1、1楼叉车系统 - // 2、2楼1区域AGV系统 - // 3、2楼2区域AGV系统 - if (!StrUtil.equals(agv_system_type, "1")) { - // task_type - // 1、生箔; Itype=1:取空,取满,放空,放满; - // 2、分切 Itype=3取满、取空、放满、放空; - // 3、普通任务 Itype=2:取货、放货; - // 4、叉车任务 - // 5、输送任务 - // 6、行架 - // 7、立库 - if (StrUtil.equals(task_type, "1")) { - instdto.setAgv_inst_type("1"); - } else if (StrUtil.equals(task_type, "3")) { - instdto.setAgv_inst_type("2"); - } else if (StrUtil.equals(task_type, "2")) { - instdto.setAgv_inst_type("3"); - } - } else { - instdto.setAgv_inst_type("4"); - } + + instdto.setAgv_inst_type("1"); + instdto.setAgv_system_type("1"); instructionservice.create2(instdto); // acsTask.setTask_status("1"); diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index 15e3caf..4c627ca 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -139,29 +139,9 @@ public class AutoCreateInst { instdto.setExecute_device_code(start_point_code); instdto.setVehicle_type(vehicleType); instdto.setAgv_system_type(agv_system_type); - //判断agv系统 - //1、1楼叉车系统 - //2、2楼1区域AGV系统 - //3、2楼2区域AGV系统 - if (!StrUtil.equals(agv_system_type, "1")) { - // task_type - //1、生箔; Itype=1:取空,取满,放空,放满; - //2、分切 Itype=3取满、取空、放满、放空; - //3、普通任务 Itype=2:取货、放货; - //4、叉车任务 - //5、输送任务 - //6、行架 - //7、立库 - if (StrUtil.equals(task_type, "1")) { - instdto.setAgv_inst_type("1"); - } else if (StrUtil.equals(task_type, "3")) { - instdto.setAgv_inst_type("2"); - } else if (StrUtil.equals(task_type, "2")) { - instdto.setAgv_inst_type("3"); - } - } else { - instdto.setAgv_inst_type("4"); - } + + instdto.setAgv_inst_type("1"); + instdto.setAgv_inst_type("1"); try { instructionService.create(instdto); diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java index 76f136c..540726c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java @@ -1,17 +1,28 @@ package org.nl.modules.quartz.task; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +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.agv.server.AgvService; import org.nl.acs.agv.server.dto.AgvDto; +import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.service.InstructionService; +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.nl.modules.mnt.websocket.MsgType; import org.nl.modules.mnt.websocket.SocketMsg; import org.nl.modules.mnt.websocket.WebSocketServer; +import org.nl.modules.wql.util.SpringContextHolder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; import java.util.Map; /** @@ -28,49 +39,39 @@ public class ToAgvDevice { public void run() throws Exception { JSONObject json = new JSONObject(); - Map agv_map = agvService.findAllAgvFromCache(); - JSONArray agv_rows = new JSONArray(); - JSONObject row = new JSONObject(); + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + List deviceList = deviceAppService.findDevice(DeviceType.agv); + for (int i=0; i