fix 任务指令日志

This commit is contained in:
USER-20220102CG\noblelift
2023-06-15 09:07:17 +08:00
parent a1ec035cf9
commit 68497454e8
5 changed files with 142 additions and 18 deletions

View File

@@ -1113,7 +1113,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
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")) { 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);

View File

@@ -530,6 +530,22 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
message = "下发电气任务号成功"; message = "下发电气任务号成功";
requireSucess = true; requireSucess = true;
applySucess = true; applySucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, instdto.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instdto.getInstruction_code())){
requireSucess = false;
applySucess = false;
return false;
}
}
} else { } else {
message = "任务号:" + task.getTask_code() + "未找到指令"; message = "任务号:" + task.getTask_code() + "未找到指令";
} }
@@ -602,6 +618,21 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
+ "已存在对应任务,下发电气信号"); + "已存在对应任务,下发电气信号");
requireSucess = true; requireSucess = true;
applySucess = true; applySucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, instdto.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instdto.getInstruction_code())){
requireSucess = false;
applySucess = false;
return false;
}
}
} else { } else {
message = "任务号:" + taskdto.getTask_code() + "未找到指令"; message = "任务号:" + taskdto.getTask_code() + "未找到指令";
} }
@@ -647,6 +678,21 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
message = "下发电气任务号成功"; message = "下发电气任务号成功";
requireSucess = true; requireSucess = true;
applySucess = true; applySucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, instdto.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instdto.getInstruction_code())){
requireSucess = false;
applySucess = false;
return false;
}
}
return true; return true;
} else { } else {
logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code
@@ -776,6 +822,21 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
// } // }
requireSucess = true; requireSucess = true;
applySucess = true; applySucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, instdto.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ObjectUtil.isEmpty(instdto.getInstruction_code())){
requireSucess = false;
applySucess = false;
return false;
}
}
} else { } else {
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
message = "申请任务中..."; message = "申请任务中...";

View File

@@ -414,9 +414,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
WQLObject wo = WQLObject.getWQLObject("acs_instruction"); WQLObject wo = WQLObject.getWQLObject("acs_instruction");
JSONObject json = (JSONObject) JSONObject.toJSON(dto); JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json); wo.insert(json);
try{
instructions.add(dto); instructions.add(dto);
log.warn("指令添加到指令列表:"+dto.toString());
} catch (Exception e){
log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage());
}
} }
@Override @Override
@@ -530,7 +535,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
JSONObject json = (JSONObject) JSONObject.toJSON(dto); JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json); wo.insert(json);
try{
instructions.add(dto); instructions.add(dto);
log.warn("指令添加到指令列表:"+dto.toString());
} catch (Exception e){
log.warn("指令添加到指令列表异常:"+e.getMessage());
}
} }
@@ -645,7 +655,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
JSONObject json = (JSONObject) JSONObject.toJSON(dto); JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json); wo.insert(json);
try{
instructions.add(dto); instructions.add(dto);
log.warn("指令添加到指令列表:"+dto.toString());
} catch (Exception e){
log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage());
}
} }
@@ -732,7 +747,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
// agvService.addOrderSequences(dto); // agvService.addOrderSequences(dto);
// } // }
// } // }
try{
instructions.add(dto); instructions.add(dto);
log.warn("指令添加到指令列表:"+dto.toString());
} catch (Exception e){
log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage());
}
} }
@Override @Override
@@ -747,7 +767,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
wo.update(json); wo.update(json);
removeByCodeFromCache(dto.getInstruction_code()); removeByCodeFromCache(dto.getInstruction_code());
try{
instructions.add(dto); instructions.add(dto);
log.warn("指令添加到指令列表:"+dto.toString());
} catch (Exception e){
log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage());
}
// this.reload(); // this.reload();
} }
@@ -1580,9 +1606,18 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override @Override
public boolean removeByCodeFromCache(String code) { public boolean removeByCodeFromCache(String code) {
CopyOnWriteArrayList<Instruction> instructions = (CopyOnWriteArrayList<Instruction>) this.instructions; CopyOnWriteArrayList<Instruction> instructions = (CopyOnWriteArrayList<Instruction>) this.instructions;
try{
instructions.removeIf((inst) -> { instructions.removeIf((inst) -> {
if(StrUtil.equals(inst.getInstruction_code(),code)){
log.warn("指令移除指令列表:"+inst.toString());
}
return inst.getInstruction_code().equals(code); return inst.getInstruction_code().equals(code);
}); });
} catch (Exception e){
log.warn("指令移除指令列表列表异常:" + e.getMessage());
}
// while (iterator.hasNext()) { // while (iterator.hasNext()) {
// Instruction instruction = iterator.next(); // Instruction instruction = iterator.next();
// if (instruction.getInstruction_code().equals(code)) { // if (instruction.getInstruction_code().equals(code)) {

View File

@@ -1,6 +1,7 @@
package org.nl.acs.opc; package org.nl.acs.opc;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.udw.UnifiedDataAccessor; import org.nl.acs.udw.UnifiedDataAccessor;
@@ -191,10 +192,11 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
if (true) { if (true) {
this.logItemChanged(itemId, accessor_value, value, itemDto); this.logItemChanged(itemId, accessor_value, value, itemDto);
} }
if(!ObjectUtil.isEmpty(value)){
accessor_value.setValue(itemId, value); accessor_value.setValue(itemId, value);
} }
} }
}
end = System.currentTimeMillis(); end = System.currentTimeMillis();
if (log.isTraceEnabled()) { if (log.isTraceEnabled()) {

View File

@@ -520,8 +520,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
JSONObject json = (JSONObject) JSONObject.toJSON(dto); JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json); wo.insert(json);
synchronized (TaskServiceImpl.class) { // synchronized (TaskServiceImpl.class) {
// tasks.add(dto);
// }
try{
tasks.add(dto); tasks.add(dto);
log.warn("任务添加到任务列表:"+dto.toString());
} catch (Exception e){
log.warn("任务添加到任务列表异常:"+ dto.toString() +e.getMessage());
} }
} }
@@ -673,7 +680,12 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
removeByCodeFromCache(entity.getTask_code()); removeByCodeFromCache(entity.getTask_code());
if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) { if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) {
try{
tasks.add(dto); tasks.add(dto);
log.warn("任务添加到任务列表:"+dto.toString());
} catch (Exception e){
log.warn("任务添加到任务列表异常:"+ dto.toString() +e.getMessage());
}
} }
// 判断是否为WMS下发的任务如果是反馈任务状态给WMS // 判断是否为WMS下发的任务如果是反馈任务状态给WMS
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
@@ -1296,9 +1308,18 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Override @Override
public boolean removeByCodeFromCache(String code) { public boolean removeByCodeFromCache(String code) {
CopyOnWriteArrayList<TaskDto> taskDtos = (CopyOnWriteArrayList<TaskDto>) this.tasks; CopyOnWriteArrayList<TaskDto> taskDtos = (CopyOnWriteArrayList<TaskDto>) this.tasks;
try{
taskDtos.removeIf((task) -> { taskDtos.removeIf((task) -> {
if(StrUtil.equals(task.getTask_code(),code)){
log.warn("任务移除任务列表成功:"+task.toString());
}
return task.getTask_code().equals(code); return task.getTask_code().equals(code);
}); });
} catch (Exception e){
log.warn("指令移除任务列表异常:"+e.getMessage());
}
return true; return true;
} }
@@ -1525,7 +1546,12 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Override @Override
public void updateByCodeFromCache(TaskDto dto) { public void updateByCodeFromCache(TaskDto dto) {
removeByCodeFromCache(dto.getTask_code()); removeByCodeFromCache(dto.getTask_code());
try{
tasks.add(dto); tasks.add(dto);
log.warn("任务添加到任务列表:"+dto.toString());
} catch (Exception e){
log.warn("任务添加到任务列表异常:"+ dto.toString() +e.getMessage());
}
} }
@Override @Override