保存进度!
This commit is contained in:
parent
7964f8fbe0
commit
3c807a6efa
@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* @Author: Kane
|
||||||
|
* @Date: 2023-10-12 10:43:31
|
||||||
|
* @LastEditors: Kane
|
||||||
|
* @FilePath: /desktop_archievement_backend/src/test/java/com/cpic/xim/DesktopArchievement/test/BatchInsertTest.java
|
||||||
|
* @Description:
|
||||||
|
*
|
||||||
|
* Copyright (c) ${2023} by Kane, All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package com.cpic.xim.DesktopArchievement.test;
|
||||||
|
|
||||||
|
import org.apache.ibatis.exceptions.PersistenceException;
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.junit.Test;
|
||||||
|
import com.cpic.xim.mybatis.mapper.ImportBIArchievementDataMapper;
|
||||||
|
import com.cpic.xim.mybatis.pojo.*;
|
||||||
|
import com.cpic.xim.mybatis.utils.MybatisUtils;
|
||||||
|
import com.cpic.xim.utils.data.ImportBIData;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class BatchInsertTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBatchInsertIntoBITelsalerAttachingRate()
|
||||||
|
{
|
||||||
|
String filePath = "D:/develop/cpicxim/deskop_task_schedule/数据/测试用/坐席车非渗透.xlsx";
|
||||||
|
ArrayList<BITelsalerAttachingRateRecord> records = null;
|
||||||
|
SqlSession session = null;
|
||||||
|
ImportBIArchievementDataMapper mapper = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
records = ImportBIData.importBITelsalerAttachingRateRecordFromXlsx( filePath, null,
|
||||||
|
true );
|
||||||
|
session = MybatisUtils.getSqlSessionBatch();
|
||||||
|
mapper = session.getMapper( ImportBIArchievementDataMapper.class );
|
||||||
|
|
||||||
|
mapper.cleanTelsalerAttachingRateData();
|
||||||
|
|
||||||
|
for ( BITelsalerAttachingRateRecord record : records )
|
||||||
|
{
|
||||||
|
mapper.insertTelsalerAttachingRateDataToDB( record );
|
||||||
|
}
|
||||||
|
|
||||||
|
session.commit();
|
||||||
|
|
||||||
|
assert (true);
|
||||||
|
}
|
||||||
|
catch ( PersistenceException error)
|
||||||
|
{
|
||||||
|
System.out.println(error);
|
||||||
|
assert( false );
|
||||||
|
}
|
||||||
|
catch ( Exception error )
|
||||||
|
{
|
||||||
|
if ( session != null )
|
||||||
|
{
|
||||||
|
session.rollback();
|
||||||
|
|
||||||
|
assert (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBatchInsertBITeslsalerRenewalRate()
|
||||||
|
{
|
||||||
|
String filePath = "D:/develop/cpicxim/deskop_task_schedule/数据/测试用/坐席续保率 .xlsx";
|
||||||
|
String sheetName = "当月个车续保率跟踪报表【机构】";
|
||||||
|
ArrayList<BITelsalerRenewalRateRecord> records = null;
|
||||||
|
SqlSession session = null;
|
||||||
|
ImportBIArchievementDataMapper mapper = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
records = ImportBIData.importBITelsalerRenewalRateFromXlsx( filePath, sheetName, true,
|
||||||
|
null );
|
||||||
|
|
||||||
|
session = MybatisUtils.getSqlSessionBatch();
|
||||||
|
mapper = session.getMapper( ImportBIArchievementDataMapper.class );
|
||||||
|
|
||||||
|
// 清理数据
|
||||||
|
mapper.cleanTelsalerRenewalRateData();
|
||||||
|
|
||||||
|
for ( BITelsalerRenewalRateRecord record : records )
|
||||||
|
{
|
||||||
|
mapper.insertTelsalerRenewalRateDataToDB( record );
|
||||||
|
}
|
||||||
|
|
||||||
|
session.commit();
|
||||||
|
|
||||||
|
System.out.println( records );
|
||||||
|
assert (!records.isEmpty());
|
||||||
|
}
|
||||||
|
catch ( Exception error )
|
||||||
|
{
|
||||||
|
assert (false);
|
||||||
|
|
||||||
|
if ( session != null )
|
||||||
|
{
|
||||||
|
session.rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBatchInsertBIDepartmentArchievementToDB()
|
||||||
|
{
|
||||||
|
String filePath = "D:/develop/cpicxim/deskop_task_schedule/数据/测试用/BI部门渗透率续保率.xlsx";
|
||||||
|
String sheetName = "部门";
|
||||||
|
|
||||||
|
ArrayList<BIDepartmentArchievementRecord> records = null;
|
||||||
|
SqlSession session = null;
|
||||||
|
ImportBIArchievementDataMapper mapper = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
records =
|
||||||
|
ImportBIData.importBIDepartmentArchievementRecords( filePath, sheetName, true );
|
||||||
|
session = MybatisUtils.getSqlSessionBatch();
|
||||||
|
mapper = session.getMapper( ImportBIArchievementDataMapper.class );
|
||||||
|
|
||||||
|
mapper.cleanDepartmentAttachingRenewalRateData();
|
||||||
|
|
||||||
|
for ( BIDepartmentArchievementRecord record : records )
|
||||||
|
{
|
||||||
|
mapper.insertDepartmentAttachingRenewalRateDataToDB( record );
|
||||||
|
}
|
||||||
|
|
||||||
|
session.commit();
|
||||||
|
}
|
||||||
|
catch ( Exception error )
|
||||||
|
{
|
||||||
|
if ( session != null )
|
||||||
|
{
|
||||||
|
session.rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user