Commit b09acea5 authored by fangxinjiang's avatar fangxinjiang

手机号码校验调整-fxj

parent 885f6bff
......@@ -18,6 +18,7 @@ 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.constant.ChecksConstants;
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;
......@@ -25,7 +26,6 @@ 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;
......@@ -88,7 +88,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
mobileList.removeAll(existMap.keySet());
//2.从远处端获取数据
if (Common.isNotNull(mobileList)) {
mobileMapR = ChecksUtil.checkMobile(Common.ListToStr(mobileList, CommonConstants.COMMA_STRING), canCheckService.getCanCheck());
mobileMapR = checkMobileTemp(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));
......@@ -150,7 +150,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
return returnMobile;
} else {
//2.从远处端获取数据
R<Map<String, TCheckMobile>> mobileMapR = ChecksUtil.checkMobile(mobile, canCheckService.getCanCheck());
R<Map<String, TCheckMobile>> mobileMapR = checkMobileTemp(mobile, canCheckService.getCanCheck());
if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())) {
if (mobileMapR != null) {
returnMobile.setMessage(mobileMapR.getMsg());
......@@ -237,7 +237,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
}
}
synchronized (this) {
R<Map<String, TCheckMobile>> mobileMapR = ChecksUtil.checkMobile(phone, canCheck);
R<Map<String, TCheckMobile>> mobileMapR = checkMobileTemp(phone, canCheck);
if (Common.isNotNull(mobileMapR) && Common.isNotNull(mobileMapR.getData())) {
Map<String, TCheckMobile> result = mobileMapR.getData();
TCheckMobile mo = result.get(phone);
......@@ -285,7 +285,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
List<TCheckMobile> saveList = new ArrayList<>();
if (!noCurlist.isEmpty() && Common.isNotNull(phones)) {
synchronized (this) {
R<Map<String, TCheckMobile>> mobileMapR = ChecksUtil.checkMobile(phones.toString(), canCheckService.getCanCheck());
R<Map<String, TCheckMobile>> mobileMapR = checkMobileTemp(phones.toString(), canCheckService.getCanCheck());
if (Common.isNotNull(mobileMapR) && Common.isNotNull(mobileMapR.getData())) {
Map<String, TCheckMobile> result = mobileMapR.getData();
TCheckMobile mo;
......@@ -307,4 +307,60 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
}
vo.setCheckMap(backMap);
}
private R<Map<String,TCheckMobile>> checkMobileTemp(String mobiles, boolean canCheck) {
Map<String,TCheckMobile> resMap = new HashMap<>();
TCheckMobile checkMobile;
List<String> mobileList = Common.initStrToList(mobiles,CommonConstants.COMMA_STRING);
if (canCheck) {
Map<String, TCheckMobile> existMap = new HashMap<>();
if (Common.isNotNull(mobiles)) {
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)) {
for (TCheckMobile c : checkMobiles) {
if (CommonConstants.ONE_STRING.equals(c.getStatus())
|| CommonConstants.FOUR_STRING.equals(c.getStatus())
|| CommonConstants.FIVE_STRING.equals(c.getStatus())) {
c.setStatus(CommonConstants.ONE_STRING);
} else {
c.setStatus(c.getStatus());
}
c.setMessage(c.getMessage());
resMap.put(c.getMobile(), c);
}
existMap = checkMobiles.stream().collect(Collectors.toMap(TCheckMobile::getMobile, TCheckMobile -> TCheckMobile));
}
mobileList.removeAll(existMap.keySet());
if (Common.isNotEmpty(mobileList)) {
for (String mobile : mobileList) {
checkMobile = new TCheckMobile();
checkMobile.setMobile(mobile);
checkMobile.setStatus(CommonConstants.ONE_STRING);
checkMobile.setType(CommonConstants.ONE_STRING);
checkMobile.setMessage(ChecksConstants.CHECK_CONFIG_ACCESS);
resMap.put(mobile, checkMobile);
}
}
}
} else {
resMap = new HashMap<>();
if (Common.isNotNull(mobileList)) {
for (String m : mobileList) {
checkMobile = new TCheckMobile();
checkMobile.setMobile(m);
checkMobile.setStatus(CommonConstants.ONE_STRING);
checkMobile.setType(CommonConstants.ONE_STRING);
checkMobile.setMessage(ChecksConstants.CHECK_CONFIG_ACCESS);
resMap.put(m, checkMobile);
}
}
}
return R.ok(resMap);
}
}
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