Commit 2f636acdb75d78224d5d9edd1e2c1c8a236b8ba0

Authored by 房远帅
1 parent 45d0069e

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

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
5 import com.lframework.starter.web.core.annotations.security.HasPermission; 5 import com.lframework.starter.web.core.annotations.security.HasPermission;
6 import com.lframework.starter.web.core.components.redis.RedisHandler; 6 import com.lframework.starter.web.core.components.redis.RedisHandler;
7 import com.lframework.starter.web.core.controller.DefaultBaseController; 7 import com.lframework.starter.web.core.controller.DefaultBaseController;
  8 +import com.lframework.starter.web.core.utils.JsonUtil;
8 import com.lframework.starter.web.core.utils.PageResultUtil; 9 import com.lframework.starter.web.core.utils.PageResultUtil;
9 import com.lframework.starter.web.core.components.resp.PageResult; 10 import com.lframework.starter.web.core.components.resp.PageResult;
10 import com.lframework.starter.web.core.components.resp.InvokeResult; 11 import com.lframework.starter.web.core.components.resp.InvokeResult;
@@ -86,19 +87,12 @@ public class CustomerCreditHistoryController extends DefaultBaseController { @@ -86,19 +87,12 @@ public class CustomerCreditHistoryController extends DefaultBaseController {
86 List<CustomerCreditHistory> query = customerCreditHistoryService.query(vo); 87 List<CustomerCreditHistory> query = customerCreditHistoryService.query(vo);
87 88
88 List<GetCustomerCreditHistoryBo> results = null; 89 List<GetCustomerCreditHistoryBo> results = null;
89 -  
90 - ObjectMapper objectMapper = new ObjectMapper();  
91 Object o = redisHandler.get(vo.getCreditId()); 90 Object o = redisHandler.get(vo.getCreditId());
92 UpdateCustomerCreditVo updateCustomerCreditVo = null; 91 UpdateCustomerCreditVo updateCustomerCreditVo = null;
93 if (o != null) { 92 if (o != null) {
94 String jsonString = o.toString(); 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 if (!CollectionUtil.isEmpty(query)) { 98 if (!CollectionUtil.isEmpty(query)) {
@@ -65,7 +65,7 @@ public class CustomerCreditHistory extends BaseEntity implements BaseDto { @@ -65,7 +65,7 @@ public class CustomerCreditHistory extends BaseEntity implements BaseDto {
65 private String customerShortName; 65 private String customerShortName;
66 66
67 /** 67 /**
68 - * 企业类型:经销商(distributor)、终端(terminal 68 + * 企业类型:经销商(DEALER)、终端(TERMINAL
69 */ 69 */
70 @Label("企业类型") 70 @Label("企业类型")
71 private String enterpriseType; 71 private String enterpriseType;
@@ -109,20 +109,15 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -109,20 +109,15 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
109 * @param businessId 业务ID 109 * @param businessId 业务ID
110 */ 110 */
111 private void handleCustomerCreditData(String flowStatus, String businessId) { 111 private void handleCustomerCreditData(String flowStatus, String businessId) {
112 - ObjectMapper objectMapper = new ObjectMapper();  
113 Object o = redisHandler.get(businessId); 112 Object o = redisHandler.get(businessId);
114 UpdateCustomerCreditVo vo = null; 113 UpdateCustomerCreditVo vo = null;
115 if (o != null) { 114 if (o != null) {
116 String jsonString = o.toString(); 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 if (vo != null) { 122 if (vo != null) {
128 vo.setStatus("PASS"); 123 vo.setStatus("PASS");
@@ -133,7 +128,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -133,7 +128,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
133 //非变更审核 128 //非变更审核
134 customerCreditService.updateStatus(businessId, "PASS"); 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 if (vo != null) { 135 if (vo != null) {
139 String creditHistoryId = vo.getCreditHistoryId(); 136 String creditHistoryId = vo.getCreditHistoryId();
@@ -307,6 +307,23 @@ public class CustomerCreditHistoryServiceImpl extends BaseMpServiceImpl<Customer @@ -307,6 +307,23 @@ public class CustomerCreditHistoryServiceImpl extends BaseMpServiceImpl<Customer
307 value2 = customer2.getName(); 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 if ("investigator".equals(fieldName)) { 328 if ("investigator".equals(fieldName)) {
312 if (StringUtil.isNotEmpty(data.getInvestigator())) { 329 if (StringUtil.isNotEmpty(data.getInvestigator())) {
@@ -334,6 +351,12 @@ public class CustomerCreditHistoryServiceImpl extends BaseMpServiceImpl<Customer @@ -334,6 +351,12 @@ public class CustomerCreditHistoryServiceImpl extends BaseMpServiceImpl<Customer
334 351
335 Map<Integer, String> changeMap = new LinkedHashMap<>(); 352 Map<Integer, String> changeMap = new LinkedHashMap<>();
336 changeMap.put(1, String.valueOf(index)); 353 changeMap.put(1, String.valueOf(index));
  354 + if (value1 == null) {
  355 + value1 = "";
  356 + }
  357 + if (value2 == null) {
  358 + value2 = "";
  359 + }
337 changeMap.put(2, formatValue(value1)); 360 changeMap.put(2, formatValue(value1));
338 changeMap.put(3, formatValue(value2)); 361 changeMap.put(3, formatValue(value2));
339 362
@@ -725,13 +725,8 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -725,13 +725,8 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
725 } 725 }
726 vo.setCorePersonnelList(corePersonnelList1); 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 } else { 730 } else {
736 //变更审核通过后再修改入库 731 //变更审核通过后再修改入库
737 LambdaUpdateWrapper<CustomerCredit> updateWrapper = Wrappers.lambdaUpdate(CustomerCredit.class) 732 LambdaUpdateWrapper<CustomerCredit> updateWrapper = Wrappers.lambdaUpdate(CustomerCredit.class)
@@ -1053,6 +1048,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -1053,6 +1048,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
1053 } 1048 }
1054 OpLogUtil.setVariable("id", data.getId()); 1049 OpLogUtil.setVariable("id", data.getId());
1055 OpLogUtil.setExtra(vo); 1050 OpLogUtil.setExtra(vo);
  1051 + cleanCacheByKey(vo.getId());
1056 } 1052 }
1057 1053
1058 @OpLog(type = OtherOpLogType.class, name = "更新状态,ID:{}", params = {"#id"}) 1054 @OpLog(type = OtherOpLogType.class, name = "更新状态,ID:{}", params = {"#id"})
@@ -1066,6 +1062,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -1066,6 +1062,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
1066 .set(CustomerCredit::getStatus, status) 1062 .set(CustomerCredit::getStatus, status)
1067 .eq(CustomerCredit::getId, id); 1063 .eq(CustomerCredit::getId, id);
1068 getBaseMapper().update(updateWrapper); 1064 getBaseMapper().update(updateWrapper);
  1065 + cleanCacheByKey(id);
1069 } 1066 }
1070 1067
1071 @OpLog(type = OtherOpLogType.class, name = "取消,ID:{}", params = {"#id"}) 1068 @OpLog(type = OtherOpLogType.class, name = "取消,ID:{}", params = {"#id"})
@@ -1079,6 +1076,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM @@ -1079,6 +1076,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
1079 .set(CustomerCredit::getStatus, "CANCEL") 1076 .set(CustomerCredit::getStatus, "CANCEL")
1080 .eq(CustomerCredit::getId, id); 1077 .eq(CustomerCredit::getId, id);
1081 getBaseMapper().update(updateWrapper); 1078 getBaseMapper().update(updateWrapper);
  1079 + cleanCacheByKey(id);
1082 } 1080 }
1083 1081
1084 @OpLog(type = OtherOpLogType.class, name = "删除客户资信表,ID:{}", params = {"#id"}) 1082 @OpLog(type = OtherOpLogType.class, name = "删除客户资信表,ID:{}", params = {"#id"})
@@ -12,6 +12,8 @@ import com.lframework.starter.web.core.vo.BaseVo; @@ -12,6 +12,8 @@ import com.lframework.starter.web.core.vo.BaseVo;
12 import com.lframework.starter.web.core.components.validation.TypeMismatch; 12 import com.lframework.starter.web.core.components.validation.TypeMismatch;
13 import io.swagger.annotations.ApiModelProperty; 13 import io.swagger.annotations.ApiModelProperty;
14 import org.hibernate.validator.constraints.Length; 14 import org.hibernate.validator.constraints.Length;
  15 +import org.springframework.format.annotation.DateTimeFormat;
  16 +
15 import java.io.Serializable; 17 import java.io.Serializable;
16 import java.util.List; 18 import java.util.List;
17 19
@@ -39,7 +41,7 @@ public class UpdateCustomerCreditVo implements BaseVo, Serializable { @@ -39,7 +41,7 @@ public class UpdateCustomerCreditVo implements BaseVo, Serializable {
39 */ 41 */
40 @ApiModelProperty("登记日期") 42 @ApiModelProperty("登记日期")
41 @TypeMismatch(message = "登记日期格式有误!") 43 @TypeMismatch(message = "登记日期格式有误!")
42 - @JsonFormat(pattern = StringPool.DATE_PATTERN) 44 + @DateTimeFormat(pattern = "yyyy-MM-dd")
43 private LocalDate registerDate; 45 private LocalDate registerDate;
44 46
45 /** 47 /**
@@ -112,7 +114,7 @@ public class UpdateCustomerCreditVo implements BaseVo, Serializable { @@ -112,7 +114,7 @@ public class UpdateCustomerCreditVo implements BaseVo, Serializable {
112 */ 114 */
113 @ApiModelProperty("注册时间") 115 @ApiModelProperty("注册时间")
114 @TypeMismatch(message = "注册时间格式有误!") 116 @TypeMismatch(message = "注册时间格式有误!")
115 - @JsonFormat(pattern = StringPool.DATE_PATTERN) 117 + @DateTimeFormat(pattern = "yyyy-MM-dd")
116 private LocalDate registrationTime; 118 private LocalDate registrationTime;
117 119
118 /** 120 /**