完成读取车非渗透表。

This commit is contained in:
Kane Wang 2023-10-09 18:37:44 +08:00
parent e40b81672a
commit e805bf914b
3 changed files with 230 additions and 17 deletions

View File

@ -15,34 +15,110 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class TelsalerAttachingRateRecord public class TelsalerAttachingRateRecord
{ {
// 统计日期 // 统计日期
@JsonProperty("summaryDate") @JsonProperty( "summaryDate" )
private LocalDate summaryDate; private LocalDate summaryDate;
// 坐席名称 // 坐席名称
@JsonProperty("telsalerName") @JsonProperty( "telsalerName" )
private String telsalerName; private String telsalerName;
// 车险保费 // 车险保费
@JsonProperty("motoPremium") @JsonProperty( "motoPremium" )
private double motoPremium; private double motoPremium;
// 非车险保费 // 非车险保费
@JsonProperty("nomotoPremium") @JsonProperty( "nomotoPremium" )
private double nomotoPremium; private double nomotoPremium;
// 车险保费占比 // 车险保费占比
@JsonProperty("motoPremiumProportion") @JsonProperty( "motoPremiumProportion" )
private double motoPremiumProportion; private double motoPremiumProportion;
// 渗透率 // 渗透率
@JsonProperty("attachingRate") @JsonProperty( "attachingRate" )
private double attachingRate; private double attachingRate;
// 渗透率环比上月 // 渗透率环比上月
@JsonProperty("attachingRateChange") @JsonProperty( "attachingRateChange" )
private double attachingRateChange; private double attachingRateChange;
public TelsalerAttachingRateRecord() {} // 当月客户渗透率
@JsonProperty( "customerHandleRateCell" )
private double customerHandleRateCell;
// 客户渗透率环比上月
@JsonProperty( "customerHandleRateChangeCell" )
private double customerHandleRateChangeCell;
// 当月车非客均保费
@JsonProperty( "noMotoPremiumPerCustomerCell" )
private double noMotoPremiumPerCustomerCell;
// 客均保费环比上月
@JsonProperty( "noMotoPremiumPerCustomerChangeCell" )
private double noMotoPremiumPerCustomerChangeCell;
public TelsalerAttachingRateRecord()
{}
public TelsalerAttachingRateRecord( LocalDate summaryDate, String telsalerName,
double motoPremium, double nomotoPremium, double motoPremiumProportion,
double attachingRate, double attachingRateChange, double customerHandleRateCell,
double customerHandleRateChangeCell, double noMotoPremiumPerCustomerCell,
double noMotoPremiumPerCustomerChangeCell )
{
this.summaryDate = summaryDate;
this.telsalerName = telsalerName;
this.motoPremium = motoPremium;
this.nomotoPremium = nomotoPremium;
this.motoPremiumProportion = motoPremiumProportion;
this.attachingRate = attachingRate;
this.attachingRateChange = attachingRateChange;
this.customerHandleRateCell = customerHandleRateCell;
this.customerHandleRateChangeCell = customerHandleRateChangeCell;
this.noMotoPremiumPerCustomerCell = noMotoPremiumPerCustomerCell;
this.noMotoPremiumPerCustomerChangeCell = noMotoPremiumPerCustomerChangeCell;
}
public double getCustomerHandleRateCell()
{
return customerHandleRateCell;
}
public void setCustomerHandleRateCell( double customerHandleRateCell )
{
this.customerHandleRateCell = customerHandleRateCell;
}
public double getCustomerHandleRateChangeCell()
{
return customerHandleRateChangeCell;
}
public void setCustomerHandleRateChangeCell( double customerHandleRateChangeCell )
{
this.customerHandleRateChangeCell = customerHandleRateChangeCell;
}
public double getNoMotoPremiumPerCustomerCell()
{
return noMotoPremiumPerCustomerCell;
}
public void setNoMotoPremiumPerCustomerCell( double noMotoPremiumPerCustomerCell )
{
this.noMotoPremiumPerCustomerCell = noMotoPremiumPerCustomerCell;
}
public double getNoMotoPremiumPerCustomerChangeCell()
{
return noMotoPremiumPerCustomerChangeCell;
}
public void setNoMotoPremiumPerCustomerChangeCell( double noMotoPremiumPerCustomerChangeCell )
{
this.noMotoPremiumPerCustomerChangeCell = noMotoPremiumPerCustomerChangeCell;
}
@Override @Override
public String toString() public String toString()
@ -50,7 +126,12 @@ public class TelsalerAttachingRateRecord
return "TelsalerAttachingRateRecord [summaryDate=" + summaryDate + ", telsalerName=" return "TelsalerAttachingRateRecord [summaryDate=" + summaryDate + ", telsalerName="
+ telsalerName + ", motoPremium=" + motoPremium + ", nomotoPremium=" + nomotoPremium + telsalerName + ", motoPremium=" + motoPremium + ", nomotoPremium=" + nomotoPremium
+ ", motoPremiumProportion=" + motoPremiumProportion + ", attachingRate=" + ", motoPremiumProportion=" + motoPremiumProportion + ", attachingRate="
+ attachingRate + ", attachingRateChange=" + attachingRateChange + "]"; + attachingRate + ", attachingRateChange=" + attachingRateChange
+ ", customerHandleRateCell=" + customerHandleRateCell
+ ", customerHandleRateChangeCell=" + customerHandleRateChangeCell
+ ", noMotoPremiumPerCustomerCell=" + noMotoPremiumPerCustomerCell
+ ", noMotoPremiumPerCustomerChangeCell=" + noMotoPremiumPerCustomerChangeCell
+ "]";
} }
@Override @Override
@ -71,6 +152,14 @@ public class TelsalerAttachingRateRecord
result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( attachingRateChange ); temp = Double.doubleToLongBits( attachingRateChange );
result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( customerHandleRateCell );
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( customerHandleRateChangeCell );
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( noMotoPremiumPerCustomerCell );
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits( noMotoPremiumPerCustomerChangeCell );
result = prime * result + (int) (temp ^ (temp >>> 32));
return result; return result;
} }
@ -113,6 +202,18 @@ public class TelsalerAttachingRateRecord
if ( Double.doubleToLongBits( attachingRateChange ) != Double if ( Double.doubleToLongBits( attachingRateChange ) != Double
.doubleToLongBits( other.attachingRateChange ) ) .doubleToLongBits( other.attachingRateChange ) )
return false; return false;
if ( Double.doubleToLongBits( customerHandleRateCell ) != Double
.doubleToLongBits( other.customerHandleRateCell ) )
return false;
if ( Double.doubleToLongBits( customerHandleRateChangeCell ) != Double
.doubleToLongBits( other.customerHandleRateChangeCell ) )
return false;
if ( Double.doubleToLongBits( noMotoPremiumPerCustomerCell ) != Double
.doubleToLongBits( other.noMotoPremiumPerCustomerCell ) )
return false;
if ( Double.doubleToLongBits( noMotoPremiumPerCustomerChangeCell ) != Double
.doubleToLongBits( other.noMotoPremiumPerCustomerChangeCell ) )
return false;
return true; return true;
} }

