k94314517
2024-07-30 d37bf55e27b7edb61037bccde6cabeda1ddec6b7
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1,17 +1,16 @@
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.ApplyChange;
import com.doumee.dao.business.model.ApplyDetail;
import com.doumee.dao.business.model.InsuranceApply;
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;
@@ -116,9 +115,9 @@
            }
        }else{
            if(Constants.equalsInteger(model.getSolutionType(),Constants.ONE)){
                return  Constants.equalsInteger(model.getUnionApplyTbdStatus(),Constants.THREE)?"保险生效止期":"期望保险生效止期";
                return  Constants.equalsInteger(model.getUnionApplyTbdStatus(),Constants.THREE)?"保险生效止期":"预计生效止期";
            }else{
                return  Constants.equalsInteger(model.getStatus(), InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())?"保险生效止期":"期望保险生效止期";
                return  Constants.equalsInteger(model.getStatus(), InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())?"保险生效止期":"预计生效止期";
            }
        }
@@ -137,6 +136,32 @@
            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())?"批减生效起期":"期望批减生效起期";
        }
    }
    /**
@@ -701,7 +726,7 @@
        // 普通方法
        public static String getName(int index) {
            for (ProjectRecord c : ProjectRecord.values()) {
            for (MultiFile c : MultiFile.values()) {
                if (c.getKey() == index) {
                    return c.name;
                }
@@ -711,7 +736,7 @@
        // 普通方法
        public static String getInfo(int index) {
            for (ProjectRecord c : ProjectRecord.values()) {
            for (MultiFile c : MultiFile.values()) {
                if (c.getKey() == index) {
                    return c.noteinfo;
                }
@@ -2179,7 +2204,13 @@
            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);
@@ -2205,26 +2236,45 @@
                }
            }
        }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();
                }
            }
        }
    }