From 52a68e18388a4c6f5395d500b1a149eb26e2de6a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 30 Jan 2024 09:24:42 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20CRM=EF=BC=9Acode=20review=20?= =?UTF-8?q?=E5=90=88=E5=90=8C=E9=87=91=E9=A2=9D=E6=8E=92=E8=A1=8C=E6=A6=9C?= =?UTF-8?q?=E3=80=81=E5=9B=9E=E6=AC=BE=E9=87=91=E9=A2=9D=E6=8E=92=E8=A1=8C?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/ranking/BiRankingController.http | 3 +- .../admin/ranking/BiRankingController.java | 2 + .../ranking/vo/BiContractRanKingRespVO.java | 4 +- .../controller/admin/ranking/vo/BiParams.java | 5 +- .../admin/ranking/vo/BiRankReqVO.java | 2 + .../vo/BiReceivablesRanKingRespVO.java | 2 + .../iocoder/yudao/module/bi/package-info.java | 3 + .../bi/service/ranking/BiRankingService.java | 2 +- .../yudao/module/bi/util/BiTimeUtil.java | 1 + .../resources/mapper/rank/BiRankingMapper.xml | 3 + .../sale/vo/order/ErpSaleOrderSaveReqVO.java | 60 ++++++++++++++++++- .../service/sale/ErpSaleOrderServiceImpl.java | 26 ++++---- .../module/system/api/dept/DeptApiImpl.java | 1 - 13 files changed, 92 insertions(+), 22 deletions(-) diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.http b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.http index 50ab7ec2b..e56a1fcfe 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.http +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.http @@ -3,8 +3,7 @@ GET {{baseUrl}}/bi/rank/contract-ranKing Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} - ### 回款金额排行榜 GET {{baseUrl}}/bi/rank/receivables-ranKing Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} +tenant-id: {{adminTenentId}} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.java b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.java index 2d81ae80d..131d43892 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.java +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.java @@ -19,6 +19,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +// TODO @anhaohao:写了 swagger 注解,不写注释哈 /** * @author anhaohao */ @@ -50,4 +51,5 @@ public class BiRankingController { public CommonResult> receivablesRanKing(BiRankReqVO biRankReqVO) { return success(biRankingService.receivablesRanKing(biRankReqVO)); } + } diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiContractRanKingRespVO.java b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiContractRanKingRespVO.java index 777996b90..487ebe031 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiContractRanKingRespVO.java +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiContractRanKingRespVO.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bi.controller.admin.ranking.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +// TODO @anhaohao:VO 类有 swagger 注解,不写注释哈 /** * 管理后台 - BI 排行榜 Response VO * @@ -12,13 +13,14 @@ import lombok.Data; @Data public class BiContractRanKingRespVO { + // TODO @anhaohao:如果一定返回的字段,需要加 requiredMode = Schema.RequiredMode.REQUIRED, 哈 @Schema(description = "金额", example = "1") private Integer price; @Schema(description = "姓名", example = "1") private String nickname; - @Schema(description = "部门名称", example = "1") private String deptName; + } diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiParams.java b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiParams.java index 5cce4c6cb..7cbf469c8 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiParams.java +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiParams.java @@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode; import java.util.List; +// TODO @anhaohao:这个类的命名,还是保持和其它一致使用 ReqVO 结尾;例如说,CrmStatisticsCommonParamReqVO /** * @author anhaohao * bi参数 @@ -25,17 +26,19 @@ public class BiParams extends PageParam { @Schema(description = "用户IDs") private List userIds; + // TODO @anhaohao:这个字段,可以融合到 startTime、endTime 里去,交给前端计算哈; @Schema(description = "类型") private String type; + // TODO @anhaohao:还是使用 LocalDateTime @Schema(description = "开始时间") private String startTime; @Schema(description = "结束时间") private String endTime; + // TODO @anhaohao:这个字段,是不是直接只基于 deptId 和 userId 来判断即可哈? @Schema(description = "0 部门 1员工") private Integer isUser = 1; - } diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiRankReqVO.java b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiRankReqVO.java index 1569ba88d..bca6c8c10 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiRankReqVO.java +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiRankReqVO.java @@ -15,6 +15,8 @@ public class BiRankReqVO { @Schema(description = "部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private Long deptId; + // TODO @anhaohao:这个字段,参考 BiParams 的 type 建议 @Schema(description = "分析类型(1.今天 2.昨天 3.本周 4.上周 5.本月 6.上月 7.本季度 8.上季度 9.本年 10 上年)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private String type; + } diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiReceivablesRanKingRespVO.java b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiReceivablesRanKingRespVO.java index 32b49231f..0b395acde 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiReceivablesRanKingRespVO.java +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiReceivablesRanKingRespVO.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bi.controller.admin.ranking.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +// TODO @anhaohao:参考 BiContractRanKingRespVO 的建议 /** * 管理后台 - BI 排行榜 Response VO * @@ -20,4 +21,5 @@ public class BiReceivablesRanKingRespVO { @Schema(description = "部门名称", example = "研发部") private String deptName; + } diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/package-info.java b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/package-info.java index b45b8458d..d412dd6fd 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/package-info.java +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/package-info.java @@ -3,5 +3,8 @@ * 例如说:报表、图表、数据分析等等 *

