加入BI机构当月个车续保率跟踪表上传导入功能。
This commit is contained in:
		@@ -2,16 +2,17 @@
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2023-10-11 16:47:59
 | 
			
		||||
 * @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: 
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2023} by Kane, All Rights Reserved. 
 | 
			
		||||
 */
 | 
			
		||||
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.BITelsalerRenewalRateRecord;
 | 
			
		||||
import com.cpic.xim.mybatis.pojo.BIDepartmentArchievementRecord;
 | 
			
		||||
 | 
			
		||||
public interface ImportBIArchievementDataMapper
 | 
			
		||||
{
 | 
			
		||||
@@ -19,11 +20,15 @@ public interface ImportBIArchievementDataMapper
 | 
			
		||||
 | 
			
		||||
    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 cleanTelsalerRenewalRateData();
 | 
			
		||||
 | 
			
		||||
    public void cleanDepartmentAttachingRenewalRateData();
 | 
			
		||||
    public void cleanDepartmentAttachingRateData();
 | 
			
		||||
 | 
			
		||||
    public void cleanDepartmentRenewalRateData();
 | 
			
		||||
}
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
 */
 | 
			
		||||
package com.cpic.xim.mybatis.pojo;
 | 
			
		||||
 | 
			
		||||
public class BIDepartmentArchievementRecord
 | 
			
		||||
