opt:1.一个设备点变更成两个AGV站点。2.增加手持功能。

This commit is contained in:
2025-11-18 20:30:04 +08:00
parent 02a82ca02e
commit d798fd1db9
14 changed files with 438 additions and 352 deletions

View File

@@ -418,11 +418,23 @@
<groupId>org.openscada.jinterop</groupId> <groupId>org.openscada.jinterop</groupId>
<artifactId>org.openscada.jinterop.core</artifactId> <artifactId>org.openscada.jinterop.core</artifactId>
<version>2.1.8</version> <version>2.1.8</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.openscada.jinterop</groupId> <groupId>org.openscada.jinterop</groupId>
<artifactId>org.openscada.jinterop.deps</artifactId> <artifactId>org.openscada.jinterop.deps</artifactId>
<version>1.5.0</version> <version>1.5.0</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.openscada.utgard</groupId> <groupId>org.openscada.utgard</groupId>

View File

@@ -1,330 +1,330 @@
package org.nl.acs.auto.run; //package org.nl.acs.auto.run;
import cn.hutool.core.util.ObjectUtil; //import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils; //import org.apache.commons.lang3.ArrayUtils;
import org.nl.acs.AcsConfig; //import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.NDCAgvService; //import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.device.domain.Device; //import org.nl.acs.device.domain.Device;
import org.nl.acs.device.service.DeviceService; //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.ndcone.AgvNdcOneDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService; //import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; //import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.domain.Instruction; //import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService; //import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.impl.InstructionServiceImpl; //import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
import org.nl.acs.log.service.DeviceExecuteLogService; //import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.DeviceAppService; //import org.nl.acs.opc.DeviceAppService;
import org.nl.config.SpringContextHolder; //import org.nl.config.SpringContextHolder;
import org.nl.system.service.dict.ISysDictService; //import org.nl.system.service.dict.ISysDictService;
import org.nl.system.service.lucene.LuceneExecuteLogService; //import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.param.ISysParamService; //import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.impl.SysParamServiceImpl; //import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; //import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
//
import java.io.DataInputStream; //import java.io.DataInputStream;
import java.io.DataOutputStream; //import java.io.DataOutputStream;
import java.io.IOException; //import java.io.IOException;
import java.net.Socket; //import java.net.Socket;
import java.util.Arrays; //import java.util.Arrays;
import java.util.Date; //import java.util.Date;
import java.util.List; //import java.util.List;
import java.util.stream.IntStream; //import java.util.stream.IntStream;
//
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; //import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
//
//
@Slf4j //@Slf4j
@Component //@Component
@Lazy //@Lazy
public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { //public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//
Socket s; // Socket s;
String ip = "192.168.10.34"; // String ip = "192.168.10.34";
int port = 1234; // int port = 1234;
static DataOutputStream dos; // static DataOutputStream dos;
static DataInputStream dis; // static DataInputStream dis;
private int recordTimeOut = 10000; // private int recordTimeOut = 10000;
private Date recordTime; // private Date recordTime;
String[] ERROR = new String[]{ // String[] ERROR = new String[]{
"货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", // "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位",
"停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", // "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位",
"抬叉停止"}; // "抬叉停止"};
boolean bConnected = true; // boolean bConnected = true;
//
boolean isReConnect = false; // boolean isReConnect = false;
//
@Autowired // @Autowired
ISysParamService paramService; // ISysParamService paramService;
@Autowired // @Autowired
AutoRunService autoRunService; // AutoRunService autoRunService;
@Autowired // @Autowired
LuceneExecuteLogService luceneExecuteLogService; // LuceneExecuteLogService luceneExecuteLogService;
@Autowired // @Autowired
ISysDictService dictService; // ISysDictService dictService;
//
//
public TwoNDCSocketConnectionAutoRun() { // public TwoNDCSocketConnectionAutoRun() {
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); // this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
} // }
//
public String getCode() { // public String getCode() {
return TwoNDCSocketConnectionAutoRun.class.getSimpleName(); // return TwoNDCSocketConnectionAutoRun.class.getSimpleName();
} // }
//
public String getName() { // public String getName() {
return "NDC2在线连接"; // return "NDC2在线连接";
} // }
//
//todo NDC相关逻辑 // //todo NDC相关逻辑
public void autoRun() throws IOException { // public void autoRun() throws IOException {
System.out.println("TwoNDCAgv链接开始"); // System.out.println("TwoNDCAgv链接开始");
ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class); // ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); // InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); // AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class); // NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class);
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); // DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); // DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); // DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
ip = paramService.findByCode(AcsConfig.AGVURL).getValue(); // ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue()); // port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
//
//
try { // try {
byte[] b = new byte[1024]; // byte[] b = new byte[1024];
s = new Socket(ip, port); // s = new Socket(ip, port);
dos = new DataOutputStream(s.getOutputStream()); // dos = new DataOutputStream(s.getOutputStream());
dis = new DataInputStream(s.getInputStream()); // dis = new DataInputStream(s.getInputStream());
System.out.println("TwoNDCAgv链接成功"); // System.out.println("TwoNDCAgv链接成功");
log.info("TwoNDC2Agv链接成功"); // log.info("TwoNDC2Agv链接成功");
while (bConnected) { // while (bConnected) {
int count = dis.read(b); // int count = dis.read(b);
//
if (count == -1) { // if (count == -1) {
break; // break;
} // }
//
int[] packetData = new int[count]; // int[] packetData = new int[count];
StringBuffer bs = new StringBuffer(); // StringBuffer bs = new StringBuffer();
//
for (int i = 0; i < count; i++) { // for (int i = 0; i < count; i++) {
int temp = b[i]; // int temp = b[i];
if (temp < 0) // if (temp < 0)
temp += 256; // temp += 256;
packetData[i] = temp; // packetData[i] = temp;
StringBuffer bs1 = new StringBuffer("0"); // StringBuffer bs1 = new StringBuffer("0");
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); // bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
} // }
log.info("接收agv上报状态信息" + bs); // log.info("接收agv上报状态信息" + bs);
// 从字节流的开头开始读取 // // 从字节流的开头开始读取
int offset = 0; // int offset = 0;
// 循环处理字节流,逐个拆包 按照S消息解析 // // 循环处理字节流,逐个拆包 按照S消息解析
while (offset < packetData.length) { // while (offset < packetData.length) {
if (offset + 6 > packetData.length) { // if (offset + 6 > packetData.length) {
System.out.println("错误:没有足够的字节来读取长度字段。"); // System.out.println("错误:没有足够的字节来读取长度字段。");
break; // break;
} // }
int messageHeader = packetData[offset] * 256 + packetData[offset+1]; // int messageHeader = packetData[offset] * 256 + packetData[offset+1];
//检测消息头是否有效 // //检测消息头是否有效
if (messageHeader == 0x87CD){ // if (messageHeader == 0x87CD){
//消息头长度 // //消息头长度
int messageHeaderLength = packetData[offset+2] * 256 + packetData[offset+3]; // int messageHeaderLength = packetData[offset+2] * 256 + packetData[offset+3];
//消息数据长度 // //消息数据长度
int messageDataLength = packetData[offset+4] * 256 + packetData[offset+5]; // int messageDataLength = packetData[offset+4] * 256 + packetData[offset+5];
//消息总长度 // //消息总长度
int messageLength = messageHeaderLength + messageDataLength; // int messageLength = messageHeaderLength + messageDataLength;
// 检查剩余字节是否足够处理完整的数据包 // // 检查剩余字节是否足够处理完整的数据包
if (offset + messageLength > packetData.length) { // if (offset + messageLength > packetData.length) {
// System.out.println("错误:检测到不完整的数据包。"); //// System.out.println("错误:检测到不完整的数据包。");
log.info("错误:检测到不完整的数据包"); // log.info("错误:检测到不完整的数据包");
// 数据包不完整,停止处理 // // 数据包不完整,停止处理
break; // break;
} // }
int[] arr = Arrays.copyOfRange(packetData, offset, offset+messageLength); // int[] arr = Arrays.copyOfRange(packetData, offset, offset+messageLength);
boolean flag = false; // boolean flag = false;
if (arr[8] * 256 + arr[9] == 0x73) { // if (arr[8] * 256 + arr[9] == 0x73) {
byte[] data = null; // byte[] data = null;
System.out.println("接收agv上报信息" + bs); // System.out.println("接收agv上报信息" + bs);
//执行阶段 // //执行阶段
int phase = arr[16] * 256 + arr[17]; // int phase = arr[16] * 256 + arr[17];
// agv任务号 // // agv任务号
int index = arr[12] * 256 + arr[13]; // int index = arr[12] * 256 + arr[13];
//任务号 // //任务号
int ikey = arr[26] * 256 + arr[27]; // int ikey = arr[26] * 256 + arr[27];
//站点号 // //站点号
int agvaddr = arr[18] * 256 + arr[19]; // int agvaddr = arr[18] * 256 + arr[19];
//车号 // //车号
int carno = arr[20]; // int carno = arr[20];
//充电桩站点号 // //充电桩站点号
int station = arr[25]; // int station = arr[25];
Instruction link_inst = null; // Instruction link_inst = null;
Instruction inst = null; // Instruction inst = null;
List<Instruction> insts = null; // List<Instruction> insts = null;
boolean link_flag = false; // boolean link_flag = false;
Device agv_device = null; // Device agv_device = null;
if (carno != 0) { // if (carno != 0) {
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); // agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
} // }
if (ikey != 0) { // if (ikey != 0) {
inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); // inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
if (ObjectUtil.isEmpty(inst)) { // if (ObjectUtil.isEmpty(inst)) {
inst = instructionService.findByCode(String.valueOf(ikey)); // inst = instructionService.findByCode(String.valueOf(ikey));
} // }
} // }
if (!ObjectUtil.isEmpty(link_inst)) { // if (!ObjectUtil.isEmpty(link_inst)) {
link_flag = true; // link_flag = true;
} // }
log.info("接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); // log.info("接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
Device device = null; // Device device = null;
String device_code = null; // String device_code = null;
//
//
// // //
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; // AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
//
//开始任务/上报订单号 // //开始任务/上报订单号
if (phase == 0x01) { // if (phase == 0x01) {
if (!ObjectUtil.isEmpty(inst)) { // if (!ObjectUtil.isEmpty(inst)) {
inst.setInstruction_status("1"); // inst.setInstruction_status("1");
inst.setAgv_jobno(String.valueOf(index)); // inst.setAgv_jobno(String.valueOf(index));
inst.setSend_status("1"); // inst.setSend_status("1");
instructionService.update(inst); // instructionService.update(inst);
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); // data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
} // }
} // }
//任务完毕 // //任务完毕
//无车id及状态 // //无车id及状态
else if (phase == 0x0A) { // else if (phase == 0x0A) {
if (!ObjectUtil.isEmpty(inst)) { // if (!ObjectUtil.isEmpty(inst)) {
instructionService.finish(inst.getInstruction_id()); // instructionService.finish(inst.getInstruction_id());
} else { // } else {
log.warn("指令号:{},未反馈wms任务完成因为agv上报指令号查询指令为空!"); // log.warn("指令号:{},未反馈wms任务完成因为agv上报指令号查询指令为空!");
} // }
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); // data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
log.info("指令号:{},已反馈agv任务完成!"); // log.info("指令号:{},已反馈agv任务完成!");
} // }
//todo 检查协议里删除任务流程有很多个步骤,在哪体现的 // //todo 检查协议里删除任务流程有很多个步骤,在哪体现的
//(需要WCS反馈) // //(需要WCS反馈)
else if (phase == 0x30) { // else if (phase == 0x30) {
data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0); // data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0);
} // }
//任务删除确认 // //任务删除确认
//(需要WCS反馈) // //(需要WCS反馈)
else if (phase == 0xFF) { // else if (phase == 0xFF) {
//
if (!ObjectUtil.isEmpty(inst)) { // if (!ObjectUtil.isEmpty(inst)) {
if (!ObjectUtil.isEmpty(inst)) { // if (!ObjectUtil.isEmpty(inst)) {
instructionService.cancelNOSendAgv(inst.getInstruction_id()); // instructionService.cancelNOSendAgv(inst.getInstruction_id());
} // }
} // }
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0); // data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
} else { // } else {
//上报异常信息 // //上报异常信息
//不需要WCS反馈 // //不需要WCS反馈
if (phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74 || phase == 0x75 || phase == 0x76 || phase == 0x77) { // if (phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74 || phase == 0x75 || phase == 0x76 || phase == 0x77) {
device = deviceAppService.findDeviceByCode(String.valueOf(agvaddr)); // device = deviceAppService.findDeviceByCode(String.valueOf(agvaddr));
} else { // } else {
//todo NDC根据车辆编号123456进行查找特定车辆 // //todo NDC根据车辆编号123456进行查找特定车辆
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); // device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
} // }
if (ObjectUtil.isNotEmpty(device)) { // if (ObjectUtil.isNotEmpty(device)) {
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { // if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); // agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
try { // try {
// agvNdcOneDeviceDriver.processSocket2(arr); //// agvNdcOneDeviceDriver.processSocket2(arr);
}catch (Exception e){ // }catch (Exception e){
log.error("处理phase:{},发生异常。异常信息:{}",phase,e.getMessage()); // log.error("处理phase:{},发生异常。异常信息:{}",phase,e.getMessage());
} // }
} // }
} // }
//
} // }
if (!ObjectUtil.isEmpty(data)) { // if (!ObjectUtil.isEmpty(data)) {
write(data); // write(data);
} // }
// 更新偏移量,继续处理下一个数据包 // // 更新偏移量,继续处理下一个数据包
offset+=messageLength; // offset+=messageLength;
} else { // } else {
log.info("agv上报不是0073类型动作不处理"); // log.info("agv上报不是0073类型动作不处理");
// 更新偏移量,继续处理下一个数据包 // // 更新偏移量,继续处理下一个数据包
offset+=messageHeaderLength; // offset+=messageHeaderLength;
// ArrayUtils.indexOf() //// ArrayUtils.indexOf()
int index = IntStream.range(offset, packetData.length-1) // int index = IntStream.range(offset, packetData.length-1)
.filter(i -> packetData[i] == 135 && packetData[i + 1] == 205) // .filter(i -> packetData[i] == 135 && packetData[i + 1] == 205)
.findFirst() // .findFirst()
.orElse(-1); // .orElse(-1);
// 如果未找到,返回 -1 // // 如果未找到,返回 -1
if (index == -1) { // if (index == -1) {
break; // break;
}else { // }else {
offset = index; // offset = index;
} // }
} // }
}else { // }else {
log.info("消息头无效,不处理。"); // log.info("消息头无效,不处理。");
int index = IntStream.range(offset, packetData.length-1) // int index = IntStream.range(offset, packetData.length-1)
.filter(i -> packetData[i] == 135 && packetData[i + 1] == 205) // .filter(i -> packetData[i] == 135 && packetData[i + 1] == 205)
.findFirst() // .findFirst()
.orElse(-1); // .orElse(-1);
if (index == -1) { // if (index == -1) {
break; // break;
}else { // }else {
offset = index; // offset = index;
} // }
} // }
} // }
} // }
//
} catch (Exception e) { // } catch (Exception e) {
System.out.println("Agv链接异常"); // System.out.println("Agv链接异常");
log.info("Agv链接异常"); // log.info("Agv链接异常");
log.error("agv连接出现异常:{}", e); // log.error("agv连接出现异常:{}", e);
if (ObjectUtil.isNotEmpty(s)) { // if (ObjectUtil.isNotEmpty(s)) {
s.close(); // s.close();
} // }
System.out.println(e.getMessage()); // System.out.println(e.getMessage());
e.printStackTrace(); // e.printStackTrace();
//
} finally { // } finally {
//
//
} // }
//
} // }
//
//
@Override // @Override
public void stop() { // public void stop() {
super.after(); // super.after();
try { // try {
s.close(); // s.close();
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//
//
public static void write(byte[] b) { // public static void write(byte[] b) {
try { // try {
log.info("下发agv数据:" + Bytes2HexString(b)); // log.info("下发agv数据:" + Bytes2HexString(b));
System.out.println("下发agv数据:" + Bytes2HexString(b)); // System.out.println("下发agv数据:" + Bytes2HexString(b));
dos.write(b); // dos.write(b);
dos.flush(); // dos.flush();
} catch (IOException e) { // } catch (IOException e) {
// TODO Auto-generated catch block // // TODO Auto-generated catch block
try { // try {
Thread.sleep(5000L); // Thread.sleep(5000L);
log.error("tofix下发agv数据失败再次下发再次下发agv数据:" + Bytes2HexString(b) + "失败原因:" + e.getMessage()); // log.error("tofix下发agv数据失败再次下发再次下发agv数据:" + Bytes2HexString(b) + "失败原因:" + e.getMessage());
System.out.println("再次下发agv数据:" + Bytes2HexString(b)); // System.out.println("再次下发agv数据:" + Bytes2HexString(b));
dos.write(b); // dos.write(b);
dos.flush(); // dos.flush();
} catch (Exception e1) { // } catch (Exception e1) {
log.error("tofix下发agv数据失败再次下发下发agv数据:" + Bytes2HexString(b) + "失败原因:" + e1.getMessage()); // log.error("tofix下发agv数据失败再次下发下发agv数据:" + Bytes2HexString(b) + "失败原因:" + e1.getMessage());
e1.printStackTrace(); // e1.printStackTrace();
} // }
//
} // }
} // }
} //}
//

View File

@@ -19,6 +19,7 @@ public enum ResponseWMSTaskStatusEnum {
*/ */
BUSY("1", 20, "任务执行中"), BUSY("1", 20, "任务执行中"),
CANCEL("3", 30, "取消任务"), CANCEL("3", 30, "取消任务"),
WAITING_FOR_EXECUTION("4", 10, "等待执行中"),
PICKUP_COMPLETED("5", 50, "取货完成"), PICKUP_COMPLETED("5", 50, "取货完成"),
FINISHED("2", 100, "完成"); FINISHED("2", 100, "完成");

View File

@@ -10,6 +10,7 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.ISysParamService; import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.impl.SysParamServiceImpl; import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.springframework.beans.factory.annotation.Value;
/** /**
* ACS连接外部系统工具类: * ACS连接外部系统工具类:
@@ -17,6 +18,8 @@ import org.nl.system.service.param.impl.SysParamServiceImpl;
@Slf4j @Slf4j
public class LmsUtil { public class LmsUtil {
private final static String wmsToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJXQ1MiLCJpc3MiOiJ3bXMtY29yZSIsImV4cCI6NDA4MzIxMTcyMiwiaWF0IjoxNzE2NTMyNDAxLCJvcGVyYXRvciI6ImFkbWluIiwianRpIjoiMGFiZDI0NDItZjAxOS00MWUyLWIzMGYtNTA1NjQ4OGFkYzE1In0.iKmQM78JArRyPLJmZiHQb-pMWFbCE-fDcbppEDYNCj8TSMSQNNXeYA1SOD8QNUp4SpGME4qrPmJ-jpq_iNbgNLRbTciaymliNyWEAhf2Ozu91EPWUlhVvtEOlWPOAbhm8CH-75Ctz93nNwJ7jyzl796mfbUbz_uFFLAhn677NVs";
public static <W> String notifyAcs(String api, W requestParam) { public static <W> String notifyAcs(String api, W requestParam) {
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);; DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);;
ISysParamService paramService = SpringContextHolder.getBean(SysParamServiceImpl.class); ISysParamService paramService = SpringContextHolder.getBean(SysParamServiceImpl.class);
@@ -35,6 +38,7 @@ public class LmsUtil {
//log.info("请求LMS参数:{}", JSON.toJSONString(requestParam)); //log.info("请求LMS参数:{}", JSON.toJSONString(requestParam));
String body = HttpRequest String body = HttpRequest
.post(wmsUrl + api).setConnectionTimeout(3000) .post(wmsUrl + api).setConnectionTimeout(3000)
.header("token", wmsToken)
.body(JSON.toJSONString(requestParam)) .body(JSON.toJSONString(requestParam))
.execute() .execute()
.body(); .body();

View File

@@ -44,6 +44,11 @@ public class CreateTaskRequest extends BaseRequest {
*/ */
String vehicle_type; String vehicle_type;
/**
* 运输载体 0托盘 1仓储笼
*/
String carrier;
/** /**
* 任务类型 * 任务类型

View File

@@ -433,6 +433,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
CreateTaskRequest req = reqs.get(i); CreateTaskRequest req = reqs.get(i);
String task_code = req.getTask_code(); String task_code = req.getTask_code();
String task_id = req.getTask_id(); String task_id = req.getTask_id();
String carrier = req.getCarrier();
String start_device_code = req.getStart_device_code(); String start_device_code = req.getStart_device_code();
String next_device_code = req.getNext_device_code(); String next_device_code = req.getNext_device_code();
String priority = req.getPriority(); String priority = req.getPriority();
@@ -473,6 +474,16 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
errArr.add(json); errArr.add(json);
continue; continue;
} }
if (StrUtil.isEmpty(carrier)) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("message", "载货类型不能为空");
errArr.add(json);
continue;
}
start_device_code = start_device_code + carrier;
next_device_code = next_device_code + carrier;
//JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0); //JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0);
StorageCell storageCell_start = new LambdaQueryChainWrapper<>(storageCellMapper) StorageCell storageCell_start = new LambdaQueryChainWrapper<>(storageCellMapper)
.eq(StorageCell::getParent_storage_code, start_device_code) .eq(StorageCell::getParent_storage_code, start_device_code)

View File

@@ -429,11 +429,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
// } // }
// if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) { // if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
try { // try {
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto); ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
} catch (Exception e) { // } catch (Exception e) {
log.error("tofix下发agv数据失败失败原因" + e.getMessage()); // dto.setSend_status("2");
} // dto.setRemark("失败原因:" + e.getMessage());
// log.error("tofix下发agv数据失败失败原因" + e.getMessage());
// }
// } else if (StrUtil.equals(shortPathsList.get(0).getType(), "2")) { // } else if (StrUtil.equals(shortPathsList.get(0).getType(), "2")) {
// ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class); // ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class);
// HttpResponse result = zheDaAgvService.sendAgvInstToAgv(dto); // HttpResponse result = zheDaAgvService.sendAgvInstToAgv(dto);

View File

@@ -875,7 +875,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang(); FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang();
Instruction instruction = instructionService.findByTaskcode(entity.getTask_code()); Instruction instruction = instructionService.findByTaskcode(entity.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)){ if (ObjectUtil.isNotEmpty(instruction)){
request_weiBang.setCarNo(Integer.valueOf(instruction.getCarno())); int carNo = ObjectUtil.isEmpty(instruction.getCarno()) ? 0 : Integer.parseInt(instruction.getCarno());
request_weiBang.setCarNo(carNo);
} }
request_weiBang.setTaskNo(entity.getTask_code()); request_weiBang.setTaskNo(entity.getTask_code());
request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(dto.getTask_status())); request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(dto.getTask_status()));
@@ -997,7 +998,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang(); FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang();
Instruction instruction = instructionService.findByTaskcode(entity.getTask_code()); Instruction instruction = instructionService.findByTaskcode(entity.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)){ if (ObjectUtil.isNotEmpty(instruction)){
request_weiBang.setCarNo(Integer.valueOf(instruction.getCarno())); int carNo = ObjectUtil.isEmpty(instruction.getCarno()) ? 0 : Integer.parseInt(instruction.getCarno());
request_weiBang.setCarNo(carNo);
} }
request_weiBang.setTaskNo(entity.getTask_code()); request_weiBang.setTaskNo(entity.getTask_code());
request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status())); request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status()));
@@ -1031,7 +1033,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang(); FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang();
Instruction instruction = instructionService.findByTaskcode(entity.getTask_code()); Instruction instruction = instructionService.findByTaskcode(entity.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)){ if (ObjectUtil.isNotEmpty(instruction)){
request_weiBang.setCarNo(Integer.valueOf(instruction.getCarno())); int carNo = ObjectUtil.isEmpty(instruction.getCarno()) ? 0 : Integer.parseInt(instruction.getCarno());
request_weiBang.setCarNo(carNo);
} }
request_weiBang.setTaskNo(entity.getTask_code()); request_weiBang.setTaskNo(entity.getTask_code());
request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status())); request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status()));
@@ -1077,7 +1080,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang(); FeedBackTaskStatusRequest_WeiBang request_weiBang = new FeedBackTaskStatusRequest_WeiBang();
Instruction instruction = instructionService.findByTaskcode(entity.getTask_code()); Instruction instruction = instructionService.findByTaskcode(entity.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)){ if (ObjectUtil.isNotEmpty(instruction)){
request_weiBang.setCarNo(Integer.valueOf(instruction.getCarno())); int carNo = ObjectUtil.isEmpty(instruction.getCarno()) ? 0 : Integer.parseInt(instruction.getCarno());
request_weiBang.setCarNo(carNo);
} }
request_weiBang.setTaskNo(entity.getTask_code()); request_weiBang.setTaskNo(entity.getTask_code());
request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status())); request_weiBang.setStatus(ResponseWMSTaskStatusEnum.getCode(entity.getTask_status()));

View File

@@ -26,4 +26,9 @@ public class HeadDto implements Serializable {
*/ */
private String task_type; private String task_type;
/**
* 任务类型
*/
private String vehicle_type;
} }

