Commit ed9fad03fb348b106daaaf3899cc8267d38a964c
1 parent
b8c81706
调整车辆认证逻辑
Showing
2 changed files
with
17 additions
and
18 deletions
fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/enums/CarUseTypeEnum.java
... | ... | @@ -15,11 +15,11 @@ public enum CarUseTypeEnum implements IEnum<Integer> { |
15 | 15 | /** |
16 | 16 | * 个人 |
17 | 17 | */ |
18 | - NO_OPERATING(1, "非运营"), | |
18 | + NO_OPERATING(1, "非营运"), | |
19 | 19 | /** |
20 | 20 | * 企业单位 |
21 | 21 | */ |
22 | - OPERATING(2, "运营"); | |
22 | + OPERATING(2, "营运"); | |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * 值 |
... | ... | @@ -57,7 +57,7 @@ public enum CarUseTypeEnum implements IEnum<Integer> { |
57 | 57 | */ |
58 | 58 | public static CarUseTypeEnum ofName(final String name) { |
59 | 59 | for (final CarUseTypeEnum typeEnum : CarUseTypeEnum.values()) { |
60 | - if (typeEnum.name.equals(name)) { | |
60 | + if (typeEnum.getName().equals(name)) { | |
61 | 61 | return typeEnum; |
62 | 62 | } |
63 | 63 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/component/AuthVehicleConsumer.java
1 | 1 | package cn.fw.valhalla.component; |
2 | 2 | |
3 | 3 | import cn.fw.identify.sdk.api.mq.AuthDataEvent; |
4 | -import cn.fw.valhalla.common.utils.*; | |
4 | +import cn.fw.valhalla.common.utils.DateUtil; | |
5 | +import cn.fw.valhalla.common.utils.StringUtils; | |
5 | 6 | import cn.fw.valhalla.domain.dto.NewVehicleDTO; |
6 | 7 | import cn.fw.valhalla.rpc.member.MemberRpcService; |
7 | 8 | import cn.fw.valhalla.rpc.member.dto.MemberUserDTO; |
... | ... | @@ -20,6 +21,7 @@ import java.util.Objects; |
20 | 21 | |
21 | 22 | /** |
22 | 23 | * 监听认证mq |
24 | + * | |
23 | 25 | * @author xiatian |
24 | 26 | */ |
25 | 27 | @Slf4j |
... | ... | @@ -41,21 +43,21 @@ public class AuthVehicleConsumer implements RocketMQListener<AuthDataEvent> { |
41 | 43 | log.info("监听认证mq: AuthDataEvent=[{}]", t); |
42 | 44 | try { |
43 | 45 | String identifyCode = "NS9k"; |
44 | - if(!identifyCode.equals(t.getIdentifyCode())){ | |
46 | + if (!identifyCode.equals(t.getIdentifyCode())) { | |
45 | 47 | return; |
46 | 48 | } |
47 | - if(StringUtils.isEmpty(t.getVin())){ | |
49 | + if (StringUtils.isEmpty(t.getVin())) { | |
48 | 50 | log.error("认证mq的vin为空"); |
49 | 51 | } |
50 | 52 | //保存车辆认证信息 |
51 | - memberVehicleBizService.saveVehicle(with(JSON.parseObject(t.getExtraData(),VehicleData.class),t)); | |
53 | + memberVehicleBizService.saveVehicle(with(JSON.parseObject(t.getExtraData(), VehicleData.class), t)); | |
52 | 54 | } catch (Exception ex) { |
53 | 55 | log.error("消费关注公众号mq失败,原因:{}", JSON.toJSONString(ex)); |
54 | 56 | } |
55 | 57 | } |
56 | 58 | |
57 | 59 | @Data |
58 | - private static class VehicleData{ | |
60 | + private static class VehicleData { | |
59 | 61 | private String plateNum; |
60 | 62 | |
61 | 63 | private String vehicleType; |
... | ... | @@ -93,19 +95,16 @@ public class AuthVehicleConsumer implements RocketMQListener<AuthDataEvent> { |
93 | 95 | private String inspectionRecord; |
94 | 96 | } |
95 | 97 | |
96 | - private NewVehicleDTO with(VehicleData vehicleData,AuthDataEvent t){ | |
97 | - log.info("行驶证转换结果:{}",JSON.toJSONString(vehicleData)); | |
98 | + private NewVehicleDTO with(VehicleData vehicleData, AuthDataEvent t) { | |
99 | + log.info("行驶证转换结果:{}", JSON.toJSONString(vehicleData)); | |
98 | 100 | MemberUserDTO member = memberRpcService.user(t.getMemberId()); |
99 | - String brandName = StringUtils.matchFirst(vehicleData.getModel(),"[\\u4e00-\\u9fa5]+",0); | |
100 | - if(Objects.isNull(brandName)){ | |
101 | + String brandName = StringUtils.matchFirst(vehicleData.getModel(), "[\\u4e00-\\u9fa5]+", 0); | |
102 | + if (Objects.isNull(brandName)) { | |
101 | 103 | log.error("未匹配行驶证品牌"); |
102 | 104 | return null; |
103 | 105 | } |
104 | - CarUseTypeEnum useType = CarUseTypeEnum.ofName(vehicleData.getUseCharacter()); | |
105 | - if(Objects.isNull(useType)){ | |
106 | - log.error("未匹配行驶证使用性质"); | |
107 | - return null; | |
108 | - } | |
106 | + CarUseTypeEnum useType = CarUseTypeEnum.NO_OPERATING.getName().equals(vehicleData.getUseCharacter()) | |
107 | + ? CarUseTypeEnum.NO_OPERATING : CarUseTypeEnum.OPERATING; | |
109 | 108 | Date regDate = DateUtil.parse1(vehicleData.registerDate); |
110 | 109 | NewVehicleDTO newVehicle = new NewVehicleDTO(); |
111 | 110 | newVehicle.setMemberId(t.getMemberId()); |
... | ... | @@ -118,7 +117,7 @@ public class AuthVehicleConsumer implements RocketMQListener<AuthDataEvent> { |
118 | 117 | newVehicle.setFrameNo(vehicleData.getVin()); |
119 | 118 | newVehicle.setName(vehicleData.getOwner()); |
120 | 119 | newVehicle.setRegDate(regDate); |
121 | - newVehicle.setSpecCode(vehicleData.getModel().replace(brandName,"")); | |
120 | + newVehicle.setSpecCode(vehicleData.getModel().replace(brandName, "")); | |
122 | 121 | return newVehicle; |
123 | 122 | } |
124 | 123 | } |
125 | 124 | \ No newline at end of file | ... | ... |