opt: 联调优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.acs.device_driver.autodoor.standard_autodoor;
|
package org.nl.acs.device_driver.autodoor.standard_autodoor;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -12,7 +13,10 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
|
|||||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||||
import org.nl.acs.utils.ReadUtil;
|
import org.nl.acs.utils.ReadUtil;
|
||||||
import org.nl.config.SpringContextHolder;
|
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.openscada.opc.lib.da.Server;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -27,6 +31,8 @@ import java.util.Map;
|
|||||||
public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
|
public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
|
||||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||||
|
|
||||||
int open = 0;
|
int open = 0;
|
||||||
int close = 0;
|
int close = 0;
|
||||||
@@ -89,7 +95,12 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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) {
|
public void writing(String param, int command) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ItemProtocol {
|
|||||||
/**
|
/**
|
||||||
* 托盘方向
|
* 托盘方向
|
||||||
*/
|
*/
|
||||||
public static String item_container_direction = "container_direction";
|
public static String item_container_direction = "carrier_direction";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 载具类型
|
* 载具类型
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem
|
|||||||
/**
|
/**
|
||||||
* 重量
|
* 重量
|
||||||
*/
|
*/
|
||||||
int weight = 0;
|
Float weight = 0.0F;
|
||||||
int last_weight = 0;
|
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_task", instruction.getInstruction_code());
|
||||||
map.put("to_target", nextAddr);
|
map.put("to_target", nextAddr);
|
||||||
map.put("to_command", CommonFinalParam.ONE);
|
map.put("to_command", CommonFinalParam.ONE);
|
||||||
|
map.put("to_type", taskDto.getTruss_type());
|
||||||
|
|
||||||
if (StrUtil.isNotEmpty(startCode2)){
|
if (StrUtil.isNotEmpty(startCode2)){
|
||||||
Device startDevice2 = deviceAppService.findDeviceByCode(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()));
|
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 startAddr = startDevice.getExtraValue().get("address").toString();
|
||||||
String nextAddr = nextDevice.getExtraValue().get("address").toString();
|
String nextAddr = nextDevice.getExtraValue().get("address").toString();
|
||||||
map.put("to_command", CommonFinalParam.ONE);
|
map.put("to_command", CommonFinalParam.ONE);
|
||||||
map.put("to_onset", startAddr);
|
map.put("to_onset", startAddr);
|
||||||
map.put("to_task", instdto.getInstruction_code());
|
map.put("to_task", instdto.getInstruction_code());
|
||||||
map.put("to_target", nextAddr);
|
map.put("to_target", nextAddr);
|
||||||
|
map.put("to_type", task.getTruss_type());
|
||||||
|
|
||||||
if (StrUtil.isNotEmpty(startDeviceCode2)){
|
if (StrUtil.isNotEmpty(startDeviceCode2)){
|
||||||
//判断任务点位是否配置电气信号
|
//判断任务点位是否配置电气信号
|
||||||
@@ -560,23 +578,7 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem
|
|||||||
map.put("to_onset2", start_addr2);
|
map.put("to_onset2", start_addr2);
|
||||||
map.put("to_target2", next_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.writing(map);
|
||||||
this.setRequireSucess(true);
|
this.setRequireSucess(true);
|
||||||
notCreateInstMessage = "";
|
notCreateInstMessage = "";
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ public class ItemProtocol {
|
|||||||
return this.getOpcIntegerValue(item_barcode);
|
return this.getOpcIntegerValue(item_barcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWeight(){
|
public Float getWeight(){
|
||||||
return this.getOpcIntegerValue(item_weight);
|
return this.getOpcFloatValue(item_weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTo_task() {
|
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) {
|
public String getOpcStringValue(String protocol) {
|
||||||
String value = this.driver.getStringValue(protocol);
|
String value = this.driver.getStringValue(protocol);
|
||||||
if (StrUtil.isEmpty(value)) {
|
if (StrUtil.isEmpty(value)) {
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ import java.util.Map;
|
|||||||
**/
|
**/
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
|
||||||
@RequestMapping("/api/deviceErrorLog")
|
@RequestMapping("/api/deviceErrorLog")
|
||||||
@Slf4j
|
|
||||||
public class DeviceErrorLogController {
|
public class DeviceErrorLogController {
|
||||||
|
|
||||||
private final DeviceErrorLogService acsDeviceErrorLogService;
|
private final DeviceErrorLogService acsDeviceErrorLogService;
|
||||||
|
|||||||
@@ -415,7 +415,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
|||||||
Object obj = accessor_value.getValue(relate);
|
Object obj = accessor_value.getValue(relate);
|
||||||
sb.append("key:" + relate + "value:" + obj + ";");
|
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情况 则不记录日志
|
// 存在上次点位值为null情况 则不记录日志
|
||||||
if(!(his instanceof Float) && !(value instanceof Float)){
|
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),
|
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 {
|
} 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)){
|
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),
|
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));
|
String.valueOf(his), String.valueOf(value));
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ public class UdwManagerController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
|
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
//@PreAuthorize("@el.check('device:list')")
|
//@PreAuthorize("@el.check('device:list')")
|
||||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||||
|
|||||||
Reference in New Issue
Block a user