Commit fc7734319b01eb6979ac2ca5af663a57a7995dd9
Merge branch 'develop' of https://gitee.com/puhui999/ruoyi-vue-pro into develop
# Conflicts: # yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java # yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
Showing
20 changed files
with
385 additions
and
116 deletions
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/annotations/ExcelColumnSelect.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.excel.core.annotations; | ||
| 2 | + | ||
| 3 | +import java.lang.annotation.*; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 给列添加下拉选择数据 | ||
| 7 | + * | ||
| 8 | + * @author HUIHUI | ||
| 9 | + */ | ||
| 10 | +@Target({ElementType.FIELD}) | ||
| 11 | +@Retention(RetentionPolicy.RUNTIME) | ||
| 12 | +@Inherited | ||
| 13 | +public @interface ExcelColumnSelect { | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * @return 获取下拉数据源的方法名称 | ||
| 17 | + */ | ||
| 18 | + String value(); | ||
| 19 | + | ||
| 20 | +} |
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/enums/ExcelColumn.java deleted
| 1 | -package cn.iocoder.yudao.framework.excel.core.enums; | ||
| 2 | - | ||
| 3 | -import lombok.AllArgsConstructor; | ||
| 4 | -import lombok.Getter; | ||
| 5 | - | ||
| 6 | -// TODO @puhui999:列表有办法通过 field name 么?主要考虑一个点,可能导入模版的顺序可能会变 | ||
| 7 | -/** | ||
| 8 | - * Excel 列名枚举 | ||
| 9 | - * 默认枚举 26 列列名如果有需求更多的列名请自行补充 | ||
| 10 | - * | ||
| 11 | - * @author HUIHUI | ||
| 12 | - */ | ||
| 13 | -@Getter | ||
| 14 | -@AllArgsConstructor | ||
| 15 | -public enum ExcelColumn { | ||
| 16 | - | ||
| 17 | - A(0), B(1), C(2), D(3), E(4), F(5), G(6), H(7), I(8), | ||
| 18 | - J(9), K(10), L(11), M(12), N(13), O(14), P(15), Q(16), | ||
| 19 | - R(17), S(18), T(19), U(20), V(21), W(22), X(23), Y(24), | ||
| 20 | - Z(25); | ||
| 21 | - | ||
| 22 | - /** | ||
| 23 | - * 列索引 | ||
| 24 | - */ | ||
| 25 | - private final int colNum; | ||
| 26 | - | ||
| 27 | -} |
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/SelectSheetWriteHandler.java
| 1 | package cn.iocoder.yudao.framework.excel.core.handler; | 1 | package cn.iocoder.yudao.framework.excel.core.handler; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.hutool.core.lang.Assert; | 4 | +import cn.hutool.core.map.MapUtil; |
| 5 | +import cn.hutool.extra.spring.SpringUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.core.KeyValue; | 6 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 6 | -import cn.iocoder.yudao.framework.excel.core.enums.ExcelColumn; | 7 | +import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; |
| 8 | +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||
| 9 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | import com.alibaba.excel.write.handler.SheetWriteHandler; | 10 | import com.alibaba.excel.write.handler.SheetWriteHandler; |
| 8 | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; | 11 | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
| 9 | import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; | 12 | import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; |
| @@ -11,10 +14,11 @@ import org.apache.poi.hssf.usermodel.HSSFDataValidation; | @@ -11,10 +14,11 @@ import org.apache.poi.hssf.usermodel.HSSFDataValidation; | ||
| 11 | import org.apache.poi.ss.usermodel.*; | 14 | import org.apache.poi.ss.usermodel.*; |
| 12 | import org.apache.poi.ss.util.CellRangeAddressList; | 15 | import org.apache.poi.ss.util.CellRangeAddressList; |
| 13 | 16 | ||
| 14 | -import java.util.Comparator; | ||
| 15 | -import java.util.List; | ||
| 16 | -import java.util.Map; | ||
| 17 | -import java.util.stream.Collectors; | 17 | +import java.lang.annotation.Annotation; |
| 18 | +import java.lang.reflect.Field; | ||
| 19 | +import java.util.*; | ||
| 20 | + | ||
| 21 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 18 | 22 | ||
| 19 | /** | 23 | /** |
| 20 | * 基于固定 sheet 实现下拉框 | 24 | * 基于固定 sheet 实现下拉框 |
| @@ -23,6 +27,9 @@ import java.util.stream.Collectors; | @@ -23,6 +27,9 @@ import java.util.stream.Collectors; | ||
| 23 | */ | 27 | */ |
| 24 | public class SelectSheetWriteHandler implements SheetWriteHandler { | 28 | public class SelectSheetWriteHandler implements SheetWriteHandler { |
| 25 | 29 | ||
| 30 | + private static final List<String> ALPHABET = getExcelColumnNameList(); | ||
| 31 | + private static final List<ExcelColumnSelectDataService> EXCEL_COLUMN_SELECT_DATA_SERVICES = new ArrayList<>(); | ||
| 32 | + | ||
| 26 | /** | 33 | /** |
| 27 | * 数据起始行从 0 开始 | 34 | * 数据起始行从 0 开始 |
| 28 | * | 35 | * |
| @@ -36,21 +43,46 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | @@ -36,21 +43,46 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | ||
| 36 | 43 | ||
| 37 | private static final String DICT_SHEET_NAME = "字典sheet"; | 44 | private static final String DICT_SHEET_NAME = "字典sheet"; |
| 38 | 45 | ||
| 39 | - // TODO @puhui999:Map<ExcelColumn, List<String>> 可以么?之前用 keyvalue 的原因,返回给前端,无法用 linkedhashmap,默认 key 会乱序 | ||
| 40 | - private final List<KeyValue<ExcelColumn, List<String>>> selectMap; | 46 | + private final List<KeyValue<Integer, List<String>>> selectMap = new ArrayList<>(); // 使用 List + KeyValue 组合方便排序 |
| 41 | 47 | ||
| 42 | - public SelectSheetWriteHandler(List<KeyValue<ExcelColumn, List<String>>> selectMap) { | ||
| 43 | - if (CollUtil.isEmpty(selectMap)) { | ||
| 44 | - this.selectMap = null; | 48 | + public SelectSheetWriteHandler(Class<?> head) { |
| 49 | + // 加载下拉数据获取接口 | ||
| 50 | + Map<String, ExcelColumnSelectDataService> beansMap = SpringUtil.getBeanFactory().getBeansOfType(ExcelColumnSelectDataService.class); | ||
| 51 | + if (MapUtil.isEmpty(beansMap)) { | ||
| 45 | return; | 52 | return; |
| 46 | } | 53 | } |
| 47 | - // 校验一下 key 是否唯一 | ||
| 48 | - Map<String, Long> nameCounts = selectMap.stream() | ||
| 49 | - .collect(Collectors.groupingBy(item -> item.getKey().name(), Collectors.counting())); | ||
| 50 | - Assert.isFalse(nameCounts.entrySet().stream().allMatch(entry -> entry.getValue() > 1), "下拉数据 key 重复请排查!!!"); | ||
| 51 | - | 54 | + if (CollUtil.isEmpty(EXCEL_COLUMN_SELECT_DATA_SERVICES) || EXCEL_COLUMN_SELECT_DATA_SERVICES.size() != beansMap.values().size()) { |
| 55 | + EXCEL_COLUMN_SELECT_DATA_SERVICES.clear(); | ||
| 56 | + EXCEL_COLUMN_SELECT_DATA_SERVICES.addAll(convertList(beansMap.values(), b -> b)); | ||
| 57 | + } | ||
| 58 | + // 解析下拉数据 | ||
| 59 | + Map<String, Field> excelPropertyFields = getFieldsWithAnnotation(head, ExcelProperty.class); | ||
| 60 | + Map<String, Field> excelColumnSelectFields = getFieldsWithAnnotation(head, ExcelColumnSelect.class); | ||
| 61 | + int colIndex = 0; | ||
| 62 | + for (String fieldName : excelPropertyFields.keySet()) { | ||
| 63 | + Field field = excelColumnSelectFields.get(fieldName); | ||
| 64 | + if (field != null) { | ||
| 65 | + getSelectDataList(colIndex, field); | ||
| 66 | + } | ||
| 67 | + colIndex++; | ||
| 68 | + } | ||
| 52 | selectMap.sort(Comparator.comparing(item -> item.getValue().size())); // 升序不然创建下拉会报错 | 69 | selectMap.sort(Comparator.comparing(item -> item.getValue().size())); // 升序不然创建下拉会报错 |
| 53 | - this.selectMap = selectMap; | 70 | + } |
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 获得下拉数据 | ||
| 74 | + * | ||
| 75 | + * @param colIndex 列索引 | ||
| 76 | + * @param field 字段 | ||
| 77 | + */ | ||
| 78 | + private void getSelectDataList(int colIndex, Field field) { | ||
| 79 | + EXCEL_COLUMN_SELECT_DATA_SERVICES.forEach(selectDataService -> { | ||
| 80 | + List<String> stringList = selectDataService.handle(field.getAnnotation(ExcelColumnSelect.class).value()); | ||
| 81 | + if (CollUtil.isEmpty(stringList)) { | ||
| 82 | + return; | ||
| 83 | + } | ||
| 84 | + selectMap.add(new KeyValue<>(colIndex, stringList)); | ||
| 85 | + }); | ||
| 54 | } | 86 | } |
| 55 | 87 | ||
| 56 | @Override | 88 | @Override |
| @@ -65,7 +97,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | @@ -65,7 +97,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | ||
| 65 | 97 | ||
| 66 | // 2. 创建数据字典的 sheet 页 | 98 | // 2. 创建数据字典的 sheet 页 |
| 67 | Sheet dictSheet = workbook.createSheet(DICT_SHEET_NAME); | 99 | Sheet dictSheet = workbook.createSheet(DICT_SHEET_NAME); |
| 68 | - for (KeyValue<ExcelColumn, List<String>> keyValue : selectMap) { | 100 | + for (KeyValue<Integer, List<String>> keyValue : selectMap) { |
| 69 | int rowLength = keyValue.getValue().size(); | 101 | int rowLength = keyValue.getValue().size(); |
| 70 | // 2.1 设置字典 sheet 页的值 每一列一个字典项 | 102 | // 2.1 设置字典 sheet 页的值 每一列一个字典项 |
| 71 | for (int i = 0; i < rowLength; i++) { | 103 | for (int i = 0; i < rowLength; i++) { |
| @@ -73,7 +105,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | @@ -73,7 +105,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | ||
| 73 | if (row == null) { | 105 | if (row == null) { |
| 74 | row = dictSheet.createRow(i); | 106 | row = dictSheet.createRow(i); |
| 75 | } | 107 | } |
| 76 | - row.createCell(keyValue.getKey().getColNum()).setCellValue(keyValue.getValue().get(i)); | 108 | + row.createCell(keyValue.getKey()).setCellValue(keyValue.getValue().get(i)); |
| 77 | } | 109 | } |
| 78 | // 2.2 设置单元格下拉选择 | 110 | // 2.2 设置单元格下拉选择 |
| 79 | setColumnSelect(writeSheetHolder, workbook, helper, keyValue); | 111 | setColumnSelect(writeSheetHolder, workbook, helper, keyValue); |
| @@ -84,10 +116,10 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | @@ -84,10 +116,10 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | ||
| 84 | * 设置单元格下拉选择 | 116 | * 设置单元格下拉选择 |
| 85 | */ | 117 | */ |
| 86 | private static void setColumnSelect(WriteSheetHolder writeSheetHolder, Workbook workbook, DataValidationHelper helper, | 118 | private static void setColumnSelect(WriteSheetHolder writeSheetHolder, Workbook workbook, DataValidationHelper helper, |
| 87 | - KeyValue<ExcelColumn, List<String>> keyValue) { | 119 | + KeyValue<Integer, List<String>> keyValue) { |
| 88 | // 1.1 创建可被其他单元格引用的名称 | 120 | // 1.1 创建可被其他单元格引用的名称 |
| 89 | Name name = workbook.createName(); | 121 | Name name = workbook.createName(); |
| 90 | - String excelColumn = keyValue.getKey().name(); | 122 | + String excelColumn = ALPHABET.get(keyValue.getKey()); |
| 91 | // 1.2 下拉框数据来源 eg:字典sheet!$B1:$B2 | 123 | // 1.2 下拉框数据来源 eg:字典sheet!$B1:$B2 |
| 92 | String refers = DICT_SHEET_NAME + "!$" + excelColumn + "$1:$" + excelColumn + "$" + keyValue.getValue().size(); | 124 | String refers = DICT_SHEET_NAME + "!$" + excelColumn + "$1:$" + excelColumn + "$" + keyValue.getValue().size(); |
| 93 | name.setNameName("dict" + keyValue.getKey()); // 设置名称的名字 | 125 | name.setNameName("dict" + keyValue.getKey()); // 设置名称的名字 |
| @@ -97,7 +129,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | @@ -97,7 +129,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | ||
| 97 | DataValidationConstraint constraint = helper.createFormulaListConstraint("dict" + keyValue.getKey()); // 设置引用约束 | 129 | DataValidationConstraint constraint = helper.createFormulaListConstraint("dict" + keyValue.getKey()); // 设置引用约束 |
| 98 | // 设置下拉单元格的首行、末行、首列、末列 | 130 | // 设置下拉单元格的首行、末行、首列、末列 |
| 99 | CellRangeAddressList rangeAddressList = new CellRangeAddressList(FIRST_ROW, LAST_ROW, | 131 | CellRangeAddressList rangeAddressList = new CellRangeAddressList(FIRST_ROW, LAST_ROW, |
| 100 | - keyValue.getKey().getColNum(), keyValue.getKey().getColNum()); | 132 | + keyValue.getKey(), keyValue.getKey()); |
| 101 | DataValidation validation = helper.createValidation(constraint, rangeAddressList); | 133 | DataValidation validation = helper.createValidation(constraint, rangeAddressList); |
| 102 | if (validation instanceof HSSFDataValidation) { | 134 | if (validation instanceof HSSFDataValidation) { |
| 103 | validation.setSuppressDropDownArrow(false); | 135 | validation.setSuppressDropDownArrow(false); |
| @@ -112,4 +144,28 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | @@ -112,4 +144,28 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { | ||
| 112 | writeSheetHolder.getSheet().addValidationData(validation); | 144 | writeSheetHolder.getSheet().addValidationData(validation); |
| 113 | } | 145 | } |
| 114 | 146 | ||
| 147 | + public static Map<String, Field> getFieldsWithAnnotation(Class<?> clazz, Class<? extends Annotation> annotationClass) { | ||
| 148 | + Map<String, Field> annotatedFields = new LinkedHashMap<>(); | ||
| 149 | + Field[] fields = clazz.getDeclaredFields(); | ||
| 150 | + for (Field field : fields) { | ||
| 151 | + if (field.isAnnotationPresent(annotationClass)) { | ||
| 152 | + annotatedFields.put(field.getName(), field); | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + return annotatedFields; | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + | ||
| 159 | + private static List<String> getExcelColumnNameList() { | ||
| 160 | + ArrayList<String> strings = new ArrayList<>(); | ||
| 161 | + for (int i = 1; i <= 52; i++) { // 生成 52 列名称,需要更多请重写此方法 | ||
| 162 | + if (i <= 26) { | ||
| 163 | + strings.add(String.valueOf((char) ('A' + i - 1))); // 使用 ASCII 码值转字母 | ||
| 164 | + } else { | ||
| 165 | + strings.add(String.valueOf((char) ('A' + (i - 1) / 26 - 1)) + (char) ('A' + (i - 1) % 26)); | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + return strings; | ||
| 169 | + } | ||
| 170 | + | ||
| 115 | } | 171 | } |
| 116 | \ No newline at end of file | 172 | \ No newline at end of file |
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/service/ExcelColumnSelectDataService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.excel.core.service; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.util.StrUtil; | ||
| 4 | + | ||
| 5 | +import java.util.Collections; | ||
| 6 | +import java.util.List; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Excel 列下拉数据源获取接口 | ||
| 10 | + * | ||
| 11 | + * 为什么不直接解析字典还搞个接口?考虑到有的下拉数据不是从字典中获取的所有需要做一个兼容 | ||
| 12 | + * | ||
| 13 | + * @author HUIHUI | ||
| 14 | + */ | ||
| 15 | +public interface ExcelColumnSelectDataService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 获得方法名称 | ||
| 19 | + * | ||
| 20 | + * @return 方法名称 | ||
| 21 | + */ | ||
| 22 | + String getFunctionName(); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 获得列下拉数据源 | ||
| 26 | + * | ||
| 27 | + * @return 下拉数据源 | ||
| 28 | + */ | ||
| 29 | + List<String> getSelectDataList(); | ||
| 30 | + | ||
| 31 | + default List<String> handle(String funcName) { | ||
| 32 | + if (StrUtil.isEmptyIfStr(funcName) || !StrUtil.equals(getFunctionName(), funcName)) { | ||
| 33 | + return Collections.emptyList(); | ||
| 34 | + } | ||
| 35 | + return getSelectDataList(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java
| 1 | package cn.iocoder.yudao.framework.excel.core.util; | 1 | package cn.iocoder.yudao.framework.excel.core.util; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.core.KeyValue; | ||
| 4 | -import cn.iocoder.yudao.framework.excel.core.enums.ExcelColumn; | ||
| 5 | import cn.iocoder.yudao.framework.excel.core.handler.SelectSheetWriteHandler; | 3 | import cn.iocoder.yudao.framework.excel.core.handler.SelectSheetWriteHandler; |
| 6 | import com.alibaba.excel.EasyExcel; | 4 | import com.alibaba.excel.EasyExcel; |
| 7 | import com.alibaba.excel.converters.longconverter.LongStringConverter; | 5 | import com.alibaba.excel.converters.longconverter.LongStringConverter; |
| @@ -34,27 +32,11 @@ public class ExcelUtils { | @@ -34,27 +32,11 @@ public class ExcelUtils { | ||
| 34 | */ | 32 | */ |
| 35 | public static <T> void write(HttpServletResponse response, String filename, String sheetName, | 33 | public static <T> void write(HttpServletResponse response, String filename, String sheetName, |
| 36 | Class<T> head, List<T> data) throws IOException { | 34 | Class<T> head, List<T> data) throws IOException { |
| 37 | - write(response, filename, sheetName, head, data, null); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * 将列表以 Excel 响应给前端 | ||
| 42 | - * | ||
| 43 | - * @param response 响应 | ||
| 44 | - * @param filename 文件名 | ||
| 45 | - * @param sheetName Excel sheet 名 | ||
| 46 | - * @param head Excel head 头 | ||
| 47 | - * @param data 数据列表哦 | ||
| 48 | - * @param selectMap 下拉选择数据 Map<下拉所对应的列表名,下拉数据> | ||
| 49 | - * @throws IOException 写入失败的情况 | ||
| 50 | - */ | ||
| 51 | - public static <T> void write(HttpServletResponse response, String filename, String sheetName, | ||
| 52 | - Class<T> head, List<T> data, List<KeyValue<ExcelColumn, List<String>>> selectMap) throws IOException { | ||
| 53 | // 输出 Excel | 35 | // 输出 Excel |
| 54 | EasyExcel.write(response.getOutputStream(), head) | 36 | EasyExcel.write(response.getOutputStream(), head) |
| 55 | .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理 | 37 | .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理 |
| 56 | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度 | 38 | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度 |
| 57 | - .registerWriteHandler(new SelectSheetWriteHandler(selectMap)) // 基于固定 sheet 实现下拉框 | 39 | + .registerWriteHandler(new SelectSheetWriteHandler(head)) // 基于固定 sheet 实现下拉框 |
| 58 | .registerConverter(new LongStringConverter()) // 避免 Long 类型丢失精度 | 40 | .registerConverter(new LongStringConverter()) // 避免 Long 类型丢失精度 |
| 59 | .sheet(sheetName).doWrite(data); | 41 | .sheet(sheetName).doWrite(data); |
| 60 | // 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了 | 42 | // 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了 |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -15,6 +15,7 @@ public interface ErrorCodeConstants { | @@ -15,6 +15,7 @@ public interface ErrorCodeConstants { | ||
| 15 | ErrorCode CONTRACT_SUBMIT_FAIL_NOT_DRAFT = new ErrorCode(1_020_000_002, "合同提交审核失败,原因:合同没处在未提交状态"); | 15 | ErrorCode CONTRACT_SUBMIT_FAIL_NOT_DRAFT = new ErrorCode(1_020_000_002, "合同提交审核失败,原因:合同没处在未提交状态"); |
| 16 | ErrorCode CONTRACT_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS = new ErrorCode(1_020_000_003, "更新合同审核状态失败,原因:合同不是审核中状态"); | 16 | ErrorCode CONTRACT_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS = new ErrorCode(1_020_000_003, "更新合同审核状态失败,原因:合同不是审核中状态"); |
| 17 | ErrorCode CONTRACT_NO_EXISTS = new ErrorCode(1_020_000_004, "生成合同序列号重复,请重试"); | 17 | ErrorCode CONTRACT_NO_EXISTS = new ErrorCode(1_020_000_004, "生成合同序列号重复,请重试"); |
| 18 | + ErrorCode CONTRACT_DELETE_FAIL = new ErrorCode(1_020_000_005, "删除合同失败,原因:有被回款所使用"); | ||
| 18 | 19 | ||
| 19 | // ========== 线索管理 1-020-001-000 ========== | 20 | // ========== 线索管理 1-020-001-000 ========== |
| 20 | ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); | 21 | ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); |
| @@ -40,6 +41,7 @@ public interface ErrorCodeConstants { | @@ -40,6 +41,7 @@ public interface ErrorCodeConstants { | ||
| 40 | ErrorCode RECEIVABLE_NO_EXISTS = new ErrorCode(1_020_004_005, "生成回款序列号重复,请重试"); | 41 | ErrorCode RECEIVABLE_NO_EXISTS = new ErrorCode(1_020_004_005, "生成回款序列号重复,请重试"); |
| 41 | ErrorCode RECEIVABLE_CREATE_FAIL_CONTRACT_NOT_APPROVE = new ErrorCode(1_020_004_006, "创建回款失败,原因:合同不是审核通过状态"); | 42 | ErrorCode RECEIVABLE_CREATE_FAIL_CONTRACT_NOT_APPROVE = new ErrorCode(1_020_004_006, "创建回款失败,原因:合同不是审核通过状态"); |
| 42 | ErrorCode RECEIVABLE_CREATE_FAIL_PRICE_EXCEEDS_LIMIT = new ErrorCode(1_020_004_007, "创建回款失败,原因:回款金额超出合同金额,目前剩余可退:{} 元"); | 43 | ErrorCode RECEIVABLE_CREATE_FAIL_PRICE_EXCEEDS_LIMIT = new ErrorCode(1_020_004_007, "创建回款失败,原因:回款金额超出合同金额,目前剩余可退:{} 元"); |
| 44 | + ErrorCode RECEIVABLE_DELETE_FAIL_IS_APPROVE = new ErrorCode(1_020_004_008, "删除回款失败,原因:回款审批已通过"); | ||
| 43 | 45 | ||
| 44 | // ========== 回款计划 1-020-005-000 ========== | 46 | // ========== 回款计划 1-020-005-000 ========== |
| 45 | ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在"); | 47 | ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在"); |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java
| @@ -142,11 +142,11 @@ public interface LogRecordConstants { | @@ -142,11 +142,11 @@ public interface LogRecordConstants { | ||
| 142 | 142 | ||
| 143 | String CRM_RECEIVABLE_TYPE = "CRM 回款"; | 143 | String CRM_RECEIVABLE_TYPE = "CRM 回款"; |
| 144 | String CRM_RECEIVABLE_CREATE_SUB_TYPE = "创建回款"; | 144 | String CRM_RECEIVABLE_CREATE_SUB_TYPE = "创建回款"; |
| 145 | - String CRM_RECEIVABLE_CREATE_SUCCESS = "创建了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款"; | 145 | + String CRM_RECEIVABLE_CREATE_SUCCESS = "创建了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款"; |
| 146 | String CRM_RECEIVABLE_UPDATE_SUB_TYPE = "更新回款"; | 146 | String CRM_RECEIVABLE_UPDATE_SUB_TYPE = "更新回款"; |
| 147 | - String CRM_RECEIVABLE_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款: {_DIFF{#updateReqVO}}"; | 147 | + String CRM_RECEIVABLE_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款: {_DIFF{#updateReqVO}}"; |
| 148 | String CRM_RECEIVABLE_DELETE_SUB_TYPE = "删除回款"; | 148 | String CRM_RECEIVABLE_DELETE_SUB_TYPE = "删除回款"; |
| 149 | - String CRM_RECEIVABLE_DELETE_SUCCESS = "删除了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款"; | 149 | + String CRM_RECEIVABLE_DELETE_SUCCESS = "删除了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款"; |
| 150 | String CRM_RECEIVABLE_SUBMIT_SUB_TYPE = "提交回款审批"; | 150 | String CRM_RECEIVABLE_SUBMIT_SUB_TYPE = "提交回款审批"; |
| 151 | String CRM_RECEIVABLE_SUBMIT_SUCCESS = "提交编号为【{{#receivableNo}}】的回款审批成功"; | 151 | String CRM_RECEIVABLE_SUBMIT_SUCCESS = "提交编号为【{{#receivableNo}}】的回款审批成功"; |
| 152 | 152 |
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; | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.map.MapUtil; | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | -import cn.iocoder.yudao.framework.common.core.KeyValue; | ||
| 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| @@ -10,9 +9,7 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | @@ -10,9 +9,7 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||
| 10 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | 9 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 11 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | 10 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| 12 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 11 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 13 | -import cn.iocoder.yudao.framework.excel.core.enums.ExcelColumn; | ||
| 14 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 12 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 15 | -import cn.iocoder.yudao.framework.ip.core.Area; | ||
| 16 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | 13 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 17 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 14 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 18 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; | 15 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; |
| @@ -38,7 +35,6 @@ import org.springframework.web.bind.annotation.*; | @@ -38,7 +35,6 @@ import org.springframework.web.bind.annotation.*; | ||
| 38 | 35 | ||
| 39 | import java.io.IOException; | 36 | import java.io.IOException; |
| 40 | import java.time.LocalDateTime; | 37 | import java.time.LocalDateTime; |
| 41 | -import java.util.ArrayList; | ||
| 42 | import java.util.Arrays; | 38 | import java.util.Arrays; |
| 43 | import java.util.List; | 39 | import java.util.List; |
| 44 | import java.util.Map; | 40 | import java.util.Map; |
| @@ -49,7 +45,6 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | @@ -49,7 +45,6 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | ||
| 49 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | 45 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 50 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | 46 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 51 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | 47 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 52 | -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.*; | ||
| 53 | import static java.util.Collections.singletonList; | 48 | import static java.util.Collections.singletonList; |
| 54 | 49 | ||
| 55 | @Tag(name = "管理后台 - CRM 客户") | 50 | @Tag(name = "管理后台 - CRM 客户") |
| @@ -265,25 +260,7 @@ public class CrmCustomerController { | @@ -265,25 +260,7 @@ public class CrmCustomerController { | ||
| 265 | .areaId(null).detailAddress("").remark("").build() | 260 | .areaId(null).detailAddress("").remark("").build() |
| 266 | ); | 261 | ); |
| 267 | // 输出 | 262 | // 输出 |
| 268 | - ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list, builderSelectMap()); | ||
| 269 | - } | ||
| 270 | - | ||
| 271 | - private List<KeyValue<ExcelColumn, List<String>>> builderSelectMap() { | ||
| 272 | - List<KeyValue<ExcelColumn, List<String>>> selectMap = new ArrayList<>(); | ||
| 273 | - // 获取地区下拉数据 | ||
| 274 | - // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? | ||
| 275 | - Area area = AreaUtils.getArea(Area.ID_CHINA); | ||
| 276 | - selectMap.add(new KeyValue<>(ExcelColumn.G, AreaUtils.getAreaNodePathList(area.getChildren()))); | ||
| 277 | - // 获取客户所属行业 | ||
| 278 | - List<String> customerIndustries = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY); | ||
| 279 | - selectMap.add(new KeyValue<>(ExcelColumn.I, customerIndustries)); | ||
| 280 | - // 获取客户等级 | ||
| 281 | - List<String> customerLevels = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL); | ||
| 282 | - selectMap.add(new KeyValue<>(ExcelColumn.J, customerLevels)); | ||
| 283 | - // 获取客户来源 | ||
| 284 | - List<String> customerSources = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE); | ||
| 285 | - selectMap.add(new KeyValue<>(ExcelColumn.K, customerSources)); | ||
| 286 | - return selectMap; | 263 | + ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list); |
| 287 | } | 264 | } |
| 288 | 265 | ||
| 289 | @PostMapping("/import") | 266 | @PostMapping("/import") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java
| 1 | package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; | 1 | package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | 3 | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| 4 | +import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; | ||
| 4 | import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert; | 5 | import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert; |
| 5 | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | 6 | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| 7 | +import cn.iocoder.yudao.module.crm.framework.excel.service.AreaExcelColumnSelectDataServiceImpl; | ||
| 8 | +import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerIndustryExcelColumnSelectDataServiceImpl; | ||
| 9 | +import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerLevelExcelColumnSelectDataServiceImpl; | ||
| 10 | +import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerSourceExcelColumnSelectDataServiceImpl; | ||
| 6 | import com.alibaba.excel.annotation.ExcelProperty; | 11 | import com.alibaba.excel.annotation.ExcelProperty; |
| 7 | import lombok.AllArgsConstructor; | 12 | import lombok.AllArgsConstructor; |
| 8 | import lombok.Builder; | 13 | import lombok.Builder; |
| @@ -41,6 +46,7 @@ public class CrmCustomerImportExcelVO { | @@ -41,6 +46,7 @@ public class CrmCustomerImportExcelVO { | ||
| 41 | private String email; | 46 | private String email; |
| 42 | 47 | ||
| 43 | @ExcelProperty(value = "地区", converter = AreaConvert.class) | 48 | @ExcelProperty(value = "地区", converter = AreaConvert.class) |
| 49 | + @ExcelColumnSelect(AreaExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | ||
| 44 | private Integer areaId; | 50 | private Integer areaId; |
| 45 | 51 | ||
| 46 | @ExcelProperty("详细地址") | 52 | @ExcelProperty("详细地址") |
| @@ -48,14 +54,17 @@ public class CrmCustomerImportExcelVO { | @@ -48,14 +54,17 @@ public class CrmCustomerImportExcelVO { | ||
| 48 | 54 | ||
| 49 | @ExcelProperty(value = "所属行业", converter = DictConvert.class) | 55 | @ExcelProperty(value = "所属行业", converter = DictConvert.class) |
| 50 | @DictFormat(CRM_CUSTOMER_INDUSTRY) | 56 | @DictFormat(CRM_CUSTOMER_INDUSTRY) |
| 57 | + @ExcelColumnSelect(CrmCustomerIndustryExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | ||
| 51 | private Integer industryId; | 58 | private Integer industryId; |
| 52 | 59 | ||
| 53 | @ExcelProperty(value = "客户等级", converter = DictConvert.class) | 60 | @ExcelProperty(value = "客户等级", converter = DictConvert.class) |
| 54 | @DictFormat(CRM_CUSTOMER_LEVEL) | 61 | @DictFormat(CRM_CUSTOMER_LEVEL) |
| 62 | + @ExcelColumnSelect(CrmCustomerLevelExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | ||
| 55 | private Integer level; | 63 | private Integer level; |
| 56 | 64 | ||
| 57 | @ExcelProperty(value = "客户来源", converter = DictConvert.class) | 65 | @ExcelProperty(value = "客户来源", converter = DictConvert.class) |
| 58 | @DictFormat(CRM_CUSTOMER_SOURCE) | 66 | @DictFormat(CRM_CUSTOMER_SOURCE) |
| 67 | + @ExcelColumnSelect(CrmCustomerSourceExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | ||
| 59 | private Integer source; | 68 | private Integer source; |
| 60 | 69 | ||
| 61 | @ExcelProperty("备注") | 70 | @ExcelProperty("备注") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java
| 1 | package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; | 1 | package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; | 3 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; |
| 4 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | import com.alibaba.excel.annotation.ExcelProperty; | 5 | import com.alibaba.excel.annotation.ExcelProperty; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -8,53 +9,69 @@ import lombok.Data; | @@ -8,53 +9,69 @@ import lombok.Data; | ||
| 8 | import java.math.BigDecimal; | 9 | import java.math.BigDecimal; |
| 9 | import java.time.LocalDateTime; | 10 | import java.time.LocalDateTime; |
| 10 | 11 | ||
| 11 | -// TODO @puhui999:缺导出 | ||
| 12 | @Schema(description = "管理后台 - CRM 回款计划 Response VO") | 12 | @Schema(description = "管理后台 - CRM 回款计划 Response VO") |
| 13 | @Data | 13 | @Data |
| 14 | +@ExcelIgnoreUnannotated | ||
| 14 | public class CrmReceivablePlanRespVO { | 15 | public class CrmReceivablePlanRespVO { |
| 15 | 16 | ||
| 16 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 17 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 18 | + @ExcelProperty("编号") | ||
| 17 | private Long id; | 19 | private Long id; |
| 18 | 20 | ||
| 19 | @Schema(description = "期数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 21 | @Schema(description = "期数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 22 | + @ExcelProperty("期数") | ||
| 20 | private Integer period; | 23 | private Integer period; |
| 21 | 24 | ||
| 22 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 25 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 26 | + @ExcelProperty("客户编号") | ||
| 23 | private Long customerId; | 27 | private Long customerId; |
| 24 | @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") | 28 | @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") |
| 29 | + @ExcelProperty("客户名字") | ||
| 25 | private String customerName; | 30 | private String customerName; |
| 26 | 31 | ||
| 27 | @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 32 | @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 33 | + @ExcelProperty("合同编号") | ||
| 28 | private Long contractId; | 34 | private Long contractId; |
| 29 | @Schema(description = "合同编号", example = "Q110") | 35 | @Schema(description = "合同编号", example = "Q110") |
| 36 | + @ExcelProperty("合同编号") | ||
| 30 | private String contractNo; | 37 | private String contractNo; |
| 31 | 38 | ||
| 32 | @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 39 | @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 40 | + @ExcelProperty("负责人编号") | ||
| 33 | private Long ownerUserId; | 41 | private Long ownerUserId; |
| 34 | @Schema(description = "负责人", example = "test") | 42 | @Schema(description = "负责人", example = "test") |
| 43 | + @ExcelProperty("负责人") | ||
| 35 | private String ownerUserName; | 44 | private String ownerUserName; |
| 36 | 45 | ||
| 37 | @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") | 46 | @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") |
| 47 | + @ExcelProperty("计划回款日期") | ||
| 38 | private LocalDateTime returnTime; | 48 | private LocalDateTime returnTime; |
| 39 | 49 | ||
| 40 | @Schema(description = "计划回款方式", example = "1") | 50 | @Schema(description = "计划回款方式", example = "1") |
| 51 | + @ExcelProperty("计划回款方式") | ||
| 41 | private Integer returnType; | 52 | private Integer returnType; |
| 42 | 53 | ||
| 43 | @Schema(description = "计划回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") | 54 | @Schema(description = "计划回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") |
| 55 | + @ExcelProperty("计划回款金额") | ||
| 44 | private BigDecimal price; | 56 | private BigDecimal price; |
| 45 | 57 | ||
| 46 | @Schema(description = "回款编号", example = "19852") | 58 | @Schema(description = "回款编号", example = "19852") |
| 59 | + @ExcelProperty("回款编号") | ||
| 47 | private Long receivableId; | 60 | private Long receivableId; |
| 48 | @Schema(description = "回款信息") | 61 | @Schema(description = "回款信息") |
| 62 | + @ExcelProperty("回款信息") | ||
| 49 | private CrmReceivableRespVO receivable; | 63 | private CrmReceivableRespVO receivable; |
| 50 | 64 | ||
| 51 | @Schema(description = "提前几天提醒", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | 65 | @Schema(description = "提前几天提醒", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 66 | + @ExcelProperty("提前几天提醒") | ||
| 52 | private Integer remindDays; | 67 | private Integer remindDays; |
| 53 | 68 | ||
| 54 | @Schema(description = "提醒日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") | 69 | @Schema(description = "提醒日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") |
| 70 | + @ExcelProperty("提醒日期") | ||
| 55 | private LocalDateTime remindTime; | 71 | private LocalDateTime remindTime; |
| 56 | 72 | ||
| 57 | @Schema(description = "备注", example = "备注") | 73 | @Schema(description = "备注", example = "备注") |
| 74 | + @ExcelProperty("备注") | ||
| 58 | private String remark; | 75 | private String remark; |
| 59 | 76 | ||
| 60 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 77 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java
| 1 | package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; | 1 | package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; | 3 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; |
| 4 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | import com.alibaba.excel.annotation.ExcelProperty; | 5 | import com.alibaba.excel.annotation.ExcelProperty; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -8,37 +9,47 @@ import lombok.Data; | @@ -8,37 +9,47 @@ import lombok.Data; | ||
| 8 | import java.math.BigDecimal; | 9 | import java.math.BigDecimal; |
| 9 | import java.time.LocalDateTime; | 10 | import java.time.LocalDateTime; |
| 10 | 11 | ||
| 11 | -// TODO 芋艿:导出的 VO,可以考虑使用 @Excel 注解,实现导出功能 | ||
| 12 | @Schema(description = "管理后台 - CRM 回款 Response VO") | 12 | @Schema(description = "管理后台 - CRM 回款 Response VO") |
| 13 | @Data | 13 | @Data |
| 14 | +@ExcelIgnoreUnannotated | ||
| 14 | public class CrmReceivableRespVO { | 15 | public class CrmReceivableRespVO { |
| 15 | 16 | ||
| 16 | @Schema(description = "编号", example = "25787") | 17 | @Schema(description = "编号", example = "25787") |
| 18 | + @ExcelProperty("编号") | ||
| 17 | private Long id; | 19 | private Long id; |
| 18 | 20 | ||
| 19 | @Schema(description = "回款编号", example = "31177") | 21 | @Schema(description = "回款编号", example = "31177") |
| 22 | + @ExcelProperty("回款编号") | ||
| 20 | private String no; | 23 | private String no; |
| 21 | 24 | ||
| 22 | @Schema(description = "回款计划编号", example = "1024") | 25 | @Schema(description = "回款计划编号", example = "1024") |
| 26 | + @ExcelProperty("回款计划编号") | ||
| 23 | private Long planId; | 27 | private Long planId; |
| 24 | 28 | ||
| 25 | @Schema(description = "回款方式", example = "2") | 29 | @Schema(description = "回款方式", example = "2") |
| 30 | + @ExcelProperty("回款方式") | ||
| 26 | private Integer returnType; | 31 | private Integer returnType; |
| 27 | 32 | ||
| 28 | @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") | 33 | @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") |
| 34 | + @ExcelProperty("回款金额") | ||
| 29 | private BigDecimal price; | 35 | private BigDecimal price; |
| 30 | 36 | ||
| 31 | @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") | 37 | @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") |
| 38 | + @ExcelProperty("计划回款日期") | ||
| 32 | private LocalDateTime returnTime; | 39 | private LocalDateTime returnTime; |
| 33 | 40 | ||
| 34 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 41 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 42 | + @ExcelProperty("客户编号") | ||
| 35 | private Long customerId; | 43 | private Long customerId; |
| 36 | @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") | 44 | @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") |
| 45 | + @ExcelProperty("客户名字") | ||
| 37 | private String customerName; | 46 | private String customerName; |
| 38 | 47 | ||
| 39 | @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 48 | @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 49 | + @ExcelProperty("合同编号") | ||
| 40 | private Long contractId; | 50 | private Long contractId; |
| 41 | @Schema(description = "合同信息") | 51 | @Schema(description = "合同信息") |
| 52 | + @ExcelProperty("合同信息") | ||
| 42 | private CrmContractRespVO contract; | 53 | private CrmContractRespVO contract; |
| 43 | 54 | ||
| 44 | @Schema(description = "负责人的用户编号", example = "25682") | 55 | @Schema(description = "负责人的用户编号", example = "25682") |
| @@ -56,20 +67,26 @@ public class CrmReceivableRespVO { | @@ -56,20 +67,26 @@ public class CrmReceivableRespVO { | ||
| 56 | private String processInstanceId; | 67 | private String processInstanceId; |
| 57 | 68 | ||
| 58 | @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | 69 | @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| 70 | + @ExcelProperty("审批状态") | ||
| 59 | private Integer auditStatus; | 71 | private Integer auditStatus; |
| 60 | 72 | ||
| 61 | - @Schema(description = "备注", example = "备注") | 73 | + @Schema(description = "工作流编号", example = "备注") |
| 74 | + @ExcelProperty("工作流编号") | ||
| 62 | private String remark; | 75 | private String remark; |
| 63 | 76 | ||
| 64 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 77 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 78 | + @ExcelProperty("创建时间") | ||
| 65 | private LocalDateTime createTime; | 79 | private LocalDateTime createTime; |
| 66 | 80 | ||
| 67 | @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) | 81 | @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 82 | + @ExcelProperty("更新时间") | ||
| 68 | private LocalDateTime updateTime; | 83 | private LocalDateTime updateTime; |
| 69 | 84 | ||
| 70 | @Schema(description = "创建人", example = "25682") | 85 | @Schema(description = "创建人", example = "25682") |
| 86 | + @ExcelProperty("创建人") | ||
| 71 | private String creator; | 87 | private String creator; |
| 72 | @Schema(description = "创建人名字", example = "test") | 88 | @Schema(description = "创建人名字", example = "test") |
| 89 | + @ExcelProperty("创建人名字") | ||
| 73 | private String creatorName; | 90 | private String creatorName; |
| 74 | 91 | ||
| 75 | } | 92 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java
0 → 100644
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/AreaExcelColumnSelectDataServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.framework.excel.service; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||
| 4 | +import cn.iocoder.yudao.framework.ip.core.Area; | ||
| 5 | +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | ||
| 6 | +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||
| 7 | +import jakarta.annotation.Resource; | ||
| 8 | +import org.springframework.stereotype.Service; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Excel 所属地区列下拉数据源获取接口实现类 | ||
| 14 | + * | ||
| 15 | + * @author HUIHUI | ||
| 16 | + */ | ||
| 17 | +@Service | ||
| 18 | +public class AreaExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | ||
| 19 | + | ||
| 20 | + public static final String FUNCTION_NAME = "getCrmAreaNameList"; // 防止和别的模块重名 | ||
| 21 | + | ||
| 22 | + @Resource | ||
| 23 | + private DictDataApi dictDataApi; | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public String getFunctionName() { | ||
| 27 | + return FUNCTION_NAME; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public List<String> getSelectDataList() { | ||
| 32 | + // 获取地区下拉数据 | ||
| 33 | + // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? | ||
| 34 | + Area area = AreaUtils.parseArea(Area.ID_CHINA); | ||
| 35 | + return AreaUtils.getAreaNodePathList(area.getChildren()); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerIndustryExcelColumnSelectDataServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.framework.excel.service; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||
| 4 | +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||
| 5 | +import jakarta.annotation.Resource; | ||
| 6 | +import org.springframework.stereotype.Service; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Excel 客户所属行业列下拉数据源获取接口实现类 | ||
| 14 | + * | ||
| 15 | + * @author HUIHUI | ||
| 16 | + */ | ||
| 17 | +@Service | ||
| 18 | +public class CrmCustomerIndustryExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | ||
| 19 | + | ||
| 20 | + public static final String FUNCTION_NAME = "getCrmCustomerIndustryList"; | ||
| 21 | + | ||
| 22 | + @Resource | ||
| 23 | + private DictDataApi dictDataApi; | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public String getFunctionName() { | ||
| 27 | + return FUNCTION_NAME; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public List<String> getSelectDataList() { | ||
| 32 | + return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerLevelExcelColumnSelectDataServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.framework.excel.service; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||
| 4 | +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||
| 5 | +import jakarta.annotation.Resource; | ||
| 6 | +import org.springframework.stereotype.Service; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Excel 客户等级列下拉数据源获取接口实现类 | ||
| 14 | + * | ||
| 15 | + * @author HUIHUI | ||
| 16 | + */ | ||
| 17 | +@Service | ||
| 18 | +public class CrmCustomerLevelExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | ||
| 19 | + | ||
| 20 | + public static final String FUNCTION_NAME = "getCrmCustomerLevelList"; | ||
| 21 | + | ||
| 22 | + @Resource | ||
| 23 | + private DictDataApi dictDataApi; | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public String getFunctionName() { | ||
| 27 | + return FUNCTION_NAME; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public List<String> getSelectDataList() { | ||
| 32 | + return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerSourceExcelColumnSelectDataServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.framework.excel.service; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||
| 4 | +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||
| 5 | +import jakarta.annotation.Resource; | ||
| 6 | +import org.springframework.stereotype.Service; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Excel 客户来源列下拉数据源获取接口实现类 | ||
| 14 | + * | ||
| 15 | + * @author HUIHUI | ||
| 16 | + */ | ||
| 17 | +@Service | ||
| 18 | +public class CrmCustomerSourceExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | ||
| 19 | + | ||
| 20 | + public static final String FUNCTION_NAME = "getCrmCustomerSourceList"; | ||
| 21 | + | ||
| 22 | + @Resource | ||
| 23 | + private DictDataApi dictDataApi; | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public String getFunctionName() { | ||
| 27 | + return FUNCTION_NAME; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public List<String> getSelectDataList() { | ||
| 32 | + return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| @@ -30,12 +30,14 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | @@ -30,12 +30,14 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | ||
| 30 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; | 30 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 31 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | 31 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 32 | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | 32 | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; |
| 33 | +import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; | ||
| 33 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 34 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 34 | import com.mzt.logapi.context.LogRecordContext; | 35 | import com.mzt.logapi.context.LogRecordContext; |
| 35 | import com.mzt.logapi.service.impl.DiffParseFunction; | 36 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| 36 | import com.mzt.logapi.starter.annotation.LogRecord; | 37 | import com.mzt.logapi.starter.annotation.LogRecord; |
| 37 | import jakarta.annotation.Resource; | 38 | import jakarta.annotation.Resource; |
| 38 | import lombok.extern.slf4j.Slf4j; | 39 | import lombok.extern.slf4j.Slf4j; |
| 40 | +import org.springframework.context.annotation.Lazy; | ||
| 39 | import org.springframework.stereotype.Service; | 41 | import org.springframework.stereotype.Service; |
| 40 | import org.springframework.transaction.annotation.Transactional; | 42 | import org.springframework.transaction.annotation.Transactional; |
| 41 | import org.springframework.validation.annotation.Validated; | 43 | import org.springframework.validation.annotation.Validated; |
| @@ -86,7 +88,9 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -86,7 +88,9 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 86 | private CrmContactService contactService; | 88 | private CrmContactService contactService; |
| 87 | @Resource | 89 | @Resource |
| 88 | private CrmContractConfigService contractConfigService; | 90 | private CrmContractConfigService contractConfigService; |
| 89 | - | 91 | + @Resource |
| 92 | + @Lazy // 延迟加载,避免循环依赖 | ||
| 93 | + private CrmReceivableService receivableService; | ||
| 90 | @Resource | 94 | @Resource |
| 91 | private AdminUserApi adminUserApi; | 95 | private AdminUserApi adminUserApi; |
| 92 | @Resource | 96 | @Resource |
| @@ -222,9 +226,12 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -222,9 +226,12 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 222 | success = CRM_CONTRACT_DELETE_SUCCESS) | 226 | success = CRM_CONTRACT_DELETE_SUCCESS) |
| 223 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) | 227 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) |
| 224 | public void deleteContract(Long id) { | 228 | public void deleteContract(Long id) { |
| 225 | - // TODO @puhui999:如果被 CrmReceivableDO 所使用,则不允许删除 | ||
| 226 | // 校验存在 | 229 | // 校验存在 |
| 227 | CrmContractDO contract = validateContractExists(id); | 230 | CrmContractDO contract = validateContractExists(id); |
| 231 | + // 如果被 CrmReceivableDO 所使用,则不允许删除 | ||
| 232 | + if (CollUtil.isNotEmpty(receivableService.getReceivableByContractId(contract.getId()))) { | ||
| 233 | + throw exception(CONTRACT_DELETE_FAIL); | ||
| 234 | + } | ||
| 228 | // 删除 | 235 | // 删除 |
| 229 | contractMapper.deleteById(id); | 236 | contractMapper.deleteById(id); |
| 230 | // 删除数据权限 | 237 | // 删除数据权限 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java
| @@ -122,4 +122,12 @@ public interface CrmReceivableService { | @@ -122,4 +122,12 @@ public interface CrmReceivableService { | ||
| 122 | */ | 122 | */ |
| 123 | Map<Long, BigDecimal> getReceivablePriceMapByContractId(Collection<Long> contractIds); | 123 | Map<Long, BigDecimal> getReceivablePriceMapByContractId(Collection<Long> contractIds); |
| 124 | 124 | ||
| 125 | + /** | ||
| 126 | + * 更具合同编号查询回款列表 | ||
| 127 | + * | ||
| 128 | + * @param contractId 合同编号 | ||
| 129 | + * @return 回款 | ||
| 130 | + */ | ||
| 131 | + List<CrmReceivableDO> getReceivableByContractId(Long contractId); | ||
| 132 | + | ||
| 125 | } | 133 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
| @@ -37,10 +37,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -37,10 +37,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 37 | import org.springframework.validation.annotation.Validated; | 37 | import org.springframework.validation.annotation.Validated; |
| 38 | 38 | ||
| 39 | import java.math.BigDecimal; | 39 | import java.math.BigDecimal; |
| 40 | -import java.util.Arrays; | ||
| 41 | -import java.util.Collection; | ||
| 42 | -import java.util.List; | ||
| 43 | -import java.util.Map; | 40 | +import java.util.*; |
| 44 | 41 | ||
| 45 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 42 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 46 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | 43 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| @@ -81,7 +78,6 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -81,7 +78,6 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 81 | @Resource | 78 | @Resource |
| 82 | private BpmProcessInstanceApi bpmProcessInstanceApi; | 79 | private BpmProcessInstanceApi bpmProcessInstanceApi; |
| 83 | 80 | ||
| 84 | - // TODO @puhui999:操作日志没记录上 | ||
| 85 | @Override | 81 | @Override |
| 86 | @Transactional(rollbackFor = Exception.class) | 82 | @Transactional(rollbackFor = Exception.class) |
| 87 | @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_CREATE_SUB_TYPE, bizNo = "{{#receivable.id}}", | 83 | @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_CREATE_SUB_TYPE, bizNo = "{{#receivable.id}}", |
| @@ -115,6 +111,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -115,6 +111,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 115 | 111 | ||
| 116 | // 5. 记录操作日志上下文 | 112 | // 5. 记录操作日志上下文 |
| 117 | LogRecordContext.putVariable("receivable", receivable); | 113 | LogRecordContext.putVariable("receivable", receivable); |
| 114 | + LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); | ||
| 118 | return receivable.getId(); | 115 | return receivable.getId(); |
| 119 | } | 116 | } |
| 120 | 117 | ||
| @@ -156,7 +153,6 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -156,7 +153,6 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 156 | } | 153 | } |
| 157 | } | 154 | } |
| 158 | 155 | ||
| 159 | - // TODO @puhui999:操作日志没记录上 | ||
| 160 | @Override | 156 | @Override |
| 161 | @Transactional(rollbackFor = Exception.class) | 157 | @Transactional(rollbackFor = Exception.class) |
| 162 | @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", | 158 | @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", |
| @@ -164,11 +160,14 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -164,11 +160,14 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 164 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) | 160 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) |
| 165 | public void updateReceivable(CrmReceivableSaveReqVO updateReqVO) { | 161 | public void updateReceivable(CrmReceivableSaveReqVO updateReqVO) { |
| 166 | Assert.notNull(updateReqVO.getId(), "回款编号不能为空"); | 162 | Assert.notNull(updateReqVO.getId(), "回款编号不能为空"); |
| 167 | - // 1.1 校验可回款金额超过上限 | ||
| 168 | - validateReceivablePriceExceedsLimit(updateReqVO); | ||
| 169 | updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段 | 163 | updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段 |
| 170 | - // 1.2 校验存在 | 164 | + // 1.1 校验存在 |
| 171 | CrmReceivableDO receivable = validateReceivableExists(updateReqVO.getId()); | 165 | CrmReceivableDO receivable = validateReceivableExists(updateReqVO.getId()); |
| 166 | + updateReqVO.setOwnerUserId(receivable.getOwnerUserId()).setCustomerId(receivable.getCustomerId()) | ||
| 167 | + .setContractId(receivable.getContractId()).setPlanId(receivable.getPlanId()); // 设置已存在的值 | ||
| 168 | + // 1.2 校验可回款金额超过上限 | ||
| 169 | + validateReceivablePriceExceedsLimit(updateReqVO); | ||
| 170 | + | ||
| 172 | // 1.3 只有草稿、审批中,可以编辑; | 171 | // 1.3 只有草稿、审批中,可以编辑; |
| 173 | if (!ObjectUtils.equalsAny(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(), | 172 | if (!ObjectUtils.equalsAny(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(), |
| 174 | CrmAuditStatusEnum.PROCESS.getStatus())) { | 173 | CrmAuditStatusEnum.PROCESS.getStatus())) { |
| @@ -180,8 +179,17 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -180,8 +179,17 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 180 | receivableMapper.updateById(updateObj); | 179 | receivableMapper.updateById(updateObj); |
| 181 | 180 | ||
| 182 | // 3. 记录操作日志上下文 | 181 | // 3. 记录操作日志上下文 |
| 183 | - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class)); | ||
| 184 | LogRecordContext.putVariable("receivable", receivable); | 182 | LogRecordContext.putVariable("receivable", receivable); |
| 183 | + LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); | ||
| 184 | + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class)); | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + private Integer getReceivablePeriod(Long planId) { | ||
| 188 | + if (Objects.isNull(planId)) { | ||
| 189 | + return null; | ||
| 190 | + } | ||
| 191 | + CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(planId); | ||
| 192 | + return receivablePlan.getPeriod(); | ||
| 185 | } | 193 | } |
| 186 | 194 | ||
| 187 | @Override | 195 | @Override |
| @@ -212,8 +220,10 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -212,8 +220,10 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 212 | if (receivable.getPlanId() != null && receivablePlanService.getReceivablePlan(receivable.getPlanId()) != null) { | 220 | if (receivable.getPlanId() != null && receivablePlanService.getReceivablePlan(receivable.getPlanId()) != null) { |
| 213 | throw exception(RECEIVABLE_DELETE_FAIL); | 221 | throw exception(RECEIVABLE_DELETE_FAIL); |
| 214 | } | 222 | } |
| 215 | - // TODO @puhui999:审批通过时,不允许删除; | ||
| 216 | - | 223 | + // 1.3 审批通过时,不允许删除 |
| 224 | + if (ObjUtil.equal(receivable.getAuditStatus(), CrmAuditStatusEnum.APPROVE.getStatus())) { | ||
| 225 | + throw exception(RECEIVABLE_DELETE_FAIL_IS_APPROVE); | ||
| 226 | + } | ||
| 217 | // 2. 删除 | 227 | // 2. 删除 |
| 218 | receivableMapper.deleteById(id); | 228 | receivableMapper.deleteById(id); |
| 219 | // 3. 删除数据权限 | 229 | // 3. 删除数据权限 |
| @@ -221,6 +231,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -221,6 +231,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 221 | 231 | ||
| 222 | // 4. 记录操作日志上下文 | 232 | // 4. 记录操作日志上下文 |
| 223 | LogRecordContext.putVariable("receivable", receivable); | 233 | LogRecordContext.putVariable("receivable", receivable); |
| 234 | + LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); | ||
| 224 | } | 235 | } |
| 225 | 236 | ||
| 226 | @Override | 237 | @Override |
| @@ -289,4 +300,9 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | @@ -289,4 +300,9 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||
| 289 | return receivableMapper.selectReceivablePriceMapByContractId(contractIds); | 300 | return receivableMapper.selectReceivablePriceMapByContractId(contractIds); |
| 290 | } | 301 | } |
| 291 | 302 | ||
| 303 | + @Override | ||
| 304 | + public List<CrmReceivableDO> getReceivableByContractId(Long contractId) { | ||
| 305 | + return receivableMapper.selectList(CrmReceivableDO::getContractId, contractId); | ||
| 306 | + } | ||
| 307 | + | ||
| 292 | } | 308 | } |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/components/list_sub_erp.vue.vm
| @@ -94,7 +94,7 @@ const { t } = useI18n() // 国际化 | @@ -94,7 +94,7 @@ const { t } = useI18n() // 国际化 | ||
| 94 | const message = useMessage() // 消息弹窗 | 94 | const message = useMessage() // 消息弹窗 |
| 95 | 95 | ||
| 96 | const props = defineProps<{ | 96 | const props = defineProps<{ |
| 97 | - ${subJoinColumn.javaField}: undefined // ${subJoinColumn.columnComment}(主表的关联字段) | 97 | + ${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段) |
| 98 | }>() | 98 | }>() |
| 99 | const loading = ref(false) // 列表的加载中 | 99 | const loading = ref(false) // 列表的加载中 |
| 100 | const list = ref([]) // 列表的数据 | 100 | const list = ref([]) // 列表的数据 |
| @@ -103,17 +103,20 @@ const total = ref(0) // 列表的总页数 | @@ -103,17 +103,20 @@ const total = ref(0) // 列表的总页数 | ||
| 103 | const queryParams = reactive({ | 103 | const queryParams = reactive({ |
| 104 | pageNo: 1, | 104 | pageNo: 1, |
| 105 | pageSize: 10, | 105 | pageSize: 10, |
| 106 | - ${subJoinColumn.javaField}: undefined | 106 | + ${subJoinColumn.javaField}: undefined as unknown |
| 107 | }) | 107 | }) |
| 108 | 108 | ||
| 109 | /** 监听主表的关联字段的变化,加载对应的子表数据 */ | 109 | /** 监听主表的关联字段的变化,加载对应的子表数据 */ |
| 110 | watch( | 110 | watch( |
| 111 | () => props.${subJoinColumn.javaField}, | 111 | () => props.${subJoinColumn.javaField}, |
| 112 | - (val) => { | 112 | + (val: number) => { |
| 113 | + if (!val) { | ||
| 114 | + return | ||
| 115 | + } | ||
| 113 | queryParams.${subJoinColumn.javaField} = val | 116 | queryParams.${subJoinColumn.javaField} = val |
| 114 | handleQuery() | 117 | handleQuery() |
| 115 | }, | 118 | }, |
| 116 | - { immediate: false } | 119 | + { immediate: true, deep: true } |
| 117 | ) | 120 | ) |
| 118 | #end | 121 | #end |
| 119 | 122 |