|
@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 客户转移审批Service业务层处理
|
|
* 客户转移审批Service业务层处理
|
|
@@ -127,6 +128,50 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp
|
|
|
return item;
|
|
return item;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<Long, List<Long>> selectCustomerTransferApprovalListByCustomerId(Long[] ids) {
|
|
|
|
|
+ List<CustomerTransferApproval> customerTransferApprovals = customerTransferApprovalMapper.selectCustomerTransferApprovalByIds(ids);
|
|
|
|
|
+ Map<Long, List<Long>> groupedUserIds = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (CustomerTransferApproval approval : customerTransferApprovals) {
|
|
|
|
|
+ // 从 transferBefore 中解析 beforeCompanyUserId 列表
|
|
|
|
|
+ Set<Long> beforeCompanyUserIds = new HashSet<>(); // 使用Set去重
|
|
|
|
|
+ if (StringUtils.isNotEmpty(approval.getTransferBefore())) {
|
|
|
|
|
+ List<TransferCustomDTO> transferBeforeList = JSON.parseArray(approval.getTransferBefore(), TransferCustomDTO.class);
|
|
|
|
|
+ for (TransferCustomDTO transferData : transferBeforeList) {
|
|
|
|
|
+ if (transferData != null && transferData.getBeforeCompanyUserId() != null) {
|
|
|
|
|
+ beforeCompanyUserIds.add(transferData.getBeforeCompanyUserId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 从 customerIds 中解析 userId 列表
|
|
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
|
|
+ if (StringUtils.isNotEmpty(approval.getCustomerIds())) {
|
|
|
|
|
+ List<UserProjectDTO> customerIds = JSON.parseArray(approval.getCustomerIds(), UserProjectDTO.class);
|
|
|
|
|
+ for (UserProjectDTO customer : customerIds) {
|
|
|
|
|
+ if (customer != null && customer.getUserId() != null) {
|
|
|
|
|
+ userIds.add(customer.getUserId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 将 userIds 按照 beforeCompanyUserIds 进行分组,避免覆盖
|
|
|
|
|
+ for (Long beforeCompanyUserId : beforeCompanyUserIds) {
|
|
|
|
|
+ groupedUserIds.computeIfAbsent(beforeCompanyUserId, k -> new ArrayList<>())
|
|
|
|
|
+ .addAll(userIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 对每个分组中的 userId 进行去重
|
|
|
|
|
+ for (Map.Entry<Long, List<Long>> entry : groupedUserIds.entrySet()) {
|
|
|
|
|
+ List<Long> uniqueUserIds = entry.getValue().stream().distinct().collect(Collectors.toList());
|
|
|
|
|
+ entry.setValue(uniqueUserIds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return groupedUserIds;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private List<TransferCustomDTO> getCustomerList(List<UserProjectDTO> customerIds, CustomerTransferApproval item) {
|
|
private List<TransferCustomDTO> getCustomerList(List<UserProjectDTO> customerIds, CustomerTransferApproval item) {
|
|
|
if (CollectionUtils.isEmpty(customerIds) || item == null) {
|
|
if (CollectionUtils.isEmpty(customerIds) || item == null) {
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|