更新
This commit is contained in:
@@ -1,36 +1,26 @@
|
||||
package org.nl.acs.agv.server.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.auto.run.TwoNDC2SocketConnectionAutoRun;
|
||||
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.LokiLog;
|
||||
import org.nl.acs.log.LokiLogType;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@@ -185,9 +175,9 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
}
|
||||
log.info("下发AGV作业指令--{}", str1);
|
||||
if (StrUtil.equals(agv_system_type,"2")){
|
||||
TwoNDCSocketConnectionAutoRun.write(b);
|
||||
//TwoNDCSocketConnectionAutoRun.write(b);
|
||||
} else if (StrUtil.equals(agv_system_type,"3")){
|
||||
TwoNDC2SocketConnectionAutoRun.write(b);
|
||||
//TwoNDC2SocketConnectionAutoRun.write(b);
|
||||
}
|
||||
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
|
||||
} else {
|
||||
|
||||
@@ -11,6 +11,7 @@ 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.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
@@ -63,17 +64,18 @@ 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);
|
||||
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.AGVURL).getValue();
|
||||
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).getValue());
|
||||
|
||||
@@ -83,7 +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链接成功");
|
||||
System.out.println("NDCAgv链接成功");
|
||||
log.info("NDCAgv链接成功");
|
||||
while (bConnected) {
|
||||
int count = dis.read(b);
|
||||
|
||||
@@ -119,6 +122,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
//车号
|
||||
int carno = arr[20];
|
||||
Instruction link_inst = null;
|
||||
Instruction inst = null;
|
||||
List<Instruction> insts = null;
|
||||
boolean link_flag = false;
|
||||
Device agv_device = null;
|
||||
@@ -126,7 +130,10 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
}
|
||||
if (ikey != 0) {
|
||||
insts = instructionService.findByLinkNum(String.valueOf(ikey));
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
if (ObjectUtil.isEmpty(inst)){
|
||||
inst = instructionService.findByCode(String.valueOf(ikey));
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(link_inst)) {
|
||||
link_flag = true;
|
||||
@@ -142,7 +149,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
//开始任务/上报订单号
|
||||
if (phase == 0x01) {
|
||||
for (Instruction inst : insts) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
inst.setInstruction_status("1");
|
||||
inst.setAgv_jobno(String.valueOf(index));
|
||||
inst.setSend_status("1");
|
||||
@@ -154,7 +161,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
//(无车id及状态)
|
||||
else if (phase == 0x0A) {
|
||||
|
||||
for (Instruction inst : insts) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.finish(inst.getInstruction_id());
|
||||
}
|
||||
@@ -172,7 +179,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
//(需要WCS反馈)
|
||||
else if(phase == 0xFF) {
|
||||
|
||||
for (Instruction inst : insts) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
||||
}
|
||||
@@ -187,10 +194,13 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
} else {
|
||||
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
agvNdcOneDeviceDriver.processSocket(arr);
|
||||
if(ObjectUtil.isNotEmpty(device)){
|
||||
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
agvNdcOneDeviceDriver.processSocket(arr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
write(data);
|
||||
@@ -203,6 +213,10 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("OneAgv链接异常");
|
||||
log.info("OneAgv链接异常");
|
||||
log.error("agv连接出现异常:{}", e);
|
||||
logServer.deviceExecuteLog("1","","","agv异常"+e.getMessage());
|
||||
logServer.deviceExecuteLog("1","","","agv异常" + e);
|
||||
if(ObjectUtil.isNotEmpty(s)){
|
||||
s.close();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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.AGVURL).getValue();
|
||||
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,11 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.common.StandardInspectSiteDevice;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||
@@ -26,7 +29,10 @@ import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* NDC单工位AGV
|
||||
@@ -78,13 +84,17 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
int carno = arr[20];
|
||||
Instruction link_inst = null;
|
||||
List<Instruction> insts = null;
|
||||
Instruction inst = null;
|
||||
boolean link_flag = false;
|
||||
Device agv_device = null;
|
||||
if (carno != 0) {
|
||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
}
|
||||
if (ikey != 0) {
|
||||
insts = instructionService.findByLinkNum(String.valueOf(ikey));
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
inst = instructionService.findByCode(String.valueOf(ikey));
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(link_inst)) {
|
||||
link_flag = true;
|
||||
@@ -106,15 +116,14 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
//普通站点
|
||||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
//货架
|
||||
StandardStorageDeviceDriver standardStorageDeviceDriver;
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
//
|
||||
|
||||
//分配 车id
|
||||
//(不需要WCS反馈)
|
||||
if (phase == 0x02) {
|
||||
for (Instruction inst : insts) {
|
||||
inst.setCarno(String.valueOf(carno));
|
||||
instructionService.update(inst);
|
||||
}
|
||||
inst.setCarno(String.valueOf(carno));
|
||||
instructionService.update(inst);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + "反馈:" + data);
|
||||
|
||||
//到达取货点
|
||||
@@ -148,26 +157,22 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空");
|
||||
return;
|
||||
}
|
||||
for (Instruction inst : insts) {
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
|
||||
break;
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
|
||||
standardOrdinarySiteDeviceDriver.setIndex(index);
|
||||
standardOrdinarySiteDeviceDriver.setInst(inst);
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到编号{}对应的指令", ikey);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
|
||||
return;
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
|
||||
standardOrdinarySiteDeviceDriver.setIndex(index);
|
||||
standardOrdinarySiteDeviceDriver.setInst(inst);
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
|
||||
//取货完毕
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x05) {
|
||||
@@ -198,27 +203,21 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code);
|
||||
return;
|
||||
}
|
||||
for (Instruction inst : insts) {
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
|
||||
break;
|
||||
}
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
|
||||
return;
|
||||
}
|
||||
|
||||
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
|
||||
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
|
||||
standardOrdinarySiteDeviceDriver.setIndex(index);
|
||||
standardOrdinarySiteDeviceDriver.setInst(inst);
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
|
||||
standardOrdinarySiteDeviceDriver.setIndex(index);
|
||||
standardOrdinarySiteDeviceDriver.setInst(inst);
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
@@ -251,23 +250,19 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
for (Instruction inst : insts) {
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
break;
|
||||
}
|
||||
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
return;
|
||||
}
|
||||
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
|
||||
standardOrdinarySiteDeviceDriver.setIndex(index);
|
||||
standardOrdinarySiteDeviceDriver.setInst(inst);
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
|
||||
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
// standardOrdinarySiteDeviceDriver.setAgvphase(phase);
|
||||
// standardOrdinarySiteDeviceDriver.setIndex(index);
|
||||
// standardOrdinarySiteDeviceDriver.setInst(inst);
|
||||
if (standardInspectSiteDeviceDriver.getMove() == 0) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
@@ -303,25 +298,24 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
for (Instruction inst : insts) {
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
break;
|
||||
}
|
||||
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到编号{}对应的指令", ikey);
|
||||
return;
|
||||
}
|
||||
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
|
||||
standardOrdinarySiteDeviceDriver.setIndex(index);
|
||||
standardOrdinarySiteDeviceDriver.setInst(inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
// standardOrdinarySiteDeviceDriver.setAgvphase(phase);
|
||||
// standardOrdinarySiteDeviceDriver.setIndex(index);
|
||||
// standardOrdinarySiteDeviceDriver.setInst(inst);
|
||||
if (standardInspectSiteDeviceDriver.getMove() > 0) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
|
||||
@@ -334,10 +328,10 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
agvaddr_copy = agvaddr;
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
}else if(phase == 0x50){//进入交通灯区域
|
||||
} else if (phase == 0x50) {//进入交通灯区域
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
}else if(phase == 0x51){//离开交通灯区域
|
||||
} else if (phase == 0x51) {//离开交通灯区域
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.auto.run.TwoNDC2SocketConnectionAutoRun;
|
||||
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
@@ -469,9 +467,9 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
if (StrUtil.equals(inst.getAgv_system_type(), "2")) {
|
||||
TwoNDCSocketConnectionAutoRun.write(data);
|
||||
//TwoNDCSocketConnectionAutoRun.write(data);
|
||||
} else if (StrUtil.equals(inst.getAgv_system_type(), "3")) {
|
||||
TwoNDC2SocketConnectionAutoRun.write(data);
|
||||
//TwoNDC2SocketConnectionAutoRun.write(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,26 +90,42 @@ public class AMHandServiceImpl implements AMHandService {
|
||||
String device_id = device.getString("device_id");
|
||||
String device_code = device.getString("device_code");
|
||||
String device_name = device.getString("device_name");
|
||||
JSONObject deviceRunPoint = wo_runPoint.query("device_id = '" + device_id + "'").uniqueResult(0);
|
||||
Integer hasgoods = deviceRunPoint.getInteger("hasgoods");
|
||||
String material_type = deviceRunPoint.getString("material_type");
|
||||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
Device device_driver = deviceAppService.findDeviceByCode(device_code);
|
||||
//点位状态status对应status_name 0空 1有货 2有任务
|
||||
String status = "0";
|
||||
String status_name = "无货";
|
||||
String input_material = "0";
|
||||
String allow_update = "0";
|
||||
TaskDto taskDto = taskService.findByStartAndNextCode(device_code);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && hasgoods == 1) {
|
||||
status = "2";
|
||||
status_name = "有任务";
|
||||
} else if (hasgoods == 1) {
|
||||
status = "1";
|
||||
status_name = "有货";
|
||||
}
|
||||
Device device_driver = deviceAppService.findDeviceByCode(device_code);
|
||||
String material_type = "0";
|
||||
if (device_driver.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
JSONObject deviceRunPoint = wo_runPoint.query("device_id = '" + device_id + "'").uniqueResult(0);
|
||||
Integer hasgoods = deviceRunPoint.getInteger("hasgoods");
|
||||
material_type = deviceRunPoint.getString("material_type");
|
||||
TaskDto taskDto = taskService.findByStartAndNextCode(device_code);
|
||||
if (ObjectUtil.isNotEmpty(taskDto) && hasgoods == 1) {
|
||||
status = "2";
|
||||
status_name = "有任务";
|
||||
} else if (hasgoods == 1) {
|
||||
status = "1";
|
||||
status_name = "有货";
|
||||
}
|
||||
input_material = "1";
|
||||
allow_update = "1";
|
||||
} else if (device_driver.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device_driver.getDeviceDriver();
|
||||
int move = standardInspectSiteDeviceDriver.getMove();
|
||||
TaskDto taskDto = taskService.findByStartAndNextCode(device_code);
|
||||
if (move != 0 && ObjectUtil.isNotEmpty(taskDto)) {
|
||||
status = "2";
|
||||
status_name = "有任务";
|
||||
material_type = "1";
|
||||
} else if (move != 0) {
|
||||
status = "1";
|
||||
status_name = "有货";
|
||||
material_type = "1";
|
||||
}
|
||||
}
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("device_id", device_id);
|
||||
@@ -671,12 +687,12 @@ public class AMHandServiceImpl implements AMHandService {
|
||||
status = "1";
|
||||
}
|
||||
JSONObject map = new JSONObject();
|
||||
if (StrUtil.equals(type, "0")) {
|
||||
map.put("material_type", "");
|
||||
map.put("hasgoods", "0");
|
||||
} else {
|
||||
if (StrUtil.equals(type, "1")) {
|
||||
map.put("material_type", material_type);
|
||||
map.put("hasgoods", status);
|
||||
} else {
|
||||
map.put("material_type", "");
|
||||
map.put("hasgoods", "0");
|
||||
}
|
||||
wo_runPoint.update(map, "device_code = '" + device_code + "'");
|
||||
jo.put("code", "1");
|
||||
@@ -753,6 +769,21 @@ public class AMHandServiceImpl implements AMHandService {
|
||||
jo.put("desc", "呼叫失败,起点或终点不能为空!");
|
||||
return jo;
|
||||
}
|
||||
for (int i = 0; i < start_device_codes.size(); i++) {
|
||||
String device_code = start_device_codes.getString(i);
|
||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
JSONObject jsonObject = wo_runPoint.query("device_code = '" + device_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject)){
|
||||
String hasgoods = jsonObject.getString("hasgoods");
|
||||
if (StrUtil.equals(hasgoods,"0")){
|
||||
throw new BadRequestException("设备:" + device_code + "库存为无货状态,请手动绑定货物!");
|
||||
}
|
||||
}
|
||||
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
|
||||
}
|
||||
}
|
||||
//将数组转换为集合判断是否为同一排的库位,并按照库位顺序号排序
|
||||
List<String> start_device_code_list = JSONArray.parseArray(start_device_codes.toJSONString(), String.class);
|
||||
Collections.sort(start_device_code_list, new Comparator<String>() {
|
||||
@@ -808,13 +839,14 @@ public class AMHandServiceImpl implements AMHandService {
|
||||
taskDto.setCreate_by(SecurityUtils.getCurrentUsername());
|
||||
taskDto.setUpdate_by(SecurityUtils.getCurrentUsername());
|
||||
taskDto.setRoute_plan_code("normal");
|
||||
taskDto.setTask_type("3");
|
||||
//任务类型
|
||||
taskDto.setTask_type("4");
|
||||
taskDto.setTask_status("0");
|
||||
taskDto.setPriority("1");
|
||||
taskDto.setCreate_time(DateUtil.now());
|
||||
taskDto.setUpdate_time(DateUtil.now());
|
||||
taskDto.setRemark("手持创建任务!");
|
||||
taskDto.setAgv_system_type("2");
|
||||
taskDto.setAgv_system_type("1");
|
||||
taskDto.setMaterial(jsonObject.getString("material"));
|
||||
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
|
||||
try {
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id
|
||||
WHERE
|
||||
sys.NAME = "region_type"
|
||||
order by
|
||||
dict_sort
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -217,6 +217,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
public Instruction findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json)){
|
||||
return null;
|
||||
}
|
||||
final Instruction obj = json.toJavaObject(Instruction.class);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -1170,7 +1170,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return new TaskDto();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.nl.modules.quartz.domain.QuartzLog;
|
||||
import org.nl.modules.quartz.repository.QuartzLogRepository;
|
||||
import org.nl.modules.quartz.service.QuartzJobService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
@@ -41,6 +42,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
@Async
|
||||
@SuppressWarnings({"unchecked", "all"})
|
||||
@Slf4j
|
||||
@DisallowConcurrentExecution
|
||||
public class ExecutionJob extends QuartzJobBean {
|
||||
|
||||
/**
|
||||
|
||||
@@ -460,7 +460,7 @@ export default {
|
||||
task_id: null,
|
||||
vehicle_code: null,
|
||||
vehicle_type: null,
|
||||
task_type: '3',
|
||||
task_type: '4',
|
||||
storage_task_type: '',
|
||||
task_status: null,
|
||||
priority: 1,
|
||||
@@ -479,7 +479,7 @@ export default {
|
||||
to_x: null,
|
||||
to_y: null,
|
||||
to_z: null,
|
||||
agv_system_type: '2'
|
||||
agv_system_type: '1'
|
||||
},
|
||||
rules: {
|
||||
start_point_code: [
|
||||
|
||||
Reference in New Issue
Block a user