liding
昨天 f29c8786807015d78b9be8a33397f69478d92a76
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 com.ruoyi.business.controller;
 
import com.ruoyi.business.dto.HomePageDto;
import com.ruoyi.business.dto.YearlyQueryDto;
import com.ruoyi.business.service.OfficialInventoryService;
import com.ruoyi.business.service.SalesRecordService;
import com.ruoyi.common.core.domain.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
 
@RestController
@AllArgsConstructor
@RequestMapping("/homePage")
public class HomePageController {
 
    private SalesRecordService salesRecordService;
    
    private OfficialInventoryService officialInventoryService;
 
    @GetMapping("/allInfo")
    private R<HomePageDto> homePageDto() {
        HomePageDto homePageDto = new HomePageDto();
        Map<String, Object> map = salesRecordService.selectAllInfo();
        //营收金额
        homePageDto.setRevenueAmount((BigDecimal) map.get("revenueAmount"));
        homePageDto.setChangeRate(map.get("changeRate").toString());
        homePageDto.setTrend(map.get("trend").toString());
        //供应量
        homePageDto.setSaleQuantity((BigDecimal) map.get("saleQuantity"));
        homePageDto.setSaleQuantityRate(map.get("saleQuantityRate").toString());
        homePageDto.setTrendQuantity(map.get("trendQuantity").toString());
        //营收分布
        homePageDto.setRevenueDistribution((Map<String, BigDecimal>) map.get("revenueDistribution"));
        //库存统计
        Map<String, BigDecimal> maps = officialInventoryService.selectOfficialAllInfo();
        homePageDto.setInventory(maps);
        //月度统计
        homePageDto.setResultMouth((Map<String, BigDecimal>) map.get("resultMouth"));
 
        //销售数据
        homePageDto.setSalesResults((List<Map<String, Object>>) map.get("salesResults"));
 
        return R.ok(homePageDto);
    }
 
    @PostMapping("/yearlySales")
    public R<Map<String, Object>> getYearlyMonthlySales(@RequestBody YearlyQueryDto query) {
        Map<String, Object> data = salesRecordService.getYearlyMonthlySales(query);
        return R.ok(data);
    }
 
}