加入BI机构当月个车续保率跟踪表上传导入功能。

This commit is contained in:
Kane Wang 2023-10-24 15:53:24 +08:00
parent 6ddfe56e6d
commit e4d641021e
12 changed files with 452 additions and 52 deletions

View File

@ -8,7 +8,9 @@ CREATE OR REPLACE PACKAGE telsale_bi_utils IS
PROCEDURE 清理BI电销坐席续保率统计表; PROCEDURE 清理BI电销坐席续保率统计表;
PROCEDURE 清理BI部门业绩统计表; PROCEDURE 清理BI部门渗透率跟踪表;
PROCEDURE 清理BI部门续保率跟踪表;
END telsale_bi_utils; END telsale_bi_utils;
/ /
@ -24,11 +26,16 @@ CREATE OR REPLACE PACKAGE BODY telsale_bi_utils IS
EXECUTE IMMEDIATE 'truncate table BI坐席续保率统计表'; EXECUTE IMMEDIATE 'truncate table BI坐席续保率统计表';
END; END;
PROCEDURE 清理BI部门业绩统计表 IS PROCEDURE 清理BI部门渗透率跟踪表 IS
BEGIN BEGIN
EXECUTE IMMEDIATE 'truncate table BI部门渗透率续保率统计表'; EXECUTE IMMEDIATE 'truncate table BI部门渗透率续保率统计表';
END; END;
PROCEDURE 清理BI部门续保率跟踪表 IS
BEGIN
EXECUTE IMMEDIATE 'truncate table BI机构当月个车续保率跟踪表';
END;
BEGIN BEGIN
-- Initialization -- Initialization
NULL; NULL;

View File

@ -0,0 +1,14 @@
drop table BI机构当月个车续保率跟踪表;
create table BI机构当月个车续保率跟踪表
(
"责任部门" varchar2(100),
"机构目标值1(%)" number,
"到期数-全月" integer,
"序时到期数占比(%)" number,
"个车续保率(序时)(%)" number,
"个车续保率(全月)(%)" number,
"环比昨日(%)" number,
"环比上月(%)" number,
"平均提前签单天数" integer,
"环比" number
);

View File

@ -111,7 +111,11 @@ export default {
}, },
{ {
reportTypeCode: 2, reportTypeCode: 2,
reportTypeName: "部门车非渗透率续保率", reportTypeName: "部门车非渗透率",
},
{
reportTypeCode: 3,
reportTypeName: "当月个车续保率跟踪报表【机构】",
},], },],
sheetIndex: 0, sheetIndex: 0,
firstRow: 2, firstRow: 2,

View File

@ -2,16 +2,17 @@
* @Author: Kane * @Author: Kane
* @Date: 2023-10-11 16:47:59 * @Date: 2023-10-11 16:47:59
* @LastEditors: Kane * @LastEditors: Kane
* @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/mybatis/mapper/ImportArchievementDataMapper.java * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/mybatis/mapper/ImportBIArchievementDataMapper.java
* @Description: * @Description:
* *
* Copyright (c) ${2023} by Kane, All Rights Reserved. * Copyright (c) ${2023} by Kane, All Rights Reserved.
*/ */
package com.cpic.xim.mybatis.mapper; package com.cpic.xim.mybatis.mapper;
import com.cpic.xim.mybatis.pojo.BIDepartmentAttachingRateRecord;
import com.cpic.xim.mybatis.pojo.BIDepartmentRenewalRateRecord;
import com.cpic.xim.mybatis.pojo.BITelsalerAttachingRateRecord; import com.cpic.xim.mybatis.pojo.BITelsalerAttachingRateRecord;
import com.cpic.xim.mybatis.pojo.BITelsalerRenewalRateRecord; import com.cpic.xim.mybatis.pojo.BITelsalerRenewalRateRecord;
import com.cpic.xim.mybatis.pojo.BIDepartmentArchievementRecord;
public interface ImportBIArchievementDataMapper public interface ImportBIArchievementDataMapper
{ {
@ -19,11 +20,15 @@ public interface ImportBIArchievementDataMapper
public void insertTelsalerRenewalRateDataToDB( BITelsalerRenewalRateRecord record ); public void insertTelsalerRenewalRateDataToDB( BITelsalerRenewalRateRecord record );
public void insertDepartmentAttachingRenewalRateDataToDB(BIDepartmentArchievementRecord record); public void insertDepartmentAttachingRateDataToDB(BIDepartmentAttachingRateRecord record);
public void insertDepartmentRenewalRateDataToDB(BIDepartmentRenewalRateRecord record);
public void cleanTelsalerAttachingRateData(); public void cleanTelsalerAttachingRateData();
public void cleanTelsalerRenewalRateData(); public void cleanTelsalerRenewalRateData();
public void cleanDepartmentAttachingRenewalRateData(); public void cleanDepartmentAttachingRateData();
public void cleanDepartmentRenewalRateData();
} }

