rev:堆垛机任务优先级优化以及贴标机、堆叠行架优化

This commit is contained in:
2024-08-22 19:32:47 +08:00
parent 1a37c3b38c
commit e7acfbf034
16 changed files with 465 additions and 240 deletions

View File

@@ -64,6 +64,9 @@ public interface NDCAgvService {
*/
public byte[] sendAgvTwoModeInst(int phase, int index, int result,int offset,int quantity);
public byte[] sendAgvTwoModeInst();
/**
* 下发一号agv指令
* @param phase

View File

@@ -369,6 +369,16 @@ public class NDCAgvServiceImpl implements NDCAgvService {
return b;
}
@Override
public byte[] sendAgvTwoModeInst() {
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X00,
(byte) 0X00, (byte) 0X04,
};
return b;
}
@Override
public byte[] sendAgvOneModeInst(int phase, int index, int result) {

View File

@@ -19,6 +19,7 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -134,182 +135,193 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
}
System.out.println("收到请求参数:" + bs);
boolean flag = false;
if (arr[8] * 256 + arr[9] == 0x73) {
byte[] data = null;
System.out.println("接收agv上报信息" + bs);
//执行阶段
int phase = arr[16] * 256 + arr[17];
// agv任务号
int index = arr[12] * 256 + arr[13];
//任务号
int ikey = arr[26] * 256 + arr[27];
//站点号
int agvaddr = arr[18] * 256 + arr[19];
//车号
int carno = arr[20];
Instruction inst = null;
if (ikey != 0) {
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
}
log.info("接收agv上报信息" + bs);
log.info("接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
Device device = null;
String device_code = null;
String old_device_code = null;
String emptyNum = null;
//自动门
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver;
if (agvaddr != 0) {
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
if (StrUtil.contains(old_device_code, "-")) {
String[] point = old_device_code.split("-");
device_code = point[0];
} else if (StrUtil.contains(old_device_code, ".")) {
String[] point = old_device_code.split("\\.");
device_code = point[0];
emptyNum = point[1];
} else {
device_code = old_device_code;
}
device = deviceAppService.findDeviceByCode(device_code);
}
AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver;
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
//开始任务
if (phase == 0x01) {
if (!ObjectUtil.isEmpty(inst)) {
inst.setInstruction_status("1");
inst.setAgv_jobno(String.valueOf(index));
inst.setSend_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
boolean flag = false;
if (arr.length < 10) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("ndc")
.content("接收agv上报信息" + bs)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
log.info("接收agv上报信息" + bs);
} else {
if (arr[8] * 256 + arr[9] == 0x73) {
byte[] data = null;
System.out.println("接收agv上报信息" + bs);
//执行阶段
int phase = arr[16] * 256 + arr[17];
// agv任务号
int index = arr[12] * 256 + arr[13];
//任务号
int ikey = arr[26] * 256 + arr[27];
//站点号
int agvaddr = arr[18] * 256 + arr[19];
//车号
int carno = arr[20];
Instruction inst = null;
if (ikey != 0) {
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
}
flag = true;
}
//任务完毕
//无车id及状态
else if (phase == 0x14) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
} else {
String agvcar = inst.getCarno();
Device agvDevice = deviceAppService.findDeviceByCode(agvcar);
if (agvDevice != null) {
if (agvDevice.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) agvDevice.getDeviceDriver();
agvNdcTwoDeviceDriver.setInstruction(null);
} else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
agvNdcOneDeviceDriver.setInstruction(null);
log.info("接收agv上报信息" + bs);
log.info("接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
Device device = null;
String device_code = null;
String old_device_code = null;
String emptyNum = null;
//自动门
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver;
if (agvaddr != 0) {
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
if (StrUtil.contains(old_device_code, "-")) {
String[] point = old_device_code.split("-");
device_code = point[0];
} else if (StrUtil.contains(old_device_code, ".")) {
String[] point = old_device_code.split("\\.");
device_code = point[0];
emptyNum = point[1];
} else {
device_code = old_device_code;
}
device = deviceAppService.findDeviceByCode(device_code);
}
AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver;
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
//开始任务
if (phase == 0x01) {
if (!ObjectUtil.isEmpty(inst)) {
inst.setInstruction_status("1");
inst.setAgv_jobno(String.valueOf(index));
inst.setSend_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
flag = true;
}
//任务完毕
//无车id及状态
else if (phase == 0x14) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
} else {
String agvcar = inst.getCarno();
Device agvDevice = deviceAppService.findDeviceByCode(agvcar);
if (agvDevice != null) {
if (agvDevice.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) agvDevice.getDeviceDriver();
agvNdcTwoDeviceDriver.setInstruction(null);
} else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
agvNdcOneDeviceDriver.setInstruction(null);
}
}
inst.setInstruction_status("2");
try {
instructionService.finish(inst);
} catch (Exception e) {
e.printStackTrace();
}
}
inst.setInstruction_status("2");
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
//请求删除任务
//(需要WCS反馈)
else if (phase == 0x30) {
// data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0, 0, 0);
}
//任务删除确认
//(需要WCS反馈)
else if (phase == 0xFF) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
} else {
instructionService.cancelNOSendAgv(inst.getInstruction_id());
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else if (phase == 0x50) {
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
if (ObjectUtil.isNotEmpty(device)) {
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
try {
standardAutodoorDeviceDriver.writing("to_open", "1");
standardAutodoorDeviceDriver.writing("to_close", "0");
} catch (Exception e) {
log.info("下发电气信号失败:" + e.getMessage());
e.printStackTrace();
}
if (standardAutodoorDeviceDriver.getOpen() == 1 && standardAutodoorDeviceDriver.getToOpen() == 1) {
log.info("下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getOpen());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getToClose());
}
}
} else {
log.info(agvaddr + "对应设备号为空!");
}
} else if (phase == 0x51) {
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
if (ObjectUtil.isNotEmpty(device)) {
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
try {
standardAutodoorDeviceDriver.writing("to_close", "1");
standardAutodoorDeviceDriver.writing("to_open", "0");
} catch (Exception e) {
log.info("下发电气信号失败:" + e.getMessage());
e.printStackTrace();
}
if (standardAutodoorDeviceDriver.getClose() == 1) {
log.info("读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
log.info("未下发NDC信号原因: 读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose());
}
}
} else {
log.info(device_code + "对应设备号为空!");
}
} else {
//上报异常信息
//不需要WCS反馈
if (phase == 0x67 || phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74) {
device = deviceAppService.findDeviceByCode(Integer.toString(arr[18] * 256 + arr[19]));
} else {
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
}
try {
instructionService.finish(inst);
if (ObjectUtil.isNotEmpty(device)) {
if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver();
agvNdcTwoDeviceDriver.processSocket(arr);
} else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
agvNdcOneDeviceDriver.processSocket(arr);
}
} else {
log.info("当前phase" + phase + "未找到对应设备");
}
} catch (Exception e) {
log.info("processSocket出错:{},{}", e, e.getMessage());
e.printStackTrace();
}
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
//请求删除任务
//(需要WCS反馈)
else if (phase == 0x30) {
// data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0);
data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0, 0, 0);
}
//任务删除确认
//(需要WCS反馈)
else if (phase == 0xFF) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
} else {
instructionService.cancelNOSendAgv(inst.getInstruction_id());
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else if (phase == 0x50) {
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
if (ObjectUtil.isNotEmpty(device)) {
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
try {
standardAutodoorDeviceDriver.writing("to_open", "1");
standardAutodoorDeviceDriver.writing("to_close", "0");
} catch (Exception e) {
log.info("下发电气信号失败:" + e.getMessage());
e.printStackTrace();
}
if (standardAutodoorDeviceDriver.getOpen() == 1 && standardAutodoorDeviceDriver.getToOpen() == 1) {
log.info("下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getOpen());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getToClose());
}
}
} else {
log.info(agvaddr + "对应设备号为空!");
}
} else if (phase == 0x51) {
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
if (ObjectUtil.isNotEmpty(device)) {
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
try {
standardAutodoorDeviceDriver.writing("to_close", "1");
standardAutodoorDeviceDriver.writing("to_open", "0");
} catch (Exception e) {
log.info("下发电气信号失败:" + e.getMessage());
e.printStackTrace();
}
if (standardAutodoorDeviceDriver.getClose() == 1) {
log.info("读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
log.info("未下发NDC信号原因: 读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose());
}
}
} else {
log.info(device_code + "对应设备号为空!");
if (!ObjectUtil.isEmpty(data)) {
write(data);
}
} else {
//上报异常信息
//不需要WCS反馈
if (phase == 0x67 || phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74) {
device = deviceAppService.findDeviceByCode(Integer.toString(arr[18] * 256 + arr[19]));
} else {
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
}
try {
if (ObjectUtil.isNotEmpty(device)) {
if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) {
agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver();
agvNdcTwoDeviceDriver.processSocket(arr);
} else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
agvNdcOneDeviceDriver.processSocket(arr);
}
} else {
log.info("当前phase" + phase + "未找到对应设备");
}
} catch (Exception e) {
log.info("processSocket出错:{},{}", e, e.getMessage());
e.printStackTrace();
}
System.out.println("agv上报不是0073类型动作不处理");
}
if (!ObjectUtil.isEmpty(data)) {
write(data);
}
} else {
System.out.println("agv上报不是0073类型动作不处理");
}
}
} catch (Exception e) {

View File

@@ -245,6 +245,10 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
clearWrite();
}
if (mode != last_mode) {
requireSucess = false;
}
if (move != 0 && task > 0) {
if (null != inst) {
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code();

View File

@@ -165,6 +165,8 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
String vehicle_code;
String last_vehicle_code;
String vehicle_code2;
@Override
public Device getDevice() {
return this.device;
@@ -194,6 +196,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
if (move != 0 && task > 0) {
if (null != inst) {
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code();
vehicle_code2 = inst.getVehicle_code2();
}
update_instruction_status();
}
@@ -471,6 +474,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
jo.put("carrier_direction", carrier_direction);
jo.put("task", task);
jo.put("last_task", last_task);
jo.put("vehicle_code2", this.vehicle_code2);
jo.put("task_code", task_code);
jo.put("inst_message", this.inst_message);
jo.put("last_inst_message", this.last_inst_message);

View File

@@ -357,7 +357,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
}
if (StrUtil.isNotEmpty(hand_barcode)) {
TaskDto taskDtoHandCode = taskserver.findByVehicleCode2AndExcute(hand_barcode);
if (Objects.nonNull(taskDtoHandCode)) {
if (ObjectUtil.isNotEmpty(taskDtoHandCode)) {
applyLaStrangulationAndLabeling2();
message = "";
}

View File

@@ -1143,6 +1143,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
jo.put("move", move);
jo.put("action", action);
jo.put("task", task);
jo.put("vehicle_code2", this.vehicle_code2);
jo.put("isOnline", this.getIsonline());
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());

View File

@@ -159,6 +159,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
String vehicle_code;
String last_vehicle_code;
String vehicle_code2;
@Override
public Device getDevice() {
return this.device;
@@ -198,6 +199,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
inst = checkInst();
if (inst != null) {
inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code();
vehicle_code2 = inst.getVehicle_code2();
}
Instruction instruction = instructionService.findByCode(String.valueOf(task));
@@ -438,6 +440,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
jo.put("is_click", true);
jo.put("requireSucess", requireSucess);
jo.put("driver_type", "siemens_conveyor");
jo.put("vehicle_code2", this.vehicle_code2);
return jo;
}

View File

@@ -135,6 +135,8 @@ public class OneRgvDeviceDriver extends AbstractOpcDeviceDriver implements Devic
String notCreateInstMessage = "";
String feedMessage = "";
String vehicle_code2;
List<String> getDeviceCodeList = null;
@@ -164,6 +166,13 @@ public class OneRgvDeviceDriver extends AbstractOpcDeviceDriver implements Devic
requireSucess = false;
}
if (task > 0){
Instruction instruction = instructionService.findByCode(String.valueOf(task));
if (ObjectUtil.isNotEmpty(instruction)){
vehicle_code2 = instruction.getVehicle_code2();
}
}
} catch (Exception var17) {
var17.printStackTrace();
@@ -320,6 +329,7 @@ public class OneRgvDeviceDriver extends AbstractOpcDeviceDriver implements Devic
map.put("isOnline", this.getIsonline());
map.put("error", ErrorUtil.getDictDetail("rgv_error_type", String.valueOf(this.getError())));
map.put("isError", this.getIserror());
map.put("vehicle_code2", this.vehicle_code2);
// map.put("message", LangProcess.msg(message));
/*jo.put("notCreateTaskMessage", notCreateTaskMessage);
jo.put("notCreateInstMessage",notCreateInstMessage);*/

View File

@@ -381,39 +381,10 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
}
}
}
List<TaskDto> taskDtosLikeReady = new ArrayList<>();
if (CollUtil.isNotEmpty(taskDtosReady)) {
for (TaskDto dto : taskDtosReady) {
BeltConveyorDeviceDriver beltConveyorDeviceDriverStart;
BeltConveyorDeviceDriver beltConveyorDeviceDriverEnd;
Device startDevice = deviceAppService.findDeviceByCode(dto.getStart_device_code());
Device nextDevice = deviceAppService.findDeviceByCode(dto.getNext_device_code());
if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver && nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriverStart = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver();
beltConveyorDeviceDriverEnd = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
if (beltConveyorDeviceDriverStart.getMove() == 1 && beltConveyorDeviceDriverStart.getMode() == 2 && beltConveyorDeviceDriverEnd.getMove() == 1 && beltConveyorDeviceDriverEnd.getMode() == 2) {
taskDtosLikeReady.add(dto);
} else {
if (beltConveyorDeviceDriverStart.getMove() != 1) {
notCreateInstMessage = "universal_feedMessage7";
}
if (beltConveyorDeviceDriverStart.getMode() != 2) {
notCreateInstMessage = "universal_remark2";
}
if (beltConveyorDeviceDriverEnd.getMove() != 1) {
notCreateInstMessage = "universal_feedMessage7";
}
if (beltConveyorDeviceDriverEnd.getMode() != 2) {
notCreateInstMessage = "universal_remark2";
}
}
}
}
List<TaskDto> taskDtoList = taskDtosReady.stream().sorted(Comparator.comparing(TaskDto::getCreate_time)).collect(Collectors.toList());
taskDto = taskDtoList.get(0);
}
if (ObjectUtil.isNotEmpty(taskDto)) {
String interactionJson = taskDto.getInteraction_json();
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
@@ -432,6 +403,38 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
}
BeltConveyorDeviceDriver beltConveyorDeviceDriverStart;
BeltConveyorDeviceDriver beltConveyorDeviceDriverEnd;
if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriverStart = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver();
if (beltConveyorDeviceDriverStart.getMove() != 1 && beltConveyorDeviceDriverStart.getMode() != 2) {
notCreateInstMessage = "universal_notCreateInstMessage2";
return false;
}
}
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriverEnd = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
if (beltConveyorDeviceDriverEnd.getMove() == 1 && beltConveyorDeviceDriverEnd.getMode() == 2) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("当前任务号:" + taskDto.getTask_code() + " " + next_device_code + "当前move值为" + beltConveyorDeviceDriverEnd.getMove() + "当前mode值为"+beltConveyorDeviceDriverEnd.getMode())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}else {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("当前任务号:" + taskDto.getTask_code() + " " + next_device_code + "当前move值为" + beltConveyorDeviceDriverEnd.getMove() + "当前mode值为"+beltConveyorDeviceDriverEnd.getMode())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
notCreateInstMessage = "universal_notCreateInstMessage2";
return false;
}
}
String taskid = taskDto.getTask_id();
String taskcode = taskDto.getTask_code();
String start_point_code = taskDto.getStart_point_code();
@@ -483,7 +486,7 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
notCreateInstMessage = "universal_notCreateInstMessage";
}
}
return false;
return true;
}
}

