|
@@ -9,6 +9,7 @@ import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.EnumUtil;
|
|
|
import cn.hutool.core.util.IdcardUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.rshy.project.hy.manager.RshyJkManager;
|
|
|
import com.rshy.project.hy.model.constant.ItfwConstant;
|
|
|
import com.rshy.project.hy.model.dto.NucleicAcidDTO;
|
|
@@ -26,16 +27,14 @@ import com.rshy.project.hy.util.ObjectUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.DependsOn;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
-import org.springframework.scheduling.annotation.AsyncResult;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.concurrent.Future;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -47,6 +46,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Component
|
|
|
@Slf4j
|
|
|
+@DependsOn("itfwServer")
|
|
|
public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
@Autowired
|
|
|
private YituFaceServer yituFaceServer;
|
|
@@ -58,12 +58,11 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
@Override
|
|
|
- @Async("hstTaskExecutor")
|
|
|
- public Future<RshyVo> getRshyInfo(RshyParam rshyParam) {
|
|
|
- // timeout 转成毫秒
|
|
|
- rshyParam.setTimeout(rshyParam.getTimeout() * 1000);
|
|
|
- //健康码最多只能用timeout入参-2秒,不然其他的接口不够
|
|
|
- int jkmTimeout = rshyParam.getTimeout() - 2000;
|
|
|
+ //@Async("hstTaskExecutor")
|
|
|
+ public RshyVo getRshyInfo(RshyParam rshyParam) {
|
|
|
+ // timeout 转成毫秒 这里考虑到网络传输延时等原因,减去200ms
|
|
|
+ rshyParam.setTimeout((int) TimeUnit.MILLISECONDS.convert(rshyParam.getTimeout(), TimeUnit.SECONDS) - 200);
|
|
|
+ int jkmTimeout = rshyParam.getTimeout();
|
|
|
RshyVo rshyVo = new RshyVo();
|
|
|
PctgkryDTO gkryDTO = new PctgkryDTO();
|
|
|
ResultDTO resultDTO = new ResultDTO();
|
|
@@ -77,36 +76,42 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
jkmInfo = itfwServer.getPctjkm(rshyParam.getBarCode(), rshyParam.getSfzh(), jkmTimeout);
|
|
|
} catch (Exception e) {
|
|
|
log.error("查询健康码信息异常:{}", e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
+ //e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
if (jkmInfo == null) {
|
|
|
- return new AsyncResult<>(rshyVo.setPassStatus(PassStatusEnum.NO_CODE).setSfzh(rshyParam.getSfzh()).setXm(rshyParam.getXm()).setWarning(PassStatusEnum.NO_CODE.getDesc())
|
|
|
- .setNucleic_acid(new NucleicAcidDTO().setStatus(NucleicAcidEnum.NO_DATA.getCode()).setResults(NucleicAcidEnum.NO_DATA.getDesc())));
|
|
|
+ return rshyVo.setPassStatus(PassStatusEnum.NO_CODE).setSfzh(rshyParam.getSfzh()).setXm(rshyParam.getXm()).setWarning(PassStatusEnum.NO_CODE.getDesc())
|
|
|
+ .setNucleic_acid(new NucleicAcidDTO().setStatus(NucleicAcidEnum.NO_DATA.getCode()).setResults(NucleicAcidEnum.NO_DATA.getDesc()));
|
|
|
}
|
|
|
|
|
|
rshyParam.setSfzh(jkmInfo.getId_num());
|
|
|
rshyVo.setSfzh(jkmInfo.getId_num()).setXm(jkmInfo.getUser_name()).setHealthCode(jkmInfo.getColor_code_label()).setPhone(jkmInfo.getPn());
|
|
|
+ int jkmElapsedTime = (int) DateUtil.between(beginDate, DateTime.now(), DateUnit.MS);
|
|
|
+ System.out.println("健康码接口用时: " + jkmElapsedTime + "毫秒");
|
|
|
|
|
|
- rshyParam.setTimeout(rshyParam.getTimeout() - (int) DateUtil.between(beginDate, DateTime.now(), DateUnit.MS) - 1000);
|
|
|
+ rshyParam.setTimeout(rshyParam.getTimeout() - jkmElapsedTime - 50);
|
|
|
+ //剩余时间不到10ms,直接返回
|
|
|
+ if (rshyParam.getTimeout() <= 10) {
|
|
|
+ return rshyVo;
|
|
|
+ }
|
|
|
|
|
|
AtomicReference<RshyVo> quickRshyVo = new AtomicReference<>(new RshyVo());
|
|
|
List<Runnable> taskList = new ArrayList<Runnable>() {
|
|
|
{
|
|
|
add(() -> resultDTO.setPctymDataDTOS(itfwServer.getPctym(rshyParam.getSfzh(), rshyParam.getTimeout())));
|
|
|
- add(() -> resultDTO.setPcthsResultDTO(itfwServer.getPcths(rshyParam.getSfzh(), rshyParam.getTimeout())));
|
|
|
- if (StrUtil.isBlank(rshyParam.getXm())) { // 刷健康码或者手动输入身份证号码
|
|
|
+ //add(() -> resultDTO.setPcthsResultDTO(itfwServer.getPcths(rshyParam.getSfzh(), rshyParam.getTimeout())));
|
|
|
+ if (StrUtil.isBlank(rshyParam.getXm())) { // 刷健康码或者手动输入身份证号码,获取证件照片
|
|
|
add(() -> resultDTO.setPctzjzpResultDTO(itfwServer.getPctzjzp(rshyParam.getSfzh(), rshyParam.getTimeout())));
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(rshyParam.getPhoto())) {
|
|
|
//add(() -> resultDTO.setPersonIdentifyDTO(viidServer.personIdentify(rshyParam.getPhoto(), rshyParam.getTimeout())));
|
|
|
- add(() -> quickRshyVo.set(getQuickRyhyInfo(new RshyQuickParam().setPhoto(rshyParam.getPhoto()).setTimeout(rshyParam.getTimeout()))));
|
|
|
+ add(() -> quickRshyVo.set(getYitu(rshyParam.getPhoto(), (rshyParam.getTimeout()))));
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
//if (rshyParam.getScreenLocked() == 0 && (barCodes == null || PassStatusEnum.GREEN_CODE.getDesc().equals(barCodes.getCOLOR_CODE_LABEL()))) {
|
|
|
- //绿码人员继续进行七大类管控接口和人车核录接口比对
|
|
|
+ //绿码人员继续进行七大类管控接口、人车核录接口、杭州市重点人员底库数据查询接口比对
|
|
|
if (PassStatusEnum.GREEN_CODE.getDesc().equals(jkmInfo.getColor_code_label())) {
|
|
|
taskList.add(() -> resultDTO.getPctgkryDTO().setPctdfkDTO(itfwServer.getPctdfk(rshyParam.getSfzh(), "", rshyParam.getTimeout())));
|
|
|
taskList.add(() -> resultDTO.getPctgkryDTO().setPctjsryDTO(itfwServer.getPctjsry(rshyParam.getSfzh(), rshyParam.getTimeout())));
|
|
@@ -116,6 +121,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
taskList.add(() -> resultDTO.getPctgkryDTO().setPctxdryDTO(itfwServer.getPctxdry(rshyParam.getSfzh(), "", rshyParam.getTimeout())));
|
|
|
taskList.add(() -> resultDTO.getPctgkryDTO().setPctzdryDTO(itfwServer.getPctzdry(rshyParam.getSfzh(), rshyParam.getTimeout())));
|
|
|
taskList.add(() -> resultDTO.setPctrchlDTO(itfwServer.getPctrchl(rshyParam.getSfzh(), rshyParam.getTimeout())));
|
|
|
+ taskList.add(() -> resultDTO.setPctzdrydkResultDTO(itfwServer.getPctzdrydk(rshyParam.getSfzh(), rshyParam.getTimeout())));
|
|
|
}
|
|
|
|
|
|
//异步流并发处理
|
|
@@ -172,14 +178,17 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
} else if (PassStatusEnum.YELLOW_CODE.getDesc().equalsIgnoreCase(jkmInfo.getColor_code_label())) {
|
|
|
//黄码
|
|
|
rshyVo.setPassStatus(PassStatusEnum.YELLOW_CODE).setKind("健康码" + PassStatusEnum.YELLOW_CODE.getDesc()).setWarning(PassStatusEnum.YELLOW_CODE.getDesc());
|
|
|
- } else if (resultDTO.getPctgkryDTO().getPctztDTO() != null || StrUtil.containsAnyIgnoreCase(hcjg, "抓捕") || StrUtil.containsAnyIgnoreCase(hcjg, "拦截")) {
|
|
|
+ } else if (resultDTO.getPctgkryDTO().getPctztDTO() != null || StrUtil.containsAnyIgnoreCase(hcjg, RchljgEnum.CAPTURE.getDesc()) || StrUtil.containsAnyIgnoreCase(hcjg, RchljgEnum.INTERCEPT.getDesc())) {
|
|
|
//在逃 或者 人车核录接口返回 抓捕或者拦截
|
|
|
rshyVo.setPassStatus(PassStatusEnum.NO_PASSING).setKind(kind(resultDTO)).setWarning(warning(resultDTO));//.setWarning("在逃人员:" + resultDTO.getPctgkryDTO().getPctztDTO().getJyaq()).setKind(resultDTO.getPctgkryDTO().getPctztDTO().getZtrylxmc());
|
|
|
//} else if (ObjectUtils.allFieldIsNULL(resultDTO.getPctgkryDTO()) || StrUtil.containsAnyIgnoreCase(hcjg, "通过")) {
|
|
|
// rshyVo.setPass(PassStatusEnum.NORMAL_TRAFFIC.getCode()).setDisplayMsg(PassStatusEnum.NORMAL_TRAFFIC.getDesc()).setTts(PassStatusEnum.NORMAL_TRAFFIC.getTts());
|
|
|
- } else if (!ObjectUtils.allFieldIsNULL(resultDTO.getPctgkryDTO()) || StrUtil.containsAnyIgnoreCase(hcjg, "存疑")) {
|
|
|
+ } else if (!ObjectUtils.allFieldIsNULL(resultDTO.getPctgkryDTO()) || StrUtil.containsAnyIgnoreCase(hcjg, RchljgEnum.IN_DOUBT.getDesc())) {
|
|
|
//七大类管控人员(在逃除外)和人车核录接口返回存疑人员
|
|
|
rshyVo.setPassStatus(PassStatusEnum.RIGHT_WAY).setKind(kind(resultDTO)).setWarning(warning(resultDTO));
|
|
|
+ } else if (resultDTO.getPctzdrydkResultDTO() != null && resultDTO.getPctzdrydkResultDTO().getTotal() > 0) {
|
|
|
+ //杭州市重点人员底库查询接口
|
|
|
+ rshyVo.setPassStatus(PassStatusEnum.RIGHT_WAY).setKind(resultDTO.getPctzdrydkResultDTO().getData().get(0).getRyflList()[0]);
|
|
|
} else if (quickRshyVo.get() != null && StrUtil.isNotEmpty(quickRshyVo.get().getSfzh())) {
|
|
|
//依图接口
|
|
|
//rshyVo = quickRshyVo.get().setTimes(times(rshyParam.getSfzh()));
|
|
@@ -196,9 +205,15 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
rshyVo.setPhoto(resultDTO.getPctzjzpResultDTO().getPhoto());
|
|
|
}
|
|
|
|
|
|
- return new AsyncResult<>(rshyVo);
|
|
|
+ //System.out.println(JSONObject.toJSONString(resultDTO));
|
|
|
+ return rshyVo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 组装返回的核酸信息
|
|
|
+ * @param pcthsResultDTO 第三方核酸接口返回数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private NucleicAcidDTO nucleicAcid(PcthsResultDTO pcthsResultDTO) {
|
|
|
NucleicAcidDTO nucleicAcidDTO = new NucleicAcidDTO();
|
|
|
if (pcthsResultDTO == null) {
|
|
@@ -233,17 +248,28 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
|
|
|
@Override
|
|
|
public RshyVo getQuickRyhyInfo(RshyQuickParam rshyQuickParam) {
|
|
|
- // timeout 转成毫秒
|
|
|
- rshyQuickParam.setTimeout(rshyQuickParam.getTimeout() * 1000);
|
|
|
+ RshyVo rshyVo = getYitu(rshyQuickParam.getPhoto(), rshyQuickParam.getTimeout() * 1000);
|
|
|
+ log.info("快速核验响应内容:{}", JSON.toJSONString(rshyVo));
|
|
|
+ return rshyVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 依图接口
|
|
|
+ *
|
|
|
+ * @param photo 人脸照片
|
|
|
+ * @param timeout 超时时间 单位ms
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private RshyVo getYitu(String photo, int timeout) {
|
|
|
RshyVo rshyVo = new RshyVo().setNucleic_acid(new NucleicAcidDTO().setStatus(NucleicAcidEnum.NO_DATA.getCode()).setResults(NucleicAcidEnum.NO_DATA.getDesc()));
|
|
|
- RetrievaResultVO retrievaResultVO = yituFaceServer.retrieval(rshyQuickParam.getPhoto(), rshyQuickParam.getTimeout());
|
|
|
+ RetrievaResultVO retrievaResultVO = yituFaceServer.retrieval(photo, timeout);
|
|
|
List<RetrievalRepositoryVO> voList = Convert.toList(RetrievalRepositoryVO.class, retrievaResultVO.getResults());
|
|
|
if (CollectionUtil.isEmpty(voList)) {
|
|
|
return rshyVo.setPass(PassStatusEnum.NORMAL_TRAFFIC.getCode()).setDisplayMsg(PassStatusEnum.NORMAL_TRAFFIC.getDesc()).setTts(PassStatusEnum.NORMAL_TRAFFIC.getTts());
|
|
|
}
|
|
|
|
|
|
//查询依图人像库信息
|
|
|
- RetrievaResultVO repository = yituFaceServer.repository(rshyQuickParam.getTimeout());
|
|
|
+ RetrievaResultVO repository = yituFaceServer.repository(timeout);
|
|
|
List<RepositoryDTO> dtoList = Convert.toList(RepositoryDTO.class, repository.getResults());
|
|
|
Map<String, String> stringMap = CollectionUtil.isNotEmpty(dtoList) ? dtoList.stream().collect(Collectors.toMap(RepositoryDTO::getId, RepositoryDTO::getName, (v1, v2) -> v1)) : MapUtil.newHashMap();
|
|
|
RetrievalRepositoryVO repositoryVO = voList.stream().findFirst().get();
|
|
@@ -252,7 +278,6 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
.setWarning(stringMap.get(repositoryVO.getRepository_id())).setDisplayMsg(RepositoryEnum.COUNTRY_LARGE.getId().equals(repositoryVO.getRepository_id()) ? PassStatusEnum.NO_PASSING.getDesc() : PassStatusEnum.RIGHT_WAY.getDesc())
|
|
|
.setTts(RepositoryEnum.COUNTRY_LARGE.getId().equals(repositoryVO.getRepository_id()) ? PassStatusEnum.NO_PASSING.getTts() : PassStatusEnum.RIGHT_WAY.getTts()).setHealthCode(StrUtil.EMPTY).setSfzh(repositoryVO.getPersonId())
|
|
|
.setXm(repositoryVO.getName()).setXb(SexEnum.codeOf(repositoryVO.getGender()).getDesc()).setMz(StrUtil.EMPTY).setPhone(StrUtil.EMPTY).setAddress(StrUtil.EMPTY);//.setPhoto(rshyQuickParam.getPhoto());
|
|
|
- //log.info("快速核验响应内容:{}", JSON.toJSONString(rshyVo));
|
|
|
return rshyVo;
|
|
|
}
|
|
|
|
|
@@ -280,7 +305,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
/**
|
|
|
* 人员类型简要概述
|
|
|
*
|
|
|
- * @param resultDTO
|
|
|
+ * @param resultDTO 所有第三方的管控人员接口返回数据
|
|
|
* @return
|
|
|
*/
|
|
|
private String kind(ResultDTO resultDTO) {
|
|
@@ -300,7 +325,7 @@ public class RshyJkManagerImpl implements RshyJkManager {
|
|
|
/**
|
|
|
* 警示信息
|
|
|
*
|
|
|
- * @param resultDTO
|
|
|
+ * @param resultDTO 所有第三方的管控人员接口返回数据
|
|
|
* @return
|
|
|
*/
|
|
|
private String warning(ResultDTO resultDTO) {
|