|
@@ -14,6 +14,7 @@ import info.aspirecn.iov.sjjh.service.sms.action.SmsActionInterface;
|
|
|
import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.yh.constant.SjjhConstant;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.yh.service.FaceCheckService;
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.yh.task.AsyncDelayTask;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.yh.utils.*;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.yh.vo.CommonRequestObject;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.yh.vo.FaceCheckResObject;
|
|
@@ -36,7 +37,10 @@ import java.util.Calendar;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Timer;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
+import java.util.concurrent.Future;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.TimeoutException;
|
|
|
|
|
|
/**
|
|
|
* @author jianggang
|
|
@@ -77,6 +81,11 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
private ObjectMapper objectMapper;
|
|
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
|
|
+ @Autowired
|
|
|
+ AsyncDelayTask asyncDelayTask;
|
|
|
+
|
|
|
+ @Value("${thread.delayedTime}")
|
|
|
+ private Long delayedTime;
|
|
|
@Override
|
|
|
public ChannelTypeHandleResponseObject callFaceCheck(HttpServletRequest request,
|
|
|
String channelId,
|
|
@@ -383,14 +392,21 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
JSONObject paramObject = JSON.parseObject(customBody);
|
|
|
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")));
|
|
|
|
|
|
- OkHttpClient okHttpClient = client.newBuilder()
|
|
|
- .connectTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
- .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"))){
|
|
@@ -453,6 +469,11 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
.url(yhProperties.getFaceCheckUri())
|
|
|
.post(requestBody)
|
|
|
.build();
|
|
|
+ OkHttpClient okHttpClient = client.newBuilder()
|
|
|
+ .connectTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
+ .writeTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
+ .readTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
+ .build();
|
|
|
Response response = okHttpClient.newCall(okRequest).execute();
|
|
|
String responseJson = response.body().string();
|
|
|
|
|
@@ -588,5 +609,35 @@ public class FaceCheckServiceImpl implements FaceCheckService {
|
|
|
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);
|
|
|
+ } catch (InterruptedException ie) {
|
|
|
+ log.info("InterruptedException, 强制结束子线程,子线程耗时:{}, {}", System.currentTimeMillis() - startTime, ie);
|
|
|
+ ErrorUtils.captureException(ie);
|
|
|
+ } catch (ExecutionException ee) {
|
|
|
+ log.info("ExecutionException, 强制结束子线程,子线程耗时:{}, {}", System.currentTimeMillis() - startTime, ee);
|
|
|
+ ErrorUtils.captureException(ee);
|
|
|
+ } catch (TimeoutException te) {
|
|
|
+ log.info("TimeoutException, 强制结束子线程,子线程耗时:{}, {}", System.currentTimeMillis() - startTime, te);
|
|
|
+ ErrorUtils.captureException(te);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setErrorNameResponse(ChannelTypeHandleResponseObject res, String ifJkCode) {
|
|
|
+ if (ifJkCode.equals(Constant.CUSTOMER_RETURN_ZW)) {
|
|
|
+ res.setResultCode(Constant.ZW_RETURN_CODE_71);
|
|
|
+ } else {
|
|
|
+ res.setResultCode(Constant.JK_RETURN_CODE_1146);
|
|
|
+ }
|
|
|
+ res.setIsCharge(Constant.IS_CHARGE);
|
|
|
+ res.setResultDesc(Constant.RETURN_MESSAGE_71);
|
|
|
|
|
|
+ JSONObject resultBody = new JSONObject();
|
|
|
+ resultBody.put("verificationScore", "");
|
|
|
+ resultBody.put("message", Constant.RETURN_MESSAGE_71);
|
|
|
+ res.setResultBody(JSON.toJSONString(resultBody));
|
|
|
+ }
|
|
|
}
|