Browse Source

识别代码修改

wks 2 years ago
parent
commit
c1d3c1c7c3

+ 12 - 6
src/main/java/com/ydtech/modules/order/service/impl/IdentifyServiceImpl.java

@@ -53,11 +53,12 @@ public class IdentifyServiceImpl implements IdentifyService {
             String s1Key = IMAGE_IDENTIFY_KEY + "idCard:" + "front:" + s1MD5;
             if (StringUtils.isNotBlank(s1) && !ObjectUtil.isAllFieldNull(redisTemplate.opsForValue().get(s1Key))) {
                 //走缓存
-                BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s1Key)), customerInfoVO);
+                CustomerInfoVO customerInfoVO1 = new CustomerInfoVO();
+                BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s1Key)), customerInfoVO1);
+                Idcard.conversionFront(customerInfoVO, customerInfoVO1);
             } else {
                 //识别身份证正面
                 Idcard.getIdCardFront(s1, customerInfoVO);
-                AssertionUtils.isEmpty(customerInfoVO, "身份证识别失败");
                 //设置缓存
                 redisTemplate.opsForValue().set(s1Key, customerInfoVO, 1, TimeUnit.DAYS);
             }
@@ -69,11 +70,12 @@ public class IdentifyServiceImpl implements IdentifyService {
             String s2Key = IMAGE_IDENTIFY_KEY + "idCard:" + "back:" + s2MD5;
             if (StringUtils.isNotBlank(s2) && !ObjectUtil.isAllFieldNull(redisTemplate.opsForValue().get(s2Key))) {
                 //走缓存
+                CustomerInfoVO customerInfoVO2 = new CustomerInfoVO();
                 BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s2Key)), customerInfoVO);
+                Idcard.conversionBack(customerInfoVO, customerInfoVO2);
             } else {
                 //识别身份证背面
                 Idcard.getIdCardBack(s2, customerInfoVO);
-                AssertionUtils.isEmpty(customerInfoVO, "身份证识别失败");
                 //设置缓存
                 redisTemplate.opsForValue().set(s2Key, customerInfoVO, 1, TimeUnit.DAYS);
             }
@@ -94,11 +96,13 @@ public class IdentifyServiceImpl implements IdentifyService {
             String s1Key = IMAGE_IDENTIFY_KEY + "drivingPermit:" + "front:" + s1MD5;
             if (StringUtils.isNotBlank(s1) && !ObjectUtil.isAllFieldNull(redisTemplate.opsForValue().get(s1Key))) {
                 //走缓存
+                CardUserInfo cardUserInfo1 = new CardUserInfo();
                 BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s1Key)), cardUserInfo);
+                MultiObjectDetect.conversionFront(cardUserInfo, cardUserInfo1);
+
             } else {
                 //行驶证正面识别
                 MultiObjectDetect.drivingPermitFront(s1, cardUserInfo);
-                AssertionUtils.isEmpty(cardUserInfo, "行驶证正面识别失败");
                 //设置缓存
                 redisTemplate.opsForValue().set(s1Key, cardUserInfo, 1, TimeUnit.DAYS);
             }
@@ -110,15 +114,17 @@ public class IdentifyServiceImpl implements IdentifyService {
             String s2Key = IMAGE_IDENTIFY_KEY + "drivingPermit:" + "back:" + s2MD5;
             if (StringUtils.isNotBlank(s2) && !ObjectUtil.isAllFieldNull(redisTemplate.opsForValue().get(s2Key))) {
                 //走缓存
-                BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s2Key)), cardUserInfo);
+                CardUserInfo cardUserInfo2 = new CardUserInfo();
+                BeanUtils.copyProperties(Objects.requireNonNull(redisTemplate.opsForValue().get(s2Key)), cardUserInfo2);
+                MultiObjectDetect.conversionBack(cardUserInfo, cardUserInfo2);
             } else {
                 //行驶证反面识别
                 MultiObjectDetect.drivingPermitBack(s2, cardUserInfo);
-                AssertionUtils.isEmpty(cardUserInfo, "行驶证正面识别失败");
                 //设置缓存
                 redisTemplate.opsForValue().set(s2Key, cardUserInfo, 1, TimeUnit.DAYS);
             }
         }
