From ae084b7ab31c38588928afb770cec1320c8c27f0 Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期四, 07 十二月 2023 12:26:24 +0800
Subject: [PATCH] 提交粮情协协议-控制柜-3

---
 src/main/java/com/fzzy/api/utils/ContextUtil.java |   62 ++++++++++++++++++++++++++++---
 1 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/fzzy/api/utils/ContextUtil.java b/src/main/java/com/fzzy/api/utils/ContextUtil.java
index 92e0c24..287452f 100644
--- a/src/main/java/com/fzzy/api/utils/ContextUtil.java
+++ b/src/main/java/com/fzzy/api/utils/ContextUtil.java
@@ -4,14 +4,18 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.time.DateUtils;
 
-import java.util.Calendar;
-import java.util.Date;
-import java.util.UUID;
+import java.util.*;
 
 /**
  *
  */
 public class ContextUtil {
+
+
+    /**
+     * 鍏ㄥ眬鍛戒护ID
+     */
+    public static Map<String, Integer> contextOrderId = new HashMap<>();
 
 
     public static String getUUID() {
@@ -101,9 +105,6 @@
 //        int i = ContextUtil.getMinuteOfHour(date);
 //
 //        System.out.println(i);
-        String str = null;
-        String [] s= str.split("-");
-        System.out.println( Integer.valueOf(s[0]));
     }
 
 
@@ -139,4 +140,53 @@
             return null;
         }
     }
+
+    /**
+     * 鐢熸垚TCP杩炴帴鐨凨EY
+     *
+     * @param ip
+     * @param port
+     * @return
+     */
+    public static String getServerKey(String ip, Integer port) {
+        return ip + ":" + port;
+    }
+
+
+    /**
+     * 鏍规嵁鍙傛暟鐢熸垚 鎵ц鍛戒护鐨勭紦瀛楰EY
+     *
+     * @param companyId
+     * @param serId
+     * @param bizType
+     * @return
+     */
+    public static final String buildExeOrderId(String companyId, String serId, String bizType) {
+        Integer start = contextOrderId.get("ORDER_ID") == null ? 5000 : contextOrderId.get("ORDER_ID");
+
+        contextOrderId.put("ORDER_ID", start + 1);
+
+        return start + "";
+    }
+
+    /**
+     * 璁惧ID鐢熸垚瑙勫垯
+     *
+     * @param companyId
+     * @param depotId
+     * @param passCode
+     * @return
+     */
+    public static final String buildDeviceId(String companyId, String depotId, int passCode) {
+        return companyId + "_" + depotId + "_" + passCode;
+    }
+
+    public static String buildDeviceStatusKey(String companyId, String serId, String passCode) {
+        if (null == passCode) passCode = "NULL";
+        return companyId + "_" + serId + "_STATUS_" + passCode;
+    }
+
+    public static String buildDeviceStatusKey(String companyId, String serId, int passCode) {
+        return companyId + "_" + serId + "_STATUS_" + passCode;
+    }
 }

--
Gitblit v1.9.3