opt: 联调优化

This commit is contained in:
yanps
2024-06-01 17:15:31 +08:00
parent 12b38767a5
commit efd08c55fa
7 changed files with 52 additions and 27 deletions

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.autodoor.standard_autodoor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -12,7 +13,10 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.utils.ReadUtil;
import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import java.util.Map;
@@ -27,6 +31,8 @@ import java.util.Map;
public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@Autowired
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
int open = 0;
int close = 0;
@@ -89,7 +95,12 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
} catch (Exception e) {
e.printStackTrace();
}
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("下发门信号:" + itemMap)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
public void writing(String param, int command) {

View File

@@ -27,7 +27,7 @@ public class ItemProtocol {
/**
* 托盘方向
*/
public static String item_container_direction = "container_direction";
public static String item_container_direction = "carrier_direction";
/**
* 载具类型

View File

@@ -116,8 +116,8 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem
/**
* 重量
*/
int weight = 0;
int last_weight = 0;
Float weight = 0.0F;
Float last_weight = 0.0F;
/**
* 条码
@@ -447,6 +447,7 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem
map.put("to_task", instruction.getInstruction_code());
map.put("to_target", nextAddr);
map.put("to_command", CommonFinalParam.ONE);
map.put("to_type", taskDto.getTruss_type());
if (StrUtil.isNotEmpty(startCode2)){
Device startDevice2 = deviceAppService.findDeviceByCode(startCode2);
@@ -534,12 +535,29 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem
throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code()));
}
try {
instructionService.create(instdto);
} catch (Exception e) {
notCreateInstMessage = e.getMessage();
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(LangProcess.msg("universal_message9") + e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
return false;
}
task.setTask_status(TaskStatusEnum.BUSY.getIndex());
task.setUpdate_time(DateUtil.now());
taskserver.update(task);
String startAddr = startDevice.getExtraValue().get("address").toString();
String nextAddr = nextDevice.getExtraValue().get("address").toString();
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_type", task.getTruss_type());
if (StrUtil.isNotEmpty(startDeviceCode2)){
//判断任务点位是否配置电气信号
@@ -560,23 +578,7 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem
map.put("to_onset2", start_addr2);
map.put("to_target2", next_addr2);
}
try {
instructionService.create(instdto);
} catch (Exception e) {
notCreateInstMessage = e.getMessage();
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(LangProcess.msg("universal_message9") + e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
return false;
}
//创建指令后修改任务状态
task.setTask_status(TaskStatusEnum.BUSY.getIndex());
task.setUpdate_time(DateUtil.now());
taskserver.update(task);
this.writing(map);
this.setRequireSucess(true);
notCreateInstMessage = "";

View File

@@ -83,8 +83,8 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_barcode);
}
public int getWeight(){
return this.getOpcIntegerValue(item_weight);
public Float getWeight(){
return this.getOpcFloatValue(item_weight);
}
public int getTo_task() {
@@ -132,6 +132,19 @@ public class ItemProtocol {
}
public float getOpcFloatValue(String protocol) {
Float value = this.driver.getDoubleValue(protocol);
if (value == null) {
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isEmpty(value)) {

View File

@@ -25,9 +25,7 @@ import java.util.Map;
**/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/deviceErrorLog")
@Slf4j
public class DeviceErrorLogController {
private final DeviceErrorLogService acsDeviceErrorLogService;

View File

@@ -415,7 +415,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
Object obj = accessor_value.getValue(relate);
sb.append("key:" + relate + "value:" + obj + ";");
}
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time") && !itemDto.getItem_code().endsWith("consumption")) {
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time") && !itemDto.getItem_code().endsWith("consumption")
&& !itemDto.getItem_code().endsWith("x") && !itemDto.getItem_code().endsWith("y")) {
// 存在上次点位值为null情况 则不记录日志
if(!(his instanceof Float) && !(value instanceof Float)){
LuceneLogDto luceneLogDto = new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(),4, itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1),
@@ -428,7 +429,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
}
}
} else {
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time") && !itemDto.getItem_code().endsWith("consumption")) {
if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time") && !itemDto.getItem_code().endsWith("consumption")
&& !itemDto.getItem_code().endsWith("x") && !itemDto.getItem_code().endsWith("y")) {
if(!(his instanceof Float) && !(value instanceof Float)){
LuceneLogDto luceneLogDto = new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(),4, itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1),
String.valueOf(his), String.valueOf(value));

View File

@@ -36,7 +36,6 @@ public class UdwManagerController {
// }
@GetMapping
@SaIgnore
//@PreAuthorize("@el.check('device:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {