保存进度!
This commit is contained in:
		@@ -64,7 +64,7 @@ public class MybatisUtils
 | 
			
		||||
        // 没有缓存的就创建一个新的
 | 
			
		||||
        InputStream configIS = Resources.getResourceAsStream( configFile );
 | 
			
		||||
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
 | 
			
		||||
        sessionBatch = factory.openSession(ExecutorType.BATCH );
 | 
			
		||||
        sessionBatch = factory.openSession(ExecutorType.BATCH, false );
 | 
			
		||||
 | 
			
		||||
        //保存
 | 
			
		||||
        SessionMapBatch.put( configFile, sessionBatch );
 | 
			
		||||
@@ -106,7 +106,7 @@ public class MybatisUtils
 | 
			
		||||
        // 没有缓存的就创建一个新的
 | 
			
		||||
        InputStream configIS = Resources.getResourceAsStream( DEFAULT_CONFIGFILE );
 | 
			
		||||
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
 | 
			
		||||
        sessionBatch = factory.openSession(ExecutorType.BATCH );
 | 
			
		||||
        sessionBatch = factory.openSession(ExecutorType.BATCH, false );
 | 
			
		||||
 | 
			
		||||
        //保存
 | 
			
		||||
        SessionMapBatch.put( DEFAULT_CONFIGFILE, sessionBatch );
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,65 @@
 | 
			
		||||
/*
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2023-10-12 00:34:39
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/web/controllers/dataimport/TelsalerArchievement/ImportTelsalerArchievementController.java
 | 
			
		||||
 * @Description: 
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2023} by Kane, All Rights Reserved. 
 | 
			
		||||
 */
 | 
			
		||||
package com.cpic.xim.web.controllers.dataimport.TelsalerArchievement;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import org.apache.ibatis.session.SqlSession;
 | 
			
		||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import com.cpic.xim.mybatis.mapper.ImportArchievementDataMapper;
 | 
			
		||||
import com.cpic.xim.mybatis.pojo.TelsalerAttachingRateRecord;
 | 
			
		||||
import com.cpic.xim.mybatis.utils.MybatisUtils;
 | 
			
		||||
import com.cpic.xim.utils.data.TelsalerArchievementData;
 | 
			
		||||
 | 
			
		||||
@Controller
 | 
			
		||||
@RequestMapping(method=RequestMethod.POST, path="/import_telsaler_archievement")
 | 
			
		||||
public class ImportTelsalerArchievementController
 | 
			
		||||
{
 | 
			
		||||
    void importTelsalerAttachingRate()
 | 
			
		||||
    {
 | 
			
		||||
        String filePath = "D:\\develop\\cpicxim\\desktop_task_schedule\\数据\\测试用\\坐席车非渗透.xlsx";
 | 
			
		||||
        SqlSession session = null;
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            ArrayList<TelsalerAttachingRateRecord> records = TelsalerArchievementData.importTelsalerAttachingRateRecordFromXlsx( filePath, null,
 | 
			
		||||
                    true );
 | 
			
		||||
            session = MybatisUtils.getSqlSessionBatch();
 | 
			
		||||
            ImportArchievementDataMapper mapper =  session.getMapper( ImportArchievementDataMapper.class );
 | 
			
		||||
            
 | 
			
		||||
            for ( TelsalerAttachingRateRecord record : records )
 | 
			
		||||
            {
 | 
			
		||||
                mapper.importTesalerAttachingRateDataToDB(record);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            session.commit();
 | 
			
		||||
 | 
			
		||||
            assert( true );
 | 
			
		||||
        }
 | 
			
		||||
        catch ( IOException error )
 | 
			
		||||
        {
 | 
			
		||||
            assert (false);
 | 
			
		||||
        }
 | 
			
		||||
        catch ( InvalidFormatException error )
 | 
			
		||||
        {
 | 
			
		||||
            assert (false);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception error)
 | 
			
		||||
        {
 | 
			
		||||
            if ( session != null)
 | 
			
		||||
            {
 | 
			
		||||
                session.rollback();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user