From a9406b6b18ee5a8e29cad3248f46320a36ac9749 Mon Sep 17 00:00:00 2001
From: yyt <306727702@qq.com>
Date: 星期三, 21 二月 2024 00:19:44 +0800
Subject: [PATCH] 批量数据采集方法更新

---
 jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java b/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
index 4cfa0c6..0ab83b0 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java
@@ -6,8 +6,13 @@
 import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
 import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
 
 /**
  * 璁惧浜у搧杩囩▼鍙傛暟閲囬泦Service涓氬姟灞傚鐞�
@@ -23,6 +28,9 @@
 
     @Autowired
     private IDaParamCollectionService daParamCollectionService;
+
+    @Resource
+    private SqlSessionFactory sqlSessionFactory;
 
     /**
      * 鏌ヨ璁惧浜у搧杩囩▼鍙傛暟閲囬泦
@@ -102,4 +110,25 @@
     {
         return daParamCollectionMapper.deleteDaParamCollectionById(id);
     }
+
+    @Override
+    public void saveBeachDaParamCollection(List<DaParamCollection> list) {
+        // ExecutorType.SIMPLE: 杩欎釜鎵ц鍣ㄧ被鍨嬩笉鍋氱壒娈婄殑浜嬫儏銆傚畠涓烘瘡涓鍙ョ殑鎵ц鍒涘缓涓�涓柊鐨勯澶勭悊璇彞銆�
+        // ExecutorType.REUSE: 杩欎釜鎵ц鍣ㄧ被鍨嬩細澶嶇敤棰勫鐞嗚鍙ャ��
+        // ExecutorType.BATCH: 杩欎釜鎵ц鍣ㄤ細鎵归噺鎵ц鎵�鏈夋洿鏂拌鍙�,濡傛灉 SELECT 鍦ㄥ畠浠腑闂存墽琛岃繕浼氭爣瀹氬畠浠槸 蹇呴』鐨�,鏉ヤ繚璇佷竴涓畝鍗曞苟鏄撲簬鐞嗚В鐨勮涓恒��
+
+        // 鍏抽棴session鐨勮嚜鍔ㄦ彁浜�
+        SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
+        try {
+            DaParamCollectionMapper userMapper = sqlSession.getMapper(DaParamCollectionMapper.class);
+            list.stream().forEach(DaParamCollection -> userMapper.insertDaParamCollection(DaParamCollection));
+            // 鎻愪氦鏁版嵁
+            sqlSession.commit();
+            sqlSession.rollback();
+        } catch (Exception e) {
+            sqlSession.rollback();
+        } finally {
+            sqlSession.close();
+        }
+    }
 }

--
Gitblit v1.9.3