diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index b7f9389..aad2232 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -27,11 +27,10 @@ public interface NDCAgvService { /** * 下发任务 - * @param agv_system_type * @param inst * @throws Exception */ - public void sendAgvInstToNDC(String agv_system_type, Instruction inst) throws Exception; + public void sendAgvInstToNDC(Instruction inst) throws Exception; /** * 一号agv指令 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index f2e209c..ef08b75 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -7,7 +7,6 @@ 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.TwoNDCSocketConnectionAutoRun; import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.service.DeviceService; @@ -38,7 +37,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { private final DeviceAppService deviceAppService; private final ISysParamService paramService; -// private final AcsToWmsService acsToWmsService; + // private final AcsToWmsService acsToWmsService; private final ISysDictService dictService; private final DeviceExecuteLogService logServer; @@ -79,194 +78,72 @@ public class NDCAgvServiceImpl implements NDCAgvService { @Override - public void sendAgvInstToNDC(String agv_system_type, Instruction inst) { - log.info("sendAgvInstToNDC 指令下发NDC:" + "inst_code:" + inst.getInstruction_code() + ",agv_system_type:" + agv_system_type + ",agv_inst_type:" + inst.getAgv_inst_type() + - ",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() + - ",nextAddress:" + inst.getNext_point_code()); + public void sendAgvInstToNDC(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); + String instcode = inst.getInstruction_code(); + int type = Integer.parseInt(inst.getInstruction_type()); + int priority = Integer.parseInt(inst.getPriority()) + 128; + 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 += "指令类型 /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 += "取货点 /qhd:" + (startAddress); + str1 += "取货点 /qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); + str += "放货点 /fhd:" + (nextAddress); + str1 += "放货点 /fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); - str += "取货点2 /qhd2:" + (startAddress2); - str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF); - str += "放货点2 /fhd2:" + (nextAddress2); - str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF); + str += "取货点2 /qhd2:" + (startAddress2); + str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF); + str += "放货点2 /fhd2:" + (nextAddress2); + str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF); - str += "优先级 /priority:" + (priority); - str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF); + str += "优先级 /priority:" + (priority); + str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF); - 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); - log.info("下发AGV作业指令--{}", str); - log.info("下发agv指令数据--{}", Bytes2HexString(b)); - - if (StrUtil.equals(agv_system_type, "2")) { - TwoNDCSocketConnectionAutoRun.write(b); - } - } else { - - String instcode = inst.getInstruction_code(); - int startHeight = Integer.parseInt(StrUtil.isEmpty(inst.getStart_height()) ? "0" : inst.getStart_height()); - int nextHeight = Integer.parseInt(StrUtil.isEmpty(inst.getNext_height()) ? "0" : inst.getNext_height()); - //默认取货放货高度都为0 - //int type = Integer.parseInt(inst.getInstruction_type()); - int type = 4; - if (startHeight != 0 && nextHeight != 0) { - //取货放货高度都不为0 - type = 1; - } else if (startHeight != 0 && nextHeight == 0) { - //取货高度不为0 放货高度为0 - type = 2; - } else if (startHeight == 0 && nextHeight != 0) { - //取货高度为0 放货高度不为0 - type = 3; - } - 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); - - byte shhigh = (byte) IntToHexHigh(startHeight); - byte shlow = (byte) IntToHexLow(startHeight); - - byte nhhigh = (byte) IntToHexHigh(nextHeight); - byte nhlow = (byte) IntToHexLow(nextHeight); - - 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) 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) fhdhigh, (byte) fhdlow, - (byte) shhigh, (byte) shlow, - (byte) nhhigh, (byte) nhlow - }; - log.info("下发AGV作业指令 --{}", str1); - log.info("下发AGV作业指令--{}", str); - log.info("下发agv指令数据--{}", Bytes2HexString(b)); - OneNDCSocketConnectionAutoRun.write(b); - } + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X18, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X14, + (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, + (byte) qhdhigh2, (byte) qhdlow2, + (byte) fhdhigh2, (byte) fhdlow2, + (byte) 0X00, (byte) 0X00 + }; + TwoNDCSocketConnectionAutoRun.write(b); + log.info("下发AGV作业指令 --{}", str1); + log.info("下发AGV作业指令--{}", str); + log.info("下发agv指令数据--{}", Bytes2HexString(b)); } } @@ -449,18 +326,18 @@ public class NDCAgvServiceImpl implements NDCAgvService { public void charge(String carno) { //检查数据字典station为0的参数 //分配车辆 - Dict dict = dictService.getDictByName3("station",carno,null); - int satation=0; - if(ObjectUtil.isNotEmpty(dict)){ - log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1()); + Dict dict = dictService.getDictByName3("station", carno, null); + int satation = 0; + if (ObjectUtil.isNotEmpty(dict)) { + log.info("当前车辆{}已分配充电桩{},退出后续判断", carno, dict.getPara1()); return; } Dict temp = dictService.getDictByName2("station"); - if(ObjectUtil.isNotEmpty(temp)){ + if (ObjectUtil.isNotEmpty(temp)) { satation = Integer.parseInt(temp.getPara1()); } - if(satation!=0){ - String instcode =CodeUtil.getNewCode("INSTRUCT_NO"); + if (satation != 0) { + String instcode = CodeUtil.getNewCode("INSTRUCT_NO"); byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno)); @@ -491,10 +368,10 @@ public class NDCAgvServiceImpl implements NDCAgvService { }; log.info("下发AGV充电任务--{}", str1); - try{ - OneNDCSocketConnectionAutoRun.write(b); - } catch (Exception e){ - log.error("下发充电任务失败{}{}",e,e.getMessage()); + try { +// OneNDCSocketConnectionAutoRun.write(b); + } catch (Exception e) { + log.error("下发充电任务失败{}{}", e, e.getMessage()); } temp.setValue("1"); @@ -502,8 +379,8 @@ public class NDCAgvServiceImpl implements NDCAgvService { temp.setPara3("下发充电"); dictService.updateDetail(temp); - }else{ - log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务",carno); + } else { + log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务", carno); } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index 19f5de0..803621a 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -1,274 +1,274 @@ -package org.nl.acs.auto.run; - -import cn.hutool.core.util.ObjectUtil; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.enums.InstructionStatusEnum; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.opc.DeviceAppService; -import org.nl.config.lucene.service.LuceneExecuteLogService; -import org.nl.system.service.param.ISysParamService; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.impl.SysParamServiceImpl; -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; -/** - * Demo class - * - * @author zhoujj - * @date 2023/12/06 - */ -@Slf4j -@Component -public class OneNDCSocketConnectionAutoRun 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 - ISysParamService paramService; - @Autowired - AutoRunService autoRunService; - @Autowired - LuceneExecuteLogService luceneExecuteLogService; - - - public OneNDCSocketConnectionAutoRun() { - this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); - } - @Override - public String getCode() { - return OneNDCSocketConnectionAutoRun.class.getSimpleName(); - } - @Override - public String getName() { - return "NDC在线连接"; - } - - @Override - public void autoRun() throws IOException { - System.out.println("NDCAgv链接开始"); - ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.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); - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - ip = paramService.findByCode(AcsConfig.AGVURL2).getValue(); - port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue()); - - - try { - byte[] b = new byte[1024]; - s = new Socket(ip, port); - dos = new DataOutputStream(s.getOutputStream()); - dis = new DataInputStream(s.getInputStream()); - System.out.println("NDCAgv链接成功"); - log.info("NDCAgv链接成功"); - 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)); - } - - 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 link_inst = null; - Instruction inst = null; - List insts = null; - boolean link_flag = false; - Device agv_device = null; - if (carno != 0) { - agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); - } - if (ikey != 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - if (ObjectUtil.isEmpty(inst)) { - inst = instructionService.findByCode(String.valueOf(ikey)); - } - } - if (!ObjectUtil.isEmpty(link_inst)) { - link_flag = true; - } - log.info("接收agv上报信息:" + bs); - log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - Device device = null; - String device_code = null; - - - // - AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; - - //开始任务/上报订单号 - if (phase == 0x01) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst.setAgv_jobno(String.valueOf(index)); - inst.setSend_status(CommonFinalParam.ONE); - instructionService.update(inst); - } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x0A) { - if (!ObjectUtil.isEmpty(inst)) { - instructionService.finish(inst.getInstruction_id()); - } else { - log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!"); - } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); - log.info("指令号:{},已反馈agv任务完成!"); - } - //请求删除任务 - //(需要WCS反馈) - else if (phase == 0x30) { - data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0); - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { - - if (!ObjectUtil.isEmpty(inst)) { - if (!ObjectUtil.isEmpty(inst)) { - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - } - } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); - - } else { - //上报异常信息 - //(不需要WCS反馈) - if (phase == 0x67) { - device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); - } else { - device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); - } - if (ObjectUtil.isNotEmpty(device)) { - if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { - agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); - agvNdcOneDeviceDriver.processSocket(arr); - } - } - - } - if (!ObjectUtil.isEmpty(data)) { - write(data); - } - - } else { - System.out.println("agv上报不是0073类型动作,不处理"); - } - } - - } catch (Exception e) { - System.out.println("Agv链接异常"); - log.info("Agv链接异常"); - log.error("agv连接出现异常:{}", e); - if (ObjectUtil.isNotEmpty(s)) { - s.close(); - } - System.out.println(e.getMessage()); - e.printStackTrace(); - - } 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 - try { - Thread.sleep(5000L); - log.info("再次下发agv数据:" + Bytes2HexString(b)); - System.out.println("再次下发agv数据:" + Bytes2HexString(b)); - dos.write(b); - dos.flush(); - } catch (Exception e1) { - e1.printStackTrace(); - } - - } - } -} - +//package org.nl.acs.auto.run; +// +//import cn.hutool.core.util.ObjectUtil; +//import lombok.extern.slf4j.Slf4j; +//import org.nl.acs.AcsConfig; +//import org.nl.acs.agv.server.NDCAgvService; +//import org.nl.acs.common.base.CommonFinalParam; +//import org.nl.acs.device.domain.Device; +//import org.nl.acs.device.service.DeviceService; +//import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver; +//import org.nl.acs.ext.wms.service.AcsToWmsService; +//import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +//import org.nl.acs.instruction.domain.Instruction; +//import org.nl.acs.instruction.enums.InstructionStatusEnum; +//import org.nl.acs.instruction.service.InstructionService; +//import org.nl.acs.instruction.service.impl.InstructionServiceImpl; +//import org.nl.acs.log.service.DeviceExecuteLogService; +//import org.nl.acs.opc.DeviceAppService; +//import org.nl.config.lucene.service.LuceneExecuteLogService; +//import org.nl.system.service.param.ISysParamService; +//import org.nl.config.SpringContextHolder; +//import org.nl.system.service.param.impl.SysParamServiceImpl; +//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; +///** +// * Demo class +// * +// * @author zhoujj +// * @date 2023/12/06 +// */ +//@Slf4j +//@Component +//public class OneNDCSocketConnectionAutoRun 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 +// ISysParamService paramService; +// @Autowired +// AutoRunService autoRunService; +// @Autowired +// LuceneExecuteLogService luceneExecuteLogService; +// +// +// public OneNDCSocketConnectionAutoRun() { +// this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); +// } +// @Override +// public String getCode() { +// return OneNDCSocketConnectionAutoRun.class.getSimpleName(); +// } +// @Override +// public String getName() { +// return "NDC在线连接"; +// } +// +// @Override +// public void autoRun() throws IOException { +// System.out.println("NDCAgv链接开始"); +// ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.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); +// DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); +// ip = paramService.findByCode(AcsConfig.AGVURL2).getValue(); +// port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue()); +// +// +// try { +// byte[] b = new byte[1024]; +// s = new Socket(ip, port); +// dos = new DataOutputStream(s.getOutputStream()); +// dis = new DataInputStream(s.getInputStream()); +// System.out.println("NDCAgv链接成功"); +// log.info("NDCAgv链接成功"); +// 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)); +// } +// +// 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 link_inst = null; +// Instruction inst = null; +// List insts = null; +// boolean link_flag = false; +// Device agv_device = null; +// if (carno != 0) { +// agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); +// } +// if (ikey != 0) { +// inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); +// if (ObjectUtil.isEmpty(inst)) { +// inst = instructionService.findByCode(String.valueOf(ikey)); +// } +// } +// if (!ObjectUtil.isEmpty(link_inst)) { +// link_flag = true; +// } +// log.info("接收agv上报信息:" + bs); +// log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); +// Device device = null; +// String device_code = null; +// +// +// // +// AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; +// +// //开始任务/上报订单号 +// if (phase == 0x01) { +// if (!ObjectUtil.isEmpty(inst)) { +// inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); +// inst.setAgv_jobno(String.valueOf(index)); +// inst.setSend_status(CommonFinalParam.ONE); +// instructionService.update(inst); +// } +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); +// } +// //任务完毕 +// //(无车id及状态) +// else if (phase == 0x0A) { +// if (!ObjectUtil.isEmpty(inst)) { +// instructionService.finish(inst.getInstruction_id()); +// } else { +// log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!"); +// } +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); +// log.info("指令号:{},已反馈agv任务完成!"); +// } +// //请求删除任务 +// //(需要WCS反馈) +// else if (phase == 0x30) { +// data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0); +// } +// //任务删除确认 +// //(需要WCS反馈) +// else if (phase == 0xFF) { +// +// if (!ObjectUtil.isEmpty(inst)) { +// if (!ObjectUtil.isEmpty(inst)) { +// instructionService.cancelNOSendAgv(inst.getInstruction_id()); +// } +// } +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); +// +// } else { +// //上报异常信息 +// //(不需要WCS反馈) +// if (phase == 0x67) { +// device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); +// } else { +// device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); +// } +// if (ObjectUtil.isNotEmpty(device)) { +// if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { +// agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); +// agvNdcOneDeviceDriver.processSocket(arr); +// } +// } +// +// } +// if (!ObjectUtil.isEmpty(data)) { +// write(data); +// } +// +// } else { +// System.out.println("agv上报不是0073类型动作,不处理"); +// } +// } +// +// } catch (Exception e) { +// System.out.println("Agv链接异常"); +// log.info("Agv链接异常"); +// log.error("agv连接出现异常:{}", e); +// if (ObjectUtil.isNotEmpty(s)) { +// s.close(); +// } +// System.out.println(e.getMessage()); +// e.printStackTrace(); +// +// } 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 +// try { +// Thread.sleep(5000L); +// log.info("再次下发agv数据:" + Bytes2HexString(b)); +// System.out.println("再次下发agv数据:" + Bytes2HexString(b)); +// dos.write(b); +// dos.flush(); +// } catch (Exception e1) { +// e1.printStackTrace(); +// } +// +// } +// } +//} +// diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java index fe8c323..619a786 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java @@ -83,7 +83,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { @Override public String getName() { - return "2楼1区域AGV系统"; + return "NDC_AGV系统"; } @Override @@ -97,7 +97,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); try { - log.info("2楼1区域AGV系统链接开始"); + log.info("NDC_AGV系统链接开始"); ip = paramService.findByCode(AcsConfig.AGVURL).getValue(); port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).getValue()); // byte[] b = new byte[1024]; @@ -112,14 +112,14 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { socket = new Socket(); socket.connect(socketAddress, 5 * 1000); socket.setKeepAlive(true);//长链接 - socket.setSoTimeout(30000);//读取超时时间 + socket.setSoTimeout(300000);//读取超时时间 dos = new DataOutputStream(socket.getOutputStream()); dis = new DataInputStream(socket.getInputStream()); while (socket.isConnected()) { - System.out.println("当前socket状态:"+socket.isConnected()); + System.out.println("当前socket状态:" + socket.isConnected()); + int count = dis.read(b); -// System.out.println("当前count值:"+count); if (count == -1) { log.error("agv连接出现异常:服务端被关闭"); if (ObjectUtil.isNotEmpty(socket)) { @@ -205,11 +205,10 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { instructionService.update(inst); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } - flag = true; } //任务完毕 //(无车id及状态) - else if (phase == 0x14) { + else if (phase == 0x12) { if (ObjectUtil.isEmpty(inst)) { log.info("未找到指令号{}对应的指令", ikey); } else { @@ -248,6 +247,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { instructionService.cancelNOSendAgv(inst.getInstruction_id()); } data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } else if (phase == 0x4D) { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); } else if (phase == 0x50) { if (ObjectUtil.isEmpty(device_code)) { log.info(agvaddr + "对应设备号为空!"); @@ -299,30 +300,29 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } else { log.info(device_code + "对应设备号为空!"); } - } else if (phase == 0x64){ - log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}",agvaddr,station); - Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null); - if (ObjectUtil.isNotEmpty(dict)){ + } else if (phase == 0x64) { + log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}", agvaddr, station); + Dict dict = dictService.getDictByName3("station", String.valueOf(agvaddr), null); + if (ObjectUtil.isNotEmpty(dict)) { dict.setValue("1"); dict.setPara2(String.valueOf(agvaddr)); dict.setPara3("下发成功"); dictService.updateDetail(dict); } //充电成功 - }else if (phase == 0x65){ - log.info("AGV车号{}反馈充电中,充电桩{}",agvaddr,station); + } else if (phase == 0x65) { + log.info("AGV车号{}反馈充电中,充电桩{}", agvaddr, station); //充电取消上报 - }else if (phase == 0x66){ - log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}",agvaddr,station); - Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null); - if (ObjectUtil.isNotEmpty(dict)){ + } else if (phase == 0x66) { + log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}", agvaddr, station); + Dict dict = dictService.getDictByName3("station", String.valueOf(agvaddr), null); + if (ObjectUtil.isNotEmpty(dict)) { dict.setValue("0"); dict.setPara2(""); dict.setPara3("充电桩空闲"); dictService.updateDetail(dict); } - } - else { + } else { //上报异常信息 //(不需要WCS反馈) if (phase == 0x67 || phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardInspectSiteDevice.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardInspectSiteDevice.java index b419359..76f6aaf 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardInspectSiteDevice.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardInspectSiteDevice.java @@ -15,9 +15,6 @@ public class StandardInspectSiteDevice extends AbstractDriverService { public JSONObject getDeviceInfo(Device device) { StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); JSONObject jo = super.getCommonDeviceInfo(standardInspectSiteDevicedriver, 0, 0); - jo.put("error", standardInspectSiteDevicedriver.getError()); - jo.put("isError", standardInspectSiteDevicedriver.getIserror()); - jo.put("container", standardInspectSiteDevicedriver.getContainer()); jo.put("message", standardInspectSiteDevicedriver.getMessage()); return jo; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index e53ac32..b2f74bb 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -999,8 +999,6 @@ public class DeviceServiceImpl extends CommonServiceImpl i } } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - standardInspectSiteDeviceDriver.setMaterial(material_type); - standardInspectSiteDeviceDriver.setBatch(batch); device.setMaterial_type(material_type); device.setBatch(batch); }else if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java index da26b4b..132a325 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -8,7 +8,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.agv.server.AgvService; import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; import org.nl.acs.device.service.DeviceService; @@ -449,7 +448,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (!ObjectUtil.isEmpty(data)) { phase = 0; logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); - OneNDCSocketConnectionAutoRun.write(data); +// OneNDCSocketConnectionAutoRun.write(data); } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java index 494b51b..d2269ef 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java @@ -36,17 +36,13 @@ import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.impl.TaskServiceImpl; import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.nl.config.thread.ThreadPoolExecutorUtil; import org.nl.system.service.dict.ISysDictService; import org.nl.system.service.dict.dao.Dict; import org.nl.system.service.param.ISysParamService; import org.nl.config.SpringContextHolder; import java.time.LocalTime; -import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; -import java.util.concurrent.ThreadPoolExecutor; /** @@ -161,7 +157,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic device_code = old_device_code; } } - device = deviceAppService.findDeviceByCode(device_code); //普通站点 StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; @@ -223,6 +218,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic instructionService.update(inst); } + //TODO 检测站点 if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); @@ -233,6 +229,24 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto); standardOrdinarySiteDeviceDriver.setOption(0); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 0) { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + ", 不允许取货") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } } else { data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); LuceneLogDto logDto = LuceneLogDto.builder() @@ -243,7 +257,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic luceneExecuteLogService.deviceExecuteLog(logDto); } } - // 取货完毕 //(Itype=1/2/3,需要WCS反馈Phase) else if (phase == 0x05) { @@ -293,7 +306,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic inst.setCarno(String.valueOf(carno)); instructionService.update(inst); } - + //TODO 检测站点 if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); @@ -306,6 +319,24 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic standardOrdinarySiteDeviceDriver.setAgvphase(phase); standardOrdinarySiteDeviceDriver.setIndex(index); standardOrdinarySiteDeviceDriver.setInst(inst); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + "工作模式为" + standardInspectSiteDeviceDriver.getMode() + ", 取货完成不允许离开") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } } else { data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); LuceneLogDto logDto = LuceneLogDto.builder() @@ -316,7 +347,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic luceneExecuteLogService.deviceExecuteLog(logDto); } } - // 到达放货点 //(Itype=1/2/3,需要WCS反馈) else if (phase == 0x07) { @@ -356,6 +386,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic log.info("未找到指令号{}对应的指令", ikey); return; } + //TODO 检测站点 if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); @@ -367,6 +398,24 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic luceneExecuteLogService.deviceExecuteLog(logDto); standardOrdinarySiteDeviceDriver.setOption(0); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + "工作模式为" + standardInspectSiteDeviceDriver.getMode() + ", 到达放货点不允许放货") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } } else { data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); LuceneLogDto logDto = LuceneLogDto.builder() @@ -377,8 +426,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic luceneExecuteLogService.deviceExecuteLog(logDto); } } - - //放货完成 //(Itype=1/2/3,需要WCS反馈) else if (phase == 0x09) { @@ -418,6 +465,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic log.info("未找到指令号{}对应的指令", ikey); return; } + //TODO 检测站点 if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); @@ -430,6 +478,24 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic standardOrdinarySiteDeviceDriver.setAgvphase(phase); standardOrdinarySiteDeviceDriver.setIndex(index); standardOrdinarySiteDeviceDriver.setInst(inst); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 0) { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + ", 放货完成不允许离开") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } } else { data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); LuceneLogDto logDto = LuceneLogDto.builder() @@ -440,7 +506,336 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic luceneExecuteLogService.deviceExecuteLog(logDto); } } - //上传AGV电量 + //到达取货点2 + else if (phase == 0x0B) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + CommonFinalParam commonFinalParam = new CommonFinalParam(); + if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { + String[] point = old_device_code.split(commonFinalParam.getBARRE()); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(agvaddr + "对应设备号为空") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + return; + } + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令号{}对应的指令", ikey); + return; + } + if (ObjectUtil.isEmpty(inst.getCarno())) { + inst.setCarno(String.valueOf(carno)); + instructionService.update(inst); + } + + //TODO 检测站点 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + standardOrdinarySiteDeviceDriver.setOption(0); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 0) { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + ", 到达取货点不允许取货") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + } else { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + } + //取货2完毕 + else if (phase == 0x0D) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agv地址参数有误,phase:" + phase) + .build(); + logDto.setLog_level(2); + luceneExecuteLogService.deviceExecuteLog(logDto); + return; + } + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + CommonFinalParam commonFinalParam = new CommonFinalParam(); + if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { + String[] point = old_device_code.split(commonFinalParam.getBARRE()); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + device = deviceAppService.findDeviceByCode(device_code); + + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("对应设备号为空" + device_code) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + return; + } + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令号{}对应的指令", ikey); + return; + } + if (ObjectUtil.isEmpty(inst.getCarno())) { + inst.setCarno(String.valueOf(carno)); + instructionService.update(inst); + } + //TODO 检测站点 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + standardOrdinarySiteDeviceDriver.setAgvphase(phase); + standardOrdinarySiteDeviceDriver.setIndex(index); + standardOrdinarySiteDeviceDriver.setInst(inst); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + "工作模式为" + standardInspectSiteDeviceDriver.getMode() + ", 取货完毕,不允许离开") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + } else { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + } + //到达放货点2 + else if (phase == 0x0F) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("agv地址参数有误,phase:" + phase) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + return; + } + if (agvaddr != 0) { + CommonFinalParam commonFinalParam = new CommonFinalParam(); + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { + String[] point = old_device_code.split(commonFinalParam.getBARRE()); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令号{}对应的指令", ikey); + return; + } + //TODO 检测站点 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + standardOrdinarySiteDeviceDriver.setOption(0); + + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + "工作模式为" + standardInspectSiteDeviceDriver.getMode() + ", 到达放货点不允许放货") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + } else { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + } + //放货2完毕 + else if (phase == 0x11) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("agv地址参数有误,phase:" + phase) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + return; + } + if (agvaddr != 0) { + CommonFinalParam commonFinalParam = new CommonFinalParam(); + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { + String[] point = old_device_code.split(commonFinalParam.getBARRE()); + device_code = point[0]; + } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { + String[] point = old_device_code.split("\\."); + device_code = point[0]; + emptyNum = point[1]; + } else { + device_code = old_device_code; + } + } + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令号{}对应的指令", ikey); + return; + } + //TODO 检测站点 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + standardOrdinarySiteDeviceDriver.setOption(0); + + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 0) { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } else { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + ", 放货完成不允许离开") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + } else { + data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(this.getDeviceCode()) + .content("agvphase:" + phase + "反馈:" + data) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + } + //上传x坐标 else if (phase == 0x70) { //x坐标 x = ikey; @@ -450,7 +845,9 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto); - } else if (phase == 0x71) { + } + //上报y坐标 + else if (phase == 0x71) { //y坐标 y = ikey; LuceneLogDto logDto = LuceneLogDto.builder() @@ -459,7 +856,9 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto); - } else if (phase == 0x72) { + } + //上报角度 + else if (phase == 0x72) { //车辆角度 angle = ikey; LuceneLogDto logDto = LuceneLogDto.builder() @@ -468,7 +867,9 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto); - } else if (phase == 0x73) { + } + //上报电量 + else if (phase == 0x73) { log.info("接收agv上报信息,phase == 0x73:" + phase); //agv电量 electric_qty = ikey; @@ -483,11 +884,11 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic //当前上报的车号 String now_car = String.valueOf(this.agvaddr); //如果配置的车号是诺宝车号 - if(now_car.equals(is_atuo_car)){ + if (now_car.equals(is_atuo_car)) { //是否开启自动充电 String is_atuo_electric = ISysParamService.findByCode(AcsConfig.IS_ATUO_ELECTRIC).getValue(); log.info("接收agv上报信息,is_atuo_electric:" + is_atuo_electric); - if("1".equals(is_atuo_electric)){ + if ("1".equals(is_atuo_electric)) { String electric_begin = ISysParamService.findByCode(AcsConfig.ELECTRIC_BEGIN).getValue(); String[] begins = electric_begin.split(":"); String electric_end = ISysParamService.findByCode(AcsConfig.ELECTRIC_END).getValue(); @@ -499,33 +900,35 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic LocalTime now = LocalTime.now(); // 判断当前时间是否在时间段内 boolean isInRange = !now.isBefore(startTime) && !now.isAfter(endTime); - int electric = 0 ; + int electric = 0; //早上8-22点 - if(isInRange){ + if (isInRange) { electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC).getValue()); - }else{ + } else { electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC2).getValue()); } - if (electric_qty>0 && electric_qty < electric) { - log.info("当前车辆{}电量为{}低于{},开始判断是否需要充电!", this.agvaddr, electric_qty,electric); + if (electric_qty > 0 && electric_qty < electric) { + log.info("当前车辆{}电量为{}低于{},开始判断是否需要充电!", this.agvaddr, electric_qty, electric); //判断是否已下发充电任务 - Dict dict1 = dictService.getDictByName3("station",String.valueOf(this.agvaddr),null); - if(ObjectUtil.isNotEmpty(dict1)){ - log.info("当前车辆{}已分配充电桩{},退出后续判断",this.agvaddr,dict1.getPara1()); - }else{ + Dict dict1 = dictService.getDictByName3("station", String.valueOf(this.agvaddr), null); + if (ObjectUtil.isNotEmpty(dict1)) { + log.info("当前车辆{}已分配充电桩{},退出后续判断", this.agvaddr, dict1.getPara1()); + } else { //未下发,判断是否有空闲充电桩 Dict dict = dictService.getDictByName2("station"); - if(ObjectUtil.isNotEmpty(dict)){ + if (ObjectUtil.isNotEmpty(dict)) { ndcAgvService.charge(String.valueOf(this.agvaddr)); - isCharge =true; - }else{ - log.info("当前车辆{}电量为{}低于{},但无空闲充电桩!", this.agvaddr, electric_qty,electric); + isCharge = true; + } else { + log.info("当前车辆{}电量为{}低于{},但无空闲充电桩!", this.agvaddr, electric_qty, electric); } } } } } - } else if (phase == 0x74) { + } + //上报车状态 + else if (phase == 0x74) { //三色灯状态 status = ikey; LuceneLogDto logDto = LuceneLogDto.builder() @@ -559,23 +962,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic last_status = status; } //进入区域(phase值) - else if (phase == 0x50) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("agvphase:" + phase + "自动门开门") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - //离开区域(phase值) - else if (phase == 0x51) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("agvphase:" + phase + "自动门关门") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - } //上报异常信息 //(不需要WCS反馈) else if (phase == 0x67) { @@ -619,12 +1005,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto); -// if (StrUtil.equals(inst.getAgv_system_type(), "2")) { -// TwoNDCSocketConnectionAutoRun.write(data); -// } -// else if (StrUtil.equals(inst.getAgv_system_type(), "3")) { -// TwoNDC2SocketConnectionAutoRun.write(data); -// } if (StrUtil.equals(inst.getAgv_system_type(), "2")) { TwoNDCSocketConnectionAutoRun.write(data); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/ItemProtocol.java index a1b660d..f06b8f4 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/ItemProtocol.java @@ -11,17 +11,10 @@ import java.util.List; @Data public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; public static String item_mode = "mode"; public static String item_move = "move"; - public static String item_action = "action"; - public static String item_error = "error"; + public static String item_mix_code = "mix_code"; public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_weight = "weight"; - /*public static String item_material_type = "material_type"; - public static String item_barcode = "barcode";*/ private StandardInspectSiteDeviceDriver driver; @@ -38,54 +31,29 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_move); } - public int getAction() { - return this.getOpcIntegerValue(item_action); + public int getMix_code() { + return this.getOpcIntegerValue(item_mix_code); } - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - /** - *是否有货 - */ - public int hasGoods(int move) { - return move; - } Boolean isonline; public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); return value; } - return -1; - + return 0; } public static List getReadableItemDtos() { ArrayList list = new ArrayList(); list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3")); + list.add(new ItemDto(item_mix_code, "终点", "DB600.B3")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java index eb71d24..c645b97 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -1,46 +1,27 @@ package org.nl.acs.device_driver.conveyor.standard_inspect_site; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.nl.acs.device.domain.Device; -import org.nl.acs.device.domain.DeviceRunpoint; -import org.nl.acs.device.service.DeviceRunpointService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device.service.mapper.DeviceMappers; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.history.ErrorUtil; -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.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.domain.Task; -import org.nl.acs.task.enums.TaskStatusEnum; +import org.nl.acs.task.enums.AgvSystemTypeEnum; +import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; -import org.nl.acs.task.service.mapper.TaskMapper; -import org.nl.acs.utils.ConvertUtil; -import org.nl.common.utils.CodeUtil; import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; +import org.nl.system.service.param.ISysParamService; import java.util.*; @@ -51,580 +32,436 @@ import java.util.*; @Data @RequiredArgsConstructor public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - TaskMapper taskMapper; - - AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); - @Autowired - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); - - DeviceMappers deviceMappers=SpringContextHolder.getBean("deviceMappers"); - - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - - DeviceRunpointService deviceRunpointService=SpringContextHolder.getBean(DeviceRunpointService.class); - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - /** - * 放货准备锁 - */ - String putReadyLock = null; - /** - * 有货标记 - */ - protected boolean has_goods_tag = false; - - private Date time = new Date(); - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - int io_action = 0; - int last_io_action = 0; - int material_type = 0; - int last_material_type = 0; - int barcode = 0; - int last_barcode = 0; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - /** - * 备注 - */ - String remark; - /** - * 数量 - */ - String qty; - /** - * 物料 - */ - String material; - /** - * 批次 - */ - String batch; - /** - * 当前指令 - */ - Instruction inst = null; - /** - * 上次指令 - */ - Instruction last_inst = null; + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + private final ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); /** - * 触摸屏手动触发任务 + * 工作模式 */ - private Boolean is_has_task = false; - + private int mode = 0; + private int last_mode = 0; /** - * 满盅入库请求标记 + * 光电信号 */ - boolean Sucess = false; - + private int move = 0; + private int last_move = 0; /** - * 暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + * 指令终点 */ - int flag; + private int mix_code = 0; + private int last_mix_code = 0; + /** + * 消息 + */ + private String message = null; + /** + * 是否报警 + */ + private Boolean isError = false; + /** + * 是否在线 + */ + private Boolean isOnline = false; + /** + * 请求标记 + */ + private boolean requireSuccess = false; + /** + * 根据光电信号请求标记 + */ + private boolean requireMoveSuccess = false; + /** + * 执行步骤 + */ + private int flag = 0; + /** + * 当前设备号 + */ + private String device_code = null; - String devicecode; @Override public Device getDevice() { return this.device; } - @Override public void execute() { - String message = null; + + this.device_code = this.getDevice().getDevice_code(); + this.mode = this.itemProtocol.getMode(); + this.move = this.itemProtocol.getMove(); + this.mix_code = this.itemProtocol.getMix_code(); + try { - devicecode = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - hasGoods = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - if (mode != last_mode) { - this.setRequireSucess(false); + if (this.mode != this.last_mode) { + this.requireSuccess = false; + luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder() + .device_code(device_code) + .log_level(4) + .content("信号: mode由" + this.last_mode + "->" + this.mode) + .build()); } - if (move != last_move) { - if (devicecode.equals("KLCZCW1") || devicecode.equals("KLCZCW2")|| devicecode.equals("KLCZCW3") ||devicecode.equals("KLCZCW4") || devicecode.equals("KLCZCW5") || devicecode.equals("KLCZCW6")) { - Device device1 = new Device(); - Device device2 = new Device(); - device1 = deviceAppService.findDeviceByCode(devicecode); - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device1.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() != -1) { - device2 = deviceMappers.getKKstartpointcode(); - device2 = deviceAppService.findDeviceByCode(device2.getDevice_code()); - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device2.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 1) { - TaskDto taskDto = new TaskDto(); - taskDto.setTask_type("1"); - taskDto.setRequest_again("0"); - taskDto.setPriority("1"); - taskDto.setAgv_action_type(1); - taskDto.setAgv_system_type("2"); - taskDto.setRoute_plan_code("normal"); - taskDto.setStart_point_code(device2.getDevice_code()); - taskDto.setNext_point_code(devicecode); - try { - taskserver.create(taskDto); - }catch (Exception e){ - log.info("检测站点创建任务失败{}",e); + + if (this.move != this.last_move) { + this.requireMoveSuccess = false; + luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder() + .device_code(device_code) + .log_level(4) + .content("信号: move由" + this.last_mode + "->" + this.mode) + .build()); + } + + if (this.mix_code != this.last_mix_code) { + luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder() + .device_code(device_code) + .log_level(4) + .content("信号: mix_code由" + this.last_mode + "->" + this.mode) + .build()); + } + + boolean applyEmptyFlag = Optional.ofNullable(this.getExtraValue().get("apply_empty")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (this.move == 0 && applyEmptyFlag && !this.requireMoveSuccess && this.mode > 0) { + //生成产线空料仓暂存位补空的任务 + this.createCXKLCZCWBKTask(); + } + + if (!this.itemProtocol.getIsonline()) { + this.isOnline = false; + this.isError = true; + this.message = "设备信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.isOnline = false; + this.message = "设备未联机"; + //有报警 + } else { + this.isOnline = true; + this.isError = false; + switch (this.mode) { + case 1: + log.debug("设备运转模式:等待工作"); + break; + case 3: + case 4: + //3生成从产线下料口到产线满料仓暂存位和从产线空料仓暂存位到产线下料口的取满补空四点任务 + //4生成从产线下料口到产线满料仓暂存位和从人工补空料仓位到产线下料口的取满补空四点任务 + if (!requireSuccess) { + //生成取满补空任务 + this.createQMBKTask(); } - }else{ - move=1; - } - }else{ - move=1; + break; + case 5: + //初始化,生成从产线空料仓暂存位到产线下料口的补空两点任务 + if (!requireSuccess) { + //生成下料口补空任务 + this.createXLKBKTask(); + } + break; + case 6: + //生成从产线满料暂存位或二楼转运料位到混合机的两点任务 + if (!requireSuccess) { + //生成混合机混合任务 + this.createHHJHHTask(); + } + break; + case 7: + //生成从混合机到满料仓的两点任务,满料仓需要按照优先级去分配终点 + if (!requireSuccess) { + //生成混合机混合完成任务 + this.createHHJWCTask(); + } + break; + case 10: + //取消该点的所有指令和任务 + if (!requireSuccess) { + //取消所有该点位的任务 + this.cancleTask(); + } + break; + default: + break; } } - } } catch (Exception var17) { + this.message = "逻辑异常,详情查看设备日志"; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "逻辑异常:" + Arrays.toString(var17.getStackTrace())) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } + this.last_mode = this.mode; + this.last_move = this.move; + this.last_mix_code = this.mix_code; + } + + /** + * 取消所有任务和指令 + */ + private void cancleTask() { + try { + instructionService.cancelInstAndTaskByDeviceCode(this.device_code); + } catch (Exception e) { + this.message = "取消指令和任务时出现异常"; return; } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - //有报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 4: - if(!requireSucess) { - this.MLCBH(); - } - break; - case 5: - if(!requireSucess) { - this.BMLCBH(); - } - break; - case 6: - if(!requireSucess) { - this.HLJJL1(); - } - break; - case 7: - if(!requireSucess) { - this.HLJJL2(); - } - break; - case 8: - if(!requireSucess) { - this.HLJJL3(); - } - break; - case 10: - if(!requireSucess) { - this.HLTASKCANCEL(); - } - break; - case 11: - if(!requireSucess) { - this.HLJSL(); - } - break; - default: - break; - } - - } - last_mode = mode; - last_move = move; - last_task = task; - last_material_type = material_type; - last_barcode = barcode; - - } - @Override - public String toString() { - return "StandardInspectSiteDeviceDriver"; - } - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - //光电变化产生补空框的任务 - - //满料仓搬货请求 - public synchronized boolean MLCBH(){ - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - TaskDto taskDto=new TaskDto(); - taskDto.setTask_type("1"); - taskDto.setRequest_again("0"); - taskDto.setPriority("1"); - taskDto.setAgv_action_type(1); - taskDto.setAgv_system_type("2"); - taskDto.setRoute_plan_code("normal"); - taskDto.setStart_point_code(devicecode); - //起点1 - Device device1=new Device(); - //终点1 - Device device2=new Device(); - //起点1 - Device device3=new Device(); - device1=deviceMappers.getdevicemessage(devicecode); - String region=device1.getRegion(); - device2=deviceMappers.getMLCBHnextpointcode(region); - device2=deviceAppService.findDeviceByCode(device2.getDevice_code()); - standardInspectSiteDeviceDriver =(StandardInspectSiteDeviceDriver)device2.getDeviceDriver(); - if(standardInspectSiteDeviceDriver.getMove()==0) { - taskDto.setNext_point_code(device2.getDevice_code()); - }else{ - Map map = new LinkedHashMap<>(); - map.put("to_command",400); - this.writing(map); - return false; - } - device3=deviceMappers.getMLCBHstartpointcode2(region); - device3=deviceAppService.findDeviceByCode(device3.getDevice_code()); - standardInspectSiteDeviceDriver =(StandardInspectSiteDeviceDriver)device3.getDeviceDriver(); - if(standardInspectSiteDeviceDriver.getMove()==1) { - taskDto.setStart_point_code2(device3.getDevice_code()); - taskDto.setNext_point_code2(devicecode); - try { - taskserver.create(taskDto); - }catch (Exception e){ - log.info("检测站点创建任务失败{}",e); - } - Map map = new LinkedHashMap<>(); - map.put("to_command",200); - this.setRequireSucess(true); - this.writing(map); - return true; - }else{ - Map map = new LinkedHashMap<>(); - map.put("to_command",400); - this.writing(map); - return false; - } - } - } - //混料机任务取消 - public synchronized boolean HLTASKCANCEL(){ - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - Instruction inst = new Instruction(); - inst = instructionService.findByStarCodeAndExcute(this.devicecode); - if (inst == null) { - Map map = new LinkedHashMap<>(); - log.info("混料机任务取消失败"); - map.put("to_command", 400); - this.writing(map); - return false; - } - String id = inst.getTask_id(); - try { - taskserver.cancel(id); - } catch (Exception e) { - log.info("检测站点取消任务失败{}", e); - Map map = new LinkedHashMap<>(); - log.info("混料机任务取消失败"); - map.put("to_command", 400); - this.writing(map); - return false; - } - Map map = new LinkedHashMap<>(); - map.put("to_command", 200); - this.writing(map); - this.setRequireSucess(true); - return true; - } - } - //半料仓请求搬货请求 - public synchronized boolean BMLCBH(){ - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - TaskDto taskDto = new TaskDto(); - taskDto.setTask_type("1"); - taskDto.setRequest_again("0"); - taskDto.setPriority("1"); - taskDto.setAgv_system_type("2"); - taskDto.setAgv_action_type(1); - taskDto.setRoute_plan_code("normal"); - taskDto.setStart_point_code(devicecode); - //起点1 - Device device1=new Device(); - //终点1 - Device device2=new Device(); - taskDto.setStart_point_code(devicecode); - device1=deviceMappers.getdevicemessage(devicecode); - String region=device1.getRegion(); - device2=deviceMappers.getMLCBHnextpointcode(region); - device2=deviceAppService.findDeviceByCode(device2.getDevice_code()); - standardInspectSiteDeviceDriver =(StandardInspectSiteDeviceDriver)device2.getDeviceDriver(); - if(standardInspectSiteDeviceDriver.getMove()==0) { - taskDto.setNext_point_code(device2.getDevice_code()); - try { - taskserver.create(taskDto); - } catch (Exception e) { - log.info("检测站点创建任务失败{}", e); - Map map = new LinkedHashMap<>(); - log.info("混料机任务取消失败"); - map.put("to_command", 400); - this.writing(map); - return false; - } - Map map = new LinkedHashMap<>(); - map.put("to_command", 200); - this.writing(map); - this.setRequireSucess(true); - return true; - } - DeviceRunpoint deviceRunpoint = deviceRunpointService.getOne(new LambdaQueryWrapper().eq(DeviceRunpoint::getHasgoods,0)); - if(deviceRunpoint!=null) { - taskDto.setNext_point_code("YCZCW"); - try { - taskserver.create(taskDto); - } catch (Exception e) { - log.info("检测站点创建任务失败{}", e); - Map map = new LinkedHashMap<>(); - log.info("混料机任务取消失败"); - map.put("to_command", 400); - this.writing(map); - return false; - } - Map map = new LinkedHashMap<>(); - map.put("to_command", 200); - this.writing(map); - this.setRequireSucess(true); - return true; - } - Map map = new LinkedHashMap<>(); - log.info("混料机任务取消失败"); - map.put("to_command", 400); - this.writing(map); - return false; - } - } - //混料机自动呼叫1号料仓货物 - public synchronized boolean HLJJL1(){ - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - TaskDto taskDto = new TaskDto(); - taskDto.setTask_type("1"); - taskDto.setRequest_again("0"); - taskDto.setAgv_system_type("2"); - taskDto.setPriority("1"); - taskDto.setAgv_action_type(1); - taskDto.setRoute_plan_code("normal"); - //终点1 - Device device2 = new Device(); - device2 = deviceMappers.getMLCBHnextpointcode("1"); - device2=deviceAppService.findDeviceByCode(device2.getDevice_code()); - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device2.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 1) { - taskDto.setStart_point_code(device2.getDevice_code()); - taskDto.setNext_point_code(devicecode); - try { - taskserver.create(taskDto); - } catch (Exception e) { - log.info("检测站点创建任务失败{}", e); - } - - Map map = new LinkedHashMap<>(); - map.put("to_command", 200); - this.writing(map); - this.setRequireSucess(true); - return true; - } else { - Map map = new LinkedHashMap<>(); - map.put("to_command",400); - this.writing(map); - return false; - } - } - } - //混料机自动呼叫2号料仓货物 - public synchronized boolean HLJJL2(){ - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - TaskDto taskDto = new TaskDto(); - taskDto.setTask_type("1"); - taskDto.setRequest_again("0"); - taskDto.setAgv_system_type("2"); - taskDto.setPriority("1"); - taskDto.setAgv_action_type(1); - taskDto.setRoute_plan_code("normal"); - //终点1 - Device device2 = new Device(); - device2 = deviceMappers.getMLCBHnextpointcode("2"); - device2=deviceAppService.findDeviceByCode(device2.getDevice_code()); - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device2.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 1) { - taskDto.setStart_point_code(device2.getDevice_code()); - taskDto.setNext_point_code(devicecode); - try { - taskserver.create(taskDto); - } catch (Exception e) { - log.info("检测站点创建任务失败{}", e); - } - Map map = new LinkedHashMap<>(); - map.put("to_command", 200); - this.writing(map); - this.setRequireSucess(true); - return true; - } else { - Map map = new LinkedHashMap<>(); - map.put("to_command",400); - this.writing(map); - return false; - } - } + Map map = new HashMap<>(); + map.put("to_command", 200); + this.writing(map); + this.requireSuccess = true; } - //混料机自动呼叫3号料仓货物 - public synchronized boolean HLJJL3(){ - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - TaskDto taskDto = new TaskDto(); - taskDto.setTask_type("1"); - taskDto.setAgv_system_type("2"); - taskDto.setRequest_again("0"); - taskDto.setPriority("1"); - taskDto.setAgv_action_type(1); - taskDto.setRoute_plan_code("normal"); - //终点1 - Device device2 = new Device(); - device2 = deviceMappers.getMLCBHnextpointcode("3"); - device2=deviceAppService.findDeviceByCode(device2.getDevice_code()); - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device2.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 1) { - taskDto.setStart_point_code(device2.getDevice_code()); - taskDto.setNext_point_code(devicecode); - try { - taskserver.create(taskDto); - } catch (Exception e) { - log.info("检测站点创建任务失败{}", e); + /** + * 创建混合机混合完成任务到满料仓位 + */ + private void createHHJWCTask() { + List hhFmDeviceList = this.getExtraDeviceCodes("fmDeviceList"); + if (CollectionUtils.isEmpty(hhFmDeviceList)) { + this.message = "未配置放满设备信息"; + return; + } + String nextDeviceCode = null; + for (int i = 0; i < hhFmDeviceList.size(); i++) { + String hhFmDeviceCode = hhFmDeviceList.get(i); + Device hhFmDevice = deviceAppService.findDeviceByCode(hhFmDeviceCode); + if (hhFmDevice != null && hhFmDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) hhFmDevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) { + TaskDto taskDto = taskService.findByNextCode(hhFmDeviceCode); + if (ObjectUtil.isEmpty(taskDto)) { + nextDeviceCode = hhFmDeviceCode; + break; + } } - Map map = new LinkedHashMap<>(); - map.put("to_command", 200); - this.writing(map); - this.setRequireSucess(true); - return true; - } else { - Map map = new LinkedHashMap<>(); - map.put("to_command",400); - this.writing(map); - return false; } } + if (nextDeviceCode == null) { + this.message = "未找到符合条件的设备"; + return; + } + TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.TWO_AGV_Task.getIndex(), this.device_code, nextDeviceCode); + try { + taskService.create(taskDto); + } catch (Exception e) { + this.message = "创建任务时出现异常"; + return; + } + Map map = new HashMap<>(); + map.put("to_command", 200); + this.writing(map); + this.requireSuccess = true; } - //混料机满料送出请求 - public synchronized boolean HLJSL(){ - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - TaskDto taskDto = new TaskDto(); - taskDto.setTask_type("1"); - taskDto.setAgv_system_type("2"); - taskDto.setRequest_again("0"); - taskDto.setPriority("1"); - taskDto.setAgv_action_type(1); - taskDto.setRoute_plan_code("normal"); - taskDto.setStart_point_code(devicecode); - //终点1 - Device device2 = new Device(); - device2 = deviceMappers.getHLJMLnextpointcode(); - device2=deviceAppService.findDeviceByCode(device2.getDevice_code()); - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device2.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - taskDto.setNext_point_code(device2.getDevice_code()); - try { - taskserver.create(taskDto); - } catch (Exception e) { - log.info("检测站点创建任务失败{}", e); + + /** + * 创建混合机混合混合任务 + */ + private void createHHJHHTask() { + JSONObject relationJson = Optional.ofNullable(paramService.findByCode("relation").getValue()).map(JSONObject::parseObject).orElse(new JSONObject()); + String nextDeviceCode = relationJson.getString(String.valueOf(this.mix_code)); + if (nextDeviceCode == null) { + this.message = "系统参数表未配置映射关系信息"; + return; + } + TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.TWO_AGV_Task.getIndex(), this.device_code, nextDeviceCode); + try { + taskService.create(taskDto); + } catch (Exception e) { + this.message = "创建任务时出现异常"; + return; + } + Map map = new HashMap<>(); + map.put("to_command", 200); + this.writing(map); + this.requireSuccess = true; + } + + /** + * 创建下料口补空任务 + */ + private void createXLKBKTask() { + List cxBkDeviceList = this.getExtraDeviceCodes("cxBkDeviceList"); + if (CollectionUtils.isEmpty(cxBkDeviceList)) { + this.message = "未配置产线补空设备"; + return; + } + String startDeviceCode = null; + for (int i = 0; i < cxBkDeviceList.size(); i++) { + String cxBkDeviceCode = cxBkDeviceList.get(i); + Device cxBkDevice = deviceAppService.findDeviceByCode(cxBkDeviceCode); + if (cxBkDevice != null && cxBkDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) cxBkDevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() > 0) { + startDeviceCode = cxBkDeviceCode; + break; } - Map map = new LinkedHashMap<>(); - map.put("to_command", 200); - this.writing(map); - this.setRequireSucess(true); - return true; - } else { - Map map = new LinkedHashMap<>(); - map.put("to_command",400); - this.writing(map); - return false; } } + if (startDeviceCode == null) { + this.message = "未找到符合条件的起点设备"; + return; + } + TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.TWO_AGV_Task.getIndex(), startDeviceCode, this.device_code); + try { + taskService.create(taskDto); + } catch (Exception e) { + this.message = "创建任务时出现异常"; + return; + } + Map map = new HashMap<>(); + map.put("to_command", 200); + this.writing(map); + this.requireSuccess = true; } + + /** + * 创建产线空料仓暂存位补空任务 + */ + private void createCXKLCZCWBKTask() { + List rgBkDeviceList = this.getExtraDeviceCodes("rgBkDeviceList"); + if (CollectionUtils.isEmpty(rgBkDeviceList)) { + this.message = "未配置产线补空设备"; + return; + } + String startDeviceCode = null; + for (int i = 0; i < rgBkDeviceList.size(); i++) { + String rgBkDeviceCode = rgBkDeviceList.get(i); + Device rgBkDevice = deviceAppService.findDeviceByCode(rgBkDeviceCode); + if (rgBkDevice != null && rgBkDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) rgBkDevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() > 0) { + startDeviceCode = rgBkDeviceCode; + break; + } + } + } + if (startDeviceCode == null) { + this.message = "未找到符合条件的起点设备"; + return; + } + TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.TWO_AGV_Task.getIndex(), startDeviceCode, this.device_code); + try { + taskService.create(taskDto); + } catch (Exception e) { + this.message = "创建任务时出现异常"; + return; + } + this.requireMoveSuccess = true; + } + + /** + * 创建产线下料口取满补空任务 + */ + private void createQMBKTask() { + //需要区分mode值是3还是4 + List cxFmDeviceList = this.getExtraDeviceCodes("fmDeviceList"); + if (CollectionUtils.isEmpty(cxFmDeviceList)) { + this.message = "未配置放满设备信息"; + return; + } + List cxBkDeviceList = this.getExtraDeviceCodes("cxBkDeviceList"); + if (CollectionUtils.isEmpty(cxBkDeviceList)) { + this.message = "未配置产线补空设备信息"; + return; + } + List rgBkDeviceList = this.getExtraDeviceCodes("rgBkDeviceList"); + if (CollectionUtils.isEmpty(rgBkDeviceList)) { + this.message = "未配置人工补空设备信息"; + return; + } + List start2DeviceList = cxBkDeviceList; + if (this.mode == 4) { + start2DeviceList = rgBkDeviceList; + } + String nextDeviceCode = null; + for (int i = 0; i < cxFmDeviceList.size(); i++) { + String cxFmDeviceCode = cxFmDeviceList.get(i); + Device cxFmDevice = deviceAppService.findDeviceByCode(cxFmDeviceCode); + if (cxFmDevice != null && cxFmDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) cxFmDevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) { + TaskDto taskDto = taskService.findByNextCode(nextDeviceCode); + if (ObjectUtil.isEmpty(taskDto)) { + nextDeviceCode = cxFmDeviceCode; + break; + } + } + } + } + if (nextDeviceCode == null) { + this.message = "未找到符合条件的终点设备"; + return; + } + String start2DeviceCode = null; + for (int i = 0; i < start2DeviceList.size(); i++) { + String cxBkDeviceCode = start2DeviceList.get(i); + Device cxBkDevice = deviceAppService.findDeviceByCode(cxBkDeviceCode); + if (cxBkDevice != null && cxBkDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) cxBkDevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() > 0) { + start2DeviceCode = cxBkDeviceCode; + break; + } + } + } + if (start2DeviceCode == null) { + this.message = "未找到符合条件的起点2设备"; + return; + } + TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.FOUR_AGV_Task.getIndex(), this.device_code, nextDeviceCode, start2DeviceCode, this.device_code); + try { + taskService.create(taskDto); + } catch (Exception e) { + this.message = "创建任务时出现异常"; + return; + } + Map map = new HashMap<>(); + map.put("to_command", 200); + this.writing(map); + this.requireSuccess = true; + } + + private TaskDto packageTaskDto(String taskType, String startDeviceCode, String nextDeviceCode) { + TaskDto taskDto = new TaskDto(); + taskDto.setTask_type(taskType); + taskDto.setAgv_system_type("1"); + taskDto.setStart_point_code(startDeviceCode); + taskDto.setStart_device_code(startDeviceCode); + taskDto.setStart_parent_code(startDeviceCode); + taskDto.setNext_point_code(nextDeviceCode); + taskDto.setNext_device_code(nextDeviceCode); + taskDto.setNext_parent_code(nextDeviceCode); + return taskDto; + } + + private TaskDto packageTaskDto(String taskType, String startDeviceCode, String nextDeviceCode, String startDeviceCode2, String nextDeviceCode2) { + TaskDto taskDto = new TaskDto(); + taskDto.setTask_type(taskType); + taskDto.setAgv_system_type(AgvSystemTypeEnum.One_NDC_System_Type.getIndex()); + taskDto.setStart_point_code(startDeviceCode); + taskDto.setStart_device_code(startDeviceCode); + taskDto.setStart_parent_code(startDeviceCode); + + taskDto.setStart_point_code2(startDeviceCode2); + taskDto.setStart_device_code2(startDeviceCode2); + + taskDto.setNext_point_code(nextDeviceCode); + taskDto.setNext_device_code(nextDeviceCode); + taskDto.setNext_parent_code(nextDeviceCode); + + taskDto.setNext_point_code2(nextDeviceCode2); + taskDto.setNext_device_code2(nextDeviceCode2); + return taskDto; + } + public void writing(Map map) { - LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); Map itemMap = new LinkedHashMap<>(); map.forEach((key, value) -> { if (ObjectUtil.isNotEmpty(value)) { @@ -635,17 +472,14 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp try { this.checkcontrol(itemMap); } catch (Exception e) { - e.printStackTrace(); - try{ - this.checkcontrol(itemMap); - } catch (Exception e1){ - e1.printStackTrace(); - } + this.message = "下发信号时出现异常"; + luceneExecuteLogService.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号 " + itemMap + "失败, 原因: " + Arrays.toString(e.getStackTrace()))); + return; } - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap)); + luceneExecuteLogService.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号 " + itemMap + "成功")); } } + /** * 抽取统一下发电气信号前缀 * @@ -658,39 +492,6 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp @Override public JSONObject getDeviceStatusName() { JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - if (this.getMode() == 0) { - mode = LangProcess.msg("universal_off-line"); - } else if (this.getMode() == 1) { - mode = LangProcess.msg("universal_stand-alone"); - } else if (this.getMode() == 2) { - mode = LangProcess.msg("universal_standby"); - } else if (this.getMode() == 3) { - mode = LangProcess.msg("universal_operation"); - } - if (this.getMove() == 0) { - move = LangProcess.msg("universal_no"); - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = LangProcess.msg("universal_yes"); - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = LangProcess.msg("universal_two_yes"); - jo.put("hasGoods", true); - } - action = LangProcess.msg("universal_actionMessage1"); - if(this.action == 1){ - action = LangProcess.msg("universal_actionMessage2"); - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("isOnline", this.getIsonline()); - jo.put("isError", this.getIserror()); - jo.put("task", this.getTask()); return jo; } @@ -699,12 +500,4 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp } - /** - * lms申请任务 - * - * @param - */ - public synchronized boolean apply(Integer type) { - return false; - } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java index 75a9c70..27989da 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -186,8 +186,6 @@ public interface InstructionService extends CommonService { void create(Instruction dto) throws Exception; - - /** * 创建2 * @@ -367,6 +365,7 @@ public interface InstructionService extends CommonService { /** * 根据终点查询指令 + * * @param devicecode * @return */ @@ -495,13 +494,16 @@ public interface InstructionService extends CommonService { */ Boolean querySameNextDeviceCodeInstByOut(String nextDeviceCode); - List findByCodeAndExcute(String nextDeviceCode); + List findByCodeAndExcute(String nextDeviceCode); List findByNextCode(String nextDeviceCode); List findReadyIns(); + List findReadyIns2(); Instruction findByStarCodeAndExcute(String deviceCode); + + void cancelInstAndTaskByDeviceCode(String device_code) throws Exception; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 00ee850..63d157d 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -456,12 +456,12 @@ public class InstructionServiceImpl extends CommonServiceImpl" + dto.getNext_device_code() + "路由不通"); } - if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) { + if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) { throw new BadRequestException(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由类型不是agv类型"); } if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) { NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); + ndcAgvService.sendAgvInstToNDC( dto); } //判断是否是仙工AGV if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { @@ -647,7 +647,7 @@ public class InstructionServiceImpl extends CommonServiceImpl instructionList = Optional.ofNullable(this.instructions) + .orElse(new ArrayList<>()) + .stream() + .filter(instruction -> instruction.getStart_device_code().equals(device_code) || instruction.getNext_device_code().equals(device_code)) + .collect(Collectors.toList()); + for (Instruction instruction : instructionList) { + taskService.cancelAndInst(instruction.getTask_id()); + } + } + } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/AgvSystemTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/AgvSystemTypeEnum.java index abf9625..ec3e6fc 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/AgvSystemTypeEnum.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/AgvSystemTypeEnum.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.AllArgsConstructor; import lombok.Getter; + /** * @author 20220102CG\noblelift */ @@ -14,7 +15,7 @@ public enum AgvSystemTypeEnum { * 二期一楼AGV任务 * 一期1楼叉车NDC系统 */ - One_NDC_System_Type("1", "1", "一期1楼叉车NDC系统"), + One_NDC_System_Type("1", "1", "叉车NDC系统"), /** * 二期二楼NDC系统 * 一期2楼NDC系统 @@ -45,6 +46,7 @@ public enum AgvSystemTypeEnum { /** * 构造方法 + * * @param index * @param code * @param name diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java index 2178201..28ffedd 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.AllArgsConstructor; import lombok.Getter; + /** * @author 20220102CG\noblelift */ @@ -12,9 +13,9 @@ import lombok.Getter; public enum TaskTypeEnum { /** * 任务类型 - */ - Raw_Foil_AGV_Task("1", "1", "生箔AGV任务"), - Cutting_AGV_Task("2", "2", "分切AGV任务"), + */ + TWO_AGV_Task("1", "1", "两点AGV任务"), + FOUR_AGV_Task("2", "2", "四点AGV任务"), Standard_AGV_Task("3", "3", "普通AGV任务"), Forklift_AGV_Task("4", "4", "叉车AGV任务"), Conveyor_Task("5", "5", "输送线任务"), @@ -52,6 +53,7 @@ public enum TaskTypeEnum { /** * 构造方法 + * * @param index * @param code * @param name diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 78988a7..2265ec3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -1139,29 +1139,6 @@ public class TaskServiceImpl extends CommonServiceImpl impleme instdto.setStart_height(start_height); instdto.setNext_height(next_height); instdto.setAgv_action_type(acsTask.getAgv_action_type()); - if (StrUtil.equals(agv_system_type, CommonFinalParam.TWO)) { - // task_type - //1、生箔; Itype=1:取空,取满,放空,放满; - //2、分切 Itype=3取满、取空、放满、放空; - //3、普通任务 Itype=2:取货、放货; - //4、叉车任务 - //5、输送任务 - //6、行架 - //7、立库 - if (StrUtil.equals(task_type, CommonFinalParam.ONE)) { - instdto.setAgv_inst_type(CommonFinalParam.ONE); - } 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 if (StrUtil.equals(task_type, "8")) { - instdto.setAgv_inst_type("2"); - } else { - log.info("未找到对应的AGV指令类型,任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type()); - } - } else { - instdto.setAgv_inst_type("4"); - } instructionservice.create2(instdto); acsTask.setTask_status(CommonFinalParam.ONE); this.update(acsTask); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java index bc5b062..bb87be3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java @@ -57,12 +57,6 @@ public class AutoCreateInst { List list = taskserver.queryAllByStatus("0"); for (int i = 0; i < list.size(); i++) { TaskDto acsTask = list.get(i); - if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) { - continue; - } - if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) { - continue; - } String taskid = acsTask.getTask_id(); String taskcode = acsTask.getTask_code(); String task_type = acsTask.getTask_type(); @@ -147,9 +141,6 @@ public class AutoCreateInst { Instruction instdto = new Instruction(); instdto.setInstruction_type(task_type); instdto.setInstruction_id(IdUtil.simpleUUID()); - if (acsTask.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())){ - instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); - } instdto.setRoute_plan_code(route_plan_code); instdto.setRemark(acsTask.getRemark()); instdto.setMaterial(acsTask.getMaterial()); @@ -182,34 +173,6 @@ public class AutoCreateInst { instdto.setStart_height(start_height); instdto.setNext_height(next_height); instdto.setAgv_action_type(agvActionType); - //判断agv系统 - //1、1楼叉车系统 - //2、2楼1区域AGV系统 - //3、2楼2区域AGV系统 -已废弃 - if (StrUtil.equals(agv_system_type, CommonFinalParam.TWO)) { - // task_type - //1、生箔; Itype=1:取空,取满,放空,放满; - //2、分切 Itype=3取满、取空、放满、放空; - //3、普通任务 Itype=2:取货、放货; - //4、叉车任务 - //5、输送任务 - //6、行架 - //7、立库 - if (StrUtil.equals(task_type, CommonFinalParam.ONE)) { - instdto.setAgv_inst_type(CommonFinalParam.ONE); - } 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 if (StrUtil.equals(task_type, "8")) { - instdto.setAgv_inst_type("2"); - } else { - log.info("未找到对应的AGV指令类型,任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type()); - continue; - } - } else { - instdto.setAgv_inst_type("4"); - } try { instructionService.create(instdto); } catch (Exception e) { @@ -223,7 +186,7 @@ public class AutoCreateInst { luceneExecuteLogService.deviceExecuteLog(logDto); continue; } - //创建指令后修改任务状态 + //创建指令后修改任务状态 acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); acsTask.setUpdate_time(DateUtil.now()); acsTask.setRemark(" "); diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml b/acs2/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml index 42950dd..b2470a3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml @@ -10,11 +10,11 @@ spring: driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3307}/${DB_NAME:hhck_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:huaHaiCK_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true username: ${DB_USER:root} # password: ${DB_PWD:Root.123456} - password: ${DB_PWD:123456} + password: ${DB_PWD:password} # 初始连接数 initial-size: 5 # 最小连接数 diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml b/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml index f510862..f502a1c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml @@ -89,10 +89,13 @@ https://juejin.cn/post/6844903775631572999 - + - + + + + diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/agv/agv_ndc_two.vue b/acs2/nladmin-ui/src/views/acs/device/driver/agv/agv_ndc_two.vue index e69de29..867afad 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/agv/agv_ndc_two.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/agv/agv_ndc_two.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/standard_inspect_site.vue b/acs2/nladmin-ui/src/views/acs/device/driver/standard_inspect_site.vue index 0a169b0..f97f6aa 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/standard_inspect_site.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/standard_inspect_site.vue @@ -101,7 +101,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -128,13 +128,18 @@ + + + + + - + - + - - + + + + diff --git a/acs2/nladmin-ui/src/views/acs/device/opc/index.vue b/acs2/nladmin-ui/src/views/acs/device/opc/index.vue index c5d7477..c85bc07 100644 --- a/acs2/nladmin-ui/src/views/acs/device/opc/index.vue +++ b/acs2/nladmin-ui/src/views/acs/device/opc/index.vue @@ -104,12 +104,11 @@ { + if (item.hasOwnProperty('hasChildren')) { + item.hasChildren = item.hasChildren === "1" || item.hasChildren === 1 || item.hasChildren === true; + } else if (item.children && item.children.length > 0) { + item.hasChildren = true; + } else { + item.hasChildren = false; + } + if (item.children && Array.isArray(item.children)) { + item.children = this.processTreeData(item.children); + } + return item; + }); + }, handleClick(row, flag) { // flag为0是新增,flag为1是编辑,flag为2是删除 // 如果是父类操作 diff --git a/acs2/nladmin-ui/src/views/acs/task/index.vue b/acs2/nladmin-ui/src/views/acs/task/index.vue index 5f6e30b..5b79622 100644 --- a/acs2/nladmin-ui/src/views/acs/task/index.vue +++ b/acs2/nladmin-ui/src/views/acs/task/index.vue @@ -504,7 +504,7 @@ import CRUD, { crud, header, presenter } from '@crud/crud' import crudOperation from '@crud/CRUD.operation' import rrOperation from '@crud/RR.operation' import pagination from '@crud/Pagination' -hasgoods +import deviceCrud from '@/api/acs/device/device' import routeCurd from '@/api/acs/route/routePlan' import { getDicts } from '@/views/system/dict/dict' import i18n from '@/i18n' @@ -633,7 +633,7 @@ export default { to_x2: null, to_y2: null, to_z2: null, - agv_system_type: '', + agv_system_type: '1', interactionJson: null }, taskStatus: {