From 5c2e8a80d739c5659d74bfd2cbe232b5d72ce21f Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期二, 15 十月 2024 16:47:54 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/entity/RawGlassStorageDetails.java | 4
hangzhoumesParent/common/pom.xml | 1
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/xml/RawGlassStorageDetailsMapper.xml | 16 +
hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application.yml | 17 +
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/impl/RawGlassStorageDetailsServiceImpl.java | 17 +
hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application-dev.yml | 4
hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/entity/vo/UpPattenUsageVO.java | 14 +
hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/mapper/UpPattenUsageMapper.java | 6
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/RawGlassStorageDetailsMapper.java | 15 +
hangzhoumesParent/common/servicebase/src/main/java/com/kangaroohy/milo/configuration/MiloAutoConfiguration.java | 8
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglasstask/entity/RawGlassStorageTask.java | 9
hangzhoumesParent/common/servicebase/src/main/java/com/kangaroohy/milo/pool/MiloConnectFactory.java | 10
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassPushMessage.java | 72 +-----
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/RawGlassStorageDetailsService.java | 4
/dev/null | 9
hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Const.java | 19 +
hangzhoumesParent/common/servicebase/src/main/resources/mapper/UpPattenUsageMapper.xml | 32 +++
hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java | 235 +++++++++++++++++++++++
hangzhoumesParent/common/servicebase/pom.xml | 7
hangzhoumesParent/moduleService/pom.xml | 5
hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/changelog/changelog.sql | 43 ++-
21 files changed, 429 insertions(+), 118 deletions(-)
diff --git a/hangzhoumesParent/common/opcuaClient/pom.xml b/hangzhoumesParent/common/opcuaClient/pom.xml
deleted file mode 100644
index cf5d20f..0000000
--- a/hangzhoumesParent/common/opcuaClient/pom.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>common</artifactId>
- <groupId>com.mes</groupId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>opcuaClient</artifactId>
-
- <properties>
- <maven.compiler.source>8</maven.compiler.source>
- <maven.compiler.target>8</maven.compiler.target>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-autoconfigure</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-configuration-processor</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse.milo</groupId>
- <artifactId>sdk-client</artifactId>
- <version>0.6.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-pool2</artifactId>
- <version>2.6.2</version>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/configuration/MiloProperties.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/configuration/MiloProperties.java
deleted file mode 100644
index 1dac285..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/configuration/MiloProperties.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package com.mes.milo.configuration;
-
-import lombok.Data;
-import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * @author mes
- * @date 2020/4/25
- * @desc milo-spring-boot-starter
- * @since 0.0.1
- */
-@Data
-@ConfigurationProperties(prefix = MiloProperties.PREFIX)
-public class MiloProperties {
- public static final String PREFIX = "mes.milo";
-
- /**
- * 鏄惁鍚敤缁勪欢
- */
- private Boolean enabled = true;
-
- /**
- * server 榛樿璇锋眰閰嶇疆锛屼笉鎸囧畾锛屽垯榛樿鍙� config涓涓�涓�
- */
- private String primary;
-
- /**
- * server 鍒楄〃
- */
- private Map<String, Config> config = new LinkedHashMap<>();
-
- /**
- * 杩炴帴姹犻厤缃�
- */
- private Pool pool = new Pool();
-
- @Data
- public static class Config {
-
- /**
- * OPC UA鍦板潃
- */
- private String endpoint;
-
- /**
- * 瀹夊叏绛栫暐
- */
- private SecurityPolicy securityPolicy = SecurityPolicy.None;
-
- /**
- * 鐢ㄦ埛鍚�
- */
- private String username;
-
- /**
- * 瀵嗙爜
- */
- private String password;
- }
-
- @Data
- public static class Pool {
- /**
- * 鏈�澶х┖闂�
- */
- private int maxIdle = 5;
- /**
- * 鏈�澶ф�绘暟
- */
- private int maxTotal = 20;
- /**
- * 鏈�灏忕┖闂�
- */
- private int minIdle = 2;
-
- /**
- * 鍒濆鍖栬繛鎺ユ暟
- */
- private int initialSize = 3;
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/exception/EndPointNotFoundException.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/exception/EndPointNotFoundException.java
deleted file mode 100644
index 0388c2f..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/exception/EndPointNotFoundException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.mes.milo.exception;
-
-/**
- * 绫� EndPointNotFoundException 鍔熻兘鎻忚堪锛�
- *
- * @author mes
- * @version 0.0.1
- * @date 2021/09/04 17:03
- */
-public class EndPointNotFoundException extends RuntimeException {
- public EndPointNotFoundException() {
- super();
- }
-
- public EndPointNotFoundException(String message) {
- super(message);
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/exception/IdentityNotFoundException.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/exception/IdentityNotFoundException.java
deleted file mode 100644
index afd69f2..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/exception/IdentityNotFoundException.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.mes.milo.exception;
-
-/**
- * 绫� IdentityNotFoundException 鍔熻兘鎻忚堪锛�
- *
- * @author mes
- * @version 0.0.1
- * @date 2021/09/15 09:35
- */
-public class IdentityNotFoundException extends RuntimeException {
- public IdentityNotFoundException(String message) {
- super(message);
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/model/ReadWriteEntity.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/model/ReadWriteEntity.java
deleted file mode 100644
index 5276365..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/model/ReadWriteEntity.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.mes.milo.model;
-
-import lombok.*;
-import lombok.experimental.Accessors;
-import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
-
-/**
- * @author mes
- * @version 0.0.1
- * @desc
- * @since 2020/4/13
- */
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-@Accessors(chain = true)
-@ToString
-public class ReadWriteEntity {
-
- private String identifier;
-
- private Object value;
-
- private DataValue dataValue;
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/model/WriteEntity.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/model/WriteEntity.java
deleted file mode 100644
index 748781c..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/model/WriteEntity.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.mes.milo.model;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.experimental.Accessors;
-import org.eclipse.milo.opcua.stack.core.types.builtin.Variant;
-
-/**
- * @author mes
- * @version 0.0.1
- * @since 2020/4/13
- */
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-@Accessors(chain = true)
-public class WriteEntity {
- private String identifier;
- private Variant variant;
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/pool/MiloConnectPool.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/pool/MiloConnectPool.java
deleted file mode 100644
index aa13b70..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/pool/MiloConnectPool.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.mes.milo.pool;
-
-import com.mes.milo.configuration.MiloProperties;
-import org.apache.commons.pool2.KeyedPooledObjectFactory;
-import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
-import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-
-/**
- * 绫� MiloConnectPool 鍔熻兘鎻忚堪锛�<br/>
- *
- * @author mes
- * @version 0.0.1
- * @date 2023/5/4 19:17
- */
-public class MiloConnectPool extends GenericKeyedObjectPool<MiloProperties.Config, OpcUaClient> {
-
- public MiloConnectPool(KeyedPooledObjectFactory<MiloProperties.Config, OpcUaClient> factory) {
- super(factory);
- }
-
- public MiloConnectPool(KeyedPooledObjectFactory<MiloProperties.Config, OpcUaClient> factory, GenericKeyedObjectPoolConfig<OpcUaClient> config) {
- super(factory, config);
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/BrowseNodeRunner.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/BrowseNodeRunner.java
deleted file mode 100644
index 6b3ba57..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/BrowseNodeRunner.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.mes.milo.runner;
-
-import com.mes.milo.utils.CustomUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.sdk.client.nodes.UaNode;
-import org.eclipse.milo.opcua.stack.core.UaException;
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-/**
- * @author mes
- * @version 0.0.1
- * @since 2020/4/14
- */
-@Slf4j
-public class BrowseNodeRunner {
- /**
- * 瑕佽鐨勮妭鐐�
- */
- private final String browseRoot;
-
- public BrowseNodeRunner(String browseRoot) {
- this.browseRoot = browseRoot;
- }
-
- public List<String> run(OpcUaClient opcUaClient) {
- NodeId nodeId = CustomUtil.parseNodeId(browseRoot);
- return browseNode(browseRoot, opcUaClient, nodeId);
- }
-
- private List<String> browseNode(String prefix, OpcUaClient client, NodeId browseRoot) {
- List<String> nodesList = new ArrayList<>();
- try {
- List<? extends UaNode> nodes = client.getAddressSpace().browseNodes(browseRoot);
-
- nodes = nodes.stream().filter(item -> !Objects.requireNonNull(item.getBrowseName().getName()).startsWith("_")).collect(Collectors.toList());
-
- for (UaNode node : nodes) {
- String sub = prefix + "." + node.getBrowseName().getName();
-
- // recursively browse to children
- List<String> browseNode = browseNode(sub, client, node.getNodeId());
- if (browseNode.isEmpty()) {
- nodesList.add(sub);
- } else {
- nodesList.addAll(browseNode(sub, client, node.getNodeId()));
- }
- }
- } catch (UaException e) {
- log.error("Browsing nodeId={} failed: {}", browseRoot, e.getMessage(), e);
- }
- return nodesList;
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/BrowseRunner.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/BrowseRunner.java
deleted file mode 100644
index 2f93c84..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/BrowseRunner.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.mes.milo.runner;
-
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.sdk.client.nodes.UaNode;
-import org.eclipse.milo.opcua.stack.core.Identifiers;
-import org.eclipse.milo.opcua.stack.core.UaException;
-import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-/**
- * @author mes
- * @version 0.0.1
- * @since 2020/4/14
- */
-@Slf4j
-public class BrowseRunner {
-
- public List<String> run(OpcUaClient opcUaClient) {
- List<String> nodesList = new ArrayList<>();
- try {
- List<? extends UaNode> nodes = opcUaClient.getAddressSpace().browseNodes(Identifiers.ObjectsFolder);
-
- nodesList.addAll(nodes.stream().filter(item -> !Objects.requireNonNull(item.getBrowseName().getName()).startsWith("_")
- && Objects.equals(item.getBrowseName().getNamespaceIndex(), UShort.valueOf(2)))
- .map(item -> item.getBrowseName().getName()).collect(Collectors.toList()));
- } catch (UaException e) {
- log.error("閬嶅巻鏍硅妭鐐瑰紓甯革細{}", e.getMessage(), e);
- }
- return nodesList;
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/ReadValuesRunner.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/ReadValuesRunner.java
deleted file mode 100644
index 74772d5..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/ReadValuesRunner.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.mes.milo.runner;
-
-import com.mes.milo.model.ReadWriteEntity;
-import com.mes.milo.utils.CustomUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
-import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode;
-import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author mes
- * @version 0.0.1
- * @desc
- * @since 2020/4/14
- */
-@Slf4j
-public class ReadValuesRunner {
- /**
- * 瑕佽鐨勭偣浣峫ist
- */
- private final List<String> identifiers;
-
- public ReadValuesRunner(List<String> identifiers) {
- this.identifiers = identifiers;
- }
-
- public List<ReadWriteEntity> run(OpcUaClient opcUaClient) {
- List<ReadWriteEntity> entityList = new ArrayList<>();
- try {
- List<NodeId> nodeIds = new ArrayList<>();
- identifiers.forEach(identifier -> nodeIds.add(CustomUtil.parseNodeId(identifier)));
- // 璇诲彇鎸囧畾鐐逛綅鐨勫�硷紝10s瓒呮椂
- List<DataValue> dataValues = opcUaClient.readValues(10000, TimestampsToReturn.Both, nodeIds).get();
- if (dataValues.size() == identifiers.size()) {
- for (int i = 0; i < identifiers.size(); i++) {
- String id = identifiers.get(i);
- Object value = dataValues.get(i).getValue().getValue();
- StatusCode status = dataValues.get(i).getStatusCode();
- assert status != null;
- if (status.isGood()) {
- log.info("璇诲彇鐐逛綅 '{}' 鐨勫�间负 {}", id, value);
- }
- entityList.add(ReadWriteEntity.builder()
- .identifier(id)
- .value(value)
- .dataValue(dataValues.get(i))
- .build());
- }
- }
- } catch (Exception e) {
- log.error("璇诲�兼椂鍑虹幇浜嗗紓甯革細{}", e.getMessage(), e);
- }
- return entityList;
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/WriteValuesRunner.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/WriteValuesRunner.java
deleted file mode 100644
index 9ff7e71..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/WriteValuesRunner.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.mes.milo.runner;
-
-import com.mes.milo.model.WriteEntity;
-import com.mes.milo.utils.CustomUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
-import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author mes
- * @version 0.0.1
- * @since 2020/4/14
- */
-@Slf4j
-public class WriteValuesRunner {
- private final List<WriteEntity> entities;
-
- public WriteValuesRunner(List<WriteEntity> entities) {
- this.entities = entities;
- }
-
- public void run(OpcUaClient opcUaClient) {
- try {
- if (!entities.isEmpty()) {
- List<NodeId> nodeIds = new LinkedList<>();
- List<DataValue> dataValues = new LinkedList<>();
- for (WriteEntity entity : entities) {
- nodeIds.add(CustomUtil.parseNodeId(entity.getIdentifier()));
- dataValues.add(new DataValue(entity.getVariant(), null, null));
- }
-
- List<StatusCode> statusCodeList = opcUaClient.writeValues(nodeIds, dataValues).join();
- for (int i = 0; i < statusCodeList.size(); i++) {
- if (statusCodeList.get(i).isGood()) {
- log.info("灏嗗�� '{}' 鍐欏叆鍒扮偣浣嶏細{} 鎴愬姛", dataValues.get(i).getValue(), nodeIds.get(i));
- } else {
- log.error("鐐逛綅锛歿} 鍐欏叆鏃跺嚭鐜颁簡寮傚父锛歿}", nodeIds.get(i), statusCodeList.get(i));
- }
- }
- }
- } catch (Exception e) {
- log.error("鎵归噺鍐欏�煎嚭鐜板紓甯稿嚭鐜颁簡寮傚父锛歿}", e.getMessage(), e);
- }
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/subscription/SubscriptionCallback.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/subscription/SubscriptionCallback.java
deleted file mode 100644
index a31cee0..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/subscription/SubscriptionCallback.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.mes.milo.runner.subscription;
-
-import org.eclipse.milo.opcua.sdk.client.subscriptions.ManagedDataItem;
-import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
-
-/**
- * 绫� SubscriptionCallback 鍔熻兘鎻忚堪锛�<br/>
- *
- * @author mes
- * @version 0.0.1
- * @date 2023/5/8 22:14
- */
-public interface SubscriptionCallback {
-
- void onSubscribe(ManagedDataItem dataItem, DataValue value) throws Exception;
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/subscription/SubscriptionRunner.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/subscription/SubscriptionRunner.java
deleted file mode 100644
index 3cc0db3..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/runner/subscription/SubscriptionRunner.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.mes.milo.runner.subscription;
-
-import com.mes.milo.utils.CustomUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscription;
-import org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscriptionManager;
-import org.eclipse.milo.opcua.sdk.client.subscriptions.ManagedDataItem;
-import org.eclipse.milo.opcua.sdk.client.subscriptions.ManagedSubscription;
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
-import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode;
-import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * 绫� SubscriptionRunner 鍔熻兘鎻忚堪锛�
- *
- * @author mes
- * @version 0.0.1
- * @date 2022/01/01 23:49
- */
-@Slf4j
-public class SubscriptionRunner {
- /**
- * 鐐逛綅list
- */
- private final List<String> identifiers;
-
- private final double samplingInterval;
-
- public SubscriptionRunner(List<String> identifiers) {
- this.identifiers = identifiers;
- this.samplingInterval = 1000.0D;
- }
-
- public SubscriptionRunner(List<String> identifiers, double samplingInterval) {
- this.identifiers = identifiers;
- this.samplingInterval = samplingInterval;
- }
-
- public void run(OpcUaClient opcUaClient, SubscriptionCallback callback) {
-
- final CountDownLatch downLatch = new CountDownLatch(1);
-
- //娣诲姞璁㈤槄鐩戝惉鍣紝鐢ㄤ簬澶勭悊鏂嚎閲嶈繛鍚庣殑璁㈤槄闂
- opcUaClient.getSubscriptionManager().addSubscriptionListener(new CustomSubscriptionListener(opcUaClient, callback));
-
- //澶勭悊璁㈤槄閫昏緫
- handler(opcUaClient, callback);
-
- try {
- //鎸佺画鐩戝惉
- downLatch.await();
- } catch (Exception e) {
- log.error("璁㈤槄鏃跺嚭鐜颁簡寮傚父锛歿}", e.getMessage(), e);
- }
- }
-
- private void handler(OpcUaClient opcUaClient, SubscriptionCallback callback) {
- try {
- //鍒涘缓璁㈤槄
- ManagedSubscription subscription = ManagedSubscription.create(opcUaClient, samplingInterval);
- subscription.setDefaultSamplingInterval(samplingInterval);
- subscription.setDefaultQueueSize(UInteger.valueOf(10));
-
- List<NodeId> nodeIdList = new ArrayList<>();
- for (String identifier : identifiers) {
- nodeIdList.add(CustomUtil.parseNodeId(identifier));
- }
- List<ManagedDataItem> dataItemList = subscription.createDataItems(nodeIdList);
- for (ManagedDataItem dataItem : dataItemList) {
- dataItem.addDataValueListener((item) -> {
- try {
- callback.onSubscribe
- (dataItem, item);
- } catch (Exception e) {
- e.printStackTrace();
- }
- });
- }
- } catch (Exception e) {
- log.error("璁㈤槄鏃跺嚭鐜颁簡寮傚父锛歿}", e.getMessage(), e);
- }
- }
-
- private class CustomSubscriptionListener implements UaSubscriptionManager.SubscriptionListener {
- private final OpcUaClient client;
- private final SubscriptionCallback callback;
-
- public CustomSubscriptionListener(OpcUaClient client, SubscriptionCallback callback) {
- this.client = client;
- this.callback = callback;
- }
-
- /**
- * 閲嶈繛鏃� 灏濊瘯鎭㈠涔嬪墠鐨勮闃呭け璐ユ椂 浼氳皟鐢ㄦ鏂规硶
- *
- * @param uaSubscription 璁㈤槄
- * @param statusCode 鐘舵��
- */
- @Override
- public void onSubscriptionTransferFailed(UaSubscription uaSubscription, StatusCode statusCode) {
- log.debug("鎭㈠璁㈤槄澶辫触 闇�瑕侀噸鏂拌闃�");
- //鍦ㄥ洖璋冩柟娉曚腑閲嶆柊璁㈤槄
- handler(client, callback);
- }
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/service/MiloService.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/service/MiloService.java
deleted file mode 100644
index 45c5658..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/service/MiloService.java
+++ /dev/null
@@ -1,553 +0,0 @@
-package com.mes.milo.service;
-
-import com.mes.milo.configuration.MiloProperties;
-import com.mes.milo.model.ReadWriteEntity;
-import com.mes.milo.model.WriteEntity;
-import com.mes.milo.pool.MiloConnectPool;
-import com.mes.milo.runner.BrowseNodeRunner;
-import com.mes.milo.runner.BrowseRunner;
-import com.mes.milo.runner.ReadValuesRunner;
-import com.mes.milo.runner.WriteValuesRunner;
-import com.mes.milo.runner.subscription.SubscriptionCallback;
-import com.mes.milo.runner.subscription.SubscriptionRunner;
-import com.mes.milo.utils.CustomUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.stack.core.types.builtin.Variant;
-import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author mes
- * @date 2020/4/25
- * @desc milo-spring-boot-starter
- * @since 0.0.1
- */
-@Service
-@Slf4j
-public class MiloService {
- private final MiloConnectPool connectPool;
- private final MiloProperties properties;
-
- public MiloService(MiloConnectPool connectPool, MiloProperties properties) {
- this.connectPool = connectPool;
- this.properties = properties;
- }
-
- /**
- * 閬嶅巻OPC UA鏈嶅姟鍣ㄦ牴鑺傜偣
- *
- * @return 鏍硅妭鐐瑰垪琛�
- */
- public List<String> browseRoot() throws Exception {
- return browseRoot(null);
- }
-
- /**
- * 閬嶅巻OPC UA鏈嶅姟鍣ㄦ牴鑺傜偣
- *
- * @param clientName 閰嶇疆key
- * @return 鏍硅妭鐐瑰垪琛�
- */
- public List<String> browseRoot(String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- BrowseRunner runner = new BrowseRunner();
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- return runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- return Collections.emptyList();
- }
-
- /**
- * 閬嶅巻OPC UA鏈嶅姟鍣ㄦ寚瀹氳妭鐐�
- *
- * @param browseRoot 鑺傜偣鍚嶇О
- * @return 鎸囧畾鑺傜偣 tag鍒楄〃
- */
- public List<String> browseNode(String browseRoot) throws Exception {
- return browseNode(browseRoot, null);
- }
-
- /**
- * 閬嶅巻OPC UA鏈嶅姟鍣ㄦ寚瀹氳妭鐐�
- *
- * @param browseRoot 鑺傜偣鍚嶇О
- * @param clientName 閰嶇疆key
- * @return 鎸囧畾鑺傜偣 tag鍒楄〃
- */
- public List<String> browseNode(String browseRoot, String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- BrowseNodeRunner runner = new BrowseNodeRunner(browseRoot);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- return runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- return Collections.emptyList();
- }
-
- /**
- * 鎸囧畾绫诲瀷 鍐欏叆kep鐐逛綅鍊�
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- */
- public void writeSpecifyType(WriteEntity entity) throws Exception {
- writeSpecifyType(Collections.singletonList(entity));
- }
-
- /**
- * 鎸囧畾绫诲瀷 鍐欏叆kep鐐逛綅鍊�
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeSpecifyType(WriteEntity entity, String clientName) throws Exception {
- writeSpecifyType(Collections.singletonList(entity), clientName);
- }
-
- /**
- * 鎸囧畾绫诲瀷 鍐欏叆kep鐐逛綅鍊硷紝鍙壒閲忓啓鍏ヤ笉鍚岀被鍨嬬殑鍊�
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- */
- public void writeSpecifyType(List<WriteEntity> entities) throws Exception {
- writeSpecifyType(entities, null);
- }
-
- /**
- * 鎸囧畾绫诲瀷 鍐欏叆kep鐐逛綅鍊硷紝鍙壒閲忓啓鍏ヤ笉鍚岀被鍨嬬殑鍊�
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeSpecifyType(List<WriteEntity> entities, String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- WriteValuesRunner runner = new WriteValuesRunner(entities);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- }
-
- /**
- * 鍐欏叆kep鐐逛綅鍊�
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcUa(ReadWriteEntity entity) throws Exception {
- writeToOpcUa(Collections.singletonList(entity));
- }
-
- /**
- * 鍐欏叆kep鐐逛綅鍊�
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcUa(ReadWriteEntity entity, String clientName) throws Exception {
- writeToOpcUa(Collections.singletonList(entity), clientName);
- }
-
- /**
- * 鍐欏叆kep鐐逛綅鍊�
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcUa(List<ReadWriteEntity> entities) throws Exception {
- writeToOpcUa(entities, null);
- }
-
- /**
- * 鍐欏叆kep鐐逛綅鍊�
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcUa(List<ReadWriteEntity> entities, String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- List<WriteEntity> writeEntityList = new ArrayList<>();
- if (!entities.isEmpty()) {
- for (ReadWriteEntity entity : entities) {
- writeEntityList.add(WriteEntity.builder()
- .identifier(entity.getIdentifier())
- .variant(new Variant(entity.getValue()))
- .build());
- }
- }
- WriteValuesRunner runner = new WriteValuesRunner(writeEntityList);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Char<br/>
- * 8浣嶅甫绗﹀彿鏁存暟
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcChar(ReadWriteEntity entity) throws Exception {
- writeToOpcChar(Collections.singletonList(entity));
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Char<br/>
- * 8浣嶅甫绗﹀彿鏁存暟
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcChar(ReadWriteEntity entity, String clientName) throws Exception {
- writeToOpcChar(Collections.singletonList(entity), clientName);
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Char<br/>
- * 8浣嶅甫绗﹀彿鏁存暟
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcChar(List<ReadWriteEntity> entities) throws Exception {
- writeToOpcChar(entities, null);
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Char<br/>
- * 8浣嶅甫绗﹀彿鏁存暟
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcChar(List<ReadWriteEntity> entities, String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- List<WriteEntity> writeEntityList = new ArrayList<>();
- if (!entities.isEmpty()) {
- for (ReadWriteEntity entity : entities) {
- writeEntityList.add(WriteEntity.builder()
- .identifier(entity.getIdentifier())
- .variant(new Variant(((Integer) entity.getValue()).byteValue()))
- .build());
- }
- }
- WriteValuesRunner runner = new WriteValuesRunner(writeEntityList);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Byte<br/>
- * 8浣嶆棤绗﹀彿鏁存暟
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcByte(ReadWriteEntity entity) throws Exception {
- writeToOpcByte(Collections.singletonList(entity));
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Byte<br/>
- * 8浣嶆棤绗﹀彿鏁存暟
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcByte(ReadWriteEntity entity, String clientName) throws Exception {
- writeToOpcByte(Collections.singletonList(entity), clientName);
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Byte<br/>
- * 8浣嶆棤绗﹀彿鏁存暟
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcByte(List<ReadWriteEntity> entities) throws Exception {
- writeToOpcByte(entities, null);
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Byte<br/>
- * 8浣嶆棤绗﹀彿鏁存暟
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcByte(List<ReadWriteEntity> entities, String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- List<WriteEntity> writeEntityList = new ArrayList<>();
- if (!entities.isEmpty()) {
- for (ReadWriteEntity entity : entities) {
- writeEntityList.add(WriteEntity.builder()
- .identifier(entity.getIdentifier())
- .variant(new Variant(Unsigned.ubyte((Integer) entity.getValue())))
- .build());
- }
- }
- WriteValuesRunner runner = new WriteValuesRunner(writeEntityList);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Short<br/>
- * 16浣嶅甫绗﹀彿鏁存暟
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcShort(ReadWriteEntity entity) throws Exception {
- writeToOpcShort(Collections.singletonList(entity));
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Short<br/>
- * 16浣嶅甫绗﹀彿鏁存暟
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcShort(ReadWriteEntity entity, String clientName) throws Exception {
- writeToOpcShort(Collections.singletonList(entity), clientName);
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Short<br/>
- * 16浣嶅甫绗﹀彿鏁存暟
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcShort(List<ReadWriteEntity> entities) throws Exception {
- writeToOpcShort(entities, null);
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Short<br/>
- * 16浣嶅甫绗﹀彿鏁存暟
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcShort(List<ReadWriteEntity> entities, String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- List<WriteEntity> writeEntityList = new ArrayList<>();
- if (!entities.isEmpty()) {
- for (ReadWriteEntity entity : entities) {
- writeEntityList.add(WriteEntity.builder()
- .identifier(entity.getIdentifier())
- .variant(new Variant(((Integer) entity.getValue()).shortValue()))
- .build());
- }
- }
- WriteValuesRunner runner = new WriteValuesRunner(writeEntityList);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Word<br/>
- * 16浣嶆棤绗﹀彿鏁存暟
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcWord(ReadWriteEntity entity) throws Exception {
- writeToOpcWord(Collections.singletonList(entity));
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Word<br/>
- * 16浣嶆棤绗﹀彿鏁存暟
- *
- * @param entity 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcWord(ReadWriteEntity entity, String clientName) throws Exception {
- writeToOpcWord(Collections.singletonList(entity), clientName);
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Word<br/>
- * 16浣嶆棤绗﹀彿鏁存暟
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- */
- public void writeToOpcWord(List<ReadWriteEntity> entities) throws Exception {
- writeToOpcWord(entities, null);
- }
-
- /**
- * kepware 鏁版嵁绫诲瀷涓猴細Word<br/>
- * 16浣嶆棤绗﹀彿鏁存暟
- *
- * @param entities 寰呭啓鍏ユ暟鎹�
- * @param clientName 閰嶇疆key
- */
- public void writeToOpcWord(List<ReadWriteEntity> entities, String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- List<WriteEntity> writeEntityList = new ArrayList<>();
- if (!entities.isEmpty()) {
- for (ReadWriteEntity entity : entities) {
- writeEntityList.add(WriteEntity.builder()
- .identifier(entity.getIdentifier())
- .variant(new Variant(Unsigned.ushort((Integer) entity.getValue())))
- .build());
- }
- }
- WriteValuesRunner runner = new WriteValuesRunner(writeEntityList);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- }
-
- /**
- * 璇诲彇kep鐐逛綅鍊�
- *
- * @param id 鐐逛綅id
- * @return
- */
- public ReadWriteEntity readFromOpcUa(String id) throws Exception {
- return readFromOpcUa(id, null);
- }
-
- /**
- * 璇诲彇kep鐐逛綅鍊�
- *
- * @param id 鐐逛綅id
- * @param clientName 閰嶇疆key
- * @return
- */
- public ReadWriteEntity readFromOpcUa(String id, String clientName) throws Exception {
- List<ReadWriteEntity> entityList = readFromOpcUa(Collections.singletonList(id), clientName);
- if (!entityList.isEmpty()) {
- return entityList.get(0);
- }
- return null;
- }
-
- /**
- * 璇诲彇kep鐐逛綅鍊�
- *
- * @param ids 鐐逛綅id鏁扮粍
- * @return
- */
- public List<ReadWriteEntity> readFromOpcUa(List<String> ids) throws Exception {
- return readFromOpcUa(ids, null);
- }
-
- /**
- * 璇诲彇kep鐐逛綅鍊�
- *
- * @param ids 鐐逛綅id鏁扮粍
- * @param clientName 閰嶇疆key
- * @return
- */
- public List<ReadWriteEntity> readFromOpcUa(List<String> ids, String clientName) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- ReadValuesRunner runner = new ReadValuesRunner(ids);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- return runner.run(client);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- return new ArrayList<>();
- }
-
- /**
- * 璁㈤槄kep鐐逛綅鍊�
- *
- * @param ids 鐐逛綅id鏁扮粍
- * @return
- */
- public void subscriptionFromOpcUa(List<String> ids, SubscriptionCallback callback) throws Exception {
- subscriptionFromOpcUa(ids, 1000.0, callback);
- }
-
- /**
- * 璁㈤槄kep鐐逛綅鍊�
- *
- * @param ids 鐐逛綅id鏁扮粍
- * @param clientName 閰嶇疆key
- * @return
- */
- public void subscriptionFromOpcUa(List<String> ids, String clientName, SubscriptionCallback callback) throws Exception {
- subscriptionFromOpcUa(ids, 1000.0, clientName, callback);
- }
-
- /**
- * 璁㈤槄kep鐐逛綅鍊�
- *
- * @param ids 鐐逛綅id鏁扮粍
- * @param samplingInterval 璁㈤槄鏃堕棿闂撮殧 榛樿1000 ms
- * @return
- */
- public void subscriptionFromOpcUa(List<String> ids, double samplingInterval, SubscriptionCallback callback) throws Exception {
- subscriptionFromOpcUa(ids, samplingInterval, null, callback);
- }
-
- /**
- * 璁㈤槄kep鐐逛綅鍊�
- *
- * @param ids 鐐逛綅id鏁扮粍
- * @param samplingInterval 璁㈤槄鏃堕棿闂撮殧 榛樿1000 ms
- * @param clientName 閰嶇疆key
- * @return
- */
- public void subscriptionFromOpcUa(List<String> ids, double samplingInterval, String clientName, SubscriptionCallback callback) throws Exception {
- MiloProperties.Config config = CustomUtil.getConfig(properties, clientName);
- SubscriptionRunner runner = new SubscriptionRunner(ids, samplingInterval);
- OpcUaClient client = connectPool.borrowObject(config);
- if (client != null) {
- try {
- runner.run(client, callback);
- } finally {
- connectPool.returnObject(config, client);
- }
- }
- }
-
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/utils/CustomUtil.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/utils/CustomUtil.java
deleted file mode 100644
index 37df820..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/utils/CustomUtil.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package com.mes.milo.utils;
-
-import com.google.common.collect.Sets;
-import com.mes.milo.configuration.MiloProperties;
-import com.mes.milo.exception.EndPointNotFoundException;
-import com.mes.milo.exception.IdentityNotFoundException;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
-import org.springframework.util.StringUtils;
-
-import java.net.*;
-import java.util.*;
-
-/**
- * @author mes
- * @version 0.0.1
- * @desc
- * @since 2020/4/13
- */
-@Slf4j
-public class CustomUtil {
-
- private static final String OPC_UA_NOT_CONFIG = "璇烽厤缃甇PC UA鍦板潃淇℃伅";
-
- private CustomUtil() {
- }
-
- public static String getHostname() {
- try {
- return InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException var1) {
- return "localhost";
- }
- }
-
- public static Set<String> getHostnames(String address) {
- return getHostnames(address, true);
- }
-
- public static Set<String> getHostnames(String address, boolean includeLoopback) {
- HashSet<String> hostnames = Sets.newHashSet();
-
- try {
- InetAddress inetAddress = InetAddress.getByName(address);
- if (inetAddress.isAnyLocalAddress()) {
- try {
- Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
-
- for (NetworkInterface ni : Collections.list(nis)) {
- Collections.list(ni.getInetAddresses()).forEach((ia) -> {
- if (ia instanceof Inet4Address) {
- boolean loopback = ia.isLoopbackAddress();
- if (!loopback || includeLoopback) {
- hostnames.add(ia.getHostName());
- hostnames.add(ia.getHostAddress());
- hostnames.add(ia.getCanonicalHostName());
- }
- }
-
- });
- }
- } catch (SocketException var7) {
- log.warn("Failed to NetworkInterfaces for bind address: {}", address, var7);
- }
- } else {
- boolean loopback = inetAddress.isLoopbackAddress();
- if (!loopback || includeLoopback) {
- hostnames.add(inetAddress.getHostName());
- hostnames.add(inetAddress.getHostAddress());
- hostnames.add(inetAddress.getCanonicalHostName());
- }
- }
- } catch (UnknownHostException var8) {
- log.warn("Failed to get InetAddress for bind address: {}", address, var8);
- }
-
- return hostnames;
- }
-
- public static NodeId parseNodeId(String identifier) {
- NodeId nodeId = new NodeId(2, identifier);
- if (identifier.startsWith("ns=") && identifier.contains(";")) {
- nodeId = NodeId.parseOrNull(identifier);
- }
- if (nodeId == null) {
- throw new IdentityNotFoundException("NodeId 瑙f瀽澶辫触锛岃妫�鏌�");
- }
- return nodeId;
- }
-
- public static void verifyProperties(MiloProperties properties) {
- if (properties.getConfig().isEmpty()) {
- throw new EndPointNotFoundException(OPC_UA_NOT_CONFIG);
- }
- if (!StringUtils.hasText(properties.getPrimary())) {
- Set<String> keySet = properties.getConfig().keySet();
- properties.setPrimary(keySet.stream().findFirst().orElseThrow(() -> new EndPointNotFoundException(OPC_UA_NOT_CONFIG)));
- }
- properties.getConfig().forEach((key, config) -> {
- if (!StringUtils.hasText(config.getEndpoint())) {
- throw new EndPointNotFoundException(OPC_UA_NOT_CONFIG + ": " + key);
- }
- });
- }
-
- public static MiloProperties.Config getConfig(MiloProperties properties) {
- return getConfig(properties, null);
- }
-
- public static MiloProperties.Config getConfig(MiloProperties properties, String clientName) {
- Map<String, MiloProperties.Config> config = properties.getConfig();
- return StringUtils.hasText(clientName) ? config.get(clientName) : config.get(properties.getPrimary());
- }
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/utils/KeyStoreLoader.java b/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/utils/KeyStoreLoader.java
deleted file mode 100644
index ad4c6bb..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/utils/KeyStoreLoader.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package com.mes.milo.utils;
-
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.stack.client.security.DefaultClientCertificateValidator;
-import org.eclipse.milo.opcua.stack.core.security.DefaultTrustListManager;
-import org.eclipse.milo.opcua.stack.core.util.SelfSignedCertificateBuilder;
-import org.eclipse.milo.opcua.stack.core.util.SelfSignedCertificateGenerator;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.security.*;
-import java.security.cert.X509Certificate;
-import java.util.Arrays;
-import java.util.regex.Pattern;
-
-@Slf4j
-public class KeyStoreLoader {
-
- private static final Pattern IP_ADDR_PATTERN = Pattern.compile(
- "^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
-
- private static final String CLIENT_ALIAS = "client-ai";
- private static final char[] PASSWORD = "password".toCharArray();
-
- private X509Certificate clientCertificate;
- private X509Certificate[] clientCertificateChain;
- private KeyPair clientKeyPair;
- private DefaultClientCertificateValidator certificateValidator;
-
- public KeyStoreLoader load() throws Exception {
- Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security");
- Files.createDirectories(securityTempDir);
- if (!Files.exists(securityTempDir)) {
- throw new Exception("unable to create security dir: " + securityTempDir);
- }
-
- File pkiDir = securityTempDir.resolve("pki").toFile();
-
- log.info("security temp dir: {}", securityTempDir.toAbsolutePath());
-
- KeyStore keyStore = KeyStore.getInstance("PKCS12");
-
- Path serverKeyStore = securityTempDir.resolve("milo-client.pfx");
-
- DefaultTrustListManager trustListManager = new DefaultTrustListManager(pkiDir);
-
- certificateValidator = new DefaultClientCertificateValidator(trustListManager);
-
- log.info("Loading KeyStore at {}", serverKeyStore);
-
- if (!Files.exists(serverKeyStore)) {
- keyStore.load(null, PASSWORD);
-
- KeyPair keyPair = SelfSignedCertificateGenerator.generateRsaKeyPair(2048);
-
- SelfSignedCertificateBuilder builder = new SelfSignedCertificateBuilder(keyPair)
- .setCommonName("Milo Client")
- .setOrganization("kangaroohy")
- .setOrganizationalUnit("dev")
- .setLocalityName("Folsom")
- .setStateName("CA")
- .setCountryCode("US")
- .setApplicationUri("urn:kangaroohy:milo:client")
- .addDnsName("localhost")
- .addIpAddress("127.0.0.1");
-
- // Get as many hostnames and IP addresses as we can listed in the certificate.
- for (String hostname : CustomUtil.getHostnames("0.0.0.0")) {
- if (IP_ADDR_PATTERN.matcher(hostname).matches()) {
- builder.addIpAddress(hostname);
- } else {
- builder.addDnsName(hostname);
- }
- }
-
- X509Certificate certificate = builder.build();
-
- keyStore.setKeyEntry(CLIENT_ALIAS, keyPair.getPrivate(), PASSWORD, new X509Certificate[]{certificate});
- try (OutputStream out = Files.newOutputStream(serverKeyStore)) {
- keyStore.store(out, PASSWORD);
- }
- } else {
- try (InputStream in = Files.newInputStream(serverKeyStore)) {
- keyStore.load(in, PASSWORD);
- }
- }
-
- Key clientPrivateKey = keyStore.getKey(CLIENT_ALIAS, PASSWORD);
- if (clientPrivateKey instanceof PrivateKey) {
- clientCertificate = (X509Certificate) keyStore.getCertificate(CLIENT_ALIAS);
-
- clientCertificateChain = Arrays.stream(keyStore.getCertificateChain(CLIENT_ALIAS))
- .map(X509Certificate.class::cast)
- .toArray(X509Certificate[]::new);
-
- PublicKey clientPublicKey = clientCertificate.getPublicKey();
- clientKeyPair = new KeyPair(clientPublicKey, (PrivateKey) clientPrivateKey);
- }
-
- return this;
- }
-
- public X509Certificate getClientCertificate() {
- return clientCertificate;
- }
-
- public X509Certificate[] getClientCertificateChain() {
- return clientCertificateChain;
- }
-
- public DefaultClientCertificateValidator getCertificateValidator() {
- return certificateValidator;
- }
-
- public KeyPair getClientKeyPair() {
- return clientKeyPair;
- }
-
-}
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/resources/META-INF/spring.factories b/hangzhoumesParent/common/opcuaClient/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index dfcfa97..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,3 +0,0 @@
-# Auto Configure
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
- com.mes.milo.configuration.MiloAutoConfiguration
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/hangzhoumesParent/common/opcuaClient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
deleted file mode 100644
index eda2fe7..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ /dev/null
@@ -1 +0,0 @@
-com.mes.milo.configuration.MiloAutoConfiguration
\ No newline at end of file
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/resources/application.yml b/hangzhoumesParent/common/opcuaClient/src/main/resources/application.yml
deleted file mode 100644
index 1ea573c..0000000
--- a/hangzhoumesParent/common/opcuaClient/src/main/resources/application.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-mes:
- milo:
- primary: default
- config:
- default:
- endpoint: opc.tcp://zidonghua:49320
- security-policy: basic256sha256
- username: zsh
- password: 1qaz2wsx3edc4rfv
\ No newline at end of file
diff --git a/hangzhoumesParent/common/pom.xml b/hangzhoumesParent/common/pom.xml
index affa009..c8bb428 100644
--- a/hangzhoumesParent/common/pom.xml
+++ b/hangzhoumesParent/common/pom.xml
@@ -15,7 +15,6 @@
<modules>
<module>servicebase</module>
<module>springsecurity</module>
- <module>opcuaClient</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/hangzhoumesParent/common/servicebase/pom.xml b/hangzhoumesParent/common/servicebase/pom.xml
index 0605bf7..4bb9465 100644
--- a/hangzhoumesParent/common/servicebase/pom.xml
+++ b/hangzhoumesParent/common/servicebase/pom.xml
@@ -38,6 +38,13 @@
<artifactId>sdk-server</artifactId>
<version>0.6.8</version>
</dependency>
+ <dependency>
+ <groupId>com.kangaroohy</groupId>
+ <artifactId>milo-spring-boot-starter</artifactId>
+ <version>3.0.6.12</version>
+ </dependency>
+
+
</dependencies>
</project>
\ No newline at end of file
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/configuration/MiloAutoConfiguration.java b/hangzhoumesParent/common/servicebase/src/main/java/com/kangaroohy/milo/configuration/MiloAutoConfiguration.java
similarity index 95%
rename from hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/configuration/MiloAutoConfiguration.java
rename to hangzhoumesParent/common/servicebase/src/main/java/com/kangaroohy/milo/configuration/MiloAutoConfiguration.java
index 5e56b39..739b239 100644
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/configuration/MiloAutoConfiguration.java
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/kangaroohy/milo/configuration/MiloAutoConfiguration.java
@@ -1,8 +1,8 @@
-package com.mes.milo.configuration;
+package com.kangaroohy.milo.configuration;
-import com.mes.milo.pool.MiloConnectFactory;
-import com.mes.milo.pool.MiloConnectPool;
-import com.mes.milo.service.MiloService;
+import com.kangaroohy.milo.pool.MiloConnectFactory;
+import com.kangaroohy.milo.pool.MiloConnectPool;
+import com.kangaroohy.milo.service.MiloService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
diff --git a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/pool/MiloConnectFactory.java b/hangzhoumesParent/common/servicebase/src/main/java/com/kangaroohy/milo/pool/MiloConnectFactory.java
similarity index 95%
rename from hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/pool/MiloConnectFactory.java
rename to hangzhoumesParent/common/servicebase/src/main/java/com/kangaroohy/milo/pool/MiloConnectFactory.java
index f99202a..187eda4 100644
--- a/hangzhoumesParent/common/opcuaClient/src/main/java/com/mes/milo/pool/MiloConnectFactory.java
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/kangaroohy/milo/pool/MiloConnectFactory.java
@@ -1,9 +1,9 @@
-package com.mes.milo.pool;
+package com.kangaroohy.milo.pool;
-import com.mes.milo.configuration.MiloProperties;
-import com.mes.milo.exception.EndPointNotFoundException;
-import com.mes.milo.exception.IdentityNotFoundException;
-import com.mes.milo.utils.CustomUtil;
+import com.kangaroohy.milo.configuration.MiloProperties;
+import com.kangaroohy.milo.exception.EndPointNotFoundException;
+import com.kangaroohy.milo.exception.IdentityNotFoundException;
+import com.kangaroohy.milo.utils.CustomUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.pool2.KeyedPooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
diff --git a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Const.java b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Const.java
index 6b9a1de..46c9d01 100644
--- a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Const.java
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Const.java
@@ -180,4 +180,23 @@
public static final Integer UNLOAD_GLASS_OUT = 1;
public static final Integer UNLOAD_GLASS_DOWN = 2;
+
+ /**
+ * 鍘熺墖浠撳偍浠诲姟绫诲瀷
+ * 杩涚墖浠诲姟1
+ * 鍑虹墖浠诲姟2
+ */
+ public static final Integer RAW_GLASS_TASK_TYPE_IN = 1;
+ public static final Integer RAW_GLASS_TASK_TYPE_OUT = 2;
+ public static final Integer RAW_GLASS_TASK_TYPE_DISPATCH = 3;
+
+ /**
+ * 鍘熺墖浠撳偍浠诲姟绫诲瀷
+ * 杩涚墖浠诲姟1
+ * 鍑虹墖浠诲姟2
+ */
+ public static final Integer ENGINEERING_NEW = 0;
+ public static final Integer ENGINEERING_RUNNING = 1;
+
+
}
diff --git a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/entity/vo/UpPattenUsageVO.java b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/entity/vo/UpPattenUsageVO.java
new file mode 100644
index 0000000..eda97c0
--- /dev/null
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/entity/vo/UpPattenUsageVO.java
@@ -0,0 +1,14 @@
+package com.mes.uppattenusage.entity.vo;
+
+import com.mes.uppattenusage.entity.UpPattenUsage;
+import lombok.Data;
+
+/**
+ * @Author : zhoush
+ * @Date: 2024/10/12 15:43
+ * @Description:
+ */
+@Data
+public class UpPattenUsageVO extends UpPattenUsage {
+ private String groupNumber;
+}
diff --git a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/mapper/UpPattenUsageMapper.java b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/mapper/UpPattenUsageMapper.java
index 154e50d..42e4308 100644
--- a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/mapper/UpPattenUsageMapper.java
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/uppattenusage/mapper/UpPattenUsageMapper.java
@@ -2,7 +2,10 @@
import com.github.yulichang.base.MPJBaseMapper;
import com.mes.uppattenusage.entity.UpPattenUsage;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.mes.uppattenusage.entity.vo.UpPattenUsageVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
/**
* <p>
@@ -14,4 +17,5 @@
*/
public interface UpPattenUsageMapper extends MPJBaseMapper<UpPattenUsage> {
+ List<UpPattenUsageVO> queryRawGlassByEngineeringId(@Param("engineeringId") String engineerId);
}
diff --git a/hangzhoumesParent/common/servicebase/src/main/resources/mapper/UpPattenUsageMapper.xml b/hangzhoumesParent/common/servicebase/src/main/resources/mapper/UpPattenUsageMapper.xml
new file mode 100644
index 0000000..951829c
--- /dev/null
+++ b/hangzhoumesParent/common/servicebase/src/main/resources/mapper/UpPattenUsageMapper.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.mes.uppattenusage.mapper.UpPattenUsageMapper">
+
+ <resultMap id="baseMap" type="com.mes.uppattenusage.entity.vo.UpPattenUsageVO">
+ <result column="id" property="id"/>
+ <result column="engineering_id" property="engineeringId"/>
+ <result column="films_id" property="filmsId"/>
+ <result column="width" property="width"/>
+ <result column="height" property="height"/>
+ <result column="thickness" property="thickness"/>
+ <result column="layout_sequence" property="layoutSequence"/>
+ <result column="state" property="state"/>
+ <result column="group_number" property="groupNumber"/>
+ </resultMap>
+ <select id="queryRawGlassByEngineeringId" resultType="com.mes.uppattenusage.entity.vo.UpPattenUsageVO">
+ SET @prev_width := NULL;
+ SET @prev_height := NULL;
+ SET @counter := 0;
+
+ SELECT t.*,
+ @counter := IF(@prev_width = width and @prev_height = height, @counter, @counter + 1) AS group_number,
+ @prev_width := width,
+ @prev_height := height
+ FROM up_patten_usage t
+ where t.engineering_id = #{engineeringId}
+ and t.state = 0
+ ORDER BY t.layout_sequence
+ </select>
+
+
+</mapper>
\ No newline at end of file
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassPushMessage.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassPushMessage.java
index a06a933..a3c0e25 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassPushMessage.java
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassPushMessage.java
@@ -2,10 +2,7 @@
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mes.rawglassdetails.entity.RawGlassStorageDetails;
-import com.mes.rawglassdetails.service.RawGlassStorageDetailsService;
import com.mes.rawglassstation.service.RawGlassStorageStationService;
import com.mes.rawglasstask.entity.RawGlassStorageTask;
import com.mes.rawglasstask.service.RawGlassStorageTaskService;
@@ -16,7 +13,6 @@
import javax.annotation.Resource;
import java.util.List;
-import java.util.stream.Collectors;
/**
* @author wangfei
@@ -25,56 +21,26 @@
@Component
public class RawGlassPushMessage {
- @Resource private RawGlassStorageStationService rawGlassStorageStationService;
+ @Resource
+ private RawGlassStorageStationService rawGlassStorageStationService;
- @Resource private RawGlassStorageTaskService rawGlassStorageTaskService;
+ @Resource
+ private RawGlassStorageTaskService rawGlassStorageTaskService;
- @Resource private RawGlassStorageDetailsService rawGlassStorageDetailsService;
-
- @Scheduled(fixedDelay = 2000)
- public void sendRawGlassMessage() {
- log.info("鍙戦�佷换鍔′俊鎭拰鏋跺瓙淇℃伅");
- JSONObject jsonObject = new JSONObject();
- List<RawGlassStorageDetails> rawStationDetailsList =
- rawGlassStorageStationService.listRawGlassDetails();
- List<RawGlassStorageTask> tasks = rawGlassStorageTaskService.listRawGlassTask();
- jsonObject.append("rawStationDetailsList", rawStationDetailsList);
- jsonObject.append("tasks", tasks);
-// log.info("鑾峰彇鍒扮殑宸ヤ綅璇︽儏鍙婁换鍔′俊鎭负锛歿}", jsonObject);
-
- List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("rawGlass");
- if (CollectionUtil.isNotEmpty(sendwServer)) {
- sendwServer.stream().forEach(e->{
- e.sendMessage(String.valueOf(jsonObject));
- });
+ @Scheduled(fixedDelay = 2000)
+ public void sendRawGlassMessage() {
+ log.info("鍙戦�佷换鍔′俊鎭拰鏋跺瓙淇℃伅");
+ JSONObject jsonObject = new JSONObject();
+ List<RawGlassStorageDetails> rawStationDetailsList =
+ rawGlassStorageStationService.listRawGlassDetails();
+ List<RawGlassStorageTask> tasks = rawGlassStorageTaskService.listRawGlassTask();
+ jsonObject.append("rawStationDetailsList", rawStationDetailsList);
+ jsonObject.append("tasks", tasks);
+ List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("rawGlass");
+ if (CollectionUtil.isNotEmpty(sendwServer)) {
+ sendwServer.stream().forEach(e -> {
+ e.sendMessage(String.valueOf(jsonObject));
+ });
+ }
}
- }
-
- /** todo:鍏ュ簱浠诲姟锛氬悐瑁呬綅鏈夌幓鐠冿紝鍏堝幓宸ヤ綅琛ㄦ煡璇㈢┖鏍煎瓙锛岀敓鎴愬叆搴撲换鍔′粠鍚婅浣嶅埌鐩爣鏍煎瓙 */
-// @Scheduled(fixedDelay = 1000)
-// public void sendRawGlassMessage() {
-//// List<RawGlassStorageDetails> rawGlassStorageDetailsList = rawGlassStorageDetailsService.List(new RawGlassStorageDetails())
-// Wrapper<RawGlassStorageDetails> queryWrapper = null;
-// List<RawGlassStorageDetails> detailsList = rawGlassStorageDetailsService.list(null);
-// queryWrapper.eq(RawGlassStorageDetails::getState, 100);
-// if(detailsList.size() >0){
-// //鏌ユ壘鏍煎瓙琛╠etails绌烘牸瀛�
-// List<String> slotIds = detailsList.stream()
-// .map(RawGlassStorageDetails::getSlotId)
-// .collect(Collectors.toList());
-// list(new LambdaQueryWrapper<RawGlassStorageTask>()
-// .in(CollectionUtil.isNotEmpty(request.getState()), RawGlassStorageTask::getState, request.getState())
-// .in(CollectionUtil.isNotEmpty(request.getSlotId()), RawGlassStorageTask::getSlotId, request.getSlotId())
-// .orderByDesc(RawGlassStorageTask::getCreateTime));
-// }if(slotIds.size()>0){
-// //鐢熸垚鍏ュ簱浠诲姟
-// }
-//
-// }
-
-
-
- /** todo:鍑哄簱浠诲姟锛�1銆佺偣鍑哄簱锛岀珛椹敓鎴愬嚭鐗囦换鍔� 2銆佺偣鍑哄簱淇敼宸ヤ綅璇︽儏鍐呯殑鐘舵�佷负寰呭嚭搴擄紝瀹氭椂浠诲姟鎵弿鐢熸垚鍑哄簱浠诲姟 */
-
- /** todo:鍘熺墖璋冨害锛�1銆佹煡璇㈠伐绋嬪師鐗囪〃锛屾寜鐓ч『搴忓皢鍘熺墖鏀惧叆涓婄墖1鍙蜂綅锛屽悗缁師鐗囨斁涓婄墖2鍙蜂綅锛屽嚭鐜板昂瀵告浛鎹紝鍒ゆ柇鍘熶笂鐗囦綅鏄惁鏈夌幓鐠冿紝鏈� 鍏堝嚭鍚庤繘锛屾棤 鐩存帴杩涚墖 */
}
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java
new file mode 100644
index 0000000..66e13c4
--- /dev/null
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/job/RawGlassTask.java
@@ -0,0 +1,235 @@
+package com.mes.job;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.mes.common.config.Const;
+import com.mes.engineering.entity.Engineering;
+import com.mes.engineering.mapper.EngineeringMapper;
+import com.mes.milo.model.ReadWriteEntity;
+import com.mes.milo.service.MiloService;
+import com.mes.rawglassdetails.entity.RawGlassStorageDetails;
+import com.mes.rawglassdetails.service.RawGlassStorageDetailsService;
+import com.mes.rawglassstation.entity.RawGlassStorageStation;
+import com.mes.rawglassstation.service.RawGlassStorageStationService;
+import com.mes.rawglasstask.entity.RawGlassStorageTask;
+import com.mes.rawglasstask.service.RawGlassStorageTaskService;
+import com.mes.uppattenusage.entity.vo.UpPattenUsageVO;
+import com.mes.uppattenusage.mapper.UpPattenUsageMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Author : zhoush
+ * @Date: 2024/10/11 16:13
+ * @Description:
+ */
+@Slf4j
+@Component
+public class RawGlassTask {
+
+ @Autowired
+ private RawGlassStorageStationService rawGlassStorageStationService;
+ @Autowired
+ private RawGlassStorageDetailsService rawGlassStorageDetailsService;
+
+ @Autowired
+ private RawGlassStorageTaskService rawGlassStorageTaskService;
+
+ @Resource
+ private EngineeringMapper engineeringMapper;
+ @Resource
+ private UpPattenUsageMapper upPattenUsageMapper;
+
+ @Autowired
+ private MiloService miloService;
+
+ private static final List<String> liftingStation = Arrays.asList("1", "2");
+ private static final List<String> loadGlassStation = Arrays.asList("3", "4", "5", "6");
+
+ /**
+ * 鍏ュ簱浠诲姟锛氬悐瑁呬綅鏈夌幓鐠冿紝鍏堝幓宸ヤ綅琛ㄦ煡璇㈢┖鏍煎瓙锛岀敓鎴愬叆搴撲换鍔′粠鍚婅浣嶅埌鐩爣鏍煎瓙
+ *
+ * @throws Exception
+ */
+ @Scheduled(fixedDelay = 1000)
+ public void warehouseTask() throws Exception {
+ ReadWriteEntity entity = miloService.readFromOpcUa("rawglass.device.request");
+ String value = entity.getValueString();
+ if (!"1".equals(value)) {
+ log.info("澶ц溅蹇欑");
+ return;
+ }
+ List<RawGlassStorageDetails> rawGlassList = rawGlassStorageDetailsService.list(new LambdaQueryWrapper<RawGlassStorageDetails>()
+ .eq(RawGlassStorageDetails::getState, Const.GLASS_STATE_IN)
+ .inSql(RawGlassStorageDetails::getSlotId, "select slot from raw_glass_storage_station where enable_state = 1 and slot in (1,2)"));
+ if (CollectionUtil.isEmpty(rawGlassList)) {
+ log.info("鍚婅浣嶈绂佺敤鎴栨病鏈夌幓鐠�");
+ return;
+ }
+ //鏌ヨ宸ヤ綅淇℃伅鏄惁鏈�
+ List<RawGlassStorageStation> stationList = rawGlassStorageStationService.list(new LambdaQueryWrapper<RawGlassStorageStation>().notInSql(RawGlassStorageStation::getSlot, "select slot_id from raw_glass_storage_details where state = '100'")
+ .eq(RawGlassStorageStation::getEnableState, Const.SLOT_ON));
+ if (CollectionUtil.isEmpty(stationList)) {
+ log.info("娌℃湁绌虹殑宸ヤ綅");
+ return;
+ }
+ //鐢熸垚杩涚浠诲姟
+ generateTask(rawGlassList.get(0).getSlotId(), stationList.get(0).getSlot(),
+ rawGlassList.get(0).getRemainQuantity(), Const.RAW_GLASS_TASK_TYPE_IN);
+ //鐢熸垚宸ヤ綅浠诲姟锛屽皢鍚婅浣嶇殑鐜荤拑鐘舵�佹敼浣嶈繘绗间腑
+ }
+
+
+ /**
+ * 鍑哄簱浠诲姟锛�1銆佺偣鍑哄簱锛岀珛椹敓鎴愬嚭鐗囦换鍔� 2銆佺偣鍑哄簱淇敼宸ヤ綅璇︽儏鍐呯殑鐘舵�佷负寰呭嚭搴擄紝瀹氭椂浠诲姟鎵弿鐢熸垚鍑哄簱浠诲姟
+ */
+ @Scheduled(fixedDelay = 1000)
+ public void outboundTask() throws Exception {
+ ReadWriteEntity entity = miloService.readFromOpcUa("rawglass.device.request");
+ String value = entity.getValueString();
+ if (!"2".equals(value)) {
+ log.info("澶ц溅蹇欑");
+ return;
+ }
+ List<RawGlassStorageDetails> rawGlassList = rawGlassStorageDetailsService.list(new LambdaQueryWrapper<RawGlassStorageDetails>()
+ .eq(RawGlassStorageDetails::getState, Const.GLASS_STATE_OUT_ING)
+ .inSql(RawGlassStorageDetails::getSlotId, "select slot from raw_glass_storage_station where enable_state = 1 and slot not in (1,2)"));
+ if (CollectionUtil.isEmpty(rawGlassList)) {
+ log.info("绯荤粺娌℃湁闇�瑕佸嚭搴撶殑鍘熺墖淇℃伅");
+ return;
+ }
+ List<Integer> emptyLeftingList = rawGlassStorageDetailsService.listBySlotState(liftingStation, Arrays.asList(Const.GLASS_STATE_IN));
+ if (CollectionUtil.isEmpty(emptyLeftingList)) {
+ log.info("鍚婅浣嶅綋鍓嶉兘鏈夊師鐗囷紝缁撴潫鍑虹墖浠诲姟");
+ }
+ //鐢熸垚鍑哄簱浠诲姟
+ generateTask(rawGlassList.get(0).getSlotId(), emptyLeftingList.get(0),
+ rawGlassList.get(0).getRemainQuantity(), Const.RAW_GLASS_TASK_TYPE_OUT);
+ }
+
+ /**
+ * 鍘熺墖璋冨害锛�1銆佹煡璇㈠伐绋嬪師鐗囪〃锛屾寜鐓ч『搴忓皢鍘熺墖鏀惧叆涓婄墖1鍙蜂綅锛屽悗缁師鐗囨斁涓婄墖2鍙蜂綅锛屽嚭鐜板昂瀵告浛鎹紝鍒ゆ柇鍘熶笂鐗囦綅鏄惁鏈夌幓鐠冿紝鏈� 鍏堝嚭鍚庤繘锛屾棤 鐩存帴杩涚墖
+ */
+ @Scheduled(fixedDelay = 1000)
+ public void rawGlassDispatchTask() throws Exception {
+ ReadWriteEntity entity = miloService.readFromOpcUa("rawglass.device.request");
+ String value = entity.getValueString();
+ if (!"2".equals(value)) {
+ log.info("澶ц溅蹇欑");
+ return;
+ }
+ //鏌ヨ褰撳墠绯荤粺姝e湪鎵ц鐨勮鍗�
+ Engineering engineering = engineeringMapper.selectOne(new LambdaQueryWrapper<Engineering>().eq(Engineering::getState, Const.ENGINEERING_RUNNING).last("order by id limit 1"));
+ if (null == engineering) {
+ log.info("娌℃湁姝e湪鎵ц鐨勫伐绋�");
+ return;
+ }
+ //褰撳墠灏哄闇�瑕佷笂鐗囩殑鏁伴噺
+ List<UpPattenUsageVO> pattenUsageList = upPattenUsageMapper.queryRawGlassByEngineeringId(engineering.getEngineerId());
+ if (CollectionUtils.isEmpty(pattenUsageList)) {
+ log.info("姝e湪鎵ц鐨勫伐绋嬪師鐗囨棤鍙笂鐗囩殑鍘熺墖淇℃伅");
+ return;
+ }
+ Map<String, List<UpPattenUsageVO>> upListMap = pattenUsageList.stream()
+ .collect(Collectors.groupingBy(UpPattenUsageVO::getGroupNumber));
+ //todo:鎸夌収宸ョ▼鍙锋寜鐓у伐绋嬩笅鏈畬鎴愮殑灏哄鐨勯『搴忥紝褰�1鍙蜂笂鐗囦綅鏋跺瓙涓婄殑褰撳墠灏哄鐜荤拑灏戜簬3鐗囦笖2鍙蜂笂鐗囦綅鏃犲師鐗囩幓鐠冿紝鍒欏皢鍘昏皟搴︾幓鐠冨幓2鍙蜂笂鐗囦綅锛�
+ //todo:褰撲竴鍙蜂笂鐗囦綅鏋跺瓙涓婄殑鐜荤拑浣嶇┖鎴栬�呭綋鍓嶅昂瀵哥敤瀹屾椂鏃讹紝灏�2鍙凤紙鏈夌幓鐠冿級涓婄墖浣嶈皟搴﹀埌1鍙蜂笂鐗囦綅
+ //1銆佹煡璇�4涓笂鐗囩殑鍘熺墖璇︽儏
+ List<RawGlassStorageDetails> rawGlassDetailsList = rawGlassStorageDetailsService.list(new LambdaQueryWrapper<RawGlassStorageDetails>()
+ .eq(RawGlassStorageDetails::getState, Const.GLASS_STATE_IN).in(RawGlassStorageDetails::getSlotId, loadGlassStation));
+ if (CollectionUtils.isEmpty(rawGlassDetailsList)) {
+ //琛ㄧず1涓婄墖浣嶆病鏈夊師鐗囷紝鐩存帴鎵惧師鐗囨斁鍏ュ搴旂殑涓婄墖浣�
+ List<UpPattenUsageVO> upPattenUsage01VOS = upListMap.get("1");
+ UpPattenUsageVO usageVO = upPattenUsage01VOS.get(0);
+ RawGlassStorageDetails details = rawGlassStorageDetailsService.getOne(new LambdaQueryWrapper<RawGlassStorageDetails>()
+ .eq(RawGlassStorageDetails::getFilmsId, usageVO.getFilmsId())
+ .eq(RawGlassStorageDetails::getPatternWidth, usageVO.getWidth())
+ .eq(RawGlassStorageDetails::getPatternHeight, usageVO.getHeight())
+ .eq(RawGlassStorageDetails::getPatternThickness, usageVO.getThickness())
+ .gt(RawGlassStorageDetails::getRemainQuantity, upPattenUsage01VOS.size())
+ .orderByAsc(RawGlassStorageDetails::getRemainQuantity)
+ .last("limit 1")
+ );
+ generateTask(details.getSlotId(), 1, details.getRemainQuantity(), Const.RAW_GLASS_TASK_TYPE_DISPATCH);
+ //缁撴潫璋冨害浠诲姟
+ }
+ Map<Integer, List<RawGlassStorageDetails>> listMap = rawGlassDetailsList.stream().collect(Collectors.groupingBy(RawGlassStorageDetails::getSlotId));
+ RawGlassStorageDetails rawGlass03Details = listMap.get(3).get(0);
+ RawGlassStorageDetails rawGlass04Details = listMap.get(4).get(0);
+// RawGlassStorageDetails rawGlass05Details = listMap.get(5).get(0);
+// RawGlassStorageDetails rawGlass06Details = listMap.get(6).get(0);
+ //todo:涓婄墖1鍙蜂綅2绉嶆竻绌烘柟寮忥細鏂瑰紡涓�锛氬師鐗囩敤瀹� 鏂瑰紡浜岋細褰撳墠灏哄鐢ㄥ畬
+ if (null == rawGlass03Details) {
+ if (null == rawGlass04Details) {
+ //琛ㄧず1涓婄墖浣嶆病鏈夊師鐗囷紝鐩存帴鎵惧師鐗囨斁鍏ュ搴旂殑涓婄墖浣�
+ List<UpPattenUsageVO> upPattenUsage01VOS = upListMap.get("1");
+ UpPattenUsageVO usageVO = upPattenUsage01VOS.get(0);
+ RawGlassStorageDetails details = rawGlassStorageDetailsService.getOne(new LambdaQueryWrapper<RawGlassStorageDetails>()
+ .eq(RawGlassStorageDetails::getFilmsId, usageVO.getFilmsId())
+ .eq(RawGlassStorageDetails::getPatternWidth, usageVO.getWidth())
+ .eq(RawGlassStorageDetails::getPatternHeight, usageVO.getHeight())
+ .eq(RawGlassStorageDetails::getPatternThickness, usageVO.getThickness())
+ .gt(RawGlassStorageDetails::getRemainQuantity, upPattenUsage01VOS.size())
+ .orderByAsc(RawGlassStorageDetails::getRemainQuantity)
+ .last("limit 1")
+ );
+ generateTask(details.getSlotId(), 1, details.getRemainQuantity(), Const.RAW_GLASS_TASK_TYPE_DISPATCH);
+ //缁撴潫璋冨害浠诲姟
+ } else {
+ //灏�2鍙蜂笂鐗囦綅鐨勫師鐗囨斁鍏�1鍙蜂笂鐗囦綅
+ generateTask(2, 1, rawGlass04Details.getRemainQuantity(), Const.RAW_GLASS_TASK_TYPE_DISPATCH);
+ //缁撴潫璋冨害浠诲姟
+ }
+ } else {
+ if (null == rawGlass04Details) {
+ List<UpPattenUsageVO> upPattenUsage01VOS = upListMap.get("2");
+ if (CollectionUtils.isEmpty(upPattenUsage01VOS)) {
+ return;
+ }
+ UpPattenUsageVO usageVO = upPattenUsage01VOS.get(0);
+ RawGlassStorageDetails details = rawGlassStorageDetailsService.getOne(new LambdaQueryWrapper<RawGlassStorageDetails>()
+ .eq(RawGlassStorageDetails::getFilmsId, usageVO.getFilmsId())
+ .eq(RawGlassStorageDetails::getPatternWidth, usageVO.getWidth())
+ .eq(RawGlassStorageDetails::getPatternHeight, usageVO.getHeight())
+ .eq(RawGlassStorageDetails::getPatternThickness, usageVO.getThickness())
+ .gt(RawGlassStorageDetails::getRemainQuantity, upPattenUsage01VOS.size())
+ .orderByAsc(RawGlassStorageDetails::getRemainQuantity)
+ .last("limit 1")
+ );
+ generateTask(details.getSlotId(), 2, details.getRemainQuantity(), Const.RAW_GLASS_TASK_TYPE_DISPATCH);
+ }
+ }
+
+
+ }
+
+
+ /**
+ * 鐢熸垚鍘熺墖浠撳偍浠诲姟
+ *
+ * @param startSlot
+ * @param endSlot
+ * @param patternQuantity
+ * @param taskType
+ * @return
+ */
+ private boolean generateTask(int startSlot, int endSlot, Integer patternQuantity, int taskType) {
+ RawGlassStorageTask task = RawGlassStorageTask.builder()
+ .originateSlot(startSlot)
+ .endSlot(endSlot)
+ .patternQuantity(patternQuantity)
+ .taskType(taskType)
+ .createTime(new Date()).build();
+ return rawGlassStorageTaskService.save(task);
+ }
+}
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/entity/RawGlassStorageDetails.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/entity/RawGlassStorageDetails.java
index 1f99472..2a339bb 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/entity/RawGlassStorageDetails.java
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/entity/RawGlassStorageDetails.java
@@ -33,7 +33,7 @@
/**
* 鏍煎瓙id
*/
- private String slotId;
+ private Integer slotId;
/**
* 鍘熺墖瀹�
@@ -63,7 +63,7 @@
/**
* 鍓╀綑鏁伴噺
*/
- private String remainQuantity;
+ private Integer remainQuantity;
/**
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/RawGlassStorageDetailsMapper.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/RawGlassStorageDetailsMapper.java
index 868b2fd..46441d4 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/RawGlassStorageDetailsMapper.java
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/RawGlassStorageDetailsMapper.java
@@ -1,11 +1,14 @@
package com.mes.rawglassdetails.mapper;
-import com.mes.rawglassdetails.entity.RawGlassStorageDetails;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.mes.rawglassdetails.entity.RawGlassStorageDetails;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
/**
* <p>
- * Mapper 鎺ュ彛
+ * Mapper 鎺ュ彛
* </p>
*
* @author wf
@@ -13,4 +16,12 @@
*/
public interface RawGlassStorageDetailsMapper extends BaseMapper<RawGlassStorageDetails> {
+ /**
+ * 鎸夌収鍚婅浣嶅拰璇︽儏琛ㄧ姸鎬佹煡璇㈢┖闂茬殑鍚婅浣�
+ *
+ * @param liftingStation
+ * @param state
+ * @return
+ */
+ List<Integer> listBySlotState(@Param("leftingStation") List<String> liftingStation, @Param("state") List<Integer> state);
}
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/xml/RawGlassStorageDetailsMapper.xml b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/xml/RawGlassStorageDetailsMapper.xml
index 454dde2..f13945e 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/xml/RawGlassStorageDetailsMapper.xml
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/mapper/xml/RawGlassStorageDetailsMapper.xml
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="glassdetails.mapper.RawGlassStorageDetailsMapper">
+<mapper namespace="com.mes.rawglassdetails.mapper.RawGlassStorageDetailsMapper">
+ <select id="listBySlotState" resultType="java.lang.Integer">
+ select t.slot
+ from raw_glass_storage_station t
+ inner JOIN raw_glass_storage_details t1
+ on t.slot = t1.slot_id and t.enable_state = 1
+ and t.slot in
+ <foreach collection="leftingStation" item="item" open='(' close=')' separator=','>
+ #{item}
+ </foreach>
+ and t1.state not in
+ <foreach collection="state" item="item" open='(' close=')' separator=','>
+ #{item}
+ </foreach>
+ </select>
</mapper>
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/RawGlassStorageDetailsService.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/RawGlassStorageDetailsService.java
index e05c291..cd7ad71 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/RawGlassStorageDetailsService.java
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/RawGlassStorageDetailsService.java
@@ -1,10 +1,8 @@
package com.mes.rawglassdetails.service;
import com.baomidou.mybatisplus.extension.service.IService;
-import com.mes.entity.request.GeneralRequest;
import com.mes.rawglassdetails.entity.RawGlassStorageDetails;
import com.mes.rawglassdetails.entity.request.RawGlassRequest;
-import com.mes.userinfo.entity.vo.SysUserVO;
import java.util.List;
@@ -39,4 +37,6 @@
String deleteWarehousing(Long slotId);
String outWarehousing(Long slotId);
+
+ List<Integer> listBySlotState(List<String> liftingStation, List<Integer> state);
}
\ No newline at end of file
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/impl/RawGlassStorageDetailsServiceImpl.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/impl/RawGlassStorageDetailsServiceImpl.java
index 8be12b1..e608d50 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/impl/RawGlassStorageDetailsServiceImpl.java
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglassdetails/service/impl/RawGlassStorageDetailsServiceImpl.java
@@ -8,8 +8,6 @@
import com.mes.rawglassdetails.entity.request.RawGlassRequest;
import com.mes.rawglassdetails.mapper.RawGlassStorageDetailsMapper;
import com.mes.rawglassdetails.service.RawGlassStorageDetailsService;
-import com.mes.rawglassstation.entity.RawGlassStorageStation;
-import com.mes.userinfo.entity.vo.SysUserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -24,8 +22,8 @@
@Service
@Slf4j
public class RawGlassStorageDetailsServiceImpl extends ServiceImpl<RawGlassStorageDetailsMapper, RawGlassStorageDetails> implements RawGlassStorageDetailsService {
- @Override
- public boolean deleteRawGlassStorageDetails(String device_id) {
+ @Override
+ public boolean deleteRawGlassStorageDetails(String device_id) {
QueryWrapper<RawGlassStorageDetails> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("device_id", device_id);
return remove(queryWrapper);//remove鎵嶆槸鍒犻櫎锛宒elete寰楃敤鍙﹀鐨勪緷璧栵紝榛樿鏂规硶鏄痳emove杩斿洖bool
@@ -60,17 +58,24 @@
.eq(RawGlassStorageDetails::getSlotId, request.getSlotId()));
return "success";
}
+
@Override
public String deleteWarehousing(Long slotId) {
update(new LambdaUpdateWrapper<RawGlassStorageDetails>().eq(RawGlassStorageDetails::getSlotId, slotId)
- .set(RawGlassStorageDetails::getState,Const.GLASS_STATE_OUT));
+ .set(RawGlassStorageDetails::getState, Const.GLASS_STATE_OUT));
return "success";
}
+
@Override
public String outWarehousing(Long slotId) {
update(new LambdaUpdateWrapper<RawGlassStorageDetails>().eq(RawGlassStorageDetails::getSlotId, slotId)
- .set(RawGlassStorageDetails::getState,Const.GLASS_STATE_OUT_ING));
+ .set(RawGlassStorageDetails::getState, Const.GLASS_STATE_OUT_ING));
return "success";
}
+ @Override
+ public List<Integer> listBySlotState(List<String> liftingStation, List<Integer> state) {
+ return baseMapper.listBySlotState(liftingStation, state);
+ }
+
}
\ No newline at end of file
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglasstask/entity/RawGlassStorageTask.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglasstask/entity/RawGlassStorageTask.java
index 8c6a3be..5346dee 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglasstask/entity/RawGlassStorageTask.java
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/rawglasstask/entity/RawGlassStorageTask.java
@@ -2,20 +2,23 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
+import java.util.Date;
/**
* <p>
- *
+ *
* </p>
*
* @author wf
* @since 2024-09-10
*/
@Data
+@Builder
@EqualsAndHashCode(callSuper = false)
public class RawGlassStorageTask implements Serializable {
@@ -38,7 +41,7 @@
/**
* 鍘熺墖鏁伴噺
*/
- private String patternQuantity;
+ private Integer patternQuantity;
/**
* 浠诲姟绫诲瀷
@@ -53,7 +56,7 @@
/**
* 鍒涘缓鏃堕棿
*/
- private String createTime;
+ private Date createTime;
}
diff --git a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application-dev.yml b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application-dev.yml
index 246a786..530267b 100644
--- a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application-dev.yml
+++ b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application-dev.yml
@@ -34,4 +34,6 @@
database: 0
host: 127.0.0.1
port: 6379
- password: 123456
\ No newline at end of file
+ password: 123456
+ liquibase:
+ change-log: classpath:changelog/changelogBase.xml
\ No newline at end of file
diff --git a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application.yml b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application.yml
index af491d8..04632dd 100644
--- a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application.yml
+++ b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/application.yml
@@ -2,16 +2,25 @@
port: 8084
spring:
profiles:
- active: cz
+ active: dev
application:
name: temperingGlass
liquibase:
- enabled: false
- change-log: classpath:changelog/changelog.sql
+ enabled: true
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mes:
width: 2800
- height: 5000
\ No newline at end of file
+ height: 5000
+kangaroohy:
+ milo:
+ enabled: false
+ primary: default
+ config:
+ default:
+ endpoint: opc.tcp://zidonghua:49320
+ security-policy: basic256sha256
+ username: zsh
+ password: 1qaz2wsx3edc4rfv
\ No newline at end of file
diff --git a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/changelog/changelog.sql b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/changelog/changelog.sql
index 245a94c..5473f61 100644
--- a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/changelog/changelog.sql
+++ b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/resources/changelog/changelog.sql
@@ -153,56 +153,61 @@
-- rollback DELETE FROM sys_dict_data WHERE dict_type in ('鐧界幓', '鍗曢摱', '鍙岄摱');
--- changeset wangfei:20240918001
+-- changeset zsh:20240918001
-- preconditions onFail:CONTINUE onError:CONTINUE
-- precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'raw_glass_storage_details' and table_schema = 'hangzhoumes';
CREATE TABLE raw_glass_storage_details
(
id bigint NOT NULL AUTO_INCREMENT,
device_id int NULL DEFAULT NULL COMMENT '璁惧id',
- slot_id varchar(255) NULL DEFAULT NULL COMMENT '鏍煎瓙id',
+ slot int NULL DEFAULT NULL COMMENT '鏍煎瓙id',
pattern_width double(8, 2) NULL DEFAULT NULL COMMENT '鍘熺墖瀹�',
pattern_height double(8, 2) NULL DEFAULT NULL COMMENT '鍘熺墖楂�',
pattern_thickness double(8, 2) NULL DEFAULT NULL COMMENT '鍘熺墖鍘氬害',
- films_id varchar(255) NULL DEFAULT NULL COMMENT '鑶滅郴',
+ films_id varchar(64) NULL DEFAULT NULL COMMENT '鑶滅郴',
create_time datetime NOT NULL COMMENT '鍒涘缓鏃堕棿',
- remain_quantity varchar(255) NULL DEFAULT NULL COMMENT '鍓╀綑鏁伴噺',
+ remain_quantity int NULL DEFAULT NULL COMMENT '鍓╀綑鏁伴噺',
+ state int NULL DEFAULT NULL COMMENT '鐘舵��',
PRIMARY KEY (id) USING BTREE
);
-- rollback DROP TABLE raw_glass_storage_details;
--- changeset wangfei:20240918002
+-- changeset zsh:20240918002
-- preconditions onFail:CONTINUE onError:CONTINUE
-- precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'raw_glass_storage_station' and table_schema = 'hangzhoumes';
CREATE TABLE raw_glass_storage_station
(
- id bigint NOT NULL AUTO_INCREMENT,
- device_id int NULL DEFAULT NULL COMMENT '璁惧id',
- slot int NULL DEFAULT NULL COMMENT '鏍呮牸鍙�',
+ id bigint NOT NULL AUTO_INCREMENT,
+ device_id int NULL DEFAULT NULL COMMENT '璁惧id',
+ slot int NULL DEFAULT NULL COMMENT '鏍呮牸鍙�',
enable_state varchar(255) NULL DEFAULT NULL COMMENT '鍚敤鏍囪',
- start_slot int NULL DEFAULT NULL COMMENT '寮�濮嬪伐浣�',
- end_slot int NULL DEFAULT NULL COMMENT '鐩爣宸ヤ綅',
- PRIMARY KEY (id) USING BTREE
+ PRIMARY KEY (id)
);
-- rollback DROP TABLE raw_glass_storage_station;
--- changeset wangfei:20240918003
+-- changeset zsh:20240918003
-- preconditions onFail:CONTINUE onError:CONTINUE
-- precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'raw_glass_storage_task' and table_schema = 'hangzhoumes';
CREATE TABLE raw_glass_storage_task
(
- id bigint NOT NULL AUTO_INCREMENT,
- enable_id int NULL DEFAULT NULL COMMENT '浠诲姟ID',
- originate_slot int NULL DEFAULT NULL COMMENT '璧峰鏍煎瓙',
- end_slot int NULL DEFAULT NULL COMMENT '鐩爣鏍煎瓙',
- pattern_quantity varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '鍘熺墖鏁伴噺',
- enable_type int NULL DEFAULT NULL COMMENT '浠诲姟绫诲瀷',
- enable_state int NULL DEFAULT NULL COMMENT '浠诲姟鐘舵��',
+ id bigint NOT NULL AUTO_INCREMENT,
+ start_slot int NULL DEFAULT NULL COMMENT '璧峰鏍煎瓙',
+ end_slot int NULL DEFAULT NULL COMMENT '鐩爣鏍煎瓙',
+ pattern_quantity int NULL DEFAULT NULL COMMENT '鍘熺墖鏁伴噺',
+ enable_type int NULL DEFAULT NULL COMMENT '浠诲姟绫诲瀷',
+ enable_state int NULL DEFAULT NULL COMMENT '浠诲姟鐘舵��',
create_time datetime NULL DEFAULT NULL COMMENT '鍒涘缓鏃堕棿',
PRIMARY KEY (id) USING BTREE
);
-- rollback DROP TABLE raw_glass_storage_task;
+-- changeset zsh:20241015001
+-- preconditions onFail:CONTINUE onError:CONTINUE
+-- precondition-sql-check expectedResult:0 SELECT count(0) FROM information_schema.columns WHERE table_schema = 'hangzhoumes' AND table_name = 'engineering' AND column_name = 'station_cell';
+ALTER TABLE engineering
+ ADD COLUMN station_cell varchar(20);
+
+
diff --git a/hangzhoumesParent/moduleService/pom.xml b/hangzhoumesParent/moduleService/pom.xml
index f799583..55ea5f6 100644
--- a/hangzhoumesParent/moduleService/pom.xml
+++ b/hangzhoumesParent/moduleService/pom.xml
@@ -55,11 +55,6 @@
<groupId>com.mes</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
-<!-- <dependency>-->
-<!-- <artifactId>opcuaClient</artifactId>-->
-<!-- <groupId>com.mes</groupId>-->
-<!-- <version>1.0-SNAPSHOT</version>-->
-<!-- </dependency>-->
<!--寮�鍙戣�呭伐鍏�-->
<!-- <dependency>-->
--
Gitblit v1.8.0