改用mybatis
This commit is contained in:
parent
9111067e63
commit
a9b6e88733
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-07-27 11:05:53
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/mybatis/mapper/ArchivementMapper.java
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
package com.cpic.xim.mybatis.mapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface ArchievementMapper
|
||||
{
|
||||
public void getDepartmentArchievement(HashMap<String, Object> params);
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-07-27 11:12:19
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/mybatis/pojo/MensualArchievementItem.java
|
||||
* @Description: 每月业绩对象。
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
package com.cpic.xim.mybatis.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class MensualArchievementItem
|
||||
{
|
||||
public MensualArchievementItem()
|
||||
{}
|
||||
|
||||
public MensualArchievementItem( String month, String premium)
|
||||
{
|
||||
this.month = month;
|
||||
this.premium = premium;
|
||||
}
|
||||
|
||||
public String getMonth()
|
||||
{
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth( String month )
|
||||
{
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public String getPremium()
|
||||
{
|
||||
return premium;
|
||||
}
|
||||
|
||||
public void setPremium( String premium )
|
||||
{
|
||||
this.premium = premium;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "MensualArchievementItem [month=" + month + ", premium=" + premium + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((month == null) ? 0 : month.hashCode());
|
||||
result = prime * result + ((premium == null) ? 0 : premium.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
return true;
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
MensualArchievementItem other = (MensualArchievementItem) obj;
|
||||
if ( month == null )
|
||||
{
|
||||
if ( other.month != null )
|
||||
return false;
|
||||
} else if ( !month.equals( other.month ) )
|
||||
return false;
|
||||
if ( premium == null )
|
||||
{
|
||||
if ( other.premium != null )
|
||||
return false;
|
||||
} else if ( !premium.equals( other.premium ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 月份
|
||||
@JsonProperty( "month" )
|
||||
private String month;
|
||||
|
||||
// 月总保费
|
||||
@JsonProperty( "premium" )
|
||||
private String premium;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "https://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<!-- <properties resource="mybatis/jdbc.properties" /> -->
|
||||
<environments default="development">
|
||||
<environment id="development">
|
||||
<transactionManager type="JDBC" />
|
||||
<dataSource type="POOLED">
|
||||
<property name="driver" value="oracle.jdbc.driver.OracleDriver" />
|
||||
<property name="url" value="jdbc:oracle:thin:@10.39.0.86:1521:xmcx1" />
|
||||
<property name="username" value="desktop_archievement_admin" />
|
||||
<property name="password" value="Cpic123456" />
|
||||
</dataSource>
|
||||
</environment>
|
||||
</environments>
|
||||
<mappers>
|
||||
<mapper resource="mybatis/mappers/StaffMapper.xml" />
|
||||
</mappers>
|
||||
</configuration>
|
@ -0,0 +1,4 @@
|
||||
jdbc.oracle.driver=oracle.jdbc.driver.OracleDriver
|
||||
jdbc.oracle.xmcx1.url=jdbc:oracle:thin:@10.39.0.86:1521:xmcx1
|
||||
jdbc.oracle.xmcx1.username=desktop_archievement_admin
|
||||
jdbc.oracle.xmcx1.password=Cpic123456
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cpic.xim.mybatis.mapper.ArchievementMapper">
|
||||
<select id="getDepartmentArchievement" statementType="CALLABLE" parameterType="java.util.HashMap">
|
||||
call telsale_archievement_pkg.department_archievement(
|
||||
#{a_department_code, mode=IN, jdbcType=VARCHAR},
|
||||
#{a_attaching_rate, mode=OUT, jdbcType=VARCHAR},
|
||||
#{a_renewal_rate, mode=OUT, jdbcType=VARCHAR},
|
||||
#{a_total, mode=OUT, jdbcType=VARCHAR},
|
||||
#{a_mensual_cur, mode=OUT, jdbcType=CURSOR, resultMap=MensualArchievementMapper})
|
||||
</select>
|
||||
<resultMap id="MensualArchievementMapper" type="MensualArchievementItem">
|
||||
<id property="month" column="mm" />
|
||||
<result property="premium" column="bf" />
|
||||
</resultMap>
|
||||
</mapper>
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "https://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<properties resource="mybatis/jdbc.properties" />
|
||||
|
||||
<!-- 类型别名 -->
|
||||
<typeAliases>
|
||||
<package name="com.cpic.xim.mybatis.pojo" />
|
||||
</typeAliases>
|
||||
|
||||
<environments default="development">
|
||||
<environment id="development">
|
||||
<transactionManager type="JDBC" />
|
||||
<dataSource type="POOLED">
|
||||
<property name="driver" value="${jdbc.oracle.driver}" />
|
||||
<property name="url" value="${jdbc.oracle.xmcx1.url}" />
|
||||
<property name="username" value="${jdbc.oracle.xmcx1.username}" />
|
||||
<property name="password" value="${jdbc.oracle.xmcx1.password}" />
|
||||
</dataSource>
|
||||
</environment>
|
||||
</environments>
|
||||
|
||||
<mappers>
|
||||
<!-- <mapper resource="mybatis/mapper/StaffMapper.xml" /> -->
|
||||
<mapper resource="mybatis/mapper/ArchievementMapper.xml" />
|
||||
</mappers>
|
||||
</configuration>
|
@ -9,15 +9,28 @@
|
||||
*/
|
||||
package com.cpic.xim.DesktopArchievement.test;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import org.apache.ibatis.io.Resources;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
|
||||
import org.junit.Test;
|
||||
import com.cpic.xim.mybatis.mapper.ArchievementMapper;
|
||||
import com.cpic.xim.utils.archievement.DepartmentArchievement;
|
||||
import com.cpic.xim.utils.ranking.CallerRankingList;
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings( "all" )
|
||||
public class DesktopArchievementTest
|
||||
{
|
||||
private static String configFilePath = "mybatis/mybatis-config.xml";
|
||||
|
||||
@Test
|
||||
public void testQueryArchievement()
|
||||
{
|
||||
@ -55,4 +68,31 @@ public class DesktopArchievementTest
|
||||
|
||||
assertNotNull( rankingList );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDepartmentArchievement()
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream configFile = Resources.getResourceAsStream( configFilePath );
|
||||
SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
|
||||
SqlSessionFactory factory = builder.build( configFile );
|
||||
SqlSession session = factory.openSession();
|
||||
|
||||
ArchievementMapper mapper = session.getMapper( ArchievementMapper.class );
|
||||
|
||||
HashMap<String,Object> params = new HashMap<>();
|
||||
params.put("a_department_code", "QDI");
|
||||
|
||||
mapper.getDepartmentArchievement( params );
|
||||
|
||||
System.out.println(params.toString());
|
||||
|
||||
assertTrue( params.size() > 1 );
|
||||
}
|
||||
catch (IOException error )
|
||||
{
|
||||
assert( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user