mitao
2025-05-06 0135fa289418c5fd231fa4e7c60ee7b8f06f17a7
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
package com.panzhihua.sangeshenbian.api;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.sangeshenbian.model.entity.Complaint;
import com.panzhihua.sangeshenbian.model.query.AnalyticStatisticsQuery;
import com.panzhihua.sangeshenbian.model.vo.AnalyticStatisticsOneVo;
import com.panzhihua.sangeshenbian.model.vo.AnalyticStatisticsThreeVo;
import com.panzhihua.sangeshenbian.model.vo.AnalyticStatisticsTwoVo;
import com.panzhihua.sangeshenbian.service.IComplaintService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.List;
 
/**
 * <p>
 * 分析统计 前端控制器
 * </p>
 *
 * @author 
 * @since 2025-04-28
 */
@RestController
@RequestMapping("/analytic-statistics")
@Validated
public class AnalyticStatisticsController {
 
    @Autowired
    private IComplaintService complaintService;
 
    @PostMapping("/data")
    @ApiOperation(value = "分析统计", tags = {"三个身边后台-分析统计"})
    public R<?> data(@Valid @RequestBody AnalyticStatisticsQuery query){
        // TODO 判断当前账号的层级  如果包含市级 可以查看所有  包含区县多个  包含镇多个 包含村多个
        LambdaQueryWrapper<Complaint> wrapper = new LambdaQueryWrapper<Complaint>().eq(Complaint::getCityCode, query.getCityCode());
        if(query.getDistrictCode()!=null){
            wrapper.eq(Complaint::getDistrictsCode, query.getDistrictCode());
        }
        if(query.getStreetId()!=null){
            wrapper.eq(Complaint::getStreetId, query.getStreetId());
        }
        if(query.getCommunityId()!=null){
            wrapper.eq(Complaint::getCommunityId, query.getCommunityId());
        }
 
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<Complaint> complaints =complaintService.list(wrapper);
        // 第一部分数据
        AnalyticStatisticsOneVo analyticStatisticsOneVo = complaintService.analyticStatisticsOne(query,complaints,simpleDateFormat);
 
        // 第二部分数据
        List<AnalyticStatisticsTwoVo> analyticStatisticsTwoVos =complaintService.analyticStatisticsTwo(query,complaints,simpleDateFormat);
 
        // 第三部分数据
        List<AnalyticStatisticsThreeVo> analyticStatisticsThreeVos =complaintService.analyticStatisticsThree(query,complaints);
 
        return R.ok(analyticStatisticsThreeVos);
    }
 
 
    public static void main(String[] args) {
        String beforeDay = DateUtils.getBeforeDay(6);
        System.out.println(beforeDay);
    }
 
}