* 1. Controller URL:以 /bi/ 开头,避免和其它 Module 冲突 + * + * TODO @anhaohao:mall 当时独立拆分一个 statistics 模块的原因,是因为 mall 拆分了多个模块,没有模块适合承接统计的能力,所以独立了。 + * TODO crm 因为没有拆分,所以可以直接放在 crm 模块下面;这样,我们可以在 controller/admin 和 service 下,新建一个 bi 包,专门放置统计的代码。 */ package cn.iocoder.yudao.module.bi; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/service/ranking/BiRankingService.java b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/service/ranking/BiRankingService.java index 98f1346de..121029b19 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/service/ranking/BiRankingService.java +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/service/ranking/BiRankingService.java @@ -11,7 +11,7 @@ import java.util.List; * * @author anhaohao */ -public interface BiRankingService { +public interface BiRankingService { // TODO @anhaohao:第一个方法,和类要有一个空行 /** * 合同金额排行榜 * diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/util/BiTimeUtil.java b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/util/BiTimeUtil.java index b1b68aea2..123122328 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/util/BiTimeUtil.java +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/util/BiTimeUtil.java @@ -28,6 +28,7 @@ public class BiTimeUtil { // 解析时间 BiTimeEntity biTimeEntity = analyzeTime(biParams); // 解析权限 + // TODO @anhaohao:涉及到数据的读取,不放在 Util 里,还是搞会到 Service 哈; biTimeEntity.setUserIds(analyzeAuth(biParams)); return biTimeEntity; } diff --git a/yudao-module-crm/yudao-module-bi-biz/src/main/resources/mapper/rank/BiRankingMapper.xml b/yudao-module-crm/yudao-module-bi-biz/src/main/resources/mapper/rank/BiRankingMapper.xml index ed12ded42..a41dc5d7f 100644 --- a/yudao-module-crm/yudao-module-bi-biz/src/main/resources/mapper/rank/BiRankingMapper.xml +++ b/yudao-module-crm/yudao-module-bi-biz/src/main/resources/mapper/rank/BiRankingMapper.xml @@ -7,6 +7,7 @@ resultType="cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiContractRanKingRespVO"> SELECT IFNULL(SUM(t.price), 0) AS price, su.nickname, t.owner_user_id, dept.name AS deptName FROM crm_contract t + LEFT JOIN system_users AS su ON su.id = t.owner_user_id LEFT JOIN system_dept AS dept ON dept.id = su.dept_id WHERE t.deleted = 0 @@ -17,10 +18,12 @@ #{item} + AND DATE_FORMAT(t.order_date,'${sqlDateFormat}') between #{beginTime} and #{finalTime} GROUP BY t.owner_user_id ORDER BY price DESC +