Commit e0cebcdb authored by hongguangwu's avatar hongguangwu

1.7.22-薪资导入校验16周岁

parent 17f552a7
...@@ -178,8 +178,8 @@ public class TCheckIdCardController { ...@@ -178,8 +178,8 @@ public class TCheckIdCardController {
@Operation(description = "校验薪资姓名身份证") @Operation(description = "校验薪资姓名身份证")
@SysLog("校验薪资姓名身份证") @SysLog("校验薪资姓名身份证")
@PostMapping("/checkSalaryIdCard") @PostMapping("/checkSalaryIdCard")
public R<List<TCheckIdCard>> checkSalaryIdCard(@RequestBody List<TCheckIdCard> checkList) { public R<List<TCheckIdCard>> checkSalaryIdCard(@RequestBody List<TCheckIdCard> checkList, @RequestParam(required = false) Integer judgeAgeType) {
return tCheckIdCardService.checkSalaryIdCard(checkList, null); return tCheckIdCardService.checkSalaryIdCard(checkList, null, judgeAgeType);
} }
/** /**
...@@ -210,7 +210,7 @@ public class TCheckIdCardController { ...@@ -210,7 +210,7 @@ public class TCheckIdCardController {
} }
/** /**
* @Description: 批量校验姓名身份证 * @Description: 批量校验姓名身份证(未来如果薪资要用这个方法,需要传参judgeAgeType=1
* @Author: hgw * @Author: hgw
* @Date: 2024-4-16 19:47:20 * @Date: 2024-4-16 19:47:20
* @return: com.yifu.cloud.v1.common.core.util.R * @return: com.yifu.cloud.v1.common.core.util.R
...@@ -221,7 +221,8 @@ public class TCheckIdCardController { ...@@ -221,7 +221,8 @@ public class TCheckIdCardController {
@PostMapping("/inner/checkIdCardList") @PostMapping("/inner/checkIdCardList")
public CheckIdCardListVo checkIdCardList(@RequestBody CheckIdCardListVo vo) { public CheckIdCardListVo checkIdCardList(@RequestBody CheckIdCardListVo vo) {
CheckIdCardListVo returnVo = new CheckIdCardListVo(); CheckIdCardListVo returnVo = new CheckIdCardListVo();
R<List<TCheckIdCard>> checkR = tCheckIdCardService.checkSalaryIdCard(vo.getCheckList(), null); // 注意:未来如果薪资要用这个方法,需要传参judgeAgeType=1
R<List<TCheckIdCard>> checkR = tCheckIdCardService.checkSalaryIdCard(vo.getCheckList(), null, null);
if (checkR != null) { if (checkR != null) {
if (checkR.getCode() == CommonConstants.SUCCESS) { if (checkR.getCode() == CommonConstants.SUCCESS) {
returnVo.setCode(CommonConstants.SUCCESS); returnVo.setCode(CommonConstants.SUCCESS);
......
...@@ -49,7 +49,7 @@ public interface TCheckIdCardService extends IService<TCheckIdCard> { ...@@ -49,7 +49,7 @@ public interface TCheckIdCardService extends IService<TCheckIdCard> {
TCheckIdCard checkIdCardSingle(TCheckIdCard tCheckIdCard); TCheckIdCard checkIdCardSingle(TCheckIdCard tCheckIdCard);
R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList, YifuUser user); R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList, YifuUser user, Integer judgeAgeType);
/** /**
* @param list * @param list
......
...@@ -431,7 +431,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh ...@@ -431,7 +431,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
} }
@Override @Override
public R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList, YifuUser user) { public R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList, YifuUser user, Integer judgeAgeType) {
TCanCheck tCanCheck= canCheckService.getById(1); TCanCheck tCanCheck= canCheckService.getById(1);
boolean canCheck = false; boolean canCheck = false;
if (tCanCheck != null && tCanCheck.getCanCheck() == 1) { if (tCanCheck != null && tCanCheck.getCanCheck() == 1) {
...@@ -491,9 +491,16 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh ...@@ -491,9 +491,16 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
int apiNum = 0; int apiNum = 0;
// 有一个错误,就不传200给前端 // 有一个错误,就不传200给前端
boolean isTrue = true; boolean isTrue = true;
int nowDay = Integer.parseInt(DateUtil.getThisDay());
try { try {
for (TCheckIdCard c : checkList) { for (TCheckIdCard c : checkList) {
if (Common.isNotNull(c.getIdCard()) && Common.isNotNull(c.getName())) { if (Common.isNotNull(c.getIdCard()) && Common.isNotNull(c.getName())) {
// 仅工资导入需要判断16周岁,其他的不需要
if (Common.isNotNull(judgeAgeType) && CommonConstants.ONE_INT == judgeAgeType
&& isNot16Age(c.getIdCard(), nowDay)) {
c.setIsTrue(0);
c.setReason("人员未满16周岁,禁用童工");
} else {
lastCard = idCardMap.get(c.getIdCard()); lastCard = idCardMap.get(c.getIdCard());
if (lastCard != null) { if (lastCard != null) {
c.setIsTrue(lastCard.getIsTrue()); c.setIsTrue(lastCard.getIsTrue());
...@@ -541,6 +548,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh ...@@ -541,6 +548,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
} }
// 将同身份证的结果存储下来备用,防止撞库 // 将同身份证的结果存储下来备用,防止撞库
idCardMap.put(c.getIdCard(), c); idCardMap.put(c.getIdCard(), c);
}
} else { } else {
c.setIsTrue(0); c.setIsTrue(0);
c.setReason("姓名身份证不可为空"); c.setReason("姓名身份证不可为空");
...@@ -577,6 +585,31 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh ...@@ -577,6 +585,31 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
return R.failed("数据为空!"); return R.failed("数据为空!");
} }
// 判断是否未满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;
}
}
/** /**
* @Description: 预入职导入使用的批量姓名身份证校验 * @Description: 预入职导入使用的批量姓名身份证校验
* @Author: hgw * @Author: hgw
...@@ -599,7 +632,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh ...@@ -599,7 +632,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
null, null, null, null,
null,null); null,null);
// 调用以前的批量校验 // 调用以前的批量校验
R<List<TCheckIdCard>> returnR = this.checkSalaryIdCard(list, user); R<List<TCheckIdCard>> returnR = this.checkSalaryIdCard(list, user, null);
if (returnR != null) { if (returnR != null) {
if (returnR.getCode() == CommonConstants.SUCCESS) { if (returnR.getCode() == CommonConstants.SUCCESS) {
checkMap.put("全部正确", true); checkMap.put("全部正确", true);
......
...@@ -47,8 +47,10 @@ import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryZeroSearchVo; ...@@ -47,8 +47,10 @@ import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryZeroSearchVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryZeroVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryZeroVo;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
...@@ -58,10 +60,7 @@ import java.io.InputStream; ...@@ -58,10 +60,7 @@ import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -90,9 +89,11 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala ...@@ -90,9 +89,11 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala
@Resource @Resource
private CheckDaprUtil checkDaprUtil; private CheckDaprUtil checkDaprUtil;
private static final Random RANDOM = new Random();
// 批量更新状态(deleteFlag0,1,2:0:正常;1:已删除;2存在报账假删除) // 批量更新状态(deleteFlag0,1,2:0:正常;1:已删除;2存在报账假删除)
@Override @Override
public int updateDeleteFlagByIdList(String invoiceTitle, String settleMonth, String year, Integer deleteFlag, Integer oldDeleteFlag, String salaryId) { public synchronized int updateDeleteFlagByIdList(String invoiceTitle, String settleMonth, String year, Integer deleteFlag, Integer oldDeleteFlag, String salaryId) {
List<String> cardList; List<String> cardList;
if (deleteFlag == CommonConstants.ZERO_INT) { if (deleteFlag == CommonConstants.ZERO_INT) {
cardList = salaryAccountService.getCardListBySalaryIdAndNotExists(salaryId, invoiceTitle, settleMonth); cardList = salaryAccountService.getCardListBySalaryIdAndNotExists(salaryId, invoiceTitle, settleMonth);
...@@ -106,7 +107,35 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala ...@@ -106,7 +107,35 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala
if (Common.isEmpty(tableName)) { if (Common.isEmpty(tableName)) {
return CommonConstants.ZERO_INT; return CommonConstants.ZERO_INT;
} }
return baseMapper.updateDeleteFlagByIdList(tableName, deleteFlag, oldDeleteFlag, cardList, invoiceTitle, settleMonth); // 1. 排序
Collections.sort(cardList);
// 2. 分批(每批50条)
int batchSize = 50;
int endIndex;
List<String> batchCards;
for (int i = 0; i < cardList.size(); i += batchSize) {
endIndex = Math.min(i + batchSize, cardList.size());
batchCards = cardList.subList(i, endIndex);
// 每批执行一次批量更新
try {
baseMapper.updateDeleteFlagByIdList(
tableName, deleteFlag, oldDeleteFlag,
batchCards, invoiceTitle, settleMonth);
} catch (Exception e) {
// 3. 带重试机制
// 随机退避,避免多个事务同时重试再次冲突
try {
Thread.sleep(RANDOM.nextInt(100) + 50);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
baseMapper.updateDeleteFlagByIdList(
tableName, deleteFlag, oldDeleteFlag,
batchCards, invoiceTitle, settleMonth);
}
}
return CommonConstants.ONE_INT;
//return baseMapper.updateDeleteFlagByIdList(tableName, deleteFlag, oldDeleteFlag, cardList, invoiceTitle, settleMonth)
} }
/** /**
......
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