Commit 3921a5f4 authored by hongguangwu's avatar hongguangwu

找回代码

parent 54abfff3
......@@ -162,4 +162,18 @@ public class TCheckIdCardController {
public TCheckIdCard checkIdCardSingle(@RequestBody TCheckIdCard tCheckIdCard) {
return tCheckIdCardService.checkIdCardSingle(tCheckIdCard);
}
/**
* @param checkList
* @Description: 校验姓名身份证
* @Author: hgw
* @Date: 2022-6-27 16:23:37
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Operation(description = "校验薪资姓名身份证")
@SysLog("校验薪资姓名身份证")
@PostMapping("/checkSalaryIdCard")
public R<List<TCheckIdCard>> checkSalaryIdCard(@RequestBody List<TCheckIdCard> checkList) {
return tCheckIdCardService.checkSalaryIdCard(checkList);
}
}
......@@ -34,5 +34,22 @@ public interface TCheckIdCardMapper extends BaseMapper<TCheckIdCard> {
**/
List<TCheckIdCard> getAllList(@Param("tCheckIdCard") TCheckIdCard tCheckIdCard);
/**
* @param idCardList
* @Description: 获取身份证的缓存
* @Author: hgw
* @Date: 2022/7/7 16:00
* @return: java.util.List<com.yifu.cloud.v1.checks.api.entity.TCheckIdCard>
**/
List<TCheckIdCard> getAllListByList(@Param("idCardList") List<String> idCardList);
/**
* @param idCardList
* @Description: 获取正确的身份证的缓存
* @Author: hgw
* @Date: 2022/7/7 16:00
* @return: java.util.List<com.yifu.cloud.v1.checks.api.entity.TCheckIdCard>
**/
List<TCheckIdCard> getTrueListByList(@Param("idCardList") List<String> idCardList);
}
......@@ -3,6 +3,7 @@ package com.yifu.cloud.plus.v1.check.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.check.entity.TCheckLock;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -23,4 +24,6 @@ public interface TCheckLockMapper extends BaseMapper<TCheckLock> {
**/
List<TCheckLock> getAllList();
int getApiNumByMonth(@Param("nowMonth") String nowMonth);
}
......@@ -46,4 +46,6 @@ public interface TCheckIdCardService extends IService<TCheckIdCard> {
R<List<TCheckIdCard>> checkIdCard(List<TCheckIdCard> checkList);
TCheckIdCard checkIdCardSingle(TCheckIdCard tCheckIdCard);
R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList);
}
......@@ -18,4 +18,6 @@ public interface TCheckLockService extends IService<TCheckLock> {
*/
List<TCheckLock> getAllList();
int getApiNumByMonth(String nowMonth);
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TCanCheck;
import com.yifu.cloud.plus.v1.check.entity.TCheckApiNum;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.entity.TCheckLock;
......@@ -23,6 +24,7 @@ import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -283,4 +285,239 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
}
}
private Map<String, TCheckIdCard> getAllMapByList(List<String> idCardList) {
Map<String, TCheckIdCard> returnMap = new HashMap<>();
if (idCardList != null && !idCardList.isEmpty()) {
List<TCheckIdCard> list = baseMapper.getAllListByList(idCardList);
if (list != null && !list.isEmpty()) {
for (TCheckIdCard c : list) {
returnMap.put(c.getIdCard() + CommonConstants.DOWN_LINE_STRING + c.getName(), c);
}
}
}
return returnMap;
}
private Map<String, TCheckIdCard> getTrueMap(TCheckIdCard tCheckIdCard) {
if (tCheckIdCard == null) {
tCheckIdCard = new TCheckIdCard();
}
tCheckIdCard.setIsTrue(CommonConstants.ONE_INT);
List<TCheckIdCard> list = baseMapper.getAllList(tCheckIdCard);
Map<String, TCheckIdCard> returnMap = new HashMap<>();
if (list != null && !list.isEmpty()) {
for (TCheckIdCard c : list) {
returnMap.put(c.getIdCard(), c);
}
}
return returnMap;
}
private Map<String, TCheckIdCard> getTrueMapByList(List<String> idCardList) {
Map<String, TCheckIdCard> returnMap = new HashMap<>();
if (idCardList != null && !idCardList.isEmpty()) {
List<TCheckIdCard> list = baseMapper.getTrueListByList(idCardList);
if (list != null && !list.isEmpty()) {
for (TCheckIdCard c : list) {
returnMap.put(c.getIdCard(), c);
}
}
}
return returnMap;
}
@Override
public R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList) {
TCanCheck tCanCheck= canCheckService.getById(1);
boolean canCheck = false;
if (tCanCheck != null && tCanCheck.getCanCheck() == 1) {
canCheck = true;
}
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed("请登录!");
}
String nowMonth = DateUtil.addMonth(0);
TCheckApiNum nowMonthNum = tCheckApiNumService.getById(nowMonth);
int nowApiNum = tCheckLockService.getApiNumByMonth(nowMonth);
if (nowMonthNum == null) {
TCheckApiNum lastMonth = tCheckApiNumService.getById(DateUtil.addMonth(-1));
int canApiNum = 10000;
if (lastMonth != null && lastMonth.getCanApiNum() != null) {
canApiNum = lastMonth.getCanApiNum();
}
nowMonthNum = new TCheckApiNum();
nowMonthNum.setId(nowMonth);
nowMonthNum.setCanApiNum(canApiNum);
nowMonthNum.setApiNum(0);
tCheckApiNumService.save(nowMonthNum);
} else if (nowApiNum >= nowMonthNum.getCanApiNum()) {
return R.failed("当月总条数:" + nowMonthNum.getCanApiNum() + "已到达上限!");
}
if (checkList != null && !checkList.isEmpty()) {
TCheckLock lock = new TCheckLock();
lock.setImportNum(checkList.size());
lock.setApiNum(0);
lock.setCreateMonth(nowMonth);
lock.setCreateTime(LocalDateTime.now());
lock.setCreateUser(user.getId());
lock.setDeleteFlag(0);
lock.setCreateUserName(user.getNickname());
tCheckLockService.save(lock);
int canApiNum = nowMonthNum.getCanApiNum();
List<String> idCardList = new ArrayList<>();
for (TCheckIdCard card: checkList) {
if (card.getIdCard() != null) {
idCardList.add(card.getIdCard());
}
}
// 全部(身份证_姓名)
Map<String, TCheckIdCard> returnMap = this.getAllMapByList(idCardList);
// 正确的身份证
Map<String, TCheckIdCard> trueMap = this.getTrueMapByList(idCardList);
TCheckIdCard nowIdCard;
TCheckIdCard lastCard;
Map<String, TCheckIdCard> idCardMap = new HashMap<>();
String userId = String.valueOf(user.getId());
TCheckLock lockUpdate;
int apiNum = 0;
// 有一个错误,就不传200给前端
boolean isTrue = true;
try {
for (TCheckIdCard c : checkList) {
if (Common.isNotNull(c.getIdCard()) && Common.isNotNull(c.getName())) {
lastCard = idCardMap.get(c.getIdCard());
if (lastCard != null) {
c.setIsTrue(lastCard.getIsTrue());
c.setReason(lastCard.getReason());
} else {
// 校验姓名身份证规则
if (!regIdCard(c.getIdCard())) {
c.setIsTrue(0);
c.setReason("身份证格式有误");
} else if (regEmpName(c.getName())) {
c.setIsTrue(0);
c.setReason("姓名含数字或空格,无法校验");
} else {
nowIdCard = returnMap.get(c.getIdCard() + CommonConstants.DOWN_LINE_STRING + c.getName());
if (nowIdCard != null) {
c.setIsTrue(nowIdCard.getIsTrue());
c.setReason(nowIdCard.getReason());
} else {
// 调用对的身份证信息
nowIdCard = trueMap.get(c.getIdCard());
if (nowIdCard != null) {
if (nowIdCard.getName().equals(c.getName())) {
c.setIsTrue(nowIdCard.getIsTrue());
c.setReason(nowIdCard.getReason());
} else {
c.setIsTrue(CommonConstants.ZERO_INT);
c.setReason("姓名错误!");
}
} else {
// 调用API校验
if (nowApiNum < canApiNum) {
nowApiNum++;
apiNum++;
// 安全调用:
this.doSafetyApi(c, canCheck, userId);
returnMap.put(c.getIdCard() + CommonConstants.DOWN_LINE_STRING + c.getName(), c);
} else {
c.setIsTrue(0);
c.setReason("调用花钱的Api的条数已达上限:" + canApiNum + ",请联系管理员处理!");
}
}
}
}
// 将同身份证的结果存储下来备用,防止撞库
idCardMap.put(c.getIdCard(), c);
}
} else {
c.setIsTrue(0);
c.setReason("姓名身份证不可为空");
}
if (isTrue && c.getIsTrue() == 0) {
isTrue = false;
}
}
} catch (Exception e) {
returnMap.clear();
trueMap.clear();
lockUpdate = new TCheckLock();
lockUpdate.setId(lock.getId());
lockUpdate.setDeleteFlag(CommonConstants.ONE_INT);
lockUpdate.setApiNum(apiNum);
tCheckLockService.updateById(lockUpdate);
throw new RuntimeException(e.getMessage() == null ? "校验身份证导入失败!" : "校验身份证导入失败:" + e.getMessage());
} finally {
returnMap.clear();
trueMap.clear();
lockUpdate = new TCheckLock();
lockUpdate.setId(lock.getId());
lockUpdate.setDeleteFlag(CommonConstants.ONE_INT);
lockUpdate.setDeleteFlag(CommonConstants.ONE_INT);
lockUpdate.setApiNum(apiNum);
tCheckLockService.updateById(lockUpdate);
}
if (isTrue) {
return R.ok();
} else {
return new R<>(CommonConstants.ONE_INT, "身份证姓名校验不通过!", checkList);
}
}
return R.failed("数据为空!");
}
/**
* @Description: 多线程调用api,每次调用前查询一下数据库:
* @Author: hgw
* @Date: 2022/6/27 17:09
* @return: void
**/
private void doSafetyApi(TCheckIdCard c, boolean canCheck, String userId) {
TCheckIdCard check = new TCheckIdCard();
check.setIdCard(c.getIdCard());
Map<String, TCheckIdCard> checkMap = this.getAllMap(check);
if (checkMap == null || checkMap.isEmpty()) {
// 调用对的身份证信息
Map<String, TCheckIdCard> trueMap = this.getTrueMap(check);
check = trueMap.get(c.getIdCard());
if (check != null) {
if (check.getName().equals(c.getName())) {
c.setIsTrue(check.getIsTrue());
c.setReason(check.getReason());
} else {
c.setIsTrue(CommonConstants.ZERO_INT);
c.setReason("姓名错误!");
}
} else {
// 调用花钱的
this.moneyCheck(c, canCheck, userId);
}
} else {
check = checkMap.get(c.getIdCard() + CommonConstants.DOWN_LINE_STRING + c.getName());
if (check != null) {
c.setIsTrue(check.getIsTrue());
c.setReason(check.getReason());
} else {
// 调用花钱的
this.moneyCheck(c, canCheck, userId);
}
}
}
// 调用花钱的
private void moneyCheck(TCheckIdCard c, boolean canCheck, String userId) {
// 调用花钱的
ChecksUtil.checkIdCard(c, canCheck);
c.setCreateUser(userId);
c.setCreateTime(LocalDateTime.now());
c.setType(CommonConstants.ONE_INT);
this.save(c);
}
}
......@@ -22,4 +22,9 @@ public class TCheckLockServiceImpl extends ServiceImpl<TCheckLockMapper, TCheckL
return baseMapper.getAllList();
}
@Override
public int getApiNumByMonth(String nowMonth) {
return baseMapper.getApiNumByMonth(nowMonth);
}
}
......@@ -60,4 +60,26 @@
order by a.CREATE_TIME desc
</select>
<select id="getAllListByList" resultMap="tCheckIdCardMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_check_id_card a
where a.id_card in
<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
#{item}
</foreach>
order by a.CREATE_TIME desc
</select>
<select id="getTrueListByList" resultMap="tCheckIdCardMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_check_id_card a
where a.is_true = 1 and a.id_card in
<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
#{item}
</foreach>
order by a.CREATE_TIME desc
</select>
</mapper>
......@@ -30,4 +30,9 @@
where a.DELETE_FLAG = 0
</select>
<!--获取所有数据-->
<select id="getApiNumByMonth" resultType="java.lang.Integer">
select ifnull(sum(c.API_NUM),0) apiNum from t_check_lock c where c.CREATE_MONTH = #{nowMonth}
</select>
</mapper>
......@@ -19,9 +19,16 @@ package com.yifu.cloud.plus.v1.yifu.salary.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TApprovalRecord;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandard;
import com.yifu.cloud.plus.v1.yifu.salary.service.TApprovalRecordService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardSearchVo;
import io.swagger.v3.oas.annotations.Operation;
......@@ -31,6 +38,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -47,6 +56,7 @@ public class TSalaryStandardController {
private final TSalaryStandardService tSalaryStandardService;
private final TApprovalRecordService auditLogService;
/**
* 简单分页查询
......@@ -141,4 +151,34 @@ public class TSalaryStandardController {
@RequestParam String id) {
return tSalaryStandardService.salaryStandardAudit(auditFlag, AuditRemark, id);
}
/**
* 保存并提交
* @return
*/
@Operation(description = "保存并提交")
@PostMapping("/doSubmit")
public R salaryStandardAudit(@RequestBody TSalaryStandard tSalaryStandard) {
if (tSalaryStandard != null && Common.isNotNull(tSalaryStandard.getId())) {
YifuUser user = SecurityUtils.getUser();
if (user != null) {
TApprovalRecord tApprovalRecord = new TApprovalRecord();
tApprovalRecord.setApprovalResult(CommonConstants.TWO_STRING);
tApprovalRecord.setApprovalOpinion("提交审核");
tApprovalRecord.setSalaryId(tSalaryStandard.getId());
tApprovalRecord.setNodeId("提交审核");
tApprovalRecord.setApprovalMan(user.getId());
tApprovalRecord.setApprovalManName(user.getNickname());
tApprovalRecord.setApprovalTime(DateUtil.getCurrentDateTime());
auditLogService.save(tApprovalRecord);
tSalaryStandard.setSubmitTime(new Date());
tSalaryStandardService.updateById(tSalaryStandard);
return R.ok("提交成功!");
} else {
return R.failed("请登录!");
}
} else {
return R.failed("请传参!");
}
}
}
......@@ -89,7 +89,7 @@ public interface TForecastLibraryService extends IService<TForecastLibrary> {
R<String> updateForecastLibaryByDispatchReduce(TSocialFundInfo socialFundInfo, int forecastFlag);
/**
* @Description: 基数变更,同步社保公积金查询、预估库
* @Description: 户调基-基数变更,同步社保公积金查询、预估库
* @Author: hgw
* @Date: 2022/7/26 19:09
* @return: void
......
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