更新
This commit is contained in:
@@ -74,6 +74,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
public int error = 0;
|
||||
public int door = 0;
|
||||
public int temperature = 0;
|
||||
public int to_temperature = 0;
|
||||
public int countdown_house = 0;
|
||||
public int countdown_min = 0;
|
||||
public int countdown_sec = 0;
|
||||
@@ -120,6 +121,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
|
||||
String device_code;
|
||||
|
||||
String message = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -130,7 +134,6 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
|
||||
device_code = this.getDeviceCode();
|
||||
heartbeat = this.itemProtocol.getItem_heartbeat();
|
||||
@@ -154,7 +157,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
currentA = this.itemProtocol.getItem_currentA();
|
||||
currentB = this.itemProtocol.getItem_currentB();
|
||||
currentC = this.itemProtocol.getItem_currentC();
|
||||
|
||||
to_temperature = this.itemProtocol.getItem_to_temperature();
|
||||
if (mode != last_mode) {
|
||||
//this.setRequireSucess(false);
|
||||
}
|
||||
@@ -187,6 +190,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
}
|
||||
|
||||
if (finish == 1 && !requireSucess) {
|
||||
message = "烘箱完成反馈LMS...";
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "开始烘箱完成反馈lms~");
|
||||
//烘箱完成反馈LMS
|
||||
apply_finish();
|
||||
@@ -358,8 +362,10 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
|
||||
if (applyLabelingAndBindingResponse.getstatus() == 200) {
|
||||
requireSucess = true;
|
||||
message = "烘箱完成反馈LMS成功...";
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse));
|
||||
} else {
|
||||
message = "烘箱完成反馈LMS失败,"+String.valueOf(applyLabelingAndBindingResponse);
|
||||
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse));
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -118,6 +118,10 @@ public class ItemProtocol {
|
||||
return this.getOpcFloatValue(item_currentC);
|
||||
} ;
|
||||
|
||||
public int getItem_to_temperature(){
|
||||
return this.getOpcIntegerValue(item_to_temperature);
|
||||
} ;
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
|
||||
@@ -232,7 +232,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min());
|
||||
jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec());
|
||||
//温度需要除以10
|
||||
jo.put("temperature", hongXiangConveyorDeviceDriver.getTemperature()/10);
|
||||
jo.put("temperature", hongXiangConveyorDeviceDriver.getTo_temperature()/10);
|
||||
jo.put("now_temperature", hongXiangConveyorDeviceDriver.getTemperature()/10);
|
||||
|
||||
jo.put("door", hongXiangConveyorDeviceDriver.getDoor());
|
||||
jo.put("finish", hongXiangConveyorDeviceDriver.getFinish());
|
||||
jo.put("task", hongXiangConveyorDeviceDriver.getTask());
|
||||
|
||||
@@ -83,7 +83,7 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
|
||||
}
|
||||
}
|
||||
|
||||
Thread.sleep(10000L);
|
||||
// Thread.sleep(10000L);
|
||||
log.info("设备执行线程开始...");
|
||||
|
||||
while (true) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -34,7 +35,12 @@ public class DeviceManageServiceImpl implements DeviceManageService {
|
||||
String opc_plc_id = json.getString("opc_plc_id");
|
||||
if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) {
|
||||
//OPC表【acs_opc】
|
||||
String opc_code = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0).getString("opc_code");
|
||||
JSONObject rb = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0);
|
||||
if(ObjectUtil.isEmpty(rb)){
|
||||
System.out.println(device.getDevice_code());
|
||||
continue;
|
||||
}
|
||||
String opc_code= rb.getString("opc_code");
|
||||
device.setOpc_server_code(opc_code);
|
||||
if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
|
||||
{
|
||||
|
||||
@@ -61,7 +61,11 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
while (true) {
|
||||
try {
|
||||
Server server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
|
||||
Group group = server.addGroup();
|
||||
// Group group = server.addGroup(this.OpcServer.getOpc_host());
|
||||
Group group = server.addGroup(this.OpcServer.getOpc_code());
|
||||
if(ObjectUtil.isEmpty(group)){
|
||||
log.info("group is null ");
|
||||
}
|
||||
List<String> itemsString = new ArrayList();
|
||||
Iterator it = this.protocols.iterator();
|
||||
|
||||
@@ -110,11 +114,18 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
label97:
|
||||
while (true) {
|
||||
long begin = System.currentTimeMillis();
|
||||
Map<Item, ItemState> itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||
Map<Item, ItemState> itemStatus = null;
|
||||
try {
|
||||
itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||
} catch (Exception e){
|
||||
// System.out.println("数据同步异常:"+itemsMap);
|
||||
e.printStackTrace();
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
log.trace("{} 开始记时{}", tag, DateUtil.now());
|
||||
long duration = end - begin;
|
||||
log.trace("{} 读取耗时:{}", tag, duration);
|
||||
System.out.println("线程:"+tag + " 读取耗时:"+ duration);
|
||||
if (duration > 1000L) {
|
||||
if (!time_out) {
|
||||
log.warn("{} 读取超时 : {}", tag, duration);
|
||||
@@ -125,6 +136,8 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
time_out = false;
|
||||
}
|
||||
|
||||
if(ObjectUtil.isEmpty(itemStatus)) continue label97;
|
||||
|
||||
Set<Item> items = itemStatus.keySet();
|
||||
Iterator var18 = items.iterator();
|
||||
|
||||
@@ -151,7 +164,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
ItemState itemState = (ItemState) itemStatus.get(item);
|
||||
value = OpcUtl.getValue(item, itemState);
|
||||
his = accessor_value.getValue(item.getId());
|
||||
if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
||||
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
||||
log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality());
|
||||
}
|
||||
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
|
||||
@@ -178,7 +191,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
}
|
||||
}
|
||||
} catch (Exception var30) {
|
||||
String error_message = "设备信息同步异常";
|
||||
String error_message = "设备信息同步异常,"+var30;
|
||||
if (!StrUtil.equals(this.message, error_message)) {
|
||||
log.warn("", var30);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package org.nl.acs.opc;
|
||||
|
||||
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ObjectUtl {
|
||||
private ObjectUtl() {
|
||||
}
|
||||
|
||||
public static boolean isEquals(Object a, Object b) {
|
||||
if (a == null && b == null) {
|
||||
return true;
|
||||
} else if (a != null && b != null) {
|
||||
if (a.getClass().isArray()) {
|
||||
if (a instanceof boolean[]) {
|
||||
return Arrays.equals((boolean[]) ((boolean[]) a), (boolean[]) ((boolean[]) b));
|
||||
} else if (a instanceof byte[]) {
|
||||
return Arrays.equals((byte[]) ((byte[]) a), (byte[]) ((byte[]) b));
|
||||
} else if (a instanceof int[]) {
|
||||
return Arrays.equals((int[]) ((int[]) a), (int[]) ((int[]) b));
|
||||
} else if (a instanceof long[]) {
|
||||
return Arrays.equals((long[]) ((long[]) a), (long[]) ((long[]) b));
|
||||
} else if (a instanceof double[]) {
|
||||
return Arrays.equals((double[]) ((double[]) a), (double[]) ((double[]) b));
|
||||
} else if (a instanceof short[]) {
|
||||
return Arrays.equals((short[]) ((short[]) a), (short[]) ((short[]) b));
|
||||
} else if (a instanceof char[]) {
|
||||
return Arrays.equals((char[]) ((char[]) a), (char[]) ((char[]) b));
|
||||
} else if (a instanceof float[]) {
|
||||
return Arrays.equals((float[]) ((float[]) a), (float[]) ((float[]) b));
|
||||
} else if (a instanceof Object[]) {
|
||||
return Arrays.equals((Object[]) ((Object[]) a), (Object[]) ((Object[]) b));
|
||||
} else {
|
||||
throw new WDKException("未实现");
|
||||
}
|
||||
} else {
|
||||
return Objects.equals(a, b);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isTrue(Boolean boolean_) {
|
||||
return boolean_ != null && isEquals(boolean_, true);
|
||||
}
|
||||
|
||||
public static boolean isTrue(Boolean targetBoolean, boolean defaultBoolean) {
|
||||
return targetBoolean == null ? defaultBoolean : targetBoolean;
|
||||
}
|
||||
|
||||
public static boolean isFalse(Boolean boolean_) {
|
||||
return boolean_ != null && isEquals(boolean_, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static boolean isObject(Class<?> clazz) {
|
||||
if (clazz == null) {
|
||||
return false;
|
||||
} else if (clazz.getClass().isArray()) {
|
||||
return false;
|
||||
} else {
|
||||
return Object.class.isAssignableFrom(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class opcServerManageServiceImpl implements OpcServerManageService {
|
||||
public List<OpcServerManageDto> queryAll() {
|
||||
//return this.opcServerRepository.queryAll(OpcServerManageDto.class);
|
||||
//OPC表【acs_opc】
|
||||
JSONArray arr = WQLObject.getWQLObject("acs_opc").query().getResultJSONArray(0);
|
||||
JSONArray arr = WQLObject.getWQLObject("acs_opc").query("is_active='1' and is_delete='0'").getResultJSONArray(0);
|
||||
|
||||
return arr.toJavaList(OpcServerManageDto.class);
|
||||
}
|
||||
|
||||
@@ -45,9 +45,6 @@
|
||||
<el-form-item label="值">
|
||||
<el-input v-model="form.value" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="操作" prop="description">-->
|
||||
<!-- <el-input v-model="form.remark" style="width: 380px;" rows="5" type="textarea" />-->
|
||||
<!-- </el-form-item>-->
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
@@ -74,22 +71,27 @@
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-dropdown trigger="click" @command="handleCommand">
|
||||
<span class="el-dropdown-link">
|
||||
<i class="el-icon-menu" />
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'a')">完成</el-dropdown-item>
|
||||
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'b')">取消</el-dropdown-item>
|
||||
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'c')">强制取消</el-dropdown-item>
|
||||
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'d')">初始化</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<el-button slot="right" size="mini" style="margin-left: -1px;margin-right: 2px" type="text" @click="dialogFormVisible = true">
|
||||
查询历史
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<!--弹窗设置设备与图标绑定与角度-->
|
||||
<el-dialog title="历史" :visible.sync="dialogFormVisible" width="35%">
|
||||
<el-form :model="form" size="small">
|
||||
<el-form-item label="unified_key" prop="unified_key" label-width="100px">
|
||||
<el-input v-model="form.unified_key" :disabled="true" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="code" prop="key" label-width="100px">
|
||||
<el-input v-model="form.key" :disabled="true" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -102,7 +104,7 @@ import crudOperation from '@crud/CRUD.operation'
|
||||
import { getDicts } from '@/api/system/dict'
|
||||
|
||||
const defaultForm = {
|
||||
unified_key: 'opc_value',
|
||||
unified_key: '',
|
||||
key: null,
|
||||
value: null,
|
||||
last_modify_date: null
|
||||
@@ -142,7 +144,14 @@ export default {
|
||||
],
|
||||
permission: {
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
rules: {
|
||||
},
|
||||
form: {
|
||||
unified_key: 'opc_value',
|
||||
key: null,
|
||||
value: null,
|
||||
last_modify_date: null
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -155,26 +164,7 @@ export default {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
// https://www.cnblogs.com/jdWu-d/p/11898666.html
|
||||
beforeHandleCommand(index, row, command) {
|
||||
return {
|
||||
'index': index,
|
||||
'row': row,
|
||||
'command': command
|
||||
}
|
||||
},
|
||||
handleCommand(command) {
|
||||
switch (command.command) {
|
||||
case 'a':// 完成
|
||||
this.finish(command.index, command.row)
|
||||
break
|
||||
case 'b':// 取消
|
||||
this.cancel(command.index, command.row)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user