保存进度!

This commit is contained in:
Kane Wang 2023-10-23 17:46:30 +08:00
parent 8b31ffb6d6
commit a3c56df910
10 changed files with 75 additions and 49 deletions

View File

@ -4,9 +4,9 @@ create table BI
varchar2(100) not null,
"目标值-机构" number default 0 not null,
number default 0 not null,
"³µÏÕ±£·Ñ(Íò)" number default 0 not null,
"³µÏÕ±£·Ñ" number default 0 not null,
number default 0 not null,
"·Ç³µ±£·Ñ(Íò)" number default 0 not null,
"·Ç³µ±£·Ñ" number default 0 not null,
number default 0 not null,
number default 0 not null,
number default 0 not null,

View File

@ -31,8 +31,7 @@ import com.cpic.xim.utils.poi.MyPOIUtils;
*/
public final class ImportBIExcelData
{
private static Logger logger =
LoggerFactory.getLogger( ImportBIExcelData.class );
private static Logger logger = LoggerFactory.getLogger( ImportBIExcelData.class );
private static String[] TelsalerAttachingRateExcelTitle = new String[]
{ "部门", "经办", "车险保费(万)", "车险保费占比", "非车保费(万)", "当月保费渗透率", "保费渗透率环比上月", "当月客户渗透率", "客户渗透率环比上月",
@ -56,7 +55,7 @@ public final class ImportBIExcelData
* @return 返回判断结果
*/
private static boolean checkExcelFormat( Sheet sheet, String caption, int captionRowIndex,
String[] title, int titleRowIndex ) throws InvalidFormatException
String[] title, int titleRowIndex )
{
boolean result = true;
@ -96,6 +95,8 @@ public final class ImportBIExcelData
result = false;
break;
}
cellIndex++;
}
}
catch ( NullPointerException error )
@ -130,6 +131,12 @@ public final class ImportBIExcelData
wb = WorkbookFactory.create( new File( filePath ) );
sheet = wb.getSheetAt( SheetIndex );
// 先验证格式不对就抛出错误
if ( !checkExcelFormat( sheet, null, 0, TelsalerAttachingRateExcelTitle, 0 ) )
{
throw new InvalidFormatException("Excel文件格式错误请检查报表内容" );
}
for ( Row row : sheet )
{
String name = "";
@ -153,24 +160,24 @@ public final class ImportBIExcelData
}
// 车险保费
double motoPremium = MyPOIUtils.getNumbericCellValue( row, 2 );
double motoPremium = MyPOIUtils.getNumbericCellValue( row, 2 ) * 10000;
// 非车险保费
double nomotoPremium = MyPOIUtils.getNumbericCellValue( row, 4 );
double nomotoPremium = MyPOIUtils.getNumbericCellValue( row, 4 ) * 10000;
// 车险保费占比
double motoPremiumProPortion = MyPOIUtils.getNumbericCellValue( row, 3 );
double motoPremiumProPortion = MyPOIUtils.getNumbericCellValue( row, 3 ) * 100;
// 当月保费渗透率
double attachingRate = MyPOIUtils.getNumbericCellValue( row, 5 );
// 保费手头率环比上月
double attachingRateChange = MyPOIUtils.getNumbericCellValue( row, 6 );
double attachingRate = MyPOIUtils.getNumbericCellValue( row, 5 ) * 100;
// 保费渗透率环比上月
double attachingRateChange = MyPOIUtils.getNumbericCellValue( row, 6 ) * 100;
// 当月客户渗透率
double customerHandleRateCell = MyPOIUtils.getNumbericCellValue( row, 7 );
double customerHandleRateCell = MyPOIUtils.getNumbericCellValue( row, 7 ) * 100;
// 客户渗透率环比上月
double customerHandleRateChangeCell = MyPOIUtils.getNumbericCellValue( row, 8 );
double customerHandleRateChangeCell = MyPOIUtils.getNumbericCellValue( row, 8 ) * 100;
// 当月车非客均保费
double noMotoPremiumPerCustomerCell = MyPOIUtils.getNumbericCellValue( row, 9 );
double noMotoPremiumPerCustomerCell = MyPOIUtils.getNumbericCellValue( row, 9 ) * 100;
// 客均保费环比上月
double noMotoPremiumPerCustomerChangeCell =
MyPOIUtils.getNumbericCellValue( row, 10 );
MyPOIUtils.getNumbericCellValue( row, 10 ) * 100;
BITelsalerAttachingRateRecord record = new BITelsalerAttachingRateRecord(
LocalDate.now(), name, motoPremium, nomotoPremium,
@ -222,7 +229,7 @@ public final class ImportBIExcelData
*/
public static ArrayList<BITelsalerRenewalRateRecord> importBITelsalerRenewalRateFromXlsx(
String filePath, int sheetIndex, int firstRow, LocalDate summaryDate )
throws IOException
throws IOException, InvalidFormatException
{
ArrayList<BITelsalerRenewalRateRecord> records = new ArrayList<>( 200 );
@ -235,6 +242,11 @@ public final class ImportBIExcelData
sheet = wb.getSheetAt( sheetIndex );
int rowIndex = 0;
if (!checkExcelFormat( sheet, null, 0, TelSalerRenewalRateExcelTitle, 0 ))
{
throw new InvalidFormatException("格式错误,请检查报表内容!");
}
for ( Row row : sheet )
{
rowIndex = row.getRowNum();
@ -254,13 +266,13 @@ public final class ImportBIExcelData
continue;
}
double 机构目标值 = MyPOIUtils.getNumbericCellValue( row, 1 );
double 到期数全月 = MyPOIUtils.getNumbericCellValue( row, 2 );
double 序时到期数占比 = MyPOIUtils.getNumbericCellValue( row, 3 );
double 个车续保率序时 = MyPOIUtils.getNumbericCellValue( row, 4 );
double 个车续保率全月 = MyPOIUtils.getNumbericCellValue( row, 5 );
double 环比昨日 = MyPOIUtils.getNumbericCellValue( row, 6 );
double 环比上月 = MyPOIUtils.getNumbericCellValue( row, 7 );
double 机构目标值 = MyPOIUtils.getNumbericCellValue( row, 1 ) * 100;
double 到期数全月 = MyPOIUtils.getNumbericCellValue( row, 2 ) * 100;
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;
BITelsalerRenewalRateRecord record = new BITelsalerRenewalRateRecord( 责任人,
机构目标值, 到期数全月, 序时到期数占比, 个车续保率序时, 个车续保率全月, 环比昨日, 环比上月 );
@ -294,7 +306,7 @@ public final class ImportBIExcelData
}
public static ArrayList<BIDepartmentArchievementRecord> importBIDepartmentArchievementRecords(
String filePath, int sheetIndex, int firstRow ) throws IOException
String filePath, int sheetIndex, int firstRow ) throws IOException, InvalidFormatException
{
ArrayList<BIDepartmentArchievementRecord> records = new ArrayList<>( 5 );
@ -307,6 +319,11 @@ public final class ImportBIExcelData
Sheet sheet = wb.getSheetAt( sheetIndex );
int rowIndex = 0;
if (!checkExcelFormat( sheet, null, 0, DepartmentArchievementExcelTitle, 0 ))
{
throw new InvalidFormatException("Excel文件格式错误请检查报表内容");
}
for ( Row row : sheet )
{
rowIndex = row.getRowNum();
@ -326,17 +343,17 @@ public final class ImportBIExcelData
continue;
}
double departmentObject = MyPOIUtils.getNumbericCellValue( row, 1 );
double objectGap = MyPOIUtils.getNumbericCellValue( row, 1 );
double motoPremium = MyPOIUtils.getNumbericCellValue( row, 1 );
double motoPremiumProPortion = MyPOIUtils.getNumbericCellValue( row, 1 );
double nomotoPremium = MyPOIUtils.getNumbericCellValue( row, 1 );
double attachingRate = MyPOIUtils.getNumbericCellValue( row, 1 );
double attachingRateChange = MyPOIUtils.getNumbericCellValue( row, 1 );
double customerHandleRate = MyPOIUtils.getNumbericCellValue( row, 1 );
double customerHandleRateChange = MyPOIUtils.getNumbericCellValue( row, 1 );
double premiumPerCustomer = MyPOIUtils.getNumbericCellValue( row, 1 );
double premiumPerCustomerChange = MyPOIUtils.getNumbericCellValue( row, 1 );
double departmentObject = MyPOIUtils.getNumbericCellValue( row, 1 ) * 100;
double objectGap = MyPOIUtils.getNumbericCellValue( row, 2 ) * 100;
double motoPremium = MyPOIUtils.getNumbericCellValue( row, 3 ) * 10000;
double motoPremiumProPortion = MyPOIUtils.getNumbericCellValue( row, 4 ) * 100;
double nomotoPremium = MyPOIUtils.getNumbericCellValue( row, 5 ) * 10000;
double attachingRate = MyPOIUtils.getNumbericCellValue( row, 6 ) * 100;
double attachingRateChange = MyPOIUtils.getNumbericCellValue( row, 7 ) * 100;
double customerHandleRate = MyPOIUtils.getNumbericCellValue( row, 8 ) * 100;
double customerHandleRateChange = MyPOIUtils.getNumbericCellValue( row, 9 ) * 100;
double premiumPerCustomer = MyPOIUtils.getNumbericCellValue( row, 10 ) * 100;
double premiumPerCustomerChange = MyPOIUtils.getNumbericCellValue( row, 11 ) * 100;
BIDepartmentArchievementRecord record = new BIDepartmentArchievementRecord(
departmentName, departmentObject, objectGap, motoPremium,

View File

@ -2,7 +2,7 @@
* @Author: Kane
* @Date: 2023-01-22 23:11:26
* @LastEditors: Kane
* @LastEditTime: 2023-10-16 10:51:36
* @LastEditTime: 2023-10-23 17:01:29
* @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/web/controllers/fileupload/FileUpload.java
* @Description: 用于接受上传文件的Controller
*
@ -51,6 +51,15 @@ public class FileUpload
result.setSuccess( true );
result.setMessage( "上传成功!" );
String filePath = request.getServletContext().getRealPath( "/temp/upload/" + sessionID );
File dir = new File( filePath );
if ( !dir.mkdirs() )
{
}
// 检查文件长度如果为0则跳过
if ( file.isEmpty() )
{
@ -60,10 +69,10 @@ public class FileUpload
else
{
// 保存文件到临时目录
Long milliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
String filePath =
request.getServletContext().getRealPath( "/temp/upload/" + sessionID );
String fileName = String.valueOf(milliSecond) + file.getOriginalFilename();
Long milliSecond =
LocalDateTime.now().toInstant( ZoneOffset.of( "+8" ) ).toEpochMilli();
String fileName = String.valueOf( milliSecond ) + file.getOriginalFilename();
// String fileName = file.getOriginalFilename();
File destFile = new File( filePath, fileName );
try
@ -72,14 +81,14 @@ public class FileUpload
// 把上传文件的绝对路径保存返回给前端
fileNames.add( destFile.getAbsolutePath() );
result.setSuccess(true);
result.setMessage("上传成功");
result.setFileList(fileNames);
result.setSuccess( true );
result.setMessage( "上传成功" );
result.setFileList( fileNames );
}
catch ( IOException error )
{
result.setSuccess(false);
result.setMessage("上传失败,原因:" + error.getMessage());
result.setSuccess( false );
result.setMessage( "上传失败,原因:" + error.getMessage() );
}
}

View File

@ -17,8 +17,8 @@
</insert>
<insert id="insertDepartmentAttachingRenewalRateDataToDB" parameterType="com.cpic.xim.mybatis.pojo.BIDepartmentArchievementRecord">
insert into BI部门渗透率续保率统计表 ( 部门,"目标值-机构",目标差距,"车险保费(万)",
车险保费占比,"非车保费(万)",当月保费渗透率,保费渗透率环比上月,当月客户渗透率,
insert into BI部门渗透率续保率统计表 ( 部门,"目标值-机构",目标差距,"车险保费",
车险保费占比,"非车保费",当月保费渗透率,保费渗透率环比上月,当月客户渗透率,
客户渗透率环比上月,当月车非客均保费,客均保费环比上月)
values (#{departmentName},#{departmentObject},#{objectGap},#{motoPremium},
#{motoPremiumProPortion},#{nomotoPremium},#{attachingRate},#{attachingRateChange},

Binary file not shown.

Binary file not shown.

Binary file not shown.