Commit 2b2dc0e8 authored by hongguangwu's avatar hongguangwu

MVP1.6.6-预入职相关_新校验

parent b350bce9
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.check.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* C端预入职校验身份证与手机号限定调用表
*
* @author hgw
* @date 2024-06-27 14:33:06
*/
@Data
@TableName("t_pre_emp_check_num")
@Schema(description = "C端预入职校验身份证与手机号限定调用表")
public class TPreEmpCheckNum implements Serializable {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("主键")
@Schema(description = "主键")
private String id;
/**
* 创建日
*/
@ExcelAttribute(name = "创建日", isNotEmpty = true, errorInfo = "创建日不能为空", maxLength = 8)
@NotBlank(message = "创建日不能为空")
@Length(max = 8, message = "创建日不能超过8个字符")
@ExcelProperty("创建日")
@Schema(description = "创建日")
private String createDay;
/**
* 项目id
*/
@ExcelAttribute(name = "项目id", isNotEmpty = true, errorInfo = "项目id不能为空", maxLength = 32)
@NotBlank(message = "项目id不能为空")
@Length(max = 32, message = "项目id不能超过32个字符")
@ExcelProperty("项目id")
@Schema(description = "项目id")
private String deptId;
/**
* 当日调用API总条数
*/
@ExcelAttribute(name = "当日调用API总条数", isNotEmpty = true, errorInfo = "当日调用API总条数不能为空")
@NotBlank(message = "当日调用API总条数不能为空")
@ExcelProperty("当日调用API总条数")
@Schema(description = "当日调用API总条数")
private Integer apiNum;
/**
* 当日允许调用API总条数
*/
@ExcelAttribute(name = "当日允许调用API总条数", isNotEmpty = true, errorInfo = "当日允许调用API总条数不能为空")
@NotBlank(message = "当日允许调用API总条数不能为空")
@ExcelProperty("当日允许调用API总条数")
@Schema(description = "当日允许调用API总条数")
private Integer canApiNum;
}
......@@ -179,6 +179,19 @@ public class TCheckIdCardController {
return tCheckIdCardService.checkSalaryIdCard(checkList);
}
/**
* @Description: C端预入职校验姓名身份证
* @Author: hgw
* @Date: 2024-6-27 15:49:32
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Operation(description = "C端预入职校验姓名身份证")
@SysLog("C端预入职校验姓名身份证")
@GetMapping("/checkPreEmpIdCard")
public R<String> checkPreEmpIdCard(@RequestParam String idCard, @RequestParam String name, @RequestParam String deptId) {
return tCheckIdCardService.checkPreEmpIdCard(idCard, name, deptId);
}
/**
* @Description: 批量校验姓名身份证
* @Author: hgw
......
......@@ -184,4 +184,18 @@ public class TCheckMobileController {
public CheckBatchVo checkMobileBatchs(@RequestBody List<String> list) {
return tCheckMobileService.checkMobileBatch(list);
}
/**
* @Description: C端预入职校验手机号
* @Author: hgw
* @Date: 2024-6-27 15:49:32
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Operation(description = "C端预入职校验手机号")
@SysLog("C端预入职校验手机号")
@GetMapping("/checkPrePhone")
public R<String> checkPrePhone(@RequestParam String phone, @RequestParam String deptId) {
return tCheckMobileService.checkPrePhone(phone, deptId);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.check.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.check.entity.TPreEmpCheckNum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* C端预入职校验身份证与手机号限定调用表
*
* @author hgw
* @date 2024-06-27 14:33:06
*/
@Mapper
public interface TPreEmpCheckNumMapper extends BaseMapper<TPreEmpCheckNum> {
/**
* C端预入职校验身份证与手机号限定调用表简单查询
* @return
*/
TPreEmpCheckNum getTPreEmpCheckNum(@Param("deptId") String deptId, @Param("createDay") String createDay);
}
......@@ -48,4 +48,12 @@ public interface TCheckIdCardService extends IService<TCheckIdCard> {
TCheckIdCard checkIdCardSingle(TCheckIdCard tCheckIdCard);
R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList);
/**
* @Description: C端预入职校验
* @Author: hgw
* @Date: 2024/6/27 14:29
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.check.entity.TCheckIdCard>
**/
R<String> checkPreEmpIdCard(String idCard, String name, String deptId);
}
......@@ -44,4 +44,13 @@ public interface TCheckMobileService extends IService<TCheckMobile> {
* @return: com.yifu.cloud.plus.v1.check.vo.CheckBatchVo
**/
CheckBatchVo checkMobileBatch(List<String> list);
/**
* @Description: C端预入职校验手机号使用,其他慎用
* @Author: hgw
* @Date: 2024/6/27 16:04
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<String> checkPrePhone(String phone, String deptId);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.check.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.check.entity.TPreEmpCheckNum;
/**
* C端预入职校验身份证与手机号限定调用表
*
* @author hgw
* @date 2024-06-27 14:33:06
*/
public interface TPreEmpCheckNumService extends IService<TPreEmpCheckNum> {
/**
* C端预入职校验身份证与手机号限定调用表简单分页查询
*
* @return
*/
TPreEmpCheckNum getTPreEmpCheckNum(String deptId, String createDay);
}
......@@ -4,15 +4,9 @@ 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;
import com.yifu.cloud.plus.v1.check.entity.*;
import com.yifu.cloud.plus.v1.check.mapper.TCheckIdCardMapper;
import com.yifu.cloud.plus.v1.check.service.TCanCheckService;
import com.yifu.cloud.plus.v1.check.service.TCheckApiNumService;
import com.yifu.cloud.plus.v1.check.service.TCheckIdCardService;
import com.yifu.cloud.plus.v1.check.service.TCheckLockService;
import com.yifu.cloud.plus.v1.check.service.*;
import com.yifu.cloud.plus.v1.check.utils.ChecksUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
......@@ -43,6 +37,7 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
private final TCheckLockService tCheckLockService;
private final TCheckApiNumService tCheckApiNumService;
private final TPreEmpCheckNumService tPreEmpCheckNumService;
private final TCanCheckService canCheckService;
......@@ -326,6 +321,112 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
return returnMap;
}
@Override
public R<String> checkPreEmpIdCard(String idCard, String name, String deptId) {
TCanCheck tCanCheck= canCheckService.getById(1);
boolean canCheck = false;
String nowDay = DateUtil.getThisDay();
if (tCanCheck != null && tCanCheck.getCanCheck() == 1) {
canCheck = true;
TPreEmpCheckNum nowDayNum = tPreEmpCheckNumService.getTPreEmpCheckNum(deptId, nowDay);
if (nowDayNum == null) {
nowDayNum = new TPreEmpCheckNum();
nowDayNum.setCanApiNum(1000);
nowDayNum.setApiNum(1);
tPreEmpCheckNumService.save(nowDayNum);
} else {
if (nowDayNum.getApiNum() >= nowDayNum.getCanApiNum()) {
return R.failed("该项目当日总条数:" + nowDayNum.getCanApiNum() + "已到达上限!");
} else {
nowDayNum.setApiNum(nowDayNum.getApiNum() + 1);
tPreEmpCheckNumService.updateById(nowDayNum);
}
}
}
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() + "已到达上限!");
}
int canApiNum = nowMonthNum.getCanApiNum();
List<String> idCardList = new ArrayList<>();
idCardList.add(idCard);
// 全部(身份证_姓名)
Map<String, TCheckIdCard> returnMap = this.getAllMapByList(idCardList);
// 正确的身份证
Map<String, TCheckIdCard> trueMap = this.getTrueMapByList(idCardList);
TCheckIdCard nowIdCard;
String userId = "1";
try {
if (Common.isNotNull(idCard) && Common.isNotNull(name)) {
nowIdCard = returnMap.get(idCard + CommonConstants.DOWN_LINE_STRING + name);
if (nowIdCard != null && Common.isNotNull(nowIdCard.getIsTrue())) {
if (CommonConstants.ONE_INT == nowIdCard.getIsTrue()) {
return R.ok();
} else {
return R.failed(nowIdCard.getReason());
}
} else {
// 调用对的身份证信息
nowIdCard = trueMap.get(idCard);
if (nowIdCard != null) {
if (nowIdCard.getName().equals(name)) {
return R.ok();
} else {
return R.failed("姓名错误!!");
}
} else {
// 校验姓名身份证规则
if (!regIdCard(idCard)) {
return R.failed("身份证格式有误");
} else if (regEmpName(name)) {
return R.failed("姓名含数字或空格,无法校验");
} else {
// 调用API校验
if (nowApiNum < canApiNum) {
TCheckIdCard c = new TCheckIdCard();
c.setName(name);
c.setIdCard(idCard);
// 安全调用:
this.doSafetyApi(c, canCheck, userId);
if (CommonConstants.ONE_INT == c.getIsTrue()) {
return R.ok();
} else {
return R.failed(c.getReason());
}
} else {
return R.failed("调用创蓝的Api的条数已达上限:" + canApiNum + ",请联系管理员处理!");
}
}
}
}
} else {
return R.failed("姓名身份证不可为空!");
}
} catch (Exception e) {
returnMap.clear();
trueMap.clear();
throw new RuntimeException(e.getMessage() == null ? "校验身份证失败!" : "校验身份证失败:" + e.getMessage());
} finally {
returnMap.clear();
trueMap.clear();
}
}
@Override
public R<List<TCheckIdCard>> checkSalaryIdCard(List<TCheckIdCard> checkList) {
TCanCheck tCanCheck= canCheckService.getById(1);
......
......@@ -18,15 +18,19 @@ package com.yifu.cloud.plus.v1.check.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.TCheckMobile;
import com.yifu.cloud.plus.v1.check.entity.TPreEmpCheckNum;
import com.yifu.cloud.plus.v1.check.mapper.TCheckMobileMapper;
import com.yifu.cloud.plus.v1.check.service.TCanCheckService;
import com.yifu.cloud.plus.v1.check.service.TCheckMobileService;
import com.yifu.cloud.plus.v1.check.service.TPreEmpCheckNumService;
import com.yifu.cloud.plus.v1.check.utils.ChecksUtil;
import com.yifu.cloud.plus.v1.check.vo.CheckBatchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
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.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.RequiredArgsConstructor;
......@@ -49,6 +53,7 @@ import java.util.stream.Collectors;
public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCheckMobile> implements TCheckMobileService {
private final TCanCheckService canCheckService;
private final TPreEmpCheckNumService tPreEmpCheckNumService;
/**
* @Author fxj 待完善
......@@ -199,6 +204,65 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
checkMobiles(tempList, vo, noMap, noCurlist, backMap);
return vo;
}
@Override
public R<String> checkPrePhone(String phone, String deptId) {
TCanCheck tCanCheck= canCheckService.getById(1);
boolean canCheck = false;
String nowDay = DateUtil.getThisDay();
if (tCanCheck != null && tCanCheck.getCanCheck() == 1) {
canCheck = true;
TPreEmpCheckNum nowDayNum = tPreEmpCheckNumService.getTPreEmpCheckNum(deptId, nowDay);
if (nowDayNum == null) {
nowDayNum = new TPreEmpCheckNum();
nowDayNum.setCanApiNum(1000);
nowDayNum.setApiNum(1);
tPreEmpCheckNumService.save(nowDayNum);
} else {
if (nowDayNum.getApiNum() >= nowDayNum.getCanApiNum()) {
return R.failed("该项目当日总条数:" + nowDayNum.getCanApiNum() + "已到达上限!");
} else {
nowDayNum.setApiNum(nowDayNum.getApiNum() + 1);
tPreEmpCheckNumService.updateById(nowDayNum);
}
}
}
CheckBatchVo vo = new CheckBatchVo();
Map<String, Boolean> noMap = new HashMap<>();
List<String> noList = new ArrayList<>();
noList.add(phone);
List<TCheckMobile> checkMobileList = baseMapper.getListByNoList(noList);
if (checkMobileList != null && !checkMobileList.isEmpty()) {
for (TCheckMobile no : checkMobileList) {
noMap.put(no.getMobile(), CommonConstants.ONE_STRING.equals(no.getStatus())
|| CommonConstants.FOUR_STRING.equals(no.getStatus())
|| CommonConstants.FIVE_STRING.equals(no.getStatus()));
}
}
List<String> tempList = new ArrayList<>();
// 因手机号码最多50个所以这里 要特殊处理下
tempList.add(phone);
synchronized (this) {
R<Map<String, TCheckMobile>> mobileMapR = ChecksUtil.checkMobile(phone, canCheck);
if (Common.isNotNull(mobileMapR) && Common.isNotNull(mobileMapR.getData())) {
Map<String, TCheckMobile> result = mobileMapR.getData();
TCheckMobile mo = result.get(phone);
if (mo != null) {
this.saveOrUpdate(mo);
if (Common.isNotNull(mo.getStatus()) &&
(CommonConstants.ONE_STRING.equals(mo.getStatus())
|| CommonConstants.FOUR_STRING.equals(mo.getStatus())
|| CommonConstants.FIVE_STRING.equals(mo.getStatus()))) {
return R.ok();
} else {
return R.failed(Common.isNotNull(mo.getMessage()) ? mo.getMessage() : "校验错误!");
}
} else {
return R.failed("校验失败");
}
}
}
return R.failed("校验失败!");
}
private void checkMobiles(List<String> list,
CheckBatchVo vo,
......
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.check.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TPreEmpCheckNum;
import com.yifu.cloud.plus.v1.check.mapper.TPreEmpCheckNumMapper;
import com.yifu.cloud.plus.v1.check.service.TPreEmpCheckNumService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
/**
* C端预入职校验身份证与手机号限定调用表
*
* @author hgw
* @date 2024-06-27 14:33:06
*/
@Log4j2
@Service
public class TPreEmpCheckNumServiceImpl extends ServiceImpl<TPreEmpCheckNumMapper, TPreEmpCheckNum> implements TPreEmpCheckNumService {
/**
* C端预入职校验身份证与手机号限定调用表简单分页查询
*
* @return
*/
@Override
public TPreEmpCheckNum getTPreEmpCheckNum(String deptId, String createDay) {
return baseMapper.getTPreEmpCheckNum(deptId, createDay);
}
}
......@@ -27,6 +27,22 @@ mybatis-plus:
configuration:
map-underscore-to-camel-case: true
# spring security 配置
security:
#client:
# client-id: pig
# client-secret: pig
# scope: server
oauth2:
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
ignore: # 通用放行URL,服务个性化,请在对应配置文件覆盖
urls:
- /tcheckidcard/checkPreEmpIdCard
- /tcheckmobile/checkPrePhone
spring:
application:
name: @artifactId@
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.check.mapper.TPreEmpCheckNumMapper">
<resultMap id="tPreEmpCheckNumMap" type="com.yifu.cloud.plus.v1.check.entity.TPreEmpCheckNum">
<id property="id" column="ID"/>
<result property="createDay" column="CREATE_DAY"/>
<result property="deptId" column="DEPT_ID"/>
<result property="apiNum" column="API_NUM"/>
<result property="canApiNum" column="CAN_API_NUM"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.CREATE_DAY,
a.DEPT_ID,
a.API_NUM,
a.CAN_API_NUM
</sql>
<!--tPreEmpCheckNum简单分页查询-->
<select id="getTPreEmpCheckNum" resultMap="tPreEmpCheckNumMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_pre_emp_check_num a
where a.DEPT_ID = #{deptId} and a.CREATE_DAY = #{createDay} limit 1
</select>
</mapper>
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