Commit 46e01e07a896be55310fdca7192f71ef01ec7aaf
1 parent
acb8d3f2
修改:CRM 商业智能,合并模块到 crm,优化查询
Showing
33 changed files
with
197 additions
and
634 deletions
yudao-module-crm/pom.xml
| ... | ... | @@ -10,8 +10,6 @@ |
| 10 | 10 | <modules> |
| 11 | 11 | <module>yudao-module-crm-api</module> |
| 12 | 12 | <module>yudao-module-crm-biz</module> |
| 13 | - <module>yudao-module-bi-biz</module> | |
| 14 | - <module>yudao-module-bi-api</module> | |
| 15 | 13 | </modules> |
| 16 | 14 | <modelVersion>4.0.0</modelVersion> |
| 17 | 15 | <artifactId>yudao-module-crm</artifactId> | ... | ... |
yudao-module-crm/yudao-module-bi-api/pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | - <parent> | |
| 6 | - <groupId>cn.iocoder.boot</groupId> | |
| 7 | - <artifactId>yudao-module-crm</artifactId> | |
| 8 | - <version>${revision}</version> | |
| 9 | - </parent> | |
| 10 | - <modelVersion>4.0.0</modelVersion> | |
| 11 | - <artifactId>yudao-module-bi-api</artifactId> | |
| 12 | - | |
| 13 | - <name>${project.artifactId}</name> | |
| 14 | - <description> | |
| 15 | - bi 模块 API,暴露给其它模块调用 | |
| 16 | - </description> | |
| 17 | - | |
| 18 | - <dependencies> | |
| 19 | - <dependency> | |
| 20 | - <groupId>cn.iocoder.boot</groupId> | |
| 21 | - <artifactId>yudao-module-system-api</artifactId> | |
| 22 | - <version>${revision}</version> | |
| 23 | - </dependency> | |
| 24 | - <dependency> | |
| 25 | - <groupId>cn.iocoder.boot</groupId> | |
| 26 | - <artifactId>yudao-module-crm-api</artifactId> | |
| 27 | - <version>${revision}</version> | |
| 28 | - </dependency> | |
| 29 | - | |
| 30 | - <!-- 业务组件 --> | |
| 31 | - <dependency> | |
| 32 | - <groupId>cn.iocoder.boot</groupId> | |
| 33 | - <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId> | |
| 34 | - </dependency> | |
| 35 | - <dependency> | |
| 36 | - <groupId>cn.iocoder.boot</groupId> | |
| 37 | - <artifactId>yudao-spring-boot-starter-biz-ip</artifactId> | |
| 38 | - </dependency> | |
| 39 | - | |
| 40 | - <!-- Web 相关 --> | |
| 41 | - <dependency> | |
| 42 | - <groupId>cn.iocoder.boot</groupId> | |
| 43 | - <artifactId>yudao-spring-boot-starter-web</artifactId> | |
| 44 | - </dependency> | |
| 45 | - | |
| 46 | - <dependency> | |
| 47 | - <groupId>cn.iocoder.boot</groupId> | |
| 48 | - <artifactId>yudao-spring-boot-starter-security</artifactId> | |
| 49 | - </dependency> | |
| 50 | - | |
| 51 | - <!-- DB 相关 --> | |
| 52 | - <dependency> | |
| 53 | - <groupId>cn.iocoder.boot</groupId> | |
| 54 | - <artifactId>yudao-spring-boot-starter-mybatis</artifactId> | |
| 55 | - </dependency> | |
| 56 | - | |
| 57 | - <!-- 工具类相关 --> | |
| 58 | - <dependency> | |
| 59 | - <groupId>cn.iocoder.boot</groupId> | |
| 60 | - <artifactId>yudao-spring-boot-starter-excel</artifactId> | |
| 61 | - </dependency> | |
| 62 | - <dependency> | |
| 63 | - <groupId>cn.iocoder.boot</groupId> | |
| 64 | - <artifactId>yudao-spring-boot-starter-biz-dict</artifactId> | |
| 65 | - </dependency> | |
| 66 | - | |
| 67 | - <!-- Test 测试相关 --> | |
| 68 | - <dependency> | |
| 69 | - <groupId>cn.iocoder.boot</groupId> | |
| 70 | - <artifactId>yudao-spring-boot-starter-test</artifactId> | |
| 71 | - </dependency> | |
| 72 | - </dependencies> | |
| 73 | -</project> | |
| 74 | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-bi-api/src/main/java/cn/iocoder/yudao/module/bi/api/package-info.java deleted
yudao-module-crm/yudao-module-bi-api/src/main/java/cn/iocoder/yudao/module/bi/enums/package-info.java deleted
yudao-module-crm/yudao-module-bi-biz/pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | - <parent> | |
| 6 | - <groupId>cn.iocoder.boot</groupId> | |
| 7 | - <artifactId>yudao-module-crm</artifactId> | |
| 8 | - <version>${revision}</version> | |
| 9 | - </parent> | |
| 10 | - <modelVersion>4.0.0</modelVersion> | |
| 11 | - <artifactId>yudao-module-bi-biz</artifactId> | |
| 12 | - | |
| 13 | - <name>${project.artifactId}</name> | |
| 14 | - <description> | |
| 15 | - crm 包下,商业智能(Business Intelligence)。 | |
| 16 | - 例如说:报表、图表、数据分析等等 | |
| 17 | - </description> | |
| 18 | - | |
| 19 | - <dependencies> | |
| 20 | - <dependency> | |
| 21 | - <groupId>cn.iocoder.boot</groupId> | |
| 22 | - <artifactId>yudao-module-system-api</artifactId> | |
| 23 | - <version>${revision}</version> | |
| 24 | - </dependency> | |
| 25 | - <dependency> | |
| 26 | - <groupId>cn.iocoder.boot</groupId> | |
| 27 | - <artifactId>yudao-module-crm-api</artifactId> | |
| 28 | - <version>${revision}</version> | |
| 29 | - </dependency> | |
| 30 | - | |
| 31 | - <!-- 业务组件 --> | |
| 32 | - <dependency> | |
| 33 | - <groupId>cn.iocoder.boot</groupId> | |
| 34 | - <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId> | |
| 35 | - </dependency> | |
| 36 | - <dependency> | |
| 37 | - <groupId>cn.iocoder.boot</groupId> | |
| 38 | - <artifactId>yudao-spring-boot-starter-biz-ip</artifactId> | |
| 39 | - </dependency> | |
| 40 | - | |
| 41 | - <!-- Web 相关 --> | |
| 42 | - <dependency> | |
| 43 | - <groupId>cn.iocoder.boot</groupId> | |
| 44 | - <artifactId>yudao-spring-boot-starter-web</artifactId> | |
| 45 | - </dependency> | |
| 46 | - | |
| 47 | - <dependency> | |
| 48 | - <groupId>cn.iocoder.boot</groupId> | |
| 49 | - <artifactId>yudao-spring-boot-starter-security</artifactId> | |
| 50 | - </dependency> | |
| 51 | - | |
| 52 | - <!-- DB 相关 --> | |
| 53 | - <dependency> | |
| 54 | - <groupId>cn.iocoder.boot</groupId> | |
| 55 | - <artifactId>yudao-spring-boot-starter-mybatis</artifactId> | |
| 56 | - </dependency> | |
| 57 | - | |
| 58 | - <!-- 工具类相关 --> | |
| 59 | - <dependency> | |
| 60 | - <groupId>cn.iocoder.boot</groupId> | |
| 61 | - <artifactId>yudao-spring-boot-starter-excel</artifactId> | |
| 62 | - </dependency> | |
| 63 | - <dependency> | |
| 64 | - <groupId>cn.iocoder.boot</groupId> | |
| 65 | - <artifactId>yudao-spring-boot-starter-biz-dict</artifactId> | |
| 66 | - </dependency> | |
| 67 | - | |
| 68 | - <!-- Test 测试相关 --> | |
| 69 | - <dependency> | |
| 70 | - <groupId>cn.iocoder.boot</groupId> | |
| 71 | - <artifactId>yudao-spring-boot-starter-test</artifactId> | |
| 72 | - </dependency> | |
| 73 | - </dependencies> | |
| 74 | -</project> | |
| 75 | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiContractRanKingRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.bi.controller.admin.ranking.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -// TODO @anhaohao:VO 类有 swagger 注解,不写注释哈 | |
| 7 | -/** | |
| 8 | - * 管理后台 - BI 排行榜 Response VO | |
| 9 | - * | |
| 10 | - * @author anhaohao | |
| 11 | - */ | |
| 12 | -@Schema(description = "管理后台 - BI 合同金额排行榜 Response VO") | |
| 13 | -@Data | |
| 14 | -public class BiContractRanKingRespVO { | |
| 15 | - | |
| 16 | - // TODO @anhaohao:如果一定返回的字段,需要加 requiredMode = Schema.RequiredMode.REQUIRED, 哈 | |
| 17 | - @Schema(description = "金额", example = "1") | |
| 18 | - private Integer price; | |
| 19 | - | |
| 20 | - @Schema(description = "姓名", example = "1") | |
| 21 | - private String nickname; | |
| 22 | - | |
| 23 | - @Schema(description = "部门名称", example = "1") | |
| 24 | - private String deptName; | |
| 25 | - | |
| 26 | -} |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiReceivablesRanKingRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.bi.controller.admin.ranking.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -// TODO @anhaohao:参考 BiContractRanKingRespVO 的建议 | |
| 7 | -/** | |
| 8 | - * 管理后台 - BI 排行榜 Response VO | |
| 9 | - * | |
| 10 | - * @author anhaohao | |
| 11 | - */ | |
| 12 | -@Schema(description = "管理后台 - BI 合同金额排行榜 Response VO") | |
| 13 | -@Data | |
| 14 | -public class BiReceivablesRanKingRespVO { | |
| 15 | - | |
| 16 | - @Schema(description = "金额", example = "100") | |
| 17 | - private Integer price; | |
| 18 | - | |
| 19 | - @Schema(description = "姓名", example = "张三") | |
| 20 | - private String nickname; | |
| 21 | - | |
| 22 | - @Schema(description = "部门名称", example = "研发部") | |
| 23 | - private String deptName; | |
| 24 | - | |
| 25 | -} |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/package-info.java deleted
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/framework/package-info.java deleted
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/framework/web/config/BiWebConfiguration.java deleted
| 1 | -package cn.iocoder.yudao.module.bi.framework.web.config; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration; | |
| 4 | -import org.springdoc.core.models.GroupedOpenApi; | |
| 5 | -import org.springframework.context.annotation.Bean; | |
| 6 | -import org.springframework.context.annotation.Configuration; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * bi 模块的 web 组件的 Configuration | |
| 10 | - * | |
| 11 | - * @author 芋道源码 | |
| 12 | - */ | |
| 13 | -@Configuration(proxyBeanMethods = false) | |
| 14 | -public class BiWebConfiguration { | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * bi 模块的 API 分组 | |
| 18 | - */ | |
| 19 | - @Bean | |
| 20 | - public GroupedOpenApi biGroupedOpenApi() { | |
| 21 | - return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("bi"); | |
| 22 | - } | |
| 23 | - | |
| 24 | -} |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/framework/web/package-info.java deleted
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/package-info.java deleted
| 1 | -/** | |
| 2 | - * crm 包下,商业智能(Business Intelligence)。 | |
| 3 | - * 例如说:报表、图表、数据分析等等 | |
| 4 | - * <p> | |
| 5 | - * 1. Controller URL:以 /bi/ 开头,避免和其它 Module 冲突 | |
| 6 | - * | |
| 7 | - * TODO @anhaohao:mall 当时独立拆分一个 statistics 模块的原因,是因为 mall 拆分了多个模块,没有模块适合承接统计的能力,所以独立了。 | |
| 8 | - * TODO crm 因为没有拆分,所以可以直接放在 crm 模块下面;这样,我们可以在 controller/admin 和 service 下,新建一个 bi 包,专门放置统计的代码。 | |
| 9 | - */ | |
| 10 | -package cn.iocoder.yudao.module.bi; | |
| 11 | 0 | \ No newline at end of file |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/service/ranking/BiRankingServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.bi.service.ranking; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiContractRanKingRespVO; | |
| 4 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiParams; | |
| 5 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiRankReqVO; | |
| 6 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiReceivablesRanKingRespVO; | |
| 7 | -import cn.iocoder.yudao.module.bi.dal.mysql.BiRankingMapper; | |
| 8 | -import cn.iocoder.yudao.module.bi.util.BiTimeUtil; | |
| 9 | -import jakarta.annotation.Resource; | |
| 10 | -import org.springframework.stereotype.Service; | |
| 11 | -import org.springframework.validation.annotation.Validated; | |
| 12 | - | |
| 13 | -import java.util.ArrayList; | |
| 14 | -import java.util.List; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * @author anhaohao | |
| 18 | - */ | |
| 19 | -@Service(value = "biRankService") | |
| 20 | -@Validated | |
| 21 | -public class BiRankingServiceImpl implements BiRankingService { | |
| 22 | - | |
| 23 | - @Resource | |
| 24 | - private BiRankingMapper biRankingMapper; | |
| 25 | - | |
| 26 | - @Override | |
| 27 | - public List<BiContractRanKingRespVO> contractRanKing(BiRankReqVO biRankReqVO) { | |
| 28 | - BiParams biParams = new BiParams(); | |
| 29 | - biParams.setType(biRankReqVO.getType()); | |
| 30 | - biParams.setDeptId(biRankReqVO.getDeptId()); | |
| 31 | - biParams.setIsUser(0); | |
| 32 | - BiTimeUtil.BiTimeEntity biTimeEntity = BiTimeUtil.analyzeType(biParams); | |
| 33 | - List<Long> userIds = biTimeEntity.getUserIds(); | |
| 34 | - if (userIds.isEmpty()) { | |
| 35 | - return new ArrayList<>(); | |
| 36 | - } | |
| 37 | - return biRankingMapper.contractRanKing(biTimeEntity); | |
| 38 | - } | |
| 39 | - | |
| 40 | - @Override | |
| 41 | - public List<BiReceivablesRanKingRespVO> receivablesRanKing(BiRankReqVO biRankReqVO) { | |
| 42 | - BiParams biParams = new BiParams(); | |
| 43 | - biParams.setType(biRankReqVO.getType()); | |
| 44 | - biParams.setDeptId(biRankReqVO.getDeptId()); | |
| 45 | - biParams.setIsUser(0); | |
| 46 | - BiTimeUtil.BiTimeEntity biTimeEntity = BiTimeUtil.analyzeType(biParams); | |
| 47 | - List<Long> userIds = biTimeEntity.getUserIds(); | |
| 48 | - if (userIds.isEmpty()) { | |
| 49 | - return new ArrayList<>(); | |
| 50 | - } | |
| 51 | - return biRankingMapper.receivablesRanKing(biTimeEntity); | |
| 52 | - } | |
| 53 | -} |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/util/BiTimeUtil.java deleted
| 1 | -package cn.iocoder.yudao.module.bi.util; | |
| 2 | - | |
| 3 | -import cn.hutool.core.date.DateUnit; | |
| 4 | -import cn.hutool.core.date.DateUtil; | |
| 5 | -import cn.hutool.core.util.StrUtil; | |
| 6 | -import cn.hutool.extra.spring.SpringUtil; | |
| 7 | -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; | |
| 8 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiParams; | |
| 9 | -import cn.iocoder.yudao.module.system.api.dept.DeptApi; | |
| 10 | -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | |
| 11 | -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 12 | -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 13 | -import lombok.Data; | |
| 14 | -import lombok.experimental.Accessors; | |
| 15 | - | |
| 16 | -import java.util.ArrayList; | |
| 17 | -import java.util.Date; | |
| 18 | -import java.util.List; | |
| 19 | - | |
| 20 | -/** | |
| 21 | - * bi时间工具类 | |
| 22 | - * | |
| 23 | - * @author anhaohao | |
| 24 | - */ | |
| 25 | -public class BiTimeUtil { | |
| 26 | - | |
| 27 | - public static BiTimeEntity analyzeType(BiParams biParams) { | |
| 28 | - // 解析时间 | |
| 29 | - BiTimeEntity biTimeEntity = analyzeTime(biParams); | |
| 30 | - // 解析权限 | |
| 31 | - // TODO @anhaohao:涉及到数据的读取,不放在 Util 里,还是搞会到 Service 哈; | |
| 32 | - biTimeEntity.setUserIds(analyzeAuth(biParams)); | |
| 33 | - return biTimeEntity; | |
| 34 | - } | |
| 35 | - | |
| 36 | - /** | |
| 37 | - * 解析权限 | |
| 38 | - * | |
| 39 | - * @param biParams bi参数 | |
| 40 | - * @return List<Long> | |
| 41 | - */ | |
| 42 | - public static List<Long> analyzeAuth(BiParams biParams) { | |
| 43 | - List<Long> userIdList = new ArrayList<>(); | |
| 44 | - Long deptId = biParams.getDeptId(); | |
| 45 | - Long userId = biParams.getUserId(); | |
| 46 | - Integer isUser = biParams.getIsUser(); | |
| 47 | - // 获取部门和用户的api | |
| 48 | - DeptApi deptApi = SpringUtil.getBean("deptApiImpl"); | |
| 49 | - AdminUserApi adminUserApi = SpringUtil.getBean("adminUserApiImpl"); | |
| 50 | - // 0.部门 1.用户 | |
| 51 | - if (isUser == 0) { | |
| 52 | - if (deptId == null) { | |
| 53 | - deptId = adminUserApi.getUser(SecurityFrameworkUtils.getLoginUserId()).getDeptId(); | |
| 54 | - } | |
| 55 | - List<DeptRespDTO> childDeptList = deptApi.getChildDeptList(deptId); | |
| 56 | - List<Long> deptIds = new ArrayList<>(); | |
| 57 | - deptIds.add(deptId); | |
| 58 | - if (childDeptList != null && !childDeptList.isEmpty()) { | |
| 59 | - for (DeptRespDTO deptRespDTO : childDeptList) { | |
| 60 | - deptIds.add(deptRespDTO.getId()); | |
| 61 | - } | |
| 62 | - } | |
| 63 | - // 获取部门下的用户 | |
| 64 | - adminUserApi.getUserListByDeptIds(deptIds).forEach(adminUserRespDTO -> userIdList.add(adminUserRespDTO.getId())); | |
| 65 | - } else { | |
| 66 | - if (userId == null) { | |
| 67 | - List<AdminUserRespDTO> userListBySubordinate = adminUserApi.getUserListBySubordinate(SecurityFrameworkUtils.getLoginUserId()); | |
| 68 | - userListBySubordinate.forEach(adminUserRespDTO -> userIdList.add(adminUserRespDTO.getId())); | |
| 69 | - } else { | |
| 70 | - userIdList.add(userId); | |
| 71 | - } | |
| 72 | - } | |
| 73 | - return userIdList; | |
| 74 | - } | |
| 75 | - | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * 解析时间 | |
| 79 | - * | |
| 80 | - * @param biParams bi参数 | |
| 81 | - * @return BiTimeEntity | |
| 82 | - */ | |
| 83 | - public static BiTimeEntity analyzeTime(BiParams biParams) { | |
| 84 | - Date beginDate = DateUtil.date(); | |
| 85 | - Date endDate = DateUtil.date(); | |
| 86 | - int cycleNum = 12; | |
| 87 | - String sqlDateFormat = "%Y%m"; | |
| 88 | - String dateFormat = "yyyyMM"; | |
| 89 | - String type = biParams.getType(); | |
| 90 | - String startTime = biParams.getStartTime(); | |
| 91 | - String endTime = biParams.getEndTime(); | |
| 92 | - if (StrUtil.isNotEmpty(type)) { | |
| 93 | - //1.今天 2.昨天 3.本周 4.上周 5.本月 6.上月 7.本季度 8.上季度 9.本年 10 上年 | |
| 94 | - switch (type) { | |
| 95 | - case "1": | |
| 96 | - beginDate = DateUtil.beginOfDay(DateUtil.date()); | |
| 97 | - endDate = DateUtil.endOfDay(DateUtil.date()); | |
| 98 | - sqlDateFormat = "%Y%m%d"; | |
| 99 | - dateFormat = "yyyyMMdd"; | |
| 100 | - cycleNum = 1; | |
| 101 | - break; | |
| 102 | - case "2": | |
| 103 | - beginDate = DateUtil.beginOfDay(new Date(System.currentTimeMillis() - 86400000)); | |
| 104 | - endDate = DateUtil.endOfDay(new Date(System.currentTimeMillis() - 86400000)); | |
| 105 | - sqlDateFormat = "%Y%m%d"; | |
| 106 | - dateFormat = "yyyyMMdd"; | |
| 107 | - cycleNum = 1; | |
| 108 | - break; | |
| 109 | - case "3": | |
| 110 | - beginDate = DateUtil.beginOfWeek(DateUtil.date()); | |
| 111 | - endDate = DateUtil.endOfWeek(DateUtil.date()); | |
| 112 | - sqlDateFormat = "%Y%m%d"; | |
| 113 | - dateFormat = "yyyyMMdd"; | |
| 114 | - cycleNum = 7; | |
| 115 | - break; | |
| 116 | - case "4": | |
| 117 | - beginDate = DateUtil.beginOfWeek(DateUtil.offsetWeek(DateUtil.date(), -1)); | |
| 118 | - endDate = DateUtil.endOfWeek(DateUtil.offsetWeek(DateUtil.date(), -1)); | |
| 119 | - sqlDateFormat = "%Y%m%d"; | |
| 120 | - dateFormat = "yyyyMMdd"; | |
| 121 | - cycleNum = 7; | |
| 122 | - break; | |
| 123 | - case "5": | |
| 124 | - beginDate = DateUtil.beginOfMonth(DateUtil.date()); | |
| 125 | - endDate = DateUtil.endOfMonth(DateUtil.date()); | |
| 126 | - sqlDateFormat = "%Y%m%d"; | |
| 127 | - dateFormat = "yyyyMMdd"; | |
| 128 | - cycleNum = (int) DateUtil.between(beginDate, endDate, DateUnit.DAY) + 1; | |
| 129 | - break; | |
| 130 | - case "6": | |
| 131 | - beginDate = DateUtil.beginOfMonth(DateUtil.offsetMonth(DateUtil.date(), -1)); | |
| 132 | - endDate = DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.date(), -1)); | |
| 133 | - sqlDateFormat = "%Y%m%d"; | |
| 134 | - dateFormat = "yyyyMMdd"; | |
| 135 | - cycleNum = (int) DateUtil.between(beginDate, endDate, DateUnit.DAY) + 1; | |
| 136 | - break; | |
| 137 | - case "7": | |
| 138 | - beginDate = DateUtil.beginOfQuarter(DateUtil.date()); | |
| 139 | - endDate = DateUtil.endOfQuarter(DateUtil.date()); | |
| 140 | - cycleNum = 3; | |
| 141 | - break; | |
| 142 | - case "8": | |
| 143 | - beginDate = DateUtil.beginOfQuarter(DateUtil.offsetMonth(DateUtil.date(), -3)); | |
| 144 | - endDate = DateUtil.endOfQuarter(DateUtil.offsetMonth(DateUtil.date(), -3)); | |
| 145 | - cycleNum = 3; | |
| 146 | - break; | |
| 147 | - case "9": | |
| 148 | - beginDate = DateUtil.beginOfYear(DateUtil.date()); | |
| 149 | - endDate = DateUtil.endOfYear(DateUtil.date()); | |
| 150 | - break; | |
| 151 | - case "10": | |
| 152 | - beginDate = DateUtil.beginOfYear(DateUtil.offsetMonth(DateUtil.date(), -12)); | |
| 153 | - endDate = DateUtil.endOfYear(DateUtil.offsetMonth(DateUtil.date(), -12)); | |
| 154 | - break; | |
| 155 | - default: | |
| 156 | - break; | |
| 157 | - } | |
| 158 | - } else if (StrUtil.isNotEmpty(startTime) && StrUtil.isNotEmpty(endTime)) { | |
| 159 | - Date start; | |
| 160 | - Date end; | |
| 161 | - if (startTime.length() == 6) { | |
| 162 | - start = DateUtil.parse(startTime, "yyyyMM"); | |
| 163 | - end = DateUtil.endOfMonth(DateUtil.parse(endTime, "yyyyMM")); | |
| 164 | - } else { | |
| 165 | - start = DateUtil.parse(startTime); | |
| 166 | - end = DateUtil.parse(endTime); | |
| 167 | - } | |
| 168 | - Integer startMonth = Integer.valueOf(DateUtil.format(start, "yyyyMM")); | |
| 169 | - int endMonth = Integer.parseInt(DateUtil.format(end, "yyyyMM")); | |
| 170 | - if (startMonth.equals(endMonth)) { | |
| 171 | - sqlDateFormat = "%Y%m%d"; | |
| 172 | - dateFormat = "yyyyMMdd"; | |
| 173 | - long diffDay = DateUtil.between(start, end, DateUnit.DAY); | |
| 174 | - cycleNum = (int) diffDay + 1; | |
| 175 | - } else { | |
| 176 | - sqlDateFormat = "%Y%m"; | |
| 177 | - dateFormat = "yyyyMM"; | |
| 178 | - int diffYear = Integer.parseInt(Integer.toString(endMonth).substring(0, 4)) - Integer.parseInt(startMonth.toString().substring(0, 4)); | |
| 179 | - int diffMonth = endMonth % 100 - startMonth % 100 + 1; | |
| 180 | - cycleNum = diffYear * 12 + diffMonth; | |
| 181 | - } | |
| 182 | - beginDate = start; | |
| 183 | - endDate = end; | |
| 184 | - } | |
| 185 | - Integer beginTime = Integer.valueOf(DateUtil.format(beginDate, dateFormat)); | |
| 186 | - Integer finalTime = Integer.valueOf(DateUtil.format(endDate, dateFormat)); | |
| 187 | - return new BiTimeEntity(sqlDateFormat, dateFormat, beginDate, endDate, cycleNum, beginTime, finalTime, new ArrayList<>()); | |
| 188 | - } | |
| 189 | - | |
| 190 | - @Data | |
| 191 | - @Accessors(chain = true) | |
| 192 | - public static class BiTimeEntity { | |
| 193 | - /** | |
| 194 | - * sql日期格式化 | |
| 195 | - */ | |
| 196 | - private String sqlDateFormat; | |
| 197 | - | |
| 198 | - /** | |
| 199 | - * 日期格式化 | |
| 200 | - */ | |
| 201 | - private String dateFormat; | |
| 202 | - | |
| 203 | - /** | |
| 204 | - * 开始时间 | |
| 205 | - */ | |
| 206 | - private Date beginDate; | |
| 207 | - | |
| 208 | - /** | |
| 209 | - * 结束时间 | |
| 210 | - */ | |
| 211 | - private Date endDate; | |
| 212 | - | |
| 213 | - /** | |
| 214 | - * 周期 | |
| 215 | - */ | |
| 216 | - private Integer cycleNum; | |
| 217 | - | |
| 218 | - /** | |
| 219 | - * 开始时间 字符串格式 如20200101 | |
| 220 | - */ | |
| 221 | - private Integer beginTime; | |
| 222 | - | |
| 223 | - /** | |
| 224 | - * 结束时间 字符串格式 如20200101 | |
| 225 | - */ | |
| 226 | - private Integer finalTime; | |
| 227 | - | |
| 228 | - /** | |
| 229 | - * user列表 | |
| 230 | - */ | |
| 231 | - private List<Long> userIds = new ArrayList<>(); | |
| 232 | - private Integer page; | |
| 233 | - private Integer limit; | |
| 234 | - | |
| 235 | - public BiTimeEntity(String sqlDateFormat, String dateFormat, Date beginDate, Date endDate, Integer cycleNum, Integer beginTime, Integer finalTime, List<Long> userIds) { | |
| 236 | - this.sqlDateFormat = sqlDateFormat; | |
| 237 | - this.dateFormat = dateFormat; | |
| 238 | - this.beginDate = beginDate; | |
| 239 | - this.endDate = endDate; | |
| 240 | - this.cycleNum = cycleNum; | |
| 241 | - this.beginTime = beginTime; | |
| 242 | - this.finalTime = finalTime; | |
| 243 | - this.userIds = userIds; | |
| 244 | - } | |
| 245 | - | |
| 246 | - public BiTimeEntity() { | |
| 247 | - } | |
| 248 | - | |
| 249 | - } | |
| 250 | -} |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.http renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bi/BiRankingController.http
| 1 | 1 | ### 合同金额排行榜 |
| 2 | -GET {{baseUrl}}/bi/rank/contract-ranKing | |
| 2 | +GET {{baseUrl}}/crm/bi-ranking/contract-ranKing | |
| 3 | 3 | Authorization: Bearer {{token}} |
| 4 | 4 | tenant-id: {{adminTenentId}} |
| 5 | 5 | |
| 6 | 6 | ### 回款金额排行榜 |
| 7 | -GET {{baseUrl}}/bi/rank/receivables-ranKing | |
| 7 | +GET {{baseUrl}}/crm/bi-ranking/receivables-ranKing | |
| 8 | 8 | Authorization: Bearer {{token}} |
| 9 | 9 | tenant-id: {{adminTenentId}} |
| 10 | 10 | \ No newline at end of file | ... | ... |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/BiRankingController.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bi/BiRankingController.java
| 1 | -package cn.iocoder.yudao.module.bi.controller.admin.ranking; | |
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.bi; | |
| 2 | + | |
| 2 | 3 | |
| 3 | 4 | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiContractRanKingRespVO; | |
| 6 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiRankReqVO; | |
| 7 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiReceivablesRanKingRespVO; | |
| 8 | -import cn.iocoder.yudao.module.bi.service.ranking.BiRankingService; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRanKingRespVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRankingReqVO; | |
| 8 | +import cn.iocoder.yudao.module.crm.service.bi.BiRankingService; | |
| 9 | 9 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | 10 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | 11 | import jakarta.annotation.Resource; |
| ... | ... | @@ -19,13 +19,10 @@ import java.util.List; |
| 19 | 19 | |
| 20 | 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 21 | 21 | |
| 22 | -// TODO @anhaohao:写了 swagger 注解,不写注释哈 | |
| 23 | -/** | |
| 24 | - * @author anhaohao | |
| 25 | - */ | |
| 22 | + | |
| 26 | 23 | @Tag(name = "管理后台 - 排行榜") |
| 27 | 24 | @RestController |
| 28 | -@RequestMapping("/bi/ranking") | |
| 25 | +@RequestMapping("/crm/bi-ranking") | |
| 29 | 26 | @Validated |
| 30 | 27 | public class BiRankingController { |
| 31 | 28 | |
| ... | ... | @@ -38,8 +35,8 @@ public class BiRankingController { |
| 38 | 35 | @GetMapping("/contract-ranking") |
| 39 | 36 | @Operation(summary = "合同金额排行榜") |
| 40 | 37 | @PreAuthorize("@ss.hasPermission('bi:ranking:query')") |
| 41 | - public CommonResult<List<BiContractRanKingRespVO>> contractAmountRanking(BiRankReqVO biRankReqVO) { | |
| 42 | - return success(biRankingService.contractRanKing(biRankReqVO)); | |
| 38 | + public CommonResult<List<BiRanKingRespVO>> contractAmountRanking(BiRankingReqVO biRankingReqVO) { | |
| 39 | + return success(biRankingService.contractRanKing(biRankingReqVO)); | |
| 43 | 40 | } |
| 44 | 41 | |
| 45 | 42 | /** |
| ... | ... | @@ -48,8 +45,8 @@ public class BiRankingController { |
| 48 | 45 | @GetMapping("/receivables-ranking") |
| 49 | 46 | @Operation(summary = "回款金额排行榜") |
| 50 | 47 | @PreAuthorize("@ss.hasPermission('bi:ranking:query')") |
| 51 | - public CommonResult<List<BiReceivablesRanKingRespVO>> receivablesRanKing(BiRankReqVO biRankReqVO) { | |
| 52 | - return success(biRankingService.receivablesRanKing(biRankReqVO)); | |
| 48 | + public CommonResult<List<BiRanKingRespVO>> receivablesRanKing(BiRankingReqVO biRankingReqVO) { | |
| 49 | + return success(biRankingService.receivablesRanKing(biRankingReqVO)); | |
| 53 | 50 | } |
| 54 | 51 | |
| 55 | 52 | } | ... | ... |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiParams.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bi/vo/BiParams.java
| 1 | -package cn.iocoder.yudao.module.bi.controller.admin.ranking.vo; | |
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.bi.vo; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | import lombok.EqualsAndHashCode; |
| 7 | 7 | |
| 8 | -import java.util.List; | |
| 9 | - | |
| 10 | 8 | // TODO @anhaohao:这个类的命名,还是保持和其它一致使用 ReqVO 结尾;例如说,CrmStatisticsCommonParamReqVO |
| 11 | 9 | /** |
| 12 | 10 | * @author anhaohao |
| ... | ... | @@ -23,9 +21,6 @@ public class BiParams extends PageParam { |
| 23 | 21 | @Schema(description = "用户ID") |
| 24 | 22 | private Long userId; |
| 25 | 23 | |
| 26 | - @Schema(description = "用户IDs") | |
| 27 | - private List<Long> userIds; | |
| 28 | - | |
| 29 | 24 | // TODO @anhaohao:这个字段,可以融合到 startTime、endTime 里去,交给前端计算哈; |
| 30 | 25 | @Schema(description = "类型") |
| 31 | 26 | private String type; |
| ... | ... | @@ -37,8 +32,4 @@ public class BiParams extends PageParam { |
| 37 | 32 | @Schema(description = "结束时间") |
| 38 | 33 | private String endTime; |
| 39 | 34 | |
| 40 | - // TODO @anhaohao:这个字段,是不是直接只基于 deptId 和 userId 来判断即可哈? | |
| 41 | - @Schema(description = "0 部门 1员工") | |
| 42 | - private Integer isUser = 1; | |
| 43 | - | |
| 44 | 35 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bi/vo/BiRanKingRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.bi.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | + | |
| 7 | +@Schema(description = "管理后台 - BI 排行榜 Response VO") | |
| 8 | +@Data | |
| 9 | +public class BiRanKingRespVO { | |
| 10 | + | |
| 11 | + @Schema(description = "金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 12 | + private Integer price; | |
| 13 | + | |
| 14 | + @Schema(description = "姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 15 | + private String nickname; | |
| 16 | + | |
| 17 | + @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 18 | + private String deptName; | |
| 19 | + | |
| 20 | + @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 21 | + private Long ownerUserId; | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/controller/admin/ranking/vo/BiRankReqVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/bi/vo/BiRankingReqVO.java
| 1 | -package cn.iocoder.yudao.module.bi.controller.admin.ranking.vo; | |
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.bi.vo; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | + | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 5 | 11 | |
| 6 | 12 | /** |
| 7 | 13 | * 管理后台 - 排行榜 Request VO |
| ... | ... | @@ -10,13 +16,20 @@ import lombok.Data; |
| 10 | 16 | */ |
| 11 | 17 | @Schema(description = "管理后台 - 排行榜 Request VO") |
| 12 | 18 | @Data |
| 13 | -public class BiRankReqVO { | |
| 19 | +public class BiRankingReqVO { | |
| 14 | 20 | |
| 15 | 21 | @Schema(description = "部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 16 | 22 | private Long deptId; |
| 17 | 23 | |
| 18 | - // TODO @anhaohao:这个字段,参考 BiParams 的 type 建议 | |
| 19 | - @Schema(description = "分析类型(1.今天 2.昨天 3.本周 4.上周 5.本月 6.上月 7.本季度 8.上季度 9.本年 10 上年)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 20 | - private String type; | |
| 24 | + @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-12-12 00:00:00") | |
| 25 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 26 | + private LocalDateTime startTime; | |
| 27 | + | |
| 28 | + @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-12-12 23:59:59") | |
| 29 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 30 | + private LocalDateTime endTime; | |
| 31 | + | |
| 32 | + @Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") | |
| 33 | + private List<Long> userIds; | |
| 21 | 34 | |
| 22 | 35 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| ... | ... | @@ -22,6 +22,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
| 22 | 22 | import jakarta.annotation.Resource; |
| 23 | 23 | import jakarta.servlet.http.HttpServletResponse; |
| 24 | 24 | import jakarta.validation.Valid; |
| 25 | +import org.springframework.context.annotation.Lazy; | |
| 25 | 26 | import org.springframework.security.access.prepost.PreAuthorize; |
| 26 | 27 | import org.springframework.validation.annotation.Validated; |
| 27 | 28 | import org.springframework.web.bind.annotation.*; |
| ... | ... | @@ -44,6 +45,7 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti |
| 44 | 45 | public class CrmContractController { |
| 45 | 46 | |
| 46 | 47 | @Resource |
| 48 | + @Lazy | |
| 47 | 49 | private CrmContractService contractService; |
| 48 | 50 | @Resource |
| 49 | 51 | private CrmCustomerService customerService; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java
| ... | ... | @@ -26,6 +26,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
| 26 | 26 | import jakarta.annotation.Resource; |
| 27 | 27 | import jakarta.servlet.http.HttpServletResponse; |
| 28 | 28 | import jakarta.validation.Valid; |
| 29 | +import org.springframework.context.annotation.Lazy; | |
| 29 | 30 | import org.springframework.security.access.prepost.PreAuthorize; |
| 30 | 31 | import org.springframework.validation.annotation.Validated; |
| 31 | 32 | import org.springframework.web.bind.annotation.*; |
| ... | ... | @@ -51,6 +52,7 @@ public class CrmReceivableController { |
| 51 | 52 | @Resource |
| 52 | 53 | private CrmReceivableService receivableService; |
| 53 | 54 | @Resource |
| 55 | + @Lazy | |
| 54 | 56 | private CrmContractService contractService; |
| 55 | 57 | @Resource |
| 56 | 58 | private CrmCustomerService customerService; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java
| ... | ... | @@ -28,6 +28,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
| 28 | 28 | import jakarta.annotation.Resource; |
| 29 | 29 | import jakarta.servlet.http.HttpServletResponse; |
| 30 | 30 | import jakarta.validation.Valid; |
| 31 | +import org.springframework.context.annotation.Lazy; | |
| 31 | 32 | import org.springframework.security.access.prepost.PreAuthorize; |
| 32 | 33 | import org.springframework.validation.annotation.Validated; |
| 33 | 34 | import org.springframework.web.bind.annotation.*; |
| ... | ... | @@ -55,6 +56,7 @@ public class CrmReceivablePlanController { |
| 55 | 56 | @Resource |
| 56 | 57 | private CrmReceivableService receivableService; |
| 57 | 58 | @Resource |
| 59 | + @Lazy | |
| 58 | 60 | private CrmContractService contractService; |
| 59 | 61 | @Resource |
| 60 | 62 | private CrmCustomerService customerService; | ... | ... |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/dal/mysql/BiRankingMapper.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/bi/BiRankingMapper.java
| 1 | -package cn.iocoder.yudao.module.bi.dal.mysql; | |
| 1 | +package cn.iocoder.yudao.module.crm.dal.mysql.bi; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiContractRanKingRespVO; | |
| 5 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiReceivablesRanKingRespVO; | |
| 6 | -import cn.iocoder.yudao.module.bi.util.BiTimeUtil; | |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRanKingRespVO; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRankingReqVO; | |
| 7 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 8 | 7 | |
| 9 | 8 | import java.util.List; |
| ... | ... | @@ -16,16 +15,17 @@ public interface BiRankingMapper extends BaseMapperX { |
| 16 | 15 | /** |
| 17 | 16 | * 合同金额排行榜 |
| 18 | 17 | * |
| 19 | - * @param biTimeEntity 参数 | |
| 18 | + * @param biRankingReqVO 参数 | |
| 20 | 19 | * @return List<BiContractAmountRankingRespVO> |
| 21 | 20 | */ |
| 22 | - List<BiContractRanKingRespVO> contractRanKing(BiTimeUtil.BiTimeEntity biTimeEntity); | |
| 21 | + List<BiRanKingRespVO> contractRanKing(BiRankingReqVO biRankingReqVO); | |
| 22 | + | |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * 回款金额排行榜 |
| 26 | 26 | * |
| 27 | - * @param biTimeEntity 参数 | |
| 27 | + * @param biRankingReqVO 参数 | |
| 28 | 28 | * @return List<BiContractAmountRankingRespVO> |
| 29 | 29 | */ |
| 30 | - List<BiReceivablesRanKingRespVO> receivablesRanKing(BiTimeUtil.BiTimeEntity biTimeEntity); | |
| 30 | + List<BiRanKingRespVO> receivablesRanKing(BiRankingReqVO biRankingReqVO); | |
| 31 | 31 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContractParseFunction.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| 6 | 6 | import com.mzt.logapi.service.IParseFunction; |
| 7 | 7 | import jakarta.annotation.Resource; |
| 8 | 8 | import lombok.extern.slf4j.Slf4j; |
| 9 | +import org.springframework.context.annotation.Lazy; | |
| 9 | 10 | import org.springframework.stereotype.Component; |
| 10 | 11 | |
| 11 | 12 | /** |
| ... | ... | @@ -20,6 +21,7 @@ public class CrmContractParseFunction implements IParseFunction { |
| 20 | 21 | public static final String NAME = "getContractById"; |
| 21 | 22 | |
| 22 | 23 | @Resource |
| 24 | + @Lazy | |
| 23 | 25 | private CrmContractService contractService; |
| 24 | 26 | |
| 25 | 27 | @Override | ... | ... |
yudao-module-crm/yudao-module-bi-biz/src/main/java/cn/iocoder/yudao/module/bi/service/ranking/BiRankingService.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/bi/BiRankingService.java
| 1 | -package cn.iocoder.yudao.module.bi.service.ranking; | |
| 1 | +package cn.iocoder.yudao.module.crm.service.bi; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiContractRanKingRespVO; | |
| 4 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiRankReqVO; | |
| 5 | -import cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiReceivablesRanKingRespVO; | |
| 3 | + | |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRanKingRespVO; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRankingReqVO; | |
| 6 | 6 | |
| 7 | 7 | import java.util.List; |
| 8 | 8 | |
| ... | ... | @@ -11,20 +11,21 @@ import java.util.List; |
| 11 | 11 | * |
| 12 | 12 | * @author anhaohao |
| 13 | 13 | */ |
| 14 | -public interface BiRankingService { // TODO @anhaohao:第一个方法,和类要有一个空行 | |
| 14 | +public interface BiRankingService { | |
| 15 | + | |
| 15 | 16 | /** |
| 16 | 17 | * 合同金额排行榜 |
| 17 | 18 | * |
| 18 | - * @param biRankReqVO 参数 | |
| 19 | + * @param biRankingReqVO 参数 | |
| 19 | 20 | * @return List<BiContractAmountRankingRespVO> |
| 20 | 21 | */ |
| 21 | - List<BiContractRanKingRespVO> contractRanKing(BiRankReqVO biRankReqVO); | |
| 22 | + List<BiRanKingRespVO> contractRanKing(BiRankingReqVO biRankingReqVO); | |
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * 回款金额排行榜 |
| 25 | 26 | * |
| 26 | - * @param biRankReqVO 参数 | |
| 27 | + * @param biRankingReqVO 参数 | |
| 27 | 28 | * @return List<BiContractAmountRankingRespVO> |
| 28 | 29 | */ |
| 29 | - List<BiReceivablesRanKingRespVO> receivablesRanKing(BiRankReqVO biRankReqVO); | |
| 30 | + List<BiRanKingRespVO> receivablesRanKing(BiRankingReqVO biRankingReqVO); | |
| 30 | 31 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/bi/BiRankingServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.service.bi; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRanKingRespVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRankingReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.dal.mysql.bi.BiRankingMapper; | |
| 8 | +import cn.iocoder.yudao.module.system.api.dept.DeptApi; | |
| 9 | +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | |
| 10 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 11 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 12 | +import jakarta.annotation.Resource; | |
| 13 | +import org.springframework.stereotype.Service; | |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 15 | + | |
| 16 | +import java.util.ArrayList; | |
| 17 | +import java.util.List; | |
| 18 | +import java.util.Map; | |
| 19 | +import java.util.function.Function; | |
| 20 | +import java.util.stream.Collectors; | |
| 21 | + | |
| 22 | +@Service(value = "biRankingService") | |
| 23 | +@Validated | |
| 24 | +public class BiRankingServiceImpl implements BiRankingService { | |
| 25 | + | |
| 26 | + @Resource | |
| 27 | + private BiRankingMapper biRankingMapper; | |
| 28 | + @Resource | |
| 29 | + private AdminUserApi adminUserApi; | |
| 30 | + @Resource | |
| 31 | + private DeptApi deptApi; | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public List<BiRanKingRespVO> contractRanKing(BiRankingReqVO biRankingReqVO) { | |
| 35 | + return processRanking(biRankingReqVO, biRankingMapper::contractRanKing); | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public List<BiRanKingRespVO> receivablesRanKing(BiRankingReqVO biRankingReqVO) { | |
| 40 | + return processRanking(biRankingReqVO, biRankingMapper::receivablesRanKing); | |
| 41 | + } | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 处理排行榜 | |
| 45 | + * | |
| 46 | + * @param biRankingReqVO 参数 | |
| 47 | + * @param rankingFunction 排行榜方法 | |
| 48 | + * @return List<BiRanKingRespVO> | |
| 49 | + */ | |
| 50 | + private List<BiRanKingRespVO> processRanking(BiRankingReqVO biRankingReqVO, Function<BiRankingReqVO, List<BiRanKingRespVO>> rankingFunction) { | |
| 51 | + analyzeAuth(biRankingReqVO); | |
| 52 | + if (biRankingReqVO.getUserIds().isEmpty()) { | |
| 53 | + return new ArrayList<>(); | |
| 54 | + } | |
| 55 | + List<BiRanKingRespVO> biRanKingRespVOS = rankingFunction.apply(biRankingReqVO); | |
| 56 | + return setName(biRanKingRespVOS); | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 设置用户名称 | |
| 61 | + * | |
| 62 | + * @param biRanKingRespVOS 排行榜数据 | |
| 63 | + * @return List<BiRanKingRespVO> | |
| 64 | + */ | |
| 65 | + private List<BiRanKingRespVO> setName(List<BiRanKingRespVO> biRanKingRespVOS) { | |
| 66 | + List<Long> userIds = biRanKingRespVOS.stream().map(BiRanKingRespVO::getOwnerUserId).collect(Collectors.toList()); | |
| 67 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); | |
| 68 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toList())); | |
| 69 | + for (BiRanKingRespVO biRanKingRespVO : biRanKingRespVOS) { | |
| 70 | + AdminUserRespDTO adminUserRespDTO = userMap.get(biRanKingRespVO.getOwnerUserId()); | |
| 71 | + if (adminUserRespDTO != null) { | |
| 72 | + biRanKingRespVO.setNickname(adminUserRespDTO.getNickname()); | |
| 73 | + DeptRespDTO deptRespDTO = deptMap.get(adminUserRespDTO.getDeptId()); | |
| 74 | + if (deptRespDTO != null) { | |
| 75 | + biRanKingRespVO.setDeptName(deptRespDTO.getName()); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + } | |
| 79 | + return biRanKingRespVOS; | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * 分析权限 | |
| 84 | + * | |
| 85 | + * @param biRankingReqVO 参数 | |
| 86 | + */ | |
| 87 | + public void analyzeAuth(BiRankingReqVO biRankingReqVO) { | |
| 88 | + Long deptId = biRankingReqVO.getDeptId() == null ? adminUserApi.getUser(SecurityFrameworkUtils.getLoginUserId()).getDeptId() : biRankingReqVO.getDeptId(); | |
| 89 | + List<Long> deptIds = deptApi.getChildDeptList(deptId).stream().map(DeptRespDTO::getId).collect(Collectors.toList()); | |
| 90 | + deptIds.add(deptId); | |
| 91 | + biRankingReqVO.setUserIds(adminUserApi.getUserListByDeptIds(deptIds).stream().map(AdminUserRespDTO::getId).collect(Collectors.toList())); | |
| 92 | + } | |
| 93 | +} | |
| 0 | 94 | \ No newline at end of file | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| ... | ... | @@ -28,6 +28,7 @@ import com.mzt.logapi.context.LogRecordContext; |
| 28 | 28 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| 29 | 29 | import com.mzt.logapi.starter.annotation.LogRecord; |
| 30 | 30 | import jakarta.annotation.Resource; |
| 31 | +import org.springframework.context.annotation.Lazy; | |
| 31 | 32 | import org.springframework.stereotype.Service; |
| 32 | 33 | import org.springframework.transaction.annotation.Transactional; |
| 33 | 34 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -56,6 +57,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 56 | 57 | @Resource |
| 57 | 58 | private CrmBusinessProductService businessProductService; |
| 58 | 59 | @Resource |
| 60 | + @Lazy | |
| 59 | 61 | private CrmContractService contractService; |
| 60 | 62 | @Resource |
| 61 | 63 | private CrmPermissionService permissionService; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| ... | ... | @@ -25,6 +25,7 @@ import com.mzt.logapi.context.LogRecordContext; |
| 25 | 25 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| 26 | 26 | import com.mzt.logapi.starter.annotation.LogRecord; |
| 27 | 27 | import jakarta.annotation.Resource; |
| 28 | +import org.springframework.context.annotation.Lazy; | |
| 28 | 29 | import org.springframework.stereotype.Service; |
| 29 | 30 | import org.springframework.transaction.annotation.Transactional; |
| 30 | 31 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -56,6 +57,7 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 56 | 57 | @Resource |
| 57 | 58 | private CrmPermissionService permissionService; |
| 58 | 59 | @Resource |
| 60 | + @Lazy | |
| 59 | 61 | private CrmContractService contractService; |
| 60 | 62 | @Resource |
| 61 | 63 | private CrmContactBusinessService contactBusinessService; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java
| ... | ... | @@ -24,6 +24,7 @@ import com.mzt.logapi.context.LogRecordContext; |
| 24 | 24 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| 25 | 25 | import com.mzt.logapi.starter.annotation.LogRecord; |
| 26 | 26 | import jakarta.annotation.Resource; |
| 27 | +import org.springframework.context.annotation.Lazy; | |
| 27 | 28 | import org.springframework.stereotype.Service; |
| 28 | 29 | import org.springframework.validation.annotation.Validated; |
| 29 | 30 | |
| ... | ... | @@ -49,6 +50,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { |
| 49 | 50 | private CrmReceivablePlanMapper receivablePlanMapper; |
| 50 | 51 | |
| 51 | 52 | @Resource |
| 53 | + @Lazy | |
| 52 | 54 | private CrmContractService contractService; |
| 53 | 55 | @Resource |
| 54 | 56 | private CrmCustomerService customerService; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
| ... | ... | @@ -27,6 +27,7 @@ import com.mzt.logapi.context.LogRecordContext; |
| 27 | 27 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| 28 | 28 | import com.mzt.logapi.starter.annotation.LogRecord; |
| 29 | 29 | import jakarta.annotation.Resource; |
| 30 | +import org.springframework.context.annotation.Lazy; | |
| 30 | 31 | import org.springframework.stereotype.Service; |
| 31 | 32 | import org.springframework.validation.annotation.Validated; |
| 32 | 33 | |
| ... | ... | @@ -50,6 +51,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { |
| 50 | 51 | private CrmReceivableMapper receivableMapper; |
| 51 | 52 | |
| 52 | 53 | @Resource |
| 54 | + @Lazy | |
| 53 | 55 | private CrmContractService contractService; |
| 54 | 56 | @Resource |
| 55 | 57 | private CrmCustomerService customerService; | ... | ... |
yudao-module-crm/yudao-module-bi-biz/src/main/resources/mapper/rank/BiRankingMapper.xml renamed to yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/bi/BiRankingMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | -<mapper namespace="cn.iocoder.yudao.module.bi.dal.mysql.BiRankingMapper"> | |
| 3 | +<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.bi.BiRankingMapper"> | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | <select id="contractRanKing" |
| 7 | - resultType="cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiContractRanKingRespVO"> | |
| 8 | - SELECT IFNULL(SUM(t.price), 0) AS price, su.nickname, t.owner_user_id, dept.name AS deptName | |
| 7 | + resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRanKingRespVO"> | |
| 8 | + SELECT IFNULL(SUM(t.price), 0) AS price, t.owner_user_id | |
| 9 | 9 | FROM crm_contract t |
| 10 | - <!-- TODO @anhaohao:system_users、system_dept 是不是没用到?尽量不连这 2 个表,微服务下会是独立仓库;如果显示需要,可以在 service 读取后拼接; --> | |
| 11 | - LEFT JOIN system_users AS su ON su.id = t.owner_user_id | |
| 12 | - LEFT JOIN system_dept AS dept ON dept.id = su.dept_id | |
| 13 | 10 | WHERE t.deleted = 0 |
| 14 | 11 | AND t.audit_status = 20 |
| 15 | - <if test="userIds != null and userIds.size() > 0"> | |
| 16 | - and t.owner_user_id in | |
| 17 | - <foreach collection="userIds" item="item" open="(" close=")" separator=","> | |
| 18 | - #{item} | |
| 19 | - </foreach> | |
| 20 | - </if> | |
| 21 | - <!-- TODO @anhaohao:在某个区间的时间,这么做有点浪费性能;一般做法是 beginTime 是开始时间(00:00:00),finalTime 是结束时间(23:59:59),这样实现的; --> | |
| 22 | - AND DATE_FORMAT(t.order_date,'${sqlDateFormat}') between #{beginTime} and #{finalTime} | |
| 12 | + and t.owner_user_id in | |
| 13 | + <foreach collection="userIds" item="item" open="(" close=")" separator=","> | |
| 14 | + #{item} | |
| 15 | + </foreach> | |
| 16 | + AND t.order_date between #{startTime} and #{endTime} | |
| 23 | 17 | GROUP BY t.owner_user_id |
| 24 | 18 | ORDER BY price DESC |
| 25 | 19 | </select> |
| 26 | 20 | |
| 27 | 21 | <select id="receivablesRanKing" |
| 28 | - resultType="cn.iocoder.yudao.module.bi.controller.admin.ranking.vo.BiReceivablesRanKingRespVO"> | |
| 29 | - SELECT IFNULL(SUM(t.price), 0) AS price, su.nickname, t.owner_user_id, dept.name AS deptName | |
| 22 | + resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.BiRanKingRespVO"> | |
| 23 | + SELECT IFNULL(SUM(t.price), 0) AS price, t.owner_user_id | |
| 30 | 24 | FROM crm_receivable t |
| 31 | - LEFT JOIN system_users AS su ON su.id = t.owner_user_id | |
| 32 | - LEFT JOIN system_dept AS dept ON dept.id = su.dept_id | |
| 33 | 25 | WHERE t.deleted = 0 |
| 34 | 26 | AND t.audit_status = 20 |
| 35 | - <if test="userIds != null and userIds.size() > 0"> | |
| 36 | - and t.owner_user_id in | |
| 37 | - <foreach collection="userIds" item="item" open="(" close=")" separator=","> | |
| 38 | - #{item} | |
| 39 | - </foreach> | |
| 40 | - </if> | |
| 41 | - AND DATE_FORMAT(t.return_time,'${sqlDateFormat}') between #{beginTime} and #{finalTime} | |
| 27 | + and t.owner_user_id in | |
| 28 | + <foreach collection="userIds" item="item" open="(" close=")" separator=","> | |
| 29 | + #{item} | |
| 30 | + </foreach> | |
| 31 | + AND t.return_time between #{startTime} and #{endTime} | |
| 42 | 32 | GROUP BY t.owner_user_id |
| 43 | 33 | ORDER BY price DESC |
| 44 | 34 | </select> | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java
yudao-server/pom.xml
| ... | ... | @@ -93,11 +93,6 @@ |
| 93 | 93 | <artifactId>yudao-module-crm-biz</artifactId> |
| 94 | 94 | <version>${revision}</version> |
| 95 | 95 | </dependency> |
| 96 | - <dependency> | |
| 97 | - <groupId>cn.iocoder.boot</groupId> | |
| 98 | - <artifactId>yudao-module-bi-biz</artifactId> | |
| 99 | - <version>${revision}</version> | |
| 100 | - </dependency> | |
| 101 | 96 | |
| 102 | 97 | <!-- ERP 相关模块。默认注释,保证编译速度 --> |
| 103 | 98 | <dependency> | ... | ... |