完成读取车非渗透表。
This commit is contained in:
parent
e40b81672a
commit
e805bf914b
@ -42,7 +42,83 @@ public class TelsalerAttachingRateRecord
|
||||
@JsonProperty( "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
|
||||
public String toString()
|
||||
@ -50,7 +126,12 @@ public class TelsalerAttachingRateRecord
|
||||
return "TelsalerAttachingRateRecord [summaryDate=" + summaryDate + ", telsalerName="
|
||||
+ telsalerName + ", motoPremium=" + motoPremium + ", nomotoPremium=" + nomotoPremium
|
||||
+ ", motoPremiumProportion=" + motoPremiumProportion + ", attachingRate="
|
||||
+ attachingRate + ", attachingRateChange=" + attachingRateChange + "]";
|
||||
+ attachingRate + ", attachingRateChange=" + attachingRateChange
|
||||
+ ", customerHandleRateCell=" + customerHandleRateCell
|
||||
+ ", customerHandleRateChangeCell=" + customerHandleRateChangeCell
|
||||
+ ", noMotoPremiumPerCustomerCell=" + noMotoPremiumPerCustomerCell
|
||||
+ ", noMotoPremiumPerCustomerChangeCell=" + noMotoPremiumPerCustomerChangeCell
|
||||
+ "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,6 +152,14 @@ public class TelsalerAttachingRateRecord
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits( attachingRateChange );
|
||||
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;
|
||||
}
|
||||
|
||||
@ -113,6 +202,18 @@ public class TelsalerAttachingRateRecord
|
||||
if ( Double.doubleToLongBits( attachingRateChange ) != Double
|
||||
.doubleToLongBits( other.attachingRateChange ) )
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -11,22 +11,35 @@ package com.cpic.xim.utils.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.Workbook;
|
||||
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.utils.poi.MyPOIUtils;
|
||||
|
||||
/**
|
||||
* 坐席业绩相关的数据操作方法。
|
||||
*/
|
||||
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(
|
||||
String filePath ) throws IOException, InvalidFormatException
|
||||
String filePath, LocalDate summaryDate, boolean hasCaptionRow ) throws IOException, InvalidFormatException
|
||||
{
|
||||
ArrayList<TelsalerAttachingRateRecord> records = new ArrayList<>( 200 );
|
||||
|
||||
@ -37,6 +50,70 @@ public class TelsalerArchievementData
|
||||
{
|
||||
wb = WorkbookFactory.create( new File( filePath ) );
|
||||
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
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
|
||||
|
||||
public class MyPOIUtils
|
||||
{
|
||||
public String getStringCellValue( Cell cell )
|
||||
public static String getStringCellValue( Cell cell )
|
||||
{
|
||||
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);
|
||||
|
||||
@ -38,4 +38,39 @@ public class MyPOIUtils
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user