|  |  |  | 
|---|
|  |  |  | 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.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 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 普通方法 | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|