diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/annotations/ExcelColumnSelect.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/annotations/ExcelColumnSelect.java new file mode 100644 index 000000000..2c519523b --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/annotations/ExcelColumnSelect.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.framework.excel.core.annotations; + +import java.lang.annotation.*; + +/** + * 给列添加下拉选择数据 + * + * @author HUIHUI + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Inherited +public @interface ExcelColumnSelect { + + /** + * @return 获取下拉数据源的方法名称 + */ + String value(); + +} diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/enums/ExcelColumn.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/enums/ExcelColumn.java deleted file mode 100644 index dd8a8374c..000000000 --- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/enums/ExcelColumn.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.framework.excel.core.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -// TODO @puhui999:列表有办法通过 field name 么?主要考虑一个点,可能导入模版的顺序可能会变 -/** - * Excel 列名枚举 - * 默认枚举 26 列列名如果有需求更多的列名请自行补充 - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum ExcelColumn { - - A(0), B(1), C(2), D(3), E(4), F(5), G(6), H(7), I(8), - J(9), K(10), L(11), M(12), N(13), O(14), P(15), Q(16), - R(17), S(18), T(19), U(20), V(21), W(22), X(23), Y(24), - Z(25); - - /** - * 列索引 - */ - private final int colNum; - -} diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/SelectSheetWriteHandler.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/SelectSheetWriteHandler.java index 38d01bd87..421c59200 100644 --- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/SelectSheetWriteHandler.java +++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/SelectSheetWriteHandler.java @@ -1,9 +1,12 @@ package cn.iocoder.yudao.framework.excel.core.handler; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapUtil; +import cn.hutool.extra.spring.SpringUtil; import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.excel.core.enums.ExcelColumn; +import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; +import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.write.handler.SheetWriteHandler; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; @@ -11,10 +14,11 @@ import org.apache.poi.hssf.usermodel.HSSFDataValidation; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddressList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.util.*; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; /** * 基于固定 sheet 实现下拉框 @@ -23,6 +27,9 @@ import java.util.stream.Collectors; */ public class SelectSheetWriteHandler implements SheetWriteHandler { + private static final List ALPHABET = getExcelColumnNameList(); + private static final List EXCEL_COLUMN_SELECT_DATA_SERVICES = new ArrayList<>(); + /** * 数据起始行从 0 开始 * @@ -36,21 +43,46 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { private static final String DICT_SHEET_NAME = "字典sheet"; - // TODO @puhui999:Map> 可以么?之前用 keyvalue 的原因,返回给前端,无法用 linkedhashmap,默认 key 会乱序 - private final List>> selectMap; + private final List>> selectMap = new ArrayList<>(); // 使用 List + KeyValue 组合方便排序 - public SelectSheetWriteHandler(List>> selectMap) { - if (CollUtil.isEmpty(selectMap)) { - this.selectMap = null; + public SelectSheetWriteHandler(Class head) { + // 加载下拉数据获取接口 + Map beansMap = SpringUtil.getBeanFactory().getBeansOfType(ExcelColumnSelectDataService.class); + if (MapUtil.isEmpty(beansMap)) { return; } - // 校验一下 key 是否唯一 - Map nameCounts = selectMap.stream() - .collect(Collectors.groupingBy(item -> item.getKey().name(), Collectors.counting())); - Assert.isFalse(nameCounts.entrySet().stream().allMatch(entry -> entry.getValue() > 1), "下拉数据 key 重复请排查!!!"); - + if (CollUtil.isEmpty(EXCEL_COLUMN_SELECT_DATA_SERVICES) || EXCEL_COLUMN_SELECT_DATA_SERVICES.size() != beansMap.values().size()) { + EXCEL_COLUMN_SELECT_DATA_SERVICES.clear(); + EXCEL_COLUMN_SELECT_DATA_SERVICES.addAll(convertList(beansMap.values(), b -> b)); + } + // 解析下拉数据 + Map excelPropertyFields = getFieldsWithAnnotation(head, ExcelProperty.class); + Map excelColumnSelectFields = getFieldsWithAnnotation(head, ExcelColumnSelect.class); + int colIndex = 0; + for (String fieldName : excelPropertyFields.keySet()) { + Field field = excelColumnSelectFields.get(fieldName); + if (field != null) { + getSelectDataList(colIndex, field); + } + colIndex++; + } selectMap.sort(Comparator.comparing(item -> item.getValue().size())); // 升序不然创建下拉会报错 - this.selectMap = selectMap; + } + + /** + * 获得下拉数据 + * + * @param colIndex 列索引 + * @param field 字段 + */ + private void getSelectDataList(int colIndex, Field field) { + EXCEL_COLUMN_SELECT_DATA_SERVICES.forEach(selectDataService -> { + List stringList = selectDataService.handle(field.getAnnotation(ExcelColumnSelect.class).value()); + if (CollUtil.isEmpty(stringList)) { + return; + } + selectMap.add(new KeyValue<>(colIndex, stringList)); + }); } @Override @@ -65,7 +97,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { // 2. 创建数据字典的 sheet 页 Sheet dictSheet = workbook.createSheet(DICT_SHEET_NAME); - for (KeyValue> keyValue : selectMap) { + for (KeyValue> keyValue : selectMap) { int rowLength = keyValue.getValue().size(); // 2.1 设置字典 sheet 页的值 每一列一个字典项 for (int i = 0; i < rowLength; i++) { @@ -73,7 +105,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { if (row == null) { row = dictSheet.createRow(i); } - row.createCell(keyValue.getKey().getColNum()).setCellValue(keyValue.getValue().get(i)); + row.createCell(keyValue.getKey()).setCellValue(keyValue.getValue().get(i)); } // 2.2 设置单元格下拉选择 setColumnSelect(writeSheetHolder, workbook, helper, keyValue); @@ -84,10 +116,10 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { * 设置单元格下拉选择 */ private static void setColumnSelect(WriteSheetHolder writeSheetHolder, Workbook workbook, DataValidationHelper helper, - KeyValue> keyValue) { + KeyValue> keyValue) { // 1.1 创建可被其他单元格引用的名称 Name name = workbook.createName(); - String excelColumn = keyValue.getKey().name(); + String excelColumn = ALPHABET.get(keyValue.getKey()); // 1.2 下拉框数据来源 eg:字典sheet!$B1:$B2 String refers = DICT_SHEET_NAME + "!$" + excelColumn + "$1:$" + excelColumn + "$" + keyValue.getValue().size(); name.setNameName("dict" + keyValue.getKey()); // 设置名称的名字 @@ -97,7 +129,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { DataValidationConstraint constraint = helper.createFormulaListConstraint("dict" + keyValue.getKey()); // 设置引用约束 // 设置下拉单元格的首行、末行、首列、末列 CellRangeAddressList rangeAddressList = new CellRangeAddressList(FIRST_ROW, LAST_ROW, - keyValue.getKey().getColNum(), keyValue.getKey().getColNum()); + keyValue.getKey(), keyValue.getKey()); DataValidation validation = helper.createValidation(constraint, rangeAddressList); if (validation instanceof HSSFDataValidation) { validation.setSuppressDropDownArrow(false); @@ -112,4 +144,28 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { writeSheetHolder.getSheet().addValidationData(validation); } + public static Map getFieldsWithAnnotation(Class clazz, Class annotationClass) { + Map annotatedFields = new LinkedHashMap<>(); + Field[] fields = clazz.getDeclaredFields(); + for (Field field : fields) { + if (field.isAnnotationPresent(annotationClass)) { + annotatedFields.put(field.getName(), field); + } + } + return annotatedFields; + } + + + private static List getExcelColumnNameList() { + ArrayList strings = new ArrayList<>(); + for (int i = 1; i <= 52; i++) { // 生成 52 列名称,需要更多请重写此方法 + if (i <= 26) { + strings.add(String.valueOf((char) ('A' + i - 1))); // 使用 ASCII 码值转字母 + } else { + strings.add(String.valueOf((char) ('A' + (i - 1) / 26 - 1)) + (char) ('A' + (i - 1) % 26)); + } + } + return strings; + } + } \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/service/ExcelColumnSelectDataService.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/service/ExcelColumnSelectDataService.java new file mode 100644 index 000000000..987cf7929 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/service/ExcelColumnSelectDataService.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.framework.excel.core.service; + +import cn.hutool.core.util.StrUtil; + +import java.util.Collections; +import java.util.List; + +/** + * Excel 列下拉数据源获取接口 + * + * 为什么不直接解析字典还搞个接口?考虑到有的下拉数据不是从字典中获取的所有需要做一个兼容 + * + * @author HUIHUI + */ +public interface ExcelColumnSelectDataService { + + /** + * 获得方法名称 + * + * @return 方法名称 + */ + String getFunctionName(); + + /** + * 获得列下拉数据源 + * + * @return 下拉数据源 + */ + List getSelectDataList(); + + default List handle(String funcName) { + if (StrUtil.isEmptyIfStr(funcName) || !StrUtil.equals(getFunctionName(), funcName)) { + return Collections.emptyList(); + } + return getSelectDataList(); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java index 81d9a8a97..f5c4b8313 100644 --- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java @@ -1,7 +1,5 @@ package cn.iocoder.yudao.framework.excel.core.util; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.excel.core.enums.ExcelColumn; import cn.iocoder.yudao.framework.excel.core.handler.SelectSheetWriteHandler; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.converters.longconverter.LongStringConverter; @@ -34,27 +32,11 @@ public class ExcelUtils { */ public static void write(HttpServletResponse response, String filename, String sheetName, Class head, List data) throws IOException { - write(response, filename, sheetName, head, data, null); - } - - /** - * 将列表以 Excel 响应给前端 - * - * @param response 响应 - * @param filename 文件名 - * @param sheetName Excel sheet 名 - * @param head Excel head 头 - * @param data 数据列表哦 - * @param selectMap 下拉选择数据 Map<下拉所对应的列表名,下拉数据> - * @throws IOException 写入失败的情况 - */ - public static void write(HttpServletResponse response, String filename, String sheetName, - Class head, List data, List>> selectMap) throws IOException { // 输出 Excel EasyExcel.write(response.getOutputStream(), head) .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理 .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度 - .registerWriteHandler(new SelectSheetWriteHandler(selectMap)) // 基于固定 sheet 实现下拉框 + .registerWriteHandler(new SelectSheetWriteHandler(head)) // 基于固定 sheet 实现下拉框 .registerConverter(new LongStringConverter()) // 避免 Long 类型丢失精度 .sheet(sheetName).doWrite(data); // 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index e784447b2..eea4ed147 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; @@ -10,9 +9,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; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; @@ -38,7 +35,6 @@ import org.springframework.web.bind.annotation.*; import java.io.IOException; import java.time.LocalDateTime; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -49,7 +45,6 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.*; import static java.util.Collections.singletonList; @Tag(name = "管理后台 - CRM 客户") @@ -266,25 +261,7 @@ public class CrmCustomerController { .areaId(null).detailAddress("").remark("").build() ); // 输出 - ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list, builderSelectMap()); - } - - private List>> builderSelectMap() { - List>> selectMap = new ArrayList<>(); - // 获取地区下拉数据 - // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? - Area area = AreaUtils.parseArea(Area.ID_CHINA); - selectMap.add(new KeyValue<>(ExcelColumn.G, AreaUtils.getAreaNodePathList(area.getChildren()))); - // 获取客户所属行业 - List customerIndustries = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY); - selectMap.add(new KeyValue<>(ExcelColumn.I, customerIndustries)); - // 获取客户等级 - List customerLevels = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL); - selectMap.add(new KeyValue<>(ExcelColumn.J, customerLevels)); - // 获取客户来源 - List customerSources = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE); - selectMap.add(new KeyValue<>(ExcelColumn.K, customerSources)); - return selectMap; + ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list); } @PostMapping("/import") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java index 2c39472fd..4b5fbefbd 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java @@ -1,8 +1,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import cn.iocoder.yudao.module.crm.framework.excel.service.AreaExcelColumnSelectDataServiceImpl; +import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerIndustryExcelColumnSelectDataServiceImpl; +import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerLevelExcelColumnSelectDataServiceImpl; +import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerSourceExcelColumnSelectDataServiceImpl; import com.alibaba.excel.annotation.ExcelProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -41,6 +46,7 @@ public class CrmCustomerImportExcelVO { private String email; @ExcelProperty(value = "地区", converter = AreaConvert.class) + @ExcelColumnSelect(AreaExcelColumnSelectDataServiceImpl.FUNCTION_NAME) private Integer areaId; @ExcelProperty("详细地址") @@ -48,14 +54,17 @@ public class CrmCustomerImportExcelVO { @ExcelProperty(value = "所属行业", converter = DictConvert.class) @DictFormat(CRM_CUSTOMER_INDUSTRY) + @ExcelColumnSelect(CrmCustomerIndustryExcelColumnSelectDataServiceImpl.FUNCTION_NAME) private Integer industryId; @ExcelProperty(value = "客户等级", converter = DictConvert.class) @DictFormat(CRM_CUSTOMER_LEVEL) + @ExcelColumnSelect(CrmCustomerLevelExcelColumnSelectDataServiceImpl.FUNCTION_NAME) private Integer level; @ExcelProperty(value = "客户来源", converter = DictConvert.class) @DictFormat(CRM_CUSTOMER_SOURCE) + @ExcelColumnSelect(CrmCustomerSourceExcelColumnSelectDataServiceImpl.FUNCTION_NAME) private Integer source; @ExcelProperty("备注") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java new file mode 100644 index 000000000..8b54b9f55 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.crm.framework.excel; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/AreaExcelColumnSelectDataServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/AreaExcelColumnSelectDataServiceImpl.java new file mode 100644 index 000000000..c6a653449 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/AreaExcelColumnSelectDataServiceImpl.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.crm.framework.excel.service; + +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; +import cn.iocoder.yudao.framework.ip.core.Area; +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Excel 所属地区列下拉数据源获取接口实现类 + * + * @author HUIHUI + */ +@Service +public class AreaExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { + + public static final String FUNCTION_NAME = "getCrmAreaNameList"; // 防止和别的模块重名 + + @Resource + private DictDataApi dictDataApi; + + @Override + public String getFunctionName() { + return FUNCTION_NAME; + } + + @Override + public List getSelectDataList() { + // 获取地区下拉数据 + // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? + Area area = AreaUtils.parseArea(Area.ID_CHINA); + return AreaUtils.getAreaNodePathList(area.getChildren()); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerIndustryExcelColumnSelectDataServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerIndustryExcelColumnSelectDataServiceImpl.java new file mode 100644 index 000000000..8a78104bf --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerIndustryExcelColumnSelectDataServiceImpl.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.crm.framework.excel.service; + +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.List; + +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; + +/** + * Excel 客户所属行业列下拉数据源获取接口实现类 + * + * @author HUIHUI + */ +@Service +public class CrmCustomerIndustryExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { + + public static final String FUNCTION_NAME = "getCrmCustomerIndustryList"; + + @Resource + private DictDataApi dictDataApi; + + @Override + public String getFunctionName() { + return FUNCTION_NAME; + } + + @Override + public List getSelectDataList() { + return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerLevelExcelColumnSelectDataServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerLevelExcelColumnSelectDataServiceImpl.java new file mode 100644 index 000000000..5948aa427 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerLevelExcelColumnSelectDataServiceImpl.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.crm.framework.excel.service; + +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.List; + +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL; + +/** + * Excel 客户等级列下拉数据源获取接口实现类 + * + * @author HUIHUI + */ +@Service +public class CrmCustomerLevelExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { + + public static final String FUNCTION_NAME = "getCrmCustomerLevelList"; + + @Resource + private DictDataApi dictDataApi; + + @Override + public String getFunctionName() { + return FUNCTION_NAME; + } + + @Override + public List getSelectDataList() { + return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerSourceExcelColumnSelectDataServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerSourceExcelColumnSelectDataServiceImpl.java new file mode 100644 index 000000000..c160ed90f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerSourceExcelColumnSelectDataServiceImpl.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.crm.framework.excel.service; + +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.List; + +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE; + +/** + * Excel 客户来源列下拉数据源获取接口实现类 + * + * @author HUIHUI + */ +@Service +public class CrmCustomerSourceExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { + + public static final String FUNCTION_NAME = "getCrmCustomerSourceList"; + + @Resource + private DictDataApi dictDataApi; + + @Override + public String getFunctionName() { + return FUNCTION_NAME; + } + + @Override + public List getSelectDataList() { + return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE); + } + +}