Ver código fonte

improve:65周岁以上预约放行不限制支持扫健康码或者刷证件

lileilei 2 anos atrás
pai
commit
8c2cedab82

+ 14 - 11
src/main/java/com/yixin/ms/service/impl/HealthCodeServiceImpl.java

@@ -4,10 +4,7 @@ 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.DesensitizedUtil;
-import cn.hutool.core.util.NumberUtil;
-import cn.hutool.core.util.RandomUtil;
-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;
@@ -49,6 +46,11 @@ import java.util.concurrent.Executor;
 @Slf4j
 @Service
 public class HealthCodeServiceImpl implements HealthCodeService {
+    /**
+     * 65周岁预约不限制通行
+     */
+    private static final int AGE = 65;
+
     @Autowired
     private RedisUtil redisUtil;
     @Autowired
@@ -61,6 +63,7 @@ public class HealthCodeServiceImpl implements HealthCodeService {
     private ScenicServer scenicServer;
     @Autowired
     private Executor executor;
+
     //顺序
 //    private static Integer index = 0;
 //    private static List<HealthMockDTO> mockDTOList = Lists.newArrayList();
@@ -202,19 +205,19 @@ public class HealthCodeServiceImpl implements HealthCodeService {
                             healthCodeVO = restResult.getData();
                         }
 
-                        if (healthCodeVO != null) {
+                        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());
                             }
-
-                            shortTermDTO.setName(verifyVO.getUserName()).setIdNumber(verifyVO.getIdNumber());
                         }
 
-                        scanIdCardResult = this.deviceScanCode(shortTermDTO);
+                        scanIdCardResult = this.deviceScanCode(shortTermDTO.setName(healthCodeVO.getUserName()).setIdNumber(healthCodeVO.getIdNum()));
                     }
                 } else {
-                    if (placeInfoVO.getScenicFlag()) {
+                    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());
@@ -344,9 +347,9 @@ public class HealthCodeServiceImpl implements HealthCodeService {
                 }
                 userVO.setOpenMsg(openMsg).setOpenVoiceMsg(openMsg);
             } else {
-                if (placeInfoVO != null && placeInfoVO.getScenicFlag()){
+                if (placeInfoVO != null && placeInfoVO.getScenicFlag()) {
                     userVO.setIsOpen(HealthOpenEnum.RELEASE.getCode()).setOpenMsg("绿码,欢迎入园").setOpenVoiceMsg("绿码,欢迎入园");
-                }else{
+                } else {
                     userVO.setIsOpen(HealthOpenEnum.RELEASE.getCode()).setOpenMsg("绿码,请通行").setOpenVoiceMsg("绿码,请通行");
                 }
             }