xiaoyi
22 小时以前 8782476e9cb4480be5da588888d08022b7942d0c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package cn.iocoder.yudao.module.srm.controller.admin.statistics;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.srm.controller.admin.statistics.vo.SrmCostAnalysisRespVO;
import cn.iocoder.yudao.module.srm.controller.admin.statistics.vo.SrmTenderStatisticsRespVO;
import cn.iocoder.yudao.module.srm.service.statistics.SrmCostAnalysisService;
import cn.iocoder.yudao.module.srm.service.statistics.SrmStatisticsService;
import jakarta.validation.Valid;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - SRM 统计分析")
@RestController
@RequestMapping("/srm/statistics")
@Validated
public class SrmStatisticsController {
 
    @Resource
    private SrmStatisticsService statisticsService;
    @Resource
    private SrmCostAnalysisService costAnalysisService;
 
    @GetMapping("/tender")
    @Operation(summary = "获取招标统计数据")
    @PreAuthorize("@ss.hasPermission('srm:statistics:query')")
    public CommonResult<SrmTenderStatisticsRespVO> getTenderStatistics(@RequestParam("year") String year) {
        return success(statisticsService.getTenderStatistics(year));
    }
 
    @GetMapping("/cost-analysis")
    @Operation(summary = "采购成本分析",
            description = "基于 SRM 招标需求量与供应商报价聚合:采购量、加权均价、最低/最高价、价格变动;不依赖 ERP")
    @PreAuthorize("@ss.hasPermission('srm:statistics:query')")
    public CommonResult<PageResult<SrmCostAnalysisRespVO>> getCostAnalysis(
            @Valid PageParam page,
            @RequestParam(value = "productName", required = false) String productName) {
        return success(costAnalysisService.page(page, productName));
    }
 
    @GetMapping("/cost-trend")
    @Operation(summary = "物料价格趋势", description = "按月汇总该物料的平均报价")
    @PreAuthorize("@ss.hasPermission('srm:statistics:query')")
    public CommonResult<java.util.List<SrmCostAnalysisRespVO.TrendPoint>> getCostTrend(
            @RequestParam("productId") Long productId) {
        return success(costAnalysisService.trend(productId));
    }
 
}