View File

@ -11,22 +11,35 @@ package com.cpic.xim.utils.data;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.cpic.xim.mybatis.pojo.TelsalerAttachingRateRecord; import com.cpic.xim.mybatis.pojo.TelsalerAttachingRateRecord;
import com.cpic.xim.utils.poi.MyPOIUtils;
/** /**
* 坐席业绩相关的数据操作方法 * 坐席业绩相关的数据操作方法
*/ */
public class TelsalerArchievementData public class TelsalerArchievementData
{ {
private static Logger logger = LoggerFactory.getLogger( TelsalerArchievementData.class );
/**
*
* @param filePath 文件路径
* @param summaryDate 统计日期
* @return 返回一个ArrayList保存的TelsalerAttachingRateRecord记录数组
* @throws IOException 打开excel文件错误时抛出
* @throws InvalidFormatException excel单元格格式错误时抛出
*/
public static ArrayList<TelsalerAttachingRateRecord> importTelsalerAttachingRateRecordFromXlsx( public static ArrayList<TelsalerAttachingRateRecord> importTelsalerAttachingRateRecordFromXlsx(
String filePath ) throws IOException, InvalidFormatException String filePath, LocalDate summaryDate, boolean hasCaptionRow ) throws IOException, InvalidFormatException
{ {
ArrayList<TelsalerAttachingRateRecord> records = new ArrayList<>( 200 ); ArrayList<TelsalerAttachingRateRecord> records = new ArrayList<>( 200 );
@ -35,8 +48,72 @@ public class TelsalerArchievementData
try try
{ {
wb = WorkbookFactory.create( new File(filePath)); wb = WorkbookFactory.create( new File( filePath ) );
sheet = wb.getSheet("经办"); sheet = wb.getSheet( "经办" );
for ( Row row : sheet )
{
String name = "";
int rowIndex = row.getRowNum();
// 判断是否要跳过标题行
if ( hasCaptionRow == true && row.getRowNum() == 0 )
{
continue;
}
try
{
// 坐席名称
name = MyPOIUtils.getStringCellValue( row, 1 );
if ( name.equals( "全流程" ) || name.equals( "其他" ) || name.isEmpty() )
{
continue;
}
// 车险保费
double motoPremium = MyPOIUtils.getNumbericCellValue( row, 2 );
// 非车险保费
double nomotoPremium = MyPOIUtils.getNumbericCellValue( row, 4 );
// 车险保费占比
double motoPremiumProPortion = MyPOIUtils.getNumbericCellValue( row, 3 );
// 当月保费渗透率
double attachingRate = MyPOIUtils.getNumbericCellValue( row, 5 );
// 保费手头率环比上月
double attachingRateChange = MyPOIUtils.getNumbericCellValue( row, 6 );
// 当月客户渗透率
double customerHandleRateCell = MyPOIUtils.getNumbericCellValue( row, 7 );
// 客户渗透率环比上月
double customerHandleRateChangeCell = MyPOIUtils.getNumbericCellValue( row, 8 );
// 当月车非客均保费
double noMotoPremiumPerCustomerCell = MyPOIUtils.getNumbericCellValue( row, 9 );
// 客均保费环比上月
double noMotoPremiumPerCustomerChangeCell =
MyPOIUtils.getNumbericCellValue( row, 10 );
TelsalerAttachingRateRecord record = new TelsalerAttachingRateRecord(
summaryDate, name, motoPremium, nomotoPremium, motoPremiumProPortion,
attachingRate, attachingRateChange, customerHandleRateCell,
customerHandleRateChangeCell, noMotoPremiumPerCustomerCell,
noMotoPremiumPerCustomerChangeCell );
records.add( record );
}
catch ( IllegalStateException error )
{
error.printStackTrace();
}
catch ( NumberFormatException error )
{
error.printStackTrace();
}
catch ( NullPointerException error )
{
String message = "" + String.valueOf(rowIndex) + "行出现NullPointerException异常";
logger.error(message, error);
}
}
} }
finally finally
{ {

View File

@ -15,7 +15,7 @@ import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
public class MyPOIUtils public class MyPOIUtils
{ {
public String getStringCellValue( Cell cell ) public static String getStringCellValue( Cell cell )
{ {
switch( cell.getCellType() ) switch( cell.getCellType() )
{ {
@ -26,7 +26,7 @@ public class MyPOIUtils
} }
} }
public String getStringCellValue( Row row, int columnIndex ) public static String getStringCellValue( Row row, int columnIndex )
{ {
Cell cell = row.getCell(columnIndex, MissingCellPolicy.RETURN_NULL_AND_BLANK); Cell cell = row.getCell(columnIndex, MissingCellPolicy.RETURN_NULL_AND_BLANK);
@ -38,4 +38,39 @@ public class MyPOIUtils
return ""; return "";
} }
} }
public static double getNumbericCellValue( Cell cell )
{
double value = 0.0;
switch ( cell.getCellType() )
{
case NUMERIC:
value = cell.getNumericCellValue();
break;
default:
value = 0.0;
break;
}
return value;
}
public static double getNumbericCellValue( Row row, int columnIndex )
{
double value = 0.0;
Cell cell = row.getCell( columnIndex, MissingCellPolicy.RETURN_NULL_AND_BLANK );
switch ( cell.getCellType() )
{
case NUMERIC:
value = cell.getNumericCellValue();
break;
default:
value = 0.0;
break;
}
return value;
}
} }