Commit cd2937f7 authored by hongguangwu's avatar hongguangwu

人员档案相关-调用服务优化吧。。

parent 0f96a352
......@@ -23,7 +23,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Max;
import java.util.Date;
import java.time.LocalDate;
/**
* 员工学历信息表
......@@ -75,7 +75,7 @@ public class TEmpEducation extends BaseEntity {
* 入学时间
*/
@Schema(description = "入学时间")
private Date entryDate;
private LocalDate entryDate;
/**
* 学历名称
......@@ -88,7 +88,7 @@ public class TEmpEducation extends BaseEntity {
* 结业日期
*/
@Schema(description = "结业日期")
private Date gradutionDate;
private LocalDate gradutionDate;
/**
* 学校名称
......
......@@ -30,7 +30,6 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Set;
......@@ -63,15 +62,15 @@ public class TEmployeeInfo extends BaseEntity {
* 员工类型(字典值,0外包1派遣2代理)
*/
@Schema(description = "员工类型(字典值,0外包1派遣2代理)")
@NotNull( message = "员工类型不可为空")
@Size(max = 1, message = "员工类型不可超过1位")
@NotNull(message = "员工类型不可为空")
@Size(max = 1, message = "员工类型不可超过1位")
private String empNatrue;
/**
* 员工姓名
*/
@Schema(description = "员工姓名")
@NotNull( message = "员工姓名不可为空")
@NotNull(message = "员工姓名不可为空")
@Size(max = 20, message = "员工姓名不可超过20位")
private String empName;
......@@ -79,7 +78,7 @@ public class TEmployeeInfo extends BaseEntity {
* 身份证号码
*/
@Schema(description = "身份证号码")
@NotNull( message = "身份证号码不可为空")
@NotNull(message = "身份证号码不可为空")
@Size(max = 20, message = "身份证号码不可超过20位")
private String empIdcard;
......@@ -144,8 +143,8 @@ public class TEmployeeInfo extends BaseEntity {
* 手机号码
*/
@Schema(description = "手机号码")
@NotNull( message = "手机号码不可为空")
@Size(max = 11,min = 11, message = "手机号码只能11位")
@NotNull(message = "手机号码不可为空")
@Size(max = 11, min = 11, message = "手机号码只能11位")
private String empPhone;
/**
......@@ -218,13 +217,13 @@ public class TEmployeeInfo extends BaseEntity {
* 入学时间
*/
@Schema(description = "入学时间")
private Date admissionDate;
private LocalDate admissionDate;
/**
* 毕业时间
*/
@Schema(description = "毕业时间")
private Date gradutionDate;
private LocalDate gradutionDate;
/**
* 备注
......
......@@ -24,7 +24,6 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;
/**
* 项目档案表excel对应的实体
......@@ -190,13 +189,13 @@ public class EmployeeVO implements Serializable {
* 入学时间
*/
@ExcelProperty(value = "入学时间")
private Date admissionDate;
private LocalDate admissionDate;
/**
* 毕业时间
*/
@ExcelProperty(value = "毕业时间")
private Date gradutionDate;
private LocalDate gradutionDate;
/**
* 备注
......
......@@ -508,13 +508,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
return R.failed("该手机号已被使用!");
}
// 调用校验服务-校验手机号
R<Map<String, TCheckMobile>> checkMobileR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckmobile/inner/checkMobiles", employeeInfo.getEmpPhone(), TCheckMobile.class, SecurityConstants.FROM_IN);
R<Boolean> checkMobileR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckmobile/inner/checkOneMobile", employeeInfo.getEmpPhone(), Boolean.class, SecurityConstants.FROM_IN);
if (checkMobileR != null && checkMobileR.getData() != null) {
for (TCheckMobile checkMobile : checkMobileR.getData().values()) {
if (!CommonConstants.ONE_STRING.equals(checkMobile.getStatus())) {
return R.failed("手机号校验错误!");
}
if (Boolean.FALSE.equals(checkMobileR.getData())) {
return R.failed("手机号校验错误!");
}
}
}
......@@ -759,14 +757,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_EXIST_ERROR, existEmp.getEmpIdcard()));
}
} else {
R<Map<String, TCheckMobile>> checkMobileR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckmobile/inner/checkMobiles", excel.getEmpPhone(), TCheckMobile.class, SecurityConstants.FROM_IN);
R<Boolean> checkMobileR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckmobile/inner/checkOneMobile", excel.getEmpPhone(), Boolean.class, SecurityConstants.FROM_IN);
if (checkMobileR != null && checkMobileR.getData() != null) {
for (TCheckMobile check : checkMobileR.getData().values()) {
if (!CommonConstants.ONE_STRING.equals(check.getStatus())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_CHECK_ERROR, excel.getEmpIdcard()));
break;
}
if (Boolean.FALSE.equals(checkMobileR.getData())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_CHECK_ERROR, excel.getEmpIdcard()));
}
}
}
......@@ -1131,14 +1126,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_EXIST_ERROR, existEmp.getEmpIdcard()));
}
} else {
R<Map<String, TCheckMobile>> checkMobileR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckmobile/inner/checkMobiles", excel.getEmpPhone(), TCheckMobile.class, SecurityConstants.FROM_IN);
R<Boolean> checkMobileR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckmobile/inner/checkOneMobile", excel.getEmpPhone(), Boolean.class, SecurityConstants.FROM_IN);
if (checkMobileR != null && checkMobileR.getData() != null) {
for (TCheckMobile check : checkMobileR.getData().values()) {
if (!CommonConstants.ONE_STRING.equals(check.getStatus())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_CHECK_ERROR, excel.getEmpIdcard()));
break;
}
if (Boolean.FALSE.equals(checkMobileR.getData())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_CHECK_ERROR, excel.getEmpIdcard()));
}
}
}
......
......@@ -138,4 +138,18 @@ public class TCheckMobileController {
return tCheckMobileService.checkMobiles(mobiles);
}
/**
* @Description: 单个检测手机号
* @Author: hgw
* @Date: 2022/6/29 15:08
* @return: boolean
**/
@Operation(description = "单个检测手机号,仅支持国内号码")
@SysLog("单个检测手机号状态" )
@Inner
@GetMapping("/inner/checkOneMobile" )
public boolean checkOneMobile(String mobile) {
return tCheckMobileService.checkOneMobile(mobile);
}
}
......@@ -32,4 +32,6 @@ import java.util.Map;
public interface TCheckMobileService extends IService<TCheckMobile> {
R<Map<String,TCheckMobile>> checkMobiles(String mobiles);
boolean checkOneMobile(String mobile);
}
......@@ -52,64 +52,98 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
* @Author fxj
* @Description 号码状态校验,单次请求上限100 多一个号码请以逗号分割
* @Date 19:18 2022/6/20
**/
**/
@Override
public synchronized R<Map<String,TCheckMobile>> checkMobiles(String mobiles){
R<Map<String,TCheckMobile>> mobileMapR = null;
Map<String,TCheckMobile> checkMobileMap = null;
Map<String,TCheckMobile> existMap = new HashMap<>();
if (Common.isNotNull(mobiles)){
List<String> mobileList = Common.initStrToList(mobiles,CommonConstants.COMMA_STRING);
if (Common.isNotEmpty(mobileList) && mobileList.size() > CommonConstants.INTEGER_HUNDRED){
public synchronized R<Map<String, TCheckMobile>> checkMobiles(String mobiles) {
R<Map<String, TCheckMobile>> mobileMapR = null;
Map<String, TCheckMobile> checkMobileMap = null;
Map<String, TCheckMobile> existMap = new HashMap<>();
if (Common.isNotNull(mobiles)) {
List<String> mobileList = Common.initStrToList(mobiles, CommonConstants.COMMA_STRING);
if (Common.isNotEmpty(mobileList) && mobileList.size() > CommonConstants.INTEGER_HUNDRED) {
return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_LIMIT_HUNDRED));
}
//1.先从本地库获取正常数据
List<TCheckMobile> checkMobiles = baseMapper.selectList(Wrappers.<TCheckMobile>query().lambda()
.in(TCheckMobile::getMobile,mobileList)
.eq(TCheckMobile::getStatus,CommonConstants.ONE_STRING));
if (Common.isNotNull(checkMobiles)){
existMap = checkMobiles.stream().collect(Collectors.toMap(TCheckMobile::getMobile,TCheckMobile -> TCheckMobile));
.in(TCheckMobile::getMobile, mobileList)
.eq(TCheckMobile::getStatus, CommonConstants.ONE_STRING));
if (Common.isNotNull(checkMobiles)) {
existMap = checkMobiles.stream().collect(Collectors.toMap(TCheckMobile::getMobile, TCheckMobile -> TCheckMobile));
}
mobileList.removeAll(existMap.keySet());
//2.从远处端获取数据
if (Common.isNotNull(mobileList)){
mobileMapR = ChecksUtil.checkMobile(Common.ListToStr(mobileList,CommonConstants.COMMA_STRING),canCheckService.getCanCheck());
if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())){
if (Common.isNotNull(mobileList)) {
mobileMapR = ChecksUtil.checkMobile(Common.ListToStr(mobileList, CommonConstants.COMMA_STRING), canCheckService.getCanCheck());
if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())) {
return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR)
+(Common.isNotNull(mobileMapR)?mobileMapR.getMsg():CommonConstants.EMPTY_STRING));
+ (Common.isNotNull(mobileMapR) ? mobileMapR.getMsg() : CommonConstants.EMPTY_STRING));
}
checkMobileMap = mobileMapR.getData();
if (Common.isNotNull(mobileList) && Common.isNotNull(checkMobileMap)){
if (Common.isNotNull(mobileList) && Common.isNotNull(checkMobileMap)) {
TCheckMobile checkMobile = null;
for (String mobile:mobileList){
if (Common.isEmpty(checkMobileMap.get(mobile))){
for (String mobile : mobileList) {
if (Common.isEmpty(checkMobileMap.get(mobile))) {
checkMobile = new TCheckMobile();
checkMobile.setType(CommonConstants.ONE_STRING);
checkMobile.setMobile(mobile);
checkMobile.setStatus(CommonConstants.TEN_STRING);
checkMobile.setMessage(Common.isEmpty(mobileMapR)?MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR):mobileMapR.getMsg());
checkMobile.setMessage(Common.isEmpty(mobileMapR) ? MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR) : mobileMapR.getMsg());
checkMobile.setChargesstatus(CommonConstants.ZERO_STRING);
checkMobile.setNumbertype(CommonConstants.EMPTY_STRING);
checkMobile.setArea(CommonConstants.EMPTY_STRING);
checkMobileMap.put(mobile,checkMobile);
checkMobileMap.put(mobile, checkMobile);
}
}
}
}
}else {
} else {
return R.failed(MsgUtils.getMessage(ErrorCodes.PARAM_NOT_EMPTY));
}
if (Common.isNotNull(checkMobileMap)){
if (Common.isNotNull(checkMobileMap)) {
this.saveBatch(checkMobileMap.values());
}else {
} else {
checkMobileMap = new HashMap<>();
}
checkMobileMap.putAll(existMap);
if (Common.isEmpty(mobileMapR)){
if (Common.isEmpty(mobileMapR)) {
mobileMapR = new R<>();
}
mobileMapR.setData(checkMobileMap);
return mobileMapR;
}
@Override
public synchronized boolean checkOneMobile(String mobile) {
if (Common.isNotNull(mobile)) {
//1.先从本地库获取正常数据
List<TCheckMobile> checkMobiles = baseMapper.selectList(Wrappers.<TCheckMobile>query().lambda()
.eq(TCheckMobile::getMobile, mobile));
if (Common.isNotNull(checkMobiles)) {
for (TCheckMobile c : checkMobiles) {
if (CommonConstants.ONE_STRING.equals(c.getStatus())) {
return true;
}
}
return false;
} else {
//2.从远处端获取数据
R<Map<String, TCheckMobile>> mobileMapR = ChecksUtil.checkMobile(mobile, canCheckService.getCanCheck());
if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())) {
return false;
}
Map<String, TCheckMobile> checkMobileMap = mobileMapR.getData();
if (Common.isNotNull(checkMobileMap) && checkMobileMap.get(mobile) != null) {
TCheckMobile checkMobile = checkMobileMap.get(mobile);
this.save(checkMobile);
if (checkMobile != null && CommonConstants.ONE_STRING.equals(checkMobile.getStatus())) {
return true;
} else {
return false;
}
}
}
}
return false;
}
}
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