opt: ndc驱动、解包完善
This commit is contained in:
@@ -12,17 +12,16 @@ import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
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.domain.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -39,7 +38,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
|
||||
private final DeviceAppService deviceAppService;
|
||||
private final ISysParamService paramService;
|
||||
// private final AcsToWmsService acsToWmsService;
|
||||
// private final AcsToWmsService acsToWmsService;
|
||||
private final ISysDictService dictService;
|
||||
private final DeviceExecuteLogService logServer;
|
||||
|
||||
@@ -85,187 +84,79 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() +
|
||||
",nextAddress:" + inst.getNext_point_code());
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||
if (!StrUtil.equals(agv_system_type, "1")) {
|
||||
String instcode = inst.getInstruction_code();
|
||||
int type = Integer.parseInt(inst.getAgv_inst_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2());
|
||||
int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2());
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(type);
|
||||
byte typelow = (byte) IntToHexLow(type);
|
||||
byte qhdhigh = (byte) IntToHexHigh(startAddress);
|
||||
byte qhdlow = (byte) IntToHexLow(startAddress);
|
||||
byte qhdhigh2 = (byte) IntToHexHigh(startAddress2);
|
||||
byte qhdlow2 = (byte) IntToHexLow(startAddress2);
|
||||
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
|
||||
byte fhdlow = (byte) IntToHexLow(nextAddress);
|
||||
byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2);
|
||||
byte fhdlow2 = (byte) IntToHexLow(nextAddress2);
|
||||
byte prioritylow = (byte) IntToHexLow(priority);
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "任务号 ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "任务号 ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
String instcode = inst.getInstruction_code();
|
||||
int type = Integer.parseInt(inst.getAgv_inst_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
// 车号。。。
|
||||
String carno = inst.getCarno();
|
||||
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);
|
||||
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
|
||||
byte carlow = (byte) IntToHexLow(Integer.parseInt(carno));
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "任务号 ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "任务号 ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
|
||||
str += "指令类型 /type:" + (type);
|
||||
str1 += "指令类型 /type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
str += "指令类型 /type:" + (type);
|
||||
str1 += "指令类型 /type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
|
||||
str += "取货点 /qhd:" + (startAddress);
|
||||
str1 += "取货点 /qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
|
||||
str += "放货点 /fhd:" + (nextAddress);
|
||||
str1 += "放货点 /fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
|
||||
str += "取货点 /qhd:" + (startAddress);
|
||||
str1 += "取货点 /qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
|
||||
str += "放货点 /fhd:" + (nextAddress);
|
||||
str1 += "放货点 /fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
|
||||
|
||||
str += "取货点2 /qhd2:" + (startAddress2);
|
||||
str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF);
|
||||
str += "放货点2 /fhd2:" + (nextAddress2);
|
||||
str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF);
|
||||
str += "取货点2 /qhd2:" + (startAddress2);
|
||||
str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF);
|
||||
str += "放货点2 /fhd2:" + (nextAddress2);
|
||||
str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF);
|
||||
|
||||
str += "优先级 /priority:" + (priority);
|
||||
str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
|
||||
str += "优先级 /priority:" + (priority);
|
||||
str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
|
||||
|
||||
byte[] b = new byte[]{};
|
||||
if (type == 1) {
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X16,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X12,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) qhdhigh2, (byte) qhdlow2,
|
||||
(byte) fhdhigh, (byte) fhdlow,
|
||||
(byte) fhdhigh2, (byte) fhdlow2
|
||||
};
|
||||
} else if (type == 2) {
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X16,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X12,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) 0X00, (byte) 0X00,
|
||||
(byte) fhdhigh, (byte) fhdlow,
|
||||
(byte) 0X00, (byte) 0X00
|
||||
};
|
||||
} else if (type == 3) {
|
||||
b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X16,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X12,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) qhdhigh2, (byte) qhdlow2,
|
||||
(byte) fhdhigh, (byte) fhdlow,
|
||||
(byte) fhdhigh2, (byte) fhdlow2
|
||||
};
|
||||
}
|
||||
log.info("下发AGV作业指令 --{}", str1);
|
||||
log.info("下发AGV作业指令--{}", str);
|
||||
log.info("下发agv指令数据--{}", Bytes2HexString(b));
|
||||
str += "车号 /carno:" + (carno);
|
||||
str1 += "车号 /carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
|
||||
|
||||
if (StrUtil.equals(agv_system_type, "2")) {
|
||||
TwoNDCSocketConnectionAutoRun.write(b);
|
||||
}
|
||||
} else {
|
||||
byte[] b = new byte[]{
|
||||
(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X18,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X14,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) fhdhigh, (byte) fhdlow,
|
||||
(byte) qhdhigh2, (byte) qhdlow2,
|
||||
(byte) fhdhigh2, (byte) fhdlow2,
|
||||
(byte) carhigh, (byte) carlow
|
||||
};
|
||||
log.info("下发AGV作业指令 --{}", str1);
|
||||
log.info("下发AGV作业指令--{}", str);
|
||||
log.info("下发agv指令数据--{}", Bytes2HexString(b));
|
||||
|
||||
String instcode = inst.getInstruction_code();
|
||||
int startHeight = Integer.parseInt(StrUtil.isEmpty(inst.getStart_height()) ? "0" : inst.getStart_height());
|
||||
int nextHeight = Integer.parseInt(StrUtil.isEmpty(inst.getNext_height()) ? "0" : inst.getNext_height());
|
||||
//默认取货放货高度都为0
|
||||
//int type = Integer.parseInt(inst.getInstruction_type());
|
||||
int type = 4;
|
||||
if (startHeight != 0 && nextHeight != 0) {
|
||||
//取货放货高度都不为0
|
||||
type = 1;
|
||||
} else if (startHeight != 0 && nextHeight == 0) {
|
||||
//取货高度不为0 放货高度为0
|
||||
type = 2;
|
||||
} else if (startHeight == 0 && nextHeight != 0) {
|
||||
//取货高度为0 放货高度不为0
|
||||
type = 3;
|
||||
}
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(type);
|
||||
byte typelow = (byte) IntToHexLow(type);
|
||||
byte qhdhigh = (byte) IntToHexHigh(startAddress);
|
||||
byte qhdlow = (byte) IntToHexLow(startAddress);
|
||||
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
|
||||
byte fhdlow = (byte) IntToHexLow(nextAddress);
|
||||
byte prioritylow = (byte) IntToHexLow(priority);
|
||||
|
||||
byte shhigh = (byte) IntToHexHigh(startHeight);
|
||||
byte shlow = (byte) IntToHexLow(startHeight);
|
||||
|
||||
byte nhhigh = (byte) IntToHexHigh(nextHeight);
|
||||
byte nhlow = (byte) IntToHexLow(nextHeight);
|
||||
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
|
||||
str += "/type:" + (type);
|
||||
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
|
||||
str += "/qhd:" + (startAddress);
|
||||
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
|
||||
str += "/fhd:" + (nextAddress);
|
||||
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
|
||||
|
||||
str += "/priority:" + (priority);
|
||||
str1 += "/priority:" + hexToString(prioritylow & 0xFF);
|
||||
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X16,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X12,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) fhdhigh, (byte) fhdlow,
|
||||
(byte) shhigh, (byte) shlow,
|
||||
(byte) nhhigh, (byte) nhlow
|
||||
};
|
||||
log.info("下发AGV作业指令 --{}", str1);
|
||||
log.info("下发AGV作业指令--{}", str);
|
||||
log.info("下发agv指令数据--{}", Bytes2HexString(b));
|
||||
if (StrUtil.equals(agv_system_type, "2")) {
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
}
|
||||
}
|
||||
@@ -450,18 +341,18 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
public void charge(String carno) {
|
||||
//检查数据字典station为0的参数
|
||||
//分配车辆
|
||||
Dict dict = dictService.getDictByName3("station",carno,null);
|
||||
int satation=0;
|
||||
if(ObjectUtil.isNotEmpty(dict)){
|
||||
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1());
|
||||
Dict dict = dictService.getDictByName3("station", carno, null);
|
||||
int satation = 0;
|
||||
if (ObjectUtil.isNotEmpty(dict)) {
|
||||
log.info("当前车辆{}已分配充电桩{},退出后续判断", carno, dict.getPara1());
|
||||
return;
|
||||
}
|
||||
Dict temp = dictService.getDictByName2("station");
|
||||
if(ObjectUtil.isNotEmpty(temp)){
|
||||
if (ObjectUtil.isNotEmpty(temp)) {
|
||||
satation = Integer.parseInt(temp.getPara1());
|
||||
}
|
||||
if(satation!=0){
|
||||
String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
|
||||
if (satation != 0) {
|
||||
String instcode = CodeUtil.getNewCode("INSTRUCT_NO");
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
|
||||
@@ -492,10 +383,10 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
};
|
||||
log.info("下发AGV充电任务--{}", str1);
|
||||
|
||||
try{
|
||||
try {
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
} catch (Exception e){
|
||||
log.error("下发充电任务失败{}{}",e,e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("下发充电任务失败{}{}", e, e.getMessage());
|
||||
}
|
||||
|
||||
temp.setValue("1");
|
||||
@@ -503,8 +394,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
temp.setPara3("下发充电");
|
||||
dictService.updateDetail(temp);
|
||||
|
||||
}else{
|
||||
log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务",carno);
|
||||
} else {
|
||||
log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务", carno);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,10 +483,10 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
Dict temp = dictService.getDictByName2("station", station);
|
||||
if (ObjectUtil.isNotEmpty(temp)) {
|
||||
int satation = 0;
|
||||
if(ObjectUtil.isNotEmpty(temp)){
|
||||
if (ObjectUtil.isNotEmpty(temp)) {
|
||||
satation = Integer.parseInt(temp.getPara1());
|
||||
}
|
||||
String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
|
||||
String instcode = CodeUtil.getNewCode("INSTRUCT_NO");
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
|
||||
@@ -626,13 +517,13 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
};
|
||||
log.info("下发AGV充电任务--{}", str1);
|
||||
|
||||
try{
|
||||
try {
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
temp.setValue("1");
|
||||
temp.setPara2(String.valueOf(carno));
|
||||
dictService.updateDetail(temp);
|
||||
} catch (Exception e){
|
||||
log.error("下发充电任务失败{}{}",e,e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("下发充电任务失败{}{}", e, e.getMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -226,4 +227,10 @@ public class CreateTaskRequest extends BaseRequest {
|
||||
* 17 木箱堆叠行架任务
|
||||
*/
|
||||
private String class_type;
|
||||
|
||||
|
||||
private String task_group_id;
|
||||
|
||||
|
||||
private BigDecimal task_group_seq;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,21 @@ public class WmsToAcsController {
|
||||
return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/action")
|
||||
@Log(value = "WMS下发点位信号")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> putAction(@RequestBody String whereJson) throws Exception {
|
||||
return new ResponseEntity<>(wmstoacsService.putAction(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/querydevice")
|
||||
@Log(value = "WMS查询设备状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryDevice(@RequestBody String whereJson) throws Exception {
|
||||
return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/cancelTask")
|
||||
@Log(value = "WMS取消任务")
|
||||
@SaIgnore
|
||||
@@ -69,20 +84,6 @@ public class WmsToAcsController {
|
||||
return new ResponseEntity<>(wmstoacsService.areaControl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/action")
|
||||
@Log(value = "WMS下发点位信号")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> putAction(@RequestBody String whereJson) throws Exception {
|
||||
return new ResponseEntity<>(wmstoacsService.putAction(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/querydevice")
|
||||
@Log(value = "WMS查询设备状态")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryDevice(@RequestBody String whereJson) throws Exception {
|
||||
return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryDeviceDBValue")
|
||||
@Log(value = "WMS查询设备DB值")
|
||||
@SaIgnore
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver;
|
||||
import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.zz_driver.unpacking_machine.UnpackingMachineDeviceDriver;
|
||||
import org.nl.acs.ext.wms.data.*;
|
||||
|
||||
import org.nl.acs.ext.wms.service.WmsToAcsService;
|
||||
@@ -37,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@@ -86,6 +88,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
// response.setErrArr(datas);
|
||||
// return response;
|
||||
// }
|
||||
// 将LMS任务转成ACS任务并保存
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
String data = datas.get(i).toString();
|
||||
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);
|
||||
@@ -115,6 +118,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
String storage_task_type = request.getDtl_type();
|
||||
String agv_system_type = request.getAgv_system_type();
|
||||
String remark = request.getRemark();
|
||||
String taskGroupId = request.getTask_group_id();
|
||||
BigDecimal taskGroupSeq = request.getTask_group_seq();
|
||||
double oven_time = 0.00d;
|
||||
if (StrUtil.isNotEmpty(request.getOven_time())) {
|
||||
oven_time = Double.parseDouble(request.getOven_time());
|
||||
@@ -296,6 +301,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("task_id", IdUtil.simpleUUID());
|
||||
jo.put("task_code", task_code);
|
||||
jo.put("task_group_id", taskGroupId);
|
||||
jo.put("task_group_seq", taskGroupSeq);
|
||||
jo.put("start_point_code", start_point_code);
|
||||
jo.put("next_point_code", next_point_code);
|
||||
jo.put("start_point_code2", start_point_code2);
|
||||
@@ -586,7 +593,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
|
||||
//标准版输送线
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
|
||||
|
||||
UnpackingMachineDeviceDriver unpackingMachineDeviceDriver;
|
||||
|
||||
if (datas.size() == 0) {
|
||||
throw new BadRequestException("缺少输入参数!");
|
||||
@@ -614,6 +621,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
jo.put("move", beltConveyorDeviceDriver.getMove());
|
||||
jo.put("mode", beltConveyorDeviceDriver.getMode());
|
||||
jo.put("device_code", parent_device_code);
|
||||
} else if (device.getDeviceDriver() instanceof UnpackingMachineDeviceDriver) {
|
||||
unpackingMachineDeviceDriver = (UnpackingMachineDeviceDriver) device.getDeviceDriver();
|
||||
jo.put("move", unpackingMachineDeviceDriver.getMove());
|
||||
jo.put("mode", unpackingMachineDeviceDriver.getMode());
|
||||
jo.put("gross_weight", unpackingMachineDeviceDriver.getGross_weight());
|
||||
jo.put("net_weight", unpackingMachineDeviceDriver.getNet_weight());
|
||||
jo.put("device_code", parent_device_code);
|
||||
} else {
|
||||
jo.put("device_code", parent_device_code);
|
||||
}
|
||||
|
||||
@@ -244,6 +244,8 @@ public class InstructionMybatis extends CommonModel<InstructionMybatis> implemen
|
||||
|
||||
|
||||
private Integer agv_action_type;
|
||||
private String task_group_id;
|
||||
private BigDecimal task_group_seq;
|
||||
|
||||
public void copyFrom(Instruction source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
@@ -380,4 +381,6 @@ public class InstructionDto implements Serializable {
|
||||
*
|
||||
*/
|
||||
// private String to_device_code;
|
||||
private String task_group_id;
|
||||
private BigDecimal task_group_seq;
|
||||
}
|
||||
|
||||
@@ -461,6 +461,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
}
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
// hint ----
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||
}
|
||||
//判断是否是仙工AGV
|
||||
|
||||
@@ -256,6 +256,8 @@ public class Task extends CommonModel<Task> implements Serializable {
|
||||
* 15 RGV输送任务
|
||||
*/
|
||||
private String class_type;
|
||||
private String task_group_id;
|
||||
private BigDecimal task_group_seq;
|
||||
|
||||
public void copyFrom(Task source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
@@ -370,4 +371,6 @@ public class TaskDto implements Serializable {
|
||||
* 15 RGV输送任务
|
||||
*/
|
||||
private String class_type;
|
||||
private String task_group_id;
|
||||
private BigDecimal task_group_seq;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package org.nl.system.service.quartz.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.instruction.domain.InstructionMybatis;
|
||||
import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.limit_regional.server.LimitRegionalService;
|
||||
import org.nl.acs.limit_regional.server.dto.LimitRegionalDto;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
@@ -33,8 +29,11 @@ import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.config.lucene.service.impl.LuceneExecuteLogServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 自动创建指令
|
||||
@@ -43,6 +42,16 @@ import java.util.List;
|
||||
@Component
|
||||
public class AutoCreateInst {
|
||||
|
||||
Map<String, Integer> carTaskCount = new ConcurrentHashMap<>();
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if (carTaskCount.isEmpty()) {
|
||||
carTaskCount.put("1", 0);
|
||||
carTaskCount.put("2", 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务状态创建指令、生成下一条指令
|
||||
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
|
||||
@@ -55,180 +64,204 @@ public class AutoCreateInst {
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogServiceImpl.class);
|
||||
List<TaskDto> list = taskserver.queryAllByStatus("0");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TaskDto acsTask = list.get(i);
|
||||
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
|
||||
continue;
|
||||
}
|
||||
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
|
||||
continue;
|
||||
}
|
||||
String taskid = acsTask.getTask_id();
|
||||
String taskcode = acsTask.getTask_code();
|
||||
String task_type = acsTask.getTask_type();
|
||||
String vehiclecode = acsTask.getVehicle_code();
|
||||
String vehiclecode2 = acsTask.getVehicle_code2();
|
||||
String storage_task_type = acsTask.getStorage_task_type();
|
||||
String priority = acsTask.getPriority();
|
||||
String is_send = acsTask.getIs_send();
|
||||
|
||||
String start_device_code = acsTask.getStart_device_code();
|
||||
String start_point_code = acsTask.getStart_point_code();
|
||||
|
||||
String put_device_code = acsTask.getPut_device_code();
|
||||
String put_point_code = acsTask.getPut_point_code();
|
||||
|
||||
String next_device_code = acsTask.getNext_device_code();
|
||||
String next_point_code = acsTask.getNext_point_code();
|
||||
|
||||
String start_point_code2 = acsTask.getStart_point_code2();
|
||||
String start_device_code2 = acsTask.getStart_device_code2();
|
||||
|
||||
String next_point_code2 = acsTask.getNext_point_code2();
|
||||
String next_device_code2 = acsTask.getNext_device_code2();
|
||||
|
||||
String route_plan_code = acsTask.getRoute_plan_code();
|
||||
String vehicleType = acsTask.getVehicle_type();
|
||||
String agv_system_type = acsTask.getAgv_system_type();
|
||||
|
||||
String start_height = acsTask.getStart_height();
|
||||
String next_height = acsTask.getNext_height();
|
||||
Integer agvActionType = acsTask.getAgv_action_type();
|
||||
|
||||
|
||||
if (StrUtil.equals(is_send, "0")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//校验路由关系
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||
acsTask.setRemark("路由不通无法生成指令");
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||
String path = routeLineDto.getPath();
|
||||
String type = routeLineDto.getType();
|
||||
String[] str = path.split("->");
|
||||
List<String> pathlist = Arrays.asList(str);
|
||||
int index = 0;
|
||||
boolean flag = false;
|
||||
for (int m = 0; m < pathlist.size(); m++) {
|
||||
if (pathlist.get(m).equals(start_device_code)) {
|
||||
if("1".equals(acsTask.getTask_type()) && !pathlist.get(m+1).equals(next_device_code)){
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
index = m + 1;
|
||||
break;
|
||||
// 根据任务组别分组
|
||||
Map<String, List<TaskDto>> groupTasks = list.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
TaskDto::getTask_group_id,
|
||||
Collectors.mapping(
|
||||
task -> task,
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.toList(),
|
||||
tasks -> tasks.stream()
|
||||
.sorted(Comparator.comparing(TaskDto::getTask_group_seq))
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
)
|
||||
));
|
||||
for (String groupId : groupTasks.keySet()) {
|
||||
List<TaskDto> taskDtos = groupTasks.get(groupId);
|
||||
// carTaskCount根据value从小到大排序
|
||||
List<Map.Entry<String, Integer>> sortedEntries = new ArrayList<>(carTaskCount.entrySet());
|
||||
sortedEntries.sort(Map.Entry.comparingByValue());
|
||||
// 获取车号
|
||||
String carNo = null;
|
||||
for (Map.Entry<String, Integer> entry : sortedEntries) {
|
||||
String carKey = entry.getKey();
|
||||
Device deviceByCode = appService.findDeviceByCode(carKey);
|
||||
AgvNdcOneDeviceDriver deviceDriver = (AgvNdcOneDeviceDriver) deviceByCode.getDeviceDriver();
|
||||
if (deviceDriver.getStatus() == 2 || deviceDriver.getStatus() == 4) {
|
||||
carNo = carKey;
|
||||
carTaskCount.put(carKey, carTaskCount.get(carKey) + 1);
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
acsTask.setRemark("路由不通无法生成指令");
|
||||
taskserver.update(acsTask);
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
if (carNo == null) {
|
||||
return;
|
||||
}
|
||||
next_device_code = pathlist.get(index);
|
||||
|
||||
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
|
||||
} else {
|
||||
next_point_code = next_device_code;
|
||||
}
|
||||
|
||||
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_type(task_type);
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
if (acsTask.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())){
|
||||
instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
|
||||
}
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setRemark(acsTask.getRemark());
|
||||
instdto.setMaterial(acsTask.getMaterial());
|
||||
instdto.setQuantity(acsTask.getQuantity());
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setVehicle_code(vehiclecode);
|
||||
instdto.setVehicle_code2(vehiclecode2);
|
||||
String now = DateUtil.now();
|
||||
instdto.setCreate_time(now);
|
||||
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
|
||||
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setPut_device_code(put_device_code);
|
||||
instdto.setPut_point_code(put_point_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
|
||||
instdto.setStart_point_code2(start_point_code2);
|
||||
instdto.setStart_device_code2(start_device_code2);
|
||||
instdto.setNext_point_code2(next_point_code2);
|
||||
instdto.setNext_device_code2(next_device_code2);
|
||||
|
||||
instdto.setPriority(priority);
|
||||
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
|
||||
instdto.setExecute_device_code(start_point_code);
|
||||
instdto.setVehicle_type(vehicleType);
|
||||
instdto.setAgv_system_type(agv_system_type);
|
||||
instdto.setStart_height(start_height);
|
||||
instdto.setNext_height(next_height);
|
||||
instdto.setAgv_action_type(agvActionType);
|
||||
//判断agv系统
|
||||
//1、1楼叉车系统
|
||||
//2、2楼1区域AGV系统
|
||||
//3、2楼2区域AGV系统 -已废弃
|
||||
if (StrUtil.equals(agv_system_type, CommonFinalParam.TWO)) {
|
||||
// task_type
|
||||
//1、生箔; Itype=1:取空,取满,放空,放满;
|
||||
//2、分切 Itype=3取满、取空、放满、放空;
|
||||
//3、普通任务 Itype=2:取货、放货;
|
||||
//4、叉车任务
|
||||
//5、输送任务
|
||||
//6、行架
|
||||
//7、立库
|
||||
if (StrUtil.equals(task_type, CommonFinalParam.ONE)) {
|
||||
instdto.setAgv_inst_type(CommonFinalParam.ONE);
|
||||
} else if (StrUtil.equals(task_type, "3")) {
|
||||
instdto.setAgv_inst_type("2");
|
||||
} else if (StrUtil.equals(task_type, "2")) {
|
||||
instdto.setAgv_inst_type("3");
|
||||
} else if (StrUtil.equals(task_type, "8")) {
|
||||
instdto.setAgv_inst_type("2");
|
||||
} else {
|
||||
log.info("未找到对应的AGV指令类型,任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type());
|
||||
for (int i = 0; i < taskDtos.size(); i++) {
|
||||
TaskDto acsTask = taskDtos.get(i);
|
||||
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
instdto.setAgv_inst_type("4");
|
||||
}
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
acsTask.setRemark(e.getMessage());
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code("定时创建指令失败")
|
||||
.content(e.getMessage())
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
continue;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
|
||||
continue;
|
||||
}
|
||||
String taskid = acsTask.getTask_id();
|
||||
String taskcode = acsTask.getTask_code();
|
||||
String task_type = acsTask.getTask_type();
|
||||
String vehiclecode = acsTask.getVehicle_code();
|
||||
String vehiclecode2 = acsTask.getVehicle_code2();
|
||||
String storage_task_type = acsTask.getStorage_task_type();
|
||||
String priority = acsTask.getPriority();
|
||||
String is_send = acsTask.getIs_send();
|
||||
|
||||
String start_device_code = acsTask.getStart_device_code();
|
||||
String start_point_code = acsTask.getStart_point_code();
|
||||
|
||||
String put_device_code = acsTask.getPut_device_code();
|
||||
String put_point_code = acsTask.getPut_point_code();
|
||||
|
||||
String next_device_code = acsTask.getNext_device_code();
|
||||
String next_point_code = acsTask.getNext_point_code();
|
||||
|
||||
String start_point_code2 = acsTask.getStart_point_code2();
|
||||
String start_device_code2 = acsTask.getStart_device_code2();
|
||||
|
||||
String next_point_code2 = acsTask.getNext_point_code2();
|
||||
String next_device_code2 = acsTask.getNext_device_code2();
|
||||
|
||||
String route_plan_code = acsTask.getRoute_plan_code();
|
||||
String vehicleType = acsTask.getVehicle_type();
|
||||
String agv_system_type = acsTask.getAgv_system_type();
|
||||
|
||||
String start_height = acsTask.getStart_height();
|
||||
String next_height = acsTask.getNext_height();
|
||||
Integer agvActionType = acsTask.getAgv_action_type();
|
||||
|
||||
String taskGroupId = acsTask.getTask_group_id();
|
||||
BigDecimal taskGroupSeq = acsTask.getTask_group_seq();
|
||||
|
||||
if (StrUtil.equals(is_send, "0")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//校验路由关系
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||
acsTask.setRemark("路由不通无法生成指令");
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||
String path = routeLineDto.getPath();
|
||||
String type = routeLineDto.getType();
|
||||
String[] str = path.split("->");
|
||||
List<String> pathlist = Arrays.asList(str);
|
||||
int index = 0;
|
||||
boolean flag = false;
|
||||
for (int m = 0; m < pathlist.size(); m++) {
|
||||
if (pathlist.get(m).equals(start_device_code)) {
|
||||
if("1".equals(acsTask.getTask_type()) && !pathlist.get(m+1).equals(next_device_code)){
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
index = m + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
acsTask.setRemark("路由不通无法生成指令");
|
||||
taskserver.update(acsTask);
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
next_device_code = pathlist.get(index);
|
||||
|
||||
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
|
||||
} else {
|
||||
next_point_code = next_device_code;
|
||||
}
|
||||
|
||||
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_type(task_type);
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
if (acsTask.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())){
|
||||
instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
|
||||
}
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setRemark(acsTask.getRemark());
|
||||
instdto.setMaterial(acsTask.getMaterial());
|
||||
instdto.setQuantity(acsTask.getQuantity());
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setVehicle_code(vehiclecode);
|
||||
instdto.setVehicle_code2(vehiclecode2);
|
||||
String now = DateUtil.now();
|
||||
instdto.setCreate_time(now);
|
||||
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
|
||||
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setPut_device_code(put_device_code);
|
||||
instdto.setPut_point_code(put_point_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
|
||||
instdto.setStart_point_code2(start_point_code2);
|
||||
instdto.setStart_device_code2(start_device_code2);
|
||||
instdto.setNext_point_code2(next_point_code2);
|
||||
instdto.setNext_device_code2(next_device_code2);
|
||||
|
||||
instdto.setTask_group_id(taskGroupId);
|
||||
instdto.setTask_group_seq(taskGroupSeq);
|
||||
|
||||
instdto.setPriority(priority);
|
||||
instdto.setCarno(carNo);
|
||||
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
|
||||
instdto.setExecute_device_code(start_point_code);
|
||||
instdto.setVehicle_type(vehicleType);
|
||||
instdto.setAgv_system_type(agv_system_type);
|
||||
instdto.setStart_height(start_height);
|
||||
instdto.setNext_height(next_height);
|
||||
instdto.setAgv_action_type(agvActionType);
|
||||
//判断agv系统
|
||||
//1、1楼叉车系统
|
||||
//2、2楼1区域AGV系统
|
||||
//3、2楼2区域AGV系统 -已废弃
|
||||
|
||||
if (ObjectUtil.isEmpty(task_type)) {
|
||||
log.info("未找到对应的AGV指令类型,任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type());
|
||||
continue;
|
||||
} else {
|
||||
instdto.setAgv_inst_type(task_type);
|
||||
}
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
acsTask.setRemark(e.getMessage());
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code("定时创建指令失败")
|
||||
.content(e.getMessage())
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
continue;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
acsTask.setUpdate_time(DateUtil.now());
|
||||
acsTask.setRemark(" ");
|
||||
taskserver.update(acsTask);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user