add:故障上报
This commit is contained in:
@@ -104,6 +104,9 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
int container_qty = 0;
|
||||
int last_container_qty = 0;
|
||||
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -136,6 +139,9 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode);
|
||||
}
|
||||
if (status != last_status) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
@@ -166,6 +172,9 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号container_qty:" + last_container_qty + " -> " + container_qty);
|
||||
}
|
||||
|
||||
if (errorDeviceRecord) {
|
||||
this.errorDeviceRecord();
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
@@ -451,4 +460,23 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
public void errorDeviceRecord() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.acs.device_driver.lnsh.lnsh_kiln_lane;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -12,6 +13,7 @@ import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
@@ -22,7 +24,9 @@ import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -46,7 +50,7 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
String device_code;
|
||||
int mode = 0;
|
||||
int error = 0;
|
||||
@@ -91,6 +95,11 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
int burning_car_qty = 0;
|
||||
int last_burning_car_qty = 0;
|
||||
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
private int instruction_require_time_out;
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -118,6 +127,9 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode);
|
||||
}
|
||||
if (status != last_status) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
@@ -149,7 +161,9 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
logServer.deviceItemValue(this.device_code,"burning_car_qty" ,String.valueOf(burning_car_qty));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号burning_car_qty:" + last_burning_car_qty + " -> " + burning_car_qty);
|
||||
}
|
||||
|
||||
if (errorDeviceRecord) {
|
||||
this.errorDeviceRecord();
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
@@ -295,4 +309,22 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
public void errorDeviceRecord() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.nl.acs.device_driver.lnsh.lnsh_kiln_truss;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -10,6 +12,7 @@ import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
@@ -19,6 +22,7 @@ import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -42,7 +46,7 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
String device_code;
|
||||
int mode = 0;
|
||||
int error = 0;
|
||||
@@ -77,6 +81,12 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
int error_time = 0;
|
||||
int last_error_time = 0;
|
||||
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -101,6 +111,9 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode);
|
||||
}
|
||||
if (status != last_status) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
@@ -120,7 +133,9 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
logServer.deviceItemValue(this.device_code,"error_time" ,String.valueOf(error_time));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号error_time:" + last_error_time + " -> " + error_time);
|
||||
}
|
||||
|
||||
if (errorDeviceRecord) {
|
||||
this.errorDeviceRecord();
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
@@ -233,4 +248,23 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
public void errorDeviceRecord() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.acs.device_driver.lnsh.lnsh_mixing_mill;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
@@ -31,6 +32,7 @@ import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -109,7 +111,8 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
String material;
|
||||
String last_material;
|
||||
|
||||
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -140,7 +143,16 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error);
|
||||
}
|
||||
|
||||
if (status != last_status) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
if (errorDeviceRecord) {
|
||||
this.errorDeviceRecord();
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
log.info(var17.getMessage());
|
||||
@@ -456,4 +468,22 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void errorDeviceRecord() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,8 @@ public class LnshOutKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
//出窑设备
|
||||
int outKiln_device = 0;
|
||||
int last_outKiln_device = 0;
|
||||
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -130,6 +131,9 @@ public class LnshOutKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode);
|
||||
}
|
||||
if (status != last_status) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
@@ -161,6 +165,9 @@ public class LnshOutKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
logServer.deviceItemValue(this.device_code,"outKiln_device" ,String.valueOf(outKiln_device));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号outKiln_device:" + last_outKiln_device + " -> " + outKiln_device);
|
||||
}
|
||||
if (errorDeviceRecord) {
|
||||
this.errorDeviceRecord();
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
@@ -351,4 +358,22 @@ public class LnshOutKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implem
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
public void errorDeviceRecord() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,9 @@ public class LnshPackageLineDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
String to_brick_type = "";
|
||||
String last_to_brick_type = "";
|
||||
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -156,6 +159,9 @@ public class LnshPackageLineDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode);
|
||||
}
|
||||
if (status != last_status) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
@@ -399,4 +405,23 @@ public class LnshPackageLineDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
public void errorDeviceRecord() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.acs.device_driver.lnsh.lnsh_package_pallet_manipulator;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
@@ -35,6 +36,7 @@ import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -142,6 +144,8 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
|
||||
int order_qty = 0;
|
||||
int last_order_qty = 0;
|
||||
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -178,6 +182,11 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode);
|
||||
}
|
||||
if (status != last_status) {
|
||||
if (status == 3) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
}
|
||||
logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
@@ -185,6 +194,9 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
|
||||
logServer.deviceItemValue(this.device_code,"error" ,String.valueOf(error));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号error:" + last_error + " -> " + error);
|
||||
}
|
||||
if (errorDeviceRecord) {
|
||||
this.errorDeviceRecord();
|
||||
}
|
||||
// if (put_station != last_put_station) {
|
||||
// logServer.deviceItemValue(this.device_code,"put_station" ,String.valueOf(put_station));
|
||||
// logServer.deviceExecuteLog(this.device_code,"","","信号put_station:" + last_put_station + " -> " + put_station);
|
||||
@@ -653,4 +665,22 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
public void errorDeviceRecord() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.acs.device_driver.lnsh.lnsh_press;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
@@ -31,6 +32,7 @@ import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -113,7 +115,8 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
int last_unqualified = 0;
|
||||
String order_No = "0";
|
||||
String last_order_No = "0";
|
||||
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -149,6 +152,9 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error);
|
||||
}
|
||||
if (status != last_status) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
@@ -192,7 +198,9 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
logServer.deviceItemValue(this.device_code, "order_No", order_No);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号order_No:" + last_order_No + " -> " + order_No);
|
||||
}
|
||||
|
||||
if (errorDeviceRecord) {
|
||||
this.errorDeviceRecord();
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
log.info(var17.getMessage());
|
||||
message = "错误:" + var17.getMessage();
|
||||
@@ -594,6 +602,23 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
public void errorDeviceRecord() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -20,6 +21,7 @@ import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.LnshLaminatingMachi
|
||||
import org.nl.acs.device_driver.lnsh.lnsh_package_site.LnshPackageSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.lnsh.lnsh_palletizing_manipulator_site.LnshPalletizingManipulatorSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
@@ -38,6 +40,7 @@ import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.AddFailedException;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
@@ -67,6 +70,8 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
||||
@Autowired
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
|
||||
Instruction inst = null;
|
||||
|
||||
//当前指令1
|
||||
@@ -177,6 +182,9 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
||||
private int instruction_require_time_out = 3000;
|
||||
private int instruction_update_time_out = 500;
|
||||
|
||||
boolean errorDeviceRecord = false;
|
||||
JSONObject errorDeviceRecordRequest = new JSONObject();
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -228,6 +236,9 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
if (status != last_status) {
|
||||
this.errorDeviceRecordRequest.put("device_code", this.device_code);
|
||||
this.errorDeviceRecordRequest.put("error", this.error);
|
||||
this.errorDeviceRecord = true;
|
||||
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status);
|
||||
}
|
||||
@@ -304,6 +315,10 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command2:" + last_to_command2 + "->" + to_command2);
|
||||
}
|
||||
|
||||
if (errorDeviceRecord) {
|
||||
this.errorDeviceRecord();
|
||||
}
|
||||
|
||||
|
||||
if (task1 > 0 || task2 > 0) {
|
||||
update_instruction_status();
|
||||
@@ -1290,4 +1305,17 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
||||
log.info("下发前后工位任务前起始站{}前目标站{}任务号{}后起始站{}后目标站{}",start_addr,next_addr,dto.getInstruction_code(),start_addr2,next_addr2);
|
||||
}
|
||||
|
||||
public void errorDeviceRecord() {
|
||||
HttpResponse result = acsToWmsService.errorDeviceRecord(errorDeviceRecordRequest);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
if (result.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.errorDeviceRecordRequest = new JSONObject();
|
||||
this.errorDeviceRecord = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -186,4 +186,6 @@ public interface AcsToWmsService {
|
||||
HttpResponse mark(JSONObject param);
|
||||
|
||||
void syncDemo();
|
||||
|
||||
HttpResponse errorDeviceRecord(JSONObject errorDeviceRecordRequest);
|
||||
}
|
||||
|
||||
@@ -1092,4 +1092,31 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
log.info("线程编号"+Thread.currentThread().getName());
|
||||
log.error("线程编号"+Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse errorDeviceRecord(JSONObject errorDeviceRecordRequest) {
|
||||
try {
|
||||
MDC.put(log_file_type, log_type);
|
||||
String wmsurl = acsConfigService.findByCode(AcsConfig.WMSURL).getValue();
|
||||
|
||||
HttpResponse result = null;
|
||||
log.info("errorDeviceRecord - 请求参数 {}", errorDeviceRecordRequest);
|
||||
AddressDto addressDto = addressService.findByCode("errorDeviceRecord");
|
||||
String methods_url = addressDto.getMethods_url();
|
||||
try {
|
||||
result = HttpRequest
|
||||
.post(wmsurl + methods_url)
|
||||
.body(errorDeviceRecordRequest.toJSONString())
|
||||
.execute();
|
||||
log.info("errorDeviceRecord - 返回参数 {}", result.body());
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
MDC.remove(log_file_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.nl.acs.opc;
|
||||
|
||||
import org.nl.acs.device_driver.driver.ItemValue;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.nl.acs.opc;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.nl.acs.auto.initial.ApplicationAutoInitial;
|
||||
import org.nl.acs.device_driver.driver.ItemValue;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.openscada.opc.lib.common.NotConnectedException;
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.*;
|
||||
import org.nl.acs.device_driver.driver.ItemValue;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
|
||||
Reference in New Issue
Block a user