|
@@ -21,6 +21,7 @@ import com.fs.qw.service.ICustomerTransferApprovalService;
|
|
|
import com.fs.qw.vo.TransferCustomDTO;
|
|
import com.fs.qw.vo.TransferCustomDTO;
|
|
|
import com.fs.store.service.cache.IFsUserCacheService;
|
|
import com.fs.store.service.cache.IFsUserCacheService;
|
|
|
import com.hc.openapi.tool.util.StringUtils;
|
|
import com.hc.openapi.tool.util.StringUtils;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.hc.core5.util.Asserts;
|
|
import org.apache.hc.core5.util.Asserts;
|
|
|
import org.springframework.aop.framework.AopContext;
|
|
import org.springframework.aop.framework.AopContext;
|
|
@@ -30,10 +31,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 客户转移审批Service业务层处理
|
|
* 客户转移审批Service业务层处理
|
|
@@ -41,6 +39,7 @@ import java.util.Objects;
|
|
|
* @author fs
|
|
* @author fs
|
|
|
* @date 2025-04-01
|
|
* @date 2025-04-01
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
@EnableAspectJAutoProxy(proxyTargetClass = true,exposeProxy = true)
|
|
@EnableAspectJAutoProxy(proxyTargetClass = true,exposeProxy = true)
|
|
|
public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApprovalService
|
|
public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApprovalService
|
|
@@ -129,35 +128,74 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private List<TransferCustomDTO> getCustomerList(List<UserProjectDTO> customerIds, CustomerTransferApproval item) {
|
|
private List<TransferCustomDTO> getCustomerList(List<UserProjectDTO> customerIds, CustomerTransferApproval item) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(customerIds) || item == null) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
List<TransferCustomDTO> customerList = new ArrayList<>();
|
|
List<TransferCustomDTO> customerList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (UserProjectDTO customerId : customerIds) {
|
|
for (UserProjectDTO customerId : customerIds) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (customerId == null || customerId.getUserId() == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ FsUser fsUser = fsUserCacheService.selectFsUserById(customerId.getUserId());
|
|
|
|
|
+ if (ObjectUtils.isNotNull(fsUser)) {
|
|
|
|
|
+ FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(
|
|
|
|
|
+ customerId.getUserId(), customerId.getProjectId());
|
|
|
|
|
|
|
|
- FsUser fsUser = fsUserCacheService.selectFsUserById(customerId.getUserId());
|
|
|
|
|
- if(ObjectUtils.isNotNull(fsUser)){
|
|
|
|
|
- FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(customerId.getUserId(), customerId.getProjectId());
|
|
|
|
|
- if(Objects.nonNull(userCompanyUser)){
|
|
|
|
|
- CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(userCompanyUser.getCompanyUserId());
|
|
|
|
|
- String companyUserName = String.format("%s_%d", companyUser.getUserName(), companyUser.getUserId());
|
|
|
|
|
-
|
|
|
|
|
- CompanyUser afterCompanyUser = companyUserCacheService.selectCompanyUserById(item.getTargetUserId());
|
|
|
|
|
- String afterCompanyUserName = String.format("%s_%d", afterCompanyUser.getUserName(), companyUser.getUserId());
|
|
|
|
|
-
|
|
|
|
|
- customerList.add(TransferCustomDTO.builder()
|
|
|
|
|
- .userName(String.format("%s_%d", fsUser.getNickName(), fsUser.getUserId()))
|
|
|
|
|
- .userId(fsUser.getUserId())
|
|
|
|
|
- .projectId(customerId.getProjectId())
|
|
|
|
|
- .beforeCompanyUserName(companyUserName)
|
|
|
|
|
- .beforeCompanyUserId(companyUser.getUserId())
|
|
|
|
|
- .afterCompanyUserName(afterCompanyUserName)
|
|
|
|
|
- .afterCompanyUserId(item.getTargetUserId())
|
|
|
|
|
- .build());
|
|
|
|
|
|
|
+ if (Objects.nonNull(userCompanyUser) && userCompanyUser.getCompanyUserId() != null) {
|
|
|
|
|
+ processCompanyUserData(customerList, fsUser, userCompanyUser, customerId, item);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("处理客户数据异常: customerId={}", customerId, e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return customerList;
|
|
return customerList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void processCompanyUserData(List<TransferCustomDTO> customerList, FsUser fsUser,
|
|
|
|
|
+ FsUserCompanyUser userCompanyUser, UserProjectDTO customerId,
|
|
|
|
|
+ CustomerTransferApproval item) {
|
|
|
|
|
+ CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(userCompanyUser.getCompanyUserId());
|
|
|
|
|
+ if (Objects.isNull(companyUser)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CompanyUser afterCompanyUser = companyUserCacheService.selectCompanyUserById(item.getTargetUserId());
|
|
|
|
|
+ if (Objects.isNull(afterCompanyUser)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String companyUserName = safeFormat("%s_%d", companyUser.getUserName(), companyUser.getUserId());
|
|
|
|
|
+ String afterCompanyUserName = safeFormat("%s_%d", afterCompanyUser.getUserName(), afterCompanyUser.getUserId());
|
|
|
|
|
+ String fsUserName = safeFormat("%s_%d", fsUser.getNickName(), fsUser.getUserId());
|
|
|
|
|
+
|
|
|
|
|
+ customerList.add(TransferCustomDTO.builder()
|
|
|
|
|
+ .userName(fsUserName)
|
|
|
|
|
+ .userId(fsUser.getUserId())
|
|
|
|
|
+ .projectId(customerId.getProjectId())
|
|
|
|
|
+ .beforeCompanyUserName(companyUserName)
|
|
|
|
|
+ .beforeCompanyUserId(companyUser.getUserId())
|
|
|
|
|
+ .afterCompanyUserName(afterCompanyUserName)
|
|
|
|
|
+ .afterCompanyUserId(item.getTargetUserId())
|
|
|
|
|
+ .build());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String safeFormat(String format, Object... args) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ Object[] safeArgs = Arrays.stream(args)
|
|
|
|
|
+ .map(arg -> Objects.toString(arg, ""))
|
|
|
|
|
+ .toArray();
|
|
|
|
|
+ return String.format(format, safeArgs);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("字符串格式化异常: format={}, args={}", format, Arrays.toString(args), e);
|
|
|
|
|
+ return Arrays.toString(args);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询客户转移审批列表
|
|
* 查询客户转移审批列表
|
|
|
*
|
|
*
|