Commit f824cef288206374aec68b100c1e66f01f7f6000
1 parent
80a5bb97
feature(*): 原始数据处理逻辑调整
- 原始数据处理逻辑调整
Showing
4 changed files
with
30 additions
and
11 deletions
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/OriginalDataDTO.java
fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/param/FollowOriginalParam.java
... | ... | @@ -25,7 +25,6 @@ public class FollowOriginalParam { |
25 | 25 | /** |
26 | 26 | * 档案id |
27 | 27 | */ |
28 | - @NotNull(message = "保有客档案id不能为空") | |
29 | 28 | private Long customerId; |
30 | 29 | /** |
31 | 30 | * 车架号 |
... | ... | @@ -37,6 +36,7 @@ public class FollowOriginalParam { |
37 | 36 | private String plateNo; |
38 | 37 | /** |
39 | 38 | * 数据产生时间 |
39 | + * [保险类型是为保险到期时间] | |
40 | 40 | */ |
41 | 41 | @NotNull(message = "产生时间不能为空") |
42 | 42 | private Date generateTime; | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/api/FollowApiServiceImpl.java
... | ... | @@ -2,6 +2,7 @@ package cn.fw.valhalla.controller.api; |
2 | 2 | |
3 | 3 | import cn.fw.common.web.annotation.ControllerMethod; |
4 | 4 | import cn.fw.data.base.domain.common.Message; |
5 | +import cn.fw.valhalla.common.utils.StringUtils; | |
5 | 6 | import cn.fw.valhalla.domain.dto.OriginalDataDTO; |
6 | 7 | import cn.fw.valhalla.sdk.api.FollowApiService; |
7 | 8 | import cn.fw.valhalla.sdk.enums.DataTypeEnum; |
... | ... | @@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
13 | 14 | import org.springframework.web.bind.annotation.*; |
14 | 15 | |
15 | 16 | import javax.validation.Valid; |
17 | +import java.util.Objects; | |
16 | 18 | |
17 | 19 | import static cn.fw.common.businessvalidator.Validator.BV; |
18 | 20 | import static cn.fw.common.web.util.ResultBuilder.success; |
... | ... | @@ -39,6 +41,10 @@ public class FollowApiServiceImpl implements FollowApiService { |
39 | 41 | @PostMapping("/origin/save") |
40 | 42 | @ControllerMethod("业务元数据保存") |
41 | 43 | public Message<Void> saveOriginal(@Valid @RequestBody FollowOriginalParam originalParam) { |
44 | + String frameNo = originalParam.getFrameNo(); | |
45 | + Long customerId = originalParam.getCustomerId(); | |
46 | + boolean bool = Objects.nonNull(customerId) || StringUtils.isValid(frameNo); | |
47 | + BV.isTrue(bool, () -> "档案id或者车架号不能为空"); | |
42 | 48 | OriginalDataDTO dataDTO = new OriginalDataDTO(); |
43 | 49 | BeanUtils.copyProperties(originalParam, dataDTO); |
44 | 50 | originalDataBizService.saveOrigin(dataDTO); | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/OriginalDataBizService.java
... | ... | @@ -50,6 +50,13 @@ public class OriginalDataBizService { |
50 | 50 | */ |
51 | 51 | @Transactional(rollbackFor = Exception.class) |
52 | 52 | public void saveOrigin(OriginalDataDTO dataDTO) { |
53 | + String frameNo = dataDTO.getFrameNo(); | |
54 | + Long customerId = dataDTO.getCustomerId(); | |
55 | + String plateNo = dataDTO.getPlateNo(); | |
56 | + | |
57 | + if (StringUtils.isEmpty(frameNo) && Objects.isNull(customerId)) { | |
58 | + return; | |
59 | + } | |
53 | 60 | OriginalData originalData = originalDataService.getOne(Wrappers.<OriginalData>lambdaQuery() |
54 | 61 | .eq(OriginalData::getType, dataDTO.getType()) |
55 | 62 | .eq(OriginalData::getDetailId, dataDTO.getDetailId()) |
... | ... | @@ -58,22 +65,28 @@ public class OriginalDataBizService { |
58 | 65 | return; |
59 | 66 | } |
60 | 67 | originalData = new OriginalData(); |
61 | - Customer customer = customerService.queryById(dataDTO.getCustomerId()); | |
62 | - if (Objects.isNull(customer)) { | |
63 | - return; | |
68 | + Customer customer; | |
69 | + if (StringUtils.isValid(frameNo)) { | |
70 | + customer = customerService.queryByFrameNo(frameNo, originalData.getGroupId()); | |
71 | + } else { | |
72 | + customer = customerService.queryById(customerId); | |
64 | 73 | } |
65 | 74 | BeanUtils.copyProperties(dataDTO, originalData); |
75 | + | |
66 | 76 | if (DataTypeEnum.BI.equals(dataDTO.getType())) { |
67 | 77 | LocalDate dateTime = DateUtil.date2LocalDate(dataDTO.getGenerateTime()); |
68 | - assert dateTime != null; | |
69 | - Date insuranceExpires = DateUtil.localDateTime2Date(dateTime.plusYears(1L).atStartOfDay()); | |
70 | - customer.setInsuranceExpires(insuranceExpires); | |
71 | - customerService.updateById(customer); | |
78 | + Date insuranceExpires = DateUtil.localDateTime2Date(dateTime.atStartOfDay()); | |
79 | + originalData.setGenerateTime(insuranceExpires); | |
80 | + if (Objects.nonNull(customer)) { | |
81 | + customer.setInsuranceExpires(insuranceExpires); | |
82 | + customerService.updateById(customer); | |
83 | + } | |
72 | 84 | } |
73 | - if (StringUtils.isEmpty(originalData.getFrameNo())) { | |
85 | + | |
86 | + if (StringUtils.isEmpty(frameNo) && Objects.nonNull(customer)) { | |
74 | 87 | originalData.setFrameNo(customer.getFrameNo()); |
75 | 88 | } |
76 | - if (StringUtils.isEmpty(originalData.getPlateNo())) { | |
89 | + if (StringUtils.isEmpty(plateNo) && Objects.nonNull(customer)) { | |
77 | 90 | originalData.setPlateNo(customer.getPlateNo()); |
78 | 91 | } |
79 | 92 | originalData.setSolved(Boolean.FALSE); | ... | ... |