保存进度!
This commit is contained in:
parent
374a87e1ee
commit
7ab604f3dd
@ -9,22 +9,32 @@
|
||||
*/
|
||||
package com.cpic.xim.utils.archievement;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.cpic.xim.mybatis.mapper.ArchievementMapper;
|
||||
import com.cpic.xim.mybatis.pojo.MensualArchievementItem;
|
||||
import com.cpic.xim.mybatis.utils.MybatisUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import oracle.jdbc.OracleCallableStatement;
|
||||
import oracle.jdbc.OracleTypes;
|
||||
|
||||
public class DepartmentArchievement
|
||||
{
|
||||
|
||||
// 以后要改
|
||||
private static String jdbcURL = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1";
|
||||
private static String userName = "desktop_archievement_admin";
|
||||
private static String password = "Cpic123456";
|
||||
// private static String jdbcURL = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1";
|
||||
// private static String userName = "desktop_archievement_admin";
|
||||
// private static String password = "Cpic123456";
|
||||
|
||||
// mybatis配置文件路径
|
||||
private static String mybatisConfigFile = "mybatis/mybatis-config.xml";
|
||||
|
||||
// log4j2
|
||||
private static Logger logger = LoggerFactory.getLogger(DepartmentArchievement.class);
|
||||
|
||||
/**
|
||||
* 默认的构造函数,提供给json使用。
|
||||
@ -32,27 +42,69 @@ public class DepartmentArchievement
|
||||
public DepartmentArchievement()
|
||||
{
|
||||
this.totalArchievement = 0;
|
||||
this.mensualArchievementList = new Vector<>();
|
||||
this.mensualArchievementList = new ArrayList<>();
|
||||
this.insuranceRenewalRate = "";
|
||||
this.attachingRate = "";
|
||||
this.departmentCode = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 构造函数,提供所有成员对象的值。
|
||||
* @param totalArchievement
|
||||
* @param mensualArchievementList
|
||||
* @param insuranceRenewalRate
|
||||
* @param attachingRate
|
||||
* @param departmentCode 部门代码
|
||||
* @param totalArchievement 总业绩
|
||||
* @param mensualArchievementList 每月业绩表
|
||||
* @param insuranceRenewalRate 续保率
|
||||
* @param attachingRate 车非渗透率
|
||||
*/
|
||||
public DepartmentArchievement( long totalArchievement, Vector<Long> mensualArchievementList,
|
||||
String insuranceRenewalRate, String attachingRate)
|
||||
public DepartmentArchievement( String departmentCode, long totalArchievement,
|
||||
List<MensualArchievementItem> mensualArchievementList, String insuranceRenewalRate, String attachingRate)
|
||||
{
|
||||
this.departmentCode = departmentCode;
|
||||
this.totalArchievement = totalArchievement;
|
||||
this.mensualArchievementList = mensualArchievementList;
|
||||
this.insuranceRenewalRate = insuranceRenewalRate;
|
||||
this.attachingRate = attachingRate;
|
||||
}
|
||||
|
||||
public static DepartmentArchievement getDepartmentArchievement( String departmentCode )
|
||||
throws IOException
|
||||
{
|
||||
DepartmentArchievement archievement = null;
|
||||
|
||||
try
|
||||
{
|
||||
SqlSession session = MybatisUtils.getSqlSession( mybatisConfigFile );
|
||||
ArchievementMapper mapper = session.getMapper(ArchievementMapper.class);
|
||||
|
||||
// 参数集合
|
||||
HashMap<String, Object> params = new HashMap<>(5);
|
||||
|
||||
params.put("a_department_code", departmentCode);
|
||||
|
||||
mapper.getDepartmentArchievement(params);
|
||||
|
||||
String totalArchievement = (String)params.get("a_total");
|
||||
String attachingRate = (String)params.get("a_attaching_rate");
|
||||
String renewalRate = (String)params.get("a_renewal_rate");
|
||||
List<MensualArchievementItem> mensual = (List<MensualArchievementItem>)params.get("a_mensual_cur");
|
||||
|
||||
archievement = new DepartmentArchievement(departmentCode, 0, mensual, renewalRate, attachingRate);
|
||||
|
||||
|
||||
}
|
||||
catch ( IOException error )
|
||||
{
|
||||
String errorMessage = "查询" + departmentCode + "业绩时出现错误。";
|
||||
|
||||
logger.error(errorMessage, error);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
||||
return archievement;
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态方法,用于根据部门代码,查询部门业绩,生成一个 DepartmentArchievement 对象。
|
||||
* @param departmentCode 部门代码
|
||||
@ -60,87 +112,87 @@ public class DepartmentArchievement
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public static DepartmentArchievement queryDepartmentArchievement( String departmentCode )
|
||||
throws SQLException, ClassNotFoundException
|
||||
{
|
||||
Connection connection = null;
|
||||
java.sql.CallableStatement statement = null;
|
||||
ResultSet menusual_cursor = null;
|
||||
// public static DepartmentArchievement queryDepartmentArchievement( String departmentCode )
|
||||
// throws SQLException, ClassNotFoundException
|
||||
// {
|
||||
// Connection connection = null;
|
||||
// java.sql.CallableStatement statement = null;
|
||||
// ResultSet menusual_cursor = null;
|
||||
|
||||
DepartmentArchievement archievement = null;
|
||||
// DepartmentArchievement archievement = null;
|
||||
|
||||
String sql = "{call telsale_archievement_pkg.department_archievement(?,?,?,?,?)}";
|
||||
// String sql = "{call telsale_archievement_pkg.department_archievement(?,?,?,?,?)}";
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName( "oracle.jdbc.driver.OracleDriver" );
|
||||
connection = DriverManager.getConnection( jdbcURL, userName, password );
|
||||
statement = connection.prepareCall( sql );
|
||||
// try
|
||||
// {
|
||||
// Class.forName( "oracle.jdbc.driver.OracleDriver" );
|
||||
// connection = DriverManager.getConnection( jdbcURL, userName, password );
|
||||
// statement = connection.prepareCall( sql );
|
||||
|
||||
statement.setString( 1, departmentCode );
|
||||
statement.registerOutParameter( 2, java.sql.Types.VARCHAR );
|
||||
statement.registerOutParameter( 3, java.sql.Types.VARCHAR );
|
||||
statement.registerOutParameter( 4, java.sql.Types.INTEGER );
|
||||
statement.registerOutParameter( 5, OracleTypes.CURSOR );
|
||||
// statement.setString( 1, departmentCode );
|
||||
// statement.registerOutParameter( 2, java.sql.Types.VARCHAR );
|
||||
// statement.registerOutParameter( 3, java.sql.Types.VARCHAR );
|
||||
// statement.registerOutParameter( 4, java.sql.Types.INTEGER );
|
||||
// statement.registerOutParameter( 5, OracleTypes.CURSOR );
|
||||
|
||||
statement.execute();
|
||||
// statement.execute();
|
||||
|
||||
Vector<Long> menusual_list = new Vector<Long>();
|
||||
String attach_rate = statement.getString( 2 );
|
||||
String renewal_rate = statement.getString( 3 );
|
||||
long totalArchievement = statement.getInt( 4 );
|
||||
// Vector<Long> menusual_list = new Vector<Long>();
|
||||
// String attach_rate = statement.getString( 2 );
|
||||
// String renewal_rate = statement.getString( 3 );
|
||||
// long totalArchievement = statement.getInt( 4 );
|
||||
|
||||
menusual_cursor = ((OracleCallableStatement) statement).getCursor( 5 );
|
||||
// menusual_cursor = ((OracleCallableStatement) statement).getCursor( 5 );
|
||||
|
||||
while ( menusual_cursor.next())
|
||||
{
|
||||
menusual_list.add( menusual_cursor.getLong( 2 ) );
|
||||
}
|
||||
// while ( menusual_cursor.next())
|
||||
// {
|
||||
// menusual_list.add( menusual_cursor.getLong( 2 ) );
|
||||
// }
|
||||
|
||||
archievement = new DepartmentArchievement( totalArchievement, menusual_list,
|
||||
renewal_rate, attach_rate );
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( menusual_cursor != null )
|
||||
{
|
||||
menusual_cursor.close();
|
||||
}
|
||||
}
|
||||
catch ( Exception exception )
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
// archievement = new DepartmentArchievement( departmentCode, totalArchievement,
|
||||
// menusual_list, renewal_rate, attach_rate );
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if ( menusual_cursor != null )
|
||||
// {
|
||||
// menusual_cursor.close();
|
||||
// }
|
||||
// }
|
||||
// catch ( Exception exception )
|
||||
// {
|
||||
// exception.printStackTrace();
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
if ( statement != null )
|
||||
{
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
catch ( Exception exception )
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
// try
|
||||
// {
|
||||
// if ( statement != null )
|
||||
// {
|
||||
// statement.close();
|
||||
// }
|
||||
// }
|
||||
// catch ( Exception exception )
|
||||
// {
|
||||
// exception.printStackTrace();
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
if ( connection != null )
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
catch ( Exception exception )
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
// try
|
||||
// {
|
||||
// if ( connection != null )
|
||||
// {
|
||||
// connection.close();
|
||||
// }
|
||||
// }
|
||||
// catch ( Exception exception )
|
||||
// {
|
||||
// exception.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
return archievement;
|
||||
}
|
||||
// return archievement;
|
||||
// }
|
||||
|
||||
public long getTotalArchievement()
|
||||
{
|
||||
@ -152,12 +204,12 @@ public class DepartmentArchievement
|
||||
this.totalArchievement = totalArchievement;
|
||||
}
|
||||
|
||||
public Vector<Long> getMensualArchievementList()
|
||||
public List<MensualArchievementItem> getMensualArchievementList()
|
||||
{
|
||||
return mensualArchievementList;
|
||||
}
|
||||
|
||||
public void setMensualArchievementList( Vector<Long> mensualArchievementList )
|
||||
public void setMensualArchievementList( List<MensualArchievementItem> mensualArchievementList )
|
||||
{
|
||||
this.mensualArchievementList = mensualArchievementList;
|
||||
}
|
||||
@ -182,13 +234,26 @@ public class DepartmentArchievement
|
||||
this.attachingRate = attachingRate;
|
||||
}
|
||||
|
||||
public String getDepartmentCode()
|
||||
{
|
||||
return departmentCode;
|
||||
}
|
||||
|
||||
public void setDepartmentCode( String departmentCode )
|
||||
{
|
||||
this.departmentCode = departmentCode;
|
||||
}
|
||||
|
||||
@JsonProperty( "department_code" )
|
||||
private String departmentCode;
|
||||
|
||||
@JsonProperty( "total_archievement" )
|
||||
private long totalArchievement; // 总业绩
|
||||
|
||||
// 每月业绩列表
|
||||
// 要保证数据是按照月份排序。
|
||||
@JsonProperty( "mensual_archievement_list" )
|
||||
private Vector<Long> mensualArchievementList;
|
||||
private List<MensualArchievementItem> mensualArchievementList;
|
||||
|
||||
@JsonProperty( "insurance_renewal_rate" )
|
||||
private String insuranceRenewalRate; // 续保率
|
||||
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-07-28 18:39:50
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/utils/exception/ConfigFileExecption.java
|
||||
* @Description: 配置文件异常
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
package com.cpic.xim.utils.exception;
|
||||
|
||||
public class ConfigFileExecption extends Exception
|
||||
{
|
||||
public ConfigFileExecption()
|
||||
{
|
||||
super("配置文件错误!");
|
||||
}
|
||||
|
||||
public ConfigFileExecption( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
|
||||
package com.cpic.xim.web.controllers.archievement;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Vector;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -56,7 +57,7 @@ public class ArchievementQueryController
|
||||
{
|
||||
// 查询业绩
|
||||
departmentArch = DepartmentArchievement
|
||||
.queryDepartmentArchievement( request.getDepartmentCode() );
|
||||
.getDepartmentArchievement( request.getDepartmentCode() );
|
||||
|
||||
result.setTotalArchievement( departmentArch.getTotalArchievement() );
|
||||
result.setInsuranceRenewalRate( departmentArch.getInsuranceRenewalRate() );
|
||||
@ -67,11 +68,7 @@ public class ArchievementQueryController
|
||||
result.addBackwardStaff( "王炜" );
|
||||
result.setMensualArchievementList( departmentArch.getMensualArchievementList() );
|
||||
}
|
||||
catch ( SQLException error )
|
||||
{
|
||||
|
||||
}
|
||||
catch ( ClassNotFoundException error )
|
||||
catch ( IOException error )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -10,9 +10,11 @@
|
||||
|
||||
package com.cpic.xim.web.controllers.archievement;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Vector;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.cpic.xim.mybatis.pojo.MensualArchievementItem;
|
||||
import com.cpic.xim.web.controllers.QueryResult;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* 查询部门业绩返回结果。
|
||||
@ -22,7 +24,7 @@ public class DepartmentArchievementQueryResult extends QueryResult
|
||||
{
|
||||
DepartmentArchievementQueryResult()
|
||||
{
|
||||
mensualArchievementList = new Vector<Long>();
|
||||
mensualArchievementList = new LinkedList<MensualArchievementItem>();
|
||||
advanceRewardGainers = new Vector<String>();
|
||||
leadingRewardGainers = new Vector<String>();
|
||||
backwardList = new Vector<String>();
|
||||
@ -38,12 +40,12 @@ public class DepartmentArchievementQueryResult extends QueryResult
|
||||
this.totalArchievement = totalArchievement;
|
||||
}
|
||||
|
||||
public Vector<Long> getMensualArchievementList()
|
||||
public LinkedList<MensualArchievementItem> getMensualArchievementList()
|
||||
{
|
||||
return mensualArchievementList;
|
||||
}
|
||||
|
||||
public void setMensualArchievementList( Vector<Long> mensualArchievementList )
|
||||
public void setMensualArchievementList( LinkedList<MensualArchievementItem> mensualArchievementList )
|
||||
{
|
||||
this.mensualArchievementList = mensualArchievementList;
|
||||
}
|
||||
@ -119,7 +121,7 @@ public class DepartmentArchievementQueryResult extends QueryResult
|
||||
// 每月业绩列表
|
||||
// 要保证数据是按照月份排序。
|
||||
@JsonProperty( "mensual_archievement_list" )
|
||||
private Vector<Long> mensualArchievementList;
|
||||
private LinkedList<MensualArchievementItem> mensualArchievementList;
|
||||
|
||||
@JsonProperty( "insurance_renewal_rate" )
|
||||
private String insuranceRenewalRate; // 续保率
|
||||
|
@ -14,14 +14,16 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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.mybatis.pojo.MensualArchievementItem;
|
||||
import com.cpic.xim.utils.ranking.CallerRankingList;
|
||||
|
||||
|
||||
@ -31,23 +33,6 @@ public class DesktopArchievementTest
|
||||
{
|
||||
private static String configFilePath = "mybatis/mybatis-config.xml";
|
||||
|
||||
@Test
|
||||
public void testQueryArchievement()
|
||||
{
|
||||
try
|
||||
{
|
||||
DepartmentArchievement.queryDepartmentArchievement( "QDI" );
|
||||
}
|
||||
catch ( SQLException error )
|
||||
{
|
||||
System.out.println( error.getMessage() );
|
||||
}
|
||||
catch ( ClassNotFoundException error )
|
||||
{
|
||||
System.out.println( error.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCallerRankingList()
|
||||
{
|
||||
@ -80,19 +65,23 @@ public class DesktopArchievementTest
|
||||
SqlSession session = factory.openSession();
|
||||
|
||||
ArchievementMapper mapper = session.getMapper( ArchievementMapper.class );
|
||||
ArrayList<MensualArchievementItem> mensual = null;
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
|
||||
HashMap<String,Object> params = new HashMap<>();
|
||||
params.put("a_department_code", "QDI");
|
||||
params.put( "a_department_code", "QDI" );
|
||||
|
||||
mapper.getDepartmentArchievement( params );
|
||||
|
||||
System.out.println(params.toString());
|
||||
mensual = (List<MensualArchievementItem>)params.get("a_mensual_cur");
|
||||
|
||||
System.out.println( params.toString() );
|
||||
System.out.println( mensual.toString() );
|
||||
|
||||
assertTrue( params.size() > 1 );
|
||||
}
|
||||
catch (IOException error )
|
||||
catch ( IOException error )
|
||||
{
|
||||
assert( false );
|
||||
assert (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user