Commit f2df0a7d by 章家宝

feat:代码优化

1 parent 6e61f0e2
package cn.com.glsx.dj.strategy.service; package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.smartcarlife.dto.CustomerProfileInfoDTO; import cn.com.glsx.dj.smartcarlife.dto.CustomerSimpleInfoDTO;
import cn.com.glsx.dj.smartcarlife.remote.CustomerInfoRemote; import cn.com.glsx.dj.smartcarlife.remote.CustomerInfoRemote;
import cn.com.glsx.dj.strategy.dto.CarSeriesDetailDTO; import cn.com.glsx.dj.strategy.dto.CarSeriesDetailDTO;
import cn.com.glsx.dj.strategy.dto.CustomerProfileRespDTO; import cn.com.glsx.dj.strategy.dto.CustomerProfileRespDTO;
...@@ -201,7 +201,7 @@ public class CustomerTagProfileService { ...@@ -201,7 +201,7 @@ public class CustomerTagProfileService {
while (hasMore) { while (hasMore) {
try { try {
// 分页查询客户画像信息 // 分页查询客户画像信息
RpcPagination<CustomerProfileInfoDTO> pagination = queryCustomerProfileInfo(pageNum); RpcPagination<CustomerSimpleInfoDTO> pagination = queryCustomerProfileInfo(pageNum);
if (pagination == null || CollectionUtils.isEmpty(pagination.getList())) { if (pagination == null || CollectionUtils.isEmpty(pagination.getList())) {
hasMore = false; hasMore = false;
break; break;
...@@ -323,16 +323,12 @@ public class CustomerTagProfileService { ...@@ -323,16 +323,12 @@ public class CustomerTagProfileService {
* @param pageNum 页码 * @param pageNum 页码
* @return 分页结果 * @return 分页结果
*/ */
private RpcPagination<CustomerProfileInfoDTO> queryCustomerProfileInfo(int pageNum) { private RpcPagination<CustomerSimpleInfoDTO> queryCustomerProfileInfo(int pageNum) {
CustomerProfileInfoDTO queryDTO = new CustomerProfileInfoDTO(); RpcPagination<CustomerSimpleInfoDTO> pagination = new RpcPagination<>();
queryDTO.setPageNum(pageNum);
queryDTO.setPageSize(PAGE_SIZE);
RpcPagination<CustomerProfileInfoDTO> pagination = new RpcPagination<>();
pagination.setList(new ArrayList<>()); pagination.setList(new ArrayList<>());
pagination.setPageSize(PAGE_SIZE); pagination.setPageSize(PAGE_SIZE);
pagination.setPageNum(pageNum); pagination.setPageNum(pageNum);
RpcResponse<RpcPagination<CustomerProfileInfoDTO>> response = customerInfoRemote.pageCustomerProfileInfo(pagination); RpcResponse<RpcPagination<CustomerSimpleInfoDTO>> response = customerInfoRemote.pageCustomerProfileInfo(pagination);
if (response.isFailed()) { if (response.isFailed()) {
log.error("查询客户画像信息失败: {}", response.getMessage()); log.error("查询客户画像信息失败: {}", response.getMessage());
throw new RpcServiceException(response.getError(), response.getMessage()); throw new RpcServiceException(response.getError(), response.getMessage());
...@@ -346,12 +342,12 @@ public class CustomerTagProfileService { ...@@ -346,12 +342,12 @@ public class CustomerTagProfileService {
* @param dtoList 客户画像信息列表 * @param dtoList 客户画像信息列表
* @param result 同步结果统计 * @param result 同步结果统计
*/ */
private void processBatch(List<CustomerProfileInfoDTO> dtoList, SyncResult result) { private void processBatch(List<CustomerSimpleInfoDTO> dtoList, SyncResult result) {
// 收集有效的标签画像 // 收集有效的标签画像
List<CustomerTagProfile> profileList = new ArrayList<>(); List<CustomerTagProfile> profileList = new ArrayList<>();
List<String> phoneList = new ArrayList<>(); List<String> phoneList = new ArrayList<>();
for (CustomerProfileInfoDTO dto : dtoList) { for (CustomerSimpleInfoDTO dto : dtoList) {
CustomerTagProfile profile = buildCustomerTagProfile(dto, result); CustomerTagProfile profile = buildCustomerTagProfile(dto, result);
if (profile != null) { if (profile != null) {
profileList.add(profile); profileList.add(profile);
...@@ -386,7 +382,7 @@ public class CustomerTagProfileService { ...@@ -386,7 +382,7 @@ public class CustomerTagProfileService {
* @param result 同步结果统计 * @param result 同步结果统计
* @return 标签画像实体,校验不通过返回 null * @return 标签画像实体,校验不通过返回 null
*/ */
private CustomerTagProfile buildCustomerTagProfile(CustomerProfileInfoDTO dto, SyncResult result) { private CustomerTagProfile buildCustomerTagProfile(CustomerSimpleInfoDTO dto, SyncResult result) {
String phone = dto.getCustomerPhone(); String phone = dto.getCustomerPhone();
Integer carSeriesId = dto.getCarSeriesId(); Integer carSeriesId = dto.getCarSeriesId();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!