From a1d1d928893c33fad6694b2503a425ab29af0a15 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期三, 04 三月 2026 14:52:49 +0800
Subject: [PATCH] 云仓WMS接口流程

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OrderTypeDictServiceImpl.java |   98 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OrderTypeDictServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OrderTypeDictServiceImpl.java
new file mode 100644
index 0000000..0d768e7
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/OrderTypeDictServiceImpl.java
@@ -0,0 +1,98 @@
+package com.vincent.rsf.server.manager.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.vincent.rsf.server.manager.enums.OrderType;
+import com.vincent.rsf.server.manager.service.OrderTypeDictService;
+import com.vincent.rsf.server.system.constant.DictTypeCode;
+import com.vincent.rsf.server.system.entity.DictData;
+import com.vincent.rsf.server.system.service.DictDataService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 璁㈠崟绫诲瀷锛氫紭鍏堜粠瀛楀吀琛ㄨ鍙栵紝鍏煎 API 鏁板瓧 1/2/3 涓庢灇涓惧洖閫�銆�
+ */
+@Slf4j
+@Service
+public class OrderTypeDictServiceImpl implements OrderTypeDictService {
+
+    private static final Map<String, String> API_NUMERIC_MAP = new HashMap<>();
+    static {
+        API_NUMERIC_MAP.put("1", OrderType.ORDER_OUT.type);   // 鍑哄簱鍗�
+        API_NUMERIC_MAP.put("2", OrderType.ORDER_IN.type);    // 鍏ュ簱鍗�
+        API_NUMERIC_MAP.put("3", OrderType.ORDER_TRANSFER.type); // 璋冩嫧鍗�
+    }
+
+    @Resource
+    private DictDataService dictDataService;
+
+    private volatile List<DictData> cache;
+    private static final Object CACHE_LOCK = new Object();
+
+    @Override
+    public List<DictData> listAll() {
+        if (cache != null && !cache.isEmpty()) {
+            return cache;
+        }
+        synchronized (CACHE_LOCK) {
+            if (cache != null && !cache.isEmpty()) {
+                return cache;
+            }
+            List<DictData> list = dictDataService.list(new LambdaQueryWrapper<DictData>()
+                    .eq(DictData::getDictTypeCode, DictTypeCode.DICT_SYS_ORDER_TYPE)
+                    .eq(DictData::getStatus, 1)
+                    .orderByAsc(DictData::getSort));
+            cache = list;
+            return cache;
+        }
+    }
+
+    @Override
+    public String getTypeByLabel(String label) {
+        if (label == null || label.isEmpty()) return null;
+        for (DictData d : listAll()) {
+            if (label.equals(d.getLabel())) return d.getValue();
+        }
+        return OrderType.getTypeVal(label);
+    }
+
+    @Override
+    public String getLabelByType(String type) {
+        if (type == null || type.isEmpty()) return null;
+        for (DictData d : listAll()) {
+            if (type.equals(d.getValue())) return d.getLabel();
+        }
+        return OrderType.getValType(type);
+    }
+
+    @Override
+    public String resolveType(String input) {
+        if (input == null) return null;
+        String s = input.trim();
+        if (s.isEmpty()) return null;
+        if (API_NUMERIC_MAP.containsKey(s)) return API_NUMERIC_MAP.get(s);
+        String byLabel = getTypeByLabel(s);
+        if (byLabel != null) return byLabel;
+        if (getLabelByType(s) != null) return s;
+        return null;
+    }
+
+    @Override
+    public String resolveType(Integer orderType) {
+        if (orderType == null) return null;
+        return API_NUMERIC_MAP.get(String.valueOf(orderType));
+    }
+
+    @Override
+    public void refreshCache() {
+        synchronized (CACHE_LOCK) {
+            cache = null;
+        }
+        log.info("璁㈠崟绫诲瀷瀛楀吀缂撳瓨宸插埛鏂�");
+    }
+}

--
Gitblit v1.9.1