Commit c58405a9 authored by 李灿灿's avatar 李灿灿

商险优化部分接口

parent c60d496d
...@@ -378,6 +378,16 @@ public interface CommonConstants { ...@@ -378,6 +378,16 @@ public interface CommonConstants {
// 日 // 日
String DAY = "日"; String DAY = "日";
/**
* 一年365天
*/
int ONE_YEAR = 365;
/**
* 数字70
*/
int SEVENTY = 70;
/** /**
* 省市 * 省市
* @Author fxj * @Author fxj
......
...@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -30,6 +31,42 @@ public class IdCardUtil { ...@@ -30,6 +31,42 @@ public class IdCardUtil {
} }
/**
* 根据身份证号计算周岁
* 例如:当前时间是2022-08-22,那么2007-08-22算15周岁,2007-08-23才算16周岁
*
* @author licancan
* @param idNO
* @return {@link int}
*/
public static int getFullAge(String idNO){
Date birthday = getBirthdate(idNO);
// 从Calendar对象中获得一个Date对象
Calendar cal = Calendar.getInstance();
// 把出生日期放入Calendar类型的bir对象中,进行Calendar和Date类型进行转换
Calendar bir = Calendar.getInstance();
bir.setTime(birthday);
// 如果生日大于当前日期,则抛出异常:出生日期不能大于当前日期
if (cal.before(birthday)) {
throw new IllegalArgumentException("The birthday is after Now,It's unbelievable");
}
// 取出当前年月日
int yearNow = cal.get(Calendar.YEAR);
int monthNow = cal.get(Calendar.MONTH);
int dayNow = cal.get(Calendar.DAY_OF_MONTH);
// 取出出生年月日
int yearBirth = bir.get(Calendar.YEAR);
int monthBirth = bir.get(Calendar.MONTH);
int dayBirth = bir.get(Calendar.DAY_OF_MONTH);
// 大概年龄是当前年减去出生年
int age = yearNow - yearBirth;
// 如果出当前月大于出生月,或者当前月等于出生月但是当前日大于出生日,那么年龄age就加一岁
if (monthNow > monthBirth || (monthNow == monthBirth && dayNow > dayBirth)) {
age++;
}
return age;
}
/** /**
* 提取身份证中的出生日期,身份证非法则返回空 * 提取身份证中的出生日期,身份证非法则返回空
* @param idNum * @param idNum
......
...@@ -185,6 +185,14 @@ public class InsurancesConstants { ...@@ -185,6 +185,14 @@ public class InsurancesConstants {
* 员工身份证号格式错误 * 员工身份证号格式错误
*/ */
public static final String EMP_IDCARD_NO_NOT_LEGITIMATE = "员工身份证号格式错误"; public static final String EMP_IDCARD_NO_NOT_LEGITIMATE = "员工身份证号格式错误";
/**
* 员工年龄不在16岁-70岁之间
*/
public static final String EMP_AGE_NOT_LEGITIMATE = "员工年龄不在16岁-70岁之间";
/**
* 替换员工年龄不在16岁-70岁之间
*/
public static final String REPLACE_EMP_AGE_NOT_LEGITIMATE = "替换员工年龄不在16岁-70岁之间";
/** /**
* 员工未通过实名认证 * 员工未通过实名认证
*/ */
...@@ -245,6 +253,10 @@ public class InsurancesConstants { ...@@ -245,6 +253,10 @@ public class InsurancesConstants {
* 保单结束时间需要大于保单开始时间 * 保单结束时间需要大于保单开始时间
*/ */
public static final String POLICY_START_SHOULD_LESS_THAN_POLICY_END = "保单结束时间需要大于保单开始时间"; public static final String POLICY_START_SHOULD_LESS_THAN_POLICY_END = "保单结束时间需要大于保单开始时间";
/**
* 保单起止时间不能超过365天
*/
public static final String POLICY_DATE_NOT_MORE_THAN_365 = "保单起止时间不能超过365天";
/** /**
* 保单结束时间不能为空 * 保单结束时间不能为空
*/ */
......
...@@ -15,6 +15,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo; ...@@ -15,6 +15,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.IdCardUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
...@@ -555,6 +556,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -555,6 +556,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (!LocalDateUtil.compareDate(param.getPolicyStart(),param.getPolicyEnd())){ if (!LocalDateUtil.compareDate(param.getPolicyStart(),param.getPolicyEnd())){
return R.failed(InsurancesConstants.POLICY_START_SHOULD_LESS_THAN_POLICY_END); return R.failed(InsurancesConstants.POLICY_START_SHOULD_LESS_THAN_POLICY_END);
} }
if (LocalDateUtil.betweenDay(param.getPolicyStart(),param.getPolicyEnd()) > CommonConstants.ONE_YEAR){
return R.failed(InsurancesConstants.POLICY_DATE_NOT_MORE_THAN_365);
}
//如果不是补单的,需要校验:保单开始日期 > 当前派单日期 //如果不是补单的,需要校验:保单开始日期 > 当前派单日期
if (byId.getSignFlag() == CommonConstants.ZERO_INT){ if (byId.getSignFlag() == CommonConstants.ZERO_INT){
...@@ -1394,6 +1398,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -1394,6 +1398,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param); listResult.add(param);
continue; continue;
} }
//年龄是否在16-70之间
if (IdCardUtil.getFullAge(param.getEmpIdcardNo()) < CommonConstants.SIXTEEN_INT || IdCardUtil.getFullAge(param.getEmpIdcardNo()) > CommonConstants.SEVENTY){
param.setErrorMessage(InsurancesConstants.EMP_AGE_NOT_LEGITIMATE);
listResult.add(param);
continue;
}
// 保单开始日期 > 当前派单日期 // 保单开始日期 > 当前派单日期
if(!LocalDateUtil.isDate(param.getPolicyStart(),LocalDateUtil.NORM_DATE_PATTERN)){ if(!LocalDateUtil.isDate(param.getPolicyStart(),LocalDateUtil.NORM_DATE_PATTERN)){
...@@ -1416,6 +1426,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -1416,6 +1426,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param); listResult.add(param);
continue; continue;
} }
if (LocalDateUtil.betweenDay(param.getPolicyStart(),param.getPolicyEnd()) > CommonConstants.ONE_YEAR){
param.setErrorMessage(InsurancesConstants.POLICY_DATE_NOT_MORE_THAN_365);
listResult.add(param);
continue;
}
//表内数据重复 员工姓名、员工身份证号码、保险公司、险种、起止时间(有交叉) //表内数据重复 员工姓名、员工身份证号码、保险公司、险种、起止时间(有交叉)
for (int j = 0; j < distinctList.size(); j++) { for (int j = 0; j < distinctList.size(); j++) {
...@@ -1776,6 +1791,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -1776,6 +1791,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param); listResult.add(param);
continue; continue;
} }
//年龄是否在16-70之间
if (IdCardUtil.getFullAge(param.getEmpIdcardNo()) < CommonConstants.SIXTEEN_INT || IdCardUtil.getFullAge(param.getEmpIdcardNo()) > CommonConstants.SEVENTY){
param.setErrorMessage(InsurancesConstants.EMP_AGE_NOT_LEGITIMATE);
listResult.add(param);
continue;
}
//表内数据重复 员工姓名、员工身份证号码、保险公司、险种 //表内数据重复 员工姓名、员工身份证号码、保险公司、险种
for (int j = 0; j < distinctList.size(); j++) { for (int j = 0; j < distinctList.size(); j++) {
InsuranceBatchParam repeat = distinctList.get(j); InsuranceBatchParam repeat = distinctList.get(j);
...@@ -2117,6 +2138,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -2117,6 +2138,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param); listResult.add(param);
continue; continue;
} }
//年龄是否在16-70之间
if (IdCardUtil.getFullAge(param.getReplaceEmpIdcardNo()) < CommonConstants.SIXTEEN_INT || IdCardUtil.getFullAge(param.getReplaceEmpIdcardNo()) > CommonConstants.SEVENTY){
param.setErrorMessage(InsurancesConstants.REPLACE_EMP_AGE_NOT_LEGITIMATE);
listResult.add(param);
continue;
}
if(!LocalDateUtil.isDate(param.getPolicyStart(),LocalDateUtil.NORM_DATE_PATTERN)){ if(!LocalDateUtil.isDate(param.getPolicyStart(),LocalDateUtil.NORM_DATE_PATTERN)){
param.setErrorMessage(InsurancesConstants.POLICY_START_PARSE_ERROR); param.setErrorMessage(InsurancesConstants.POLICY_START_PARSE_ERROR);
...@@ -2133,6 +2160,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -2133,6 +2160,12 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param); listResult.add(param);
continue; continue;
} }
if (LocalDateUtil.betweenDay(param.getPolicyStart(),param.getPolicyEnd()) > CommonConstants.ONE_YEAR){
param.setErrorMessage(InsurancesConstants.POLICY_DATE_NOT_MORE_THAN_365);
listResult.add(param);
continue;
}
//表内数据重复 员工姓名、员工身份证号码、保险公司、险种、起止时间(有交叉) //表内数据重复 员工姓名、员工身份证号码、保险公司、险种、起止时间(有交叉)
for (int j = 0; j < distinctList.size(); j++) { for (int j = 0; j < distinctList.size(); j++) {
InsuranceReplaceParam repeat = distinctList.get(j); InsuranceReplaceParam repeat = distinctList.get(j);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment