|
|
@@ -172,6 +172,33 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
vo.setCustomerSalesInfoVo(voObj);
|
|
|
|
|
|
+ Set<Long> comStaffIds = new HashSet<>();
|
|
|
+ Set<Long> comDeptIds = new HashSet<>(); //系统的部门
|
|
|
+
|
|
|
+ if (vo.getSalesPersonId() != null) {
|
|
|
+ comStaffIds.add(customerSalesInfo.getSalesPersonId());
|
|
|
+ }
|
|
|
+ if (vo.getServiceStaffId() != null) {
|
|
|
+ comStaffIds.add(customerSalesInfo.getServiceStaffId());
|
|
|
+ }
|
|
|
+ if (vo.getBelongingDepartmentId() != null) {
|
|
|
+ comDeptIds.add(customerSalesInfo.getBelongingDepartmentId());
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, String> comStaffMap = staffIds.isEmpty()
|
|
|
+ ? Collections.emptyMap()
|
|
|
+ : remoteComStaffService.selectStaffNameByIds(staffIds);
|
|
|
+
|
|
|
+ Map<Long, String> comDeptMap = deptIds.isEmpty()//系统的部门
|
|
|
+ ? Collections.emptyMap()
|
|
|
+ : remoteDeptService.selectDeptNameByIds(deptIds);
|
|
|
+
|
|
|
+ /*回填系统的人员与部门*/
|
|
|
+ vo.setSalesPersonName(comStaffMap.get(vo.getSalesPersonId()));
|
|
|
+ vo.setServiceStaffName(comStaffMap.get(vo.getServiceStaffId()));
|
|
|
+ vo.setBelongingDepartmentName(comDeptMap.get(vo.getBelongingDepartmentId()));
|
|
|
+
|
|
|
+
|
|
|
List<CustomerContact> contactEntities = customerContactMapper.selectListByCustomerId(id);
|
|
|
vo.setCustomerContactVoList(
|
|
|
contactEntities != null
|
|
|
@@ -239,6 +266,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
IndustryCategoryVo::getIndustryCategoryName,
|
|
|
(e, r) -> e
|
|
|
));
|
|
|
+ records.forEach(vo -> vo.setIndustryCategory(industryMap.get(vo.getIndustryCategoryId())));
|
|
|
}
|
|
|
|
|
|
// === 2. 提取客户ID,查询销售信息 ===
|
|
|
@@ -278,6 +306,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
(existing, replacement) -> existing // 若有重复,保留第一个
|
|
|
));
|
|
|
|
|
|
+ // === 4. 收集人员和部门ID ===
|
|
|
Set<Long> staffIds = new HashSet<>();
|
|
|
Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
|
@@ -305,6 +334,31 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
vo.setServiceStaff(staffMap.get(vo.getServiceStaffId()));
|
|
|
vo.setBelongingDepartment(deptMap.get(vo.getBelongingDepartmentId()));
|
|
|
}
|
|
|
+ //系统人员与部门
|
|
|
+ Set<Long> comStaffIds = new HashSet<>();
|
|
|
+ Set<Long> comDeptIds = new HashSet<>();
|
|
|
+
|
|
|
+ for (CustomerInfoVo vo : records) {
|
|
|
+ if (vo.getSalesPersonId() != null) comStaffIds.add(vo.getSalesPersonId());
|
|
|
+ if (vo.getServiceStaffId() != null) comStaffIds.add(vo.getServiceStaffId());
|
|
|
+ if (vo.getBelongingDepartmentId() != null) comDeptIds.add(vo.getBelongingDepartmentId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // === 远程调用获取名称 ===
|
|
|
+ Map<Long, String> comStaffMap = staffIds.isEmpty()
|
|
|
+ ? Collections.emptyMap()
|
|
|
+ : remoteComStaffService.selectStaffNameByIds(comStaffIds);
|
|
|
+
|
|
|
+ Map<Long, String> comDeptMap = deptIds.isEmpty()
|
|
|
+ ? Collections.emptyMap()
|
|
|
+ : remoteDeptService.selectDeptNameByIds(comDeptIds);
|
|
|
+
|
|
|
+ // === 回填系统人员和部门名称到 customerInfoVo ===
|
|
|
+ records.forEach(v -> {
|
|
|
+ v.setSalesPersonName(comStaffMap.get(v.getSalesPersonId()));
|
|
|
+ v.setServiceStaffName(comStaffMap.get(v.getServiceStaffId()));
|
|
|
+ v.setBelongingDepartmentName(comDeptMap.get(v.getBelongingDepartmentId()));
|
|
|
+ });
|
|
|
|
|
|
// === 7. 将销售信息回填到客户VO ===
|
|
|
for (CustomerInfoVo customerVo : records) {
|
|
|
@@ -471,6 +525,10 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
*/
|
|
|
@Override
|
|
|
public TableDataInfo<CustomerListVo> queryCustomerListPage(CustomerListBo bo, PageQuery pageQuery) {
|
|
|
+ // 设置平台标识(暂时注释掉)
|
|
|
+ // if (StringUtils.isBlank(bo.getPlatformCode())) {
|
|
|
+ // bo.setPlatformCode(PlatformContext.getPlatform());
|
|
|
+ // }
|
|
|
Page<CustomerListVo> page = baseMapper.selectCustomerListPage(pageQuery.build(), bo);
|
|
|
|
|
|
// 补充业务员名称和信用等级名称
|
|
|
@@ -561,6 +619,9 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
lqw.orderByDesc(CustomerInfo::getId);
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getCustomerNo()), CustomerInfo::getCustomerNo, bo.getCustomerNo());
|
|
|
lqw.eq(bo.getBelongCompanyId() != null, CustomerInfo::getBelongCompanyId, bo.getBelongCompanyId());
|
|
|
+ lqw.eq(bo.getSalesPersonId() != null, CustomerInfo::getSalesPersonId, bo.getSalesPersonId());
|
|
|
+ lqw.eq(bo.getServiceStaffId() != null, CustomerInfo::getServiceStaffId, bo.getServiceStaffId());
|
|
|
+ lqw.eq(bo.getBelongingDepartmentId() != null, CustomerInfo::getBelongingDepartmentId, bo.getBelongingDepartmentId());
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getCompanyName()), CustomerInfo::getCompanyName, bo.getCompanyName());
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getCustomerName()), CustomerInfo::getCustomerName, bo.getCustomerName());
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getBusinessCustomerName()), CustomerInfo::getBusinessCustomerName, bo.getBusinessCustomerName());
|
|
|
@@ -1208,25 +1269,25 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- List<CustomerSalesInfo> updateList = new ArrayList<>();
|
|
|
- CustomerSalesInfo salesInfo = null;
|
|
|
+ List<CustomerInfo> updateList = new ArrayList<>();
|
|
|
+ CustomerInfo customerInfo = null;
|
|
|
for (Long customerId : customerIds) {
|
|
|
if (customerId == null) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- salesInfo = customerSalesInfoMapper.selectByCustomerId(customerId);
|
|
|
- if (salesInfo != null) {
|
|
|
- salesInfo.setSalesPersonId(salesPersonId);
|
|
|
- salesInfo.setBelongingDepartmentId(deptId);
|
|
|
- updateList.add(salesInfo);
|
|
|
+ customerInfo = baseMapper.selectById(customerId);
|
|
|
+ if (customerInfo != null) {
|
|
|
+ customerInfo.setSalesPersonId(salesPersonId);
|
|
|
+ customerInfo.setBelongingDepartmentId(deptId);
|
|
|
+ updateList.add(customerInfo);
|
|
|
} else {
|
|
|
log.warn("客户 ID: {} 的销售信息不存在,跳过更新", customerId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!updateList.isEmpty()) {
|
|
|
- boolean success = customerSalesInfoMapper.updateBatchById(updateList);
|
|
|
+ boolean success = baseMapper.updateBatchById(updateList);
|
|
|
if (success) {
|
|
|
log.info("成功转移 {} 个客户的业务人员,目标业务员 ID: {}, 部门 ID: {}",
|
|
|
updateList.size(), salesPersonId, deptId);
|
|
|
@@ -1261,24 +1322,24 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- List<CustomerSalesInfo> updateList = new ArrayList<>();
|
|
|
- CustomerSalesInfo salesInfo = null;
|
|
|
+ List<CustomerInfo> updateList = new ArrayList<>();
|
|
|
+ CustomerInfo customerInfo = null;
|
|
|
for (Long customerId : customerIds) {
|
|
|
if (customerId == null) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- salesInfo = customerSalesInfoMapper.selectByCustomerId(customerId);
|
|
|
- if (salesInfo != null) {
|
|
|
- salesInfo.setServiceStaffId(serviceStaffId);
|
|
|
- updateList.add(salesInfo);
|
|
|
+ customerInfo = baseMapper.selectById(customerId);
|
|
|
+ if (customerInfo != null) {
|
|
|
+ customerInfo.setServiceStaffId(serviceStaffId);
|
|
|
+ updateList.add(customerInfo);
|
|
|
} else {
|
|
|
log.warn("客户 ID: {} 的销售信息不存在,跳过更新", customerId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!updateList.isEmpty()) {
|
|
|
- boolean success = customerSalesInfoMapper.updateBatchById(updateList);
|
|
|
+ boolean success = baseMapper.updateBatchById(updateList);
|
|
|
if (success) {
|
|
|
log.info("成功转移 {} 个客户的客服人员,目标客服人员 ID: {}",
|
|
|
updateList.size(), serviceStaffId);
|