From d3788b219b72e7a1732ed6d0cf37152efda8f7d4 Mon Sep 17 00:00:00 2001 From: zhoujj <1549112868@qq.com> Date: Tue, 7 Jan 2025 13:36:16 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E9=A1=B9=E7=9B=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StandardInspectSiteDeviceDriver.java | 57 +++- .../driver/AbstractOpcDeviceDriver.java | 282 ++++++++++++--- .../LnshKilnTrussDeviceDriver.java | 2 +- .../LnshMixingMillDeviceDriver.java | 45 ++- .../LnshOutKilnTrussDeviceDriver.java | 54 ++- ...hPackagePalletManipulatorDeviceDriver.java | 40 +++ .../LnshPackageSiteDeviceDriver.java | 45 ++- ...alletizingManipulatorSiteDeviceDriver.java | 45 ++- .../lnsh_press/LnshPressDeviceDriver.java | 45 ++- .../LnshSplitManipulatorDeviceDriver.java | 40 +++ .../lnsh_station/LnshStationDeviceDriver.java | 50 ++- .../java/org/nl/acs/opc/OpcServerService.java | 7 +- .../org/nl/acs/opc/OpcServerServiceImpl.java | 186 ++++++---- .../java/org/nl/acs/opc/OpcServerUtl.java | 3 +- .../src/main/java/org/nl/acs/opc/OpcUtl.java | 321 ++++++++---------- .../auto/run/NDCSocketConnectionAutoRun.java | 12 +- .../call/material/YZCallMaterialTask.java | 24 +- .../call/material/wql/CALL_MATERIAL_TASK.wql | 31 +- .../send/material/HLSendMaterialTask.java | 46 +-- .../wms/basedata/vehicle/group/index.vue | 24 +- 20 files changed, 998 insertions(+), 361 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index d557fcd..d45cbf5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -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 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 map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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 itemMap) { ReadUtil.write(itemMap, server, 0); server.disconnect(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java index ac617b4..8a479a6 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java @@ -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 map) { - LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); + + public void checkcontrol(Map itemValues) throws JIException, AddFailedException { + Group group = opcServerService.getServer(this.getOpcServer()); + Map write = new HashMap(); + Map readitems = new LinkedHashMap(); + List 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); + } + + } catch (Exception e){ + e.printStackTrace(); + } + Map read = new HashMap(); + Map 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 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); + } + + 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 String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - public void control(Map itemValues) { + public boolean controlByNewConn(Map itemValues) { Iterator> it = itemValues.entrySet().iterator(); - ItemValue[] p2; + ItemValue p2[]; p2 = new ItemValue[itemValues.size()]; - int i = 0; + int i=0; while (it.hasNext()) { Map.Entry 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; - OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class); +// 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; + }*/ - opcServerService.writeInteger(this.getOpcServer(), itemValues); - UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor(); + 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();*/ - for (ItemValue itemValue : itemValues) { - String code = itemValue.getItem_code(); - Object value = itemValue.getItem_value(); - opcValueAccessor.setValue(code, value); + 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 itemValues) { + + Iterator> it = itemValues.entrySet().iterator(); + + ItemValue p2[]; + p2 = new ItemValue[itemValues.size()]; + int i=0; + while (it.hasNext()) { + Map.Entry 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 (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("下发 无内容"); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java index 9b88aec..1a977b0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java @@ -28,7 +28,7 @@ import java.util.HashMap; import java.util.Map; /** - * 晟华入出窑桁架 + * 晟华出窑桁架 */ @Slf4j @Getter diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java index 2c4d4bc..7f5732a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java @@ -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 map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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() diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java index 0cb9de0..c2bcb14 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java @@ -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 map = new LinkedHashMap<>(); + map.put("to_command",22); + this.writing(map); this.setRequireSucess(true); } }else{ - this.writing(24); + Map map = new LinkedHashMap<>(); + map.put("to_command",24); + this.writing(map); this.setRequireSucess(true); } } return true; } } + /** + * 多个信号一起下发电气 + * + * @param map + */ + + public void writing(Map map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java index 2ce8068..9dc095a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java @@ -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 map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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() diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java index 3e762a9..f6ef99b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_site/LnshPackageSiteDeviceDriver.java @@ -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 map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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() diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java index 616e666..28f978c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/LnshPalletizingManipulatorSiteDeviceDriver.java @@ -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 map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java index 826471c..25f00dc 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java @@ -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 map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java index 502a1b3..febd21a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java @@ -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 map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java index 3191abb..828d04b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java @@ -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 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 map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map 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) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java index 4f53ca9..dd25920 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java @@ -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); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java index 6c5ed3b..8ff6aae 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java @@ -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,30 +27,33 @@ import java.util.Map; public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoInitial { private static final Logger log = LoggerFactory.getLogger(OpcServerServiceImpl.class); - @Autowired - OpcServerManageService opcServerManageService; - Map opcServerManageDtos = new HashMap<>(); - Map servers = Collections.synchronizedMap(new HashMap<>()); - Map groups = Collections.synchronizedMap(new HashMap<>()); + @Autowired OpcServerManageService opcServerManageService; + Map opcServerManageDtos = new HashMap(); + Map servers = Collections.synchronizedMap(new HashMap()); + Map 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(); - for (OpcServerManageDto dto : OpcServerServiceImpl.this.opcServerManageDtos.values()) { - try { - OpcServerServiceImpl.this.getServer(dto.getOpc_code()); - OpcServerServiceImpl.log.info("加载opc server {}", dto.getOpc_code()); - } catch (Exception var4) { - OpcServerServiceImpl.log.warn("启动无法载入servers", var4); + while (var1.hasNext()) { + OpcServerManageDto dto = (OpcServerManageDto) var1.next(); + + try { + OpcServerServiceImpl.this.getServer(dto.getOpc_code()); + OpcServerServiceImpl.log.info("加载opc server {}", dto.getOpc_code()); + } catch (Exception var4) { + 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); - 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); + public Group getServer(String code) { + synchronized(this.buildLock(code)) { + Group group = null; + 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; } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerUtl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerUtl.java index 1cf05b2..8bce071 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerUtl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerUtl.java @@ -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; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java index 626e99f..1d68db0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java @@ -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> showAllOpcServer(String host, String user, String password, String domain) throws Exception { + public static void writeValue(Group group, WriteRequest... requests) throws WDKException { try { - List> listResult = new ArrayList(); - ServerList serverList = new ServerList(host, user, password, domain); - Collection 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 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 write = group.write(requests); + Map 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 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(); - } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java index cca9664..6e76f56 100644 --- a/acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java @@ -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; diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/YZCallMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/YZCallMaterialTask.java index 1923ab7..7b94873 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/YZCallMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/YZCallMaterialTask.java @@ -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") + "] 的叫料任务未找到起点!"); } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/wql/CALL_MATERIAL_TASK.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/wql/CALL_MATERIAL_TASK.wql index 60d4f13..d0a9e83 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/wql/CALL_MATERIAL_TASK.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/wql/CALL_MATERIAL_TASK.wql @@ -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 + + diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/HLSendMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/HLSendMaterialTask.java index 4be4093..f116b8d 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/HLSendMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/HLSendMaterialTask.java @@ -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 ? "直接送到布料机" : ""); diff --git a/lms/nladmin-ui/src/views/wms/basedata/vehicle/group/index.vue b/lms/nladmin-ui/src/views/wms/basedata/vehicle/group/index.vue index 8035d8f..397caa2 100644 --- a/lms/nladmin-ui/src/views/wms/basedata/vehicle/group/index.vue +++ b/lms/nladmin-ui/src/views/wms/basedata/vehicle/group/index.vue @@ -62,6 +62,15 @@ + + + @@ -102,6 +111,7 @@ /> +