+
         AssertionUtils.isEmpty(cardUserInfo, "行驶证正面识别失败");
         map.put("carInfo", cardUserInfo);
         return HttpResult.ok("success", map);

+ 13 - 0
src/main/java/com/ydtech/utils/baidu/Idcard.java

@@ -121,6 +121,15 @@ public class Idcard {
         }
     }
 
+    public static void conversionFront(CustomerInfoVO customerInfo, CustomerInfoVO customerInfoNew) {
+        customerInfo.setName(customerInfoNew.getName());
+        customerInfo.setIdentifyNumber(customerInfoNew.getIdentifyNumber());
+        customerInfo.setAddr(customerInfoNew.getAddr());
+        customerInfo.setIdentifyType(customerInfoNew.getIdentifyType());
+        customerInfo.setIdentifyIssuedCom(customerInfoNew.getIdentifyIssuedCom());
+    }
+
+
     public static void getIdCardBack(String images, CustomerInfoVO customerInfo) {
         if (StringUtils.isEmpty(images)) {
             return;
@@ -135,5 +144,9 @@ public class Idcard {
         }
     }
 
+    public static void conversionBack(CustomerInfoVO customerInfo, CustomerInfoVO customerInfoNew) {
+        customerInfo.setIdentifyValidDate(customerInfoNew.getName());
+        customerInfo.setIdentifyValidEndDate(customerInfoNew.getIdentifyValidEndDate());
+    }
 
 }

+ 24 - 0
src/main/java/com/ydtech/utils/baidu/MultiObjectDetect.java

@@ -173,6 +173,22 @@ public class MultiObjectDetect {
         }
     }
 
+    public static void conversionFront(CardUserInfo cardUserInfo, CardUserInfo cardUserInfoNew){
+        cardUserInfo.setVIN(cardUserInfoNew.getVIN());
+        cardUserInfo.setIssueDate(cardUserInfoNew.getIssueDate());
+        cardUserInfo.setCategory(cardUserInfoNew.getCategory());
+        cardUserInfo.setPlateType(cardUserInfoNew.getPlateType());
+        cardUserInfo.setVehicleUse(cardUserInfoNew.getVehicleUse());
+        cardUserInfo.setUseNature(cardUserInfoNew.getUseNature());
+        cardUserInfo.setMotorUsageTypeCode(cardUserInfoNew.getMotorUsageTypeCode());
+        cardUserInfo.setMotorTypeCode(cardUserInfoNew.getMotorTypeCode());
+        cardUserInfo.setRegisterDate(cardUserInfoNew.getRegisterDate());
+        cardUserInfo.setEngine(cardUserInfoNew.getEngine());
+        cardUserInfo.setPlateNo(cardUserInfoNew.getPlateNo());
+        cardUserInfo.setBackOcrID(cardUserInfoNew.getBackOcrID());
+        cardUserInfo.setCarOwner(cardUserInfoNew.getCarOwner());
+    }
+
 
     /**
      * 行驶证背面
@@ -196,4 +212,12 @@ public class MultiObjectDetect {
         }
 
     }
+
+    public static void conversionBack(CardUserInfo cardUserInfo, CardUserInfo cardUserInfoNew){
+        cardUserInfo.setGrossMass(cardUserInfoNew.getGrossMass());
+        cardUserInfo.setApprovedPassengersCapacity(cardUserInfoNew.getApprovedPassengersCapacity());
+        cardUserInfo.setUnladenMass(cardUserInfoNew.getUnladenMass());
+        cardUserInfo.setLimitLoad(cardUserInfoNew.getLimitLoad());
+    }
+
 }