View File

@@ -1186,7 +1186,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
private List<Instruction> sortInst(List<Instruction> instructions) {
Collections.sort(instructions, (t1, t2) -> {
//优先级从大到小
int i = t2.getPriority().compareTo(t1.getPriority());
int i = t1.getPriority().compareTo(t2.getPriority());
//如果优先级相等
if (i == 0) {
//时间从早到晚

View File

@@ -407,9 +407,9 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
logDto1.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1);
String interaction_json = taskDto.getInteraction_json();
Map<String, Object> map = toStringObjectMap(instruction, startAddr, nextAddr, interaction_json);
// Map<String, Object> map = toStringObjectMap(instruction, startAddr, nextAddr, interaction_json);
try {
this.writing(map);
pushPLC(instruction, startAddr, nextAddr, interaction_json);
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
@@ -533,9 +533,9 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
String startAddr = startDevice.getExtraValue().get("address").toString();
String nextAddr = nextDevice.getExtraValue().get("address").toString();
String interaction_json = task.getInteraction_json();
Map<String, Object> map = toStringObjectMap(instdto, startAddr, nextAddr, interaction_json);
// Map<String, Object> map = toStringObjectMap(instdto, startAddr, nextAddr, interaction_json);
try {
this.writing(map);
pushPLC(instdto, startAddr, nextAddr, interaction_json);
} catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
@@ -556,9 +556,37 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
}
@NotNull
private Map<String, Object> toStringObjectMap(Instruction instdto, String startAddr, String nextAddr, String interaction_json) {
Map<String, Object> map = new LinkedHashMap<>();
private void pushPLC(Instruction instdto, String startAddr, String nextAddr, String interaction_json) {
// Map<String, Object> map = new LinkedHashMap<>();
List list = new ArrayList();
Map<String, Object> map1 = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map4 = new HashMap<>();
Map<String, Object> map5 = new HashMap<>();
Map<String, Object> map6 = new HashMap<>();
Map<String, Object> map7 = new HashMap<>();
Map<String, Object> map8 = new HashMap<>();
Map<String, Object> map9 = new HashMap<>();
Map<String, Object> map10 = new HashMap<>();
Map<String, Object> map11 = new HashMap<>();
Map<String, Object> map12 = new HashMap<>();
Map<String, Object> map13 = new HashMap<>();
Map<String, Object> map14 = new HashMap<>();
Map<String, Object> map15 = new HashMap<>();
Map<String, Object> map16 = new HashMap<>();
Map<String, Object> map17 = new HashMap<>();
Map<String, Object> map18 = new HashMap<>();
Map<String, Object> map19 = new HashMap<>();
Map<String, Object> map20 = new HashMap<>();
Map<String, Object> map21 = new HashMap<>();
Map<String, Object> map22 = new HashMap<>();
Map<String, Object> map23 = new HashMap<>();
Map<String, Object> map24 = new HashMap<>();
Map<String, Object> map25 = new HashMap<>();
Map<String, Object> map26 = new HashMap<>();
Map<String, Object> map27 = new HashMap<>();
Map<String, Object> map28 = new HashMap<>();
if (StrUtil.isNotEmpty(interaction_json) && !"".equals(interaction_json)) {
JSONObject jsonObject = JSONObject.parseObject(interaction_json);
//套管1物料
@@ -591,71 +619,196 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
//拔管数量
Object to_qty2 = jsonObject.get("pullCount");
map.put("to_pull", jsonObject.getString("is_pulling"));
map.put("is_bushing", jsonObject.getString("is_bushing"));
map.put("to_size", jsonObject.getString("qzz_size"));
map.put("to_barcode", jsonObject.getString("qzz_no"));
map.put("to_command", CommonFinalParam.ONE);
map.put("to_onset", startAddr);
map.put("to_task", instdto.getInstruction_code());
map.put("to_target", nextAddr);
// map.put("to_pull", jsonObject.getString("is_pulling"));
map1.put("code", "to_pull");
map1.put("value", jsonObject.getString("is_pulling"));
list.add(map1);
// map.put("is_bushing", jsonObject.getString("is_bushing"));
map2.put("code", "is_bushing");
map2.put("value", jsonObject.getString("is_bushing"));
list.add(map2);
// map.put("to_size", jsonObject.getString("qzz_size"));
map3.put("code", "to_size");
map3.put("value", jsonObject.getString("qzz_size"));
list.add(map3);
// map.put("to_barcode", jsonObject.getString("qzz_no"));
map4.put("code", "to_barcode");
map4.put("value", jsonObject.getString("qzz_no"));
list.add(map4);
// map.put("to_command", CommonFinalParam.ONE);
map5.put("code", "to_command");
map5.put("value", CommonFinalParam.ONE);
list.add(map5);
// map.put("to_onset", startAddr);
map6.put("code", "to_onset");
map6.put("value", startAddr);
list.add(map6);
// map.put("to_task", instdto.getInstruction_code());
map7.put("code", "to_task");
map7.put("value", instdto.getInstruction_code());
list.add(map7);
// map.put("to_target", nextAddr);
map8.put("code", "to_target");
map8.put("value", nextAddr);
list.add(map8);
//toTranscription(taskDto,map);
if (ObjectUtil.isEmpty(to_material1) && ObjectUtil.isNotEmpty(to_material2)) {
map.put("to_material1", to_material2);
// map.put("to_material1", to_material2);
map9.put("code", "to_material1");
map9.put("value", to_material2);
list.add(map9);
if (ObjectUtil.isNotEmpty(to_spec2)) {
map.put("to_spec1", to_spec2);
// map.put("to_spec1", to_spec2);
map10.put("code", "to_spec1");
map10.put("value", to_spec2);
list.add(map10);
}
if (ObjectUtil.isNotEmpty(to_size2)) {
map.put("to_size1", to_size2);
// map.put("to_size1", to_size2);
map11.put("code", "to_size1");
map11.put("value", to_size2);
list.add(map11);
}
} else {
map.put("to_material1", to_material1);
// map.put("to_material1", to_material1);
map9.put("code", "to_material1");
map9.put("value", to_material1);
list.add(map9);
if (ObjectUtil.isNotEmpty(to_material2)) {
map.put("to_material2", to_material2);
// map.put("to_material2", to_material2);
map12.put("code", "to_material2");
map12.put("value", to_material2);
list.add(map12);
}
map.put("to_spec1", to_spec1);
// map.put("to_spec1", to_spec1);
map10.put("code", "to_spec1");
map10.put("value", to_spec1);
list.add(map10);
if (ObjectUtil.isNotEmpty(to_spec2)) {
map.put("to_spec2", to_spec2);
// map.put("to_spec2", to_spec2);
map11.put("code", "to_spec2");
map11.put("value", to_spec2);
list.add(map11);
}
map.put("to_size1", to_size1);
// map.put("to_size1", to_size1);
map13.put("code", "to_size1");
map13.put("value", to_size1);
list.add(map13);
if (ObjectUtil.isNotEmpty(to_size2)) {
map.put("to_size2", to_size2);
// map.put("to_size2", to_size2);
map14.put("code", "to_size2");
map14.put("value", to_size2);
list.add(map14);
}
}
if (ObjectUtil.isEmpty(to_material3) && ObjectUtil.isNotEmpty(to_material4)) {
map.put("to_material3", to_material4);
// map.put("to_material3", to_material4);
map14.put("code", "to_material3");
map14.put("value", to_material4);
list.add(map14);
if (ObjectUtil.isNotEmpty(to_size4)) {
map.put("to_size3", to_size4);
// map.put("to_size3", to_size4);
map15.put("code", "to_size3");
map15.put("value", to_size4);
list.add(map15);
}
if (ObjectUtil.isNotEmpty(to_spec4)) {
map.put("to_spec3", to_spec4);
// map.put("to_spec3", to_spec4);
map16.put("code", "to_spec3");
map16.put("value", to_spec4);
list.add(map16);
}
} else {
map.put("to_material3", to_material3);
// map.put("to_material3", to_material3);
map17.put("code", "to_material3");
map17.put("value", to_material3);
list.add(map17);
if (ObjectUtil.isNotEmpty(to_material4)) {
map.put("to_material4", to_material4);
// map.put("to_material4", to_material4);
map18.put("code", "to_material4");
map18.put("value", to_material4);
list.add(map18);
}
map.put("to_size3", to_size3);
// map.put("to_size3", to_size3);
map19.put("code", "to_size3");
map19.put("value", to_size3);
list.add(map19);
if (ObjectUtil.isNotEmpty(to_size4)) {
map.put("to_size4", to_size4);
// map.put("to_size4", to_size4);
map20.put("code", "to_size4");
map20.put("value", to_size4);
list.add(map20);
}
map.put("to_spec3", to_spec3);
// map.put("to_spec3", to_spec3);
map21.put("code", "to_spec3");
map21.put("value", to_spec3);
list.add(map21);
if (ObjectUtil.isNotEmpty(to_spec4)) {
map.put("to_spec4", to_spec4);
// map.put("to_spec4", to_spec4);
map22.put("code", "to_spec4");
map22.put("value", to_spec4);
list.add(map22);
}
}
map.put("to_qty1", to_qty1);
map.put("to_qty2", to_qty2);
return map;
// map.put("to_qty1", to_qty1);
map23.put("code", "to_qty1");
map23.put("value", to_qty1);
list.add(map23);
// map.put("to_qty2", to_qty2);
map24.put("code", "to_qty2");
map24.put("value", to_qty2);
list.add(map24);
this.writing(list);
} else {
map.put("to_command", CommonFinalParam.ONE);
map.put("to_onset", startAddr);
map.put("to_task", instdto.getInstruction_code());
map.put("to_target", nextAddr);
return map;
// map.put("to_command", CommonFinalParam.ONE);
map25.put("code", "to_command");
map25.put("value", CommonFinalParam.ONE);
list.add(map25);
// map.put("to_onset", startAddr);
map26.put("code", "to_onset");
map26.put("value", startAddr);
list.add(map26);
// map.put("to_task", instdto.getInstruction_code());
map27.put("code", "to_task");
map27.put("value", instdto.getInstruction_code());
list.add(map27);
// map.put("to_target", nextAddr);
map28.put("code", "to_target");
map28.put("value", nextAddr);
list.add(map28);
this.writing(list);
}
}
public void writing(List list) {
Map<String, Object> itemMap = new HashMap<String, Object>();
for (int i = 0; i < list.size(); i++) {
Object ob = list.get(i);
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
if (!StrUtil.isEmpty(json.getString("value"))) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + json.getString("code");
itemMap.put(to_param, json.getString("value"));
}
}
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("下发多个电气信号" + itemMap)
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
}
}
private void toTranscription(TaskDto taskDto, Map map) {
String interactionJson = taskDto.getInteraction_json();
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);

View File

@@ -131,6 +131,8 @@ public class InstructionMybatis extends CommonModel<InstructionMybatis> implemen
private String vehicle_code;
private String vehicle_code2;
private String vehicle_type;

View File

@@ -89,6 +89,7 @@ public class LuceneLogDto {
}
//1
public LuceneLogDto(final Integer log_level,final String method, final String status,
final String requestparam, final String responseparam, final String content) {

View File

@@ -417,7 +417,7 @@ public class CreateDDJInst {
private List<TaskDto> sortInst(List<TaskDto> taskDtos) {
Collections.sort(taskDtos, (t1, t2) -> {
//优先级从大到小
int i = t2.getPriority().compareTo(t1.getPriority());
int i = t1.getPriority().compareTo(t2.getPriority());
//如果优先级相等
if (i == 0) {
//时间从早到晚

View File

@@ -0,0 +1,19 @@
package org.nl.system.service.quartz.task;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
import org.nl.config.SpringContextHolder;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class Ndcconnect {
public void run() {
log.info("AGV-ACS心跳链接开始");
byte[] data = null;
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
data = ndcAgvService.sendAgvTwoModeInst();
TwoNDCSocketConnectionAutoRun.write(data);
}
}