Commit 2f636acdb75d78224d5d9edd1e2c1c8a236b8ba0

Authored by 房远帅
1 parent 45d0069e

楚江ERP:客户资信-序列化问题处理

... ... @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
5 5 import com.lframework.starter.web.core.annotations.security.HasPermission;
6 6 import com.lframework.starter.web.core.components.redis.RedisHandler;
7 7 import com.lframework.starter.web.core.controller.DefaultBaseController;
  8 +import com.lframework.starter.web.core.utils.JsonUtil;
8 9 import com.lframework.starter.web.core.utils.PageResultUtil;
9 10 import com.lframework.starter.web.core.components.resp.PageResult;
10 11 import com.lframework.starter.web.core.components.resp.InvokeResult;
... ... @@ -86,19 +87,12 @@ public class CustomerCreditHistoryController extends DefaultBaseController {
86 87 List<CustomerCreditHistory> query = customerCreditHistoryService.query(vo);
87 88
88 89 List<GetCustomerCreditHistoryBo> results = null;
89   -
90   - ObjectMapper objectMapper = new ObjectMapper();
91 90 Object o = redisHandler.get(vo.getCreditId());
92 91 UpdateCustomerCreditVo updateCustomerCreditVo = null;
93 92 if (o != null) {
94 93 String jsonString = o.toString();
95   - try {
96   - // 2. 反序列化为 UpdateCustomerCreditVo 对象
97   - updateCustomerCreditVo = objectMapper.readValue(jsonString, UpdateCustomerCreditVo.class);
98   - } catch (JsonProcessingException e) {
99   - e.printStackTrace(); // 或使用日志
100   - throw new RuntimeException("JSON 反序列化失败", e);
101   - }
  94 + // 2. 反序列化为 UpdateCustomerCreditVo 对象
  95 + updateCustomerCreditVo = JsonUtil.parseObject(jsonString, UpdateCustomerCreditVo.class);
102 96 }
103 97
104 98 if (!CollectionUtil.isEmpty(query)) {
... ...
... ... @@ -65,7 +65,7 @@ public class CustomerCreditHistory extends BaseEntity implements BaseDto {
65 65 private String customerShortName;
66 66
67 67 /**
68   - * 企业类型:经销商(distributor)、终端(terminal
  68 + * 企业类型:经销商(DEALER)、终端(TERMINAL
69 69 */
70 70 @Label("企业类型")
71 71 private String enterpriseType;
... ...
... ... @@ -109,20 +109,15 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
109 109 * @param businessId 业务ID
110 110 */
111 111 private void handleCustomerCreditData(String flowStatus, String businessId) {
112   - ObjectMapper objectMapper = new ObjectMapper();
113 112 Object o = redisHandler.get(businessId);
114 113 UpdateCustomerCreditVo vo = null;
115 114 if (o != null) {
116 115 String jsonString = o.toString();
117   - try {
118   - // 2. 反序列化为 UpdateCustomerCreditVo 对象
119   - vo = objectMapper.readValue(jsonString, UpdateCustomerCreditVo.class);
120   - } catch (JsonProcessingException e) {
121   - e.printStackTrace(); // 或使用日志
122   - throw new RuntimeException("JSON 反序列化失败", e);
123   - }
  116 + // 2. 反序列化为 UpdateCustomerCreditVo 对象
  117 + vo = JsonUtil.parseObject(jsonString, UpdateCustomerCreditVo.class);
124 118 }
125   - if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)) {
  119 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  120 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
126 121 //变更通过,更新数据
127 122 if (vo != null) {
128 123 vo.setStatus("PASS");
... ... @@ -133,7 +128,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
133 128 //非变更审核
134 129 customerCreditService.updateStatus(businessId, "PASS");
135 130 }
136   - } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)) {
  131 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  132 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
  133 + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
137 134 //变更拒绝,回退历史记录数据
138 135 if (vo != null) {
139 136 String creditHistoryId = vo.getCreditHistoryId();
... ...
... ... @@ -307,6 +307,23 @@ public class CustomerCreditHistoryServiceImpl extends BaseMpServiceImpl<Customer
307 307 value2 = customer2.getName();
308 308 }
309 309 }
  310 + //企业类型
  311 + if ("enterpriseType".equals(fieldName)) {
  312 + if (StringUtil.isNotEmpty(data.getEnterpriseType())) {
  313 + if ("TERMINAL".equals(data.getEnterpriseType())) {
  314 + value1 = "终端";
  315 + } else if ("DEALER".equals(data.getEnterpriseType())) {
  316 + value1 = "经销商";
  317 + }
  318 + }
  319 + if (StringUtil.isNotEmpty(customerCreditHistory.getEnterpriseType())) {
  320 + if ("TERMINAL".equals(customerCreditHistory.getEnterpriseType())) {
  321 + value2 = "终端";
  322 + } else if ("DEALER".equals(customerCreditHistory.getEnterpriseType())) {
  323 + value2 = "经销商";
  324 + }
  325 + }
  326 + }
