rev:申请开盖空指针处理

This commit is contained in:
2025-10-20 15:59:59 +08:00
parent 827f985deb
commit ee95726bd8
2 changed files with 25 additions and 28 deletions

View File

@@ -76,7 +76,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
//当前指令 //当前指令
Instruction inst = null; Instruction inst = null;
@@ -160,6 +160,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
String last_vehicle_code; String last_vehicle_code;
String vehicle_code2; String vehicle_code2;
@Override @Override
public Device getDevice() { public Device getDevice() {
return this.device; return this.device;
@@ -203,11 +204,11 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
} }
//空箱出库开盖位,申请开盖 //空箱出库开盖位,申请开盖
if (mode == 15 && move == 1 && task > 0 ) { if (mode == 15 && move == 1 && task > 0) {
Instruction instruction = instructionService.findByCode(String.valueOf(task)); Instruction instruction = instructionService.findByCode(String.valueOf(task));
//不允许开盖,完成出库任务,自动去扫码位 //不允许开盖,完成出库任务,自动去扫码位
if (StrUtil.isEmpty(instruction.getVehicle_code())){ if (instruction == null || StrUtil.isEmpty(instruction.getVehicle_code())) {
message = "任务托盘码为空"; message = "指令信息不存在或者任务托盘码为空,无法开盖";
} }
applyUnbox(instruction.getVehicle_code()); applyUnbox(instruction.getVehicle_code());
@@ -226,23 +227,20 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
} }
last_mode = mode;
last_move = move;
last_carrier_direction = carrier_direction;
last_mode =mode; last_error = error;
last_move =move; last_task = task;
last_carrier_direction =carrier_direction; last_heartbeat = heartbeat;
last_error =error; last_to_task = to_task;
last_task =task; last_to_command = to_command;
last_heartbeat =heartbeat; last_to_target = to_target;
last_to_task =to_task; last_to_strap_times = to_strap_times;
last_to_command =to_command; last_to_length = to_length;
last_to_target =to_target; last_to_weight = to_weight;
last_to_strap_times =to_strap_times; last_to_height = to_height;
last_to_length =to_length; }
last_to_weight =to_weight;
last_to_height =to_height;
}
private Boolean applyUnbox(String vehicleCode) { private Boolean applyUnbox(String vehicleCode) {
Date date = new Date(); Date date = new Date();
@@ -275,14 +273,14 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
requireSucess = true; requireSucess = true;
packagePLCData(jo); packagePLCData(jo);
String isUncap = jo.getString("isUncap"); String isUncap = jo.getString("isUncap");
if ("1".equals(isUncap)){ if ("1".equals(isUncap)) {
List list1 = new ArrayList(); List list1 = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
map.put("code", "to_command"); map.put("code", "to_command");
map.put("value", 15); map.put("value", 15);
list1.add(map); list1.add(map);
this.writing(list1); this.writing(list1);
}else { } else {
List list1 = new ArrayList(); List list1 = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
map.put("code", "to_command"); map.put("code", "to_command");
@@ -293,7 +291,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
finish_instruction(inst); finish_instruction(inst);
} }
}else { } else {
LuceneLogDto logDto2 = LuceneLogDto.builder() LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code) .device_code(device_code)
.content("木箱开盖报错,接口返回:" + response) .content("木箱开盖报错,接口返回:" + response)
@@ -631,7 +629,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, instdto.getInstruction_code())) { , instdto.getInstruction_code())) {
this.writing(list); this.writing(list);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code) .device_code(device_code)
.content(device_code + inst.getInstruction_code() + "再次下发电气信号") .content(device_code + inst.getInstruction_code() + "再次下发电气信号")
.build(); .build();
@@ -675,7 +673,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) { , inst.getInstruction_code())) {
this.writing(list); this.writing(list);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code) .device_code(device_code)
.content(device_code + inst.getInstruction_code() + "再次下发电气信号") .content(device_code + inst.getInstruction_code() + "再次下发电气信号")
.build(); .build();

View File

@@ -2109,8 +2109,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override @Override
public Instruction findByStarCodeAndExcute(String start_code) { public Instruction findByStarCodeAndExcute(String start_code) {
Optional<Instruction> optionalInstruction = instructions.stream() Optional<Instruction> optionalInstruction = instructions.stream()
.filter(instruction -> StrUtil.equals(instruction.getStart_device_code(), start_code) .filter(instruction -> StrUtil.equals(instruction.getStart_device_code(), start_code))
&& StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex()))
.findFirst(); .findFirst();
return optionalInstruction.orElse(null); return optionalInstruction.orElse(null);
} }