|  |  |  | 
|---|
|  |  |  | package com.doumee.core.utils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.io.IoUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.IdcardUtil; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.dao.business.dto.CountCyclePriceDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.model.ApplyDetail; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Solutions; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.ChangeDealTypeVO; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.CountCyclePriceVO; | 
|---|
|  |  |  | import io.swagger.models.auth.In; | 
|---|
|  |  |  | import org.apache.commons.collections4.CollectionUtils; | 
|---|
|  |  |  | import org.apache.commons.compress.archivers.zip.Zip64Mode; | 
|---|
|  |  |  | import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; | 
|---|
|  |  |  | import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final String DU_FILE ="DU_FILE" ; | 
|---|
|  |  |  | public static final String SIGN_DONE_NOTIFY_URL = "SIGN_DONE_NOTIFY_URL"; | 
|---|
|  |  |  | public static final int FOUR = 4; | 
|---|
|  |  |  | public static final String COMPANY_PHONE_AUTH ="COMPANY_PHONE_AUTH" ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取申请单时间列标题 | 
|---|
|  |  |  | * @param type 0开始时间 1截止时间 | 
|---|
|  |  |  | * @param model | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static String getApplyTimeTitle(int type, InsuranceApply model){ | 
|---|
|  |  |  | if(type ==1){ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getSolutionType(),Constants.ONE)){ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getUnionApplyTbdStatus(),Constants.THREE)?"保险生效起期":"期望保险生效起期"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())?"保险生效起期":"期望保险生效起期"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(Constants.equalsInteger(model.getSolutionType(),Constants.ONE)){ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getUnionApplyTbdStatus(),Constants.THREE)?"保险生效止期":"预计生效止期"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())?"保险生效止期":"预计生效止期"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public interface DATAPERMISSION_TYPE{ | 
|---|
|  |  |  | public static final  int all = 0; | 
|---|
|  |  |  | public static final  int departAndChild = 1; | 
|---|
|  |  |  | public static final  int departAndLeaf = 2; | 
|---|
|  |  |  | public static final  int depart = 3; | 
|---|
|  |  |  | public static final  int custom = 4; | 
|---|
|  |  |  | public static final  int self = -1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取批改单时间标题列 | 
|---|
|  |  |  | * @param type 0更换派遣单位 1加保 0减保 | 
|---|
|  |  |  | * @param model | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static String getChangeApplyTimeTitle(int type, ApplyChange model){ | 
|---|
|  |  |  | if(type ==2){ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), ApplyChangeStatus.APPROVE.getKey())?"批单生效期":"期望批单生效期"; | 
|---|
|  |  |  | }else  if(type ==1){ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), ApplyChangeStatus.APPROVE.getKey())?"批增生效起期":"期望批增生效起期"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), ApplyChangeStatus.APPROVE.getKey())?"批减生效起期":"期望批减生效起期"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String getApplyTimeTitle(int type, UnionApply model){ | 
|---|
|  |  |  | if(type ==1){ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), UnionApplyStatus.FINISH.getKey())?"保险生效起期":"期望保险生效起期"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), UnionApplyStatus.FINISH.getKey())?"保险生效止期":"预计生效止期"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取批改单时间标题列 | 
|---|
|  |  |  | * @param type 0更换派遣单位 1加保 0减保 | 
|---|
|  |  |  | * @param model | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static String getChangeApplyTimeTitle(int type, UnionChange model){ | 
|---|
|  |  |  | if(type ==2){ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), UnionChangeStatus.FINISH.getKey())?"批单生效期":"期望批单生效期"; | 
|---|
|  |  |  | }else  if(type ==1){ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), UnionChangeStatus.FINISH.getKey())?"批增生效起期":"期望批增生效起期"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return  Constants.equalsInteger(model.getStatus(), UnionChangeStatus.FINISH.getKey())?"批减生效起期":"期望批减生效起期"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 企业数据来源 0平台注册 1后台导入 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 普通方法 | 
|---|
|  |  |  | public static String getName(int index) { | 
|---|
|  |  |  | for (ProjectRecord c : ProjectRecord.values()) { | 
|---|
|  |  |  | for (MultiFile c : MultiFile.values()) { | 
|---|
|  |  |  | if (c.getKey() == index) { | 
|---|
|  |  |  | return c.name; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 普通方法 | 
|---|
|  |  |  | public static String getInfo(int index) { | 
|---|
|  |  |  | for (ProjectRecord c : ProjectRecord.values()) { | 
|---|
|  |  |  | for (MultiFile c : MultiFile.values()) { | 
|---|
|  |  |  | if (c.getKey() == index) { | 
|---|
|  |  |  | return c.noteinfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public  enum ApplyLogType { | 
|---|
|  |  |  | UPLOAD(0, "提交投保","提交意见:${param}",0), | 
|---|
|  |  |  | PLATFORM_RETURN(1, "退回投保","提交意见:${param}",0), | 
|---|
|  |  |  | PLATFORM_RETURN(1, "退回申请","提交意见:${param}",0), | 
|---|
|  |  |  | WAIT_SIGNATURE(2, "上传投保单","提交意见:${param}",0), | 
|---|
|  |  |  | SIGNATURE(3, "企业签章","",0), | 
|---|
|  |  |  | FAIL_RETURN(4, "保单出具失败退回","提交意见:${param}",0), | 
|---|
|  |  |  | 
|---|
|  |  |  | COMPANY_EDIT(10, "保单修改","提交意见:${param1}\n${param2}",0), | 
|---|
|  |  |  | PLATFORM_CHECK_PASS(11, "投保审核通过","提交意见:${param}",0), | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CA_PLATFORM_CHECK_PASS_NO(12, "退回投保","提交意见:${param}",1), | 
|---|
|  |  |  | CA_PLATFORM_CHECK_PASS_NO(12, "退回申请","提交意见:${param}",1), | 
|---|
|  |  |  | CA_PLATFORM_AGREE_BACK_APPLY(13, "同意退回申请","提交意见:${param}",1), | 
|---|
|  |  |  | CA_PLATFORM_APPROVE(14, "批单完成","保险生效起期:${param1}变更为${param2}",1), | 
|---|
|  |  |  | CA_PLATFORM_CHECK_SIGNATURE(15, "企业签章","",1), | 
|---|
|  |  |  | CA_COMPANY_EDIT(16, "批单修改","提交意见:${param1}\n${param2}",1), | 
|---|
|  |  |  | CA_COMPANY_COMMIT(17, "提交投保","",1), | 
|---|
|  |  |  | CA_COMPANY_BACK_APPLY(18, "申请退回","提交意见:${param}",1), | 
|---|
|  |  |  | CA_COMPANY_CLOSE(19, "关闭订单","",1), | 
|---|
|  |  |  | CA_COMPANY_CLOSE(19, "关闭申请","",1), | 
|---|
|  |  |  | CA_PALTFORM_REFUSE_APPLY(20, "驳回退回申请","",1), | 
|---|
|  |  |  | CA_PALTFORM_EDIT_PIDAN(21, "修改批单","修改原因:${param}",1), | 
|---|
|  |  |  | CA_JIAJIAN_APPLY_SIGN(23, "加减保申请企业签章","",1), | 
|---|
|  |  |  | 
|---|
|  |  |  | InputStream inStream = null; | 
|---|
|  |  |  | OutputStream os = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String tempDir = System.getProperty("java.io.tmpdir")+fileName; | 
|---|
|  |  |  | String tempDir = "C:\\hj\\jars\\temp\\"; | 
|---|
|  |  |  | File f =  new File(tempDir); | 
|---|
|  |  |  | if(!f.exists() ){ | 
|---|
|  |  |  | f.mkdirs(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | tempDir +=  fileName; | 
|---|
|  |  |  | System.out.println(url+"================="+tempDir); | 
|---|
|  |  |  | file = new File(tempDir); | 
|---|
|  |  |  | //下载 | 
|---|
|  |  |  | urlfile = new URL(url); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return file; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static void packFilesToZip(List<File> files,    ServletOutputStream os) throws IOException { | 
|---|
|  |  |  | try (ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(os)) { | 
|---|
|  |  |  | public static void packFilesToZip(List<File> files,    OutputStream os) throws IOException { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(os); | 
|---|
|  |  |  | zipOutputStream.setUseZip64(Zip64Mode.AsNeeded); | 
|---|
|  |  |  | for (File file : files) { | 
|---|
|  |  |  | if(!file.exists()){ | 
|---|
|  |  |  | System.out.println("===文件不存在======="+file.getPath()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | System.out.println("===文件存在======="+file.getPath()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ZipArchiveEntry entry = new ZipArchiveEntry(file.getName()); | 
|---|
|  |  |  | zipOutputStream.putArchiveEntry(entry); | 
|---|
|  |  |  | try (FileInputStream fileInputStream = new FileInputStream(file)) { | 
|---|
|  |  |  | byte[] buffer = new byte[1024]; | 
|---|
|  |  |  | int length; | 
|---|
|  |  |  | while ((length = fileInputStream.read(buffer)) > 0) { | 
|---|
|  |  |  | zipOutputStream.write(buffer, 0, length); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | FileInputStream fileInputStream = new FileInputStream(file); | 
|---|
|  |  |  | byte[] buffer = new byte[1024]; | 
|---|
|  |  |  | int length; | 
|---|
|  |  |  | while ((length = fileInputStream.read(buffer)) > 0) { | 
|---|
|  |  |  | zipOutputStream.write(buffer, 0, length); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | zipOutputStream.closeArchiveEntry(); | 
|---|
|  |  |  | zipOutputStream.flush(); | 
|---|
|  |  |  | IoUtil.close(fileInputStream); | 
|---|
|  |  |  | file.delete(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR.getCode(),"对不起,下载压缩文件失败"); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | if (os != null) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | os.close(); | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|