From 2f432f52c1cfb1567dadcf6e040c5d38b0a26a79 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期五, 28 十一月 2025 17:31:49 +0800
Subject: [PATCH] 数量检测配置页面

---
 fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java |   89 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java
index b845309..f36b989 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/utils/ContextUtil.java
@@ -3,8 +3,8 @@
 import com.ruoyi.common.config.FrameworkConfig;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.ShiroUtils;
+import com.ruoyi.common.utils.StringUtils;
 import org.apache.commons.lang3.RandomUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
 
 import java.time.LocalDateTime;
@@ -21,6 +21,14 @@
 
     private static final AtomicLong sequence = new AtomicLong(0);
     private static String lastTimestamp = "";
+
+    //鍏ㄥ眬鐢ㄦ埛瀹炴椂鍧愬湪閮ㄩ棬
+    public static Map<String, String> contextUserDept = new HashMap<>();
+
+    /**
+     * 鍏ㄥ眬鐢ㄤ簬瀛樻斁SN涓庣粍缁囩紪鐮佺殑鍏崇郴锛屼緥濡傚垎鏈篠N鍜岀粍缁囩紪鐮佸叧绯�
+     */
+    public static Map<String, String> contextSnCompanyIdMap = new HashMap<>();
 
     /**
      * 鐢熸垚椤哄簭ID锛氬勾鏈堟棩鏃跺垎绉掓绉�(17浣�) + 搴忓垪鍙�(4浣�) = 21浣�
@@ -60,6 +68,83 @@
     }
 
     public static String getLoginUserName() {
-      return  ShiroUtils.getUserName() ;
+        SysUser user = ShiroUtils.getSysUser();
+        return null == user ? "绯荤粺" : user.getUserName();
+    }
+
+    public static SysUser getLoginUser() {
+        return ShiroUtils.getSysUser();
+    }
+
+    public static String subDeptId(SysUser user) {
+        if (null == user) {
+            user = getLoginUser();
+        }
+
+        if (null == user) {
+            return getCompanyId() + "001";
+        }
+
+        //浠庡叏灞�鑾峰彇锛屽鏋滄湁鍒欏彇鍏ㄥ眬鐨勯粯璁わ紝濡傛灉娌℃湁鍒欏彇鑷繁鎵�灞�
+        if (null != contextUserDept.get(user.getLoginName())) {
+            return contextUserDept.get(user.getLoginName());
+        }
+
+        if (null == user.getDeptId()) {
+            return user.getCompanyId();
+        }
+        return user.getDeptId().toString();
+    }
+
+    public static void updateSubDept(String userId, String deptId) {
+        if (null == deptId) return;
+        contextUserDept.put(userId, deptId);
+    }
+
+    /**
+     * 鑾峰彇椤哄簭鍙�
+     * @param oldOrderId 鍘熸湁椤哄簭鍙�
+     * @param num 浣嶆暟
+     * @return
+     */
+    public static String getOrderId(String oldOrderId, Integer num) {
+        Integer index3 = 1001;
+        Integer index4 = 10001;
+        Integer index5 = 100001;
+        Integer index = 0;
+        String orderId = "001";
+        if(StringUtils.isNotEmpty(oldOrderId)){
+            index = Integer.valueOf(oldOrderId);
+        }
+        if(3 == num){
+            orderId = ((index3 + index) + "").substring(1);
+        }
+        if(4 == num){
+            orderId = ((index4 + index) + "").substring(1);
+        }
+        if(5 == num){
+            orderId = ((index5 + index) + "").substring(1);
+        }
+        return orderId;
+    }
+
+    /**
+     * 瀛樻斁SN涓庢墍灞炵粍缁囩殑鍏崇郴
+     *
+     * @param sn
+     * @param companyId
+     */
+    public static void addSerCompany(String sn, String companyId) {
+        contextSnCompanyIdMap.put(sn, companyId);
+    }
+
+    /**
+     * 閫氳繃SN鑾峰彇褰撳墠SN鎵�灞炵殑缁勭粐
+     *
+     * @param sn
+     * @return
+     */
+    public static String getCompanyIdBySn(String sn) {
+        return contextSnCompanyIdMap.get(sn);
     }
 }

--
Gitblit v1.9.3