xuefei
2020-12-13 59380c11771d47459b8db5425bc21293823ada74
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
package cn.cetc54.platform.zhyl.api;
 
import cn.cetc54.platform.core.common.utils.ResultUtil;
import cn.cetc54.platform.core.common.vo.Result;
import cn.cetc54.platform.zhyl.entity.SubsidyPersonStatics;
import cn.cetc54.platform.zhyl.service.ISubsidyPersonStaticsService;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
/**
 * @author xfei
 * @date 2020/12/12
 */
@Slf4j
@RestController
@Api(description = "服务对象")
@RequestMapping("/api2/fwdx")
@Transactional
@CrossOrigin("*")
public class FwdxController {
    @Autowired
    private ISubsidyPersonStaticsService iSubsidyPersonStaticsService;
    @GetMapping("getStaticsData")
    @ApiOperation(value = "获取统计数据")
    public Result getStaticsData(String areaId,Integer type){
        if (StrUtil.isEmpty(areaId)){
            return ResultUtil.error("缺少参数");
        }
        String month = DateUtil.format(new Date(),"yyyy-MM");
        QueryWrapper<SubsidyPersonStatics> query = new QueryWrapper<>();
        query.lambda().eq(SubsidyPersonStatics::getAreaId,areaId);
        query.lambda().eq(SubsidyPersonStatics::getMonth,month);
        if (type!=null){
            query.lambda().eq(SubsidyPersonStatics::getSubsidyType,type);
        }
        List<SubsidyPersonStatics> list = iSubsidyPersonStaticsService.list(query);
        SubsidyPersonStatics statics = new SubsidyPersonStatics();
        statics.setChild(list);
        list.forEach(e->{
            statics.setMonth(e.getMonth());
            statics.setYearAdd(statics.getYearAdd()+e.getYearAdd());
            statics.setYearOut(statics.getYearOut()+e.getYearOut());
            statics.setYearSum(statics.getYearSum()+e.getYearSum());
            statics.setMonthAdd(statics.getMonthAdd()+e.getMonthAdd());
            statics.setMonthOut(statics.getMonthOut()+e.getMonthOut());
            statics.setMonthSum(statics.getMonthSum()+e.getMonthSum());
            statics.setTotalNum(statics.getTotalNum()+e.getTotalNum());
            statics.setCheckNum(statics.getCheckNum()+e.getCheckNum());
            statics.setPersonNum(statics.getPersonNum()+e.getPersonNum());
        });
        return ResultUtil.data(statics);
    }
    @GetMapping("getHistoryStaticsData")
    @ApiOperation(value = "获取历史统计数据")
    public Result getHistoryStaticsData(String areaId,Integer type){
        if (StrUtil.isEmpty(areaId)){
            return ResultUtil.error("缺少参数");
        }
        List<Map<String,Object>> result = iSubsidyPersonStaticsService.getMonthAddOut(areaId,type);
        StatisVO vo = new StatisVO();
        result.forEach(e->{
            String month = (String) e.get("month");
            int mAdd = Integer.parseInt(String.valueOf(e.get("mAdd")));
            int mOut = Integer.parseInt(String.valueOf(e.get("mOut")));
            int checkNum = Integer.parseInt(String.valueOf(e.get("checkNum")));
            int totalNum = Integer.parseInt(String.valueOf(e.get("totalNum")));
            vo.month.add(0,month.split("-")[1]);
            vo.mAdd.add(0,mAdd);
            vo.mOut.add(0,mOut);
            vo.checkNum.add(0,checkNum);
            vo.totalNum.add(0,totalNum);
        });
        return ResultUtil.data(vo);
 
    }
    @Data
    class StatisVO{
        //月份
        List month = new ArrayList();
        //月新增
        List mAdd = new ArrayList();
        //月退出
        List mOut = new ArrayList();
        //月复核数
        List checkNum = new ArrayList();
        //月复核数
        List totalNum = new ArrayList();
 
    }
 
}