From 8c0a9a3da3ed709b90f4c30cfcae9224c7873254 Mon Sep 17 00:00:00 2001 From: gongbaoxiong <751575283@qq.com> Date: Thu, 31 Oct 2024 20:41:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=8D=E9=A6=88wms?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../standard_inspect/ItemProtocol.java | 2 +- .../standard_autodoor/ItemProtocol.java | 2 +- .../standard_inspect_site/ItemProtocol.java | 2 +- .../StandardInspectSiteDeviceDriver.java | 25 ++++++++++--------- .../fold_disc_site/ItemProtocol.java | 2 +- .../wms/service/impl/AcsToWmsServiceImpl.java | 9 +++---- .../modules/system/service/dto/ParamDto.java | 6 ++--- .../system/service/impl/ParamServiceImpl.java | 6 ++++- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/standard_inspect/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/standard_inspect/ItemProtocol.java index 66dff9e..a22a3e4 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/standard_inspect/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/standard_inspect/ItemProtocol.java @@ -34,7 +34,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error("读取错误!"); + log.error(this.driver.getDevice().getDevice_code()+"信号读取错误!"); } else { return value; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java index d1fd7e6..0f5f19f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_autodoor/ItemProtocol.java @@ -45,7 +45,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error("读取错误!"); + log.error(this.driver.getDevicecode()+"信号读取错误!"); } else { return value; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java index 1398148..7b65026 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java @@ -74,7 +74,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); 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 11dbae9..07725ad 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 @@ -2,14 +2,11 @@ package org.nl.acs.device_driver.basedriver.standard_inspect_site; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; @@ -20,8 +17,6 @@ import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.opc.WcsConfig; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; @@ -32,7 +27,6 @@ import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.util.SpringContextHolder; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import java.util.Date; import java.util.HashMap; @@ -139,11 +133,17 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp move = this.itemProtocol.getMove(); task = this.itemProtocol.getTask(); hasGoods = this.itemProtocol.getMove(); - + if (devicecode.contains("F2TBJ")) { + if (move != last_move) { + log.info(this.devicecode + ",检测到货位信号的值由" + last_move + "->" + move); + } + if (mode != last_mode) { + log.info(this.devicecode + ",检测到货位工作模式的值由" + last_mode + "->" + mode); + } + } if (move != last_move) { this.requireSucess = false; } - } catch (Exception var17) { return; } @@ -178,6 +178,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp JSONObject param = new JSONObject(); param.put("device_code", this.devicecode); param.put("is_have", this.move); + log.info(this.devicecode + "检测到货位光电信号变动,开始反馈WMS"); this.shipDeviceUpdate(param); } } @@ -338,11 +339,11 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); } else { this.instruction_require_time = date; - JSONObject response = acsToWmsService.shipDeviceUpdate(param); -// if (20000 == response.getIntValue("code")) { - this.requireSucess = true; -// } + // if (20000 == response.getIntValue("code")) { + this.requireSucess = true; + log.info(this.devicecode + "检测到货位光电信号变动,反馈WMS成功!"); + // } } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/fold_disc_site/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/fold_disc_site/ItemProtocol.java index a8f1f74..8731690 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/fold_disc_site/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/fold_disc_site/ItemProtocol.java @@ -76,7 +76,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { -// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index f58ac2b..3e86c9c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -24,8 +24,6 @@ import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.HashMap; -import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; @@ -536,22 +534,21 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { MDC.put(log_file_type, log_type); if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); - String password=paramService.findByCode(AcsConfig.PASSWORD).getValue(); + String password = paramService.findByCode(AcsConfig.PASSWORD).getValue(); AddressDto addressDto = addressService.findByCode("shipDeviceUpdate"); String methods_url = addressDto.getMethods_url(); String url = wmsUrl + methods_url; log.info("shipDeviceUpdate - 请求参数 {}", param); JSONArray ja = new JSONArray(); ja.add(param); - HttpResponse result=HttpRequest.post(url) + HttpResponse result = HttpRequest.post(url) .body(ja.toString()) - .basicAuth("INFOR",password) + .basicAuth("INFOR", password) .execute(); log.info("shipDeviceUpdate - 返回参数 {}", result.body()); return JSONObject.parseObject(result.body()); } } catch (Throwable ignored) { - } finally { MDC.remove(log_file_type); } diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/system/service/dto/ParamDto.java b/acs/nladmin-system/src/main/java/org/nl/modules/system/service/dto/ParamDto.java index 0cc5cf1..5aaae6e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/system/service/dto/ParamDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/system/service/dto/ParamDto.java @@ -14,11 +14,11 @@ public class ParamDto implements Serializable { private String id; - private String code; + private String code=""; - private String name; + private String name=""; - private String value; + private String value=""; private String remark; diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/ParamServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/ParamServiceImpl.java index 25d0522..c9f0dbe 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/ParamServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/ParamServiceImpl.java @@ -5,6 +5,7 @@ package org.nl.modules.system.service.impl; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; @@ -67,7 +68,10 @@ public class ParamServiceImpl implements ParamService { public ParamDto findByCode(String code) { WQLObject wo = WQLObject.getWQLObject("sys_param"); JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0); - final ParamDto obj = json.toJavaObject(ParamDto.class);; + if (ObjectUtil.isEmpty(json)) { + return new ParamDto(); + } + final ParamDto obj = json.toJavaObject(ParamDto.class); return obj; }