111
k94314517
2024-01-24 0c009141867c996897928c4f12490f21b78222f2
server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -3,6 +3,7 @@
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.dao.business.model.Solutions;
import io.swagger.models.auth.In;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -13,6 +14,8 @@
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLDecoder;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.Date;
import java.util.regex.Matcher;
@@ -145,6 +148,36 @@
        }
        return d.intValue();
    }
    public static long getAgeByIdCard(String idCard){
        int birthYear = Integer.parseInt(idCard.substring(6, 10));
        int birthMonth = Integer.parseInt(idCard.substring(10, 12));
        int birthDay = Integer.parseInt(idCard.substring(12, 14));
        LocalDate birthDate = LocalDate.of(birthYear, birthMonth, birthDay);
        LocalDate currentDate = LocalDate.now();
        long age = ChronoUnit.YEARS.between(birthDate, currentDate);
        return age;
    }
    public static Integer getSexByIdCard(String idCard){
        Pattern pattern = Pattern.compile("\\d{17}[\\d|x]"); // 定义身份证号码格式的正则表达式
        Matcher matcher = pattern.matcher(idCard);
        Integer sex = 1;
        if (matcher.matches()) {
            int genderCode = Integer.parseInt(idCard.substring(16, 17)); // 从第17位开始提取性别编码(奇数为男性,偶数为女性)
            if ((genderCode % 2 == 1)) {
                sex = 1;
            } else {
                sex = 2;
            }
        } else {
           sex = -1;
        }
        return sex;
    }
    /**
     * 状态 0已保存、1待审核、2审核通过、3退回修改、4审核驳回、5待服务机构确认、6服务机构拒绝、7已分配服务机构、8诊断中
     * (成功上传第一份服务资料)、9服务完成、10已分配评分专家、11已完成(专家上传评分) 12退回修改中 13 已完成退回修改