Crunchy
2025-06-14 b2f31607cbe26d721cd7514b619162b3e355b1aa
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
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.wms_admin.server.controller;
 
import com.wms_admin.server.service.ProductService;
import com.wms_admin.utils.RedisUtil;
import com.wms_admin.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Api(tags = "首页数据")
@RestController
@RequestMapping("/home")
public class HomeController {
    @Autowired
    private ProductService service;
 
    @ApiOperation(value = "首页数据")
    @GetMapping(value = "/exceed")
    public Result<Map<String,Object>> SelectExceedThirtyDayData(){
        Map<String, Object> map = null;
        try {
            // 超过七天的数据
            List<Map<String, Object>> ExceedThirtyDay = service.SelectExceedThirtyDayData();
            Map<String, Object> WeekNumData = service.SelectWeekNumData();
            List<Map<String, Object>> PieData;
            Object sevenDaysCount;
            try {
                PieData = service.PieData();
            } catch (Exception e) {
                PieData = null;
            }
            try {
                sevenDaysCount = RedisUtil.get("SevenDaysCount");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            map = new HashMap<>();
            map.put("ExceedThirtyDay", ExceedThirtyDay);
            map.put("WeekNumData", WeekNumData);
            map.put("DailyTotal", sevenDaysCount);
            map.put("PieData", PieData);
        } catch (Exception e) {
            return Result.success("数据为空,请添加数据!");
        }
        return Result.success(map);
    }
 
    @ApiOperation(value = "根据名称查询数据")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "productName", value = "入库设备名称", dataTypeClass = String.class, required = true)
    })
    @GetMapping(value = "/name")
    public Result<Map<String,Object>> SelectNameData(String productName){
        // 当前入库表中的数据
        List<Map<String, Object>> NameData = service.SelectNameData(productName);
        Map<String, Object> map = new HashMap<>();
        map.put("productName", NameData);
        return Result.success(map);
    }
}