保存进度!
This commit is contained in:
		@@ -17,4 +17,8 @@ public interface TWrTelsalerMapper
 | 
			
		||||
    public TWrTelsalerRecord queryTWrTelsalerInfo( @Param("telsaler") String telsaler );
 | 
			
		||||
 | 
			
		||||
    public void insertTWrTelsalerRecordToDB( TWrTelsalerRecord record );
 | 
			
		||||
 | 
			
		||||
    public void cleanTWrTelsalerRecord();
 | 
			
		||||
 | 
			
		||||
    public void cleanTWrTelsalerTeamRecord();
 | 
			
		||||
}
 | 
			
		||||
@@ -32,7 +32,7 @@ public class ImportTWRTelsalerData
 | 
			
		||||
            "学历类型", "用工性质名称", "合同种类", "合同类型", "合同性质", "合同签订次数", "合同生效日期", "合同到期日期", "人员属性", "保代员工号",
 | 
			
		||||
            "职场属性", "办公性质", "保代人员属性", "人员状态",};
 | 
			
		||||
 | 
			
		||||
    public static void importTWrTelsalerDataFromExcel( String filePath, int sheetIndex,
 | 
			
		||||
    public static ArrayList<TWrTelsalerRecord> importTWrTelsalerDataFromExcel( String filePath, int sheetIndex,
 | 
			
		||||
            int firstRow ) throws IOException, InvalidFormatException
 | 
			
		||||
    {
 | 
			
		||||
        ArrayList<TWrTelsalerRecord> records = new ArrayList<>( 200 );
 | 
			
		||||
@@ -132,6 +132,8 @@ public class ImportTWRTelsalerData
 | 
			
		||||
                error.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return records;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static boolean checkExcelFormat( Sheet sheet, String caption, int captionRowIndex,
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,35 @@
 | 
			
		||||
package com.cpic.xim.web.controllers.dataimport;
 | 
			
		||||
 | 
			
		||||
public enum ReportType {
 | 
			
		||||
        BiTelsalerAttachingRateReport(1,"坐席车非渗透率"),
 | 
			
		||||
        BiTelsalerRenewalRateReport(2,"坐席续保率"),
 | 
			
		||||
        BiDepartmentAttachingRateReport(3,"部门车非渗透率"),
 | 
			
		||||
        BiDepartmentRenewalRateReport(4,"当月个车续保率跟踪报表【机构】"),
 | 
			
		||||
        TWrTelsalerList(10,"TWr坐席清单"); // Twr坐席清单
 | 
			
		||||
 | 
			
		||||
        private int reportTypeCode;
 | 
			
		||||
 | 
			
		||||
        private String reportTypeName;
 | 
			
		||||
        private ReportType( final int code, final String name )
 | 
			
		||||
        {
 | 
			
		||||
            this.reportTypeCode = code;
 | 
			
		||||
            this.reportTypeName = name;
 | 
			
		||||
        }
 | 
			
		||||
        public int getReportTypeCode()
 | 
			
		||||
        {
 | 
			
		||||
            return reportTypeCode;
 | 
			
		||||
        }
 | 
			
		||||
        public void setReportTypeCode( int reportTypeCode )
 | 
			
		||||
        {
 | 
			
		||||
            this.reportTypeCode = reportTypeCode;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getReportTypeName()
 | 
			
		||||
        {
 | 
			
		||||
            return reportTypeName;
 | 
			
		||||
        }
 | 
			
		||||
        public void setReportTypeName( String reportTypeName )
 | 
			
		||||
        {
 | 
			
		||||
            this.reportTypeName = reportTypeName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -10,7 +10,6 @@
 | 
			
		||||
package com.cpic.xim.web.controllers.dataimport.bi;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import org.apache.ibatis.exceptions.PersistenceException;
 | 
			
		||||
import org.apache.ibatis.session.SqlSession;
 | 
			
		||||
@@ -23,13 +22,16 @@ 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.mapper.TWrTelsalerMapper;
 | 
			
		||||
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.TWrTelsalerRecord;
 | 
			
		||||
import com.cpic.xim.mybatis.utils.MybatisUtils;
 | 
			
		||||
import com.cpic.xim.utils.data.ImportBIExcelData;
 | 
			
		||||
import com.cpic.xim.web.controllers.dataimport.bi.ImportBIDataRequest.ReportType;
 | 
			
		||||
import com.cpic.xim.utils.data.ImportTWRTelsalerData;
 | 
			
		||||
import com.cpic.xim.web.controllers.dataimport.ReportType;;
 | 
			
		||||
 | 
			
		||||
@Controller
 | 
			
		||||
@RequestMapping( method = RequestMethod.POST, path = "/import_bi_data" )
 | 
			
		||||
@@ -43,29 +45,33 @@ public class ImportBIDataController
 | 
			
		||||
    {
 | 
			
		||||
        ImportBIDataResponse response = new ImportBIDataResponse();
 | 
			
		||||
        String filePath = request.getFilePath();
 | 
			
		||||
        ReportType type = request.getReportType();
 | 
			
		||||
        int type = request.getReportType();
 | 
			
		||||
        int firstRow = request.getFirstRow();
 | 
			
		||||
        int sheetIndex = request.getSheetIndex();
 | 
			
		||||
        int importedCount = 0;
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            if ( type == ReportType.TelsalerAttachingRateReport )
 | 
			
		||||
            if ( type == ReportType.BiTelsalerAttachingRateReport.getReportTypeCode() )
 | 
			
		||||
            {
 | 
			
		||||
                importedCount = importBITelsalerAttachingRate( filePath, sheetIndex, firstRow );
 | 
			
		||||
            }
 | 
			
		||||
            else if ( type == ReportType.TelsalerRenewalRateReport )
 | 
			
		||||
            else if ( type == ReportType.BiTelsalerRenewalRateReport.getReportTypeCode() )
 | 
			
		||||
            {
 | 
			
		||||
                importedCount = importBITeslsalerRenewalRate( filePath, sheetIndex, firstRow );
 | 
			
		||||
            }
 | 
			
		||||
            else if ( type == ReportType.DepartmentAttachingRateReport )
 | 
			
		||||
            else if ( type == ReportType.BiDepartmentAttachingRateReport.getReportTypeCode() )
 | 
			
		||||
            {
 | 
			
		||||
                importedCount = importBIDepartmentAttachingRate( filePath, sheetIndex, firstRow );
 | 
			
		||||
            }
 | 
			
		||||
            else if ( type == ReportType.DepartmentRenewalRateReport )
 | 
			
		||||
            else if ( type == ReportType.BiDepartmentRenewalRateReport.getReportTypeCode() )
 | 
			
		||||
            {
 | 
			
		||||
                importedCount = importBIDepartmentRenewalRate( filePath, sheetIndex, firstRow );
 | 
			
		||||
            }
 | 
			
		||||
            else if ( type == ReportType.TWrTelsalerList.getReportTypeCode() )
 | 
			
		||||
            {
 | 
			
		||||
                importedCount = importTWrTelsalerList( filePath, sheetIndex, firstRow );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            response.setImportedCount( importedCount );
 | 
			
		||||
            response.setSuccess( true );
 | 
			
		||||
@@ -254,4 +260,43 @@ public class ImportBIDataController
 | 
			
		||||
 | 
			
		||||
        return importedCount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static int importTWrTelsalerList( String filePath, int sheetIndex, int firstRow )
 | 
			
		||||
            throws PersistenceException, IOException, InvalidFormatException
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        ArrayList<TWrTelsalerRecord> records = null;
 | 
			
		||||
        SqlSession session = null;
 | 
			
		||||
        TWrTelsalerMapper mapper = null;
 | 
			
		||||
        int importedCount = 0;
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            records = ImportTWRTelsalerData.importTWrTelsalerDataFromExcel(filePath, sheetIndex, firstRow);
 | 
			
		||||
            session = MybatisUtils.getSqlSessionBatch();
 | 
			
		||||
            mapper = session.getMapper(TWrTelsalerMapper.class);
 | 
			
		||||
            
 | 
			
		||||
            mapper.cleanTWrTelsalerTeamRecord();
 | 
			
		||||
 | 
			
		||||
            for ( TWrTelsalerRecord record : records )
 | 
			
		||||
            {
 | 
			
		||||
                mapper.insertTWrTelsalerRecordToDB(record);
 | 
			
		||||
 | 
			
		||||
                importedCount++;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            session.commit();
 | 
			
		||||
        }
 | 
			
		||||
        catch ( Exception error)
 | 
			
		||||
        {
 | 
			
		||||
            if ( session != null )
 | 
			
		||||
            {
 | 
			
		||||
                session.rollback();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            throw error;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return importedCount;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,78 +3,65 @@
 | 
			
		||||
 * @Date: 2023-10-13 14:39:06
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/web/controllers/dataimport/bi/ImportBIDataRequest.java
 | 
			
		||||
 * @Description: 
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2023} by Kane, All Rights Reserved. 
 | 
			
		||||
 * @Description:
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) ${2023} by Kane, All Rights Reserved.
 | 
			
		||||
 */
 | 
			
		||||
package com.cpic.xim.web.controllers.dataimport.bi;
 | 
			
		||||
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonProperty;
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
 | 
			
		||||
@Controller
 | 
			
		||||
public class ImportBIDataRequest
 | 
			
		||||
{
 | 
			
		||||
    public enum ReportType {
 | 
			
		||||
        TelsalerAttachingRateReport, TelsalerRenewalRateReport, DepartmentAttachingRateReport, DepartmentRenewalRateReport
 | 
			
		||||
    };
 | 
			
		||||
public class ImportBIDataRequest {
 | 
			
		||||
 | 
			
		||||
    // 导入文件的路径
 | 
			
		||||
    @JsonProperty( "filePath" )
 | 
			
		||||
    private String     filePath;
 | 
			
		||||
    @JsonProperty("filePath")
 | 
			
		||||
    private String filePath;
 | 
			
		||||
 | 
			
		||||
    // 报表名称
 | 
			
		||||
    @JsonProperty( "reportType" )
 | 
			
		||||
    private ReportType reportType;
 | 
			
		||||
    @JsonProperty("reportType")
 | 
			
		||||
    private int reportType;
 | 
			
		||||
 | 
			
		||||
    // 是否有标题行
 | 
			
		||||
    @JsonProperty( "firstRow" )
 | 
			
		||||
    private int    firstRow;
 | 
			
		||||
    @JsonProperty("firstRow")
 | 
			
		||||
    private int firstRow;
 | 
			
		||||
 | 
			
		||||
    // sheet索引
 | 
			
		||||
    @JsonProperty( "sheetIndex" )
 | 
			
		||||
    private int        sheetIndex;
 | 
			
		||||
    @JsonProperty("sheetIndex")
 | 
			
		||||
    private int sheetIndex;
 | 
			
		||||
 | 
			
		||||
    public ImportBIDataRequest()
 | 
			
		||||
    {}
 | 
			
		||||
    public ImportBIDataRequest() {}
 | 
			
		||||
 | 
			
		||||
    public int getFirstRow()
 | 
			
		||||
    {
 | 
			
		||||
    public int getFirstRow() {
 | 
			
		||||
        return firstRow;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setFirstRow( int firstRow )
 | 
			
		||||
    {
 | 
			
		||||
    public void setFirstRow(int firstRow) {
 | 
			
		||||
        this.firstRow = firstRow;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getSheetIndex()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSheetIndex() {
 | 
			
		||||
        return sheetIndex;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSheetIndex( int sheetIndex )
 | 
			
		||||
    {
 | 
			
		||||
    public void setSheetIndex(int sheetIndex) {
 | 
			
		||||
        this.sheetIndex = sheetIndex;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getFilePath()
 | 
			
		||||
    {
 | 
			
		||||
    public String getFilePath() {
 | 
			
		||||
        return filePath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setFilePath( String filePath )
 | 
			
		||||
    {
 | 
			
		||||
    public void setFilePath(String filePath) {
 | 
			
		||||
        this.filePath = filePath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ReportType getReportType()
 | 
			
		||||
    {
 | 
			
		||||
    public int getReportType() {
 | 
			
		||||
        return reportType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setReportType( ReportType reportType )
 | 
			
		||||
    {
 | 
			
		||||
    public void setReportType(int reportType) {
 | 
			
		||||
        this.reportType = reportType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -84,7 +71,7 @@ public class ImportBIDataRequest
 | 
			
		||||
        final int prime = 31;
 | 
			
		||||
        int result = 1;
 | 
			
		||||
        result = prime * result + ((filePath == null) ? 0 : filePath.hashCode());
 | 
			
		||||
        result = prime * result + ((reportType == null) ? 0 : reportType.hashCode());
 | 
			
		||||
        result = prime * result + reportType;
 | 
			
		||||
        result = prime * result + firstRow;
 | 
			
		||||
        result = prime * result + sheetIndex;
 | 
			
		||||
        return result;
 | 
			
		||||
@@ -117,11 +104,17 @@ public class ImportBIDataRequest
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString()
 | 
			
		||||
    {
 | 
			
		||||
        return "ImportBIDataRequest [filePath=" + filePath + ", reportType=" + reportType
 | 
			
		||||
                + ", firstRow=" + firstRow + ", sheetIndex=" + sheetIndex + "]";
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return (
 | 
			
		||||
            "ImportBIDataRequest [filePath=" +
 | 
			
		||||
            filePath +
 | 
			
		||||
            ", reportType=" +
 | 
			
		||||
            reportType +
 | 
			
		||||
            ", firstRow=" +
 | 
			
		||||
            firstRow +
 | 
			
		||||
            ", sheetIndex=" +
 | 
			
		||||
            sheetIndex +
 | 
			
		||||
            "]"
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -79,6 +79,86 @@
 | 
			
		||||
    </resultMap>
 | 
			
		||||
 | 
			
		||||
    <!-- insertTWrTelsalerRecordToDB --> 
 | 
			
		||||
    <insert id="insertTWrTelsalerRecordToDB">
 | 
			
		||||
    <insert id="insertTWrTelsalerRecordToDB" parameterType="TWrTelsalerRecord">
 | 
			
		||||
        insert into TWR_TELSALER_DEV(
 | 
			
		||||
            人员姓名,
 | 
			
		||||
            人员工号,
 | 
			
		||||
            籍贯,
 | 
			
		||||
            参加工作时间,
 | 
			
		||||
            入职日期,
 | 
			
		||||
            入司日期,
 | 
			
		||||
            业务类型,
 | 
			
		||||
            办公地省,
 | 
			
		||||
            办公地市,
 | 
			
		||||
            人员类别,
 | 
			
		||||
            现任岗位,
 | 
			
		||||
            现任职级,
 | 
			
		||||
            机构名称,
 | 
			
		||||
            职场分类,
 | 
			
		||||
            片区名称,
 | 
			
		||||
            团队名称,
 | 
			
		||||
            对口分公司,
 | 
			
		||||
            展业地区,
 | 
			
		||||
            招聘渠道,
 | 
			
		||||
            渠道明细,
 | 
			
		||||
            全日制最高学历,
 | 
			
		||||
            学历类型,
 | 
			
		||||
            用工性质名称,
 | 
			
		||||
            合同种类,
 | 
			
		||||
            合同类型,
 | 
			
		||||
            合同性质,
 | 
			
		||||
            合同签订次数,
 | 
			
		||||
            合同生效日期,
 | 
			
		||||
            合同到期日期,
 | 
			
		||||
            人员属性,
 | 
			
		||||
            保代员工号,
 | 
			
		||||
            职场属性,
 | 
			
		||||
            办公性质,
 | 
			
		||||
            保代人员属性,
 | 
			
		||||
            人员状态)
 | 
			
		||||
        values (
 | 
			
		||||
            #{人员姓名},
 | 
			
		||||
            #{人员工号},
 | 
			
		||||
            #{籍贯},
 | 
			
		||||
            #{参加工作时间},
 | 
			
		||||
            #{入职日期},
 | 
			
		||||
            #{入司日期},
 | 
			
		||||
            #{业务类型},
 | 
			
		||||
            #{办公地省},
 | 
			
		||||
            #{办公地市},
 | 
			
		||||
            #{人员类别},
 | 
			
		||||
            #{现任岗位},
 | 
			
		||||
            #{现任职级},
 | 
			
		||||
            #{机构名称},
 | 
			
		||||
            #{职场分类},
 | 
			
		||||
            #{片区名称},
 | 
			
		||||
            #{团队名称},
 | 
			
		||||
            #{对口分公司},
 | 
			
		||||
            #{展业地区},
 | 
			
		||||
            #{招聘渠道},
 | 
			
		||||
            #{渠道明细},
 | 
			
		||||
            #{全日制最高学历},
 | 
			
		||||
            #{学历类型},
 | 
			
		||||
            #{用工性质名称},
 | 
			
		||||
            #{合同种类},
 | 
			
		||||
            #{合同类型},
 | 
			
		||||
            #{合同性质},
 | 
			
		||||
            #{合同签订次数},
 | 
			
		||||
            #{合同生效日期},
 | 
			
		||||
            #{合同到期日期},
 | 
			
		||||
            #{人员属性},
 | 
			
		||||
            #{保代员工号},
 | 
			
		||||
            #{职场属性},
 | 
			
		||||
            #{办公性质},
 | 
			
		||||
            #{保代人员属性},
 | 
			
		||||
            #{人员状态} )
 | 
			
		||||
    </insert>
 | 
			
		||||
 | 
			
		||||
    <select id="cleanTWrTelsalerRecord" statementType="CALLABLE">
 | 
			
		||||
        call TELSALER_TWR_UTILS.清理TWR坐席清单()
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="cleanTWrTelsalerTeamRecord" statementType="CALLABLE">
 | 
			
		||||
        call TELSALER_TWR_UTILS.清理TWR团队清单()
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -32,7 +32,8 @@
 | 
			
		||||
        <mapper resource="mybatis/mapper/RankingListMapper.xml" />
 | 
			
		||||
        <mapper resource="mybatis/mapper/RewardsMapper.xml" />
 | 
			
		||||
        <mapper resource="mybatis/mapper/ImportBIArchievementDataMapper.xml" />
 | 
			
		||||
        <mapper resource="mybatis/mapper/QueryBIArchievementDataMapper.xml" />    
 | 
			
		||||
        <mapper resource="mybatis/mapper/QueryBIArchievementDataMapper.xml" />
 | 
			
		||||
        <mapper resource="mybatis/mapper/TWrTelsalerMapper.xml" /> 
 | 
			
		||||
    </mappers>
 | 
			
		||||
 | 
			
		||||
</configuration>
 | 
			
		||||
		Reference in New Issue
	
	Block a user