add 项目更新

This commit is contained in:
zhoujj
2025-01-07 13:36:16 +08:00
parent 4f6218e6c5
commit d3788b219b
20 changed files with 998 additions and 361 deletions

View File

@@ -29,6 +29,8 @@ import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
@@ -36,10 +38,7 @@ 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;
import java.util.*;
/**
* 检测站点驱动
@@ -147,7 +146,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
if (mode != last_mode) {
// this.setRequireSucess(false);
this.setRequireSucess(false);
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + " -> " + mode);
}
@@ -282,14 +281,9 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
if (result.getStatus() == HttpStatus.OK.value()) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
Boolean isPackage = jsonObject.getBoolean("data");
if (isPackage == null) {
this.writing(24);
} else {
// this.writing(isPackage ? 22 : 23);
//全部都是优先出窑
this.writing(22);
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command",5);
this.writing(map);
this.setRequireSucess(true);
}
}
@@ -298,7 +292,44 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
}
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server, 0);
server.disconnect();

View File

@@ -1,87 +1,293 @@
package org.nl.acs.device_driver.driver;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.jinterop.dcom.common.JIException;
import org.nl.acs.ext.wms.data.JsonUtl;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.ItemValue;
import org.nl.acs.opc.OpcConfig;
import org.nl.acs.opc.OpcServerService;
import org.nl.acs.opc.OpcServerServiceImpl;
import org.nl.acs.opc.*;
import org.nl.acs.udw.UnifiedDataAccessor;
import org.nl.acs.udw.UnifiedDataAccessorFactory;
import org.nl.acs.udw.UnifiedDataAppService;
import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.wql.exception.WDKException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.AddFailedException;
import org.openscada.opc.lib.da.Group;
import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.ItemState;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.*;
@Slf4j
public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver {
UnifiedDataAccessor opcUdw;
@Autowired
private OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService .class);
public AbstractOpcDeviceDriver() {
this.opcUdw = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
}
private Date sendTime;
private String last_items;
private int noLog_sendTimeOut;
private Date noLog_sendTime;
private String noLog_last_items;
@Override
public UnifiedDataAccessor getOpcValueAccessor() {
return this.opcUdw;
}
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
public void checkcontrol(Map<String, Object> itemValues) throws JIException, AddFailedException {
Group group = opcServerService.getServer(this.getOpcServer());
Map<String, Object> write = new HashMap();
Map<String, Item> readitems = new LinkedHashMap();
List<String> itemsString = new ArrayList();
itemsString = new ArrayList<> (itemValues.keySet());
Iterator is = itemsString.iterator();
while (is.hasNext()) {
String string = (String) is.next();
try {
readitems.put(string, group.addItem(string));
} catch (Exception e) {
e.printStackTrace();
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
this.control(itemMap);
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
int i = 0;
while(true) {
//下发信号
try{
if(i == 0){
control( itemValues);
} else {
controlByNewConn( itemValues);
}
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
} catch (Exception e){
e.printStackTrace();
}
Map<String, Object> read = new HashMap();
Map<Item, ItemState> itemStatus = null;
boolean check = true;
try{
if(i>0){
group = opcServerService.getServer(this.getOpcServer());
itemsString = new ArrayList<> (itemValues.keySet());
Iterator nis = itemsString.iterator();
while (nis.hasNext()) {
String string = (String) nis.next();
try {
readitems.put(string, group.addItem(string));
} catch (Exception e) {
e.printStackTrace();
}
}
itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0]));
} else {
itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0]));
}
Set<Item> items = itemStatus.keySet();
Iterator var15 = items.iterator();
while(var15.hasNext()) {
Item item = (Item)var15.next();
ItemState itemState = (ItemState)itemStatus.get(item);
Object value = OpcUtl.getValue(item, itemState);
read.put(item.getId(), value);
}
public void control(Map<String, Object> itemValues) {
Iterator var24 = itemsString.iterator();
while(var24.hasNext()) {
String itemString = (String)var24.next();
if (!ObjectUtl.isEquals(String.valueOf(itemValues.get(itemString)), String.valueOf(read.get(itemString)))) {
check = false;
}
}
} catch (Exception e){
e.printStackTrace();
check = false;
}
if (check) {
return;
}
if (i > 0) {
ThreadUtl.sleep(300L);
}
if (i > 3) {
log.info("写入次数超过3次而失败");
throw new WDKException("写入次数超过3次而失败");
}
++i;
}
}
public boolean controlByNewConn(Map<String, Object> itemValues) {
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
ItemValue[] p2;
ItemValue p2[];
p2 = new ItemValue[itemValues.size()];
int i = 0;
int i=0;
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue());
System.out.println("即将写入值:"+entry.getKey() + ":" + entry.getValue());
p2[i] = new ItemValue();
p2[i].setItem_code(entry.getKey());
p2[i].setItem_value(entry.getValue());
i++;
}
this.control(p2);
return this.controlByNewConn(p2);
}
public void control(ItemValue[] itemValues) {
public boolean controlByNewConn(ItemValue[] itemValues) {
if (itemValues != null && itemValues.length != 0) {
String this_items = JsonUtl.parseWithoutException(itemValues);
boolean need_write = false;
StringBuilder sb = new StringBuilder();
ItemValue[] var5 = itemValues;
int var6 = itemValues.length;
// for (int var7 = 0; var7 < var6; ++var7) {
// ItemValue itemValue = var5[var7];
// String code = itemValue.getItem_code();
// Object udw_value = this.getUdwValue(code);
// Object write_value = itemValue.getItem_value();
// sb.append(code);
// sb.append(":");
// sb.append(JsonUtl.parseWithoutException(udw_value));
// sb.append(";");
// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
// need_write = true;
// } else {
// log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
// }
// }
need_write = true;
if (need_write) {
Date date = new Date();
/*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) {
log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check);
return false;
}*/
this.last_items = this_items;
this.sendTime = date;
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
opcServerService.writeIntegerByNewConn(this.getOpcServer(), itemValues);
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
ItemValue[] var17 = itemValues;
int var18 = itemValues.length;
for (int var19 = 0; var19 < var18; ++var19) {
ItemValue itemValue = var17[var19];
String code = itemValue.getItem_code();
Object value = itemValue.getItem_value();
opcValueAccessor.setValue(code, value);
}
}
return true;
} else {
throw new WDKException("下发 无内容");
}
}
public boolean control(Map<String, Object> itemValues) {
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
ItemValue p2[];
p2 = new ItemValue[itemValues.size()];
int i=0;
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
System.out.println("即将写入值:"+entry.getKey() + ":" + entry.getValue());
p2[i] = new ItemValue();
p2[i].setItem_code(entry.getKey());
p2[i].setItem_value(entry.getValue());
i++;
}
return this.control(p2);
}
public boolean control(ItemValue[] itemValues) {
if (itemValues != null && itemValues.length != 0) {
String this_items = JsonUtl.parseWithoutException(itemValues);
boolean need_write = false;
StringBuilder sb = new StringBuilder();
ItemValue[] var5 = itemValues;
int var6 = itemValues.length;
for (int var7 = 0; var7 < var6; ++var7) {
ItemValue itemValue = var5[var7];
String code = itemValue.getItem_code();
Object udw_value = this.getUdwValue(code);
Object write_value = itemValue.getItem_value();
sb.append(code);
sb.append(":");
sb.append(JsonUtl.parseWithoutException(udw_value));
sb.append(";");
if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) {
need_write = true;
} else {
//log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value );
}
}
// need_write = true;
if (need_write) {
Date date = new Date();
/*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) {
log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check);
return false;
}*/
this.last_items = this_items;
this.sendTime = date;
/* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName());
this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items});
OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
opcServerService.writeInteger(this.getOpcServer(), itemValues);
UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor();
ItemValue[] var17 = itemValues;
int var18 = itemValues.length;
for (ItemValue itemValue : itemValues) {
for (int var19 = 0; var19 < var18; ++var19) {
ItemValue itemValue = var17[var19];
String code = itemValue.getItem_code();
Object value = itemValue.getItem_value();
opcValueAccessor.setValue(code, value);
}
}
return true;
} else {
throw new WDKException("下发 无内容");
}

View File

@@ -28,7 +28,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* 晟华出窑桁架
* 晟华出窑桁架
*/
@Slf4j
@Getter

View File

@@ -24,16 +24,15 @@ import org.nl.acs.order.service.ProduceshiftorderService;
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
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.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 晟华混碾机
@@ -316,6 +315,44 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen
server.disconnect();
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void writing(int type, int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()

View File

@@ -21,14 +21,13 @@ import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
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.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 晟华出窑桁架
@@ -275,17 +274,60 @@ public class LnshOutKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implem
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
// this.writing(isPackage ? 22 : 23);
//全部都是优先出窑
this.writing(22);
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command",22);
this.writing(map);
this.setRequireSucess(true);
}
}else{
this.writing(24);
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command",24);
this.writing(map);
this.setRequireSucess(true);
}
}
return true;
}
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void writing(int command) {

View File

@@ -24,6 +24,8 @@ import org.nl.acs.order.service.ProduceshiftorderService;
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
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.beans.factory.annotation.Autowired;
@@ -676,6 +678,44 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
}
return flag;
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void writing(int feedback) {
String to_feedback = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()

View File

@@ -1,5 +1,6 @@
package org.nl.acs.device_driver.lnsh.lnsh_package_site;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -19,13 +20,12 @@ import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
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 java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 晟华-包装线工位
@@ -209,7 +209,44 @@ public class LnshPackageSiteDeviceDriver extends AbstractOpcDeviceDriver impleme
last_to_vehicle_code = to_vehicle_code;
last_to_vehicle_type = to_vehicle_type;
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()

View File

@@ -25,15 +25,14 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.order.service.ProduceshiftorderService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.lucene.service.impl.LuceneExecuteLogServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.http.HttpStatus;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 晟华-码垛机械手工位
@@ -1504,6 +1503,44 @@ public class LnshPalletizingManipulatorSiteDeviceDriver extends AbstractOpcDevic
}
}
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void writing(String param, String value) {

View File

@@ -24,16 +24,15 @@ import org.nl.acs.order.service.ProduceshiftorderService;
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
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.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 晟华压力机
@@ -376,6 +375,44 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
server.disconnect();
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void writing(String param, String value) {

View File

@@ -21,6 +21,8 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.Device;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
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.beans.factory.annotation.Autowired;
@@ -961,6 +963,44 @@ public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver im
return true;
}
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public boolean exe_business() {
return true;

View File

@@ -28,6 +28,8 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder;
@@ -35,10 +37,7 @@ 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;
import java.util.*;
/**
* 晟华-工位(交互模板)
@@ -578,7 +577,10 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
if (response.getStatus() == HttpStatus.OK.value()) {
JSONObject jsonObject = JSONObject.parseObject(response.body());
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
this.writing(this.mode);
Map<String, Object> map = new LinkedHashMap<>();
log.info("反向组盘成功条码为{}",barcode);
map.put("to_command",17);
this.writing(map);
this.setRequireSucess(true);
}
}
@@ -634,6 +636,44 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements
}
}
}
/**
* 多个信号一起下发电气
*
* @param map
*/
public void writing(Map<String, Object> map) {
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
Map<String, Object> itemMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (ObjectUtil.isNotEmpty(value)) {
itemMap.put(getToParam() + key, value);
}
});
if (ObjectUtil.isNotEmpty(itemMap)) {
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
}
}
/**
* 抽取统一下发电气信号前缀
*
* @return
*/
public String getToParam() {
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
}
public void writing(String param, String value) {

View File

@@ -12,11 +12,14 @@ public interface OpcServerService {
void reload();
Group getServer(String var1) throws Exception;
Group getServer(String var1);
Group getServerByNewConn(String var1);
void writeInteger(String var1, ItemValue... var2);
void clearServer(String var1);
void writeIntegerByNewConn(String var1, ItemValue... var2);
void clearServer(String var1);
void cleanGroups(String var1);
}

View File

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
@@ -26,22 +27,24 @@ import java.util.Map;
public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoInitial {
private static final Logger log = LoggerFactory.getLogger(OpcServerServiceImpl.class);
@Autowired
OpcServerManageService opcServerManageService;
Map<String, OpcServerManageDto> opcServerManageDtos = new HashMap<>();
Map<String, Server> servers = Collections.synchronizedMap(new HashMap<>());
Map<String, Group> groups = Collections.synchronizedMap(new HashMap<>());
@Autowired OpcServerManageService opcServerManageService;
Map<String, OpcServerManageDto> opcServerManageDtos = new HashMap();
Map<String, Server> servers = Collections.synchronizedMap(new HashMap());
Map<String, Group> groups = Collections.synchronizedMap(new HashMap());
public OpcServerServiceImpl() {
}
public OpcServerServiceImpl() {}
public void autoInitial() throws Exception {
this.reload();
if (OpcConfig.auto_start_opc) {
Thread t =
new Thread(() -> {
new Thread() {
public void run() {
Iterator var1 = OpcServerServiceImpl.this.opcServerManageDtos.values().iterator();
while (var1.hasNext()) {
OpcServerManageDto dto = (OpcServerManageDto) var1.next();
for (OpcServerManageDto dto : OpcServerServiceImpl.this.opcServerManageDtos.values()) {
try {
OpcServerServiceImpl.this.getServer(dto.getOpc_code());
OpcServerServiceImpl.log.info("加载opc server {}", dto.getOpc_code());
@@ -49,7 +52,8 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
OpcServerServiceImpl.log.warn("启动无法载入servers", var4);
}
}
});
}
};
t.start();
}
}
@@ -59,31 +63,12 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos);
}
public void cleanGroups(String opcCode) {
Group group = this.groups.get(opcCode);
public Group getServer(String code) {
synchronized(this.buildLock(code)) {
Group group = null;
group = (Group)this.groups.get(code);
if (group != null) {
Server server = group.getServer();
try {
group.remove();
} catch (JIException var5) {
log.error("error !", var5);
}
this.groups.remove(opcCode);
server.disconnect();
this.servers.remove(opcCode);
}
}
public Group getServer(String code) throws Exception {
synchronized (this.buildLock(code)) {
Group group;
group = this.groups.get(code);
if (group != null) {
label68:
{
label68: {
Group var10000;
try {
if (!group.isActive()) {
@@ -100,44 +85,45 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
}
}
Server server = this.servers.get(code);
Server server = (Server)this.servers.get(code);
boolean needcreate = false;
String groupName = code;
if (server == null) {
needcreate = true;
} else {
try {
group = server.findGroup(code);
} catch (UnknownHostException | JIException | UnknownGroupException | NotConnectedException |
IllegalArgumentException var13) {
group = server.findGroup(groupName);
} catch (UnknownHostException | JIException | UnknownGroupException | NotConnectedException | IllegalArgumentException var13) {
log.error(code, var13);
needcreate = true;
}
}
if (needcreate) {
OpcServerManageDto dto = this.opcServerManageDtos.get(code);
OpcServerManageDto dto = (OpcServerManageDto)this.opcServerManageDtos.get(code);
if (dto == null) {
throw new BadRequestException(code + "{} 不存在");
throw new RuntimeException(code+"不存在");
}
// if (server!=null){
// server.disconnect();
// server=null;
// }
if (server == null) {
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
}
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain())); }
try {
assert server != null;
group = server.addGroup(code);
group = server.addGroup(groupName);
} catch (Exception var12) {
this.clearServer(code);
ThreadUtl.sleep(5000L);
log.warn("获取opc出错重新获取 {}", code, var12);
ThreadUtl.sleep(1000L);
log.warn("获取opc出错重新获取", code, var12);
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
try {
assert server != null;
group = server.addGroup(code);
group = server.addGroup(groupName);
} catch (Exception var11) {
log.error("error !", var11);
throw new RuntimeException(var12);
}
}
@@ -149,12 +135,51 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
}
}
public void clearServer(String code) {
synchronized (this.buildLock(code)) {
public Group getServerByNewConn(String code) {
synchronized(this.buildLock(code)) {
Server server = (Server)this.servers.get(code);
if (server!=null){
this.clearServer(code);
}
OpcServerManageDto dto = (OpcServerManageDto)this.opcServerManageDtos.get(code);
if (dto == null) {
throw new RuntimeException(code+"不存在");
}
// if (server == null) {
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
// }
String groupName = code;
Group group = null;
try {
Server server = this.servers.get(code);
group = server.addGroup(groupName);
} catch (Exception var12) {
this.clearServer(code);
ThreadUtl.sleep(1000L);
log.warn("获取opc出错重新获取", code, var12);
server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain()));
try {
group = server.addGroup(groupName);
} catch (Exception var11) {
throw new RuntimeException(var12);
}
}
this.servers.put(code, server);
this.groups.put(code, group);
return group;
}
}
public void clearServer(String code) {
synchronized(this.buildLock(code)) {
try {
Server server = (Server)this.servers.get(code);
server.disconnect();
} catch (Exception ignored) {
} catch (Exception var5) {
}
this.servers.remove(code);
@@ -162,6 +187,23 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
}
}
public void cleanGroups(String opcCode) {
Group group = (Group)this.groups.get(opcCode);
if (group != null) {
Server server = group.getServer();
try {
group.remove();
} catch (JIException var5) {
var5.printStackTrace();
}
this.groups.remove(opcCode);
server.disconnect();
this.servers.remove(opcCode);
}
}
public void writeInteger(String code, ItemValue... values) {
try {
@@ -169,9 +211,21 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
OpcUtl.writeValue(group, values);
} catch (Exception var4) {
this.clearServer(code);
log.warn("写入出错opc server {} 重新加载", code, var4);
ThreadUtl.sleep(5000L);
// throw var4;
log.info("写入出错opc server {} 重新加载", code, var4);
ThreadUtl.sleep(1000L);
throw var4;
}
}
public void writeIntegerByNewConn(String code, ItemValue... values) {
try {
Group group = this.getServerByNewConn(code);
OpcUtl.writeValue(group, values);
} catch (Exception var4) {
this.clearServer(code);
log.info("写入出错opc server {} 重新加载", code, var4);
ThreadUtl.sleep(1000L);
throw var4;
}
}
@@ -179,8 +233,10 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
if (StrUtil.isEmpty(key)) {
key = "";
}
String builder = "OpcServerService." +
key;
return builder.intern();
StringBuilder builder = new StringBuilder();
builder.append("OpcServerService.");
builder.append(key);
String lock = builder.toString().intern();
return lock;
}
}

View File

@@ -6,12 +6,13 @@ import org.openscada.opc.lib.da.Server;
public class OpcServerUtl {
public static synchronized Server getServerWithOutException(String host, String clsid, String user, String password,
String domain) throws Exception {
String domain) {
if (!StrUtil.isEmpty(host) && !StrUtil.isEmpty(clsid) && !StrUtil.isEmpty(user)) {
if (domain == null) {
domain = "";
}
return OpcUtl.getServer(host, clsid, user, password, domain);
// return OpcUtl.getAutoServer(host, clsid, user, password, domain);
} else {
return null;
}

View File

@@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import cn.hutool.core.util.NumberUtil;
import lombok.extern.slf4j.Slf4j;
import org.jinterop.dcom.common.JIException;
import org.jinterop.dcom.core.IJIUnsigned;
@@ -17,6 +18,8 @@ import org.jinterop.dcom.core.JIString;
import org.jinterop.dcom.core.JIUnsignedByte;
import org.jinterop.dcom.core.JIUnsignedShort;
import org.jinterop.dcom.core.JIVariant;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.exception.WDKException;
import org.openscada.opc.dcom.list.ClassDetails;
import org.openscada.opc.lib.common.AlreadyConnectedException;
import org.openscada.opc.lib.common.ConnectionInformation;
@@ -35,181 +38,32 @@ import org.slf4j.LoggerFactory;
@Slf4j
public class OpcUtl {
private static int timeout = 180000;
private static int timeout = 1*60*1000;
private static String key = "rpc.socketTimeout";
static {
checkTimeout();
}
public static void checkTimeout() {
if (Integer.getInteger(key, 0) != timeout) {
if (Integer.getInteger(key, 0).intValue() != timeout) {
System.setProperty(key, String.valueOf(timeout));
}
}
private OpcUtl() {
}
public static List<Map<String, String>> showAllOpcServer(String host, String user, String password, String domain) throws Exception {
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
try {
List<Map<String, String>> listResult = new ArrayList();
ServerList serverList = new ServerList(host, user, password, domain);
Collection<ClassDetails> classDetails = serverList.listServersWithDetails(new Category[]{Categories.OPCDAServer10, Categories.OPCDAServer20, Categories.OPCDAServer30}, new Category[0]);
Iterator var7 = classDetails.iterator();
while(var7.hasNext()) {
ClassDetails details = (ClassDetails)var7.next();
Map<String, String> result = new LinkedHashMap();
result.put("classId", details.getClsId());
result.put("progId", details.getProgId());
result.put("description", details.getDescription());
listResult.add(result);
}
return listResult;
} catch (UnknownHostException | JIException | IllegalArgumentException var10) {
throw new Exception(var10);
}
}
public static Server getServer(String host, String clsid, String user, String password, String domain) throws Exception {
checkTimeout();
Server server = null;
try {
server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor());
server.connect();
return server;
} catch (UnknownHostException | JIException | AlreadyConnectedException | IllegalArgumentException var7) {
throw new Exception(var7);
}
}
public static Server getAutoServer(String host, String clsid, String user, String password, String domain) throws Exception {
checkTimeout();
Server server = null;
server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor());
AutoReconnectController autoReconnectController = new AutoReconnectController(server);
autoReconnectController.connect();
return server;
}
public static ConnectionInformation getConnection(String host, String clsid, String user, String password, String domain) {
ConnectionInformation connection = new ConnectionInformation();
connection.setHost(host);
connection.setClsid(clsid);
connection.setUser(user);
connection.setPassword(password);
connection.setDomain(domain);
return connection;
}
public static Object getValue(Item item, ItemState itemState) throws Exception {
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD)) {
if (item != null) {
log.debug("value is not good {} : {}", item.getId(), itemState.getQuality());
} else {
log.debug("value is not good {}", itemState.getQuality());
}
return null;
} else {
JIVariant value = itemState.getValue();
return getValue(value, item.getId());
}
}
public static int getIntegerValue(Item item, ItemState itemState) throws Exception {
return (Integer)getValue(item, itemState);
}
public static String getStringValue(Item item, ItemState itemState) throws Exception {
return (String)getValue(item, itemState);
}
public static byte[] getByteArrayValue(Item item, ItemState itemState) throws Exception {
return (byte[])((byte[])getValue(item, itemState));
}
public static Object getValue(JIVariant jiVariant, String id) {
try {
Object object = jiVariant.getObject();
if (object instanceof IJIUnsigned) {
return ((IJIUnsigned)object).getValue().intValue();
} else if (object instanceof Boolean) {
return jiVariant.getObjectAsBoolean() ? 1 : 0;
} else if (object instanceof JIString) {
return ((JIString)object).getString();
} else if (!(object instanceof JIArray)) {
if (object instanceof Integer) {
return jiVariant.getObject();
} else if (object instanceof Short) {
return jiVariant.getObject();
} else if (object instanceof Float) {
return jiVariant.getObject();
} else {
System.err.println(id + "不明类型" + object.getClass());
if (jiVariant.getType() == 0) {
System.err.println("因类型为emtpy 返回 null");
return null;
} else if (jiVariant.getType() == 1) {
System.err.println("因类型为null 返回 null");
return null;
} else {
return jiVariant.getObject();
}
}
} else {
Class<?> clazz = ((JIArray)object).getArrayClass();
int[] r;
int i;
if (JIUnsignedByte.class.isAssignableFrom(clazz)) {
JIUnsignedByte[] array = (JIUnsignedByte[])((JIUnsignedByte[])((JIArray)object).getArrayInstance());
r = new int[array.length];
for(i = 0; i < array.length; ++i) {
r[i] = array[i].getValue().byteValue();
}
return r;
} else if (!JIUnsignedShort.class.isAssignableFrom(clazz)) {
System.err.println(id + "不明类型");
if (jiVariant.getType() == 0) {
System.err.println("因类型为emtpy 返回 null");
return null;
} else if (jiVariant.getType() == 1) {
System.err.println("因类型为null 返回 null");
return null;
} else {
return ((JIArray)object).getArrayInstance();
}
} else {
JIUnsignedShort[] array = (JIUnsignedShort[])((JIUnsignedShort[])((JIArray)object).getArrayInstance());
r = new int[array.length];
for(i = 0; i < array.length; ++i) {
r[i] = array[i].getValue().intValue();
}
return r;
}
}
} catch (JIException var7) {
// throw new Exception(var7);
var7.printStackTrace();
}
return null;
}
public static void writeValue(Group group, WriteRequest... requests) throws Exception {
try {
Map<Item, Integer> write = group.write(requests);
Map<Item, Integer> e=group.write(requests);
boolean is_success = true;
StringBuilder message = new StringBuilder();
Iterator var5 = write.keySet().iterator();
Iterator arg4 = e.keySet().iterator();
while(var5.hasNext()) {
Item item = (Item)var5.next();
Integer integer = (Integer)write.get(item);
if (integer != 0) {
while (arg4.hasNext()) {
Item item = (Item) arg4.next();
Integer integer = (Integer) e.get(item);
if (integer.intValue() != 0) {
if (is_success) {
is_success = false;
}
@@ -222,14 +76,16 @@ public class OpcUtl {
}
if (!is_success) {
throw new Exception(message.toString());
log.info("下发信号失败:"+message.toString());
throw new WDKException(message.toString());
}
} catch (JIException var8) {
throw new Exception(var8);
} catch (JIException arg7) {
log.info("下发信号失败Exception"+arg7.getMessage());
throw new WDKException("下发信号失败Exception:"+arg7);
}
}
public static void writeValue(Group group, ItemValue... values) throws Exception {
public static void writeValue(Group group, ItemValue... values) throws WDKException {
try {
if (values != null && values.length > 0) {
List<WriteRequest> ws = new ArrayList();
@@ -241,16 +97,15 @@ public class OpcUtl {
Item item = group.addItem(value.getItem_code());
ws.add(new WriteRequest(item, getVariant(value.getItem_value())));
}
writeValue(group, (WriteRequest[])ws.toArray(new WriteRequest[0]));
}
} catch (AddFailedException | JIException var8) {
throw new Exception(var8);
throw new WDKException(var8);
}
}
public static JIVariant getVariant(Object object) throws Exception {
public static JIVariant getVariant(Object object) {
if (object instanceof Integer) {
return getIntegerVariant((Integer)object);
} else if (object instanceof String) {
@@ -270,10 +125,132 @@ public class OpcUtl {
} else if (object instanceof JIVariant) {
return (JIVariant)object;
} else {
throw new Exception("未实现目前支持是int,string,byte[]");
throw new WDKException("未实现目前支持是int,string,byte[]");
}
}
public static Object getValue(Item item, ItemState itemState) throws BadRequestException {
if (NumberUtil.compare(itemState.getQuality(), Short.valueOf(QualityTypeValue.OPC_QUALITY_GOOD)) != 0) {
if (item != null) {
log.debug("value is not good {} : {}", item.getId(), itemState.getQuality());
// throw new WDKException("值不健康进行重连!");
} else {
log.debug("value is not good {}", itemState.getQuality());
}
return null;
} else {
JIVariant value = itemState.getValue();
return getValue(value, item.getId());
}
}
public static Object getValue(JIVariant jiVariant, String id) throws BadRequestException {
try {
Object e = jiVariant.getObject();
if (e instanceof IJIUnsigned) {
return Integer.valueOf(((IJIUnsigned) e).getValue().intValue());
} else if (e instanceof Boolean) {
return jiVariant.getObjectAsBoolean() ? Integer.valueOf(1) : Integer.valueOf(0);
} else if (e instanceof JIString) {
return ((JIString) e).getString();
} else if (!(e instanceof JIArray)) {
if (e instanceof Integer) {
return jiVariant.getObject();
} else if (e instanceof Short) {
return jiVariant.getObject();
} else if (e instanceof Float) {
return jiVariant.getObject();
} else {
System.err.println(id + "不明类型" + e.getClass());
if (jiVariant.getType() == 0) {
System.err.println("因类型为emtpy 返回 null");
return null;
} else if (jiVariant.getType() == 1) {
System.err.println("因类型为null 返回 null");
return null;
} else {
return jiVariant.getObject();
}
}
} else {
Class clazz = ((JIArray) e).getArrayClass();
int[] r;
int i;
if (JIUnsignedByte.class.isAssignableFrom(clazz)) {
JIUnsignedByte[] arg7 = (JIUnsignedByte[]) ((JIUnsignedByte[]) ((JIArray) e).getArrayInstance());
r = new int[arg7.length];
for (i = 0; i < arg7.length; ++i) {
r[i] = arg7[i].getValue().byteValue();
}
return r;
} else if (!JIUnsignedShort.class.isAssignableFrom(clazz)) {
System.err.println(id + "不明类型");
if (jiVariant.getType() == 0) {
System.err.println("因类型为emtpy 返回 null");
return null;
} else if (jiVariant.getType() == 1) {
System.err.println("因类型为null 返回 null");
return null;
} else {
return ((JIArray) e).getArrayInstance();
}
} else {
JIUnsignedShort[] array = (JIUnsignedShort[]) ((JIUnsignedShort[]) ((JIArray) e)
.getArrayInstance());
r = new int[array.length];
for (i = 0; i < array.length; ++i) {
r[i] = array[i].getValue().intValue();
}
return r;
}
}
} catch (JIException e) {
throw new BadRequestException(e.getMessage());
}
}
public static Server getServer(String host, String clsid, String user, String password, String domain)
throws WDKException {
checkTimeout();
Server server = null;
try {
server = new Server(getConnection(host, clsid, user, password, domain),
Executors.newSingleThreadScheduledExecutor());
server.connect();
return server;
} catch (Exception e) {
System.out.println("server error:"+e.getMessage());
throw new WDKException(e.getMessage());
}
}
public static Server getAutoServer(String host, String clsid, String user, String password, String domain) throws WDKException {
checkTimeout();
Server server = null;
server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor());
AutoReconnectController autoReconnectController = new AutoReconnectController(server);
autoReconnectController.connect();
return server;
}
public static ConnectionInformation getConnection(String host, String clsid, String user, String password,
String domain) {
ConnectionInformation connection = new ConnectionInformation();
connection.setHost(host);
connection.setClsid(clsid);
connection.setUser(user);
connection.setPassword(password);
connection.setDomain(domain);
return connection;
}
public static JIVariant getByteArrayVariantxx(int[] bytes) {
Integer[] byte_Data = new Integer[bytes.length];
@@ -312,8 +289,6 @@ public class OpcUtl {
return value;
}
static {
checkTimeout();
}
}

View File

@@ -792,12 +792,12 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
&& (lnshStationDeviceDriver.getIo_action() == 2 || lnshStationDeviceDriver.getIo_action() == 3)) {
inst.setExecute_status("6");
instructionService.update(inst);
while (!inst.getInstruction_code().equals(String.valueOf(lnshStationDeviceDriver.getTo_task()))) {
lnshStationDeviceDriver.writing("to_task", inst.getInstruction_code());
}
while (lnshStationDeviceDriver.getTo_command() != 3) {
lnshStationDeviceDriver.writing(3);
}
// while (!inst.getInstruction_code().equals(String.valueOf(lnshStationDeviceDriver.getTo_task()))) {
// lnshStationDeviceDriver.writing("to_task", inst.getInstruction_code());
// }
// while (lnshStationDeviceDriver.getTo_command() != 3) {
// lnshStationDeviceDriver.writing(3);
// }
data = ndcAGVService.sendAgvOneModeInst(phase, index, 0);
lnshStationDeviceDriver.setMessage("");
flag = true;

View File

@@ -67,7 +67,15 @@ public class YZCallMaterialTask extends AbstractAcsTask {
.addParam("device_code", workorder.getString("device_code"))
.process()
.uniqueResult(0);
if (ObjectUtil.isEmpty(point1)) {
point1 = WQL
.getWO("CALL_MATERIAL_TASK")
.addParam("flag", "6")
.addParam("material_id", task.getString("material_id"))
.addParam("device_code", workorder.getString("device_code"))
.process()
.uniqueResult(0);
}
if (ObjectUtil.isNotEmpty(point1)) {
point.put("lock_type", LockType.TASK_LOCKED.value());
point.put("task_code", task.getString("task_code"));
@@ -91,13 +99,13 @@ public class YZCallMaterialTask extends AbstractAcsTask {
return task.getString("task_code");
} else {
// update: 设置点位状态为等待(4)设置所需要的参数到remark中materialId
point.put("point_status", PointStatus.WAITING.value());
point.put("remark", workorder.getString("material_id"));
TaskUtils.addFormUpdateColum(point, form);
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
point_table.update(point);
return null;
// throw new BadRequestException("[" + point.get("point_code") + "] 的叫料任务未找到起点!");
// point.put("point_status", PointStatus.WAITING.value());
// point.put("remark", workorder.getString("material_id"));
// TaskUtils.addFormUpdateColum(point, form);
// WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
// point_table.update(point);
// return null;
throw new BadRequestException("[" + point.get("point_code") + "] 的叫料任务未找到起点!");
}
}

View File

@@ -101,9 +101,9 @@
p.is_used = '1'
AND p.lock_type = '1'
AND p.region_code = 'KLHJ'
AND p.point_type IN ('1', '3')
AND p.point_type = '3'
AND p.point_status = '3'
AND (p.device_code = 输入.device_code OR p.point_type = '1')
AND p.device_code = 输入.device_code
AND p.vehicle_type = '1'
AND vd.material_id = 输入.material_id
AND vd.stand_status IN ('2', '3')
@@ -156,3 +156,30 @@
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "6"
QUERY
SELECT
p.*
FROM
sch_base_point p
LEFT JOIN st_ivt_vehicle_detail vd ON p.vd_id = vd.vd_id
LEFT JOIN pdm_bd_workorder wo ON vd.workorder_id = wo.workorder_id
WHERE
p.is_used = '1'
AND p.lock_type = '1'
AND p.region_code = 'KLHJ'
AND p.point_type = '1'
AND p.point_status = '3'
AND wo.associated_device = 输入.device_code
AND p.vehicle_type = '1'
AND vd.material_id = 输入.material_id
AND vd.stand_status IN ('2', '3')
ORDER BY
wo.is_pri DESC,
vd.create_time ASC
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -137,30 +137,30 @@ public class HLSendMaterialTask extends AbstractAcsTask {
taskCode, deviceCode, object.getString("associated_device"), nextPoint);
}
}
if (ObjectUtil.isEmpty(nextPoint) || ObjectUtil.isEmpty(nextPoint.get("point_code"))) {
// 判断压机上是否有点位状态是4物料对应
flag = true;
nextPoint = WQL.getWO("SEND_MATERIAL_TASK")
.addParam("flag", "10")
.addParam("material_id", task.getString("material_id"))
.process()
.uniqueResult(0);
log.info("任务 {} 设备 {} 查找等待的压机物料是 {} ,得到的数据 {}",
taskCode, deviceCode, task.getString("material_id"), nextPoint);
} else {
task.put("priority", "4");
}
if (ObjectUtil.isEmpty(nextPoint)) {
// if (ObjectUtil.isEmpty(nextPoint) || ObjectUtil.isEmpty(nextPoint.get("point_code"))) {
// // 判断压机上是否有点位状态是4物料对应
// flag = true;
// nextPoint = WQL.getWO("SEND_MATERIAL_TASK")
// .addParam("flag", "10")
// .addParam("material_id", task.getString("material_id"))
// .process()
// .uniqueResult(0);
// log.info("任务 {} 设备 {} 查找等待的压机物料是 {} ,得到的数据 {}",
// taskCode, deviceCode, task.getString("material_id"), nextPoint);
// } else {
// task.put("priority", "4");
// }
if (ObjectUtil.isEmpty(nextPoint)||ObjectUtil.isEmpty(nextPoint.get("point_code"))) {
flag = false;
// 先去普通压机困料货位
nextPoint = WQL.getWO("SEND_MATERIAL_TASK")
.addParam("flag", "4")
.addParam("material_id", task.getString("material_id"))
.process()
.uniqueResult(0);
log.info("任务 {} 设备 {} 满料去了普通压机的困料位,物料是 {} ,得到的数据 {}",
taskCode, deviceCode, task.getString("material_id"), nextPoint);
if (ObjectUtil.isEmpty(nextPoint)) {
// nextPoint = WQL.getWO("SEND_MATERIAL_TASK")
// .addParam("flag", "4")
// .addParam("material_id", task.getString("material_id"))
// .process()
// .uniqueResult(0);
// log.info("任务 {} 设备 {} 满料去了普通压机的困料位,物料是 {} ,得到的数据 {}",
// taskCode, deviceCode, task.getString("material_id"), nextPoint);
if (ObjectUtil.isEmpty(nextPoint)||ObjectUtil.isEmpty(nextPoint.get("point_code"))) {
// 公共货位
nextPoint = WQL.getWO("SEND_MATERIAL_TASK")
.addParam("flag", "5")
@@ -171,7 +171,7 @@ public class HLSendMaterialTask extends AbstractAcsTask {
}
}
}
if (ObjectUtil.isNotEmpty(nextPoint)) {
if (ObjectUtil.isNotEmpty(nextPoint)&&ObjectUtil.isNotEmpty(nextPoint.get("point_code"))) {
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code2", nextPoint.getString("point_code"));
task.put("remark", flag ? "直接送到布料机" : "");

View File

@@ -62,6 +62,15 @@
<el-form-item label="点位号">
<el-input v-model="form.point_code" style="width: 370px;" />
</el-form-item>
<el-form-item label="物料标识" prop="material_number">
<el-input
v-model="form.material_id"
style="width: 300px"
clearable
@focus="materialShow=true"
@clear="form.material_id=''; form.material_number=''; form.material_name=''"
/>
</el-form-item>
<el-form-item label="是否满垛" prop="is_full">
<el-radio v-model="form.is_full" label="0">否</el-radio>
<el-radio v-model="form.is_full" label="1">是</el-radio>
@@ -102,6 +111,7 @@
/>
<el-table-column prop="qty" label="数量" :min-width="flexWidth('qty',crud.data,'数量')" />
<el-table-column prop="weight" label="重量" :min-width="flexWidth('weight',crud.data,'重量')" />
<el-table-column prop="material_number"label="物料号":min-width="flexWidth('material_number',crud.data,'物料号')"/>
<!-- <el-table-column prop="point_name" label="点位名称" :min-width="flexWidth('point_name',crud.data,'点位名称')"/>-->
<el-table-column prop="is_full" label="是否满垛" :min-width="flexWidth('is_full',crud.data,'是否满垛')">
<template slot-scope="scope">
@@ -143,6 +153,7 @@
</el-table-column>
</el-table>
<!--分页组件-->
<MaterDtl :dialog-show.sync="materialShow" :is-single="true" @setMaterValue="setMaterValue" />
<pagination />
</div>
</div>
@@ -154,6 +165,7 @@ import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import MaterDtl from '@/views/wms/pub/MaterDialog'
import pagination from '@crud/Pagination'
const defaultForm = {
@@ -222,12 +234,14 @@ const defaultForm = {
update_time: null,
is_delete: null,
is_fire: '0',
is_in_kiln: null
is_in_kiln: null,
material_id: null,
material_number: null
}
export default {
name: 'VehicleDetail',
dicts: ['vehicle_type'],
components: { pagination, crudOperation, rrOperation, udOperation },
components: { pagination, crudOperation,MaterDtl, rrOperation, udOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
@@ -241,6 +255,7 @@ export default {
data() {
return {
permission: {},
materialShow: false,
rules: {
vehicle_type: [
{ required: true, message: '不能为空', trigger: 'blur' }
@@ -261,6 +276,11 @@ export default {
}
},
methods: {
// 新增编辑给form表单物料相关信息赋值
setMaterValue(row) {
this.form.material_id = row.material_id
this.form.material_number = row.material_number
},
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true