diff --git a/wcs/nladmin-system/pom.xml b/wcs/nladmin-system/pom.xml
index 2777efdd..43638475 100644
--- a/wcs/nladmin-system/pom.xml
+++ b/wcs/nladmin-system/pom.xml
@@ -22,7 +22,7 @@
2.9.2
1.1.22
2.5.0
- 1.4.1.Final
+ 1.3.1.Final
1.31.0
5.7.14
0.11.1
@@ -35,7 +35,7 @@
-
+
org.fusesource.jansi
jansi
@@ -82,11 +82,11 @@
org.openscada.jinterop.deps
1.5.0
-->
-
+
org.openscada.utgard
org.openscada.opc.lib
@@ -110,11 +110,11 @@
1.8.0
-
+
@@ -157,10 +157,10 @@
-
- org.springframework.boot
- spring-boot-starter-websocket
-
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
@@ -186,16 +186,16 @@
-
- ch.ethz.ganymed
- ganymed-ssh2
- build210
-
-
- com.jcraft
- jsch
- 0.1.55
-
+
+ ch.ethz.ganymed
+ ganymed-ssh2
+ build210
+
+
+ com.jcraft
+ jsch
+ 0.1.55
+
@@ -363,16 +363,16 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
xerces
xercesImpl
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/acsEnum/DeviceEnum.java b/wcs/nladmin-system/src/main/java/org/nl/acs/acsEnum/DeviceEnum.java
new file mode 100644
index 00000000..fc22fb67
--- /dev/null
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/acsEnum/DeviceEnum.java
@@ -0,0 +1,58 @@
+package org.nl.acs.acsEnum;
+
+import java.util.Arrays;
+
+public enum DeviceEnum {
+
+ A3_HR_RM_J("A3_HR_RM_J","","",""),
+ A3_HR_RM_D("A3_HR_RM_D","13","",""),
+ A3_HR_RM_C("A3_HR_RM_C","13","",""),
+ A3_HR_RK_J("A3_HR_RK_J","","",""),
+ A3_HR_RK_D("A3_HR_RK_D","13","",""),
+ A3_HR_RK_C("A3_HR_RK_C","13","",""),
+ A3_HR_CM_J("A3_HR_CM_J","","",""),
+ A3_HR_CM_D("A3_HR_CM_D","14","",""),
+ A3_HR_CM_C("A3_HR_CM_C","14","",""),
+ A3_HR_CK_J("A3_HR_CK_J","","",""),
+ A3_HR_CK_D("A3_HR_CK_D","14","",""),
+ A3_HR_CK_C("A3_HR_CK_C","14","",""),
+
+ OTHER("OTHER", "5", "","");
+
+ private String code;
+ private String type;
+ private String desc;
+ private String ext;
+
+ DeviceEnum(String code, String type, String desc, String ext) {
+ this.code = code;
+ this.type = type;
+ this.desc = desc;
+ this.ext = ext;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public String getExt() {
+ return ext;
+ }
+
+ public static String getTypeByCode(String code){
+ return Arrays
+ .stream(DeviceEnum.values())
+ .filter(signal -> signal.code.equals(code))
+ .findFirst()
+ .orElse(OTHER)
+ .type;
+ }
+}
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/acsEnum/StatusEnum.java b/wcs/nladmin-system/src/main/java/org/nl/acs/acsEnum/StatusEnum.java
index ce8b7769..e114d7fa 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/acsEnum/StatusEnum.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/acsEnum/StatusEnum.java
@@ -65,6 +65,10 @@ public enum StatusEnum {
HAIROU_LIKU_REQ("18","半成品库任务(海柔)",""),
+ HAIROU_RELOCATION("19","移库(海柔)",""),
+ HAIROU_CARRY("20","搬运(海柔)",""),
+ HAIROU_CHECK("21","盘库(海柔)",""),
+
TOTE_INBOUND("1","容器入库","tote_inbound"),
TOTE_OUTBOUND("2","容器出库","tote_outbound"),
TOTE_RELOCATION("3","容器移库","tote_relocation"),
@@ -82,7 +86,9 @@ public enum StatusEnum {
TASK_RUNNING("1", "执行中", "6"),
TASK_FINISH("2", "完成", "7"),
TASK_CANCEL("3", "取消", "8"),
- TASK_FULL_IN("4","满入","");
+ TASK_FULL_IN("4","满入",""),
+ TASK_EMPTY_OUT("5","空出",""),
+ TASK_CHECK_ANOMALY("6","盘点异常","");
private String code;
private String desc;
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_with_station/WithStationDeviceDriver.java b/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_with_station/WithStationDeviceDriver.java
index b0f93e3d..0496b49a 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_with_station/WithStationDeviceDriver.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_old/hailiang_with_station/WithStationDeviceDriver.java
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.nl.acs.acsEnum.DeviceEnum;
import org.nl.acs.acsEnum.InstActionEnum;
import org.nl.acs.acsEnum.StatusEnum;
import org.nl.acs.agv.server.NDCAgvService;
@@ -185,9 +186,9 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
//取关联设备 list
//遍历
- List hiaRouDeviceCodeList = this.getExtraDeviceCodes("link_device_code");
- for(int i=0;i haiRouDeviceCodeList = this.getExtraDeviceCodes("link_device_code");
+ for(int i=0;i" + order);
}
- if (isonline != last_isonline) {
- logServer.deviceExecuteLog(this.device_code, "", "", SignalEnum.getNameByCode("isonline") + SignalEnum.getDescByCode("isonline") +":" + last_isonline + "->" + isonline);
- feedDeviceStatusFlag = false;
- }
+// if (isonline != last_isonline) {
+// logServer.deviceExecuteLog(this.device_code, "", "", SignalEnum.getNameByCode("isonline") + SignalEnum.getDescByCode("isonline") +":" + last_isonline + "->" + isonline);
+// feedDeviceStatusFlag = false;
+// }
if (!this.itemProtocol.getIsonline() && !feedDeviceStatusFlag) {
JSONObject chm = new JSONObject();
@@ -409,6 +409,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
//agv到达取货点
if (agvphase == 0x03) {
+ logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:"+agvphase+",联机信号:"+mode+",光电信号:"+move+",指令是否为空:"+ObjectUtil.isNotEmpty(inst));
if (mode == 1 && move == 1 && ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status(InstActionEnum.EXECUTE_TO_GET.getCode());
instructionService.update(inst);
@@ -429,6 +430,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
//agv取货完成
if (agvphase == 0x05) {
+ logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:"+agvphase+",联机信号:"+mode+",光电信号:"+move+",指令是否为空:"+ObjectUtil.isNotEmpty(inst));
if (mode == 1 && move == 0 && ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status(InstActionEnum.EXECUTE_GET_FINISH.getCode());
instructionService.update(inst);
@@ -450,6 +452,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
//agv到达放货点
if (agvphase == 0x07) {
+ logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:"+agvphase+",联机信号:"+mode+",光电信号:"+move+",指令是否为空:"+ObjectUtil.isNotEmpty(inst));
if (mode == 1 && move == 0 && ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status(InstActionEnum.EXECUTE_TO_PUT_FALL_SEND_FULL.getCode());
instructionService.update(inst);
@@ -470,6 +473,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
//agv放货完成
if (agvphase == 0x09) {
+ logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:"+agvphase+",联机信号:"+mode+",光电信号:"+move+",指令是否为空:"+ObjectUtil.isNotEmpty(inst));
if (mode == 1 && move == 1 && ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status(InstActionEnum.EXECUTE_PUT_FALL_SEND_FULL_FINISH.getCode());
instructionService.update(inst);
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java
index 155d242e..9fb31bf2 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java
@@ -169,4 +169,12 @@ public interface AcsToWmsService {
* @return
*/
HttpResponse washTask(JSONObject param);
+
+ /**
+ * 上报海柔异常状态
+ *
+ * @param param
+ * @return
+ */
+ HttpResponse reportAnomaly(JSONObject param);
}
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java
index 671a80eb..d783b12a 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java
@@ -8,7 +8,7 @@ import java.util.Map;
public interface WmsToAcsService {
/**
- * mes创建任务
+ * lms创建任务
*
* @param tasks 条件
* @return
@@ -32,7 +32,7 @@ public interface WmsToAcsService {
Map actionOrder(List orders);
/**
- * mes修改任务状态
+ * lms修改任务状态
*
* @param taskStatus 条件
* @return Map
@@ -41,7 +41,7 @@ public interface WmsToAcsService {
/**
- * mes修改工单状态
+ * lms修改工单状态
*
* @param orderStatus
* @return
@@ -156,7 +156,7 @@ public interface WmsToAcsService {
Map cleanPut(JSONObject param);
/**
- * 刻字上料(mes直接下任务acs,此接口暂未用)
+ * 刻字上料(lms直接下任务acs,此接口暂未用)
*
* @param param 条件
* @return Map
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
index a54da89b..38f8d70c 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
@@ -45,7 +45,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
- log.info("acs开始向mes请求任务,请求参数:{}", JSON.toJSONString(param));
+ log.info("acs开始向lms请求任务,请求参数:{}", JSON.toJSONString(param));
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("applyTaskToWms");
String url = wmsurl + addressDto.getMethods_url();
@@ -73,7 +73,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
- log.info("acs开始向mes反馈任务状态,请求参数:{}", JSON.toJSONString(data));
+ log.info("acs开始向lms反馈任务状态,请求参数:{}", JSON.toJSONString(data));
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedbackTaskStatusToWms");
String methods_url = addressDto.getMethods_url();
@@ -84,9 +84,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
.header("Authorization", token)
.body(JSON.toJSONString(data))
.execute();
- log.info("acs向mes反馈任务状态成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(data), result.body());
+ log.info("acs向lms反馈任务状态成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(data), result.body());
} catch (Exception e) {
- log.error("acs向mes反馈任务状态失败,请求路径:{},请求参数:{},失败原因:{}", url, JSON.toJSONString(data), e.getMessage());
+ log.error("acs向lms反馈任务状态失败,请求路径:{},请求参数:{},失败原因:{}", url, JSON.toJSONString(data), e.getMessage());
}
return result;
}
@@ -102,7 +102,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
- log.info("acs开始向mes反馈工单状态,请求参数:{}", JSON.toJSONString(param));
+ log.info("acs开始向lms反馈工单状态,请求参数:{}", JSON.toJSONString(param));
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedbackOrderStatus");
String methods_url = addressDto.getMethods_url();
@@ -112,9 +112,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
result = HttpRequest.post(url)
.body(JSON.toJSONString(param))
.execute();
- log.info("acs向mes反馈工单状态成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(param), result.body());
+ log.info("acs向lms反馈工单状态成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(param), result.body());
} catch (Exception e) {
- log.error("acs向mes反馈工单状态失败,请求路径:{},请求参数:{},失败原因:{}", url, JSON.toJSONString(param), e.getMessage());
+ log.error("acs向lms反馈工单状态失败,请求路径:{},请求参数:{},失败原因:{}", url, JSON.toJSONString(param), e.getMessage());
}
return result;
}
@@ -129,7 +129,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1") && StrUtil.equals(paramService.findByCode(AcsConfig.ISFEEDDEVICESTATUS).getValue(), "1")) {
- log.info("acs开始向mes反馈设备状态,请求参数:{}", JSON.toJSONString(param));
+ log.info("acs开始向lms反馈设备状态,请求参数:{}", JSON.toJSONString(param));
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedDeviceStatusType");
String methods_url = addressDto.getMethods_url();
@@ -139,9 +139,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
result = HttpRequest.post(url)
.body(JSON.toJSONString(param))
.execute();
- log.info("acs向mes反馈设备状态成功,请求参数:{},请求路径:{},响应参数:{}", JSON.toJSONString(param), url, result.body());
+ log.info("acs向lms反馈设备状态成功,请求参数:{},请求路径:{},响应参数:{}", JSON.toJSONString(param), url, result.body());
} catch (Exception e) {
- log.error("acs向mes反馈设备状态失败,请求参数:{},请求路径:{},失败原因:{}", JSON.toJSONString(param), url, e.getMessage());
+ log.error("acs向lms反馈设备状态失败,请求参数:{},请求路径:{},失败原因:{}", JSON.toJSONString(param), url, e.getMessage());
}
return result;
}
@@ -157,7 +157,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
- //log.info("acs开始向mes反馈当前设备工单生产数量,请求参数:{}", JSON.toJSONString(param));
+ //log.info("acs开始向lms反馈当前设备工单生产数量,请求参数:{}", JSON.toJSONString(param));
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedOrderRealQty");
String methods_url = addressDto.getMethods_url();
@@ -168,9 +168,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
.post(url)
.body(JSON.toJSONString(param))
.execute();
- //log.info("acs向mes反馈当前设备工单生产数量成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(param), JSON.toJSONString(result));
+ //log.info("acs向lms反馈当前设备工单生产数量成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(param), JSON.toJSONString(result));
} catch (Exception e) {
- log.error("acs向mes反馈当前设备工单生产数量失败,请求路径:{},请求参数:{},失败原因:{}", url, JSON.toJSONString(param), e.getMessage());
+ log.error("acs向lms反馈当前设备工单生产数量失败,请求路径:{},请求参数:{},失败原因:{}", url, JSON.toJSONString(param), e.getMessage());
}
return result;
}
@@ -185,7 +185,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
- //log.info("acs开始向mes反馈设备数量,请求参数:{}", JSON.toJSONString(map));
+ //log.info("acs开始向lms反馈设备数量,请求参数:{}", JSON.toJSONString(map));
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedDeviceNum");
String methods_url = addressDto.getMethods_url();
@@ -195,9 +195,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
result = HttpRequest.post(url)
.body(JSON.toJSONString(map))
.execute();
- //log.info("acs向mes反馈设备设备数量成功,请求参数:{},请求路径:{},响应参数:{}", JSON.toJSONString(map), url, JSON.toJSONString(result));
+ //log.info("acs向lms反馈设备设备数量成功,请求参数:{},请求路径:{},响应参数:{}", JSON.toJSONString(map), url, JSON.toJSONString(result));
} catch (Exception e) {
- log.error("acs向mes反馈设备数量失败,请求参数:{},请求路径:{},失败原因:{}", JSON.toJSONString(map), url, e.getMessage());
+ log.error("acs向lms反馈设备数量失败,请求参数:{},请求路径:{},失败原因:{}", JSON.toJSONString(map), url, e.getMessage());
}
return result;
}
@@ -212,7 +212,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
- //log.info("acs开始向mes反馈储料仓重量和数量,请求参数:{}", JSON.toJSONString(map));
+ //log.info("acs开始向lms反馈储料仓重量和数量,请求参数:{}", JSON.toJSONString(map));
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedDeviceNum2");
String methods_url = addressDto.getMethods_url();
@@ -222,9 +222,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
result = HttpRequest.post(url)
.body(JSON.toJSONString(map))
.execute();
- //log.info("acs向mes反馈储料仓重量和数量成功,请求参数:{},请求路径:{},响应参数:{}", JSON.toJSONString(map), url, JSON.toJSONString(result));
+ //log.info("acs向lms反馈储料仓重量和数量成功,请求参数:{},请求路径:{},响应参数:{}", JSON.toJSONString(map), url, JSON.toJSONString(result));
} catch (Exception e) {
- log.error("acs向mes反馈储料仓重量和数量失败,请求参数:{},请求路径:{},失败原因:{}", JSON.toJSONString(map), url, e.getMessage());
+ log.error("acs向lms反馈储料仓重量和数量失败,请求参数:{},请求路径:{},失败原因:{}", JSON.toJSONString(map), url, e.getMessage());
}
return result;
}
@@ -239,7 +239,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
- log.info("acs开始向mes申请扫码器任务,请求参数:{}", JSON.toJSONString(map));
+ log.info("acs开始向lms申请扫码器任务,请求参数:{}", JSON.toJSONString(map));
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("applyScannerTask");
String methods_url = addressDto.getMethods_url();
@@ -695,7 +695,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
- log.info("acs开始向mes反馈清洗上料状态,请求参数:{}", JSON.toJSONString(param));
+ log.info("acs开始向lms反馈清洗上料状态,请求参数:{}", JSON.toJSONString(param));
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("washTask");
String methods_url = addressDto.getMethods_url();
@@ -716,4 +716,31 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
MDC.remove(log_file_type);
}
}
+
+ @Override
+ public HttpResponse reportAnomaly(JSONObject param) {
+ try {
+ MDC.put(log_file_type, log_type);
+ if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
+ log.info("acs开始向lms反馈立库异常状态,请求参数:{}", JSON.toJSONString(param));
+ String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
+ AddressDto addressDto = addressService.findByCode("anomaly");
+ String methods_url = addressDto.getMethods_url();
+ String url = wmsurl + methods_url;
+ HttpResponse result = null;
+ try {
+ result = HttpRequest.post(url)
+ .body(JSON.toJSONString(param))
+ .execute();
+ log.info("acs向lms反馈工单状态成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(param), result.body());
+ } catch (Exception e) {
+ log.error("acs向lms反馈工单状态失败,请求路径:{},请求参数:{},失败原因:{}", url, JSON.toJSONString(param), e.getMessage());
+ }
+ return result;
+ }
+ return null;
+ } finally {
+ MDC.remove(log_file_type);
+ }
+ }
}
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java
index ce87844c..3746e55f 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java
@@ -9,20 +9,27 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
+import org.nl.acs.acsEnum.StatusEnum;
import org.nl.acs.device.address.service.AddressService;
import org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_hr_ssx.HailiangHrSsxDeviceDriver;
import org.nl.acs.ext.wms.RespUtil;
+import org.nl.acs.ext.wms.liKuData.Resp;
import org.nl.acs.ext.wms.liKuData.a.*;
+import org.nl.acs.ext.wms.liKuData.b.AGVTask;
+import org.nl.acs.ext.wms.liKuData.b.CreateRequest;
+import org.nl.acs.ext.wms.liKuData.b.InTaskDescribe;
import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.LiKuToAcsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
+import org.nl.acs.instruction.service.dto.InstructionDto;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.service.ParamService;
+import org.nl.modules.wql.util.SpringContextHolder;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -314,7 +321,7 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
result.put("code", "0");
result.put("msg", "success");
result.put("data", json);
- log.info("任务状态上报-----输出参数{}", result);
+ log.info("任务状态上报反馈-----输出参数{}", result);
return result;
} finally {
MDC.remove(log_file_type);
@@ -326,32 +333,88 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
try{
log.info("异常上报-----输入参数{}", JSON.toJSONString(requestParam));
String eventType=requestParam.getEventType();
-
+ String barcode = requestParam.getContainerCode();
+ TaskDto dto = taskService.findByContainer(barcode);
if(StrUtil.equals(eventType,"location_abnormal") || StrUtil.equals(eventType,"robot_abnormal") ){
//异常描述
String message = requestParam.getMessage();
if (StrUtil.equals(message,"TRY_ACTION_LOCATION_ALREADY_LOADING_CONTAINER")){
// 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
+ if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
+ JSONObject reqParam = new JSONObject();
+ reqParam.put("task_id", dto.getExt_task_id());
+ reqParam.put("status", StatusEnum.TASK_FULL_IN.getCode());
+
+ HttpResponse httpResponse = acsToWmsService.reportAnomaly(reqParam);
+ if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
+ log.info("反馈LMS半成品库任务状态成功");
+
+ JSONObject resp = JSONObject.parseObject(httpResponse.body());
+ if (resp.getInteger("status") == 200) {
+ //获取lms返回的新货位,ACS更新任务,指令,调用下发任务接口(指令号相同,新目标点)
+ String point_code2 = resp.getString("point_code2");
+ dto.setNext_point_code(point_code2);
+ taskService.update(dto);
+
+ Instruction insDto = instructionService.findByTaskId(dto.getTask_id(),"");
+ insDto.setNext_point_code(point_code2);
+ instructionService.update(insDto);
+
+ CreateRequest createRequest = new CreateRequest();
+ List list = new ArrayList();
+ Resp resp_hairou = new Resp();
+ createRequest.setTaskType("tote_inbound");
+ //list Describe 入库
+ InTaskDescribe inTaskDescribe=new InTaskDescribe();
+ inTaskDescribe.setContainerCode(insDto.getVehicle_code());
+ inTaskDescribe.setFromLocationCode(insDto.getStart_point_code());
+ inTaskDescribe.setLocationCode(point_code2);
+ inTaskDescribe.setContainerType(insDto.getVehicle_type());
+
+ AGVTask agvTask1 = new AGVTask();
+ agvTask1.setTaskDescribe(inTaskDescribe);
+ agvTask1.setTaskCode(insDto.getTask_id());
+ agvTask1.setTaskPriority(insDto.getPriority());
+
+ list.add(agvTask1);
+ createRequest.setTasks(list);
+ resp_hairou = acsToLiKuService.create(createRequest);
+ }
+ }
+ }
+ }
+// if (StrUtil.equals(message,"TRY_ACTION_LOCATION_NOT_LOADING_CONTAINER")){
+// // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
+// String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
// if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
-// JSONObject feed_jo = new JSONObject();
-// feed_jo.put("task_id", entity.getExt_task_id());
-// feed_jo.put("status", dto.getTask_status());
-// if (ObjectUtil.isNotEmpty(dto.getQuantity())) {
-// feed_jo.put("quantity", dto.getQuantity());
+// JSONObject reqParam = new JSONObject();
+// reqParam.put("task_id", dto.getExt_task_id());
+// reqParam.put("status", StatusEnum.TASK_EMPTY_OUT.getCode());
+//
+// HttpResponse httpResponse = acsToWmsService.washTask(reqParam);
+// if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
+// log.info("反馈LMS半成品库任务状态成功");
// }
-// if (ObjectUtil.isNotEmpty(dto.getVehicle_code())) {
-// feed_jo.put("vehicle_code", dto.getVehicle_code());
-// }
-// if (ObjectUtil.isNotEmpty(dto.getWeight())) {
-// feed_jo.put("weight", dto.getWeight());
-// }
-// feed_jo.put("ext_param", dto.getExt_param());
-// JSONArray ja = new JSONArray();
-// ja.add(feed_jo);
-// HttpResponse httpResponse = acsToWmsService.feedbackTaskStatusToWms(ja);
-// this.taskFeedbackAdd(httpResponse, dto);
// }
+// }
+
+ if (StrUtil.equals(message,"TRY_ACTION_LOCATION_CONTAINER_NOT_SAME_WITH_TASK") || StrUtil.equals(message,"NO_CONTAINER_CODE")){
+ // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
+ String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
+ if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
+ JSONObject reqParam = new JSONObject();
+ reqParam.put("task_id", dto.getExt_task_id());
+ reqParam.put("status", StatusEnum.TASK_CHECK_ANOMALY.getCode());
+
+ HttpResponse httpResponse = acsToWmsService.reportAnomaly(reqParam);
+ if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
+ log.info("反馈LMS半成品库任务状态成功");
+ //完成指令,任务
+ Instruction insDto = instructionService.findByTaskId(dto.getTask_id(),"");
+ instructionService.finish(insDto.getInstruction_id());
+ }
+ }
}
}
AbnormarReportingResponse abnormarReportingResponse = new AbnormarReportingResponse();
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
index 86b55754..e504c477 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
@@ -181,7 +181,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (hailiangEngravingInDeviceDriver.getGd_move() == 0) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
- json.put("message", "->上面无料框!请核实后再点击按钮!");
+ json.put("message", "->"+hailiangEngravingInDeviceDriver.getGd_move()+"上面无料框!请核实后再点击按钮!");
errArr.add(json);
continue;
}
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/wcs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
index dd9bb8aa..612f82f4 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
@@ -356,12 +356,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
* 7 不去称重平台称重PS20 agvtype:2
* 8 RT20 agvtype:3
*/
- if(StrUtil.equals(task.getTask_type(),"18")){
+ if(StrUtil.equals(task.getTask_type(),StatusEnum.HAIROU_LIKU_REQ.getCode())){
CreateRequest createRequest = new CreateRequest();
List list = new ArrayList();
AcsToLiKuService acsToLiKuService = SpringContextHolder.getBean(AcsToLiKuService.class);
Resp resp = new Resp();
- if(StrUtil.equals("1",task.getStorage_task_type())){
+ if(StrUtil.equals(StatusEnum.HAIROU_IN_REQ.getCode(),task.getStorage_task_type()) || StrUtil.equals(StatusEnum.HAIROU_EMPTY_IN_REQ.getCode(),task.getStorage_task_type())){
createRequest.setTaskType("tote_inbound");
//list Describe 入库
InTaskDescribe inTaskDescribe=new InTaskDescribe();
@@ -378,7 +378,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
list.add(agvTask1);
createRequest.setTasks(list);
resp=acsToLiKuService.create(createRequest);
- } else if(StrUtil.equals("2",task.getStorage_task_type())){
+ } else if(StrUtil.equals(StatusEnum.HAIROU_OUT_REQ.getCode(),task.getStorage_task_type()) || StrUtil.equals(StatusEnum.HAIROU_EMPTY_OUT_REQ.getCode(),task.getStorage_task_type())){
createRequest.setTaskType("tote_outbound");
//list Describe 出库
OutTaskDescribe outTaskDescribe = new OutTaskDescribe();
@@ -393,7 +393,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
list.add(agvTask);
createRequest.setTasks(list);
resp=acsToLiKuService.create(createRequest);
- }else if(StrUtil.equals("3",task.getStorage_task_type())){
+ }else if(StrUtil.equals(StatusEnum.HAIROU_RELOCATION.getCode(),task.getStorage_task_type())){
createRequest.setTaskType("tote_relocation");
//list Describe 移库
RelocationTaskDescribe relocationTaskDescribe = new RelocationTaskDescribe();
@@ -410,7 +410,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
createRequest.setTasks(list);
resp=acsToLiKuService.create(createRequest);
- }else if(StrUtil.equals("4",task.getStorage_task_type())){
+ }else if(StrUtil.equals(StatusEnum.HAIROU_CARRY.getCode(),task.getStorage_task_type())){
createRequest.setTaskType("tote_carry");
//list Describe 搬运
CarryTaskDescribe carryTaskDescribe=new CarryTaskDescribe();
@@ -427,7 +427,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
list.add(agvTask4);
createRequest.setTasks(list);
resp=acsToLiKuService.create(createRequest);
- }else if(StrUtil.equals("5",task.getStorage_task_type())){
+ }else if(StrUtil.equals(StatusEnum.HAIROU_CHECK.getCode(),task.getStorage_task_type())){
createRequest.setTaskType("tote_check");
//list Describe 盘库
CheckTaskDescribe checkTaskDescribe=new CheckTaskDescribe();
diff --git a/wcs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java b/wcs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java
index 03f10868..3ef07ba6 100644
--- a/wcs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java
+++ b/wcs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java
@@ -14,352 +14,400 @@ import org.openscada.opc.lib.da.*;
import java.util.*;
+
@Slf4j
-public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerConnectionStateListener{
- List protocols;
- OpcServerManageDto OpcServer;
- int error_num;
- String message;
- int maxResartNum;
- private Server server;
- private Group group;
- boolean flag = false;
- private int all_null;
- private Map itemSearchCache;
+public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerConnectionStateListener {
+ List protocols;
+ OpcServerManageDto OpcServer;
+ int error_num;
+ String message;
+ int maxResartNum;
+ private Server server;
+ private Group group;
+ boolean flag = false;
+ private int all_null;
+ private Map itemSearchCache;
- public DeviceOpcProtocolRunable() {
- this.error_num = 0;
- this.all_null = 0;
- this.message = null;
- this.itemSearchCache = new HashMap();
- this.server = null;
- }
+ public DeviceOpcProtocolRunable() {
+ this.error_num = 0;
+ this.all_null = 0;
+ this.message = null;
+ this.itemSearchCache = new HashMap();
+ this.server = null;
+ }
- public List getProtocols() {
- return this.protocols;
- }
+ public List getProtocols() {
+ return this.protocols;
+ }
- public void setProtocols(List protocols) {
- this.protocols = protocols;
- }
+ public void setProtocols(List protocols) {
+ this.protocols = protocols;
+ }
- public OpcServerManageDto getOpcServer() {
- return this.OpcServer;
- }
+ public OpcServerManageDto getOpcServer() {
+ return this.OpcServer;
+ }
- public void setOpcServer(OpcServerManageDto opcServer) {
- this.OpcServer = opcServer;
- }
+ public void setOpcServer(OpcServerManageDto opcServer) {
+ this.OpcServer = opcServer;
+ }
- private OpcItemDto getItem(String item) {
- OpcItemDto x = (OpcItemDto) this.itemSearchCache.get(item);
- if(x == null) {
- Iterator var3 = this.protocols.iterator();
- while(var3.hasNext()) {
- OpcItemDto dto = (OpcItemDto) var3.next();
- if(StrUtil.equals(item, dto.getItem_code())) {
- x = dto;
- this.itemSearchCache.put(item, dto);
- break;
- }
- }
- }
- return x;
- }
- @Override
- public void run() {
- if(OpcConfig.opc_item_read_using_callback) {
- this.runNew();
- }
- else{
- this.runOld();
- }
- }
+ private OpcItemDto getItem(String item) {
+ OpcItemDto x = (OpcItemDto) this.itemSearchCache.get(item);
+ if (x == null) {
+ Iterator var3 = this.protocols.iterator();
- private void runOld() {
- OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService.class);
- while(true) {
- start:
- try {
- if(this.group != null) {
- group.clear();
- group.remove();
- log.trace("清理group...");
- }
- if(this.server != null) {
- server.disconnect();
- log.trace("清理server...");
- }
- // this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
- // this.server.addStateListener(this);
- // group = this.server.addGroup();
- group = opcServerService.getServer(this.getOpcServer().getOpc_code());
- List itemsString = new ArrayList();
- Iterator var3 = this.protocols.iterator();
- while(var3.hasNext()) {
- OpcItemDto protocol = (OpcItemDto) var3.next();
- String item = protocol.getItem_code();
- itemsString.add(item);
- }
- Map itemsMap = new LinkedHashMap();
- boolean is_error = false;
- StringBuilder err_message = new StringBuilder();
- Iterator var6 = itemsString.iterator();
- while(var6.hasNext()) {
- String string = (String) var6.next();
- try {
- Item item = group.addItem(string);
- itemsMap.put(string, item);
- log.trace("添加成功 {}", string);
- }
- catch(Exception var26) {
- err_message.append(string + ":" + var26.getMessage());
- if(!is_error) {
- is_error = true;
- }
- }
- }
- String tag;
- if(is_error) {
- tag = err_message.toString();
- log.warn("{}:{}", OpcConfig.resource_code, tag);
- }
- if(!OpcStartTag.is_run) {
- OpcStartTag.is_run = true;
- }
- tag = "";
- if(log.isWarnEnabled()) {
- tag = Thread.currentThread().getName();
- if(this.OpcServer != null) {
- tag = tag + this.getOpcGroupID();
- }
- }
- UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
- boolean time_out = false;
- while(DeviceOpcSynchronizeAutoRun.isRun) {
- long begin = System.currentTimeMillis();
- if(log.isTraceEnabled()) {
- log.trace("{} 开始记时{}", tag, DateUtil.now());
- }
- Map- itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
- long end = System.currentTimeMillis();
- long duration = end - begin;
- if(log.isTraceEnabled()) {
- log.trace("{} 读取耗时:{}", tag, duration);
- }
- if(duration > 1000L) {
- if(!time_out) {
- log.warn("{} 读取超时 : {}", tag, duration);
- }
- time_out = true;
- }
- else{
- time_out = false;
- }
- boolean valueAllNotNull = false;
- Set
- items = itemStatus.keySet();
- Iterator var18 = items.iterator();
- while(var18.hasNext()) {
- Item item = (Item) var18.next();
- ItemState itemState = (ItemState) itemStatus.get(item);
- Object value = OpcUtl.getValue(item, itemState);
- if(value != null) {
- valueAllNotNull = true;
- }
- String itemId = item.getId();
- Object his = accessor_value.getValue(itemId);
- if(!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
- log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality());
- valueAllNotNull = false;
- }
- if(!UnifiedDataAppService.isEquals(value, his)) {
- OpcItemDto itemDto = this.getItem(itemId);
- if(true) {
- this.logItemChanged(itemId, accessor_value, value, itemDto);
- }
- if(!ObjectUtil.isEmpty(value)) {
- accessor_value.setValue(itemId, value);
- }
- }
- }
- end = System.currentTimeMillis();
- if(log.isTraceEnabled()) {
- log.trace("{}", itemsString);
- log.trace("{} 计算完成耗时{}", tag, end - begin);
- }
- ThreadUtl.sleep((long) OpcConfig.synchronized_millisecond);
- if(this.error_num != 0) {
- this.error_num = 0;
- this.message = null;
- }
- if(!valueAllNotNull) {
- int random = (new Random()).nextInt(10) + 1;
- random *= 1000;
- if(this.all_null < 3) {
- if(log.isWarnEnabled()) {
- log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 5000 + random);
- }
- ThreadUtl.sleep((long) (5000 + random));
- }
- else if(this.all_null < 6) {
- if(log.isWarnEnabled()) {
- log.warn(tag + "重新创建server");
- log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 30000 + random);
- }
- // ThreadUtl.sleep((long) (30000 + random));
- ThreadUtl.sleep((long) ((new Random()).nextInt(3) + 1) * 10000);
- break start;
- }
- else if(this.all_null < 12) {
- if(log.isWarnEnabled()) {
- log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, '\uea60' + random);
- }
- ThreadUtl.sleep((long) ('\uea60' + random));
- }
- else{
- if(log.isWarnEnabled()) {
- log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, 120000 + random);
- }
- ThreadUtl.sleep((long) (120000 + random));
- }
- ++this.all_null;
- }
- else{
- this.all_null = 0;
- }
- // break start;
- }
- log.warn("opc线程停止。。。");
- return;
- }
- catch(Exception var27) {
- if(this.server != null) {
- try {
- this.server.disconnect();
- }
- catch(Exception var25) {
- }
- }
- this.server = null;
- if(!DeviceOpcSynchronizeAutoRun.isRun) {
- log.warn("opc线程停止2。。。");
- return;
- }
- String error_message = "设备信息同步异常";
- if(!StrUtil.equals(this.message, error_message)) {
- log.warn(error_message, var27);
- }
- ThreadUtl.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
- ++this.error_num;
- if(this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {
- this.message = error_message;
- }
- }
- }
- }
+ while (var3.hasNext()) {
+ OpcItemDto dto = (OpcItemDto) var3.next();
+ if (StrUtil.equals(item, dto.getItem_code())) {
+ x = dto;
+ this.itemSearchCache.put(item, dto);
+ break;
+ }
+ }
+ }
- private void runNew() {
- Async20Access accessor = null;
- while(true) {
- String opcGroupId = this.getOpcGroupID();
- try {
- if(this.server == null) {
- this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
- this.server.addStateListener(this);
- accessor = new Async20Access(this.server, OpcConfig.synchronized_millisecond, true);
- Iterator var9 = this.protocols.iterator();
- while(var9.hasNext()) {
- OpcItemDto protocol = (OpcItemDto) var9.next();
- String itemId = protocol.getItem_code();
- accessor.addItem(itemId, this);
- }
- accessor.bind();
- log.info("Async20Access bind {}", opcGroupId);
- }
- Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
- }
- catch(Exception var8) {
- if(accessor != null) {
- try {
- log.warn("Async20Access unbind {}", opcGroupId);
- accessor.unbind();
- }
- catch(Exception var7) {
- var7.printStackTrace();
- }
- accessor = null;
- }
- if(this.server != null) {
- try {
- this.server.disconnect();
- }
- catch(Exception var6) {
- }
- this.server = null;
- }
- if(var8 instanceof InterruptedException) {
- log.warn("OPC 同步线程(%s)被中断", opcGroupId);
- return;
- }
- log.warn("设备信息同步异常", var8);
- ThreadUtl.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
- String error_message = var8.getMessage();
- if(error_message == null) {
- error_message = var8.toString();
- }
- ++this.error_num;
- if(this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {
- this.message = error_message;
- }
- }
- }
- }
+ return x;
+ }
- public void connectionStateChanged(boolean connected) {
- if(!connected) {
- this.server = null;
- }
- log.warn("opc server {} {}", this.getOpcGroupID(), connected ? "connected" : "disconnected");
- }
- private String getOpcGroupID() {
- String var10000 = this.OpcServer.getOpc_code();
- return var10000 + "(" + this.protocols.size() + " items)";
- }
+ @Override
+ public void run() {
+ if (OpcConfig.opc_item_read_using_callback) {
+ this.runNew();
+ } else {
+ this.runOld();
+ }
+ }
- public static String formatDuring(long mss) {
- long days = mss / 86400000L;
- long hours = mss % 86400000L / 3600000L;
- long minutes = mss % 3600000L / 60000L;
- long seconds = mss % 60000L / 1000L;
- return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds ";
- }
- public void changed(Item item, ItemState itemState) {
- String itemId = item.getId();
+ private void runOld() {
+ OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService .class);
+ while (true) {
+ start:
+ try {
+ if (this.group != null) {
+ group.clear();
+ group.remove();
+ log.trace("清理group...");
+ }
+ if (this.server != null) {
+ server.disconnect();
+ log.trace("清理server...");
+ }
+ this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
+ this.server.addStateListener(this);
+ group = this.server.addGroup();
+// group =opcServerService.getServer(this.getOpcServer().getOpc_code());
+
+ List itemsString = new ArrayList();
+ Iterator var3 = this.protocols.iterator();
+
+ while (var3.hasNext()) {
+ OpcItemDto protocol = (OpcItemDto) var3.next();
+ String item = protocol.getItem_code();
+ itemsString.add(item);
+ }
+
+ Map itemsMap = new LinkedHashMap();
+ boolean is_error = false;
+ StringBuilder err_message = new StringBuilder();
+ Iterator var6 = itemsString.iterator();
+
+ while (var6.hasNext()) {
+ String string = (String) var6.next();
+
try {
- Object value = OpcUtl.getValue(item, itemState);
- UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
- accessor_value.setValue(itemId, value);
- // if (value != null) {
- // if (log.isTraceEnabled()) {
- // log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()});
- // }
- // } else if (log.isInfoEnabled()) {
- // log.info("Item {} new value: {}, Timestamp: {}, Quality: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime(), itemState.getQuality()});
- // }
- log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()});
- OpcItemDto itemDto = this.getItem(itemId);
- // if (Boolean.TRUE.equals(itemDto.getNeed_log())) {
- // this.logItemChanged(itemId, accessor_value, value, itemDto);
- // }
- this.logItemChanged(itemId, accessor_value, value, itemDto);
+ Item item = group.addItem(string);
+ itemsMap.put(string, item);
+ log.trace("添加成功 {}", string);
+ } catch (Exception var26) {
+ err_message.append(string + ":" + var26.getMessage());
+ if (!is_error) {
+ is_error = true;
+ }
}
- catch(Exception var7) {
- log.error(itemId, var7);
+ }
+
+ String tag;
+ if (is_error) {
+ tag = err_message.toString();
+ log.warn("{}:{}", OpcConfig.resource_code, tag);
+ }
+
+ if (!OpcStartTag.is_run) {
+ OpcStartTag.is_run = true;
+ }
+
+ tag = "";
+ if (log.isWarnEnabled()) {
+ tag = Thread.currentThread().getName();
+ if (this.OpcServer != null) {
+ tag = tag + this.getOpcGroupID();
}
- }
+ }
+
+ UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
+ boolean time_out = false;
+
+ while (DeviceOpcSynchronizeAutoRun.isRun) {
+ long begin = System.currentTimeMillis();
+ if (log.isTraceEnabled()) {
+ log.trace("{} 开始记时{}", tag, DateUtil.now());
+ }
+
+ Map
- itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
+ long end = System.currentTimeMillis();
+ long duration = end - begin;
+ if (log.isTraceEnabled()) {
+ log.trace("{} 读取耗时:{}", tag, duration);
+ }
+
+ if (duration > 1000L) {
+ if (!time_out) {
+ log.warn("{} 读取超时 : {}", tag, duration);
+ }
+
+ time_out = true;
+ } else {
+ time_out = false;
+ }
+
+ boolean valueAllNotNull = false;
+ Set
- items = itemStatus.keySet();
+ Iterator var18 = items.iterator();
+
+ while (var18.hasNext()) {
+ Item item = (Item) var18.next();
+ ItemState itemState = (ItemState) itemStatus.get(item);
+ Object value = OpcUtl.getValue(item, itemState);
+ if (value != null) {
+ valueAllNotNull = true;
+ }
+
+ String itemId = item.getId();
+ Object his = accessor_value.getValue(itemId);
+ if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
+ log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality());
+ valueAllNotNull = false;
+ }
+
+ if (!UnifiedDataAppService.isEquals(value, his)) {
+ OpcItemDto itemDto = this.getItem(itemId);
+ if (true) {
+ this.logItemChanged(itemId, accessor_value, value, itemDto);
+ }
+ if(!ObjectUtil.isEmpty(value)){
+ accessor_value.setValue(itemId, value);
+ }
+ }
+ }
+
+ end = System.currentTimeMillis();
+ if (log.isTraceEnabled()) {
+ log.trace("{}", itemsString);
+ log.trace("{} 计算完成耗时{}", tag, end - begin);
+ }
+
+ ThreadUtl.sleep((long) OpcConfig.synchronized_millisecond);
+ if (this.error_num != 0) {
+ this.error_num = 0;
+ this.message = null;
+ }
+
+ if (!valueAllNotNull) {
+ int random = (new Random()).nextInt(10) + 1;
+ random *= 1000;
+ if (this.all_null < 3) {
+ if (log.isWarnEnabled()) {
+ log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,5000 + random);
+ }
+
+ ThreadUtl.sleep((long) (5000 + random));
+// ThreadUtl.sleep((long) ((new Random()).nextInt(3) +1) * 10000);
+// break start;
+ } else if (this.all_null < 6) {
+ if (log.isWarnEnabled()) {
+ log.warn(tag + "重新创建server");
+ log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,30000 + random);
+ }
+// ThreadUtl.sleep((long) (30000 + random));
+ ThreadUtl.sleep((long) ((new Random()).nextInt(3) +1) * 10000);
+ break start;
+ } else if (this.all_null < 12) {
+ if (log.isWarnEnabled()) {
+ log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, '\uea60' + random);
+ }
+
+ ThreadUtl.sleep((long) ('\uea60' + random));
+// ThreadUtl.sleep((long) ((new Random()).nextInt(3) +1) * 10000);
+// break start;
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, 120000 + random);
+ }
+
+ ThreadUtl.sleep((long) (120000 + random));
+// ThreadUtl.sleep((long) ((new Random()).nextInt(3) +1) * 10000);
+// break start;
+ }
+
+ ++this.all_null;
+ } else {
+ this.all_null = 0;
+ }
+// break start;
+
+ }
+
+ log.warn("opc线程停止。。。");
+ return;
+ } catch (Exception var27) {
+ if (this.server != null) {
+ try {
+ this.server.disconnect();
+ } catch (Exception var25) {
+ }
+ }
+
+ this.server = null;
+ if (!DeviceOpcSynchronizeAutoRun.isRun) {
+ log.warn("opc线程停止2。。。");
+ return;
+ }
+
+ String error_message = "设备信息同步异常";
+ if (!StrUtil.equals(this.message, error_message)) {
+ log.warn(error_message, var27);
+ }
+
+ ThreadUtl.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
+ ++this.error_num;
+ if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {
+ this.message = error_message;
+ }
+ }
+ }
+ }
+
+
+ private void runNew() {
+ Async20Access accessor = null;
+
+ while (true) {
+ String opcGroupId = this.getOpcGroupID();
+
+ try {
+ if (this.server == null) {
+ this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
+ this.server.addStateListener(this);
+ accessor = new Async20Access(this.server, OpcConfig.synchronized_millisecond, true);
+ Iterator var9 = this.protocols.iterator();
+
+ while (var9.hasNext()) {
+ OpcItemDto protocol = (OpcItemDto) var9.next();
+ String itemId = protocol.getItem_code();
+ accessor.addItem(itemId, this);
+ }
+
+ accessor.bind();
+ log.info("Async20Access bind {}", opcGroupId);
+ }
+
+ Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
+ } catch (Exception var8) {
+ if (accessor != null) {
+ try {
+ log.warn("Async20Access unbind {}", opcGroupId);
+ accessor.unbind();
+ } catch (Exception var7) {
+ var7.printStackTrace();
+ }
+
+ accessor = null;
+ }
+
+ if (this.server != null) {
+ try {
+ this.server.disconnect();
+ } catch (Exception var6) {
+ }
+
+ this.server = null;
+ }
+
+ if (var8 instanceof InterruptedException) {
+ log.warn("OPC 同步线程(%s)被中断", opcGroupId);
+ return;
+ }
+
+ log.warn("设备信息同步异常", var8);
+ ThreadUtl.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
+ String error_message = var8.getMessage();
+ if (error_message == null) {
+ error_message = var8.toString();
+ }
+
+ ++this.error_num;
+ if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {
+ this.message = error_message;
+ }
+ }
+ }
+ }
+
+
+ public void connectionStateChanged(boolean connected) {
+ if (!connected) {
+ this.server = null;
+ }
+
+ log.warn("opc server {} {}", this.getOpcGroupID(), connected ? "connected" : "disconnected");
+ }
+
+ private String getOpcGroupID() {
+ String var10000 = this.OpcServer.getOpc_code();
+ return var10000 + "(" + this.protocols.size() + " items)";
+ }
+
+ public static String formatDuring(long mss) {
+ long days = mss / 86400000L;
+ long hours = mss % 86400000L / 3600000L;
+ long minutes = mss % 3600000L / 60000L;
+ long seconds = mss % 60000L / 1000L;
+ return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds ";
+ }
+
+
+ public void changed(Item item, ItemState itemState) {
+ String itemId = item.getId();
+
+ try {
+ Object value = OpcUtl.getValue(item, itemState);
+ UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
+ accessor_value.setValue(itemId, value);
+
+// if (value != null) {
+// if (log.isTraceEnabled()) {
+// log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()});
+// }
+// } else if (log.isInfoEnabled()) {
+// log.info("Item {} new value: {}, Timestamp: {}, Quality: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime(), itemState.getQuality()});
+// }
+ log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()});
+
+ OpcItemDto itemDto = this.getItem(itemId);
+// if (Boolean.TRUE.equals(itemDto.getNeed_log())) {
+// this.logItemChanged(itemId, accessor_value, value, itemDto);
+// }
+ this.logItemChanged(itemId, accessor_value, value, itemDto);
+
+ } catch (Exception var7) {
+ log.error(itemId, var7);
+ }
+
+ }
private void logItemChanged(String itemId, UnifiedDataAccessor accessor_value, Object value, OpcItemDto itemDto) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);