|
@@ -29,12 +29,10 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
import java.net.SocketTimeoutException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Calendar;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Timer;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
@@ -66,7 +64,7 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
@Value("${wz.aesDecryptKey}")
|
|
|
private String aesDecryptKey;
|
|
|
|
|
|
- private String key="urlFaceCheck";
|
|
|
+ private String key = "urlFaceCheck";
|
|
|
@Autowired
|
|
|
private CommonUtil commonUtil;
|
|
|
|
|
@@ -86,6 +84,7 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
|
|
|
@Value("${thread.delayedTime}")
|
|
|
private Long delayedTime;
|
|
|
+
|
|
|
@Override
|
|
|
public ChannelTypeHandleResponseObject callFaceCheck(HttpServletRequest request,
|
|
|
String channelId,
|
|
@@ -113,9 +112,9 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
try {
|
|
|
|
|
|
String hashKey = commonUtil.getKey();
|
|
|
- boolean flag = checkVisitCount(hashKey,key,yhProperties.getUrlFaceUp(),channelId);
|
|
|
- if(!flag){
|
|
|
- countOver(res,ifJkCode);
|
|
|
+ boolean flag = checkVisitCount(hashKey, key, yhProperties.getUrlFaceUp(), channelId);
|
|
|
+ if (!flag) {
|
|
|
+ countOver(res, ifJkCode);
|
|
|
return res;
|
|
|
}
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
@@ -126,27 +125,27 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
.writeTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
.readTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
.build();
|
|
|
- if(StringUtils.isBlank((String)map.get("name"))
|
|
|
- ||StringUtils.isBlank((String)map.get("idCode"))
|
|
|
- ||StringUtils.isBlank((String)map.get("photo"))){
|
|
|
+ if (StringUtils.isBlank((String) map.get("name"))
|
|
|
+ || StringUtils.isBlank((String) map.get("idCode"))
|
|
|
+ || StringUtils.isBlank((String) map.get("photo"))) {
|
|
|
|
|
|
res.setIsCharge(Constant.IS_NOT_CHARGE);
|
|
|
/**参数错误*/
|
|
|
- if(Constant.CUSTOMER_RETURN_JK.equals(ifJkCode)){
|
|
|
+ if (Constant.CUSTOMER_RETURN_JK.equals(ifJkCode)) {
|
|
|
res.setResultCode(Constant.JK_RETURN_CODE_9909);
|
|
|
res.setResultBody(Constant.RETURN_MESSAGE_77);
|
|
|
res.setResultDesc(Constant.RETURN_MESSAGE_77);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_77);
|
|
|
res.setResultBody(Constant.RETURN_MESSAGE_77);
|
|
|
res.setResultDesc(Constant.RETURN_MESSAGE_77);
|
|
|
}
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
return res;
|
|
|
}
|
|
|
/**参数校验*/
|
|
|
- if(!PatternTools.checkResult(Constant.PATTERN_CN_NAME_REGEX,(String)map.get("name"))){
|
|
|
- if(Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
+ if (!PatternTools.checkResult(Constant.PATTERN_CN_NAME_REGEX, (String) map.get("name"))) {
|
|
|
+ if (Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
res.setResultCode(Constant.NAME_FORMAT_ERROR_CODE);
|
|
|
res.setResultDesc(Constant.NAME_FORMAT_ERROR);
|
|
|
res.setResultBody(Constant.NAME_FORMAT_ERROR);
|
|
@@ -156,10 +155,10 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
res.setResultBody(Constant.JK_NAME_FORMAT_ERROR);
|
|
|
}
|
|
|
res.setIsCharge(Constant.IS_NOT_CHARGE);
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
return res;
|
|
|
- }else if(!PatternTools.checkResult(Constant.PATTERN_SPECIAL_ID_NUMBER_REGEX,(String)map.get("idCode"))){
|
|
|
- if(Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
+ } else if (!PatternTools.checkResult(Constant.PATTERN_SPECIAL_ID_NUMBER_REGEX, (String) map.get("idCode"))) {
|
|
|
+ if (Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
res.setResultCode(Constant.IDCODE_FORMAT_ERROR_CODE);
|
|
|
res.setResultDesc(Constant.IDCODE_FORMAT_ERROR);
|
|
|
res.setResultBody(Constant.IDCODE_FORMAT_ERROR);
|
|
@@ -168,7 +167,7 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
res.setResultDesc(Constant.JK_IDCODE_FORMAT_ERROR);
|
|
|
res.setResultBody(Constant.JK_IDCODE_FORMAT_ERROR);
|
|
|
}
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
res.setIsCharge(Constant.IS_NOT_CHARGE);
|
|
|
return res;
|
|
|
}
|
|
@@ -194,16 +193,16 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
log.info("--------------->接口返回数据为:{}", responseJson);
|
|
|
FaceCheckResObject faceCheckResObject = mapper.readValue(responseJson, FaceCheckResObject.class);
|
|
|
/**判断计费状态*/
|
|
|
- if(!check(faceCheckResObject,res,ifJkCode,channelId)){
|
|
|
+ if (!check(faceCheckResObject, res, ifJkCode, channelId)) {
|
|
|
return res;
|
|
|
}
|
|
|
boolean isCharge = Constant.FACE_RES_CODE_ZERO.equals(faceCheckResObject.getCode())
|
|
|
&& (Constant.FACE_RES_RESULT_ONE.equals(faceCheckResObject.getData().getResult())
|
|
|
- || Constant.FACE_RES_RESULT_TWO.equals(faceCheckResObject.getData().getResult())
|
|
|
- || Constant.FACE_RES_RESULT_THREE.equals(faceCheckResObject.getData().getResult())
|
|
|
- || Constant.FACE_RES_RESULT_FIVE.equals(faceCheckResObject.getData().getResult())
|
|
|
- || Constant.FACE_RES_RESULT_TEN.equals(faceCheckResObject.getData().getResult())
|
|
|
- || Constant.FACE_RES_RESULT_ELEVEN.equals(faceCheckResObject.getData().getResult()));
|
|
|
+ || Constant.FACE_RES_RESULT_TWO.equals(faceCheckResObject.getData().getResult())
|
|
|
+ || Constant.FACE_RES_RESULT_THREE.equals(faceCheckResObject.getData().getResult())
|
|
|
+ || Constant.FACE_RES_RESULT_FIVE.equals(faceCheckResObject.getData().getResult())
|
|
|
+ || Constant.FACE_RES_RESULT_TEN.equals(faceCheckResObject.getData().getResult())
|
|
|
+ || Constant.FACE_RES_RESULT_ELEVEN.equals(faceCheckResObject.getData().getResult()));
|
|
|
if (isCharge) {
|
|
|
res.setIsCharge(Constant.IS_CHARGE);
|
|
|
} else {
|
|
@@ -229,8 +228,8 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- public void switchResultCode(ObjectMapper mapper,String ifJkCode,
|
|
|
- FaceCheckResObject faceCheckResObject, ChannelTypeHandleResponseObject res) throws JsonProcessingException{
|
|
|
+ public void switchResultCode(ObjectMapper mapper, String ifJkCode,
|
|
|
+ FaceCheckResObject faceCheckResObject, ChannelTypeHandleResponseObject res) throws JsonProcessingException {
|
|
|
if (Constant.TELECOM_RES_CODE_ZERO.equals(faceCheckResObject.getCode())) {
|
|
|
JSONObject resultBody = new JSONObject();
|
|
|
resultBody.put("verificationScore", faceCheckResObject.getData().getVerificationScore());
|
|
@@ -311,37 +310,37 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
|
|
|
if (ifJkCode.equals(Constant.CUSTOMER_RETURN_ZW)) {
|
|
|
switch (res.getResultCode()) {
|
|
|
- case Constant.JK_RETURN_CODE_1143 :
|
|
|
+ case Constant.JK_RETURN_CODE_1143:
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_68);
|
|
|
break;
|
|
|
- case Constant.JK_RETURN_CODE_1144 :
|
|
|
+ case Constant.JK_RETURN_CODE_1144:
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_69);
|
|
|
break;
|
|
|
- case Constant.JK_RETURN_CODE_1145 :
|
|
|
+ case Constant.JK_RETURN_CODE_1145:
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_70);
|
|
|
break;
|
|
|
- case Constant.JK_RETURN_CODE_1146 :
|
|
|
+ case Constant.JK_RETURN_CODE_1146:
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_71);
|
|
|
break;
|
|
|
- case Constant.JK_RETURN_CODE_1147 :
|
|
|
+ case Constant.JK_RETURN_CODE_1147:
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_72);
|
|
|
break;
|
|
|
- case Constant.JK_RETURN_CODE_1148 :
|
|
|
+ case Constant.JK_RETURN_CODE_1148:
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_73);
|
|
|
break;
|
|
|
- case Constant.JK_RETURN_CODE_1149 :
|
|
|
+ case Constant.JK_RETURN_CODE_1149:
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_74);
|
|
|
break;
|
|
|
- case Constant.JK_RETURN_CODE_NO_INFO :
|
|
|
+ case Constant.JK_RETURN_CODE_NO_INFO:
|
|
|
res.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
break;
|
|
|
- case Constant.JK_NAME_FORMAT_ERROR_CODE :
|
|
|
+ case Constant.JK_NAME_FORMAT_ERROR_CODE:
|
|
|
res.setResultCode(Constant.NAME_FORMAT_ERROR_CODE);
|
|
|
break;
|
|
|
- case Constant.JK_IDCODE_FORMAT_ERROR_CODE :
|
|
|
+ case Constant.JK_IDCODE_FORMAT_ERROR_CODE:
|
|
|
res.setResultCode(Constant.IDCODE_FORMAT_ERROR_CODE);
|
|
|
break;
|
|
|
- case Constant.JK_RETURN_CODE_OTHER_ERROR :
|
|
|
+ case Constant.JK_RETURN_CODE_OTHER_ERROR:
|
|
|
res.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
break;
|
|
|
}
|
|
@@ -370,20 +369,19 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
res.setCode(Constant.SUCCESS);
|
|
|
|
|
|
|
|
|
-
|
|
|
try {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
String ymd = dateTimeFormatter.format(now);
|
|
|
String hashKey = commonUtil.getKey();
|
|
|
- boolean flag = checkVisitCount(hashKey,key,yhProperties.getUrlFaceUp(),channelId);
|
|
|
- if(!flag){
|
|
|
- countOver(res,ifJkCode);
|
|
|
+ boolean flag = checkVisitCount(hashKey, key, yhProperties.getUrlFaceUp(), channelId);
|
|
|
+ if (!flag) {
|
|
|
+ countOver(res, ifJkCode);
|
|
|
return res;
|
|
|
}
|
|
|
customBody = DecodeUtil.decodeParams(res, ifJkCode, customBody);
|
|
|
if (StringUtils.isBlank(customBody)) {
|
|
|
request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
return res;
|
|
|
}
|
|
|
Gson gson = new Gson();
|
|
@@ -393,40 +391,29 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
paramObject.put("photo", "base64");
|
|
|
log.info("supplier10000003.faceCheckWZDecode---customBody={},outTime={}", paramObject.toJSONString(), outTime);
|
|
|
|
|
|
- if (StringUtils.isNotBlank((String)map.get("name")) && ((String) map.get("name")).length() == 1) {
|
|
|
- // 姓名1个字, 增加500-700ms延时,返回身份证号与姓名不匹配
|
|
|
- delay();
|
|
|
- setErrorNameResponse(res, ifJkCode);
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
- map = null;
|
|
|
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, "-1");
|
|
|
- log.info("supplier10000003.faceCheckWZDecode---姓名格式错误");
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
request.setAttribute(Constant.CHANNEL_LOG_QUERY,
|
|
|
Base64.encodeBase64String(paramObject.toJSONString().getBytes("utf-8")));
|
|
|
|
|
|
- if(StringUtils.isBlank((String)map.get("name"))
|
|
|
- ||StringUtils.isBlank((String)map.get("idCode"))
|
|
|
- ||StringUtils.isBlank((String)map.get("photo"))){
|
|
|
+ if (StringUtils.isBlank((String) map.get("name"))
|
|
|
+ || StringUtils.isBlank((String) map.get("idCode"))
|
|
|
+ || StringUtils.isBlank((String) map.get("photo"))) {
|
|
|
res.setIsCharge(Constant.IS_NOT_CHARGE);
|
|
|
/**参数错误*/
|
|
|
- if(Constant.CUSTOMER_RETURN_JK.equals(ifJkCode)){
|
|
|
+ if (Constant.CUSTOMER_RETURN_JK.equals(ifJkCode)) {
|
|
|
res.setResultCode(Constant.JK_RETURN_CODE_9909);
|
|
|
res.setResultBody(Constant.RETURN_MESSAGE_77);
|
|
|
res.setResultDesc(Constant.RETURN_MESSAGE_77);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
res.setResultCode(Constant.ZW_RETURN_CODE_77);
|
|
|
res.setResultBody(Constant.RETURN_MESSAGE_77);
|
|
|
res.setResultDesc(Constant.RETURN_MESSAGE_77);
|
|
|
}
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
return res;
|
|
|
}
|
|
|
/**参数校验*/
|
|
|
- if(!PatternTools.checkResult(Constant.PATTERN_SPECIAL_CN_NAME_REGEX,(String)map.get("name"))){
|
|
|
- if(Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
+ if (!PatternTools.checkResult(Constant.PATTERN_SPECIAL_CN_NAME_REGEX, (String) map.get("name"))) {
|
|
|
+ if (Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
res.setResultCode(Constant.NAME_FORMAT_ERROR_CODE);
|
|
|
res.setResultDesc(Constant.NAME_FORMAT_ERROR);
|
|
|
res.setResultBody(Constant.NAME_FORMAT_ERROR);
|
|
@@ -435,11 +422,11 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
res.setResultDesc(Constant.JK_NAME_FORMAT_ERROR);
|
|
|
res.setResultBody(Constant.JK_NAME_FORMAT_ERROR);
|
|
|
}
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
res.setIsCharge(Constant.IS_NOT_CHARGE);
|
|
|
return res;
|
|
|
- }else if(!PatternTools.checkResult(Constant.PATTERN_SPECIAL_ID_NUMBER_REGEX,(String)map.get("idCode"))){
|
|
|
- if(Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
+ } else if (!PatternTools.checkResult(Constant.PATTERN_SPECIAL_ID_NUMBER_REGEX, (String) map.get("idCode"))) {
|
|
|
+ if (Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
res.setResultCode(Constant.IDCODE_FORMAT_ERROR_CODE);
|
|
|
res.setResultDesc(Constant.IDCODE_FORMAT_ERROR);
|
|
|
res.setResultBody(Constant.IDCODE_FORMAT_ERROR);
|
|
@@ -448,10 +435,22 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
res.setResultDesc(Constant.JK_IDCODE_FORMAT_ERROR);
|
|
|
res.setResultBody(Constant.JK_IDCODE_FORMAT_ERROR);
|
|
|
}
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
res.setIsCharge(Constant.IS_NOT_CHARGE);
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank((String) map.get("name")) && ((String) map.get("name")).length() == 1) {
|
|
|
+ // 姓名1个字, 增加500-700ms延时,返回身份证号与姓名不匹配
|
|
|
+ delay();
|
|
|
+ setErrorNameResponse(res, ifJkCode);
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
+ map = null;
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, "-1");
|
|
|
+ log.info("supplier10000003.faceCheckWZDecode---姓名格式错误");
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
CommonRequestObject commonRequestObject = new CommonRequestObject();
|
|
|
commonRequestObject.setUsername(yhProperties.getUsername());
|
|
|
commonRequestObject.setApiKey(yhProperties.getApiKeyY000r1());
|
|
@@ -481,7 +480,7 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
log.info("--------------->接口返回数据为:{}", responseJson);
|
|
|
FaceCheckResObject faceCheckResObject = JSONObject.toJavaObject(JSON.parseObject(responseJson), FaceCheckResObject.class);
|
|
|
|
|
|
- if(!check(faceCheckResObject,res,ifJkCode,channelId)){
|
|
|
+ if (!check(faceCheckResObject, res, ifJkCode, channelId)) {
|
|
|
return res;
|
|
|
}
|
|
|
/**判断计费状态*/
|
|
@@ -517,44 +516,46 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
- public boolean checkVisitCount(String hashKey,String key,long upCount,String channelId){
|
|
|
+
|
|
|
+ public boolean checkVisitCount(String hashKey, String key, long upCount, String channelId) {
|
|
|
//查看是否有超过权限的标志
|
|
|
/*Map map =SjjhConstant.hashMap.get(hashKey);
|
|
|
if(map!=null&&map.get(key+SjjhConstant.key_subStr)!=null && map.get(key+SjjhConstant.key_subStr).equals(Boolean.TRUE)){
|
|
|
return false;
|
|
|
}*/
|
|
|
|
|
|
- String countStr = (String)stringRedisTemplate.boundHashOps(hashKey).get(key);
|
|
|
- log.info("countStr:{}",countStr);
|
|
|
- if(countStr!=null && Long.parseLong(countStr)>=upCount){
|
|
|
+ String countStr = (String) stringRedisTemplate.boundHashOps(hashKey).get(key);
|
|
|
+ log.info("countStr:{}", countStr);
|
|
|
+ if (countStr != null && Long.parseLong(countStr) >= upCount) {
|
|
|
return false;
|
|
|
}
|
|
|
- if(stringRedisTemplate.boundHashOps(hashKey).hasKey(key+SjjhConstant.key_subStr)){
|
|
|
+ if (stringRedisTemplate.boundHashOps(hashKey).hasKey(key + SjjhConstant.key_subStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
- long visitCount = stringRedisTemplate.boundHashOps(hashKey).increment(key,1);
|
|
|
- if(visitCount==1){
|
|
|
+ long visitCount = stringRedisTemplate.boundHashOps(hashKey).increment(key, 1);
|
|
|
+ if (visitCount == 1) {
|
|
|
stringRedisTemplate.boundValueOps(hashKey).expire(1, TimeUnit.DAYS);
|
|
|
}
|
|
|
|
|
|
- if(upCount-visitCount==yhProperties.getNotityLimit()){
|
|
|
+ if (upCount - visitCount == yhProperties.getNotityLimit()) {
|
|
|
//起一个线程,处理此逻辑
|
|
|
- testNotify(channelId,1);
|
|
|
+ testNotify(channelId, 1);
|
|
|
}
|
|
|
- if(upCount-visitCount==0){
|
|
|
+ if (upCount - visitCount == 0) {
|
|
|
//起一个线程,处理此逻辑,
|
|
|
- testNotify(channelId,2);
|
|
|
+ testNotify(channelId, 2);
|
|
|
}
|
|
|
|
|
|
- if(visitCount>upCount){
|
|
|
- reduceVisitCount(hashKey,key);
|
|
|
+ if (visitCount > upCount) {
|
|
|
+ reduceVisitCount(hashKey, key);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
- public void countOver(ChannelTypeHandleResponseObject ret,String ifJkCode){
|
|
|
- if(Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
+
|
|
|
+ public void countOver(ChannelTypeHandleResponseObject ret, String ifJkCode) {
|
|
|
+ if (Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
|
|
} else {
|
|
@@ -563,27 +564,28 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
}
|
|
|
ret.setCode(Constant.REQUEST_LIMIT);
|
|
|
}
|
|
|
- public void reduceVisitCount(String hashKey,String key){
|
|
|
- long visitCount = stringRedisTemplate.boundHashOps(hashKey).increment(key,-1);
|
|
|
+
|
|
|
+ public void reduceVisitCount(String hashKey, String key) {
|
|
|
+ long visitCount = stringRedisTemplate.boundHashOps(hashKey).increment(key, -1);
|
|
|
|
|
|
}
|
|
|
|
|
|
- public boolean check(FaceCheckResObject faceCheckResObject,ChannelTypeHandleResponseObject ret,String ifJkCode,String channelId){
|
|
|
- if("210".equals(faceCheckResObject.getCode())){
|
|
|
+ public boolean check(FaceCheckResObject faceCheckResObject, ChannelTypeHandleResponseObject ret, String ifJkCode, String channelId) {
|
|
|
+ if ("210".equals(faceCheckResObject.getCode())) {
|
|
|
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
|
|
|
ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
- if(hour>=yhProperties.getHour()){
|
|
|
+ if (hour >= yhProperties.getHour()) {
|
|
|
String hashKey = commonUtil.getKey();
|
|
|
- String keySign=key+SjjhConstant.key_subStr;
|
|
|
- boolean flag = stringRedisTemplate.boundHashOps(hashKey).putIfAbsent(keySign,"1");
|
|
|
- log.info("key:{},flag:{}",keySign,flag);
|
|
|
+ String keySign = key + SjjhConstant.key_subStr;
|
|
|
+ boolean flag = stringRedisTemplate.boundHashOps(hashKey).putIfAbsent(keySign, "1");
|
|
|
+ log.info("key:{},flag:{}", keySign, flag);
|
|
|
ret.setCode(Constant.REQUEST_LIMIT);
|
|
|
- if(flag){
|
|
|
- testNotify(channelId,3);
|
|
|
+ if (flag) {
|
|
|
+ testNotify(channelId, 3);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
+ if (Constant.CUSTOMER_RETURN_ZW.equals(ifJkCode)) {
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
|
|
} else {
|
|
@@ -595,9 +597,9 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public void testNotify(String channelId,int type){
|
|
|
- String traceId= tracer.currentSpan().context().traceIdString();
|
|
|
- NotifySms notifySms =new NotifySms();
|
|
|
+ public void testNotify(String channelId, int type) {
|
|
|
+ String traceId = tracer.currentSpan().context().traceIdString();
|
|
|
+ NotifySms notifySms = new NotifySms();
|
|
|
notifySms.setSupplierProperties(yhProperties);
|
|
|
notifySms.setSmsActionInterface(smsActionInterface);
|
|
|
notifySms.setChannelActionInterface(channelActionInterface);
|
|
@@ -605,15 +607,16 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
notifySms.setTraceId(traceId);
|
|
|
notifySms.setType(type);
|
|
|
notifySms.setCount(0);
|
|
|
- Timer timer =new Timer();
|
|
|
- log.info("test..................,notify:{},traceId:{}",notifySms);
|
|
|
- timer.schedule(new NotifyThread(notifySms),1*60*1000);
|
|
|
+ Timer timer = new Timer();
|
|
|
+ log.info("test..................,notify:{},traceId:{}", notifySms);
|
|
|
+ timer.schedule(new NotifyThread(notifySms), 1 * 60 * 1000);
|
|
|
}
|
|
|
+
|
|
|
private void delay() {
|
|
|
Long startTime = System.currentTimeMillis();
|
|
|
try {
|
|
|
Future<String> delayTask = asyncDelayTask.doDelay();
|
|
|
- delayTask.get(delayedTime*2, TimeUnit.MILLISECONDS);
|
|
|
+ delayTask.get(delayedTime * 2, TimeUnit.MILLISECONDS);
|
|
|
} catch (InterruptedException ie) {
|
|
|
log.info("InterruptedException, 强制结束子线程,子线程耗时:{}, {}", System.currentTimeMillis() - startTime, ie);
|
|
|
ErrorUtils.captureException(ie);
|