Commit 93cce868 authored by hongguangwu's avatar hongguangwu

1.7.22-薪资人员导入校验16周岁

parent 46ea3e9e
......@@ -1155,14 +1155,17 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
return R.failed("请登录!");
}
TCheckIdCard idCardCheck;
int nowDay = Integer.parseInt(DateUtil.getThisDay());
for (TSalaryEmployee emp : excelVOList) {
if (Common.isNotNull(emp.getEmpIdcard())) {
if (!isNot16Age(emp.getEmpIdcard(), nowDay)) {
idCardCheck = new TCheckIdCard();
idCardCheck.setIdCard(emp.getEmpIdcard());
idCardCheck.setName(emp.getEmpName());
idCardCheck.setCreateUser(user.getId());
idCardCheck.setReason(user.getNickname());
checkList.add(idCardCheck);
}
idCardList.add(emp.getEmpIdcard());
}
if (Common.isNotNull(emp.getEmpPhone())) {
......@@ -1391,6 +1394,10 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
errorMessageList.add(new ErrorMessage((i ), "新增员工,除了支行,其他必填"));
continue;
} else {
if (isNot16Age(idCard, nowDay)) {
errorMessageList.add(new ErrorMessage((i ), "人员未满16周岁,禁用童工"));
continue;
}
if (excel.getTaxMonth().length() == 6) {
try {
Integer.parseInt(excel.getTaxMonth());
......@@ -1489,6 +1496,31 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
}
}
// 判断是否未满16周岁(只有一种:身份证格式正确,且+16年大于等于当前日期
// 未满16周岁的,返回true,表示需要返回错误信息
public static boolean isNot16Age(String idCard, int nowDay) {
try {
if (Common.isNotNull(idCard) && (idCard.length() == 15 || idCard.length() == 18)) {
int birthDay;
if (idCard.length() == 18) {
// 18位身份证:第7-14位是出生年月日 (YYYYMMDD)
birthDay = Integer.parseInt(idCard.substring(6, 14));
} else {
// 15位身份证年份需要补全19xx年(15位身份证都是19开头的)
birthDay = Integer.parseInt("19" + idCard.substring(6, 12));
}
birthDay += 160000;
return birthDay >= nowDay;
} else {
// 其他情况不判断16周岁
return false;
}
} catch (Exception e) {
// 特殊或错误身份证,不判断16周岁-2026-04-20同倩倩确认
return false;
}
}
/**
* 同步ekp薪酬人员信息
*
......
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