fix:提前完场任务

This commit is contained in:
2023-12-25 12:36:29 +08:00
parent 885d1ec962
commit 9dcef9e939

View File

@@ -257,8 +257,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
last_inst_message = inst_message; last_inst_message = inst_message;
if ("true".equals(this.device.getExtraValue().get("ship_device_update"))) { if ("true".equals(this.device.getExtraValue().get("ship_device_update"))) {
this.requiresShipDeviceUpdate = false; this.requiresShipDeviceUpdate = false;
if(mode>0 ) if (mode > 0) {
{
shipDeviceUpdate(); shipDeviceUpdate();
} }
} }
@@ -290,7 +289,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
deviceErrorLogService.create(dto); deviceErrorLogService.create(dto);
} }
if(error != 110 && error != 70 ){ if (error != 110 && error != 70) {
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("device_code", this.device_code); param.put("device_code", this.device_code);
param.put("error", error); param.put("error", error);
@@ -323,7 +322,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
} }
try{ try {
if ("true".equals(this.device.getExtraValue().get("ship_device_update"))) { if ("true".equals(this.device.getExtraValue().get("ship_device_update"))) {
if (ObjectUtil.equal(this.getDevice().getExtraValue().get("noIdleRequest"), "true")) { if (ObjectUtil.equal(this.getDevice().getExtraValue().get("noIdleRequest"), "true")) {
if (!requiresShipDeviceUpdate && move == 0) { if (!requiresShipDeviceUpdate && move == 0) {
@@ -335,13 +334,12 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} }
} }
} }
} catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logServer.deviceExecuteLog(this.device_code, "", "", "反馈LMS光电信号变化时出现异常:" + e.getMessage()); logServer.deviceExecuteLog(this.device_code, "", "", "反馈LMS光电信号变化时出现异常:" + e.getMessage());
} }
if (mode == 0) { if (mode == 0) {
this.setIsonline(false); this.setIsonline(false);
message = "未联机"; message = "未联机";
@@ -426,11 +424,11 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} }
public void shipDeviceUpdate() { public void shipDeviceUpdate() {
CompletableFuture<String> future = new CompletableFuture<>(); CompletableFuture<String> future = new CompletableFuture<>();
// 使用线程池执行异步操作 // 使用线程池执行异步操作
EXECUTOR.submit(() -> { EXECUTOR.submit(() -> {
try { try {
JSONObject param = new JSONObject() ; JSONObject param = new JSONObject();
param.put("device_code", device_code); param.put("device_code", device_code);
logServer.deviceExecuteLog(this.device_code, "", "", "有货变无货请求LMS,参数:" + param); logServer.deviceExecuteLog(this.device_code, "", "", "有货变无货请求LMS,参数:" + param);
this.requiresShipDeviceUpdate = true; this.requiresShipDeviceUpdate = true;
@@ -460,7 +458,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} }
private void taskDeviceUpdate(int task) { private void taskDeviceUpdate(int task) {
Instruction inst = instructionService.findByInsructionCode(String.valueOf(task)); Instruction inst = instructionService.findByInsructionCode(String.valueOf(task));
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
applyManipulatorActionRequest.setDevice_code(device_code); applyManipulatorActionRequest.setDevice_code(device_code);
applyManipulatorActionRequest.setAction("3"); applyManipulatorActionRequest.setAction("3");
@@ -475,7 +473,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
if (response == null || response.getstatus() == 200) { if (response == null || response.getstatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "task变化请求LMS,接口返回:" + response.getMessage()); logServer.deviceExecuteLog(this.device_code, "", "", "task变化请求LMS,接口返回:" + response.getMessage());
} }
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logServer.deviceExecuteLog(this.device_code, "", "", "task变化请求LMS失败" + e.getMessage()); logServer.deviceExecuteLog(this.device_code, "", "", "task变化请求LMS失败" + e.getMessage());
} }
@@ -483,7 +481,6 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} }
public boolean exe_error() { public boolean exe_error() {
if (this.error == 0) { if (this.error == 0) {
return true; return true;
@@ -672,9 +669,9 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
this.checkcontrol(itemMap); this.checkcontrol(itemMap);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
try{ try {
this.checkcontrol(itemMap); this.checkcontrol(itemMap);
} catch (Exception e1){ } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
} }
@@ -736,7 +733,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))){ if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) {
requireSucess = false; requireSucess = false;
return false; return false;
} }
@@ -859,14 +856,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
if(ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))){ if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) {
requireSucess = false; requireSucess = false;
return false; return false;
} }
} }
// if (task != Integer.parseInt(inst.getInstruction_code())) { // if (task != Integer.parseInt(inst.getInstruction_code())) {
// this.writing(list); // this.writing(list);
// message = "重新下发电气信号"; // message = "重新下发电气信号";
@@ -879,12 +875,12 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
return false; return false;
} }
//当起点为行架任务的时候不需要请求下发 //当起点为行架任务的时候不需要请求下发
if (StrUtil.equals(inst.getInstruction_type(), "6") || StrUtil.equals(inst.getInstruction_type(),"9")) { if (StrUtil.equals(inst.getInstruction_type(), "6") || StrUtil.equals(inst.getInstruction_type(), "9")) {
return false; return false;
} }
Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
String next_addr = nextdevice.getExtraValue().get("address").toString(); String next_addr = nextdevice.getExtraValue().get("address").toString();
if(StrUtil.equals(next_addr,"0")){ if (StrUtil.equals(next_addr, "0")) {
if (StrUtil.isNotEmpty(inst.getTo_z())) { if (StrUtil.isNotEmpty(inst.getTo_z())) {
if (StrUtil.equals(inst.getTo_z(), "01")) { if (StrUtil.equals(inst.getTo_z(), "01")) {
next_addr = "102"; next_addr = "102";
@@ -919,7 +915,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
if(ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))){ if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) {
requireSucess = false; requireSucess = false;
return false; return false;
} }
@@ -1050,7 +1046,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
apply.put("type", "2"); apply.put("type", "2");
String str = acsToWmsService.applyTaskToWms(apply); String str = acsToWmsService.applyTaskToWms(apply);
logServer.deviceExecuteLog(this.device_code, "", "", "申请空盘入库,请求参数:" + apply); logServer.deviceExecuteLog(this.device_code, "", "", "申请空盘入库,请求参数:" + apply);
message = "申请空盘入库任务,请求参数:"+apply; message = "申请空盘入库任务,请求参数:" + apply;
JSONObject jo = JSON.parseObject(str); JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) { if (ObjectUtil.isEmpty(jo)) {
@@ -1221,14 +1217,16 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
inst.setInstruction_status("1"); inst.setInstruction_status("1");
inst.setExecute_device_code(this.device_code); inst.setExecute_device_code(this.device_code);
instructionService.update(inst); instructionService.update(inst);
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code());
} }
if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0") ) { if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0")) {
if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
vehicle_code = inst.getVehicle_code(); vehicle_code = inst.getVehicle_code();
inst.setExecute_device_code(this.device_code); inst.setExecute_device_code(this.device_code);
finish_instruction(); if (mode == 2) {
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); finish_instruction();
}
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code());
} else { } else {
} }
@@ -1241,10 +1239,10 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
} }
} }
public Instruction checkInst(){ public Instruction checkInst() {
if(ObjectUtil.isNotEmpty(this.inst)){ if (ObjectUtil.isNotEmpty(this.inst)) {
if(this.task>0){ if (this.task > 0) {
if(this.inst.getInstruction_code().equals(String.valueOf(this.task))){ if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) {
return this.inst; return this.inst;
} else { } else {
inst = instructionService.findByCodeFromCache(String.valueOf(task)); inst = instructionService.findByCodeFromCache(String.valueOf(task));