|
@@ -1,8 +1,10 @@
|
|
|
package com.yixin.ms.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.core.util.*;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.excel.util.CollectionUtils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -16,21 +18,19 @@ import com.yixin.ms.boot.uitls.DESUtil;
|
|
|
import com.yixin.ms.boot.uitls.OkHttpUtils;
|
|
|
import com.yixin.ms.boot.uitls.RedisUtil;
|
|
|
import com.yixin.ms.boot.uitls.SMSOrIdCardUtils;
|
|
|
+import com.yixin.ms.model.dto.HealthCodeDTO;
|
|
|
+import com.yixin.ms.model.dto.HealthMockDTO;
|
|
|
import com.yixin.ms.model.dto.ShortTermDTO;
|
|
|
-import com.yixin.ms.model.enums.HealthCodeLevelEnum;
|
|
|
-import com.yixin.ms.model.enums.HealthOpenEnum;
|
|
|
-import com.yixin.ms.model.enums.HealthVaccineNumEnum;
|
|
|
-import com.yixin.ms.model.enums.IDTypeEnum;
|
|
|
+import com.yixin.ms.model.enums.*;
|
|
|
import com.yixin.ms.model.vo.HealtCodeNucleinVO;
|
|
|
import com.yixin.ms.model.vo.HealtCodeTypeVO;
|
|
|
import com.yixin.ms.model.vo.HealtCodeUserVO;
|
|
|
+import com.yixin.ms.server.HealthCodeServer;
|
|
|
+import com.yixin.ms.server.HealthServer;
|
|
|
import com.yixin.ms.server.PlaceHealthCodeServer;
|
|
|
-import com.yixin.ms.server.dto.DeviceScanCodeDTO;
|
|
|
-import com.yixin.ms.server.dto.DeviceScanIdCardDTO;
|
|
|
-import com.yixin.ms.server.dto.PlaceRecordDTO;
|
|
|
-import com.yixin.ms.server.vo.DeviceScanIdCardVO;
|
|
|
-import com.yixin.ms.server.vo.HealthResultVO;
|
|
|
-import com.yixin.ms.server.vo.PlaceInfoVO;
|
|
|
+import com.yixin.ms.server.ScenicServer;
|
|
|
+import com.yixin.ms.server.dto.*;
|
|
|
+import com.yixin.ms.server.vo.*;
|
|
|
import com.yixin.ms.service.HealthCodeService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -46,13 +46,48 @@ import java.util.concurrent.Executor;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
+ /**
|
|
|
+ * 65周岁预约不限制通行
|
|
|
+ */
|
|
|
+ private static final int AGE = 65;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
@Autowired
|
|
|
private PlaceHealthCodeServer placeHealthCodeServer;
|
|
|
@Autowired
|
|
|
+ private HealthCodeServer healthCodeServer;
|
|
|
+ @Autowired
|
|
|
+ private HealthServer healthServer;
|
|
|
+ @Autowired
|
|
|
+ private ScenicServer scenicServer;
|
|
|
+ @Autowired
|
|
|
private Executor executor;
|
|
|
|
|
|
+ //顺序
|
|
|
+// private static Integer index = 0;
|
|
|
+// private static List<HealthMockDTO> mockDTOList = Lists.newArrayList();
|
|
|
+
|
|
|
+// static {
|
|
|
+// if (CollectionUtil.isEmpty(mockDTOList)) {
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(0).setMzt("绿码").setNucleicExpirationTime(0));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(1).setMzt("绿码").setNucleicExpirationTime(24));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(2).setMzt("绿码").setNucleicExpirationTime(48));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(3).setMzt("绿码").setNucleicExpirationTime(72));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(4).setMzt("绿码").setNucleicExpirationTime(168));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(5).setMzt("黄码").setNucleicExpirationTime(0));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(6).setMzt("黄码").setNucleicExpirationTime(24));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(7).setMzt("黄码").setNucleicExpirationTime(48));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(8).setMzt("黄码").setNucleicExpirationTime(72));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(9).setMzt("黄码").setNucleicExpirationTime(168));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(10).setMzt("红码").setNucleicExpirationTime(0));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(11).setMzt("红码").setNucleicExpirationTime(24));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(12).setMzt("红码").setNucleicExpirationTime(48));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(13).setMzt("红码").setNucleicExpirationTime(72));
|
|
|
+// mockDTOList.add(new HealthMockDTO().setIndex(14).setMzt("红码").setNucleicExpirationTime(168));
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
public HealtCodeUserVO getShortTermCertificate(ShortTermDTO shortTermDTO) {
|
|
|
try {
|
|
@@ -93,6 +128,7 @@ public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
|
|
|
@Override
|
|
|
public RestResult getShortTerm(ShortTermDTO shortTermDTO) {
|
|
|
+ log.info("健康码查询入参信息:{}", JSON.toJSONString(shortTermDTO));
|
|
|
if (StrUtil.isEmpty(shortTermDTO.getHealthCode())) {
|
|
|
if (StringUtils.isBlank(shortTermDTO.getIdNumber()) && StringUtils.isBlank(shortTermDTO.getName())) {
|
|
|
throw new ServiceException(701, "身份证和姓名为空哦");
|
|
@@ -107,21 +143,21 @@ public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
* \\000026https://h5.dingtalk.com/healthAct/index.html?stateCouncilBarCode=ffd631d12c5ee80fe77fe0fb4347b4e8&flag=1#/result
|
|
|
* 扫码参数兼容问题处理
|
|
|
*/
|
|
|
- if(StrUtil.isNotEmpty(shortTermDTO.getHealthCode()) && shortTermDTO.getHealthCode().contains("http")){
|
|
|
+ if (StrUtil.isNotEmpty(shortTermDTO.getHealthCode()) && shortTermDTO.getHealthCode().contains("http")) {
|
|
|
shortTermDTO.setHealthCode(shortTermDTO.getHealthCode().substring(shortTermDTO.getHealthCode().indexOf("http")));
|
|
|
}
|
|
|
|
|
|
- if(StrUtil.isNotEmpty(shortTermDTO.getHealthCode()) && shortTermDTO.getHealthCode().contains("HTTP")){
|
|
|
+ if (StrUtil.isNotEmpty(shortTermDTO.getHealthCode()) && shortTermDTO.getHealthCode().contains("HTTP")) {
|
|
|
shortTermDTO.setHealthCode(shortTermDTO.getHealthCode().substring(shortTermDTO.getHealthCode().indexOf("HTTP")));
|
|
|
}
|
|
|
|
|
|
- if(StrUtil.isNotEmpty(shortTermDTO.getHealthCode()) && (HttpUtil.isHttp(shortTermDTO.getHealthCode()) || HttpUtil.isHttps(shortTermDTO.getHealthCode()))){
|
|
|
+ if (StrUtil.isNotEmpty(shortTermDTO.getHealthCode()) && (HttpUtil.isHttp(shortTermDTO.getHealthCode()) || HttpUtil.isHttps(shortTermDTO.getHealthCode()))) {
|
|
|
log.info("请求健康码参数信息: {}", shortTermDTO.getHealthCode());
|
|
|
//扫码推送参数为链接,提取杭州健康码barCode参数信息
|
|
|
String barCode = HttpUtil.decodeParamMap(shortTermDTO.getHealthCode().toLowerCase(), Charset.defaultCharset()).get("statecouncilbarcode");
|
|
|
- if(StrUtil.isEmpty(barCode)){
|
|
|
+ if (StrUtil.isEmpty(barCode)) {
|
|
|
throw new ServiceException("请打开支付宝选择杭州健康码重试");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
shortTermDTO.setHealthCode(barCode);
|
|
|
}
|
|
|
}
|
|
@@ -129,9 +165,10 @@ public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
HealtCodeUserVO userVO = null;
|
|
|
//核酸有效期时间,默认0不限制
|
|
|
Integer nucleicExpirationTime = 0;
|
|
|
+ PlaceInfoVO placeInfoVO = null;
|
|
|
if (StringUtils.isNotEmpty(shortTermDTO.getSn())) {
|
|
|
RestResult<PlaceInfoVO> placeInfoResult = placeHealthCodeServer.queryPlaceInfoBySn(shortTermDTO.getSn());
|
|
|
- if (placeInfoResult != null && placeInfoResult.getData() != null){
|
|
|
+ if (placeInfoResult != null && placeInfoResult.getData() != null) {
|
|
|
nucleicExpirationTime = placeInfoResult.getData().getNucleicExpirationTime();
|
|
|
}
|
|
|
|
|
@@ -140,49 +177,54 @@ public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
}
|
|
|
|
|
|
if (placeInfoResult != null && placeInfoResult.getData() != null && StrUtil.isNotEmpty(placeInfoResult.getData().getAddressCode()) && RestCode.SUCCESS.getCode() == placeInfoResult.getCode()) {
|
|
|
- PlaceInfoVO placeInfoVO = placeInfoResult.getData();
|
|
|
+ placeInfoVO = placeInfoResult.getData();
|
|
|
HealthResultVO<DeviceScanIdCardVO> scanIdCardResult = null;
|
|
|
if (StrUtil.isNotEmpty(shortTermDTO.getHealthCode())) {
|
|
|
- //健康码查询场所码信息
|
|
|
- scanIdCardResult = placeHealthCodeServer.deviceScanCode(new DeviceScanCodeDTO().setDeviceId(shortTermDTO.getSn()).setHealthCodeQrCode(shortTermDTO.getHealthCode()).setUrlParams(shortTermDTO.getHealthCode()));
|
|
|
- //换绑场所码或者管理员健康码首次会提示设备未打卡等错误,重新发起调用
|
|
|
- if (scanIdCardResult == null || !scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.SUCCESS.getCode()))) {
|
|
|
- if (scanIdCardResult != null && scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.INVALID_TOKEN.getCode()))) {
|
|
|
- //清理token缓存
|
|
|
- placeHealthCodeServer.getToken(true);
|
|
|
- }
|
|
|
+ //非景区预约,通用健康码查询
|
|
|
+ if (!placeInfoVO.getScenicFlag()) {
|
|
|
+ scanIdCardResult = this.deviceScanCode(shortTermDTO);
|
|
|
+ }
|
|
|
|
|
|
- try {
|
|
|
- Thread.sleep(500);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ //景区预约,走预约码查询
|
|
|
+ if (placeInfoVO.getScenicFlag() && NumberUtil.isNumber(shortTermDTO.getHealthCode())) {
|
|
|
+ ScenicVerifyVO verifyVO = scenicServer.verify(new ScenicVerifyDTO().setReservationCode(shortTermDTO.getHealthCode()), placeInfoVO.getAdminId());
|
|
|
+ if (!verifyVO.getReleaseStatus()) {
|
|
|
+ throw new ServiceException(verifyVO.getMessage());
|
|
|
+ } else {
|
|
|
+ shortTermDTO.setName(verifyVO.getUserName()).setIdNumber(verifyVO.getIdNumber());
|
|
|
+ scanIdCardResult = this.deviceScanIdCardEncrypt(shortTermDTO);
|
|
|
}
|
|
|
- scanIdCardResult = placeHealthCodeServer.deviceScanCode(new DeviceScanCodeDTO().setDeviceId(shortTermDTO.getSn()).setHealthCodeQrCode(shortTermDTO.getHealthCode()).setUrlParams(shortTermDTO.getHealthCode()));
|
|
|
- }
|
|
|
- } else {
|
|
|
- DeviceScanIdCardDTO scanIdCardDTO = new DeviceScanIdCardDTO().setDeviceId(shortTermDTO.getSn()).setIdNumber(shortTermDTO.getIdNumber());
|
|
|
- if(SMSOrIdCardUtils.isIdCard(shortTermDTO.getIdNumber())){
|
|
|
- scanIdCardDTO.setIdType(IDTypeEnum.ID_CARD.getCode());
|
|
|
- }else{
|
|
|
- scanIdCardDTO.setIdType(IDTypeEnum.PASSPORT.getCode());
|
|
|
}
|
|
|
|
|
|
- //扫人员证件查询场所码信息
|
|
|
- scanIdCardResult = placeHealthCodeServer.deviceScanIdCardEncrypt(scanIdCardDTO);
|
|
|
- //换绑场所码或者管理员健康码首次会提示设备未打卡等错误,重新发起调用
|
|
|
- if (scanIdCardResult == null || !scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.SUCCESS.getCode()))) {
|
|
|
- if (scanIdCardResult != null && scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.INVALID_TOKEN.getCode()))) {
|
|
|
- //清理token缓存
|
|
|
- placeHealthCodeServer.getToken(true);
|
|
|
+ //景区预约,走健康码查询
|
|
|
+ if (placeInfoVO.getScenicFlag() && !NumberUtil.isNumber(shortTermDTO.getHealthCode())) {
|
|
|
+ RestResult<HealthCodeVO> restResult = healthServer.queryInfoByBarCode(shortTermDTO.getHealthCode());
|
|
|
+ HealthCodeVO healthCodeVO = null;
|
|
|
+
|
|
|
+ if (restResult.getCode() == RestCode.SUCCESS.getCode()) {
|
|
|
+ healthCodeVO = restResult.getData();
|
|
|
}
|
|
|
|
|
|
- try {
|
|
|
- Thread.sleep(500);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ if (healthCodeVO != null && StrUtil.isNotEmpty(healthCodeVO.getIdNum()) && IdcardUtil.getAgeByIdCard(healthCodeVO.getIdNum()) < AGE) {
|
|
|
+ //判断是否小于65周岁查询预约放行权限
|
|
|
+ ScenicVerifyVO verifyVO = scenicServer.verify(new ScenicVerifyDTO().setIdNumber(healthCodeVO.getIdNum()), placeInfoVO.getAdminId());
|
|
|
+ if (!verifyVO.getReleaseStatus()) {
|
|
|
+ throw new ServiceException(verifyVO.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ scanIdCardResult = this.deviceScanCode(shortTermDTO.setName(healthCodeVO.getUserName()).setIdNumber(healthCodeVO.getIdNum()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (placeInfoVO.getScenicFlag() && IdcardUtil.getAgeByIdCard(shortTermDTO.getIdNumber()) < AGE) {
|
|
|
+ //判断是否小于65周岁查询预约放行权限
|
|
|
+ ScenicVerifyVO verifyVO = scenicServer.verify(new ScenicVerifyDTO().setIdNumber(shortTermDTO.getIdNumber()), placeInfoVO.getAdminId());
|
|
|
+ if (!verifyVO.getReleaseStatus()) {
|
|
|
+ throw new ServiceException(verifyVO.getMessage());
|
|
|
}
|
|
|
- scanIdCardResult = placeHealthCodeServer.deviceScanIdCardEncrypt(scanIdCardDTO);
|
|
|
}
|
|
|
+
|
|
|
+ scanIdCardResult = this.deviceScanIdCardEncrypt(shortTermDTO);
|
|
|
}
|
|
|
|
|
|
if (scanIdCardResult == null || !scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.SUCCESS.getCode()))) {
|
|
@@ -193,10 +235,10 @@ public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
userVO = new HealtCodeUserVO();
|
|
|
//疫苗接种数量
|
|
|
userVO.setVaccineNum(scanIdCardVO.getVaccinated());
|
|
|
- if(StrUtil.isNotEmpty(scanIdCardVO.getCheckTime())){
|
|
|
+ if (StrUtil.isNotEmpty(scanIdCardVO.getCheckTime())) {
|
|
|
//核酸记录
|
|
|
userVO.setNuclein(Lists.newArrayList(new HealtCodeNucleinVO().setChecktime(DateUtil.parseDateTime(scanIdCardVO.getCheckTime())).setReportTime(StrUtil.isEmpty(scanIdCardVO.getReportTime()) ? null : DateUtil.parseDateTime(scanIdCardVO.getReportTime())).setResult(scanIdCardVO.getCheckResult())));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
userVO.setNuclein(Lists.newArrayList());
|
|
|
}
|
|
|
|
|
@@ -234,6 +276,10 @@ public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
userVO.setUsername(StrUtil.isEmpty(userVO.getUsername()) ? shortTermDTO.getName() : userVO.getUsername());
|
|
|
//身份证号
|
|
|
userVO.setIdNumber(StrUtil.isEmpty(userVO.getIdNumber()) ? shortTermDTO.getIdNumber() : userVO.getIdNumber());
|
|
|
+
|
|
|
+ //姓名和身份证号脱敏处理
|
|
|
+ userVO.setUsername(StrUtil.isEmpty(userVO.getUsername()) ? StrUtil.EMPTY : DesensitizedUtil.chineseName(userVO.getUsername()));
|
|
|
+ userVO.setIdNumber(StrUtil.isEmpty(userVO.getIdNumber()) ? StrUtil.EMPTY : DesensitizedUtil.idCardNum(userVO.getIdNumber(), 4, 4));
|
|
|
/**
|
|
|
* 0 未接种 对应0针
|
|
|
*
|
|
@@ -243,50 +289,182 @@ public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
*
|
|
|
* 3- 完成加强针 对应3针
|
|
|
*/
|
|
|
- if(HealthVaccineNumEnum.VACCINATION_COMPLETE.getStatus().equals(userVO.getVaccineNum())){
|
|
|
+ if (HealthVaccineNumEnum.VACCINATION_COMPLETE.getStatus().equals(userVO.getVaccineNum())) {
|
|
|
userVO.setVaccineNum(HealthVaccineNumEnum.VACCINATION_COMPLETE.getNum());
|
|
|
- }else if(HealthVaccineNumEnum.INCOMPLETE_INOCULATION.getStatus().equals(userVO.getVaccineNum())){
|
|
|
+ } else if (HealthVaccineNumEnum.INCOMPLETE_INOCULATION.getStatus().equals(userVO.getVaccineNum())) {
|
|
|
userVO.setVaccineNum(HealthVaccineNumEnum.INCOMPLETE_INOCULATION.getNum());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
userVO.setVaccineNum(userVO.getVaccineNum());
|
|
|
}
|
|
|
|
|
|
//用户健康码信息
|
|
|
HealtCodeTypeVO codeTypeVO = userVO.getData().stream().findFirst().get();
|
|
|
+ //TODO MOCK 测试 start
|
|
|
+// HealthMockDTO mockDTO = mockDTOList.get(index);
|
|
|
+// codeTypeVO.setMzt(mockDTO.getMzt());
|
|
|
+// nucleicExpirationTime = mockDTO.getNucleicExpirationTime();
|
|
|
+// index++;
|
|
|
+// if (index > 14) {
|
|
|
+// index = 0;
|
|
|
+// }
|
|
|
+ //TODO MOCK 测试 end
|
|
|
+
|
|
|
//用户核酸信息
|
|
|
List<HealtCodeNucleinVO> nucleinList = userVO.getNuclein();
|
|
|
+ if (CollectionUtil.isNotEmpty(nucleinList)) {
|
|
|
+ nucleinList.forEach(v -> v.setShowTime(v.getReportTime() == null ? v.getChecktime() : DateUtil.compare(v.getChecktime(), v.getReportTime()) > 0 ? v.getChecktime() : v.getReportTime()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (HealthCodeLevelEnum.GREEN.getDesc().equals(codeTypeVO.getMzt())) {
|
|
|
+ codeTypeVO.setContent("绿码:健康码状态为低风险").setContentColor(ColorEnum.GREEN.getValue());
|
|
|
+ userVO.setBackgroundColor(ColorEnum.GREEN.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ //核酸过期标识
|
|
|
+ boolean nucleicExpirationFlag = false;
|
|
|
/**
|
|
|
* 开门规则判定校验:红黄码,核酸有效期
|
|
|
*/
|
|
|
- if(!HealthCodeLevelEnum.GREEN.getDesc().equals(codeTypeVO.getMzt())){
|
|
|
+ if (!HealthCodeLevelEnum.GREEN.getDesc().equals(codeTypeVO.getMzt())) {
|
|
|
userVO.setIsOpen(HealthOpenEnum.NO_THOROUGHFARE.getCode());
|
|
|
- userVO.setOpenMsg(new StringBuilder().append(codeTypeVO.getMzt()).append("禁止通行").toString());
|
|
|
- }else if(nucleicExpirationTime != null && !nucleicExpirationTime.equals(0) && (CollectionUtils.isEmpty(nucleinList) || DateUtil.betweenMs(nucleinList.stream().findFirst().get().getChecktime(), DateUtil.date()) > nucleicExpirationTime * 60 * 60 * 1000)){
|
|
|
+ String openMsg = new StringBuilder().append(codeTypeVO.getMzt()).append("禁止通行").toString();
|
|
|
+ userVO.setOpenMsg(openMsg).setOpenVoiceMsg(openMsg);
|
|
|
+ if (HealthCodeLevelEnum.RED.getDesc().equals(codeTypeVO.getMzt())) {
|
|
|
+ codeTypeVO.setContent(new StringBuilder().append(codeTypeVO.getMzt()).append(":健康码状态为高风险").toString()).setContentColor(ColorEnum.RED.getValue());
|
|
|
+ userVO.setBackgroundColor(ColorEnum.RED.getValue());
|
|
|
+ } else {
|
|
|
+ codeTypeVO.setContent(new StringBuilder().append(codeTypeVO.getMzt()).append(": 健康码状态为中风险").toString()).setContentColor(ColorEnum.YELLOW.getValue());
|
|
|
+ userVO.setBackgroundColor(ColorEnum.YELLOW.getValue());
|
|
|
+ }
|
|
|
+ } else if (nucleicExpirationTime != null && !nucleicExpirationTime.equals(0) && (CollectionUtils.isEmpty(nucleinList) || DateUtil.betweenMs(nucleinList.stream().findFirst().get().getShowTime(), DateUtil.date()) > nucleicExpirationTime * 60 * 60 * 1000)) {
|
|
|
+ nucleicExpirationFlag = true;
|
|
|
userVO.setIsOpen(HealthOpenEnum.NO_THOROUGHFARE.getCode());
|
|
|
- userVO.setOpenMsg(new StringBuilder().append(nucleicExpirationTime).append("小时内无有效核酸阴性记录,禁止通行").toString());
|
|
|
- }else{
|
|
|
- userVO.setIsOpen(HealthOpenEnum.RELEASE.getCode());
|
|
|
- userVO.setOpenMsg("绿码,请通行");
|
|
|
+ String openMsg;
|
|
|
+ if (nucleicExpirationTime <= NucleicRuleEnum.SEVENTY_TWO.getValue()) {
|
|
|
+ openMsg = new StringBuilder().append(nucleicExpirationTime).append("小时内无有效核酸阴性记录,禁止通行").toString();
|
|
|
+ } else {
|
|
|
+ openMsg = new StringBuilder().append((nucleicExpirationTime / 24) + 1).append("天内无有效核酸阴性记录,禁止通行").toString();
|
|
|
+ }
|
|
|
+ userVO.setOpenMsg(openMsg).setOpenVoiceMsg(openMsg);
|
|
|
+ } else {
|
|
|
+ if (placeInfoVO != null && placeInfoVO.getScenicFlag()) {
|
|
|
+ userVO.setIsOpen(HealthOpenEnum.RELEASE.getCode()).setOpenMsg("绿码,欢迎入园").setOpenVoiceMsg("绿码,欢迎入园");
|
|
|
+ } else {
|
|
|
+ userVO.setIsOpen(HealthOpenEnum.RELEASE.getCode()).setOpenMsg("绿码,请通行").setOpenVoiceMsg("绿码,请通行");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //TODO 是否放行对接测试
|
|
|
- /*
|
|
|
- List<Integer> openList = Lists.newArrayList(0, 1);
|
|
|
- userVO.setIsOpen(openList.get(RandomUtil.randomInt(0, 2)));
|
|
|
-
|
|
|
- if(userVO.getIsOpen().equals(1)){
|
|
|
- List<String> openMsgList = Lists.newArrayList("测试文案: 核酸已过有效期,禁止通行", "测试文案: 黄码,禁止通行", "测试文案: 红码,禁止通行");
|
|
|
- userVO.setOpenMsg(openMsgList.get(RandomUtil.randomInt(0, 3)));
|
|
|
- }else{
|
|
|
- userVO.setOpenMsg("绿码,请通行");
|
|
|
- }*/
|
|
|
+ if (CollectionUtil.isNotEmpty(nucleinList)) {
|
|
|
+ HealtCodeNucleinVO nucleinVO = nucleinList.stream().findFirst().get();
|
|
|
+ nucleinVO.setTitle("核酸检测").setContentColor(nucleicExpirationFlag ? ColorEnum.YELLOW.getValue() : ColorEnum.GREEN.getValue()).setIconUrl(nucleicExpirationFlag ? NucleicStatusEnum.NOT_AVAILABLE.getUrl() : NucleicStatusEnum.NEGATIVE.getUrl());
|
|
|
+ if (nucleinVO.getReportTime() != null && DateUtil.compare(nucleinVO.getChecktime(), nucleinVO.getReportTime()) > 0) {
|
|
|
+// nucleinVO.setContent(new StringBuilder().append(NucleicRuleEnum.TWENTY_FOUR.getValue()).append("H").append(" 结果未出").toString());
|
|
|
+ nucleinVO.setContent(new StringBuilder().append("结果未出").toString());
|
|
|
+ } else {
|
|
|
+ long betweenHour = DateUtil.between(nucleinVO.getShowTime(), DateUtil.date(), DateUnit.HOUR);
|
|
|
+ if (betweenHour < NucleicRuleEnum.TWENTY_FOUR.getValue()) {
|
|
|
+ nucleinVO.setContent(new StringBuilder().append(NucleicRuleEnum.TWENTY_FOUR.getValue()).append(" ").append(nucleinVO.getResult()).toString());
|
|
|
+ } else if (betweenHour < NucleicRuleEnum.FORTY_EIGHT.getValue()) {
|
|
|
+ nucleinVO.setContent(new StringBuilder().append(NucleicRuleEnum.FORTY_EIGHT.getValue()).append(" ").append(nucleinVO.getResult()).toString());
|
|
|
+ } else if (betweenHour < NucleicRuleEnum.SEVENTY_TWO.getValue()) {
|
|
|
+ nucleinVO.setContent(new StringBuilder().append(NucleicRuleEnum.SEVENTY_TWO.getValue()).append(" ").append(nucleinVO.getResult()).toString());
|
|
|
+ } else {
|
|
|
+ nucleinVO.setContent(new StringBuilder().append(DateUtil.betweenDay(nucleinVO.getShowTime(), DateUtil.date(), false) + 1).append("天 ").append(nucleinVO.getResult()).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ userVO.setNuclein(Lists.newArrayList(new HealtCodeNucleinVO().setTitle("核酸检测").setIconUrl(NucleicStatusEnum.NOT_AVAILABLE.getUrl()).setContent("暂无").setContentColor(ColorEnum.GREEN.getValue())));
|
|
|
+ }
|
|
|
|
|
|
+ userVO.setTitle("健 康 码").setTitleColor(ColorEnum.WHITE.getValue())
|
|
|
+ //疫苗信息
|
|
|
+ .setVaccineIcoTitle("新冠疫苗").setVaccineIconUrl(HealthVaccineNumEnum.numOf(userVO.getVaccineNum()).getUrl()).setVaccineNumColor(ColorEnum.GREEN.getValue())
|
|
|
+ //行程信息
|
|
|
+ .setTravelValidationDesc(TravelValidationEnum.codeOf(userVO.getTravelValidation()).getDesc()).setTravelValidationTitle("动态行程卡").setTravelValidationIconUrl(TravelValidationEnum.codeOf(userVO.getTravelValidation()).getUrl());
|
|
|
+ final PlaceInfoVO finalPlaceInfoVO = placeInfoVO;
|
|
|
+ final HealtCodeUserVO finalUserVO = userVO;
|
|
|
+ executor.execute(() -> {
|
|
|
+ if (finalPlaceInfoVO != null && finalPlaceInfoVO.getScenicFlag() && finalUserVO.getIsOpen().equals(HealthOpenEnum.RELEASE.getCode())) {
|
|
|
+ scenicServer.consume(new ScenicConsumeDTO().setIdNumber(shortTermDTO.getIdNumber()).setReservationCode(NumberUtil.isNumber(shortTermDTO.getHealthCode()) ? shortTermDTO.getHealthCode() : StrUtil.EMPTY), finalPlaceInfoVO.getAdminId());
|
|
|
+ }
|
|
|
+ });
|
|
|
return RestResponse.ok(userVO);
|
|
|
}
|
|
|
|
|
|
throw new ServiceException(703, "未查询到此数据");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据barCode查询健康码信息
|
|
|
+ *
|
|
|
+ * @param shortTermDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private HealthResultVO<DeviceScanIdCardVO> deviceScanCode(ShortTermDTO shortTermDTO) {
|
|
|
+ //健康码查询场所码信息
|
|
|
+ HealthResultVO<DeviceScanIdCardVO> scanIdCardResult = placeHealthCodeServer.deviceScanCode(new DeviceScanCodeDTO().setDeviceId(shortTermDTO.getSn()).setHealthCodeQrCode(shortTermDTO.getHealthCode()).setUrlParams(shortTermDTO.getHealthCode()));
|
|
|
+ //换绑场所码或者管理员健康码首次会提示设备未打卡等错误,重新发起调用
|
|
|
+ if (scanIdCardResult == null || !scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.SUCCESS.getCode()))) {
|
|
|
+ if (scanIdCardResult != null && scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.INVALID_TOKEN.getCode()))) {
|
|
|
+ //清理token缓存
|
|
|
+ placeHealthCodeServer.getToken(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ Thread.sleep(500);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ scanIdCardResult = placeHealthCodeServer.deviceScanCode(new DeviceScanCodeDTO().setDeviceId(shortTermDTO.getSn()).setHealthCodeQrCode(shortTermDTO.getHealthCode()).setUrlParams(shortTermDTO.getHealthCode()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return scanIdCardResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据证件号查询健康码信息
|
|
|
+ *
|
|
|
+ * @param shortTermDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private HealthResultVO<DeviceScanIdCardVO> deviceScanIdCardEncrypt(ShortTermDTO shortTermDTO) {
|
|
|
+ DeviceScanIdCardDTO scanIdCardDTO = new DeviceScanIdCardDTO().setDeviceId(shortTermDTO.getSn()).setIdNumber(shortTermDTO.getIdNumber());
|
|
|
+ if (SMSOrIdCardUtils.isIdCard(shortTermDTO.getIdNumber())) {
|
|
|
+ scanIdCardDTO.setIdType(IDTypeEnum.ID_CARD.getCode());
|
|
|
+ } else {
|
|
|
+ scanIdCardDTO.setIdType(IDTypeEnum.PASSPORT.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ //扫人员证件查询场所码信息
|
|
|
+ HealthResultVO<DeviceScanIdCardVO> scanIdCardResult = placeHealthCodeServer.deviceScanIdCardEncrypt(scanIdCardDTO);
|
|
|
+ //换绑场所码或者管理员健康码首次会提示设备未打卡等错误,重新发起调用
|
|
|
+ if (scanIdCardResult == null || !scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.SUCCESS.getCode()))) {
|
|
|
+ if (scanIdCardResult != null && scanIdCardResult.getCode().equals(Integer.valueOf(RestCode.INVALID_TOKEN.getCode()))) {
|
|
|
+ //清理token缓存
|
|
|
+ placeHealthCodeServer.getToken(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ Thread.sleep(500);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ scanIdCardResult = placeHealthCodeServer.deviceScanIdCardEncrypt(scanIdCardDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ return scanIdCardResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RestResult<HealthCodeVO> queryInfoByBarCode(HealthCodeDTO healthCodeDTO) {
|
|
|
+ IrsTripAuthEnum authEnum = IrsTripAuthEnum.appKeyOf(healthCodeDTO.getAppKey());
|
|
|
+ if (authEnum == null || !authEnum.getAppSecret().equals(healthCodeDTO.getAppSecret())) {
|
|
|
+ return RestResponse.error("调用权限校验失败,请检查");
|
|
|
+ }
|
|
|
+
|
|
|
+ return healthCodeServer.queryInfoByBarCode(healthCodeDTO.getBarCode());
|
|
|
+ }
|
|
|
+
|
|
|
public HealtCodeUserVO getShortTermUser(String sfzh, String name) throws Exception {
|
|
|
log.info("江干分局健康码传参,身份证{} 姓名 {}", sfzh, name);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
@@ -306,6 +484,8 @@ public class HealthCodeServiceImpl implements HealthCodeService {
|
|
|
if (StringUtils.equals("00", json.getString("error_code"))) {
|
|
|
healtCodeUserVO.setData(JSON.parseArray(json.getJSONArray("data").toJSONString(), HealtCodeTypeVO.class));
|
|
|
healtCodeUserVO.setNuclein(JSON.parseArray(json.getJSONArray("nuclein").toJSONString(), HealtCodeNucleinVO.class));
|
|
|
+ //源数据只返回报告时间,检测时间先等同于报告时间,方便后面逻辑处理
|
|
|
+// healtCodeUserVO.getNuclein().forEach(v -> v.setReportTime(v.getChecktime()));
|
|
|
healtCodeUserVO.setVaccineNum(json.getString("vaccine_num"));
|
|
|
} else {
|
|
|
throw new ServiceException("江干分局异常:" + jsonObject.getString("msg"));
|