diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java index 00e13ef23..53b5574f9 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java @@ -27,12 +27,6 @@ public class DateUtils { public static final String FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND = "yyyy-MM-dd HH:mm:ss"; - public static final String FORMAT_YEAR = "yyyy"; - - public static final String FORMAT_YEAR_MONTH = "yyyy-MM"; - - - public static final String FORMAT_HOUR_MINUTE_SECOND = "HH:mm:ss"; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsStaffPerformanceController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsStaffPerformanceController.java deleted file mode 100644 index 1581611fb..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsStaffPerformanceController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsStaffPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsStaffPerformanceRespVO; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsStaffPerformanceService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - - -@Tag(name = "管理后台 - CRM 员工业绩统计") -@RestController -@RequestMapping("/crm/statistics-performance") -@Validated -public class CrmStatisticsStaffPerformanceController { - - @Resource - private CrmStatisticsStaffPerformanceService performanceService; - - @GetMapping("/get-contract-count-performance") - @Operation(summary = "员工业绩-签约合同数量") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getContractCountStaffPerformance(@Valid CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO) { - return success(performanceService.getContractCountStaffPerformance(staffPerformanceReqVO)); - } - - @GetMapping("/get-contract-price-performance") - @Operation(summary = "员工业绩-获得合同金额") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getContractPriceStaffPerformance(@Valid CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO) { - return success(performanceService.getContractPriceStaffPerformance(staffPerformanceReqVO)); - } - - @GetMapping("/get-receivable-price-performance") - @Operation(summary = "员工业绩-获得回款金额") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getReceivablePriceStaffPerformance(@Valid CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO) { - return success(performanceService.getReceivablePriceStaffPerformance(staffPerformanceReqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/CrmStatisticsStaffPerformanceReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/CrmStatisticsStaffPerformanceReqVO.java deleted file mode 100644 index 8d5d2bf5e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/CrmStatisticsStaffPerformanceReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 员工业绩统计 Request VO") -@Data -public class CrmStatisticsStaffPerformanceReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - - @Schema(description = "年", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR) - @NotEmpty(message = "时间不能为空") - private LocalDateTime year; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/CrmStatisticsStaffPerformanceRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/CrmStatisticsStaffPerformanceRespVO.java deleted file mode 100644 index 859ce9c4f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/CrmStatisticsStaffPerformanceRespVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotEmpty; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH; - -@Schema(description = "管理后台 - CRM 员工业绩统计 Response VO") -@Data -public class CrmStatisticsStaffPerformanceRespVO { - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long ownerUserId; - - @Schema(description = "姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String nickname; - - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String deptName; - - @Schema(description = "年-月", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH) - @NotEmpty(message = "时间不能为空") - private LocalDateTime orderDate; - - /** - * 数量是个特别“抽象”的概念,在不同排行下,代表不同含义 - * - * 1. 金额:合同金额排行、回款金额排行 - * 2. 个数:签约合同排行、产品销量排行、产品销量排行、新增客户数排行、新增联系人排行、跟进次数排行、跟进客户数排行 - */ - @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsStaffPerformanceMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsStaffPerformanceMapper.java deleted file mode 100644 index 0623c78af..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsStaffPerformanceMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsStaffPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsStaffPerformanceRespVO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -@Mapper -public interface CrmStatisticsStaffPerformanceMapper { - - /** - * 员工签约合同数量 - * - * @param staffPerformanceReqVO 参数 - * @return 员工签约合同数量 - */ - List selectContractCountStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO); - - - /** - * 员工签约合同金额 - * - * @param staffPerformanceReqVO 参数 - * @return 员工签约合同金额 - */ - List selectContractPriceStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO); - - /** - * 员工回款金额 - * - * @param staffPerformanceReqVO 参数 - * @return 员工回款金额 - */ - List selectReceivablePriceStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO); - - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsStaffPerformanceService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsStaffPerformanceService.java deleted file mode 100644 index 208095d32..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsStaffPerformanceService.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - - - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsStaffPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsStaffPerformanceRespVO; - -import java.util.List; - -/** - * CRM 员工绩效统计 Service 接口 - * - * @author scholar - */ -public interface CrmStatisticsStaffPerformanceService { - - /** - * 员工签约合同数量分析 - * - * @param staffPerformanceReqVO 排行参数 - * @return 员工签约合同数量排行分析 - */ - List getContractCountStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO); - - /** - * 员工签约合同金额分析 - * - * @param staffPerformanceReqVO 排行参数 - * @return 员工签约合同金额分析 - */ - List getContractPriceStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO); - - /** - * 员工获得回款金额分析 - * - * @param staffPerformanceReqVO 排行参数 - * @return 员工获得回款金额分析 - */ - List getReceivablePriceStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO); - - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsStaffPerformanceServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsStaffPerformanceServiceImpl.java deleted file mode 100644 index 8dceafcde..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsStaffPerformanceServiceImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsStaffPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsStaffPerformanceRespVO; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsStaffPerformanceMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * CRM 员工业绩分析 Service 实现类 - * - * @author scholar - */ -@Service -@Validated -public class CrmStatisticsStaffPerformanceServiceImpl implements CrmStatisticsStaffPerformanceService { - - @Resource - private CrmStatisticsStaffPerformanceMapper staffPerformanceMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - - - @Override - public List getContractCountStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO) { - return getStaffPerformance(staffPerformanceReqVO, staffPerformanceMapper::selectContractCountStaffPerformance); - } - @Override - public List getContractPriceStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO) { - return getStaffPerformance(staffPerformanceReqVO, staffPerformanceMapper::selectContractPriceStaffPerformance); - } - - @Override - public List getReceivablePriceStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO) { - return getStaffPerformance(staffPerformanceReqVO, staffPerformanceMapper::selectReceivablePriceStaffPerformance); - } - - - - /** - * 获得员工业绩数据 - * - * @param staffPerformanceReqVO 参数 - * @param staffPerformanceFunction 排行榜方法 - * @return 排行版数据 - */ - private List getStaffPerformance(CrmStatisticsStaffPerformanceReqVO staffPerformanceReqVO, Function> staffPerformanceFunction) { - - // 1. 获得员工业绩数据 - List performance = staffPerformanceFunction.apply(staffPerformanceReqVO); - if (CollUtil.isEmpty(performance)) { - return Collections.emptyList(); - } - performance.sort(Comparator.comparing(CrmStatisticsStaffPerformanceRespVO::getCount).reversed()); - // 3. 拼接用户信息 - appendUserInfo(performance); - return performance; - } - - /** - * 拼接用户信息(昵称、部门) - * - * @param performances 员工业绩数据 - */ - private void appendUserInfo(List performances) { - Map userMap = adminUserApi.getUserMap(convertSet(performances, CrmStatisticsStaffPerformanceRespVO::getOwnerUserId)); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - performances.forEach(performance -> MapUtils.findAndThen(userMap, performance.getOwnerUserId(), user -> { - performance.setNickname(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> performance.setDeptName(dept.getName())); - })); - } - - - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/bi/CrmBiStaffPerformanceMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/bi/CrmBiStaffPerformanceMapper.xml deleted file mode 100644 index 0f930e7d3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/bi/CrmBiStaffPerformanceMapper.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - -