From 43ce77a85d8297a53dc25430fff10ead57296167 Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期六, 04 十一月 2023 15:43:18 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 igds-recir/src/main/java/com/ld/igds/drug/service/HDrugService.java |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/igds-recir/src/main/java/com/ld/igds/drug/service/HDrugService.java b/igds-recir/src/main/java/com/ld/igds/drug/service/HDrugService.java
index 045e470..f34431c 100644
--- a/igds-recir/src/main/java/com/ld/igds/drug/service/HDrugService.java
+++ b/igds-recir/src/main/java/com/ld/igds/drug/service/HDrugService.java
@@ -14,6 +14,7 @@
 import com.ld.igds.util.ContextUtil;
 import com.ld.igds.util.RedisUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
 import org.hibernate.Session;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -86,14 +87,12 @@
         if (null == data.getDeptId()) {
             data.setDeptId(ContextUtil.subDeptId(null));
         }
-        DefaultDept dept = sysDeptService.getDeptById(data.getDeptId());
-        data.setDeptName(dept.getName());
         Session session = this.getSessionFactory().openSession();
         data.setUpdateTime(new Date());
         data.setUpdateUser(ContextUtil.getLoginUserCName());
         try {
             if (null == data.getId()) {
-                String id = createId(data.getCompanyId(), data.getDeptId());
+                String id = createId(data.getCompanyId(), data.getCgrq());
                 data.setId(id);
                 session.save(data);
             } else {
@@ -184,26 +183,27 @@
 
     }
 
-    public String createId(String companyId, String deptId) {
+    public String createId(String companyId, Date time) {
 
+        String timeKey = DateFormatUtils.format(time, "yyyyMMdd");
         // 浠庣紦瀛樹腑鑾峰彇宸叉湁鐨勭粍缁囩紪鐮�
         String cacheKey = RedisConst.buildKey(companyId, HDrugService.CACHE_DRUG_ID);
 
         String cacheId = (String) redisUtil.get(cacheKey);
 
-        if (null != cacheId && cacheId.indexOf(deptId) >= 0) {
+        if (null != cacheId && cacheId.indexOf(timeKey) >= 0) {
             String temp = cacheId.substring(cacheId.length() - 3);
             Integer i = Integer.valueOf(temp);
-            cacheId = deptId + String.format("%03d", ++i);
+            cacheId = timeKey + String.format("%03d", ++i);
         } else {
             List<Drug> result = listDrug(companyId, null);
             if (null == result || result.size() == 0) {
-                cacheId = deptId + "001";
+                cacheId = timeKey + "001";
             } else {
                 Drug drug = result.get(0);
                 String temp = drug.getId().substring(drug.getId().length() - 3);
                 Integer i = Integer.valueOf(temp);
-                cacheId = deptId + String.format("%03d", ++i);
+                cacheId = timeKey + String.format("%03d", ++i);
             }
         }
         // 鏇存柊缂撳瓨

--
Gitblit v1.9.3