View File

@ -9,7 +9,7 @@
*/ */
package com.cpic.xim.mybatis.pojo; package com.cpic.xim.mybatis.pojo;
public class BIDepartmentArchievementRecord public class BIDepartmentAttachingRateRecord
{ {
// 部门 // 部门
private String departmentName; private String departmentName;
@ -36,7 +36,7 @@ public class BIDepartmentArchievementRecord
// 客均保费环比上月 // 客均保费环比上月
private double premiumPerCustomerChange; private double premiumPerCustomerChange;
public BIDepartmentArchievementRecord( String departmentName, double departmentObject, public BIDepartmentAttachingRateRecord( String departmentName, double departmentObject,
double objectGap, double motoPremium, double motoPremiumProPortion, double objectGap, double motoPremium, double motoPremiumProPortion,
double nomotoPremium, double attachingRate, double attachingRateChange, double nomotoPremium, double attachingRate, double attachingRateChange,
double customerHandleRate, double customerHandleRateChange, double premiumPerCustomer, double customerHandleRate, double customerHandleRateChange, double premiumPerCustomer,
@ -110,7 +110,7 @@ public class BIDepartmentArchievementRecord
return false; return false;
if ( getClass() != obj.getClass() ) if ( getClass() != obj.getClass() )
return false; return false;
BIDepartmentArchievementRecord other = (BIDepartmentArchievementRecord) obj; BIDepartmentAttachingRateRecord other = (BIDepartmentAttachingRateRecord) obj;
if ( departmentName == null ) if ( departmentName == null )
{ {
if ( other.departmentName != null ) if ( other.departmentName != null )

View File

@ -0,0 +1,214 @@
/*
* @Author: Kane
* @Date: 2023-10-24 11:06:29
* @LastEditors: Kane
* @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/mybatis/pojo/BIDepartmentRenewalRateRecord.java
* @Description: BI机构当月个车续保率跟踪表记录对象
*
* Copyright (c) ${2023} by Kane, All Rights Reserved.
*/
package com.cpic.xim.mybatis.pojo;
public class BIDepartmentRenewalRateRecord
{
private String 责任部门;
private double 机构目标值;
private int 到期数全月;
private double 序时到期数占比;
private double 个车续保率序时;
private double 个车续保率全月;
private double 环比昨日;
private double 环比上月;
private int 平均提前签单天数;
private double 环比;
public BIDepartmentRenewalRateRecord() {}
public BIDepartmentRenewalRateRecord( String 责任部门, double 机构目标值, int 到期数全月, double 序时到期数占比,
double 个车续保率序时, double 个车续保率全月, double 环比昨日, double 环比上月, int 平均提前签单天数, double 环比 )
{
this.责任部门 = 责任部门;
this.机构目标值 = 机构目标值;
this.到期数全月 = 到期数全月;
this.序时到期数占比 = 序时到期数占比;
this.个车续保率序时 = 个车续保率序时;
this.个车续保率全月 = 个车续保率全月;
this.环比昨日 = 环比昨日;
this.环比上月 = 环比上月;
this.平均提前签单天数 = 平均提前签单天数;
this.环比 = 环比;
}
public String get责任部门()
{
return 责任部门;
}
public void set责任部门( String 责任部门 )
{
this.责任部门 = 责任部门;
}
public double get机构目标值()
{
return 机构目标值;
}
public void set机构目标值( double 机构目标值 )
{
this.机构目标值 = 机构目标值;
}
public int get到期数全月()
{
return 到期数全月;
}
public void set到期数全月( int 到期数全月 )
{
this.到期数全月 = 到期数全月;
}
public double get序时到期数占比()
{
return 序时到期数占比;
}
public void set序时到期数占比( double 序时到期数占比 )
{
this.序时到期数占比 = 序时到期数占比;
}
public double get个车续保率序时()
{
return 个车续保率序时;
}
public void set个车续保率序时( double 个车续保率序时 )
{
this.个车续保率序时 = 个车续保率序时;
}
public double get个车续保率全月()
{
return 个车续保率全月;
}
public void set个车续保率全月( double 个车续保率全月 )
{
this.个车续保率全月 = 个车续保率全月;
}
public double get环比昨日()
{
return 环比昨日;
}
public void set环比昨日( double 环比昨日 )
{
this.环比昨日 = 环比昨日;
}
public double get环比上月()
{
return 环比上月;
}
public void set环比上月( double 环比上月 )
{
this.环比上月 = 环比上月;
}
public int get平均提前签单天数()
{
return 平均提前签单天数;
}
public void set平均提前签单天数( int 平均提前签单天数 )
{
this.平均提前签单天数 = 平均提前签单天数;
}
public double get环比()
{
return 环比;
}
public void set环比( double 环比 )
{
this.环比 = 环比;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((责任部门 == null) ? 0 : 责任部门.hashCode());
long temp;
temp = Double.doubleToLongBits( 机构目标值 );
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + 到期数全月;
temp = Double.doubleToLongBits( 序时到期数占比 );
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( 个车续保率序时 );
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( 个车续保率全月 );
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( 环比昨日 );
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( 环比上月 );
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + 平均提前签单天数;
temp = Double.doubleToLongBits( 环比 );
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals( Object obj )
{
if ( this == obj )
return true;
if ( obj == null )
return false;
if ( getClass() != obj.getClass() )
return false;
BIDepartmentRenewalRateRecord other = (BIDepartmentRenewalRateRecord) obj;
if ( 责任部门 == null )
{
if ( other.责任部门 != null )
return false;
}
else if ( !责任部门.equals( other.责任部门 ) )
return false;
if ( Double.doubleToLongBits( 机构目标值 ) != Double.doubleToLongBits( other.机构目标值 ) )
return false;
if ( 到期数全月 != other.到期数全月 )
return false;
if ( Double.doubleToLongBits( 序时到期数占比 ) != Double.doubleToLongBits( other.序时到期数占比 ) )
return false;
if ( Double.doubleToLongBits( 个车续保率序时 ) != Double.doubleToLongBits( other.个车续保率序时 ) )
return false;
if ( Double.doubleToLongBits( 个车续保率全月 ) != Double.doubleToLongBits( other.个车续保率全月 ) )
return false;
if ( Double.doubleToLongBits( 环比昨日 ) != Double.doubleToLongBits( other.环比昨日 ) )
return false;
if ( Double.doubleToLongBits( 环比上月 ) != Double.doubleToLongBits( other.环比上月 ) )
return false;
if ( 平均提前签单天数 != other.平均提前签单天数 )
return false;
if ( Double.doubleToLongBits( 环比 ) != Double.doubleToLongBits( other.环比 ) )
return false;
return true;
}
@Override
public String toString()
{
return "BIDepartmentRenewalRateRecord [责任部门=" + 责任部门 + ", 机构目标值=" + 机构目标值 + ", 到期数全月="
+ 到期数全月 + ", 序时到期数占比=" + 序时到期数占比 + ", 个车续保率序时=" + 个车续保率序时 + ", 个车续保率全月=" + 个车续保率全月
+ ", 环比昨日=" + 环比昨日 + ", 环比上月=" + 环比上月 + ", 平均提前签单天数=" + 平均提前签单天数 + ", 环比=" + 环比
+ "]";
}
}

View File

@ -21,7 +21,8 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.cpic.xim.mybatis.pojo.BIDepartmentArchievementRecord; import com.cpic.xim.mybatis.pojo.BIDepartmentAttachingRateRecord;
import com.cpic.xim.mybatis.pojo.BIDepartmentRenewalRateRecord;
import com.cpic.xim.mybatis.pojo.BITelsalerAttachingRateRecord; import com.cpic.xim.mybatis.pojo.BITelsalerAttachingRateRecord;
import com.cpic.xim.mybatis.pojo.BITelsalerRenewalRateRecord; import com.cpic.xim.mybatis.pojo.BITelsalerRenewalRateRecord;
import com.cpic.xim.utils.poi.MyPOIUtils; import com.cpic.xim.utils.poi.MyPOIUtils;
@ -41,10 +42,14 @@ public final class ImportBIExcelData
{ "责任人", "机构目标值1(%)", "到期数-全月", "序时到期数占比(%)", "个车续保率(序时)(%)", "个车续保率(全月)(%)", "环比昨日(%)", { "责任人", "机构目标值1(%)", "到期数-全月", "序时到期数占比(%)", "个车续保率(序时)(%)", "个车续保率(全月)(%)", "环比昨日(%)",
"环比上月(%)"}; "环比上月(%)"};
private static String[] DepartmentArchievementExcelTitle = new String[] private static String[] DepartmentAttachingRateExcelTitle = new String[]
{ "部门", "目标值-机构", "目标差距", "车险保费(万)", "车险保费占比", "非车保费(万)", "当月保费渗透率", "保费渗透率环比上月", "当月客户渗透率", { "部门", "目标值-机构", "目标差距", "车险保费(万)", "车险保费占比", "非车保费(万)", "当月保费渗透率", "保费渗透率环比上月", "当月客户渗透率",
"客户渗透率环比上月", "当月车非客均保费", "客均保费环比上月"}; "客户渗透率环比上月", "当月车非客均保费", "客均保费环比上月"};
private static String[] DepartmentRenewalRateExcelTitle = new String[]
{ "责任部门", "机构目标值1(%)", "到期数-全月", "序时到期数占比(%)", "个车续保率(序时)(%)", "个车续保率(全月)(%)", "环比昨日(%)",
"环比上月(%)", "平均提前签单天数", "环比",};
/** /**
* 用于通过对比标题行判断excel文件格式的函数 * 用于通过对比标题行判断excel文件格式的函数
* @param sheet * @param sheet
@ -134,7 +139,7 @@ public final class ImportBIExcelData
// 先验证格式不对就抛出错误 // 先验证格式不对就抛出错误
if ( !checkExcelFormat( sheet, null, 0, TelsalerAttachingRateExcelTitle, 0 ) ) if ( !checkExcelFormat( sheet, null, 0, TelsalerAttachingRateExcelTitle, 0 ) )
{ {
throw new InvalidFormatException("Excel文件格式错误请检查报表内容" ); throw new InvalidFormatException( "Excel文件格式错误请检查报表内容" );
} }
for ( Row row : sheet ) for ( Row row : sheet )
@ -172,9 +177,11 @@ public final class ImportBIExcelData
// 当月客户渗透率 // 当月客户渗透率
double customerHandleRateCell = MyPOIUtils.getNumbericCellValue( row, 7 ) * 100; double customerHandleRateCell = MyPOIUtils.getNumbericCellValue( row, 7 ) * 100;
// 客户渗透率环比上月 // 客户渗透率环比上月
double customerHandleRateChangeCell = MyPOIUtils.getNumbericCellValue( row, 8 ) * 100; double customerHandleRateChangeCell =
MyPOIUtils.getNumbericCellValue( row, 8 ) * 100;
// 当月车非客均保费 // 当月车非客均保费
double noMotoPremiumPerCustomerCell = MyPOIUtils.getNumbericCellValue( row, 9 ) * 100; double noMotoPremiumPerCustomerCell =
MyPOIUtils.getNumbericCellValue( row, 9 ) * 100;
// 客均保费环比上月 // 客均保费环比上月
double noMotoPremiumPerCustomerChangeCell = double noMotoPremiumPerCustomerChangeCell =
MyPOIUtils.getNumbericCellValue( row, 10 ) * 100; MyPOIUtils.getNumbericCellValue( row, 10 ) * 100;
@ -242,9 +249,9 @@ public final class ImportBIExcelData
sheet = wb.getSheetAt( sheetIndex ); sheet = wb.getSheetAt( sheetIndex );
int rowIndex = 0; int rowIndex = 0;
if (!checkExcelFormat( sheet, null, 0, TelSalerRenewalRateExcelTitle, 0 )) if ( !checkExcelFormat( sheet, null, 0, TelSalerRenewalRateExcelTitle, 0 ) )
{ {
throw new InvalidFormatException("格式错误,请检查报表内容!"); throw new InvalidFormatException( "格式错误,请检查报表内容!" );
} }
for ( Row row : sheet ) for ( Row row : sheet )
@ -305,10 +312,20 @@ public final class ImportBIExcelData
return records; return records;
} }
public static ArrayList<BIDepartmentArchievementRecord> importBIDepartmentArchievementRecords( /**
String filePath, int sheetIndex, int firstRow ) throws IOException, InvalidFormatException * 读取BI机构当月个车续保率跟踪表
* @param filePath
* @param sheetIndex
* @param firstRow
* @return
* @throws IOException
* @throws InvalidFormatException
*/
public static ArrayList<BIDepartmentAttachingRateRecord> importBIDepartmentAttachingRateRecordsFromXlsx(
String filePath, int sheetIndex, int firstRow )
throws IOException, InvalidFormatException
{ {
ArrayList<BIDepartmentArchievementRecord> records = new ArrayList<>( 5 ); ArrayList<BIDepartmentAttachingRateRecord> records = new ArrayList<>( 5 );
Workbook wb = null; Workbook wb = null;
@ -319,9 +336,9 @@ public final class ImportBIExcelData
Sheet sheet = wb.getSheetAt( sheetIndex ); Sheet sheet = wb.getSheetAt( sheetIndex );
int rowIndex = 0; int rowIndex = 0;
if (!checkExcelFormat( sheet, null, 0, DepartmentArchievementExcelTitle, 0 )) if ( !checkExcelFormat( sheet, null, 0, DepartmentAttachingRateExcelTitle, 0 ) )
{ {
throw new InvalidFormatException("Excel文件格式错误请检查报表内容"); throw new InvalidFormatException( "Excel文件格式错误请检查报表内容" );
} }
for ( Row row : sheet ) for ( Row row : sheet )
@ -351,11 +368,13 @@ public final class ImportBIExcelData
double attachingRate = MyPOIUtils.getNumbericCellValue( row, 6 ) * 100; double attachingRate = MyPOIUtils.getNumbericCellValue( row, 6 ) * 100;
double attachingRateChange = MyPOIUtils.getNumbericCellValue( row, 7 ) * 100; double attachingRateChange = MyPOIUtils.getNumbericCellValue( row, 7 ) * 100;
double customerHandleRate = MyPOIUtils.getNumbericCellValue( row, 8 ) * 100; double customerHandleRate = MyPOIUtils.getNumbericCellValue( row, 8 ) * 100;
double customerHandleRateChange = MyPOIUtils.getNumbericCellValue( row, 9 ) * 100; double customerHandleRateChange =
MyPOIUtils.getNumbericCellValue( row, 9 ) * 100;
double premiumPerCustomer = MyPOIUtils.getNumbericCellValue( row, 10 ) * 100; double premiumPerCustomer = MyPOIUtils.getNumbericCellValue( row, 10 ) * 100;
double premiumPerCustomerChange = MyPOIUtils.getNumbericCellValue( row, 11 ) * 100; double premiumPerCustomerChange =
MyPOIUtils.getNumbericCellValue( row, 11 ) * 100;
BIDepartmentArchievementRecord record = new BIDepartmentArchievementRecord( BIDepartmentAttachingRateRecord record = new BIDepartmentAttachingRateRecord(
departmentName, departmentObject, objectGap, motoPremium, departmentName, departmentObject, objectGap, motoPremium,
motoPremiumProPortion, nomotoPremium, attachingRate, motoPremiumProPortion, nomotoPremium, attachingRate,
attachingRateChange, customerHandleRate, customerHandleRateChange, attachingRateChange, customerHandleRate, customerHandleRateChange,
@ -390,4 +409,84 @@ public final class ImportBIExcelData
return records; return records;
} }
public static ArrayList<BIDepartmentRenewalRateRecord> importBIDepartmentRenewalRateRecordsFromXlsx(
String filePath, int sheetIndex, int firstRow )
throws IOException, InvalidFormatException
{
ArrayList<BIDepartmentRenewalRateRecord> records = new ArrayList<>( 20 );
Workbook wb = null;
try
{
wb = WorkbookFactory.create( new File( filePath ) );
Sheet sheet = wb.getSheetAt( sheetIndex );
int rowIndex = 0;
if ( !checkExcelFormat( sheet, null, 0, DepartmentRenewalRateExcelTitle, 0 ) )
{
throw new InvalidFormatException( "Excel文件格式错误请检查报表内容" );
}
for ( Row row : sheet )
{
rowIndex = row.getRowNum();
if ( rowIndex < firstRow )
{
continue;
}
try
{
String 责任部门 = MyPOIUtils.getStringCellValue( row, 0 );
// 部门为空或者是合计行就跳过
if ( 责任部门.isEmpty() || 责任部门.equals( "合计" ) )
{
continue;
}
double 机构目标值 = MyPOIUtils.getNumbericCellValue( row, 1 ) * 100;
int 到期数全月 = (int) MyPOIUtils.getNumbericCellValue( row, 2 );
double 序时到期数占比 = MyPOIUtils.getNumbericCellValue( row, 3 ) * 100;
double 个车续保率序时 = MyPOIUtils.getNumbericCellValue( row, 4 ) * 100;
double 个车续保率全月 = MyPOIUtils.getNumbericCellValue( row, 5 ) * 100;
double 环比昨日 = MyPOIUtils.getNumbericCellValue( row, 6 ) * 100;
double 环比上月 = MyPOIUtils.getNumbericCellValue( row, 7 ) * 100;
int 平均提前签单天数 = (int) MyPOIUtils.getNumbericCellValue( row, 8 );
double 环比 = MyPOIUtils.getNumbericCellValue( row, 9 ) * 100;
BIDepartmentRenewalRateRecord record = new BIDepartmentRenewalRateRecord( 责任部门,
机构目标值, 到期数全月, 序时到期数占比, 个车续保率序时, 个车续保率全月, 环比昨日, 环比上月, 平均提前签单天数, 环比 );
records.add( record );
}
catch ( NullPointerException error )
{
String message = "" + String.valueOf( rowIndex ) + "行出现NullPointerException异常";
logger.error( message, error );
}
}
}
finally
{
if ( wb != null )
{
try
{
wb.close();
}
catch ( Exception error )
{
error.printStackTrace();
}
}
}
return records;
}
} }

View File

@ -23,7 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.cpic.xim.mybatis.mapper.ImportBIArchievementDataMapper; import com.cpic.xim.mybatis.mapper.ImportBIArchievementDataMapper;
import com.cpic.xim.mybatis.pojo.BIDepartmentArchievementRecord; import com.cpic.xim.mybatis.pojo.BIDepartmentAttachingRateRecord;
import com.cpic.xim.mybatis.pojo.BIDepartmentRenewalRateRecord;
import com.cpic.xim.mybatis.pojo.BITelsalerAttachingRateRecord; import com.cpic.xim.mybatis.pojo.BITelsalerAttachingRateRecord;
import com.cpic.xim.mybatis.pojo.BITelsalerRenewalRateRecord; import com.cpic.xim.mybatis.pojo.BITelsalerRenewalRateRecord;
import com.cpic.xim.mybatis.utils.MybatisUtils; import com.cpic.xim.mybatis.utils.MybatisUtils;
@ -57,14 +58,18 @@ public class ImportBIDataController
{ {
importedCount = importBITeslsalerRenewalRate( filePath, sheetIndex, firstRow ); importedCount = importBITeslsalerRenewalRate( filePath, sheetIndex, firstRow );
} }
else if ( type == ReportType.DepartmentAttachingRenewalRateReport ) else if ( type == ReportType.DepartmentAttachingRateReport )
{ {
importedCount = importBIDepartmentArchievement( filePath, sheetIndex, firstRow ); importedCount = importBIDepartmentAttachingRate( filePath, sheetIndex, firstRow );
}
else if ( type == ReportType.DepartmentRenewalRateReport )
{
importedCount = importBIDepartmentRenewalRate( filePath, sheetIndex, firstRow );
} }
response.setImportedCount(importedCount); response.setImportedCount( importedCount );
response.setSuccess(true); response.setSuccess( true );
response.setMessage("导入成功"); response.setMessage( "导入成功" );
} }
catch ( IOException error ) catch ( IOException error )
{ {
@ -103,9 +108,8 @@ public class ImportBIDataController
try try
{ {
ArrayList<BITelsalerAttachingRateRecord> records = ArrayList<BITelsalerAttachingRateRecord> records = ImportBIExcelData
ImportBIExcelData.importBITelsalerAttachingRateRecordFromXlsx( filePath, .importBITelsalerAttachingRateRecordFromXlsx( filePath, sheetIndex, firstRow );
sheetIndex, firstRow );
session = MybatisUtils.getSqlSessionBatch(); session = MybatisUtils.getSqlSessionBatch();
ImportBIArchievementDataMapper mapper = ImportBIArchievementDataMapper mapper =
@ -134,8 +138,8 @@ public class ImportBIDataController
return importedCount; return importedCount;
} }
private static int importBITeslsalerRenewalRate( String filePath, int sheetIndex, private static int importBITeslsalerRenewalRate( String filePath, int sheetIndex, int firstRow )
int firstRow ) throws PersistenceException, IOException, InvalidFormatException throws PersistenceException, IOException, InvalidFormatException
{ {
ArrayList<BITelsalerRenewalRateRecord> records = null; ArrayList<BITelsalerRenewalRateRecord> records = null;
SqlSession session = null; SqlSession session = null;
@ -174,26 +178,26 @@ public class ImportBIDataController
return importedCount; return importedCount;
} }
private static int importBIDepartmentArchievement( String filePath, int sheetIndex, private static int importBIDepartmentAttachingRate( String filePath, int sheetIndex,
int firstRow ) throws PersistenceException, IOException, InvalidFormatException int firstRow ) throws PersistenceException, IOException, InvalidFormatException
{ {
ArrayList<BIDepartmentArchievementRecord> records = null; ArrayList<BIDepartmentAttachingRateRecord> records = null;
SqlSession session = null; SqlSession session = null;
ImportBIArchievementDataMapper mapper = null; ImportBIArchievementDataMapper mapper = null;
int importedCount = 0; int importedCount = 0;
try try
{ {
records = ImportBIExcelData.importBIDepartmentArchievementRecords( filePath, sheetIndex, records = ImportBIExcelData.importBIDepartmentAttachingRateRecordsFromXlsx( filePath,
firstRow ); sheetIndex, firstRow );
session = MybatisUtils.getSqlSessionBatch(); session = MybatisUtils.getSqlSessionBatch();
mapper = session.getMapper( ImportBIArchievementDataMapper.class ); mapper = session.getMapper( ImportBIArchievementDataMapper.class );
mapper.cleanDepartmentAttachingRenewalRateData(); mapper.cleanDepartmentAttachingRateData();
for ( BIDepartmentArchievementRecord record : records ) for ( BIDepartmentAttachingRateRecord record : records )
{ {
mapper.insertDepartmentAttachingRenewalRateDataToDB( record ); mapper.insertDepartmentAttachingRateDataToDB( record );
importedCount++; importedCount++;
} }
@ -205,6 +209,47 @@ public class ImportBIDataController
{ {
session.rollback(); session.rollback();
} }
throw error;
}
return importedCount;
}
private static int importBIDepartmentRenewalRate( String filePath, int sheetIndex, int firstRow )
throws PersistenceException, IOException, InvalidFormatException
{
ArrayList<BIDepartmentRenewalRateRecord> records = null;
SqlSession session = null;
ImportBIArchievementDataMapper mapper = null;
int importedCount = 0;
try
{
records = ImportBIExcelData.importBIDepartmentRenewalRateRecordsFromXlsx(filePath, sheetIndex, firstRow);
session = MybatisUtils.getSqlSessionBatch();
mapper = session.getMapper(ImportBIArchievementDataMapper.class);
mapper.cleanDepartmentRenewalRateData();
for ( BIDepartmentRenewalRateRecord record : records )
{
mapper.insertDepartmentRenewalRateDataToDB(record);
importedCount++;
}
session.commit();
}
catch ( Exception error)
{
if ( session != null )
{
session.rollback();
}
throw error;
} }
return importedCount; return importedCount;

View File

@ -16,7 +16,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class ImportBIDataRequest public class ImportBIDataRequest
{ {
public enum ReportType { public enum ReportType {
TelsalerAttachingRateReport, TelsalerRenewalRateReport, DepartmentAttachingRenewalRateReport TelsalerAttachingRateReport, TelsalerRenewalRateReport, DepartmentAttachingRateReport, DepartmentRenewalRateReport
}; };
// 导入文件的路径 // 导入文件的路径

View File

@ -16,7 +16,7 @@
#{个车续保率序时},#{个车续保率全月},#{环比昨日},#{环比上月}) #{个车续保率序时},#{个车续保率全月},#{环比昨日},#{环比上月})
</insert> </insert>
<insert id="insertDepartmentAttachingRenewalRateDataToDB" parameterType="com.cpic.xim.mybatis.pojo.BIDepartmentArchievementRecord"> <insert id="insertDepartmentAttachingRateDataToDB" parameterType="com.cpic.xim.mybatis.pojo.BIDepartmentAttachingRateRecord">
insert into BI部门渗透率续保率统计表 ( 部门,"目标值-机构",目标差距,"车险保费", insert into BI部门渗透率续保率统计表 ( 部门,"目标值-机构",目标差距,"车险保费",
车险保费占比,"非车保费",当月保费渗透率,保费渗透率环比上月,当月客户渗透率, 车险保费占比,"非车保费",当月保费渗透率,保费渗透率环比上月,当月客户渗透率,
客户渗透率环比上月,当月车非客均保费,客均保费环比上月) 客户渗透率环比上月,当月车非客均保费,客均保费环比上月)
@ -25,13 +25,25 @@
#{customerHandleRate},#{customerHandleRateChange},#{premiumPerCustomer},#{premiumPerCustomerChange} ) #{customerHandleRate},#{customerHandleRateChange},#{premiumPerCustomer},#{premiumPerCustomerChange} )
</insert> </insert>
<insert id="insertDepartmentRenewalRateDataToDB" parameterType="com.cpic.xim.mybatis.pojo.BIDepartmentRenewalRateRecord" >
insert into BI机构当月个车续保率跟踪表( "责任部门","机构目标值1(%)","到期数-全月" ,"序时到期数占比(%)","个车续保率(序时)(%)",
"个车续保率(全月)(%)","环比昨日(%)","环比上月(%)","平均提前签单天数","环比")
values (#{责任部门},#{机构目标值},#{到期数全月},#{序时到期数占比},
#{个车续保率序时},#{个车续保率全月},#{环比昨日},#{环比上月},
#{平均提前签单天数},#{环比})
</insert>
<select id="cleanTelsalerAttachingRateData" statementType="CALLABLE"> <select id="cleanTelsalerAttachingRateData" statementType="CALLABLE">
call telsale_bi_utils.清理BI电销坐席车非渗透统计表() call telsale_bi_utils.清理BI电销坐席车非渗透统计表()
</select> </select>
<select id="cleanTelsalerRenewalRateData" statementType="CALLABLE"> <select id="cleanTelsalerRenewalRateData" statementType="CALLABLE">
call telsale_bi_utils.清理BI电销坐席续保率统计表() call telsale_bi_utils.清理BI电销坐席续保率统计表()
</select> </select>
<select id="cleanDepartmentAttachingRenewalRateData" statementType="CALLABLE"> <select id="cleanDepartmentAttachingRateData" statementType="CALLABLE">
call telsale_bi_utils.清理BI部门业绩统计表() call telsale_bi_utils.清理BI部门渗透率跟踪表()
</select>
<select id="cleanDepartmentRenewalRateData" statementType="CALLABLE">
call telsale_bi_utils.清理BI部门续保率跟踪表()
</select> </select>
</mapper> </mapper>

View File

@ -109,22 +109,22 @@ public class BatchInsertTest
String filePath = "D:/develop/cpicxim/deskop_task_schedule/数据/测试用/BI部门渗透率续保率.xlsx"; String filePath = "D:/develop/cpicxim/deskop_task_schedule/数据/测试用/BI部门渗透率续保率.xlsx";
String sheetName = "部门"; String sheetName = "部门";
ArrayList<BIDepartmentArchievementRecord> records = null; ArrayList<BIDepartmentAttachingRateRecord> records = null;
SqlSession session = null; SqlSession session = null;
ImportBIArchievementDataMapper mapper = null; ImportBIArchievementDataMapper mapper = null;
try try
{ {
records = records =
ImportBIExcelData.importBIDepartmentArchievementRecords( filePath, 0, 1 ); ImportBIExcelData.importBIDepartmentAttachingRateRecordsFromXlsx( filePath, 0, 1 );
session = MybatisUtils.getSqlSessionBatch(); session = MybatisUtils.getSqlSessionBatch();
mapper = session.getMapper( ImportBIArchievementDataMapper.class ); mapper = session.getMapper( ImportBIArchievementDataMapper.class );
mapper.cleanDepartmentAttachingRenewalRateData(); mapper.cleanDepartmentAttachingRateData();
for ( BIDepartmentArchievementRecord record : records ) for ( BIDepartmentAttachingRateRecord record : records )
{ {
mapper.insertDepartmentAttachingRenewalRateDataToDB( record ); mapper.insertDepartmentAttachingRateDataToDB( record );
} }
session.commit(); session.commit();