huliguo
2025-05-13 a70919b4f7baab856125f36e5bd41f5ee81be680
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.cl.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.cl.common.result.Result;
import com.cl.pojo.dto.AddDataDTO;
 
import com.cl.pojo.dto.DataPageDTO;
import com.cl.pojo.entity.DataEntity;
 
import com.cl.pojo.vo.DataDetailVO;
import com.cl.pojo.vo.DataVO;
import com.cl.pojo.vo.EditDataDTO;
 
import com.cl.pojo.vo.screen.ScreenVO;
import com.cl.service.DataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.time.Year;
import java.util.Date;
import java.util.List;
 
 
@RestController
@RequestMapping("/data")
@Slf4j
@Api(tags = "数据")
public class DataController {
 
    @Autowired
    private DataService dataService;
    /**
     * 新增
     */
    @PostMapping("/add")
    @ApiOperation("数据上报")
    public Result<String> add(@RequestBody @Valid AddDataDTO addDataDTO) {
        dataService.add(addDataDTO);
        return Result.success("上传成功");
    }
 
    /**
     * 分页
     */
    @PostMapping("/pageList")
    @ApiOperation("用户分页查询")
    public Result<IPage<DataVO>>  selectPageUser(@RequestBody @Valid DataPageDTO dataPageDTO){
        IPage<DataEntity> page = new Page<>(dataPageDTO.getPageNum(), dataPageDTO.getPageSize());
        IPage<DataVO> iPage=dataService.pageList(page,dataPageDTO.getCountyList(),dataPageDTO.getName());
        return Result.success(iPage);
    }
 
    /**
     * 列表查看详情(数据回显) 返回两次数据 查询该id和该id上一次数据   同比增加减少
     */
    @PostMapping("/detail")
    @ApiOperation("查看详情")
    public Result<DataDetailVO> detail(@RequestParam(value = "id")Integer id) {
 
        return Result.success( dataService.detail(id));
    }
 
    /**
     * 新增回显
     */
    @PostMapping("/add/detail")
    @ApiOperation("查看详情(新增回显上一次数据)")
    public Result<DataDetailVO> addDetail(@RequestParam(value = "county" )Integer county) {
        return Result.success( dataService.addDetail(county));
    }
 
    /**
     * 修改
     */
    @PutMapping("/edit")
    @ApiOperation("数据修改")
    public Result<String> edit(@RequestBody @Valid EditDataDTO editDataDTO) {
        dataService.edit(editDataDTO);
        return Result.success("修改成功");
    }
 
    /**
     * 删除
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除数据")
    public Result<String> delete(@PathVariable Integer id) {
        dataService.delete(id);
        return Result.success("删除成功");
    }
 
    /**
     * 大屏数据
     */
    @PostMapping("/screen")
    @ApiOperation("大屏数据")
    public Result<ScreenVO> screen(@RequestParam(value = "county",required = false)Integer county,
                                   @RequestParam(value = "year",required = false)Integer year) {
        if (year == null){
            year = Year.now().getValue();
        }
        return Result.success( dataService.screen(county==null?0:county,year));
    }
    /**
     * 补贴总人数
     */
    @GetMapping("/getAssistiveDeviceTotal")
    @ApiOperation("补贴总人数")
    public Result<Integer> getAssistiveDeviceTotal(@RequestParam(value = "county",required = false)Integer county,@RequestParam("year") Integer year) {
 
        return Result.success( dataService.getAssistiveDeviceTotal(county==null?0:county,year));
    }
 
    /**
     * 可选择年份列表
     */
    @GetMapping("/getYearList")
    @ApiOperation("可选择年份列表")
    public Result<List<Integer>> getYearList(@RequestParam(value = "county",required = false)Integer county) {
        return Result.success( dataService.getYearList( county));
    }
 
 
}