From 220f7b818bb9399391830fbbb9fb2028a21b938f Mon Sep 17 00:00:00 2001 From: yyt <306727702@qq.com> Date: 星期三, 21 二月 2024 00:23:34 +0800 Subject: [PATCH] 批量数据采集方法更新 --- jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 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 2c3a908..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 @@ -5,8 +5,14 @@ import com.jcdm.main.da.paramCollection.domain.DaParamCollection; 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涓氬姟灞傚鐞� @@ -19,6 +25,12 @@ { @Autowired private DaParamCollectionMapper daParamCollectionMapper; + + @Autowired + private IDaParamCollectionService daParamCollectionService; + + @Resource + private SqlSessionFactory sqlSessionFactory; /** * 鏌ヨ璁惧浜у搧杩囩▼鍙傛暟閲囬泦 @@ -41,6 +53,11 @@ @Override public List<DaParamCollection> selectDaParamCollectionList(DaParamCollection daParamCollection) { + if(daParamCollection.getDateConditions()!=null){ + String[] conditions = daParamCollection.getDateConditions(); + daParamCollection.setStartTime(conditions[0]); + daParamCollection.setEndTime(conditions[1]); + } return daParamCollectionMapper.selectDaParamCollectionList(daParamCollection); } @@ -93,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