保存进度!

This commit is contained in:
2023-11-21 19:21:01 +08:00
parent 84b2e906f3
commit 0c89df8c34
8 changed files with 88 additions and 56 deletions

View File

@@ -13,7 +13,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spring.version>5.3.30</spring.version>
<spring.version>5.3.24</spring.version>
<log4j2.version>2.20.0</log4j2.version>
<!-- <spring.version>6.0.11</spring.version> -->
</properties>

View File

@@ -20,8 +20,10 @@ import org.apache.ibatis.session.SqlSessionFactoryBuilder;
public class MybatisUtils
{
private static HashMap<String, SqlSession> SessionMap = new HashMap<>(5);
private static HashMap<String, SqlSession> SessionMapBatch = new HashMap<>(5);
private static HashMap<String, SqlSession> SessionMap = new HashMap<>( 5 );
private static HashMap<String, SqlSession> SessionMapBatch = new HashMap<>( 5 );
private static HashMap<String, SqlSessionFactory> SessionFactoryMap = new HashMap<>( 5 );
private static HashMap<String, SqlSessionFactory> SessionFactoryMapBatch = new HashMap<>( 5 );
private static String DEFAULT_CONFIGFILE = "mybatis/mybatis-config.xml";
/**
@@ -33,43 +35,45 @@ public class MybatisUtils
public static SqlSession getSqlSession( String configFile ) throws IOException
{
// 根据配置文件的路径查找是否已经创建了对应的session
SqlSession session = SessionMap.get( configFile );
SqlSessionFactory factory = SessionFactoryMap.get( configFile );
// 找到就直接返回
if ( session != null )
if ( factory != null )
{
return session;
return factory.openSession();
}
// 没找到就创建一个
InputStream configIS = Resources.getResourceAsStream( configFile );
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
session = factory.openSession();
factory = new SqlSessionFactoryBuilder().build( configIS );
SqlSession session = factory.openSession();
// 保存
SessionMap.put( configFile, session );
SessionFactoryMap.put( configFile, factory );
return session;
}
public static SqlSession getSqlSessionBatch( String configFile ) throws IOException
{
SqlSession sessionBatch = SessionMapBatch.get( configFile );
// 根据配置文件的路径查找是否已经创建了对应的session
SqlSessionFactory factory = SessionFactoryMap.get( configFile );
if ( sessionBatch != null )
// 找到就直接返回
if ( factory != null )
{
return sessionBatch;
return factory.openSession();
}
// 没有缓存的就创建一个新的
// 没找到就创建一个
InputStream configIS = Resources.getResourceAsStream( configFile );
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
sessionBatch = factory.openSession(ExecutorType.BATCH, false );
factory = new SqlSessionFactoryBuilder().build( configIS );
SqlSession session = factory.openSession( ExecutorType.BATCH, false );
//保存
SessionMapBatch.put( configFile, sessionBatch );
// 保存
SessionFactoryMap.put( configFile, factory );
return sessionBatch;
return session;
}
/**
@@ -80,21 +84,21 @@ public class MybatisUtils
public static SqlSession getSqlSession() throws IOException
{
// 根据配置文件的路径查找是否已经创建了对应的session
SqlSession session = SessionMap.get( DEFAULT_CONFIGFILE );
SqlSessionFactory factory = SessionFactoryMap.get( DEFAULT_CONFIGFILE );
// 找到就直接返回
if ( session != null )
if ( factory != null )
{
return session;
return factory.openSession();
}
// 没找到就创建一个
InputStream configIS = Resources.getResourceAsStream( DEFAULT_CONFIGFILE );
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
session = factory.openSession();
factory = new SqlSessionFactoryBuilder().build( configIS );
SqlSession session = factory.openSession();
// 保存
SessionMap.put( DEFAULT_CONFIGFILE, session );
SessionFactoryMap.put( DEFAULT_CONFIGFILE, factory );
return session;
}
@@ -108,21 +112,23 @@ public class MybatisUtils
*/
public static SqlSession getSqlSessionBatch() throws IOException
{
SqlSession sessionBatch = SessionMapBatch.get( DEFAULT_CONFIGFILE );
// 根据配置文件的路径查找是否已经创建了对应的session
SqlSessionFactory factory = SessionFactoryMap.get( DEFAULT_CONFIGFILE );
if ( sessionBatch != null )
// 找到就直接返回
if ( factory != null )
{
return sessionBatch;
return factory.openSession();
}
// 没有缓存的就创建一个新的
// 没找到就创建一个
InputStream configIS = Resources.getResourceAsStream( DEFAULT_CONFIGFILE );
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
sessionBatch = factory.openSession(ExecutorType.BATCH, false );
factory = new SqlSessionFactoryBuilder().build( configIS );
SqlSession session = factory.openSession( ExecutorType.BATCH, false );
//保存
SessionMapBatch.put( DEFAULT_CONFIGFILE, sessionBatch );
// 保存
SessionFactoryMap.put( DEFAULT_CONFIGFILE, factory );
return sessionBatch;
return session;
}
}

View File

@@ -61,7 +61,7 @@ public class CallerArchievement
params.put( "a_caller_code", callerCode );
session.clearCache();
// session.clearCache();
mapper.getCallerArchievement( params );
// 总业绩

View File

@@ -38,7 +38,7 @@
</insert>
<select id="cleanTelsalerAttachingRateData" statementType="CALLABLE">
call telsale_bi_utils.清理BI电销坐席车非渗透跟踪表()
call telsale_bi_utils.清理BI电销坐席车非渗透跟踪表()
</select>
<select id="cleanTelsalerRenewalRateData" statementType="CALLABLE">
call telsale_bi_utils.清理BI电销坐席续保率跟踪表()