From 6484d1de42edd8cfe8f0568a56a760f2a7da1003 Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Thu, 9 Mar 2023 16:21:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/agv/server/NDCAgvService.java | 8 + .../agv/server/impl/NDCAgvServiceImpl.java | 54 +++- .../run/OneNDCSocketConnectionAutoRun.java | 12 +- .../run/TwoNDC2SocketConnectionAutoRun.java | 243 ----------------- .../run/TwoNDCSocketConnectionAutoRun.java | 245 ------------------ .../agv/ndctwo/AgvNdcTwoDeviceDriver.java | 12 +- .../acs/ext/wms/data/CancelTaskRequest.java | 18 +- .../acs/ext/wms/data/CreateTaskRequest.java | 75 ++---- .../acs/ext/wms/rest/WmsToAcsController.java | 12 +- .../acs/ext/wms/service/WmsToAcsService.java | 13 +- .../wms/service/impl/WmsToAcsServiceImpl.java | 141 ++-------- .../org/nl/acs/task/service/TaskService.java | 8 + .../task/service/impl/TaskServiceImpl.java | 71 +++-- .../resources/config/application-prod.yml | 2 +- acs/nladmin-ui/src/views/acs/task/index.vue | 2 +- 15 files changed, 192 insertions(+), 724 deletions(-) delete mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDC2SocketConnectionAutoRun.java delete mode 100644 acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index 42960b7..abc3185 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -32,4 +32,12 @@ public interface NDCAgvService { public byte[] sendAgvOneModeInst(int phase, int index,int result); public byte[] sendAgvTwoModeInst(int phase, int index,int result); + + + /** + * 下发充电任务 + * @param carno + * @return + */ + public boolean createChargingTaskToNDC(String carno); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index d225613..09eb276 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -1,36 +1,27 @@ package org.nl.acs.agv.server.impl; -import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.agv.server.dto.AgvDto; import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; -import org.nl.acs.auto.run.TwoNDC2SocketConnectionAutoRun; -import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.impl.DeviceServiceImpl; import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.LokiLog; import org.nl.acs.log.LokiLogType; import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.DeviceType; -import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.util.CodeUtil; import org.nl.modules.wql.util.SpringContextHolder; import org.springframework.stereotype.Service; import java.util.HashMap; -import java.util.List; import java.util.Map; @Slf4j @@ -190,6 +181,49 @@ public class NDCAgvServiceImpl implements NDCAgvService { return b; } + @Override + public boolean createChargingTaskToNDC(String carno) { + byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno)); + byte carlow = (byte) IntToHexLow(Integer.parseInt(carno)); + + String instcode = CodeUtil.getNewCode("INSTRUCT_NO"); + byte instcodehigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); + byte instcodelow = (byte) IntToHexLow(Integer.parseInt(instcode)); + + String str = "十进制下发:"; + String str1 = "十六进制下发:"; + str += "carno:" + (Integer.parseInt(carno)); + str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF); + + str += "/instcode:" + (instcode); + str1 += "/instcode:" + hexToString(instcodehigh & 0xFF) + hexToString(instcodelow & 0xFF); + + System.out.println(str); + System.out.println(str1); + + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0C, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X08, + (byte) 0X64, (byte) 0X80, + (byte) 0X00, (byte) 0X01, + (byte) instcodehigh, (byte) instcodelow, + (byte) carhigh, (byte) carlow + }; + log.info("下发AGV充电任务--{}", str1); + + try{ + OneNDCSocketConnectionAutoRun.write(b); + } catch (Exception e){ + e.getMessage(); + return false; + } + System.out.println("下发agv充电任务数据:" + Bytes2HexString(b)); + return true; + } + String hexToString(int i) { return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase(); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index e2feb5e..e1fa800 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -64,11 +64,11 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } public String getName() { - return "1楼NDC在线连接"; + return "NDC在线连接"; } public void autoRun() throws IOException { - System.out.println("1楼NDCAgv链接开始"); + System.out.println("NDCAgv链接开始"); ParamService ParamService = SpringContextHolder.getBean(ParamServiceImpl.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); @@ -85,8 +85,8 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { s = new Socket(ip, port); dos = new DataOutputStream(s.getOutputStream()); dis = new DataInputStream(s.getInputStream()); - System.out.println("1楼NDCAgv链接成功"); - log.info("1楼NDCAgv链接成功"); + System.out.println("NDCAgv链接成功"); + log.info("NDCAgv链接成功"); while (bConnected) { int count = dis.read(b); @@ -210,8 +210,8 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } } catch (Exception e) { - System.out.println("OneAgv链接异常"); - log.info("OneAgv链接异常"); + System.out.println("Agv链接异常"); + log.info("Agv链接异常"); log.error("agv连接出现异常:{}", e); logServer.deviceExecuteLog("1", "", "", "agv异常" + e.getMessage()); logServer.deviceExecuteLog("1", "", "", "agv异常" + e); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDC2SocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDC2SocketConnectionAutoRun.java deleted file mode 100644 index c79eaa7..0000000 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDC2SocketConnectionAutoRun.java +++ /dev/null @@ -1,243 +0,0 @@ -package org.nl.acs.auto.run; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.modules.system.service.ParamService; -import org.nl.modules.system.service.impl.ParamServiceImpl; -import org.nl.modules.wql.util.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.net.Socket; -import java.util.Date; - -import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; - - -@Slf4j -@Component -public class TwoNDC2SocketConnectionAutoRun extends AbstractAutoRunnable { - - Socket s; - String ip = "192.168.46.225"; - int port = 1234; - static DataOutputStream dos; - static DataInputStream dis; - private int recordTimeOut = 10000; - private Date recordTime; - String[] ERROR = new String[]{ - "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", - "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", - "抬叉停止"}; - boolean bConnected = true; - - boolean isReConnect = false; - - @Autowired - ParamService paramService; - @Autowired - AutoRunService autoRunService; - - - public TwoNDC2SocketConnectionAutoRun() { - this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); - } - - public String getCode() { - return TwoNDC2SocketConnectionAutoRun.class.getSimpleName(); - } - - public String getName() { - return "2楼2区域AGV系统"; - } - - public void autoRun() { - - try { - System.out.println("2楼2区域AGV系统链接开始"); - ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - ip = paramService.findByCode(AcsConfig.AGVURL22).getValue(); - port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT22).getValue()); - byte[] b = new byte[1028]; - s = new Socket(ip, port); - System.out.println("2楼2区域AGV链接成功"); - dos = new DataOutputStream(s.getOutputStream()); - dis = new DataInputStream(s.getInputStream()); - - while (bConnected) { - int count = dis.read(b); - - if (count == -1) { - break; - } - - int[] arr = new int[count]; - StringBuffer bs = new StringBuffer(); - - for (int i = 0; i < count; i++) { - int temp = b[i]; - if (temp < 0) - temp += 256; - arr[i] = temp; - StringBuffer bs1 = new StringBuffer("0"); - bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); - } - - System.out.println("收到请求参数:" + bs); - boolean flag = false; - if (arr[8] * 256 + arr[9] == 0x73) { - byte[] data = null; - System.out.println("接收agv上报信息:" + bs); - //执行阶段 - int phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - //任务号 - int ikey = arr[26] * 256 + arr[27]; - //站点号 - int agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - Instruction inst = null; - if (ikey != 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - } - log.info("接收agv上报信息:" + bs); - log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - Device device = null; - String device_code = null; - String old_device_code = null; - String emptyNum = null; - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - device = deviceAppService.findDeviceByCode(device_code); - } - - AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; - //开始任务 - if (phase == 0x01) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("1"); - inst.setAgv_jobno(String.valueOf(index)); - inst.setSend_status("1"); - instructionService.update(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } - flag = true; - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x14) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - inst.setInstruction_status("2"); - instructionService.finish(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } - //请求删除任务 - //(需要WCS反馈) - else if (phase == 0x30) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0); - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - //上报异常信息 - //(不需要WCS反馈) - if(phase == 0x67){ - device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); - } else { - device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); - } - if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); - agvNdcTwoDeviceDriver.processSocket(arr); - } - } - if (!ObjectUtil.isEmpty(data)) { - write(data); - } - - } else { - System.out.println("agv上报不是0073类型动作,不处理"); - } - } - - } catch (Exception e) { - - - } finally { - - - } - - } - - - @Override - public void stop() { - super.after(); - try { - s.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - public static void write(byte[] b) { - try { - log.info("下发agv数据:" + Bytes2HexString(b)); - System.out.println("下发agv数据:" + Bytes2HexString(b)); - dos.write(b); - dos.flush(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } -} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java deleted file mode 100644 index 9224c15..0000000 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java +++ /dev/null @@ -1,245 +0,0 @@ -package org.nl.acs.auto.run; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; -import org.nl.acs.device_driver.basedriver.agv.ndctwo.AgvNdcTwoDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.modules.system.service.ParamService; -import org.nl.modules.system.service.impl.ParamServiceImpl; -import org.nl.modules.wql.util.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.net.Socket; -import java.util.Date; -import java.util.List; - -import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; - - -@Slf4j -@Component -public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { - - Socket s; - String ip = "192.168.46.225"; - int port = 1234; - static DataOutputStream dos; - static DataInputStream dis; - private int recordTimeOut = 10000; - private Date recordTime; - String[] ERROR = new String[]{ - "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", - "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", - "抬叉停止"}; - boolean bConnected = true; - - boolean isReConnect = false; - - @Autowired - ParamService paramService; - @Autowired - AutoRunService autoRunService; - - - public TwoNDCSocketConnectionAutoRun() { - this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); - } - - public String getCode() { - return TwoNDCSocketConnectionAutoRun.class.getSimpleName(); - } - - public String getName() { - return "2楼1区域AGV系统"; - } - - public void autoRun() { - - try { - System.out.println("2楼1区域AGV系统链接开始"); - ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - ip = paramService.findByCode(AcsConfig.AGVURL2).getValue(); - port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue()); - byte[] b = new byte[1028]; - s = new Socket(ip, port); - System.out.println("2楼1区域Agv链接成功"); - dos = new DataOutputStream(s.getOutputStream()); - dis = new DataInputStream(s.getInputStream()); - - while (bConnected) { - int count = dis.read(b); - - if (count == -1) { - break; - } - - int[] arr = new int[count]; - StringBuffer bs = new StringBuffer(); - - for (int i = 0; i < count; i++) { - int temp = b[i]; - if (temp < 0) - temp += 256; - arr[i] = temp; - StringBuffer bs1 = new StringBuffer("0"); - bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); - } - - System.out.println("收到请求参数:" + bs); - boolean flag = false; - if (arr[8] * 256 + arr[9] == 0x73) { - byte[] data = null; - System.out.println("接收agv上报信息:" + bs); - //执行阶段 - int phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - //任务号 - int ikey = arr[26] * 256 + arr[27]; - //站点号 - int agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - Instruction inst = null; - if (ikey != 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - } - log.info("接收agv上报信息:" + bs); - log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - Device device = null; - String device_code = null; - String old_device_code = null; - String emptyNum = null; - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - device = deviceAppService.findDeviceByCode(device_code); - } - - AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; - //开始任务 - if (phase == 0x01) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("1"); - inst.setAgv_jobno(String.valueOf(index)); - inst.setSend_status("1"); - instructionService.update(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } - flag = true; - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x14) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - inst.setInstruction_status("2"); - instructionService.finish(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } - //请求删除任务 - //(需要WCS反馈) - else if (phase == 0x30) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0); - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - //上报异常信息 - //(不需要WCS反馈) - if(phase == 0x67){ - device = deviceAppService.findDeviceByCode(Integer.toString(arr[27])); - } else { - device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); - } - if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); - agvNdcTwoDeviceDriver.processSocket(arr); - } - } - if (!ObjectUtil.isEmpty(data)) { - write(data); - } - - } else { - System.out.println("agv上报不是0073类型动作,不处理"); - } - } - - } catch (Exception e) { - - - } finally { - - - } - - } - - - @Override - public void stop() { - super.after(); - try { - s.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - public static void write(byte[] b) { - try { - log.info("下发agv数据:" + Bytes2HexString(b)); - System.out.println("下发agv数据:" + Bytes2HexString(b)); - dos.write(b); - dos.flush(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } -} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java index 1965d29..8a77cad 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndctwo/AgvNdcTwoDeviceDriver.java @@ -6,8 +6,6 @@ import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.auto.run.TwoNDC2SocketConnectionAutoRun; -import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; @@ -468,11 +466,11 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic } if (!ObjectUtil.isEmpty(data)) { logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - if (StrUtil.equals(inst.getAgv_system_type(), "2")) { - TwoNDCSocketConnectionAutoRun.write(data); - } else if (StrUtil.equals(inst.getAgv_system_type(), "3")) { - TwoNDC2SocketConnectionAutoRun.write(data); - } +// if (StrUtil.equals(inst.getAgv_system_type(), "2")) { +// TwoNDCSocketConnectionAutoRun.write(data); +// } else if (StrUtil.equals(inst.getAgv_system_type(), "3")) { +// TwoNDC2SocketConnectionAutoRun.write(data); +// } } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskRequest.java index e2aea4c..76b324a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskRequest.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CancelTaskRequest.java @@ -2,16 +2,12 @@ package org.nl.acs.ext.wms.data; import lombok.Data; +import java.util.HashMap; import java.util.Map; @Data public class CancelTaskRequest extends BaseRequest { - /** - * 任务标识 - */ - private String ext_task_id; - /** * 任务编号 */ @@ -25,6 +21,14 @@ public class CancelTaskRequest extends BaseRequest { /** * 扩展属性 */ - Map params; - + Map params = new HashMap<>(); + + @Override + public String toString() { + return "CancelTaskRequest{" + + "task_code='" + task_code + '\'' + + ", vehicle_code='" + vehicle_code + '\'' + + ", params=" + params + + '}'; + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java index 5ec4d37..687b419 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java @@ -2,15 +2,13 @@ package org.nl.acs.ext.wms.data; import lombok.Data; +import java.util.HashMap; import java.util.Map; @Data public class CreateTaskRequest extends BaseRequest { - /** - * 任务标识 - */ - private String ext_task_id; + /** * 任务编号 @@ -28,25 +26,10 @@ public class CreateTaskRequest extends BaseRequest { */ String next_device_code; - /** - * 取货点2 - */ - String start_device_code2; - - /** - * 放货点2 - */ - String next_device_code2; - - /** - * 烘箱对接位 - */ - String put_device_code; - /** * 优先级 */ - String priority; + String priority = "1"; /** * 载具号 @@ -58,55 +41,35 @@ public class CreateTaskRequest extends BaseRequest { */ String vehicle_type; - /** - * 路由方案 - */ - String route_plan_code; /** - * 1、生箔; - * 2、分切 - * 3、普通任务 - * 4、叉车任务 - * 5、输送任务 - * 6、行架 - * 7、立库 * 任务类型 */ String task_type; - /** - * 立库任务类型 - * - */ - String dtl_type; - - /** - * Agv系统类型 - * 1:1楼叉车系统 - * 2:2楼1区域AGV系统 - * 3:2楼2区域AGV系统 - */ - String agv_system_type; /** * 备注 */ String remark; - /** - * 烘箱时间 - */ - String oven_time; - - /** - * 烘箱温度 - */ - String temperature; - /** * 扩展属性 */ - Map params; - + Map params = new HashMap<>(); + + @Override + public String toString() { + return "CreateTaskRequest{" + + "task_code='" + task_code + '\'' + + ", start_device_code='" + start_device_code + '\'' + + ", next_device_code='" + next_device_code + '\'' + + ", priority='" + priority + '\'' + + ", vehicle_code='" + vehicle_code + '\'' + + ", vehicle_type='" + vehicle_type + '\'' + + ", task_type='" + task_type + '\'' + + ", remark='" + remark + '\'' + + ", params=" + params + + '}'; + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index 47c5a88..d44ee5d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -8,6 +8,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.ext.wms.data.CancelTaskRequest; +import org.nl.acs.ext.wms.data.CreateTaskRequest; import org.nl.acs.ext.wms.data.CreateTaskResponse; import org.nl.acs.ext.wms.service.WmsToAcsService; import org.nl.modules.logging.InterfaceLogType; @@ -19,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * @author ludj * @date 2021-07-21 @@ -35,16 +39,16 @@ public class WmsToAcsController { @Log(value = "ACS接收WMS任务",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) @ApiOperation("接收WMS任务") @SaIgnore - public ResponseEntity createFromWms(@RequestBody String whereJson) { - return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK); + public ResponseEntity createFromWms(@RequestBody List reqs) { + return new ResponseEntity<>(wmstoacsService.crateTask(reqs), HttpStatus.OK); } @PostMapping("/cancelTask") @Log(value = "WMS取消任务",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) @ApiOperation("WMS取消任务") @SaIgnore - public ResponseEntity cancelFromWms(@RequestBody String whereJson) throws Exception { - return new ResponseEntity<>(wmstoacsService.cancelFromWms(whereJson), HttpStatus.OK); + public ResponseEntity cancelFromWms(@RequestBody List reqs) throws Exception { + return new ResponseEntity<>(wmstoacsService.cancelFromWms(reqs), HttpStatus.OK); } @PostMapping("/updateDeviceGoodsFromWms") diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index a9125cc..e86d747 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -3,28 +3,27 @@ package org.nl.acs.ext.wms.service; import com.alibaba.fastjson.JSONObject; -import org.nl.acs.ext.wms.data.CancelTaskResponse; -import org.nl.acs.ext.wms.data.CreateTaskResponse; -import org.nl.acs.ext.wms.data.PutActionResponse; +import org.nl.acs.ext.wms.data.*; +import java.util.List; import java.util.Map; public interface WmsToAcsService { /** * 创建任务 - * @param whereJson + * @param reqs * @return */ - CreateTaskResponse crateTask(String whereJson); + CreateTaskResponse crateTask(List reqs); /** * 取消任务 * - * @param jsonObject 条件 + * @param reqs 条件 */ - CancelTaskResponse cancelFromWms(String jsonObject) throws Exception; + CancelTaskResponse cancelFromWms(List reqs) throws Exception; /** * 修改设置有无货属性 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 20d6515..ecc9b90 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -1,7 +1,9 @@ package org.nl.acs.ext.wms.service.impl; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONString; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -62,33 +64,27 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { private String log_type = "LMS请求ACS"; @Override - public CancelTaskResponse cancelFromWms(String param) throws Exception { + public CancelTaskResponse cancelFromWms(List reqs) throws Exception { ParamService paramService = SpringContextHolder.getBean(ParamService.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - JSONArray datas = JSONArray.parseArray(param); CancelTaskResponse response = new CancelTaskResponse(); JSONArray errArr = new JSONArray(); - for (int i = 0; i < datas.size(); i++) { - String data = datas.get(i).toString(); - CancelTaskRequest request = JsonUtl.format(param, CancelTaskRequest.class); - - String task_uuid = request.getExt_task_id(); + for (int i = 0; i < reqs.size(); i++) { + CancelTaskRequest request = reqs.get(i); String task_code = request.getTask_code(); String vehicle_code = request.getVehicle_code(); - - if (StrUtil.isEmpty(task_uuid)) { - throw new WDKException("任务标识不能为空"); - } + Map params = request.getParams(); if (StrUtil.isEmpty(task_code)) { throw new WDKException("任务号不能为空"); } + TaskDto taskDto = taskService.findByCodeFromCache(task_code); String cancelTaskCheck = paramService.findByCode(AcsConfig.CANCELTASKCHECK).getValue(); if (StrUtil.equals(cancelTaskCheck, "1")) { - taskService.cancel(task_uuid); + taskService.cancelNoSendWms(taskDto.getTask_id()); } else if (StrUtil.equals(cancelTaskCheck, "0")) { Instruction inst = instructionService.findByTaskcode(task_code); if (inst == null) { - taskService.cancel(task_uuid); + taskService.cancelNoSendWms(taskDto.getTask_id()); } else { throw new RuntimeException("指令正在执行中,操作失败!"); } @@ -456,47 +452,29 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override - public CreateTaskResponse crateTask(String param) { + public CreateTaskResponse crateTask(List reqs) { try { MDC.put(log_file_type, log_type); - log.info("crateTask-----输入参数{}", param); - JSONArray datas = JSONArray.parseArray(param); + log.info("crateTask-----输入参数{}", reqs); CreateTaskResponse response = new CreateTaskResponse(); JSONArray errArr = new JSONArray(); - for (int i = 0; i < datas.size(); i++) { - String data = datas.get(i).toString(); - CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class); - String ext_task_id = request.getExt_task_id(); - String task_code = request.getTask_code(); - String start_device_code = request.getStart_device_code(); - String start_device_code2 = request.getStart_device_code2(); - String next_device_code = request.getNext_device_code(); - String next_device_code2 = request.getNext_device_code2(); - String put_device_code = request.getPut_device_code(); - String priority = request.getPriority(); - String vehicle_code = request.getVehicle_code(); - String vehicle_type = request.getVehicle_type(); - String route_plan_code = request.getRoute_plan_code(); - String task_type = request.getTask_type(); - String storage_task_type = request.getDtl_type(); - String agv_system_type = request.getAgv_system_type(); - String remark = request.getRemark(); - double oven_time = 0.00d; - if (StrUtil.isNotEmpty(request.getOven_time())) { - oven_time = Double.parseDouble(request.getOven_time()); - } - String temperature = request.getTemperature(); - Map params = request.getParams(); + for (int i = 0; i < reqs.size(); i++) { + CreateTaskRequest req = reqs.get(i); + String task_code = req.getTask_code(); + String start_device_code = req.getStart_device_code(); + String next_device_code = req.getNext_device_code(); + String priority = req.getPriority(); + String vehicle_code = req.getVehicle_code(); + String vehicle_type = req.getVehicle_type(); + String task_type = req.getTask_type(); + String remark = req.getRemark(); + Map params = req.getParams(); String start_point_code = ""; - String start_point_code2 = ""; String next_point_code = ""; - String next_point_code2 = ""; - String put_point_code = ""; if (StrUtil.isEmpty(task_code)) { JSONObject json = new JSONObject(); json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); json.put("message", "任务号不能为空"); errArr.add(json); continue; @@ -504,7 +482,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (StrUtil.isEmpty(start_device_code)) { JSONObject json = new JSONObject(); json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); json.put("message", "起点不能为空"); errArr.add(json); continue; @@ -512,13 +489,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (StrUtil.isEmpty(next_device_code)) { JSONObject json = new JSONObject(); json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); json.put("message", "终点不能为空"); errArr.add(json); continue; } - - JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0); if (!ObjectUtil.isEmpty(start_device_json)) { start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code"); @@ -527,18 +501,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (!ObjectUtil.isEmpty(next_device_json)) { next_point_code = (String) next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("storage_code"); } - JSONObject start_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code2 + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(start_device_json2)) { - start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_device_code2 : (String) start_device_json2.get("storage_code"); - } - JSONObject next_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_code2 + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(next_device_json2)) { - next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_device_code2 : (String) next_device_json2.get("storage_code"); - } - JSONObject put_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + put_device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(put_device_json)) { - put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_device_code : (String) put_device_json.get("storage_code"); - } if (StrUtil.isNotEmpty(start_point_code) && start_point_code.indexOf("-") > 0) { String str[] = start_point_code.split("-"); start_device_code = str[0]; @@ -553,44 +515,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { next_device_code = next_point_code; } - if (StrUtil.isNotEmpty(start_point_code2) && start_point_code2.indexOf("-") > 0) { - String str[] = start_point_code2.split("-"); - start_device_code2 = str[0]; - } else { - start_device_code2 = start_point_code2; - } - - if (StrUtil.isNotEmpty(next_point_code2) && next_point_code2.indexOf("-") > 0) { - String str[] = next_point_code2.split("-"); - next_device_code2 = str[0]; - } else { - next_device_code2 = next_point_code2; - } - - if (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) { - String str[] = put_point_code.split("-"); - put_device_code = str[0]; - } else { - put_device_code = put_point_code; - } + String route_plan_code = ""; if (StrUtil.isEmpty(route_plan_code)) { route_plan_code = "normal"; } - -// if( StrUtil.equals(task_type,"5") && taskService.querySameDeviceReadyTask(start_device_code,next_device_code,"0") > 1){ -// JSONObject json = new JSONObject(); -// json.put("task_code", task_code); -// json.put("ext_task_id", ext_task_id); -// json.put("message", "已存在相同的起点终点未执行的输送任务"); -// errArr.add(json); -// continue; -// } TaskDto taskDto = taskService.findByCodeFromCache(task_code); if (taskDto != null) { JSONObject json = new JSONObject(); json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); json.put("message", "不能存在相同的任务号"); errArr.add(json); continue; @@ -600,7 +533,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (vehicle_dto != null) { JSONObject json = new JSONObject(); json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); json.put("message", "不能存在相同的托盘号"); errArr.add(json); continue; @@ -610,52 +542,35 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (StrUtil.isEmpty(start_point_code)) { JSONObject json = new JSONObject(); json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", request.getStart_device_code() + " 该设备号未找到对应点位"); + json.put("message", req.getStart_device_code() + " 该设备号未找到对应点位"); errArr.add(json); continue; } if (StrUtil.isEmpty(next_point_code)) { JSONObject json = new JSONObject(); json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", request.getNext_device_code() + " 该设备号未找到对应点位"); + json.put("message", req.getNext_device_code() + " 该设备号未找到对应点位"); errArr.add(json); continue; } JSONObject jo = new JSONObject(); jo.put("task_code", task_code); - jo.put("task_id", ext_task_id); + jo.put("task_id", IdUtil.simpleUUID()); jo.put("start_point_code", start_point_code); jo.put("next_point_code", next_point_code); - jo.put("start_point_code2", start_point_code2); - jo.put("next_point_code2", next_point_code2); - jo.put("put_point_code", put_point_code); jo.put("start_parent_code", start_point_code); jo.put("next_parent_code", next_point_code); jo.put("start_device_code", start_device_code); jo.put("next_device_code", next_device_code); - jo.put("start_device_code2", start_device_code2); - jo.put("next_device_code2", next_device_code2); - jo.put("put_device_code", put_device_code); jo.put("priority", priority); jo.put("vehicle_code", vehicle_code); jo.put("vehicle_type", vehicle_type); - jo.put("storage_task_type", storage_task_type); - if (StrUtil.isEmpty(agv_system_type)) { - agv_system_type = "1"; - } - jo.put("agv_system_type", agv_system_type); - jo.put("oven_time", (int) Math.ceil(oven_time)); + jo.put("agv_system_type", "1"); jo.put("remark", remark); jo.put("params", params); jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type)); - if (!StrUtil.isEmpty(ext_task_id)) { - jo.put("ext_task_id", ext_task_id); - } - TaskDto task_dto = jo.toJavaObject(TaskDto.class); try { taskService.create(task_dto); @@ -663,7 +578,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { // e.printStackTrace(); JSONObject json = new JSONObject(); json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); json.put("message", e.getMessage()); errArr.add(json); continue; @@ -682,7 +596,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { response.setErrArr(errArr); } log.info("createFromWms--------------:输出参数:" + JSON.toJSONString(response)); - return response; } finally { MDC.remove(log_file_type); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java index 2acbb63..44fbc41 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java @@ -187,6 +187,14 @@ public interface TaskService { */ void cancel(String ids) throws Exception; + + /** + * 取消任务 + * + * @param ids + */ + void cancelNoSendWms(String ids) throws Exception; + /** * 手动创建指令 * diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 1077f64..e5f42b2 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -974,6 +974,53 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } } + @Override + @Transactional(rollbackFor = Exception.class) + public void cancelNoSendWms(String id) throws Exception { + TaskDto entity = this.findById(id); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); + } + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); + if (instdto != null) { + throw new BadRequestException("有指令未完成!"); + } + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setTask_status("3"); + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + +// synchronized (TaskServiceImpl.class){ +// Iterator it = tasks.iterator(); +// // 清理缓存 +// while (it.hasNext()) { +// TaskDto taskDto = it.next(); +// if (taskDto.getTask_id().equals(id)) { +// tasks.remove(taskDto); +// } +// }} + + removeByCodeFromCache(entity.getTask_code()); + + List shortPathsList = + routeLineService.getShortPathLines( + entity.getStart_device_code(), + entity.getNext_device_code(), + entity.getRoute_plan_code()); + String type = shortPathsList.get(0).getType(); + // != 0 为agv任务 + if (!StrUtil.equals(type, "0")) { + if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { + agvService.markComplete(entity.getTask_code()); + } + } + } + @Override public Instruction createTemporaryInst(TaskDto acsTask) { if (acsTask == null) { @@ -1189,29 +1236,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { instdto.setNext_device_code2(next_point_code2); instdto.setNext_point_code2(next_point_code2); instdto.setAgv_system_type(agv_system_type); - // 判断agv系统 - // 1、1楼叉车系统 - // 2、2楼1区域AGV系统 - // 3、2楼2区域AGV系统 - if (!StrUtil.equals(agv_system_type, "1")) { - // task_type - // 1、生箔; Itype=1:取空,取满,放空,放满; - // 2、分切 Itype=3取满、取空、放满、放空; - // 3、普通任务 Itype=2:取货、放货; - // 4、叉车任务 - // 5、输送任务 - // 6、行架 - // 7、立库 - if (StrUtil.equals(task_type, "1")) { - instdto.setAgv_inst_type("1"); - } else if (StrUtil.equals(task_type, "3")) { - instdto.setAgv_inst_type("2"); - } else if (StrUtil.equals(task_type, "2")) { - instdto.setAgv_inst_type("3"); - } - } else { - instdto.setAgv_inst_type("4"); - } + instdto.setAgv_inst_type("1"); instructionservice.create2(instdto); // acsTask.setTask_status("1"); diff --git a/acs/nladmin-system/src/main/resources/config/application-prod.yml b/acs/nladmin-system/src/main/resources/config/application-prod.yml index e6113d9..e22d641 100644 --- a/acs/nladmin-system/src/main/resources/config/application-prod.yml +++ b/acs/nladmin-system/src/main/resources/config/application-prod.yml @@ -1,5 +1,5 @@ server: - port: 8011 + port: 8010 tomcat: accept-count: 1000 max-connections: 10000 diff --git a/acs/nladmin-ui/src/views/acs/task/index.vue b/acs/nladmin-ui/src/views/acs/task/index.vue index 51704cc..8302850 100644 --- a/acs/nladmin-ui/src/views/acs/task/index.vue +++ b/acs/nladmin-ui/src/views/acs/task/index.vue @@ -491,7 +491,7 @@ export default { to_x: null, to_y: null, to_z: null, - agv_system_type: '' + agv_system_type: '1' }, rules: { start_point_code: [