k94314517
2024-07-30 d37bf55e27b7edb61037bccde6cabeda1ddec6b7
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1,15 +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.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;
@@ -96,7 +97,73 @@
    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())?"保险生效止期":"预计生效止期";
            }
        }
    }
    /**
     * 获取批改单时间标题列
     * @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后台导入
     */
@@ -386,7 +453,7 @@
        if(StringUtils.isBlank(idCard)){
            return 2;
        }
        Pattern pattern = Pattern.compile("\\d{17}[\\d|x]"); // 定义身份证号码格式的正则表达式
        Pattern pattern = Pattern.compile("\\d{17}[\\d|x|X]"); // 定义身份证号码格式的正则表达式
        Matcher matcher = pattern.matcher(idCard);
        Integer sex = 0;
        if (matcher.matches()) {
@@ -401,6 +468,7 @@
        }
        return sex;
    }
    /**
     * 状态 0已保存、1待审核、2审核通过、3退回修改、4审核驳回、5待服务机构确认、6服务机构拒绝、7已分配服务机构、8诊断中
@@ -658,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;
                }
@@ -668,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;
                }
@@ -759,9 +827,12 @@
    }
    public static void main(String[] args) {
        System.out.println(IdcardUtil.isValidCard("340621199310134818"));
        System.out.println(IdcardUtil.isValidCard("341621199310134818"));
        System.out.println(IdcardUtil.isValidCard("342623199201150101"));
        System.out.println(IdcardUtil.isValidCard("342623199201150102"));
        System.out.println(IdcardUtil.isValidCard("342623199201150103"));
        System.out.println(IdcardUtil.isValidCard("342623199201150104"));
//        System.out.println(IdcardUtil.isValidCard("340621199310134818"));
//        System.out.println(IdcardUtil.isValidCard("341621199310134818"));
//        System.out.println("{\"companyName\":\"应宝科技\",\"endtime\":\"2024-03-01 17:19:00\",\"erpId\":\"4D40185D5BC74A13821BE46EAF8B4179\",\"erpWithVisitDTOList\":[],\"faceImg\":\"20240304/1709518170325_742.jpg\",\"idcardNo\":\"342501199609300535\",\"idcardType\":0,\"name\":\"黄晋\",\"phone\":\"17756328697\",\"reason\":\"探险\",\"receptMemberId\":\"E7E514BD7DE3F27CE0530B630A0AEAE0\",\"starttime\":\"2024-03-01 13:18:00\"}");
    }
@@ -2133,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);
@@ -2159,25 +2236,44 @@
                }
            }
        }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();
                }
            }
        }
    }
@@ -2379,4 +2475,5 @@
        }
    }
}