fix: 扫码位报警重新下发plc、异步写lucence

This commit is contained in:
2024-07-16 09:46:43 +08:00
parent 484cfacee6
commit 467a9c94d1
5 changed files with 63 additions and 5 deletions

View File

@@ -753,6 +753,10 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(hand_barcode); TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(hand_barcode);
if (!ObjectUtil.isEmpty(taskdto)) { if (!ObjectUtil.isEmpty(taskdto)) {
if (creatInstruction(taskdto)) return false; if (creatInstruction(taskdto)) return false;
} else {
//如果不存在则直接找对应指令直接下发信号
if (pushPLC()) return false;
} }
} else { } else {
if (StrUtil.isNotBlank(barcode)) { if (StrUtil.isNotBlank(barcode)) {
@@ -760,6 +764,10 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(barcode); TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(barcode);
if (!ObjectUtil.isEmpty(taskdto)) { if (!ObjectUtil.isEmpty(taskdto)) {
if (creatInstruction(taskdto)) return false; if (creatInstruction(taskdto)) return false;
}else {
//如果不存在则直接找对应指令直接下发信号
if (pushPLC()) return false;
} }
} }
} }
@@ -767,6 +775,52 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
} }
} }
private boolean pushPLC() {
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
if (ObjectUtil.isEmpty(inst)) {
return true;
}
Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_target");
map.put("value", next_addr);
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", inst.getInstruction_code());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
requireSucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(device_code + inst.getInstruction_code() + "再次下发电气信号")
.build();
logDto.setLog_level(3);
luceneExecuteLogService.deviceExecuteLog(logDto);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) {
requireSucess = false;
return true;
}
}
return false;
}
private boolean creatInstruction(TaskDto taskdto) { private boolean creatInstruction(TaskDto taskdto) {
String taskid = taskdto.getTask_id(); String taskid = taskdto.getTask_id();
String taskcode = taskdto.getTask_code(); String taskcode = taskdto.getTask_code();
@@ -814,7 +868,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
BeltConveyorDeviceDriver linkDeviceDriver; BeltConveyorDeviceDriver linkDeviceDriver;
if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver(); linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver();
if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) && (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) { if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) || (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) {
this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机"; this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机";
requireSucess = false; requireSucess = false;
return true; return true;

View File

@@ -290,7 +290,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
param.put("actionType",actionType ); param.put("actionType",actionType );
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code) .device_code(device_code)
.content("行架取放货完成请求lms,参数:" + task + "--" +ActionTypeEnum.RELEASE_FINISHING.getStatus()) .content("行架取放货完成请求lms,参数:" + task + "--" +ActionTypeEnum.getStatus(actionType))
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);

View File

@@ -203,7 +203,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
if (!UnifiedDataAppService.isEquals(value, his)) { if (!UnifiedDataAppService.isEquals(value, his)) {
OpcItemDto itemDto = this.getItem(itemId); OpcItemDto itemDto = this.getItem(itemId);
if (true) { if (true) {
// this.logItemChanged(itemId, accessor_value, value, itemDto); this.logItemChanged(itemId, accessor_value, value, itemDto);
} }
if(!ObjectUtil.isEmpty(value) || "".equals(value)){ if(!ObjectUtil.isEmpty(value) || "".equals(value)){
accessor_value.setValue(itemId, value); accessor_value.setValue(itemId, value);

View File

@@ -37,7 +37,11 @@ public class AsyncLuceneAppender extends AspectLogbackAsyncAppender {
} }
MDC.clear(); MDC.clear();
} }
super.append(event); try {
super.append(event);
}catch (Exception e){
e.printStackTrace();
}
} }
} }

View File

@@ -54,7 +54,7 @@ https://juejin.cn/post/6844903775631572999
</appender> </appender>
<!--异步到文件--> <!--异步到文件-->
<appender name="asyncFileAppender" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender"> <appender name="asyncAppenter" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<discardingThreshold>0</discardingThreshold> <discardingThreshold>0</discardingThreshold>
<queueSize>500</queueSize> <queueSize>500</queueSize>
<appender-ref ref="FILE"/> <appender-ref ref="FILE"/>