更新
This commit is contained in:
@@ -13,14 +13,6 @@ import java.util.Map;
|
||||
public interface NDCAgvService {
|
||||
Map<String, AgvDto> findAllAgvFromCache();
|
||||
|
||||
/**
|
||||
* 查询自动门状态
|
||||
*
|
||||
* @param device
|
||||
* @return
|
||||
*/
|
||||
public String queryDoorStatus(String device);
|
||||
|
||||
/**
|
||||
* 删除NDC任务
|
||||
*
|
||||
@@ -29,61 +21,15 @@ public interface NDCAgvService {
|
||||
*/
|
||||
public void deleteAgvInstToNDC(Instruction inst) throws Exception;
|
||||
|
||||
/**
|
||||
* 下发NDC agv1楼动作指令,反馈信号,如能否进、能否出。
|
||||
* 告诉AGV能否进,能否出
|
||||
*
|
||||
* @param phase
|
||||
* @param index
|
||||
* @param result1
|
||||
* @param result2
|
||||
*/
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2);
|
||||
|
||||
/**
|
||||
* 下发NDC agv2楼动作指令,反馈信号,如能否进、能否出。
|
||||
* 告诉AGV能否进,能否出
|
||||
*
|
||||
* @param phase
|
||||
* @param index
|
||||
* @param result1
|
||||
* @param result2
|
||||
*/
|
||||
public byte[] sendAgvTwoModeInst(int phase, int index);
|
||||
|
||||
/**
|
||||
* @param inst
|
||||
* @param inst2
|
||||
*/
|
||||
void sendAgvTwoInstToNDC(Instruction inst, Instruction inst2);
|
||||
|
||||
/**
|
||||
* 下发任务
|
||||
*
|
||||
* @param inst
|
||||
* @throws Exception
|
||||
*/
|
||||
public void sendAgvInstToNDC(Instruction inst) throws Exception;
|
||||
public void sendAgvInstToNDC(String type,Instruction inst) throws Exception;
|
||||
|
||||
void sendAgvOneInstToNDC(Instruction inst);
|
||||
|
||||
public void sendAgvInstToNDC(String code) throws Exception;
|
||||
|
||||
/**
|
||||
* 下发agv单工动作指令
|
||||
*
|
||||
* @param phase
|
||||
* @param index
|
||||
*/
|
||||
public byte[] sendAgvOneModeInst(int phase, int index);
|
||||
|
||||
/**
|
||||
* 反馈agv单工动作指令
|
||||
* AGV调用ACS,告诉AGV是否允许进,允许出等操作.
|
||||
*
|
||||
* @param phase
|
||||
* @param index
|
||||
*/
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result);
|
||||
public byte[] sendAgvOneModeInst(int phase, int index,int result);
|
||||
|
||||
public byte[] sendAgvTwoModeInst(int phase, int index,int result);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
@@ -75,176 +77,239 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2) {
|
||||
public void sendAgvInstToNDC(String agv_type, Instruction inst) {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||
if (StrUtil.equals(agv_type, "1")) {
|
||||
String instcode = inst.getInstruction_code();
|
||||
int type = Integer.parseInt(inst.getAgv_inst_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2());
|
||||
int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2());
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(type);
|
||||
byte typelow = (byte) IntToHexLow(type);
|
||||
byte qhdhigh = (byte) IntToHexHigh(startAddress);
|
||||
byte qhdlow = (byte) IntToHexLow(startAddress);
|
||||
byte qhdhigh2 = (byte) IntToHexHigh(startAddress2);
|
||||
byte qhdlow2 = (byte) IntToHexLow(startAddress2);
|
||||
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
|
||||
byte fhdlow = (byte) IntToHexLow(nextAddress);
|
||||
byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2);
|
||||
byte fhdlow2 = (byte) IntToHexLow(nextAddress2);
|
||||
byte prioritylow = (byte) IntToHexLow(priority);
|
||||
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
|
||||
str += "/type:" + (type);
|
||||
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
|
||||
str += "/qhd:" + (startAddress);
|
||||
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
|
||||
str += "/fhd:" + (nextAddress);
|
||||
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
|
||||
|
||||
str += "/qhd2:" + (startAddress2);
|
||||
str1 += "/qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF);
|
||||
str += "/fhd2:" + (nextAddress2);
|
||||
str1 += "/fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF);
|
||||
|
||||
str += "/priority:" + (priority);
|
||||
str1 += "/priority:" + hexToString(prioritylow & 0xFF);
|
||||
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
byte[] b = new byte[]{};
|
||||
if (type == 1) {
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X1A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X16,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) qhdhigh2, (byte) qhdlow2,
|
||||
(byte) fhdhigh, (byte) fhdlow,
|
||||
(byte) fhdhigh2, (byte) fhdlow2,
|
||||
(byte) 0X00, (byte) 0X00,
|
||||
(byte) 0X00, (byte) 0X00
|
||||
};
|
||||
} else if (type == 2) {
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X1A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X16,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) 0X00, (byte) 0X00,
|
||||
(byte) fhdhigh, (byte) fhdlow,
|
||||
(byte) 0X00, (byte) 0X00,
|
||||
(byte) 0X00, (byte) 0X00,
|
||||
(byte) 0X00, (byte) 0X00
|
||||
};
|
||||
} else if (type == 3) {
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X1A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X16,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) 0X00, (byte) 0X00,
|
||||
(byte) fhdhigh, (byte) fhdlow,
|
||||
(byte) 0X00, (byte) 0X00,
|
||||
(byte) qhdhigh2, (byte) qhdlow2,
|
||||
(byte) fhdhigh2, (byte) fhdlow2
|
||||
};
|
||||
}
|
||||
log.info("下发AGV作业指令--{}", str1);
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
|
||||
} else {
|
||||
|
||||
String instcode = inst.getInstruction_code();
|
||||
int type = Integer.parseInt(inst.getInstruction_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(type);
|
||||
byte typelow = (byte) IntToHexLow(type);
|
||||
byte qhdhigh = (byte) IntToHexHigh(startAddress);
|
||||
byte qhdlow = (byte) IntToHexLow(startAddress);
|
||||
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
|
||||
byte fhdlow = (byte) IntToHexLow(nextAddress);
|
||||
byte prioritylow = (byte) IntToHexLow(priority);
|
||||
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
|
||||
str += "/type:" + (type);
|
||||
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
|
||||
str += "/qhd:" + (startAddress);
|
||||
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
|
||||
str += "/fhd:" + (nextAddress);
|
||||
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
|
||||
|
||||
str += "/priority:" + (priority);
|
||||
str1 += "/priority:" + hexToString(prioritylow & 0xFF);
|
||||
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X12,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X0E,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) fhdhigh, (byte) fhdlow
|
||||
};
|
||||
log.info("下发AGV作业指令--{}", str1);
|
||||
TwoNDCSocketConnectionAutoRun.write(b);
|
||||
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result) {
|
||||
if (phase < 0 || index < 0)
|
||||
return null;
|
||||
byte indexhigh = (byte) IntToHexHigh(index);
|
||||
byte indexlow = (byte) IntToHexLow(index);
|
||||
byte phasehigh = (byte) IntToHexHigh(phase);
|
||||
byte phaselow = (byte) IntToHexLow(phase);
|
||||
byte resulthigh1 = (byte) IntToHexHigh(result1);
|
||||
byte resultlow1 = (byte) IntToHexLow(result1);
|
||||
byte resulthigh2 = (byte) IntToHexHigh(result2);
|
||||
byte resultlow2 = (byte) IntToHexLow(result2);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0D,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow,
|
||||
(byte) resulthigh1, (byte) resultlow1,
|
||||
(byte) resulthigh2, (byte) resultlow2
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
};
|
||||
|
||||
|
||||
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
|
||||
//87CD 0008 000C 0001 006D 0008 0000 0114 000E 0000
|
||||
//87CD 0008 000C 0001 006D 0008 0003 0114 008F 0000
|
||||
|
||||
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
|
||||
return b;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public void sendAgvOneInstToNDC(Instruction inst) {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.ONEFORKAGV).getValue(), "1")) {
|
||||
String instcode = inst.getLink_num();
|
||||
int type = Integer.parseInt(inst.getAgv_inst_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
public byte[] sendAgvTwoModeInst(int phase, int index, int result) {
|
||||
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(type);
|
||||
byte typelow = (byte) IntToHexLow(type);
|
||||
byte qhdhigh = (byte) IntToHexHigh(startAddress);
|
||||
byte qhdlow = (byte) IntToHexLow(startAddress);
|
||||
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
|
||||
byte fhdlow = (byte) IntToHexLow(nextAddress);
|
||||
byte prioritylow = (byte) IntToHexLow(priority);
|
||||
if (phase < 0 || index < 0)
|
||||
return null;
|
||||
byte indexhigh = (byte) IntToHexHigh(index);
|
||||
byte indexlow = (byte) IntToHexLow(index);
|
||||
byte phasehigh = (byte) IntToHexHigh(phase);
|
||||
byte phaselow = (byte) IntToHexLow(phase);
|
||||
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X10,
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
};
|
||||
|
||||
str += "/type:" + (type);
|
||||
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
|
||||
str += "/qhd:" + (startAddress);
|
||||
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
|
||||
str += "/fhd:" + (nextAddress);
|
||||
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
|
||||
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
|
||||
|
||||
str += "/priority:" + (priority);
|
||||
str1 += "/priority:" + hexToString(prioritylow & 0xFF);
|
||||
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X12,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X0E,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) fhdhigh, (byte) fhdlow
|
||||
};
|
||||
log.info("下发AGV作业指令--{}", str1);
|
||||
|
||||
// OneNDCSocketConnectionAutoRun.write(b);
|
||||
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
|
||||
}
|
||||
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
|
||||
return b;
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public void sendAgvInstToNDC(Instruction inst) {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||
String instcode = inst.getInstruction_code();
|
||||
int type = Integer.parseInt(inst.getInstruction_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(type);
|
||||
byte typelow = (byte) IntToHexLow(type);
|
||||
byte qhdhigh = (byte) IntToHexHigh(startAddress);
|
||||
byte qhdlow = (byte) IntToHexLow(startAddress);
|
||||
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
|
||||
byte fhdlow = (byte) IntToHexLow(nextAddress);
|
||||
byte prioritylow = (byte) IntToHexLow(priority);
|
||||
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
|
||||
str += "/type:" + (type);
|
||||
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
|
||||
str += "/qhd:" + (startAddress);
|
||||
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
|
||||
str += "/fhd:" + (nextAddress);
|
||||
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
|
||||
|
||||
str += "/priority:" + (priority);
|
||||
str1 += "/priority:" + hexToString(prioritylow & 0xFF);
|
||||
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X12,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X0E,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) fhdhigh, (byte) fhdlow
|
||||
};
|
||||
log.info("下发AGV作业指令--{}", str1);
|
||||
|
||||
// NDCSocketConnectionAutoRun.write(b);
|
||||
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
|
||||
}
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public void sendAgvInstToNDC(String instcode) throws Exception {
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
Instruction inst = instructionService.findByCodeFromCache(instcode);
|
||||
sendAgvInstToNDC(inst);
|
||||
}
|
||||
|
||||
|
||||
String hexToString(int i) {
|
||||
return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase();
|
||||
}
|
||||
@@ -273,240 +338,6 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public byte[] sendAgvOneModeInst(int phase, int index) {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public byte[] sendAgvTwoModeInst(int phase, int index) {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result) {
|
||||
if (phase < 0 || index < 0)
|
||||
return null;
|
||||
byte indexhigh = (byte) IntToHexHigh(index);
|
||||
byte indexlow = (byte) IntToHexLow(index);
|
||||
byte phasehigh = (byte) IntToHexHigh(phase);
|
||||
byte phaselow = (byte) IntToHexLow(phase);
|
||||
byte resulthigh = (byte) IntToHexHigh(result);
|
||||
byte resultlow = (byte) IntToHexLow(result);
|
||||
|
||||
int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue());
|
||||
byte[] b = new byte[]{};
|
||||
switch (type) {
|
||||
case 0:
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0D,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow,
|
||||
(byte) resulthigh, (byte) resultlow
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
};
|
||||
break;
|
||||
case 5:
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
};
|
||||
break;
|
||||
case 7:
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
};
|
||||
break;
|
||||
}
|
||||
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
|
||||
|
||||
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public String queryDoorStatus(String device) {
|
||||
log.info("AGV查询自动门状态,参数:{}", device);
|
||||
int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue());
|
||||
switch (type) {
|
||||
case 4:
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASOTHERSYSTEM).getValue(), "1")) {
|
||||
String result = acsToWmsService.queryDoorsStatus().body();
|
||||
JSONArray ja = JSONArray.parseArray(result);
|
||||
log.info("AGV查询自动门状态,反馈:{}", ja.toString());
|
||||
return ja.toString();
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
if (StrUtil.equals("doors", device)) {
|
||||
List<Device> list = deviceAppService.findDevice(DeviceType.autodoor);
|
||||
JSONArray ja = new JSONArray();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code());
|
||||
if (ObjectUtil.isEmpty(doordevice)) {
|
||||
throw new BadRequestException("未找到对应设备");
|
||||
}
|
||||
String mes = null;
|
||||
|
||||
JSONObject jo = JSONObject.parseObject(mes);
|
||||
ja.add(jo);
|
||||
}
|
||||
log.info("AGV查询自动门状态,反馈:{}", ja.toString());
|
||||
return ja.toString();
|
||||
|
||||
} else {
|
||||
Device doordevice = deviceAppService.findDeviceByCode(device);
|
||||
if (ObjectUtil.isEmpty(doordevice)) {
|
||||
throw new BadRequestException("未找到对应设备");
|
||||
}
|
||||
String mes = null;
|
||||
JSONObject jo = JSONObject.parseObject(mes);
|
||||
log.info("AGV查询自动门状态,反馈:{}", jo.toString());
|
||||
return jo.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 双工位诺宝车任务
|
||||
*
|
||||
* @param inst
|
||||
*/
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public void sendAgvTwoInstToNDC(Instruction inst, Instruction inst2) {
|
||||
String instcode = inst.getLink_num();
|
||||
int type = Integer.parseInt(inst.getAgv_inst_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress1 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int putAddress1 = deviceService.queryAddressBydeviceCode(inst.getPut_point_code());
|
||||
int nextAddress1 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
int startAddress2 = 0;
|
||||
int putAddress2 = 0;
|
||||
int nextAddress2 = 0;
|
||||
if (ObjectUtil.isNotEmpty(inst2)) {
|
||||
startAddress2 = deviceService.queryAddressBydeviceCode(inst2.getStart_point_code());
|
||||
putAddress2 = deviceService.queryAddressBydeviceCode(inst2.getPut_point_code());
|
||||
nextAddress2 = deviceService.queryAddressBydeviceCode(inst2.getNext_point_code());
|
||||
}
|
||||
|
||||
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(type);
|
||||
byte typelow = (byte) IntToHexLow(type);
|
||||
|
||||
byte qhd1high = (byte) IntToHexHigh(startAddress1);
|
||||
byte qhd1low = (byte) IntToHexLow(startAddress1);
|
||||
|
||||
byte qhd2high = (byte) IntToHexHigh(startAddress2);
|
||||
byte qhd2low = (byte) IntToHexLow(startAddress2);
|
||||
|
||||
byte dld1high = (byte) IntToHexHigh(putAddress1);
|
||||
byte dld1low = (byte) IntToHexLow(putAddress1);
|
||||
|
||||
byte dld2high = (byte) IntToHexHigh(putAddress2);
|
||||
byte dld2low = (byte) IntToHexLow(putAddress2);
|
||||
|
||||
byte fhd1high = (byte) IntToHexHigh(nextAddress1);
|
||||
byte fhd1low = (byte) IntToHexLow(nextAddress1);
|
||||
|
||||
byte fhd2high = (byte) IntToHexHigh(nextAddress2);
|
||||
byte fhd2low = (byte) IntToHexLow(nextAddress2);
|
||||
|
||||
byte prioritylow = (byte) IntToHexLow(priority);
|
||||
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
|
||||
str += "/type:" + (type);
|
||||
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
|
||||
str1 += "/qhd1:" + hexToString(qhd1high & 0xFF) + hexToString(qhd1low & 0xFF);
|
||||
str1 += "/qhd2:" + hexToString(qhd2high & 0xFF) + hexToString(qhd2low & 0xFF);
|
||||
str1 += "/dld1:" + hexToString(dld1high & 0xFF) + hexToString(dld1low & 0xFF);
|
||||
|
||||
str1 += "/dld2:" + hexToString(dld2high & 0xFF) + hexToString(dld2low & 0xFF);
|
||||
str1 += "/fhd1:" + hexToString(fhd1high & 0xFF) + hexToString(fhd1low & 0xFF);
|
||||
str1 += "/fhd2:" + hexToString(fhd2high & 0xFF) + hexToString(fhd2low & 0xFF);
|
||||
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X1A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X16,
|
||||
(byte) 0X01, (byte) 0X80,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
|
||||
(byte) qhd1high, (byte) qhd1low,
|
||||
(byte) qhd2high, (byte) qhd2low,
|
||||
(byte) dld1high, (byte) dld1low,
|
||||
(byte) dld2high, (byte) dld2low,
|
||||
(byte) fhd1high, (byte) fhd1low,
|
||||
(byte) fhd2high, (byte) fhd2low
|
||||
};
|
||||
log.info("下发AGV作业指令--{}", str1);
|
||||
|
||||
// NDCSocketConnectionAutoRun.write(b);
|
||||
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
|
||||
}
|
||||
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.nl.acs.agv.server.impl;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -14,7 +13,7 @@ import org.nl.acs.agv.server.ZheDaAgvService;
|
||||
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_smart_plc_test.HailiangSmartplcTestDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.haokai_auto_conveyor.HaoKaiAutoConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.paint_conveyor.PaintConveyorDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
@@ -149,7 +148,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
CargoLiftConveyorDeviceDriver cargoLiftConveyorDeviceDriver;
|
||||
EmptyVehicleStackingPositionDeviceDriver emptyVehicleStackingPositionDeviceDriver;
|
||||
HailiangSmartplcTestDeviceDriver hailiangSmartplcTestDeviceDriver;
|
||||
HaoKaiAutoConveyorDeviceDriver haoKaiAutoConveyorDeviceDriver;
|
||||
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||
PaintConveyorDeviceDriver paintConveyorDeviceDriver;
|
||||
|
||||
//取货的进入前等待和离开等待
|
||||
@@ -183,9 +182,9 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
}
|
||||
}
|
||||
//豪凯自动线对接位
|
||||
if (addressdevice.getDeviceDriver() instanceof HaoKaiAutoConveyorDeviceDriver) {
|
||||
haoKaiAutoConveyorDeviceDriver = (HaoKaiAutoConveyorDeviceDriver) addressdevice.getDeviceDriver();
|
||||
if ((haoKaiAutoConveyorDeviceDriver.getAction() == 1 || haoKaiAutoConveyorDeviceDriver.getAction() == 3) && haoKaiAutoConveyorDeviceDriver.getMove() == 1) {
|
||||
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
|
||||
if ((hongXiangConveyorDeviceDriver.getAction() == 1 || hongXiangConveyorDeviceDriver.getAction() == 3) && hongXiangConveyorDeviceDriver.getMove() == 1) {
|
||||
inst.setExecute_status("1");
|
||||
is_feedback = true;
|
||||
}
|
||||
@@ -221,10 +220,10 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
is_feedback = true;
|
||||
}
|
||||
|
||||
if (addressdevice.getDeviceDriver() instanceof HaoKaiAutoConveyorDeviceDriver) {
|
||||
haoKaiAutoConveyorDeviceDriver = (HaoKaiAutoConveyorDeviceDriver) addressdevice.getDeviceDriver();
|
||||
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
|
||||
inst.setExecute_status("2");
|
||||
haoKaiAutoConveyorDeviceDriver.writing(2);
|
||||
hongXiangConveyorDeviceDriver.writing(2);
|
||||
is_feedback = true;
|
||||
}
|
||||
|
||||
@@ -334,9 +333,9 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
}
|
||||
}
|
||||
|
||||
if (addressdevice.getDeviceDriver() instanceof HaoKaiAutoConveyorDeviceDriver) {
|
||||
haoKaiAutoConveyorDeviceDriver = (HaoKaiAutoConveyorDeviceDriver) addressdevice.getDeviceDriver();
|
||||
if ((haoKaiAutoConveyorDeviceDriver.getAction() == 2 || haoKaiAutoConveyorDeviceDriver.getAction() == 3) && haoKaiAutoConveyorDeviceDriver.getMove() == 0) {
|
||||
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
|
||||
if ((hongXiangConveyorDeviceDriver.getAction() == 2 || hongXiangConveyorDeviceDriver.getAction() == 3) && hongXiangConveyorDeviceDriver.getMove() == 0) {
|
||||
inst.setExecute_status("3");
|
||||
is_feedback = true;
|
||||
}
|
||||
@@ -372,10 +371,10 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
is_feedback = true;
|
||||
}
|
||||
|
||||
if (addressdevice.getDeviceDriver() instanceof HaoKaiAutoConveyorDeviceDriver) {
|
||||
haoKaiAutoConveyorDeviceDriver = (HaoKaiAutoConveyorDeviceDriver) addressdevice.getDeviceDriver();
|
||||
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
|
||||
inst.setExecute_status("4");
|
||||
haoKaiAutoConveyorDeviceDriver.writing(3);
|
||||
hongXiangConveyorDeviceDriver.writing(3);
|
||||
is_feedback = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ 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;
|
||||
@@ -85,6 +86,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
dos = new DataOutputStream(s.getOutputStream());
|
||||
dis = new DataInputStream(s.getInputStream());
|
||||
System.out.println("TwoAgv链接成功");
|
||||
log.info("TwoAgv链接成功");
|
||||
while (bConnected) {
|
||||
int count = dis.read(b);
|
||||
|
||||
@@ -119,66 +121,55 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
int agvaddr = arr[18] * 256 + arr[19];
|
||||
//车号
|
||||
int carno = arr[20];
|
||||
Instruction link_inst = null;
|
||||
List<Instruction> insts = null;
|
||||
boolean link_flag = false;
|
||||
Instruction inst = null;
|
||||
Device agv_device = null;
|
||||
if (carno != 0) {
|
||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
}
|
||||
if (ikey != 0) {
|
||||
insts = instructionService.findByLinkNum(String.valueOf(ikey));
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(link_inst)) {
|
||||
link_flag = true;
|
||||
inst = instructionService.findByCode(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;
|
||||
|
||||
|
||||
//
|
||||
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
|
||||
AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver;
|
||||
|
||||
//开始任务/上报订单号
|
||||
if (phase == 0x01) {
|
||||
for (Instruction inst : insts) {
|
||||
inst.setInstruction_status("1");
|
||||
inst.setAgv_jobno(String.valueOf(index));
|
||||
inst.setSend_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
|
||||
|
||||
} else if (phase == 0x0A) {
|
||||
|
||||
for (Instruction inst : insts) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.finish(inst.getInstruction_id());
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.finish(inst.getInstruction_id());
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
|
||||
} else if (phase == 0x30) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(143, index, 0);
|
||||
data = NDCAgvService.sendAgvTwoModeInst(143, index, 0);
|
||||
|
||||
} else if (phase == 0xFF) {
|
||||
|
||||
for (Instruction inst : insts) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
|
||||
} else if (phase == 0x50) {//离开区域
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
|
||||
} else if (phase == 0x51) {//离开区域
|
||||
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -188,8 +179,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
agvNdcOneDeviceDriver.processSocket(arr);
|
||||
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver();
|
||||
agvNdcTwoDeviceDriver.processSocket(arr);
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
@@ -202,7 +193,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("OneAgv链接异常");
|
||||
System.out.println("TwoAgv链接异常");
|
||||
if (ObjectUtil.isNotEmpty(s)) {
|
||||
s.close();
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -23,7 +23,10 @@ public enum DriverTypeEnum {
|
||||
|
||||
AGV_NDC_ONE(7, "agv_ndc_one", "NDC1楼AGV", "agv"),
|
||||
|
||||
AGV_NDC_TWO(8, "agv_ndc_two", "NDC2楼AGV", "agv");
|
||||
AGV_NDC_TWO(8, "agv_ndc_two", "NDC2楼AGV", "agv"),
|
||||
|
||||
HONGXIANG_DEVICE(8, "hongxiang_device", "烘箱设备点位", "conveyor");
|
||||
|
||||
|
||||
//驱动索引
|
||||
private int index;
|
||||
|
||||
Binary file not shown.
@@ -75,31 +75,42 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
agvaddr = arr[18] * 256 + arr[19];
|
||||
//车号
|
||||
int carno = arr[20];
|
||||
Instruction link_inst = null;
|
||||
List<Instruction> insts = null;
|
||||
boolean link_flag = false;
|
||||
Instruction inst = null;
|
||||
Device agv_device = null;
|
||||
if (carno != 0) {
|
||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
}
|
||||
if (ikey != 0) {
|
||||
insts = instructionService.findByLinkNum(String.valueOf(ikey));
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(link_inst)) {
|
||||
link_flag = true;
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
}
|
||||
|
||||
|
||||
Device device = null;
|
||||
String old_device_code = null;
|
||||
String emptyNum = null;
|
||||
String device_code = 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);
|
||||
|
||||
if (phase == 0x67) {
|
||||
//故障信息
|
||||
if (arr[18] * 256 + arr[19] == 0) {
|
||||
|
||||
}
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index);
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
}
|
||||
|
||||
//普通站点
|
||||
@@ -109,273 +120,60 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
|
||||
//开始任务/上报订单号
|
||||
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);
|
||||
|
||||
//请求取货
|
||||
} else if (phase == 0x03) {
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
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;
|
||||
//判断普通站点驱动是否开启等待
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
if (standardOrdinarySiteDeviceDriver.getHasGoods() != 0) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
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.sendAgvTwoModeInst(phase, index);
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
}
|
||||
|
||||
} else if (phase == 0x65) {//param,重量待定
|
||||
//1、得到重量信息
|
||||
int weight = (arr[18] * 256 + arr[19]) * 10;
|
||||
for (Instruction inst : insts) {
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
break;
|
||||
}
|
||||
// 4010 待处理
|
||||
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
|
||||
inst.setWeight(String.valueOf(weight));
|
||||
}
|
||||
}
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index);
|
||||
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index, 0);
|
||||
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
|
||||
//取货完毕/取满框完毕1/点对点取货完毕
|
||||
} else if (phase == 0x64) {//param,agv货位id待定
|
||||
//1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备
|
||||
agvaddr = arr[18] * 256 + arr[19];
|
||||
agvaddr_copy = agvaddr;
|
||||
data = NDCAgvService.sendAgvTwoModeInst(phase, index);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
|
||||
//取货完毕
|
||||
} else if (phase == 0x05) {
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
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;
|
||||
}
|
||||
|
||||
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.sendAgvTwoModeInst(phase, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
|
||||
//请求放货
|
||||
} else if (phase == 0x07) {
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
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)) {
|
||||
|
||||
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.sendAgvTwoModeInst(phase, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
|
||||
//放货完成
|
||||
} else if (phase == 0x09) {
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
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)) {
|
||||
|
||||
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.sendAgvTwoModeInst(phase, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
|
||||
} else if (phase == 0x71) {
|
||||
x = ikey;
|
||||
if (x != last_x) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "x", String.valueOf(x));
|
||||
}
|
||||
|
||||
|
||||
} else if (phase == 0x72) {
|
||||
y = ikey;
|
||||
if (y != last_y) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "y", String.valueOf(y));
|
||||
}
|
||||
|
||||
|
||||
} else if (phase == 0x73) {
|
||||
angle = last_angle;
|
||||
if (angle != last_angle) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "angle", String.valueOf(angle));
|
||||
}
|
||||
|
||||
|
||||
} else if (phase == 0x74) {
|
||||
electric_qty = ikey;
|
||||
if (electric_qty != last_electric_qty) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "electric_qty", String.valueOf(electric_qty));
|
||||
}
|
||||
|
||||
|
||||
} else if (phase == 0x75) {
|
||||
status = ikey;
|
||||
if (status != last_status) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "status", String.valueOf(status));
|
||||
}
|
||||
|
||||
|
||||
} else if (phase == 0x76) {
|
||||
error = ikey;
|
||||
if (error != last_error) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "error", String.valueOf(error));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.basedriver.haokai_auto_conveyor;
|
||||
package org.nl.acs.device_driver.basedriver.hongxiang_device;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -14,30 +14,30 @@ import java.util.List;
|
||||
* 豪凯自动对接线
|
||||
*/
|
||||
@Service
|
||||
public class HaoKaiAutoConveyorDefination implements OpcDeviceDriverDefination {
|
||||
public class HongXiangConveyorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "haokai_auto_conveyor";
|
||||
return "hongxiang_device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "豪凯自动线对接位";
|
||||
return "烘箱设备对接位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "豪凯自动线对接位";
|
||||
return "烘箱设备对接位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HaoKaiAutoConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
return (new HongXiangConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HaoKaiAutoConveyorDeviceDriver.class;
|
||||
return HongXiangConveyorDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.basedriver.haokai_auto_conveyor;
|
||||
package org.nl.acs.device_driver.basedriver.hongxiang_device;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -34,12 +34,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 豪凯自动对接线
|
||||
* 烘箱对接位
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HaoKaiAutoConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver , DeviceStageMonitor {
|
||||
public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver , DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
@@ -134,48 +134,8 @@ public class HaoKaiAutoConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
message = "有报警";
|
||||
//无报警
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
break;
|
||||
case 2:
|
||||
//申请任务
|
||||
if (move > 0 && !requireSucess) {
|
||||
message = "申请任务中...";
|
||||
JSONObject apply = new JSONObject();
|
||||
apply.put("type","8");
|
||||
apply.put("point_code",device_code);
|
||||
String str = acsToWmsService.applyTaskToWms(apply);
|
||||
JSONObject jo = JSON.parseObject(str);
|
||||
if (ObjectUtil.isEmpty(jo)) {
|
||||
message = "接口不通";
|
||||
} else {
|
||||
if (jo.getInteger("status") == 200) {
|
||||
requireSucess = true;
|
||||
} else {
|
||||
requireSucess = false;
|
||||
message = jo.get("message").toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
switch (flag) {
|
||||
//取货完成
|
||||
case 1:
|
||||
writing(2);
|
||||
break;
|
||||
//放货完成
|
||||
case 2:
|
||||
writing(3);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
last_mode = mode;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.acs.device_driver.basedriver.haokai_auto_conveyor;
|
||||
package org.nl.acs.device_driver.basedriver.hongxiang_device;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -16,17 +16,30 @@ public class ItemProtocol {
|
||||
public static String item_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_door = "door";
|
||||
public static String item_temperature = "temperature";
|
||||
//恒温倒计时
|
||||
public static String item_countdown = "countdown";
|
||||
public static String item_finish = "finish";
|
||||
public static String item_task = "task";
|
||||
public static String item_error1 = "error1";
|
||||
public static String item_material = "material";
|
||||
public static String item_consumption = "consumption";
|
||||
public static String item_voltage = "voltage";
|
||||
public static String item_current = "current";
|
||||
|
||||
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_target = "to_target";
|
||||
public static String item_to_door = "to_door";
|
||||
public static String item_to_temperature = "to_temperature";
|
||||
public static String item_to_material = "to_material";
|
||||
public static String item_to_time = "to_time";
|
||||
public static String item_to_task = "to_task";
|
||||
|
||||
|
||||
private HaoKaiAutoConveyorDeviceDriver driver;
|
||||
private HongXiangConveyorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HaoKaiAutoConveyorDeviceDriver driver) {
|
||||
public ItemProtocol(HongXiangConveyorDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
@@ -75,7 +88,14 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_move, "光电信号", "VW4"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "VW6"));
|
||||
list.add(new ItemDto(item_error, "故障", "VW8"));
|
||||
list.add(new ItemDto(item_task, "任务号", "VD10"));
|
||||
list.add(new ItemDto(item_error1, "故障1", "VW8"));
|
||||
list.add(new ItemDto(item_door, "门状态", "VW8"));
|
||||
list.add(new ItemDto(item_temperature, "工位温度", "VW8"));
|
||||
list.add(new ItemDto(item_countdown, "恒温倒计时", "VW8"));
|
||||
list.add(new ItemDto(item_finish, "烘干完成", "VW8"));
|
||||
list.add(new ItemDto(item_consumption, "电能耗", "VD10"));
|
||||
list.add(new ItemDto(item_voltage, "电压", "VD10"));
|
||||
list.add(new ItemDto(item_current, "电流", "VD10"));
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -83,7 +103,10 @@ public class ItemProtocol {
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "VW102"));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "VW104"));
|
||||
list.add(new ItemDto(item_to_door, "开关门", "VD108"));
|
||||
list.add(new ItemDto(item_to_temperature, "生产温度", "VD108"));
|
||||
list.add(new ItemDto(item_to_material, "生产物料", "VD108"));
|
||||
list.add(new ItemDto(item_to_time, "生产时间", "VD108"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "VD108"));
|
||||
return list;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.nl.acs.ext.wms.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class BaseRequest {
|
||||
private Map<String, String> parameters = new HashMap();
|
||||
private String systemCode;
|
||||
private String houseCode;
|
||||
|
||||
public String getSystemCode() {
|
||||
return this.systemCode;
|
||||
}
|
||||
|
||||
public void setSystemCode(String systemCode) {
|
||||
this.systemCode = systemCode;
|
||||
}
|
||||
|
||||
public String getHouseCode() {
|
||||
return this.houseCode;
|
||||
}
|
||||
|
||||
public void setHouseCode(String houseCode) {
|
||||
this.houseCode = houseCode;
|
||||
}
|
||||
|
||||
public BaseRequest() {
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Object getParameter(String key) {
|
||||
return this.parameters.get(key);
|
||||
}
|
||||
|
||||
public void putParameter(String key, String object) {
|
||||
this.parameters.put(key, object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.nl.acs.ext.wms.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BaseResponse {
|
||||
|
||||
private Integer status = 0;
|
||||
private String message;
|
||||
private Map<String, String> parameters = new HashMap();
|
||||
|
||||
public BaseResponse() {
|
||||
}
|
||||
|
||||
public Integer getstatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Object getParameter(String key) {
|
||||
return this.parameters.get(key);
|
||||
}
|
||||
|
||||
public void putParameter(String key, String object) {
|
||||
this.parameters.put(key, object);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.nl.acs.ext.wms.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateTaskRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 设备号
|
||||
*/
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 容器码
|
||||
*/
|
||||
private String containerCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.nl.acs.ext.wms.data;
|
||||
|
||||
public class CreateTaskResponse extends BaseResponse {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package org.nl.acs.ext.wms.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JsonUtl {
|
||||
private static ObjectMapper objectMapper = null;
|
||||
private static ObjectMapper objectMapperLog = null;
|
||||
|
||||
private JsonUtl() {
|
||||
}
|
||||
|
||||
private static ObjectMapper init() {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
// simpleModule.addSerializer(Enum.class, new EnumSerializer());
|
||||
// simpleModule.addSerializer(Date.class, new DateSerializer());
|
||||
// simpleModule.addDeserializer(Enum.class, new EnumDeserializer());
|
||||
// simpleModule.addDeserializer(Date.class, new DateDeserializers.DateDeserializer());
|
||||
objectMapper.registerModule(simpleModule);
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
public static ObjectMapper getInstance() {
|
||||
if (objectMapper == null) {
|
||||
Class var0 = JsonUtl.class;
|
||||
synchronized(JsonUtl.class) {
|
||||
if (objectMapper == null) {
|
||||
objectMapper = init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
public static ObjectMapper getInstanceLog() {
|
||||
if (objectMapperLog == null) {
|
||||
Class var0 = JsonUtl.class;
|
||||
synchronized(JsonUtl.class) {
|
||||
if (objectMapperLog == null) {
|
||||
objectMapperLog = init();
|
||||
objectMapperLog.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objectMapperLog;
|
||||
}
|
||||
|
||||
public static ObjectMapper getObjectMapper() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
public static String parse(Object object) throws RuntimeException {
|
||||
try {
|
||||
return getObjectMapper().writeValueAsString(object);
|
||||
} catch (JsonProcessingException var2) {
|
||||
throw new RuntimeException(var2);
|
||||
}
|
||||
}
|
||||
|
||||
public static String parseWithoutException(Object object) {
|
||||
try {
|
||||
return parse(object);
|
||||
} catch (Exception var2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String parseLog(Object object) {
|
||||
try {
|
||||
return getInstanceLog().writeValueAsString(object);
|
||||
} catch (Exception var2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T format(String json, Class<T> clazz) throws RuntimeException {
|
||||
try {
|
||||
return getObjectMapper().readValue(json, clazz);
|
||||
} catch (IOException var3) {
|
||||
throw new RuntimeException(var3);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<T> formatList(String json, Class<T> clazz) throws RuntimeException {
|
||||
try {
|
||||
JavaType type = getObjectMapper().getTypeFactory().constructParametricType(List.class, new Class[]{clazz});
|
||||
return (List)getObjectMapper().readValue(json, type);
|
||||
} catch (IOException var3) {
|
||||
throw new RuntimeException(var3);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, U> Map<T, U> formatMap(String json, Class<T> clazzKey, Class<U> clazzValue) throws RuntimeException {
|
||||
try {
|
||||
JavaType type = getObjectMapper().getTypeFactory().constructParametricType(Map.class, new Class[]{clazzKey, clazzValue});
|
||||
return (Map)getObjectMapper().readValue(json, type);
|
||||
} catch (IOException var4) {
|
||||
throw new RuntimeException(var4);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<List<T>> formatListTwo(String json, Class<T> clazz) throws RuntimeException {
|
||||
try {
|
||||
TypeFactory typeFactory = getObjectMapper().getTypeFactory();
|
||||
JavaType type = typeFactory.constructParametrizedType(List.class, List.class, new Class[]{clazz});
|
||||
type = typeFactory.constructParametrizedType(List.class, List.class, new JavaType[]{type});
|
||||
return (List)getObjectMapper().readValue(json, type);
|
||||
} catch (IOException var4) {
|
||||
throw new RuntimeException(var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ 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.CreateTaskResponse;
|
||||
import org.nl.acs.ext.wms.service.WmsToAcsService;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -79,4 +80,13 @@ public class WmsToAcsController {
|
||||
return new ResponseEntity<>(wmstoacsService.queryDeviceDBValue(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@PostMapping("/createtask")
|
||||
@Log("11")
|
||||
@ApiOperation("11")
|
||||
public ResponseEntity<Object> task(@RequestBody String whereJson){
|
||||
return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.acs.ext.wms.service;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.ext.wms.data.CreateTaskResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -62,4 +63,6 @@ public interface WmsToAcsService {
|
||||
*/
|
||||
Map<String, Object> queryDeviceDBValue(String whereJson);
|
||||
|
||||
CreateTaskResponse crateTask(String whereJson);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
|
||||
import org.nl.acs.ext.wms.data.CreateTaskRequest;
|
||||
import org.nl.acs.ext.wms.data.CreateTaskResponse;
|
||||
import org.nl.acs.ext.wms.data.JsonUtl;
|
||||
import org.nl.acs.ext.wms.service.WmsToAcsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
@@ -59,8 +62,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
String task_code = task.getString("task_code");
|
||||
String start_point_code = task.getString("start_device_code");
|
||||
String next_point_code = task.getString("next_device_code");
|
||||
String is_send = task.getString("is_send");
|
||||
String link_num = task.getString("link_num");
|
||||
String start_point_code2 = task.getString("start_device_code2");
|
||||
String next_point_code2 = task.getString("next_device_code2");
|
||||
String put_point_code = task.getString("put_device_code");
|
||||
String start_device_code = "";
|
||||
String next_device_code = "";
|
||||
if (StrUtil.isEmpty(task_code)) {
|
||||
@@ -131,8 +135,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
jo.put("start_device_code", start_device_code);
|
||||
jo.put("next_device_code", next_device_code);
|
||||
jo.put("priority", priority);
|
||||
jo.put("is_send", is_send);
|
||||
jo.put("link_num", link_num);
|
||||
jo.put("vehicle_code", vehicle_code);
|
||||
jo.put("vehicle_type", vehicle_type);
|
||||
jo.put("remark", remark);
|
||||
@@ -372,4 +374,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateTaskResponse crateTask(String json) {
|
||||
JSONArray datas = JSONArray.parseArray(json);
|
||||
|
||||
CreateTaskResponse response = new CreateTaskResponse();
|
||||
CreateTaskRequest request = JsonUtl.format(json, CreateTaskRequest.class);
|
||||
String containerCode = request.getContainerCode();
|
||||
response.setStatus(200);
|
||||
response.setMessage("success");
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -101,13 +101,6 @@ public interface InstructionService {
|
||||
*/
|
||||
void create(Instruction dto) throws Exception;
|
||||
|
||||
/**
|
||||
* 创建双工任务
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void createTwoInst(Instruction dto, Instruction dto2) throws Exception;
|
||||
|
||||
/**
|
||||
* 再次创建
|
||||
*
|
||||
|
||||
@@ -113,6 +113,26 @@ public class InstructionDto implements Serializable {
|
||||
*/
|
||||
private String next_device_code;
|
||||
|
||||
/**
|
||||
* 起始点位编码2
|
||||
*/
|
||||
private String start_point_code2;
|
||||
|
||||
/**
|
||||
* 起始设备编码2
|
||||
*/
|
||||
private String start_device_code2;
|
||||
|
||||
/**
|
||||
* 目标点位编码2
|
||||
*/
|
||||
private String next_point_code2;
|
||||
|
||||
/**
|
||||
* 目标设备编码2
|
||||
*/
|
||||
private String next_device_code2;
|
||||
|
||||
/**
|
||||
* 放货点位编码
|
||||
*/
|
||||
@@ -138,6 +158,21 @@ public class InstructionDto implements Serializable {
|
||||
*/
|
||||
private String from_z;
|
||||
|
||||
/**
|
||||
* 排2
|
||||
*/
|
||||
private String from_x2;
|
||||
|
||||
/**
|
||||
* 列2
|
||||
*/
|
||||
private String from_y2;
|
||||
|
||||
/**
|
||||
* 层2
|
||||
*/
|
||||
private String from_z2;
|
||||
|
||||
/**
|
||||
* 排
|
||||
*/
|
||||
@@ -169,6 +204,22 @@ public class InstructionDto implements Serializable {
|
||||
*/
|
||||
private String to_z;
|
||||
|
||||
/**
|
||||
* 排2
|
||||
*/
|
||||
private String to_x2;
|
||||
|
||||
/**
|
||||
* 列2
|
||||
*/
|
||||
private String to_y2;
|
||||
|
||||
/**
|
||||
* 层2
|
||||
*/
|
||||
private String to_z2;
|
||||
|
||||
|
||||
/**
|
||||
* 最后一条指令标识
|
||||
*/
|
||||
@@ -271,6 +322,12 @@ public class InstructionDto implements Serializable {
|
||||
*/
|
||||
private String agv_jobno;
|
||||
|
||||
|
||||
/**
|
||||
* agv指令类型(NDC系统使用)
|
||||
*/
|
||||
private String agv_inst_type;
|
||||
|
||||
/**
|
||||
* 下发agv状态 0未下发 1成功 2失败
|
||||
*/
|
||||
@@ -291,8 +348,4 @@ public class InstructionDto implements Serializable {
|
||||
*/
|
||||
private String agv_system_type;
|
||||
|
||||
/**
|
||||
* AGV指令类型
|
||||
*/
|
||||
private String agv_inst_type;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.nl.acs.auto.initial.ApplicationAutoInitial;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.haokai_auto_conveyor.HaoKaiAutoConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
@@ -38,7 +38,6 @@ import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -67,7 +66,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
DeviceAppService deviceAppService;
|
||||
@Autowired
|
||||
NDCAgvService ndcAgvService;
|
||||
@Autowired
|
||||
@Autowired
|
||||
ParamService paramService;
|
||||
@Autowired
|
||||
RouteLineService routeLineService;
|
||||
@@ -290,7 +289,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
dto.setStart_parent_code(task.getStart_parent_code());
|
||||
dto.setNext_parent_code(task.getNext_parent_code());
|
||||
|
||||
if(ObjectUtil.isNotEmpty(task.getTask_type())){
|
||||
if (ObjectUtil.isNotEmpty(task.getTask_type())) {
|
||||
dto.setInstruction_type(task.getTask_type());
|
||||
}
|
||||
|
||||
@@ -299,26 +298,26 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
|
||||
|
||||
CargoLiftConveyorDeviceDriver cargoLiftConveyorDeviceDriver;
|
||||
HaoKaiAutoConveyorDeviceDriver haoKaiAutoConveyorDeviceDriver;
|
||||
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
|
||||
//输送线相关需要给任务字段进行赋值,通过任务来判断输送线当前执行到哪一步
|
||||
if (startdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
|
||||
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||
cargoLiftConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver){
|
||||
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
|
||||
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) nextdevice.getDeviceDriver();
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(1,1);
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(1, 1);
|
||||
String address = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("address").toString();
|
||||
if (StrUtil.isEmpty(address)){
|
||||
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置电气调度号!");
|
||||
if (StrUtil.isEmpty(address)) {
|
||||
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
String door = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("door").toString();
|
||||
if (StrUtil.isEmpty(door)){
|
||||
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置门!");
|
||||
if (StrUtil.isEmpty(door)) {
|
||||
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置门!");
|
||||
}
|
||||
String floor = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("floor").toString();
|
||||
if (StrUtil.isEmpty(floor)){
|
||||
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!");
|
||||
if (StrUtil.isEmpty(floor)) {
|
||||
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置楼层!");
|
||||
}
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(2, Integer.parseInt(address));
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.parseInt(task_code));
|
||||
@@ -329,20 +328,20 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
|
||||
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver();
|
||||
standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
||||
if (nextdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver){
|
||||
if (nextdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
|
||||
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) nextdevice.getDeviceDriver();
|
||||
cargoLiftConveyorDeviceDriver.writing(1,1);
|
||||
cargoLiftConveyorDeviceDriver.writing(1, 1);
|
||||
String address = cargoLiftConveyorDeviceDriver.getExtraValue().get("address").toString();
|
||||
if (StrUtil.isEmpty(address)){
|
||||
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置电气调度号!");
|
||||
if (StrUtil.isEmpty(address)) {
|
||||
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置电气调度号!");
|
||||
}
|
||||
String door = cargoLiftConveyorDeviceDriver.getExtraValue().get("door").toString();
|
||||
if (StrUtil.isEmpty(door)){
|
||||
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置门!");
|
||||
if (StrUtil.isEmpty(door)) {
|
||||
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置门!");
|
||||
}
|
||||
String floor = cargoLiftConveyorDeviceDriver.getExtraValue().get("floor").toString();
|
||||
if (StrUtil.isEmpty(floor)){
|
||||
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!");
|
||||
if (StrUtil.isEmpty(floor)) {
|
||||
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置楼层!");
|
||||
}
|
||||
cargoLiftConveyorDeviceDriver.writing(2, Integer.parseInt(address));
|
||||
cargoLiftConveyorDeviceDriver.writing(3, Integer.parseInt(task_code));
|
||||
@@ -350,9 +349,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
cargoLiftConveyorDeviceDriver.writing(5, Integer.parseInt(floor));
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof HaoKaiAutoConveyorDeviceDriver) {
|
||||
haoKaiAutoConveyorDeviceDriver = (HaoKaiAutoConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||
haoKaiAutoConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
||||
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -365,12 +364,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
RouteLineDto routeLineDto = shortPathsList.get(i);
|
||||
String route_device = routeLineDto.getDevice_code();
|
||||
String route_next_device = routeLineDto.getNext_device_code();
|
||||
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())){
|
||||
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) {
|
||||
route = routeLineDto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isEmpty(route)){
|
||||
if (ObjectUtil.isEmpty(route)) {
|
||||
throw new BadRequestException("未查询到相关路由!");
|
||||
}
|
||||
if (StrUtil.equals(route.getType(), "1")) {
|
||||
@@ -395,149 +394,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
instructions.add(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTwoInst(Instruction dto, Instruction dto2) throws Exception {
|
||||
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
|
||||
if (ObjectUtils.isNotEmpty(dto)) {
|
||||
dto = foramte(dto);
|
||||
String task_code = dto.getTask_code();
|
||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||
String excutetype = null;
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
|
||||
dto.setRoute_plan_code(task.getRoute_plan_code());
|
||||
}
|
||||
if (StrUtil.isEmpty(dto.getPriority())) {
|
||||
dto.setPriority(task.getPriority());
|
||||
}
|
||||
if (StrUtil.isEmpty(dto.getInstruction_code())) {
|
||||
dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
|
||||
}
|
||||
if (StrUtil.isEmpty(dto.getInstruction_id())) {
|
||||
dto.setInstruction_id(IdUtil.simpleUUID());
|
||||
}
|
||||
JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0);
|
||||
if (instcheckjson != null) {
|
||||
throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!");
|
||||
}
|
||||
if (!StrUtil.isEmpty(dto.getVehicle_code())) {
|
||||
Instruction inst_dto = this.findByContainer(dto.getVehicle_code());
|
||||
if (ObjectUtils.isNotEmpty(inst_dto) && !StrUtil.equals(inst_dto.getTask_id(), dto.getTask_id())) {
|
||||
throw new WDKException("已存在该载具号的指令!");
|
||||
}
|
||||
}
|
||||
//起点设备与终点设备相同则为初始指令
|
||||
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) {
|
||||
dto.setCompound_inst("1");
|
||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||
}
|
||||
}
|
||||
|
||||
dto.setCreate_by(currentUsername);
|
||||
dto.setUpdate_by(currentUsername);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
dto.setStart_parent_code(task.getStart_parent_code());
|
||||
dto.setNext_parent_code(task.getNext_parent_code());
|
||||
}
|
||||
|
||||
if (ObjectUtils.isNotEmpty(dto2)) {
|
||||
dto2 = foramte(dto2);
|
||||
String task_code2 = dto2.getTask_code();
|
||||
TaskDto task2 = taskService.findByCodeFromCache(task_code2);
|
||||
String excutetype2 = null;
|
||||
WQLObject instwo2 = WQLObject.getWQLObject("acs_instruction");
|
||||
String currentUsername2 = SecurityUtils.getCurrentUsername();
|
||||
String now2 = DateUtil.now();
|
||||
if (StrUtil.isEmpty(dto2.getRoute_plan_code())) {
|
||||
dto2.setRoute_plan_code(task2.getRoute_plan_code());
|
||||
}
|
||||
if (StrUtil.isEmpty(dto2.getPriority())) {
|
||||
dto2.setPriority(task2.getPriority());
|
||||
}
|
||||
if (StrUtil.isEmpty(dto2.getInstruction_code())) {
|
||||
dto2.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
|
||||
}
|
||||
if (StrUtil.isEmpty(dto2.getInstruction_id())) {
|
||||
dto2.setInstruction_id(IdUtil.simpleUUID());
|
||||
}
|
||||
JSONObject instcheckjson2 = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0);
|
||||
if (instcheckjson2 != null) {
|
||||
throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!");
|
||||
}
|
||||
if (!StrUtil.isEmpty(dto2.getVehicle_code())) {
|
||||
Instruction inst_dto2 = this.findByContainer(dto2.getVehicle_code());
|
||||
if (ObjectUtils.isNotEmpty(inst_dto2) && !StrUtil.equals(inst_dto2.getTask_id(), dto2.getTask_id())) {
|
||||
throw new WDKException("已存在该载具号的指令!");
|
||||
}
|
||||
}
|
||||
//起点设备与终点设备相同则为初始指令
|
||||
if (StrUtil.equals(task2.getStart_device_code(), dto2.getStart_device_code())) {
|
||||
if (!StrUtil.equals(dto2.getCompound_inst(), "0") && StrUtil.equals(task2.getCompound_task(), "1")) {
|
||||
dto2.setCompound_inst("1");
|
||||
dto2.setCompound_inst_data(task2.getCompound_task_data());
|
||||
}
|
||||
}
|
||||
|
||||
dto2.setCreate_by(currentUsername2);
|
||||
dto2.setUpdate_by(currentUsername2);
|
||||
dto2.setUpdate_time(now2);
|
||||
dto2.setCreate_time(now2);
|
||||
dto2.setStart_parent_code(task2.getStart_parent_code());
|
||||
dto2.setNext_parent_code(task2.getNext_parent_code());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// != 0 为agv任务
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||
|
||||
if (StrUtil.equals("1", dto.getInstruction_type())) {
|
||||
ndcAgvService.sendAgvTwoInstToNDC(dto, dto2);
|
||||
dto.setSend_status("1");
|
||||
dto2.setSend_status("1");
|
||||
} else if (StrUtil.equals("2", dto.getInstruction_type())) {
|
||||
dto.setSend_status("1");
|
||||
ndcAgvService.sendAgvTwoInstToNDC(dto, null);
|
||||
} else if (StrUtil.equals("3", dto.getInstruction_type())) {
|
||||
|
||||
} else if (StrUtil.equals("4", dto.getInstruction_type())) {
|
||||
|
||||
} else if (StrUtil.equals("5", dto.getInstruction_type())) {
|
||||
|
||||
} else if (StrUtil.equals("6", dto.getInstruction_type())) {
|
||||
dto.setSend_status("1");
|
||||
ndcAgvService.sendAgvOneInstToNDC(dto);
|
||||
} else if (StrUtil.equals("7", dto.getInstruction_type())) {
|
||||
ndcAgvService.sendAgvOneInstToNDC(dto);
|
||||
dto.setSend_status("1");
|
||||
} else if (StrUtil.equals("8", dto.getInstruction_type())) {
|
||||
dto.setSend_status("1");
|
||||
ndcAgvService.sendAgvOneInstToNDC(dto);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (ObjectUtil.isNotEmpty(dto)) {
|
||||
dto.setSend_status("2");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(dto2)) {
|
||||
dto2.setSend_status("2");
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
JSONObject json2 = (JSONObject) JSONObject.toJSON(dto2);
|
||||
wo.insert(json);
|
||||
wo.insert(json2);
|
||||
instructions.add(dto);
|
||||
instructions.add(dto2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
Reference in New Issue
Block a user