310 327 //调查人
311 328 if ("investigator".equals(fieldName)) {
312 329 if (StringUtil.isNotEmpty(data.getInvestigator())) {
... ... @@ -334,6 +351,12 @@ public class CustomerCreditHistoryServiceImpl extends BaseMpServiceImpl<Customer
334 351
335 352 Map<Integer, String> changeMap = new LinkedHashMap<>();
336 353 changeMap.put(1, String.valueOf(index));
  354 + if (value1 == null) {
  355 + value1 = "";
  356 + }
  357 + if (value2 == null) {
  358 + value2 = "";
  359 + }
337 360 changeMap.put(2, formatValue(value1));
338 361 changeMap.put(3, formatValue(value2));
339 362
... ...
... ... @@ -725,13 +725,8 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
725 725 }
726 726 vo.setCorePersonnelList(corePersonnelList1);
727 727 }
728   - ObjectMapper objectMapper = new ObjectMapper();
729   - try {
730   - String jsonString = objectMapper.writeValueAsString(vo);
731   - redisHandler.set(vo.getId(), jsonString);
732   - } catch (JsonProcessingException e) {
733   - e.printStackTrace();
734   - }
  728 + String jsonString = JsonUtil.toJsonString(vo);
  729 + redisHandler.set(vo.getId(), jsonString);
735 730 } else {
736 731 //变更审核通过后再修改入库
737 732 LambdaUpdateWrapper<CustomerCredit> updateWrapper = Wrappers.lambdaUpdate(CustomerCredit.class)
... ... @@ -1053,6 +1048,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
1053 1048 }
1054 1049 OpLogUtil.setVariable("id", data.getId());
1055 1050 OpLogUtil.setExtra(vo);
  1051 + cleanCacheByKey(vo.getId());
1056 1052 }
1057 1053
1058 1054 @OpLog(type = OtherOpLogType.class, name = "更新状态,ID:{}", params = {"#id"})
... ... @@ -1066,6 +1062,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
1066 1062 .set(CustomerCredit::getStatus, status)
1067 1063 .eq(CustomerCredit::getId, id);
1068 1064 getBaseMapper().update(updateWrapper);
  1065 + cleanCacheByKey(id);
1069 1066 }
1070 1067
1071 1068 @OpLog(type = OtherOpLogType.class, name = "取消,ID:{}", params = {"#id"})
... ... @@ -1079,6 +1076,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
1079 1076 .set(CustomerCredit::getStatus, "CANCEL")
1080 1077 .eq(CustomerCredit::getId, id);
1081 1078 getBaseMapper().update(updateWrapper);
  1079 + cleanCacheByKey(id);
1082 1080 }
1083 1081
1084 1082 @OpLog(type = OtherOpLogType.class, name = "删除客户资信表,ID:{}", params = {"#id"})
... ...
... ... @@ -12,6 +12,8 @@ import com.lframework.starter.web.core.vo.BaseVo;
12 12 import com.lframework.starter.web.core.components.validation.TypeMismatch;
13 13 import io.swagger.annotations.ApiModelProperty;
14 14 import org.hibernate.validator.constraints.Length;
  15 +import org.springframework.format.annotation.DateTimeFormat;
  16 +
15 17 import java.io.Serializable;
16 18 import java.util.List;
17 19
... ... @@ -39,7 +41,7 @@ public class UpdateCustomerCreditVo implements BaseVo, Serializable {
39 41 */
40 42 @ApiModelProperty("登记日期")
41 43 @TypeMismatch(message = "登记日期格式有误!")
42   - @JsonFormat(pattern = StringPool.DATE_PATTERN)
  44 + @DateTimeFormat(pattern = "yyyy-MM-dd")
43 45 private LocalDate registerDate;
44 46
45 47 /**
... ... @@ -112,7 +114,7 @@ public class UpdateCustomerCreditVo implements BaseVo, Serializable {
112 114 */
113 115 @ApiModelProperty("注册时间")
114 116 @TypeMismatch(message = "注册时间格式有误!")
115   - @JsonFormat(pattern = StringPool.DATE_PATTERN)
  117 + @DateTimeFormat(pattern = "yyyy-MM-dd")
116 118 private LocalDate registrationTime;
117 119
118 120 /**
... ...