test2 14.8 KB

已分queryPoServerInfoExportToExcel
        
        //表头
        List<String> header = new ArrayList<String>();
        //数据体
        List<List<String>> body = new ArrayList<List<String>>();
     
        header.add("保单号");
        header.add("分公司名称");
        header.add("中心支公司名称");
        header.add("部门名称");
        header.add("营销服务部名称");
        
        header.add("渠道");
        header.add("投保人姓名");
        header.add("投保人客户号");
        header.add("业务员姓名");
        header.add("业务员工号");
        header.add("收展服务人员姓名");
        header.add("收展服务人员工号");
        header.add("主险名称");
        header.add("缴次");
        header.add("期交保费合计金额");
        
        header.add("被保人客户号");
        header.add("被保人姓名");
        header.add("缴费年期");
        header.add("保单联系地址");

        if(StringUtils.isEmpty(branchCode)){
            return ;
        }
        if(StringUtils.isEmpty(month)){
            return ;
        }
        
        //数据源
        List<JSONObject> resultList = checkService.queryPoServerInfoExportToExcel(branchCode, channelType, month);
        //数据源处理
        if(resultList != null && resultList.size() != 0){
            //每行数据
            for (Object objectLineData : resultList) {
                JSONObject lineData = (JSONObject) JSONObject.toJSON(objectLineData);
                List<String> data = new ArrayList<>();
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("POLICYNO")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("SECONDBRANCHNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("THIRDBRANCHNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("DEPTNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("BRANCHNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("DESCRIPTION")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("APPLICANTNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("APPLICANTNO")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("AGENTNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("AGENTNO")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("EMPNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("SERVICERNO")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("ABBRNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("PAYTIMES")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("MODALTOTALPREM")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("INSUREDNO")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("INSUREDNAME")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("PREMTERM")));
                data.add(StringUtils.isNotNullAndEmptyBalck(lineData.get("FULLADDRESS")));
                
                body.add(data);
            }
        }
        Workbook workbook = ExportFileUtils.generateExcel("sheetName", header, body, "xlsx");
        response.setContentType("application/octet-stream");
        try {
            response.setHeader("Content-disposition","attachment;filename="+java.net.URLEncoder.encode(branchCode+"-"+month+"已分单保单信息", "UTF-8")+".xlsx");
            response.flushBuffer();
            workbook.write(response.getOutputStream());
        }catch (IOException e){
            logUtils.error(e);
        }
    




SELECT rpsi.policy_no policyNo,
	       (SELECT branch_name
	          FROM branch_info
	         WHERE is_valid = 'Y'
	           AND branch_level = '02'
	         START WITH branch_code = po.branch_code
	        CONNECT BY PRIOR parent_branch = branch_code) secondBranchName,
	       (SELECT branch_name
	          FROM branch_info
	         WHERE is_valid = 'Y'
	           AND branch_level = '03'
	         START WITH branch_code = po.branch_code
	        CONNECT BY PRIOR parent_branch = branch_code) thirdBranchName,
	       di.dept_name deptName,
	       decode(bi.branch_level, '04', bi.branch_name, '') branchName,
	       ctl.description AS description,
	       (SELECT ci.client_name
	          FROM client_information ci
	         WHERE ci.client_no = po.applicant_no) applicantName,
	       po.applicant_no applicantNo,
	       (SELECT ssi.emp_name
	          FROM staff_info ssi
	         WHERE ssi.emp_no = rpsi.agent_no) agentName,
	       rpsi.agent_no agentNo,
	       si.emp_name empName,
	       rpsi.service_no servicerNo,
	       p.abbr_name abbrName,
	       rpsi.pay_times payTimes,
	       ppi.modal_total_prem modalTotalPrem,
	       ca.full_address fullAddress,
	       (SELECT cci.client_name
	          FROM client_information cci
	         WHERE cci.client_no = pp.insured_no) insuredName,
	       pp.insured_no insuredNo,
	       ppp.prem_term premTerm,
	       ppi.prem_due_date premDate
	  FROM policy po
	 INNER JOIN rn_policy_service_info rpsi
	    ON rpsi.policy_no = po.policy_no
	 INNER JOIN branch_code_relation bcr
	    ON bcr.branch_code = po.branch_code
	 INNER JOIN policy_product pp
	    ON pp.policy_no = po.policy_no
	   AND pp.prod_seq = '1'
	 INNER JOIN policy_prem_info ppi
	    ON ppi.policy_no = po.policy_no
	 INNER JOIN staff_info si
	    ON si.emp_no = rpsi.service_no
	 INNER JOIN channel_type_tbl ctl
	    ON ctl.channel_type = po.channel_type
	 INNER JOIN branch_info bi
	    ON bi.branch_code = po.branch_code
	 INNER JOIN department_info di
	    ON di.dept_no = si.dept_no
	 INNER JOIN product p
	    ON p.product_code = pp.product_code
	 INNER JOIN policy_product_prem ppp
	    ON ppp.policy_no = po.policy_no
	   AND ppp.prod_seq = '1'
	  LEFT JOIN policy_contact_info pci
	    ON pci.policy_no = po.policy_no
	  LEFT JOIN client_address ca
	    ON ca.address_seq = pci.address_seq
	  LEFT JOIN gras_assign_failed_record gfr
	    ON gfr.policy_no = rpsi.policy_no
	   AND gfr.is_valid = 'Y'
	 WHERE
	 bcr.relative_grade > -1
	 AND gfr.policy_no IS NULL
	 AND ppi.prem_status = '1'
	 AND ppi.prem_source = '1'
	 AND po.duty_status = '1'
	 AND (rpsi.assign_rule IN ('01', '02') OR rpsi.assign_rule IS NULL)
	 AND pp.product_code NOT IN ('CBAN_TN1', 'CBAN_UN1', 'CBAN_VN1')
	 AND bcr.relative_branch_code = #{branchCode,jdbcType=VARCHAR}
	 AND ppi.PREM_DUE_DATE >= "TO_DATE"(#{nowMonth},'yyyy-MM-dd hh24:mi:ss')
	 AND ppi.PREM_DUE_DATE &lt; "TO_DATE"(#{nextMonth},'yyyy-MM-dd hh24:mi:ss')
    <choose>
		 <when test="channelTypeList != null and channelTypeList.size() > 0">
		         AND po.channel_type in 
		         <foreach collection="channelTypeList" index="index" item="item" open="(" separator="," close=")">
			        #{item}
			     </foreach>
		 </when>
		 <otherwise>
		        AND po.channel_type not in ('06','08','11')
		  </otherwise>
    </choose>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    应分getDatasExportToExcel
    
    
        logUtils.info("(分单)getDatasExportToExcel方法参数开始:"+DateUtil.getDateTimeFormat(new Date()));
        List<String> header = new ArrayList<String>();// 第一行数据
        List<List<String>> body = new ArrayList<List<String>>();
        if(premDueDate != null) {
            JSONObject params = new JSONObject();
            params.put("branchCode", branchCode);
            //需要分单的保单条件
            params.put("premStatus","1");//缴费状态为已缴费
//            params.put("channelType","01,02,04,05,07");//渠道
            params.put("channelType","06,08,11");//渠道
            params.put("premSource","1");//保费来源为客户1
//        params.put("orphanMark","1");//0在职单1孤儿单,保单要为孤儿单
            params.put("assignRule","03");//只考虑正常分单(01、null)和跨机构分单(02)
            params.put("prodSeq","1");//产品序号,保单险种序号等于1
            params.put("productCode","CBAN_TN1,CBAN_UN1,CBAN_VN1");//产品代码 ,保单险种不能为CBAN_TN1,CBAN_UN1,CBAN_VN1
            transFormDate(premDueDate, params);
            if (pageSize == null || pageSize == 0) {
                pageSize = 10;
            }
            if (pageNum == null || pageNum == 0) {
                pageNum = 0;
            }
            Map<String, JSONObject> result = service.queryAllotPolicys(params);
            header.add("保单号");
            header.add("分公司名称");
            header.add("中心支公司名称");
            //部门名称service_dept_name
            header.add("部门名称");
            //营销服务部名称bi_branch_level=4   bi_branch_name
            header.add("营销服务部名称");
            
            header.add("渠道");
            header.add("投保人姓名");
            header.add("投保人客户号");
            header.add("业务员姓名");
            header.add("业务员工号");
            header.add("收展服务人员姓名");
            header.add("收展服务人员工号");
            header.add("主险名称");
            header.add("缴次");
            header.add("期交保费合计金额");
            
            //被保人客户号pp_insured_no
            header.add("被保人客户号");
            //被保人姓名 insured_client_name
            header.add("被保人姓名");
            //缴费年期ppp_prem_term
            header.add("缴费年期");
            //保单联系地址ca_full_address
            header.add("保单联系地址");
            
            List<Object> in = (List<Object>) result.get("in").get("att_value");
            List<Object> out = (List<Object>) result.get("out").get("att_value");
            List<Object> allList = new ArrayList<>();
            if (in != null){
                allList.addAll(in);
            }
            if (out != null){
                allList.addAll(out);
            }
            JSONObject attName = result.get("out").getJSONObject("att_name");
            if (allList != null) {
                /*for (int i = 0; i < 5000; i++) {
                Object[] realData = (Object[]) in.get(i);*/
                if (allList.size()>1000) {
                    //创建多线程
                    //多线程
                    AllotExportToExcelRunnable task = null;
                    MultiThreadHandler handler = new MultiThreadHandler();
                    task = new AllotExportToExcelRunnable(allList, body, attName);
                    handler.addTask(task);
                    //多线程执行
                    handler.run();
                }else {
                    for (Object datasByParam : allList) {
                        Object[] realData = (Object[]) datasByParam;
                        List<String> data = new ArrayList<>();
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("po_policy_no")]));//保单号
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("second_branch_name")]));//分公司名称pbi_branch_name
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("third_branch_name")]));//中心支公司名称
                        
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("service_dept_name")]));//部门名称
                        Object branchLevel=realData[attName.getInteger("bi_branch_level")];
                        if(branchLevel==null || !branchLevel.equals("04")){
                            data.add(null);//营销服务部名称
                        }else{
                            data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("bi_branch_name")]));//营销服务部名称
                        }
                        
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("ct_description")]));//渠道
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("ci_client_name")]));//客户姓名
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("ca_client_no")]));//客户号
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("agent_emp_name")]));//业务员姓名
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("agent_emp_code")]));//业务员工号
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("service_emp_name")]));//续收人员姓名
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("service_emp_no")]));//续收人员工号
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("pro_abbr_name")]));//主险名称
                        String rnpsi_pay_times = StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("rnpsi_pay_times")]);
                        if (rnpsi_pay_times!=null&&!"".equals(rnpsi_pay_times)) {
                            String split = rnpsi_pay_times.split("[.]")[0];
                            data.add(split);//缴次
                        }
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("pp_modal_total_prem")]));//期交保费
                        
                        
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("pp_insured_no")]));//被保人客户号
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("insured_client_name")]));//被保人姓名
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("ppp_prem_term")]));//缴费期
                        data.add(StringUtils.isNotNullAndEmptyBalck(realData[attName.getInteger("ca_detail_address")]));//保单联系地址
                        body.add(data);
                    }
                }
            }
        }
        Workbook workbook = ExportFileUtils.generateExcel("sheetName", header, body, "xlsx");
        response.setContentType("application/octet-stream");
        try {
            response.setHeader("Content-disposition","attachment;filename="+java.net.URLEncoder.encode(branchCode+"-"+premDueDate+"应分单保单信息", "UTF-8")+".xlsx");
            response.flushBuffer();
            workbook.write(response.getOutputStream());
            logUtils.info("(分单)getDatasExportToExcel方法参数结束:"+DateUtil.getDateTimeFormat(new Date()));
        }catch (IOException e){
            logUtils.error(e);
        }