From 0a459742200d44025dc826473211379c6a561627 Mon Sep 17 00:00:00 2001 From: liuxy Date: Tue, 25 Apr 2023 11:09:56 +0800 Subject: [PATCH 01/10] =?UTF-8?q?rev:=E7=9B=98=E7=82=B9=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/HandMoveStorServiceImpl.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java index 2750cb7e5..3dbfe778a 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java @@ -85,6 +85,10 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv"); //任务表 WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); + //点位表 + WQLObject wo_Point = WQLObject.getWQLObject("sch_base_point"); + //仓位表 + WQLObject wo_Attr = WQLObject.getWQLObject("st_ivt_structattr"); String currentUserId = SecurityUtils.getCurrentUserId(); String nickName = SecurityUtils.getCurrentNickName(); @@ -96,11 +100,13 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { map.put("update_time", now); JSONObject jo_mst = wo_mst.query("moveinv_id='" + moveinv_id + "'").uniqueResult(0); JSONArray ja = wo_dtl.query("moveinv_id='" + moveinv_id + "'").getResultJSONArray(0); + String point_code2 = ""; for (int i = 0; i < ja.size(); i++) { JSONObject jo = ja.getJSONObject(i); //删除任务 HashMap task_map = new HashMap<>(); task_map.put("is_delete", "1"); + point_code2 = wo_Task.query("task_id = '" + jo.getString("task_id") + "'").uniqueResult(0).getString("point_code2"); wo_Task.update(task_map, "task_id='" + jo.getString("task_id") + "'"); //解锁起点点位、仓位 JSONObject from_start = new JSONObject(); @@ -133,6 +139,15 @@ public class HandMoveStorServiceImpl implements HandMoveStorService { } //更新主表 wo_mst.update(map, "moveinv_id='" + moveinv_id + "'"); + // 更新移入点位 + JSONObject jsonPoint = wo_Point.query("point_code = '" + point_code2 + "'").uniqueResult(0); + jsonPoint.put("vehicle_code", ""); + wo_Point.update(jsonPoint); + + JSONObject jsonAttr = wo_Attr.query("struct_code = '" + point_code2 + "'").uniqueResult(0); + jsonAttr.put("storagevehicle_code", ""); + wo_Attr.update(jsonAttr); + } @Override From e158d84afbc7a1ee84be589400ce24ecd243b2ae Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Tue, 25 Apr 2023 22:06:09 +0800 Subject: [PATCH 02/10] =?UTF-8?q?fix=20=E6=9B=B4=E6=96=B0=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../driver/AbstractOpcDeviceDriver.java | 13 +- .../nl/acs/opc/DeviceOpcProtocolRunable.java | 651 +++++++++++------- .../org/nl/acs/opc/OpcServerServiceImpl.java | 142 ++-- 3 files changed, 489 insertions(+), 317 deletions(-) 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 f29d55d8c..7f6fe7de8 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,11 +1,13 @@ package org.nl.acs.device_driver.driver; +import lombok.extern.slf4j.Slf4j; import org.jinterop.dcom.common.JIException; import org.nl.acs.ext.wms.data.JsonUtl; import org.nl.acs.instruction.service.InstructionService; 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.wql.exception.WDKException; import org.nl.modules.wql.util.SpringContextHolder; import org.openscada.opc.lib.da.AddFailedException; @@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.*; +@Slf4j public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver { @Autowired @@ -135,11 +138,13 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc sb.append(":"); sb.append(JsonUtl.parseWithoutException(udw_value)); sb.append(";"); -// if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) { -// need_write = true; -// } + if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) { + need_write = true; + } else { + log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value ); + } } - need_write = true; + //need_write = true; if (need_write) { Date date = new Date(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java index 968ae2a12..d0b770e86 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java @@ -1,271 +1,418 @@ package org.nl.acs.opc; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import lombok.extern.slf4j.Slf4j; import org.nl.acs.udw.UnifiedDataAccessor; import org.nl.acs.udw.UnifiedDataAccessorFactory; -import org.openscada.opc.lib.da.Group; -import org.openscada.opc.lib.da.Item; -import org.openscada.opc.lib.da.ItemState; -import org.openscada.opc.lib.da.Server; +import org.nl.acs.udw.UnifiedDataAppService; +import org.openscada.opc.lib.da.*; import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; + @Slf4j -public class DeviceOpcProtocolRunable implements Runnable { - List protocols; - OpcServerManageDto OpcServer; - int error_num; - String message; - private Server server; - //boolean flag =false; - - - public DeviceOpcProtocolRunable() { - this.error_num = 0; - this.message = null; - this.server = null; - } - - public List getProtocols() { - return this.protocols; - } - - public void setProtocols(List protocols) { - this.protocols = protocols; - } - - public OpcServerManageDto getOpcServer() { - return this.OpcServer; - } - - public void setOpcServer(OpcServerManageDto opcServer) { - this.OpcServer = opcServer; - } - - OpcItemDto getItem(String item) { - Iterator var2 = this.protocols.iterator(); - - OpcItemDto dto; - do { - if (!var2.hasNext()) { - return null; - } - - dto = (OpcItemDto) var2.next(); - } while (!StrUtil.equals(item, dto.getItem_code())); - - return dto; - } - - @Override - public void run() { - while (true) { - try { - this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); -// Group group = server.addGroup(this.OpcServer.getOpc_host()); - Group group = server.addGroup(this.OpcServer.getOpc_code()); - if(ObjectUtil.isEmpty(group)){ - log.info("group is null "); - } - List itemsString = new ArrayList(); - Iterator it = this.protocols.iterator(); - - while (it.hasNext()) { - OpcItemDto protocol = (OpcItemDto) it.next(); - String item = protocol.getItem_code(); - itemsString.add(item); - } - - Map itemsMap = new LinkedHashMap(); - boolean is_error = false; - StringBuilder err_message = new StringBuilder(); - Iterator var7 = itemsString.iterator(); - - while (var7.hasNext()) { - String string = (String) var7.next(); - - try { - itemsMap.put(string, group.addItem(string)); - log.trace("添加成功 {}", string); - } catch (Exception var29) { - err_message.append(string + ":" + var29.getMessage()); - if (!is_error) { - is_error = true; - } - } - } - - if (is_error) { - log.info("设备OPC数据同步配置异常"); - } - - if (!OpcStartTag.is_run) { - OpcStartTag.is_run = true; - } - - //线程名 - String tag = Thread.currentThread().getName(); - if (this.OpcServer != null) { - tag = tag + this.OpcServer.getOpc_code(); - } - UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key); - - boolean time_out = false; - - label97: - while (true) { - long begin = System.currentTimeMillis(); - Map itemStatus = null; - try { - itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0])); - } catch (Exception e){ - System.out.println("数据同步异常:"+ this.getOpcServer().getOpc_code()); - log.trace("数据同步异常:{}", this.getOpcServer().getOpc_code()); - //e.printStackTrace(); - } - long end = System.currentTimeMillis(); - log.trace("{} 开始记时{}", tag, DateUtil.now()); - long duration = end - begin; - log.trace("{} 读取耗时:{}", tag, duration); - System.out.println("线程:"+tag + " 读取耗时:"+ duration); - if (duration > 1000L) { - if (!time_out) { - log.warn(" {} 读取超时 : {}", tag, duration); - } - - time_out = true; - } else { - time_out = false; - } - - if(ObjectUtil.isEmpty(itemStatus)) { - System.out.println( tag + " :itemStatus is null"); - log.warn(" {} 读取异常 : {} itemStatus is null", tag); - } - - - Set items = itemStatus.keySet(); - Iterator var18 = items.iterator(); - - while (true) { - Item item; - //当前值 - Object value; - //旧的值 - Object his; - do { - if (!var18.hasNext()) { - end = System.currentTimeMillis(); - log.trace("{}", itemsString); - log.trace("{} 计算完成耗时{}", tag, end - begin); - Thread.sleep((long) OpcConfig.synchronized_millisecond); - if (this.error_num != 0) { - this.error_num = 0; - this.message = null; - } - continue label97; - } - - item = (Item) var18.next(); - ItemState itemState = (ItemState) itemStatus.get(item); - value = OpcUtl.getValue(item, itemState); - his = accessor_value.getValue(item.getId()); - if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { - //flag = true; - log.warn("opc 值不健康 item: {}, 状态: {},当前读取值:{}, 系统内存值{} ", item.getId(), itemState.getQuality(), value, his); - } -// if(flag){ -// if (this.server != null) { -// try { -// this.server.disconnect(); -// } catch (Exception var25) { -// log.warn("{} : server disconnect", var25); -// } -// } -// DeviceOpcProtocolRunable runable = new DeviceOpcProtocolRunable(); -// runable.setProtocols(protocols); -// runable.setOpcServer(OpcServer); -// ExecutorService executorService = Executors.newCachedThreadPool(); -// executorService.submit(runable); -// log.warn("opc 值不健康 item: {}, 重新创建连接,当前线程名:{}", item.getId(),tag); -// break; -// } - } while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码 - -// if(flag){ -// break; -// } - OpcItemDto itemDto = this.getItem(item.getId()); - //默认记录日志 - if (true) { - StringBuilder sb = new StringBuilder(); - //设备的ITEM项 - List relate_items = itemDto.getRelate_items(); - Iterator var26 = relate_items.iterator(); - - while (var26.hasNext()) { - String relate = (String) var26.next(); - Object obj = accessor_value.getValue(relate); - sb.append("key:" + relate + "value:" + obj + ";"); - } - - log.warn("信号{}变更从{}->{};信号快照:{}", new Object[]{item.getId(), his, value, sb}); - - } -// accessor_value.setValueWithPersistence(item.getId(),accessor_value.getValue(item.getId())); -// accessor_value.getHistoryUnifiedData(item.getId()); - //设置值 - accessor_value.setValue(item.getId(), value); -// if(flag){ -// break; -// } - } -// if(flag){ -// break; -// } - } - } catch (Exception var30) { - if (this.server != null) { - try { - this.server.disconnect(); - } catch (Exception var25) { - log.warn("{} : server disconnect", var25); - } - } +public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerConnectionStateListener { + List protocols; + OpcServerManageDto OpcServer; + int error_num; + String message; + int maxResartNum; + private Server server; + private Group group; + boolean flag = false; + private int all_null; + private Map itemSearchCache; + public DeviceOpcProtocolRunable() { + this.error_num = 0; + this.all_null = 0; + this.message = null; + this.itemSearchCache = new HashMap(); this.server = null; + } - String error_message = "设备信息同步异常,"+var30; - if (!StrUtil.equals(this.message, error_message)) { - log.warn("", var30); + public List getProtocols() { + return this.protocols; + } + + public void setProtocols(List protocols) { + this.protocols = protocols; + } + + public OpcServerManageDto getOpcServer() { + return this.OpcServer; + } + + public void setOpcServer(OpcServerManageDto opcServer) { + this.OpcServer = opcServer; + } + + + private OpcItemDto getItem(String item) { + OpcItemDto x = (OpcItemDto) this.itemSearchCache.get(item); + if (x == null) { + Iterator var3 = this.protocols.iterator(); + + while (var3.hasNext()) { + OpcItemDto dto = (OpcItemDto) var3.next(); + if (StrUtil.equals(item, dto.getItem_code())) { + x = dto; + this.itemSearchCache.put(item, dto); + break; + } + } } + return x; + } + + + @Override + public void run() { + if (OpcConfig.opc_item_read_using_callback) { + this.runNew(); + } else { + this.runOld(); + } + } + + + private void runOld() { + while (true) { + start: + try { + if (this.group != null) { + group.clear(); + group.remove(); + log.trace("清理group..."); + } + if (this.server != null) { + server.disconnect(); + log.trace("清理server..."); + } + + this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); + this.server.addStateListener(this); + group = this.server.addGroup(); + List itemsString = new ArrayList(); + Iterator var3 = this.protocols.iterator(); + + while (var3.hasNext()) { + OpcItemDto protocol = (OpcItemDto) var3.next(); + String item = protocol.getItem_code(); + itemsString.add(item); + } + + Map itemsMap = new LinkedHashMap(); + boolean is_error = false; + StringBuilder err_message = new StringBuilder(); + Iterator var6 = itemsString.iterator(); + + while (var6.hasNext()) { + String string = (String) var6.next(); + + try { + Item item = group.addItem(string); + itemsMap.put(string, item); + log.trace("添加成功 {}", string); + } catch (Exception var26) { + err_message.append(string + ":" + var26.getMessage()); + if (!is_error) { + is_error = true; + } + } + } + + String tag; + if (is_error) { + tag = err_message.toString(); + log.warn("{}:{}", OpcConfig.resource_code, tag); + } + + if (!OpcStartTag.is_run) { + OpcStartTag.is_run = true; + } + + tag = ""; + if (log.isWarnEnabled()) { + tag = Thread.currentThread().getName(); + if (this.OpcServer != null) { + tag = tag + this.getOpcGroupID(); + } + } + + UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key); + boolean time_out = false; + + while (DeviceOpcSynchronizeAutoRun.isRun) { + long begin = System.currentTimeMillis(); + if (log.isTraceEnabled()) { + log.trace("{} 开始记时{}", tag, DateUtil.now()); + } + + Map itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0])); + long end = System.currentTimeMillis(); + long duration = end - begin; + if (log.isTraceEnabled()) { + log.trace("{} 读取耗时:{}", tag, duration); + } + + if (duration > 1000L) { + if (!time_out) { + log.warn("{} 读取超时 : {}", tag, duration); + } + + time_out = true; + } else { + time_out = false; + } + + boolean valueAllNotNull = false; + Set items = itemStatus.keySet(); + Iterator var18 = items.iterator(); + + while (var18.hasNext()) { + Item item = (Item) var18.next(); + ItemState itemState = (ItemState) itemStatus.get(item); + Object value = OpcUtl.getValue(item, itemState); + if (value != null) { + valueAllNotNull = true; + } + + String itemId = item.getId(); + Object his = accessor_value.getValue(itemId); + if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { + log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality()); + } + + if (!UnifiedDataAppService.isEquals(value, his)) { + OpcItemDto itemDto = this.getItem(itemId); + if (true) { + this.logItemChanged(itemId, accessor_value, value, itemDto); + } + + accessor_value.setValue(itemId, value); + } + } + + end = System.currentTimeMillis(); + if (log.isTraceEnabled()) { + log.trace("{}", itemsString); + log.trace("{} 计算完成耗时{}", tag, end - begin); + } + + ThreadUtl.sleep((long) OpcConfig.synchronized_millisecond); + if (this.error_num != 0) { + this.error_num = 0; + this.message = null; + } + + if (!valueAllNotNull) { + int random = (new Random()).nextInt(10) + 1; + random *= 1000; + if (this.all_null < 3) { + if (log.isWarnEnabled()) { + log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,5000 + random); + } + + ThreadUtl.sleep((long) (5000 + random)); + } else if (this.all_null < 6) { + if (log.isWarnEnabled()) { + log.warn(tag + "重新创建server"); + log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,30000 + random); + } +// ThreadUtl.sleep((long) (30000 + random)); + ThreadUtl.sleep((long) ((new Random()).nextInt(3) +1) * 1000); + break start; + } else if (this.all_null < 12) { + if (log.isWarnEnabled()) { + log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, '\uea60' + random); + } + + ThreadUtl.sleep((long) ('\uea60' + random)); + } else { + if (log.isWarnEnabled()) { + log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, 120000 + random); + } + + ThreadUtl.sleep((long) (120000 + random)); + } + + ++this.all_null; + } else { + this.all_null = 0; + } +// break start; + + } + + log.warn("opc线程停止。。。"); + return; + } catch (Exception var27) { + if (this.server != null) { + try { + this.server.disconnect(); + } catch (Exception var25) { + } + } + + this.server = null; + if (!DeviceOpcSynchronizeAutoRun.isRun) { + log.warn("opc线程停止2。。。"); + return; + } + + String error_message = "设备信息同步异常"; + if (!StrUtil.equals(this.message, error_message)) { + log.warn(error_message, var27); + } + + ThreadUtl.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000)); + ++this.error_num; + if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) { + this.message = error_message; + } + } + } + } + + + private void runNew() { + Async20Access accessor = null; + + while (true) { + String opcGroupId = this.getOpcGroupID(); + + try { + if (this.server == null) { + this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); + this.server.addStateListener(this); + accessor = new Async20Access(this.server, OpcConfig.synchronized_millisecond, true); + Iterator var9 = this.protocols.iterator(); + + while (var9.hasNext()) { + OpcItemDto protocol = (OpcItemDto) var9.next(); + String itemId = protocol.getItem_code(); + accessor.addItem(itemId, this); + } + + accessor.bind(); + log.info("Async20Access bind {}", opcGroupId); + } + + Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000)); + } catch (Exception var8) { + if (accessor != null) { + try { + log.warn("Async20Access unbind {}", opcGroupId); + accessor.unbind(); + } catch (Exception var7) { + var7.printStackTrace(); + } + + accessor = null; + } + + if (this.server != null) { + try { + this.server.disconnect(); + } catch (Exception var6) { + } + + this.server = null; + } + + if (var8 instanceof InterruptedException) { + log.warn("OPC 同步线程(%s)被中断", opcGroupId); + return; + } + + log.warn("设备信息同步异常", var8); + ThreadUtl.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000)); + String error_message = var8.getMessage(); + if (error_message == null) { + error_message = var8.toString(); + } + + ++this.error_num; + if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) { + this.message = error_message; + } + } + } + } + + + public void connectionStateChanged(boolean connected) { + if (!connected) { + this.server = null; + } + + log.warn("opc server {} {}", this.getOpcGroupID(), connected ? "connected" : "disconnected"); + } + + private String getOpcGroupID() { + String var10000 = this.OpcServer.getOpc_code(); + return var10000 + "(" + this.protocols.size() + " items)"; + } + + public static String formatDuring(long mss) { + long days = mss / 86400000L; + long hours = mss % 86400000L / 3600000L; + long minutes = mss % 3600000L / 60000L; + long seconds = mss % 60000L / 1000L; + return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds "; + } + + + public void changed(Item item, ItemState itemState) { + String itemId = item.getId(); + try { - Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000)); - } catch (InterruptedException e) { - e.printStackTrace(); - log.warn("OPC 读取线程读取异常{} :", e); -// Thread.currentThread().interrupt();不会真正停止线程 - } - ++this.error_num; - if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) { - log.info("设备同步通信异常"); - this.message = error_message; - } - } - } - } + Object value = OpcUtl.getValue(item, itemState); + UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key); + accessor_value.setValue(itemId, value); + +// if (value != null) { +// if (log.isTraceEnabled()) { +// log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()}); +// } +// } else if (log.isInfoEnabled()) { +// log.info("Item {} new value: {}, Timestamp: {}, Quality: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime(), itemState.getQuality()}); +// } + log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()}); + + OpcItemDto itemDto = this.getItem(itemId); +// if (Boolean.TRUE.equals(itemDto.getNeed_log())) { +// this.logItemChanged(itemId, accessor_value, value, itemDto); +// } + this.logItemChanged(itemId, accessor_value, value, itemDto); + + } catch (Exception var7) { + log.error(itemId, var7); + } + + } + + private void logItemChanged(String itemId, UnifiedDataAccessor accessor_value, Object value, OpcItemDto itemDto) { + Object his = accessor_value.getValue(itemId); + List relate_items = itemDto.getRelate_items(); + if (relate_items != null && !relate_items.isEmpty()) { + StringBuilder sb = new StringBuilder(); + Iterator var8 = relate_items.iterator(); + + while (var8.hasNext()) { + String relate = (String) var8.next(); + Object obj = accessor_value.getValue(relate); + sb.append("key:" + relate + "value:" + obj + ";"); + } + log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value, sb}); +// this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{};信号快照:{}", new Object[]{itemId, his, value, sb}); + } else { + log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value}); +// this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{}", new Object[]{itemId, his, value}); + } + } - public static String formatDuring(long mss) { - long days = mss / 86400000L; - long hours = mss % 86400000L / 3600000L; - long minutes = mss % 3600000L / 60000L; - long seconds = mss % 60000L / 1000L; - return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds "; - } } 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 92a265428..c39adc2f1 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 @@ -1,8 +1,10 @@ package org.nl.acs.opc; +import cn.hutool.core.util.StrUtil; import org.jinterop.dcom.common.JIException; import org.nl.acs.auto.initial.ApplicationAutoInitial; import org.nl.acs.device_driver.driver.ItemValue; +import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.wql.exception.WDKException; import org.openscada.opc.lib.common.NotConnectedException; import org.openscada.opc.lib.da.Group; @@ -65,79 +67,86 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos); } - public synchronized Group getServer(String code) { - Group group = null; - group = (Group) this.groups.get(code); - if (group != null) { - try { - if (group.isActive()) { - return group; + public Group getServer(String code) { + synchronized(this.buildLock(code)) { + Group group = null; + group = (Group)this.groups.get(code); + if (group != null) { + label68: { + Group var10000; + try { + if (!group.isActive()) { + break label68; + } + + var10000 = group; + } catch (JIException var14) { + log.error(code, var14); + break label68; + } + + return var10000; } - } catch (JIException var9) { - var9.printStackTrace(); } - } - Server server = (Server) this.servers.get(code); - boolean needcreate = false; - if (server == null) { - needcreate = true; - } else { - try { - group = server.findGroup(OpcConfig.opc_server_default_group); - } catch (UnknownHostException - | JIException - | UnknownGroupException - | NotConnectedException - | IllegalArgumentException var8) { - var8.printStackTrace(); + Server server = (Server)this.servers.get(code); + boolean needcreate = false; + String groupName = code; + if (server == null) { needcreate = true; + } else { + try { + group = server.findGroup(groupName); + } catch (UnknownHostException | JIException | UnknownGroupException | NotConnectedException | IllegalArgumentException var13) { + log.error(code, var13); + needcreate = true; + } } + + if (needcreate) { + OpcServerManageDto dto = (OpcServerManageDto)this.opcServerManageDtos.get(code); + if (dto == null) { + throw new BadRequestException(code + "{} 不存在"); + } + + if (server == null) { + 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 var12) { + this.clearServer(code); + ThreadUtl.sleep(5000L); + 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) { + var11.printStackTrace(); + } + } + + this.servers.put(code, server); + this.groups.put(code, group); + } + + return group; } - - if (needcreate) { - OpcServerManageDto dto = (OpcServerManageDto) this.opcServerManageDtos.get(code); - if (dto == null) { - throw new WDKException("code 不存在"); - } - - server = OpcServerUtl.getServerWithOutException( - dto.getOpc_host(), - dto.getCls_id(), - dto.getUser(), - dto.getPassword(), - dto.getDomain()); - -// server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); - - - try { - group = server.addGroup(OpcConfig.opc_server_default_group); - } catch (Exception var7) { - throw new WDKException(var7); - } - - this.servers.put(code, server); - this.groups.put(code, group); - } - - return group; } - public synchronized void clearServer(String code) { - try { - Server server = (Server) this.servers.get(code); - if (server!=null){ + public void clearServer(String code) { + synchronized(this.buildLock(code)) { + try { + Server server = (Server)this.servers.get(code); server.disconnect(); + } catch (Exception var5) { } - } catch (Exception e) { - e.printStackTrace(); - log.error("清理server异常,",e.getMessage()); + this.servers.remove(code); + this.groups.remove(code); } - - this.servers.remove(code); - this.groups.remove(code); } public void writeInteger(String code, ItemValue... values) { @@ -151,4 +160,15 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn throw var4; } } + + private String buildLock(String key) { + if (StrUtil.isEmpty(key)) { + key = ""; + } + StringBuilder builder = new StringBuilder(); + builder.append("OpcServerService."); + builder.append(key); + String lock = builder.toString().intern(); + return lock; + } } From 6b5d0b447370b1168bfaebd7337ba4f7fc5c18ab Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Wed, 26 Apr 2023 19:00:36 +0800 Subject: [PATCH 03/10] =?UTF-8?q?fix=20=E7=BA=B8=E7=AE=A1=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paper_tube_device/ItemProtocol.java | 6 +++ .../PaperTubeConveyorDeviceDriver.java | 44 +++++++++++++++---- .../src/views/system/monitor/device/index.vue | 6 +++ 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java index 5f6d4454e..bae2d10ad 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java @@ -17,6 +17,7 @@ public class ItemProtocol { public static String item_inventory_qty ="inventory_qty"; public static String item_out_finish = "out_finish"; public static String item_material = "material"; + public static String item_error = "error"; public static String item_to_target = "to_target"; @@ -48,6 +49,10 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_out_finish); } + public int getError() { + return this.getOpcIntegerValue(item_error); + } + public String getMaterial() { return this.getOpcStringValue(item_material); } @@ -100,6 +105,7 @@ public class ItemProtocol { list.add(new ItemDto(item_inventory_qty, "库存数量", "DB101.W4")); list.add(new ItemDto(item_out_finish, "出库完成 ", "DB101.W6")); list.add(new ItemDto(item_material, "物料", "DB101.STRING8.50")); + list.add(new ItemDto(item_error, "error ", "DB101.W58")); return list; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java index 38928bf5e..d614838b5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.basedriver.paper_tube_device; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -12,6 +13,7 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.history.ErrorUtil; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.monitor.DeviceStageMonitor; @@ -63,6 +65,7 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple int mode = 0; int inventory_qty =0; int out_finish =0; + int error =0; String material = null; Boolean isonline = true; @@ -75,6 +78,7 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple int last_mode = 0; int last_inventory_qty =0; int last_out_finish =0; + int last_error = 0; String last_material = null; String device_code; @@ -97,25 +101,45 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple inventory_qty = this.itemProtocol.getInventory_qty(); out_finish =this.itemProtocol.getOut_finish(); material = this.itemProtocol.getMaterial(); + error = this.itemProtocol.getError(); if (mode != last_mode) { this.setRequireSucess(false); + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + } else { + this.setIsonline(true); + } + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (inventory_qty != last_inventory_qty) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号inventory_qty:" + last_inventory_qty + "->" + inventory_qty); + } + if (out_finish != last_out_finish) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); + } + if (!StrUtil.equals(material,last_material)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material:" + last_material + "->" + material); + } + if (error != last_error) { + if(error > 0){ + this.setIserror(true); + } else { + if(error > 0){ + this.setIserror(false); + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); } - if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - } else { - this.setIsonline(true); - this.setIserror(false); - - } last_mode = mode; last_inventory_qty = inventory_qty; last_out_finish = out_finish; + last_error = error; + last_material = material; } @@ -155,9 +179,11 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple } jo.put("device_name", this.getDevice().getDevice_name()); jo.put("mode", mode); + jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); jo.put("inventory_qty", inventory_qty); jo.put("out_finish", out_finish); jo.put("material", material); + jo.put("isOnline", this.getIsonline()); return jo; } diff --git a/acs/nladmin-ui/src/views/system/monitor/device/index.vue b/acs/nladmin-ui/src/views/system/monitor/device/index.vue index 46de2c227..f8b72ca4f 100644 --- a/acs/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/system/monitor/device/index.vue @@ -528,6 +528,12 @@ export default { } else if (val === 'applySucess') { const obj = { name: 'applySucess', value: data[val] } this.arr.push(obj) + } else if (val === 'out_finish') { + const obj = { name: '出库完成', value: data[val] } + this.arr.push(obj) + } else if (val === 'inventory_qty') { + const obj = { name: '库存数量', value: data[val] } + this.arr.push(obj) } } } From f13875ace87a57770315d087f17d4ae1a8daee09 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Sat, 29 Apr 2023 19:58:31 +0800 Subject: [PATCH 04/10] =?UTF-8?q?add=20=E7=BA=B8=E7=AE=A1=E5=BA=93?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paper_tube_device/ItemProtocol.java | 2 +- .../PaperTubeConveyorDeviceDriver.java | 11 ++- .../acs/ext/wms/rest/WmsToAcsController.java | 8 ++ .../acs/ext/wms/service/WmsToAcsService.java | 3 + .../wms/service/impl/WmsToAcsServiceImpl.java | 89 ++++++++++++++++++- 5 files changed, 109 insertions(+), 4 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java index bae2d10ad..fdabd5ac7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java @@ -105,7 +105,7 @@ public class ItemProtocol { list.add(new ItemDto(item_inventory_qty, "库存数量", "DB101.W4")); list.add(new ItemDto(item_out_finish, "出库完成 ", "DB101.W6")); list.add(new ItemDto(item_material, "物料", "DB101.STRING8.50")); - list.add(new ItemDto(item_error, "error ", "DB101.W58")); + list.add(new ItemDto(item_error, "error", "DB101.W58")); return list; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java index d614838b5..5b205dc1e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java @@ -66,6 +66,8 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple int inventory_qty =0; int out_finish =0; int error =0; + int to_command =0; + int to_target =0; String material = null; Boolean isonline = true; @@ -102,7 +104,8 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple out_finish =this.itemProtocol.getOut_finish(); material = this.itemProtocol.getMaterial(); error = this.itemProtocol.getError(); - + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTotarget(); if (mode != last_mode) { this.setRequireSucess(false); @@ -118,6 +121,12 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple logServer.deviceExecuteLog(this.device_code, "", "", "信号inventory_qty:" + last_inventory_qty + "->" + inventory_qty); } if (out_finish != last_out_finish) { + if(out_finish == 1){ + this.writing(0); + this.writing("to_target","0"); + this.writing("to_out_qty","0"); + + } logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); } if (!StrUtil.equals(material,last_material)) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index f7a3ed0e0..7a44dff3f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -143,4 +143,12 @@ public class WmsToAcsController { public ResponseEntity realTimefaultInfo(@RequestBody JSONObject param){ return new ResponseEntity<>(wmstoacsService.realTimefaultInfo(param), HttpStatus.OK); } + + @PostMapping("/paperTubeAction") + @Log(value = "下发纸管库动作",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @ApiOperation("下发纸管库动作") + @SaIgnore + public ResponseEntity paperTubeAction(@RequestBody JSONObject param){ + return new ResponseEntity<>(wmstoacsService.paperTubeAction(param), HttpStatus.OK); + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index 80d80b8e1..08f717eea 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -107,4 +107,7 @@ public interface WmsToAcsService { Map syncfaultInfo(); Map realTimefaultInfo(JSONObject param); + + Map paperTubeAction(JSONObject param); + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index b43dba697..cfd6ae389 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -24,6 +24,7 @@ import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.Empty import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver; +import org.nl.acs.device_driver.basedriver.paper_tube_device.PaperTubeConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.plug_pull_device_site.PlugPullDeviceSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; @@ -225,7 +226,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; //货梯对接线-带扫码器 StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - + //纸管库 + PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver; if (datas.size() == 0) { throw new BadRequestException("缺少输入参数!"); } @@ -272,7 +274,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("move", standardCoveyorControlWithScannerDeviceDriver.getMove()); jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); - } else { + + } else if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) { + paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", parent_device_code); + jo.put("qty", paperTubeConveyorDeviceDriver.getInventory_qty()); + jo.put("mode", paperTubeConveyorDeviceDriver.getMode()); + jo.put("error", paperTubeConveyorDeviceDriver.getError()); + jo.put("material_code", ObjectUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())? "":paperTubeConveyorDeviceDriver.getMaterial() ); + jo.put("out_finish", paperTubeConveyorDeviceDriver.getOut_finish()); + + }else { jo.put("device_code", parent_device_code); } backja.add(jo); @@ -1000,4 +1012,77 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { return resp; } + + @Override + public Map paperTubeAction(JSONObject param) { + log.info("paperTubeAction--------------:输入参数" + param.toString()); + JSONObject resp = new JSONObject(); + String device_code = param.getString("device_code"); + String type = param.getString("type"); + String material_code = param.getString("material_code"); + String qty = param.getString("qty"); + + if (StrUtil.isNotEmpty(device_code)) { + + Device device = deviceAppService.findDeviceByCode(device_code); + if (device == null) { + resp.put("status", 400); + resp.put("message", "未找到对应设备"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) { + PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver(); + if(paperTubeConveyorDeviceDriver.getMode() != 2){ + resp.put("status", 400); + resp.put("message", "设备:"+ device_code +"未待机,无法下发信号"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + if(StrUtil.equals(type,"1")){ + if(paperTubeConveyorDeviceDriver.getInventory_qty() > 0){ + resp.put("status", 400); + resp.put("message", "设备:"+ device_code +"当前数量为"+paperTubeConveyorDeviceDriver.getInventory_qty() +"无法设置物料"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + paperTubeConveyorDeviceDriver.writing("to_material",material_code); + } else if (StrUtil.equals(type,"2")) { + if(paperTubeConveyorDeviceDriver.getInventory_qty() < Integer.parseInt(qty)){ + resp.put("status", 400); + resp.put("message", "设备:"+ device_code +"当前数量为"+paperTubeConveyorDeviceDriver.getInventory_qty() +"小于出库数量"+qty); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + if(StrUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())){ + resp.put("status", 400); + resp.put("message", "设备:"+ device_code +"设备上报物料为空无法出库"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } else { + if(!StrUtil.equals(paperTubeConveyorDeviceDriver.getMaterial(),material_code)){ + resp.put("status", 400); + resp.put("message", "设备:"+ device_code +"设备上报物料为"+paperTubeConveyorDeviceDriver.getMaterial() +"与出库物料"+material_code+"不匹配"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + } + if(paperTubeConveyorDeviceDriver.getTo_command() != 0 || paperTubeConveyorDeviceDriver.getTo_target() != 0 ){ + resp.put("status", 400); + resp.put("message", "设备:"+ device_code +"下发命令信号值为"+paperTubeConveyorDeviceDriver.getTo_command() + ",下发目标站:" + paperTubeConveyorDeviceDriver.getTo_target() +",已存在待执行的任务"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + paperTubeConveyorDeviceDriver.writing("to_out_qty",qty); + paperTubeConveyorDeviceDriver.writing("to_target",device.getAddress()); + paperTubeConveyorDeviceDriver.writing("to_command","2"); + } + } + + } + resp.put("status", 200); + resp.put("message", "操作成功"); + return resp; + } + } From ea280b05f89f5b983b7a5ed5a493594b10f40579 Mon Sep 17 00:00:00 2001 From: zhangzhiqiang Date: Thu, 4 May 2023 13:53:34 +0800 Subject: [PATCH 05/10] =?UTF-8?q?fix:=E7=94=A8=E6=88=B7=E8=A1=A8=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E6=9F=A5=E8=AF=A2=E9=A1=B5=E6=95=B0=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/user/dao/mapper/SysUserMapper.xml | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/system/service/user/dao/mapper/SysUserMapper.xml b/lms/nladmin-system/src/main/java/org/nl/system/service/user/dao/mapper/SysUserMapper.xml index e89cfc99e..65eb3052b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/system/service/user/dao/mapper/SysUserMapper.xml +++ b/lms/nladmin-system/src/main/java/org/nl/system/service/user/dao/mapper/SysUserMapper.xml @@ -52,25 +52,14 @@ - - - - - - - + + + +