public class BIDepartmentAttachingRateRecord
 | 
			
		||||
{
 | 
			
		||||
    // 部门
 | 
			
		||||
    private String departmentName;
 | 
			
		||||
@@ -36,7 +36,7 @@ public class BIDepartmentArchievementRecord
 | 
			
		||||
    // 客均保费环比上月
 | 
			
		||||
    private double premiumPerCustomerChange;
 | 
			
		||||
 | 
			
		||||
    public BIDepartmentArchievementRecord( String departmentName, double departmentObject,
 | 
			
		||||
    public BIDepartmentAttachingRateRecord( String departmentName, double departmentObject,
 | 
			
		||||
            double objectGap, double motoPremium, double motoPremiumProPortion,
 | 
			
		||||
            double nomotoPremium, double attachingRate, double attachingRateChange,
 | 
			
		||||
            double customerHandleRate, double customerHandleRateChange, double premiumPerCustomer,
 | 
			
		||||
@@ -110,7 +110,7 @@ public class BIDepartmentArchievementRecord
 | 
			
		||||
            return false;
 | 
			
		||||
        if ( getClass() != obj.getClass() )
 | 
			
		||||
            return false;
 | 
			
		||||
        BIDepartmentArchievementRecord other = (BIDepartmentArchievementRecord) obj;
 | 
			
		||||
        BIDepartmentAttachingRateRecord other = (BIDepartmentAttachingRateRecord) obj;
 | 
			
		||||
        if ( departmentName == null )
 | 
			
		||||
        {
 | 
			
		||||
            if ( other.departmentName != null )
 | 
			
		||||
@@ -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 [责任部门=" + 责任部门 + ", 机构目标值=" + 机构目标值 + ", 到期数全月="
 | 
			
		||||
                + 到期数全月 + ", 序时到期数占比=" + 序时到期数占比 + ", 个车续保率序时=" + 个车续保率序时 + ", 个车续保率全月=" + 个车续保率全月
 | 
			
		||||
                + ", 环比昨日=" + 环比昨日 + ", 环比上月=" + 环比上月 + ", 平均提前签单天数=" + 平均提前签单天数 + ", 环比=" + 环比
 | 
			
		||||
                + "]";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -21,7 +21,8 @@ import org.apache.poi.ss.usermodel.Workbook;
 | 
			
		||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
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.BITelsalerRenewalRateRecord;
 | 
			
		||||
import com.cpic.xim.utils.poi.MyPOIUtils;
 | 
			
		||||
@@ -41,10 +42,14 @@ public final class ImportBIExcelData
 | 
			
		||||
    { "责任人", "机构目标值1(%)", "到期数-全月", "序时到期数占比(%)", "个车续保率(序时)(%)", "个车续保率(全月)(%)", "环比昨日(%)",
 | 
			
		||||
            "环比上月(%)"};
 | 
			
		||||
 | 
			
		||||
    private static String[] DepartmentArchievementExcelTitle = new String[]
 | 
			
		||||
    private static String[] DepartmentAttachingRateExcelTitle = new String[]
 | 
			
		||||
    { "部门", "目标值-机构", "目标差距", "车险保费(万)", "车险保费占比", "非车保费(万)", "当月保费渗透率", "保费渗透率环比上月", "当月客户渗透率",
 | 
			
		||||
            "客户渗透率环比上月", "当月车非客均保费", "客均保费环比上月"};
 | 
			
		||||
 | 
			
		||||
    private static String[] DepartmentRenewalRateExcelTitle = new String[]
 | 
			
		||||
    { "责任部门", "机构目标值1(%)", "到期数-全月", "序时到期数占比(%)", "个车续保率(序时)(%)", "个车续保率(全月)(%)", "环比昨日(%)",
 | 
			
		||||
            "环比上月(%)", "平均提前签单天数", "环比",};
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 用于通过对比标题行判断excel文件格式的函数。
 | 
			
		||||
     * @param sheet
 | 
			
		||||
@@ -134,7 +139,7 @@ public final class ImportBIExcelData
 | 
			
		||||
            // 先验证格式,不对就抛出错误
 | 
			
		||||
            if ( !checkExcelFormat( sheet, null, 0, TelsalerAttachingRateExcelTitle, 0 ) )
 | 
			
		||||
            {
 | 
			
		||||
                throw new InvalidFormatException("Excel文件格式错误,请检查报表内容!" );
 | 
			
		||||
                throw new InvalidFormatException( "Excel文件格式错误,请检查报表内容!" );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            for ( Row row : sheet )
 | 
			
		||||
@@ -172,9 +177,11 @@ public final class ImportBIExcelData
 | 
			
		||||
                    // 当月客户渗透率
 | 
			
		||||
                    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 =
 | 
			
		||||
                            MyPOIUtils.getNumbericCellValue( row, 10 ) * 100;
 | 
			
		||||
@@ -242,9 +249,9 @@ public final class ImportBIExcelData
 | 
			
		||||
            sheet = wb.getSheetAt( sheetIndex );
 | 
			
		||||
            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 )
 | 
			
		||||
@@ -305,10 +312,20 @@ public final class ImportBIExcelData
 | 
			
		||||
        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;
 | 
			
		||||
 | 
			
		||||
@@ -319,9 +336,9 @@ public final class ImportBIExcelData
 | 
			
		||||
            Sheet sheet = wb.getSheetAt( sheetIndex );
 | 
			
		||||
            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 )
 | 
			
		||||
@@ -351,11 +368,13 @@ public final class ImportBIExcelData
 | 
			
		||||
                    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 customerHandleRateChange =
 | 
			
		||||
                            MyPOIUtils.getNumbericCellValue( row, 9 ) * 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,
 | 
			
		||||
                            motoPremiumProPortion, nomotoPremium, attachingRate,
 | 
			
		||||
                            attachingRateChange, customerHandleRate, customerHandleRateChange,
 | 
			
		||||
@@ -390,4 +409,84 @@ public final class ImportBIExcelData
 | 
			
		||||
 | 
			
		||||
        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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.ResponseBody;
 | 
			
		||||
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.BITelsalerRenewalRateRecord;
 | 
			
		||||
import com.cpic.xim.mybatis.utils.MybatisUtils;
 | 
			
		||||
@@ -57,14 +58,18 @@ public class ImportBIDataController
 | 
			
		||||
            {
 | 
			
		||||
                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.setSuccess(true);
 | 
			
		||||
            response.setMessage("导入成功");
 | 
			
		||||
            response.setImportedCount( importedCount );
 | 
			
		||||
            response.setSuccess( true );
 | 
			
		||||
            response.setMessage( "导入成功" );
 | 
			
		||||
        }
 | 
			
		||||
        catch ( IOException error )
 | 
			
		||||
        {
 | 
			
		||||
@@ -103,9 +108,8 @@ public class ImportBIDataController
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            ArrayList<BITelsalerAttachingRateRecord> records =
 | 
			
		||||
                    ImportBIExcelData.importBITelsalerAttachingRateRecordFromXlsx( filePath,
 | 
			
		||||
                            sheetIndex, firstRow );
 | 
			
		||||
            ArrayList<BITelsalerAttachingRateRecord> records = ImportBIExcelData
 | 
			
		||||
                    .importBITelsalerAttachingRateRecordFromXlsx( filePath, sheetIndex, firstRow );
 | 
			
		||||
 | 
			
		||||
            session = MybatisUtils.getSqlSessionBatch();
 | 
			
		||||
            ImportBIArchievementDataMapper mapper =
 | 
			
		||||
@@ -134,8 +138,8 @@ public class ImportBIDataController
 | 
			
		||||
        return importedCount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static int importBITeslsalerRenewalRate( String filePath, int sheetIndex,
 | 
			
		||||
            int firstRow ) throws PersistenceException, IOException, InvalidFormatException
 | 
			
		||||
    private static int importBITeslsalerRenewalRate( String filePath, int sheetIndex, int firstRow )
 | 
			
		||||
            throws PersistenceException, IOException, InvalidFormatException
 | 
			
		||||
    {
 | 
			
		||||
        ArrayList<BITelsalerRenewalRateRecord> records = null;
 | 
			
		||||
        SqlSession session = null;
 | 
			
		||||
@@ -174,26 +178,26 @@ public class ImportBIDataController
 | 
			
		||||
        return importedCount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static int importBIDepartmentArchievement( String filePath, int sheetIndex,
 | 
			
		||||
    private static int importBIDepartmentAttachingRate( String filePath, int sheetIndex,
 | 
			
		||||
            int firstRow ) throws PersistenceException, IOException, InvalidFormatException
 | 
			
		||||
    {
 | 
			
		||||
        ArrayList<BIDepartmentArchievementRecord> records = null;
 | 
			
		||||
        ArrayList<BIDepartmentAttachingRateRecord> records = null;
 | 
			
		||||
        SqlSession session = null;
 | 
			
		||||
        ImportBIArchievementDataMapper mapper = null;
 | 
			
		||||
        int importedCount = 0;
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            records = ImportBIExcelData.importBIDepartmentArchievementRecords( filePath, sheetIndex,
 | 
			
		||||
                    firstRow );
 | 
			
		||||
            records = ImportBIExcelData.importBIDepartmentAttachingRateRecordsFromXlsx( filePath,
 | 
			
		||||
                    sheetIndex, firstRow );
 | 
			
		||||
            session = MybatisUtils.getSqlSessionBatch();
 | 
			
		||||
            mapper = session.getMapper( ImportBIArchievementDataMapper.class );
 | 
			
		||||
 | 
			
		||||
            mapper.cleanDepartmentAttachingRenewalRateData();
 | 
			
		||||
            mapper.cleanDepartmentAttachingRateData();
 | 
			
		||||
 | 
			
		||||
            for ( BIDepartmentArchievementRecord record : records )
 | 
			
		||||
            for ( BIDepartmentAttachingRateRecord record : records )
 | 
			
		||||
            {
 | 
			
		||||
                mapper.insertDepartmentAttachingRenewalRateDataToDB( record );
 | 
			
		||||
                mapper.insertDepartmentAttachingRateDataToDB( record );
 | 
			
		||||
                importedCount++;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@@ -205,6 +209,47 @@ public class ImportBIDataController
 | 
			
		||||
            {
 | 
			
		||||
                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;
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 | 
			
		||||
public class ImportBIDataRequest
 | 
			
		||||
{
 | 
			
		||||
    public enum ReportType {
 | 
			
		||||
        TelsalerAttachingRateReport, TelsalerRenewalRateReport, DepartmentAttachingRenewalRateReport
 | 
			
		||||
        TelsalerAttachingRateReport, TelsalerRenewalRateReport, DepartmentAttachingRateReport, DepartmentRenewalRateReport
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // 导入文件的路径
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
        #{个车续保率序时},#{个车续保率全月},#{环比昨日},#{环比上月})
 | 
			
		||||
    </insert>
 | 
			
		||||
 | 
			
		||||
    <insert id="insertDepartmentAttachingRenewalRateDataToDB" parameterType="com.cpic.xim.mybatis.pojo.BIDepartmentArchievementRecord">
 | 
			
		||||
    <insert id="insertDepartmentAttachingRateDataToDB" parameterType="com.cpic.xim.mybatis.pojo.BIDepartmentAttachingRateRecord">
 | 
			
		||||
        insert into BI部门渗透率续保率统计表 ( 部门,"目标值-机构",目标差距,"车险保费",
 | 
			
		||||
        车险保费占比,"非车保费",当月保费渗透率,保费渗透率环比上月,当月客户渗透率,
 | 
			
		||||
        客户渗透率环比上月,当月车非客均保费,客均保费环比上月)
 | 
			
		||||
@@ -25,13 +25,25 @@
 | 
			
		||||
        #{customerHandleRate},#{customerHandleRateChange},#{premiumPerCustomer},#{premiumPerCustomerChange} )
 | 
			
		||||
    </insert>
 | 
			
		||||
 | 
			
		||||
    <insert id="insertDepartmentRenewalRateDataToDB" parameterType="com.cpic.xim.mybatis.pojo.BIDepartmentRenewalRateRecord" >
 | 
			
		||||
        insert into BI机构当月个车续保率跟踪表( "责任部门","机构目标值1(%)","到期数-全月" ,"序时到期数占比(%)","个车续保率(序时)(%)",
 | 
			
		||||
        "个车续保率(全月)(%)","环比昨日(%)","环比上月(%)","平均提前签单天数","环比")
 | 
			
		||||
        values (#{责任部门},#{机构目标值},#{到期数全月},#{序时到期数占比},
 | 
			
		||||
        #{个车续保率序时},#{个车续保率全月},#{环比昨日},#{环比上月},
 | 
			
		||||
        #{平均提前签单天数},#{环比})
 | 
			
		||||
    </insert>
 | 
			
		||||
 | 
			
		||||
    <select id="cleanTelsalerAttachingRateData" statementType="CALLABLE">
 | 
			
		||||
        call telsale_bi_utils.清理BI电销坐席车非渗透统计表()
 | 
			
		||||
    </select>
 | 
			
		||||
    <select id="cleanTelsalerRenewalRateData" statementType="CALLABLE">
 | 
			
		||||
        call telsale_bi_utils.清理BI电销坐席续保率统计表()
 | 
			
		||||
    </select>
 | 
			
		||||
    <select id="cleanDepartmentAttachingRenewalRateData" statementType="CALLABLE">
 | 
			
		||||
        call telsale_bi_utils.清理BI部门业绩统计表()
 | 
			
		||||
    <select id="cleanDepartmentAttachingRateData" statementType="CALLABLE">
 | 
			
		||||
        call telsale_bi_utils.清理BI部门渗透率跟踪表()
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="cleanDepartmentRenewalRateData" statementType="CALLABLE">
 | 
			
		||||
        call telsale_bi_utils.清理BI部门续保率跟踪表()
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -109,22 +109,22 @@ public class BatchInsertTest
 | 
			
		||||
        String filePath = "D:/develop/cpicxim/deskop_task_schedule/数据/测试用/BI部门渗透率续保率.xlsx";
 | 
			
		||||
        String sheetName = "部门";
 | 
			
		||||
 | 
			
		||||
        ArrayList<BIDepartmentArchievementRecord> records = null;
 | 
			
		||||
        ArrayList<BIDepartmentAttachingRateRecord> records = null;
 | 
			
		||||
        SqlSession session = null;
 | 
			
		||||
        ImportBIArchievementDataMapper mapper = null;
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            records =
 | 
			
		||||
                    ImportBIExcelData.importBIDepartmentArchievementRecords( filePath, 0, 1 );
 | 
			
		||||
                    ImportBIExcelData.importBIDepartmentAttachingRateRecordsFromXlsx( filePath, 0, 1 );
 | 
			
		||||
            session = MybatisUtils.getSqlSessionBatch();
 | 
			
		||||
            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();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user