From c6afa728278253cd653be0951588bd99d1639d2f Mon Sep 17 00:00:00 2001
From: YYC <1833023622@qq.com>
Date: 星期五, 08 九月 2023 15:40:44 +0800
Subject: [PATCH] 添加数据

---
 igds-recir/src/main/java/com/ld/igds/drug/service/HDrugLogService.java |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/igds-recir/src/main/java/com/ld/igds/drug/service/HDrugLogService.java b/igds-recir/src/main/java/com/ld/igds/drug/service/HDrugLogService.java
index bf969f7..fd9718a 100644
--- a/igds-recir/src/main/java/com/ld/igds/drug/service/HDrugLogService.java
+++ b/igds-recir/src/main/java/com/ld/igds/drug/service/HDrugLogService.java
@@ -9,6 +9,7 @@
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.hibernate.Session;
 import org.springframework.stereotype.Service;
+
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -31,6 +32,11 @@
                 hql += " and depotId =:depotId";
                 args.put("depotId", str);
             }
+            str = (String) param.get("name");
+            if (StringUtils.isNotEmpty(str)) {
+                hql += " and user =:name";
+                args.put("name", "%" + str + "%");
+            }
 
         }
 
@@ -42,11 +48,11 @@
 
     }
 
-    private List<DrugLog> getDrugLogByTime(String companyId){
+    private List<DrugLog> getDrugLogByTime(String companyId) {
         String hql = " from " + DrugLog.class.getName()
                 + " where companyId =:companyId ";
 
-        Map<String,Object> args = new HashMap<String,Object>();
+        Map<String, Object> args = new HashMap<String, Object>();
         args.put("companyId", companyId);
 
         hql += " and updateTime >:startTime";
@@ -62,18 +68,18 @@
         return this.query(hql, args);
     }
 
-    public String getIndex(String companyId){
+    public String getIndex(String companyId) {
         List<DrugLog> list = getDrugLogByTime(companyId);
         String index = "001";
-        if(list != null && list.size() > 0){
+        if (list != null && list.size() > 0) {
             String id = list.get(0).getId().substring(8);
             int temp = Integer.valueOf(id) + 1;
             index = temp + "";
         }
-        if(index.length() == 1){
+        if (index.length() == 1) {
             index = "00" + index;
         }
-        if(index.length() == 2){
+        if (index.length() == 2) {
             index = "0" + index;
         }
         return index;
@@ -91,7 +97,7 @@
         data.setUpdateUser(ContextUtil.getLoginUserCName());
         try {
             if (null == data.getId()) {
-                data.setId(DateFormatUtils.format(new Date(), "yyyyMMdd") + getIndex(data.getCompanyId()));
+                data.setId(data.getDepotId() + DateFormatUtils.format(new Date(), "yyyyMMdd") + getIndex(data.getCompanyId()));
                 session.save(data);
             } else {
                 session.update(data);
@@ -103,6 +109,7 @@
             session.close();
         }
     }
+
     public String delData(DrugLog data) {
         Session session = this.getSessionFactory().openSession();
         try {

--
Gitblit v1.9.3