xuhy
2025-11-17 2c35ada755cd899d07d06d98556d7de0f4705bf8
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package com.ruoyi.web.controller.api;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.model.*;
import com.ruoyi.system.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
@Api(tags = "数据大屏")
@RestController
@RequestMapping("/statistics")
public class DataStatisticsController {
 
    private final TAppealServicesService appealServicesService;
    private final TOldsterWarningService oldsterWarningService;
    private final THtmlConfigService htmlConfigService;
    private final TLargeDeptService largeDeptService;
    private final TLargeUserService largeUserService;
    private final TLargeOrganizationService largeOrganizationService;
    private final TLargeResourceService largeResourceService;
    private final TLargeSocialWorkerService largeSocialWorkerService;
    private final TLargeVolunteerService largeVolunteerService;
    private final TLargeKeyGridUserService largeKeyGridUserService;
    private final TLargeKeyPersonnelTypeService largeKeyPersonnelTypeService;
    @Autowired
    public DataStatisticsController(TAppealServicesService appealServicesService, TOldsterWarningService oldsterWarningService, THtmlConfigService htmlConfigService, TLargeDeptService largeDeptService, TLargeUserService largeUserService, TLargeOrganizationService largeOrganizationService, TLargeResourceService largeResourceService, TLargeSocialWorkerService largeSocialWorkerService, TLargeVolunteerService largeVolunteerService, TLargeKeyGridUserService largeKeyGridUserService, TLargeKeyPersonnelTypeService largeKeyPersonnelTypeService) {
        this.appealServicesService = appealServicesService;
        this.oldsterWarningService = oldsterWarningService;
        this.htmlConfigService = htmlConfigService;
        this.largeDeptService = largeDeptService;
        this.largeUserService = largeUserService;
        this.largeOrganizationService = largeOrganizationService;
        this.largeResourceService = largeResourceService;
        this.largeSocialWorkerService = largeSocialWorkerService;
        this.largeVolunteerService = largeVolunteerService;
        this.largeKeyGridUserService = largeKeyGridUserService;
        this.largeKeyPersonnelTypeService = largeKeyPersonnelTypeService;
    }
 
    /**
     * 获取组织部门管理列表
     */
    @ApiOperation(value = "获取组织部门列表")
    @GetMapping(value = "/deptList")
    public R<List<TLargeDept>> deptList() {
        return R.ok(largeDeptService.list(Wrappers.lambdaQuery(TLargeDept.class).orderByDesc(TLargeDept::getCreateTime)));
    }
 
    /**
     * 获取组织人员管理列表
     */
    @ApiOperation(value = "获取组织人员列表")
    @GetMapping(value = "/largeUserList")
    public R<List<TLargeUser>> largeUserList(@RequestParam String deptId) {
        List<TLargeUser> list = largeUserService.list(Wrappers.lambdaQuery(TLargeUser.class)
                .eq(TLargeUser::getDeptId, deptId)
                .orderByDesc(TLargeUser::getCreateTime));
        return R.ok(list);
    }
 
    /**
     * 事件中心
     */
    @ApiOperation(value = "事件中心",notes = "appealServicesCount:居民上报事件,warningCount:养老告警事件")
    @GetMapping(value = "/eventCenter")
    public R<Map<String,Long>> eventCenter() {
        // 居民上报事件
        long appealServicesCount = appealServicesService.count();
        // 养老告警事件
        long warningCount = oldsterWarningService.count();
        Map<String,Long> map = new HashMap<>();
        map.put("appealServicesCount",appealServicesCount);
        map.put("warningCount",warningCount);
        return R.ok(map);
    }
 
    /**
     * 社区地图-社区概况
     */
    @ApiOperation(value = "社区地图-社区概况",notes = "14=社区地图 15=社区概况")
    @GetMapping(value = "/communityProfile")
    public R<THtmlConfig> communityProfile(@RequestParam Integer configType) {
        THtmlConfig sysConfig = htmlConfigService.getOne(Wrappers.<THtmlConfig>lambdaQuery().eq(THtmlConfig::getConfigType, configType)
                .last("LIMIT 1"));
        return R.ok(sysConfig);
    }
 
    /**
     * 五社联动
     */
    @ApiOperation(value = "五社联动",notes = "resourceCount:社区资源,socialWorkerCount:社区工作者,volunteerCount:社区志愿者,organizationCount:社区组织")
    @GetMapping(value = "/fiveSocietyLinkage")
    public R<Map<String,Long>> fiveSocietyLinkage() {
        // 社区资源
        long resourceCount = largeResourceService.count();
        // 社区工作者
        long socialWorkerCount = largeSocialWorkerService.count();
        // 社区志愿者
        long volunteerCount = largeVolunteerService.count();
        // 社区组织
        long organizationCount = largeOrganizationService.count();
 
        Map<String,Long> map = new HashMap<>();
        map.put("resourceCount",resourceCount);
        map.put("socialWorkerCount",socialWorkerCount);
        map.put("volunteerCount",volunteerCount);
        map.put("organizationCount",organizationCount);
        return R.ok(map);
    }
 
    /**
     * 网格-重点人数
     */
    @ApiOperation(value = "网格-重点人数",notes = "keyCount:重点人数,gridCount:网格人数")
    @GetMapping(value = "/keyGridUserCount")
    public R<Map<String,Long>> keyGridUserCount() {
        // 重点人数
        long keyCount = largeKeyGridUserService.count(Wrappers.lambdaQuery(TLargeKeyGridUser.class)
                .eq(TLargeKeyGridUser::getUserType, 1));
        // 网格人数
        long gridCount = largeKeyGridUserService.count(Wrappers.lambdaQuery(TLargeKeyGridUser.class)
                .eq(TLargeKeyGridUser::getUserType, 2));
        Map<String,Long> map = new HashMap<>();
        map.put("keyCount",keyCount);
        map.put("gridCount",gridCount);
        return R.ok(map);
    }
 
    /**
     * 重点人员情况
     */
    @ApiOperation(value = "重点人员情况",notes = "keyCount:重点人数,gridCount:网格人数")
    @GetMapping(value = "/keyPersonnelSituation")
    public R<List<TLargeKeyPersonnelType>> keyPersonnelSituation() {
        List<TLargeKeyPersonnelType> list = largeKeyPersonnelTypeService.list();
        List<TLargeKeyGridUser> largeKeyGridUsers = largeKeyGridUserService.list();
        for (TLargeKeyPersonnelType largeKeyPersonnelType : list) {
            if(largeKeyPersonnelType.getShowType() == 2 && !CollectionUtils.isEmpty(largeKeyGridUsers)){
                // 查询真实的汇总数据
                List<TLargeKeyGridUser> users = largeKeyGridUsers.stream().filter(largeKeyGridUser -> largeKeyGridUser.getTypeId().equals(largeKeyPersonnelType.getId())).collect(Collectors.toList());
                largeKeyPersonnelType.setShowNumber(users.size());
            }
        }
        return R.ok(list);
    }
 
}