소스 검색

提交设置

xiaochan 2 년 전
부모
커밋
e919bcb0d4

+ 9 - 3
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -543,23 +543,29 @@ public class YiZhuLuRuServer {
 
         CacheOnce<XinZhenYzActOrder> drug = new CacheOnce<>();
 
+        SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
+        YiZhuLuRuDao mapper = sqlSession.getMapper(YiZhuLuRuDao.class);
+
         resList.forEach(item -> {
             setTempInfo(drug, item, patInfo);
             item.setActOrderNo(queue.poll());
             returnOrderList.add(item.getActOrderNo());
-            dao.insertEntryOrder(patInfo, item, userCode);
+            mapper.insertEntryOrder(patInfo, item, userCode);
 
             if (ListUtil.notBlank(item.getChildren())) {
                 item.getChildren().forEach(children -> {
                     setTempInfo(drug, children, patInfo);
                     children.setActOrderNo(queue.poll());
                     returnOrderList.add(children.getActOrderNo());
-
                     children.setParentNo(item.getActOrderNo());
-                    dao.insertEntryOrder(patInfo, children, userCode);
+                    mapper.insertEntryOrder(patInfo, children, userCode);
                 });
             }
+
         });
+
+        sqlSession.commit();
+        sqlSession.close();
     }
 
     private void setTempInfo(CacheOnce<XinZhenYzActOrder> drug, XinZhenYzActOrder data, XinZhenYiZhu patInfo) {

+ 6 - 8
src/main/java/thyyxxk/webserver/utils/CacheOnce.java

@@ -9,37 +9,35 @@ import java.util.function.Function;
  * @author Administrator
  */
 public class CacheOnce<V> {
-    private final Map<String, Object> map = new HashMap<>();
+    private final Map<String, V> map = new HashMap<>();
     private final Set<String> notQueried = new HashSet<>();
 
-    @SuppressWarnings("unchecked")
     public V get(String name) {
         if (map.containsKey(name)) {
-            return (V) map.get(name);
+            return map.get(name);
         }
         return null;
     }
 
-    @SuppressWarnings("unchecked")
-    public V get(String name, Function<String, Object> filter) {
+    public V get(String name, Function<String, V> filter) {
         Objects.requireNonNull(filter);
 
         if (map.containsKey(name)) {
-            return (V) map.get(name);
+            return map.get(name);
         }
 
         if (notQueried.contains(name)) {
             return null;
         }
 
-        Object object = filter.apply(name);
+        V object = filter.apply(name);
 
         if (object == null) {
             notQueried.add(name);
             return null;
         } else {
             map.put(name, object);
-            return (V) (object);
+            return object;
         }
     }
 

+ 6 - 0
src/main/java/thyyxxk/webserver/utils/SqlSessionUtils.java

@@ -0,0 +1,6 @@
+package thyyxxk.webserver.utils;
+
+public class SqlSessionUtils {
+    
+
+}