完善 Excel 导入模版下拉选择生成实现

This commit is contained in:
puhui999
2024-02-24 11:40:58 +08:00
parent e53a0ca884
commit 5dc1dbb3b2
8 changed files with 102 additions and 85 deletions

View File

@ -10,6 +10,7 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.enums.ExcelColumn;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.ip.core.Area;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
@ -268,21 +269,21 @@ public class CrmCustomerController {
ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list, builderSelectMap());
}
private List<KeyValue<Integer, List<String>>> builderSelectMap() {
List<KeyValue<Integer, List<String>>> selectMap = new ArrayList<>();
private List<KeyValue<ExcelColumn, List<String>>> builderSelectMap() {
List<KeyValue<ExcelColumn, List<String>>> selectMap = new ArrayList<>();
// 获取地区下拉数据
// TODO @puhui999嘿嘿这里改成省份、城市、区域三个选项难度大么
Area area = AreaUtils.parseArea(Area.ID_CHINA);
selectMap.add(new KeyValue<>(6, AreaUtils.getAreaNodePathList(area.getChildren())));
selectMap.add(new KeyValue<>(ExcelColumn.G, AreaUtils.getAreaNodePathList(area.getChildren())));
// 获取客户所属行业
List<String> customerIndustries = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY);
selectMap.add(new KeyValue<>(8, customerIndustries));
selectMap.add(new KeyValue<>(ExcelColumn.I, customerIndustries));
// 获取客户等级
List<String> customerLevels = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL);
selectMap.add(new KeyValue<>(9, customerLevels));
selectMap.add(new KeyValue<>(ExcelColumn.J, customerLevels));
// 获取客户来源
List<String> customerSources = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE);
selectMap.add(new KeyValue<>(10, customerSources));
selectMap.add(new KeyValue<>(ExcelColumn.K, customerSources));
return selectMap;
}

View File

@ -41,6 +41,7 @@ import java.time.LocalDateTime;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_LOCK_LIMIT;
@ -203,7 +204,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
// 2.1 数据权限转移
permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
// 2.2 转移后重新设置负责人
customerMapper.updateById(new CrmCustomerDO().setId(reqVO.getId())
.setOwnerUserId(reqVO.getNewOwnerUserId()).setOwnerTime(LocalDateTime.now()));
@ -260,6 +261,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
if (CollUtil.isEmpty(importCustomers)) {
throw exception(CUSTOMER_IMPORT_LIST_IS_EMPTY);
}
// 因为有下拉所以需要过滤掉空行
importCustomers = filterList(importCustomers, item -> Objects.nonNull(item.getName()));
CrmCustomerImportRespVO respVO = CrmCustomerImportRespVO.builder().createCustomerNames(new ArrayList<>())
.updateCustomerNames(new ArrayList<>()).failureCustomerNames(new LinkedHashMap<>()).build();
importCustomers.forEach(importCustomer -> {

View File

@ -70,11 +70,10 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
validateRelationDataExists(createReqVO);
// 1.2 查验关联合同回款数量
Long count = receivableService.getReceivableCountByContractId(createReqVO.getContractId());
int period = (int) (count + 1);
createReqVO.setPeriod(createReqVO.getPeriod() != period ? period : createReqVO.getPeriod()); // 如果期数不对则纠正
// 2. 插入还款计划
CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class).setId(null).setFinishStatus(false);
CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class).setId(null)
.setPeriod((int) (count + 1)).setFinishStatus(false);
receivablePlanMapper.insert(receivablePlan);
// 3. 创建数据权限

View File

@ -67,7 +67,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
private CrmContractService contractService;
@Resource
private CrmCustomerService customerService;
// @Resource
@Resource
@Lazy // 延迟加载,避免循环依赖
private CrmReceivablePlanService receivablePlanService;
@Resource