|
|
@@ -96,7 +96,6 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
private final CustomerInfoTagMapper customerInfoTagMapper;
|
|
|
private final CustomerContractMapper customerContractMapper;
|
|
|
private final CustomerDeptMapper customerDeptMapper;
|
|
|
- private final CustomerDictMapper customerDictMapper;
|
|
|
private final SupplierBusinessInfoMapper supplierBusinessInfoMapper;
|
|
|
private final TeamMemberMapper teamMemberMapper;
|
|
|
private final CrmStaffMapper crmStaffMapper;
|
|
|
@@ -138,10 +137,12 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
// 企业类型名称 (Q0001)
|
|
|
if (vo.getCustomerTypeId() != null) {
|
|
|
- CustomerDict dict = customerDictMapper.selectById(vo.getCustomerTypeId());
|
|
|
- if (dict != null) {
|
|
|
- vo.setEnterpriseTypeName(dict.getName());
|
|
|
- }
|
|
|
+ List<RemoteDictDataVo> enterpriseTypeDicts = remoteDictService.selectDictDataByType("Q0001");
|
|
|
+ String typeIdStr = String.valueOf(vo.getCustomerTypeId());
|
|
|
+ CollUtil.emptyIfNull(enterpriseTypeDicts).stream()
|
|
|
+ .filter(d -> typeIdStr.equals(d.getDictValue()))
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(d -> vo.setEnterpriseTypeName(d.getDictLabel()));
|
|
|
}
|
|
|
|
|
|
// 客户等级名称 (远程调用)
|
|
|
@@ -150,20 +151,13 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
vo.setCustomerLevelName(levelMap.get(vo.getCustomerLevelId()));
|
|
|
}
|
|
|
|
|
|
- // 合作状态名称 (COOPERATION_STATUS)
|
|
|
+ // 合作状态名称 (cooperation_status)
|
|
|
if (StringUtils.isNotBlank(vo.getStatus())) {
|
|
|
- List<CustomerDict> cooperationDicts = customerDictMapper.selectList(new LambdaQueryWrapper<CustomerDict>()
|
|
|
- .eq(CustomerDict::getCode, "COOPERATION_STATUS"));
|
|
|
- Map<String, String> cooperationMap = cooperationDicts.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- d -> {
|
|
|
- String val = d.getValue();
|
|
|
- return (val == null || val.isEmpty()) ? (d.getCodeIndex() != null ? String.valueOf(d.getCodeIndex()) : "") : val;
|
|
|
- },
|
|
|
- CustomerDict::getName,
|
|
|
- (k1, k2) -> k1
|
|
|
- ));
|
|
|
- vo.setCooperationName(cooperationMap.get(vo.getStatus()));
|
|
|
+ List<RemoteDictDataVo> cooperationDicts = remoteDictService.selectDictDataByType("cooperation_status");
|
|
|
+ CollUtil.emptyIfNull(cooperationDicts).stream()
|
|
|
+ .filter(d -> vo.getStatus().equals(d.getDictValue()))
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(d -> vo.setCooperationName(d.getDictLabel()));
|
|
|
}
|
|
|
|
|
|
// 补充省份和城市名称
|
|
|
@@ -218,18 +212,13 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
CustomerSalesInfoVo voObj = MapstructUtils.convert(customerSalesInfo, CustomerSalesInfoVo.class);
|
|
|
|
|
|
- // 补充客户来源名称 (K0001)
|
|
|
+ // 补充客户来源名称 (customer_source)
|
|
|
if (StringUtils.isNotBlank(customerSalesInfo.getCustomerSource())) {
|
|
|
- CustomerDict sourceDict = customerDictMapper.selectOne(new LambdaQueryWrapper<CustomerDict>()
|
|
|
- .eq(CustomerDict::getCode, "K0001")
|
|
|
- .eq(CustomerDict::getValue, customerSalesInfo.getCustomerSource()));
|
|
|
- if (sourceDict == null && StringUtils.isNumeric(customerSalesInfo.getCustomerSource())) {
|
|
|
- // 尝试作为 ID 查询
|
|
|
- sourceDict = customerDictMapper.selectById(Long.parseLong(customerSalesInfo.getCustomerSource()));
|
|
|
- }
|
|
|
- if (sourceDict != null) {
|
|
|
- vo.setCustomerSourceName(sourceDict.getName());
|
|
|
- }
|
|
|
+ List<RemoteDictDataVo> sourceDicts = remoteDictService.selectDictDataByType("customer_source");
|
|
|
+ sourceDicts.stream()
|
|
|
+ .filter(d -> customerSalesInfo.getCustomerSource().equals(d.getDictValue()))
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(d -> vo.setCustomerSourceName(d.getDictLabel()));
|
|
|
}
|
|
|
|
|
|
// 补充人员和部门名称
|
|
|
@@ -407,8 +396,9 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
? Collections.emptyMap()
|
|
|
: remoteComCompanyService.selectCompanyNameByIds(companyIds);
|
|
|
|
|
|
- Map<Long, RemoteComStaffVo> staffFullMap = staffIds.isEmpty() ? Collections.emptyMap() :
|
|
|
- remoteComStaffService.selectStaffByIds(staffIds).stream().collect(Collectors.toMap(RemoteComStaffVo::getStaffId, Function.identity(), (k1, k2) -> k1));
|
|
|
+ List<RemoteComStaffVo> staffVos = staffIds.isEmpty() ? Collections.emptyList() : remoteComStaffService.selectStaffByIds(staffIds);
|
|
|
+ Map<Long, RemoteComStaffVo> staffFullMap = CollUtil.isEmpty(staffVos) ? Collections.emptyMap() :
|
|
|
+ staffVos.stream().collect(Collectors.toMap(RemoteComStaffVo::getStaffId, Function.identity(), (k1, k2) -> k1));
|
|
|
|
|
|
// === 6. 回填人员和部门名称到 vo ===
|
|
|
for (CustomerInfoVo vo : records) {
|
|
|
@@ -610,7 +600,6 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
Set<Long> staffIds = new HashSet<>();
|
|
|
Set<Long> creditLevelIds = new HashSet<>();
|
|
|
Set<Long> companyIds = new HashSet<>();
|
|
|
- Set<Long> enterpriseTypeIds = new HashSet<>();
|
|
|
Set<Long> customerLevelIds = new HashSet<>();
|
|
|
Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
|
@@ -622,7 +611,6 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
if (vo.getCreditLevelId() != null) creditLevelIds.add(vo.getCreditLevelId());
|
|
|
}
|
|
|
if (vo.getBelongCompanyId() != null) companyIds.add(vo.getBelongCompanyId());
|
|
|
- if (vo.getEnterpriseTypeId() != null) enterpriseTypeIds.add(vo.getEnterpriseTypeId());
|
|
|
if (vo.getCustomerLevelId() != null) customerLevelIds.add(vo.getCustomerLevelId());
|
|
|
|
|
|
// 处理部门ID收集
|
|
|
@@ -640,10 +628,10 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
// 3. 批量查询公司名称 (远程调用)
|
|
|
Map<Long, String> companyMap = companyIds.isEmpty() ? Collections.emptyMap() : remoteComCompanyService.selectCompanyNameByIds(companyIds);
|
|
|
|
|
|
- // 4. 批量查询企业类型名称 (从客户字典表查询)
|
|
|
- Map<Long, String> enterpriseTypeMap = enterpriseTypeIds.isEmpty() ? Collections.emptyMap() :
|
|
|
- customerDictMapper.selectList(new LambdaQueryWrapper<CustomerDict>().in(CustomerDict::getId, enterpriseTypeIds)).stream()
|
|
|
- .collect(Collectors.toMap(d -> Long.valueOf(d.getId()), CustomerDict::getName, (k1, k2) -> k1));
|
|
|
+ // 4. 批量查询企业类型名称 (优先系统字典)
|
|
|
+ List<RemoteDictDataVo> enterpriseTypeDicts = remoteDictService.selectDictDataByType("enterprise_type");
|
|
|
+ Map<String, String> enterpriseTypeMap = enterpriseTypeDicts == null ? Collections.emptyMap() : enterpriseTypeDicts.stream()
|
|
|
+ .collect(Collectors.toMap(RemoteDictDataVo::getDictValue, RemoteDictDataVo::getDictLabel, (k1, k2) -> k1));
|
|
|
|
|
|
// 5. 批量查询客户/合作等级名称 (远程调用)
|
|
|
Map<Long, String> customerLevelMap = customerLevelIds.isEmpty() ? Collections.emptyMap() : remoteComCustomerLevelService.selectCustomerLevelNameByIds(customerLevelIds);
|
|
|
@@ -651,18 +639,10 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
// 6. 批量查询部门名称 (系统部门)
|
|
|
Map<Long, String> deptMap = deptIds.isEmpty() ? Collections.emptyMap() : remoteDeptService.selectDeptNameByIds(deptIds);
|
|
|
|
|
|
- // 7. 批量查询合作状态名称 (从客户字典表查询 code='COOPERATION_STATUS')
|
|
|
- List<CustomerDict> cooperationDicts = customerDictMapper.selectList(new LambdaQueryWrapper<CustomerDict>()
|
|
|
- .eq(CustomerDict::getCode, "COOPERATION_STATUS"));
|
|
|
- Map<String, String> cooperationMap = cooperationDicts.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- d -> {
|
|
|
- String val = d.getValue();
|
|
|
- return (val == null || val.isEmpty()) ? (d.getCodeIndex() != null ? String.valueOf(d.getCodeIndex()) : "") : val;
|
|
|
- },
|
|
|
- CustomerDict::getName,
|
|
|
- (k1, k2) -> k1
|
|
|
- ));
|
|
|
+ // 7. 批量查询合作状态名称 (优先系统字典)
|
|
|
+ List<RemoteDictDataVo> cooperationDicts = remoteDictService.selectDictDataByType("cooperation_status");
|
|
|
+ Map<String, String> cooperationMap = cooperationDicts == null ? Collections.emptyMap() : cooperationDicts.stream()
|
|
|
+ .collect(Collectors.toMap(RemoteDictDataVo::getDictValue, RemoteDictDataVo::getDictLabel, (k1, k2) -> k1));
|
|
|
|
|
|
// 8. 填充数据
|
|
|
records.forEach(vo -> {
|
|
|
@@ -674,11 +654,15 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
}
|
|
|
vo.setCreditLevelName(creditLevelMap.get(vo.getCreditLevelId()));
|
|
|
vo.setCompanyName(companyMap.get(vo.getBelongCompanyId()));
|
|
|
- vo.setEnterpriseTypeName(enterpriseTypeMap.get(vo.getEnterpriseTypeId()));
|
|
|
+
|
|
|
+ // 企业类型翻译
|
|
|
+ String typeValue = vo.getEnterpriseTypeId() != null ? String.valueOf(vo.getEnterpriseTypeId()) : null;
|
|
|
+ vo.setEnterpriseTypeName(enterpriseTypeMap.get(typeValue));
|
|
|
+
|
|
|
vo.setCustomerLevelName(customerLevelMap.get(vo.getCustomerLevelId()));
|
|
|
- vo.setCooperationName(cooperationMap.get(vo.getStatus()));
|
|
|
|
|
|
- // 部门名称已在 Mapper 中通过业务负责人关联查询,此处无需再回填覆盖
|
|
|
+ // 合作状态翻译
|
|
|
+ vo.setCooperationName(cooperationMap.get(vo.getStatus()));
|
|
|
});
|
|
|
}
|
|
|
|