View File

@@ -97,4 +97,13 @@ public class HandController {
return new ResponseEntity<>(handService.taskOperation(dto), HttpStatus.OK); return new ResponseEntity<>(handService.taskOperation(dto), HttpStatus.OK);
} }
@PostMapping("/queryVehicleType")
@Log("查询载具类型")
@ApiOperation("查询载具类型")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryVehicleType(@RequestBody HeadDto dto) {
return new ResponseEntity<>(handService.queryVehicleType(), HttpStatus.OK);
}
} }

View File

@@ -34,4 +34,5 @@ public interface HandService {
Map<String, Object> taskOperation(HeadTaskDto dto); Map<String, Object> taskOperation(HeadTaskDto dto);
Map<String, Object> queryVehicleType();
} }

View File

@@ -35,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -98,6 +99,7 @@ public class HandServiceImpl implements HandService {
@Override @Override
public Map<String, Object> callTask(HeadDto dto) { public Map<String, Object> callTask(HeadDto dto) {
JSONArray errArr = new JSONArray(); JSONArray errArr = new JSONArray();
String vehicle_type = dto.getVehicle_type();
String start_device_code = dto.getStart_device_code(); String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code(); String next_device_code = dto.getNext_device_code();
String task_type = dto.getTask_type(); String task_type = dto.getTask_type();
@@ -111,7 +113,11 @@ public class HandServiceImpl implements HandService {
if (StrUtil.isEmpty(task_type)) { if (StrUtil.isEmpty(task_type)) {
throw new BadRequestException("任务类型不能为空"); throw new BadRequestException("任务类型不能为空");
} }
if (StrUtil.isEmpty(vehicle_type)) {
throw new BadRequestException("托盘类型不能为空");
}
start_device_code = start_device_code + vehicle_type;
next_device_code = next_device_code + vehicle_type;
String start_device_code2 = ""; String start_device_code2 = "";
String next_device_code2 = ""; String next_device_code2 = "";
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
@@ -460,4 +466,30 @@ public class HandServiceImpl implements HandService {
resultJson.put("data", data); resultJson.put("data", data);
return resultJson; return resultJson;
} }
@Override
public Map<String, Object> queryVehicleType() {
JSONArray data = new JSONArray();
List<Dict> list = dictService.lambdaQuery()
.eq(Dict::getCode, "vehicle_type")
.list();
if (CollectionUtil.isEmpty(list)) {
throw new BadRequestException("未查到托盘类型!");
}
for (int i = 0; i < list.size(); i++) {
JSONObject jo = new JSONObject();
Dict dict = list.get(i);
String vehicle_type_id = dict.getDict_id();
String vehicle_type_code = dict.getValue();
String vehicle_type_name = dict.getLabel();
jo.put("vehicle_type_id", vehicle_type_id);
jo.put("value", vehicle_type_code);
jo.put("text", vehicle_type_name);
data.add(jo);
}
JSONObject resultJson = new JSONObject();
resultJson.put("message", "操作成功");
resultJson.put("data", data);
return resultJson;
}
} }

View File

@@ -12,13 +12,13 @@ import org.springframework.stereotype.Component;
@Component @Component
public class AutoCreateChargingTaskToNDC { public class AutoCreateChargingTaskToNDC {
@Autowired // @Autowired
NDCAgvService ndcAgvService; // NDCAgvService ndcAgvService;
//
public void run(String threadCode) throws Exception { // public void run(String threadCode) throws Exception {
String[] threadCodes = threadCode.split(","); // String[] threadCodes = threadCode.split(",");
for (String code : threadCodes) { // for (String code : threadCodes) {
ndcAgvService.createChargingTaskToNDC(code); // ndcAgvService.createChargingTaskToNDC(code);
} // }
} // }
} }

View File

@@ -7,7 +7,7 @@ spring:
db-type: com.alibaba.druid.pool.DruidDataSource db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy 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: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:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:qzyf}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:weibang_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
username: ${DB_USER:root} username: ${DB_USER:root}
# password: ${DB_PWD:Root.123456} # password: ${DB_PWD:Root.123456}
password: ${DB_PWD:123456} password: ${DB_PWD:123456}
@@ -73,7 +73,7 @@ spring:
#数据库索引 #数据库索引
database: ${REDIS_DB:5} database: ${REDIS_DB:5}
# host: ${REDIS_HOST:10.44.101.19} # host: ${REDIS_HOST:10.44.101.19}
host: ${REDIS_HOST:192.168.11.250} host: ${REDIS_HOST:127.0.0.1}
port: ${REDIS_PORT:6379} port: ${REDIS_PORT:6379}
# password: ${REDIS_PWD:} # password: ${REDIS_PWD:}
@@ -172,7 +172,7 @@ sa-token:
# Redis数据库索引默认为0 # Redis数据库索引默认为0
database: 5 database: 5
# Redis服务器地址 # Redis服务器地址
host: 192.168.11.250 host: 127.0.0.1
# Redis服务器连接端口 # Redis服务器连接端口
port: 6379 port: 6379
# Redis服务器连接密码默认为空 # Redis服务器连接密码默认为空