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> deptList() { return R.ok(largeDeptService.list(Wrappers.lambdaQuery(TLargeDept.class).orderByDesc(TLargeDept::getCreateTime))); } /** * 获取组织人员管理列表 */ @ApiOperation(value = "获取组织人员列表") @GetMapping(value = "/largeUserList") public R> largeUserList(@RequestParam String deptId) { List 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> eventCenter() { // 居民上报事件 long appealServicesCount = appealServicesService.count(); // 养老告警事件 long warningCount = oldsterWarningService.count(); Map 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 communityProfile(@RequestParam Integer configType) { THtmlConfig sysConfig = htmlConfigService.getOne(Wrappers.lambdaQuery().eq(THtmlConfig::getConfigType, configType) .last("LIMIT 1")); return R.ok(sysConfig); } /** * 五社联动 */ @ApiOperation(value = "五社联动",notes = "resourceCount:社区资源,socialWorkerCount:社区工作者,volunteerCount:社区志愿者,organizationCount:社区组织") @GetMapping(value = "/fiveSocietyLinkage") public R> fiveSocietyLinkage() { // 社区资源 long resourceCount = largeResourceService.count(); // 社区工作者 long socialWorkerCount = largeSocialWorkerService.count(); // 社区志愿者 long volunteerCount = largeVolunteerService.count(); // 社区组织 long organizationCount = largeOrganizationService.count(); Map 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> 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 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> keyPersonnelSituation() { List list = largeKeyPersonnelTypeService.list(); List largeKeyGridUsers = largeKeyGridUserService.list(Wrappers.lambdaQuery(TLargeKeyGridUser.class) .eq(TLargeKeyGridUser::getUserType, 1)); for (TLargeKeyPersonnelType largeKeyPersonnelType : list) { if(largeKeyPersonnelType.getShowType() == 2 && !CollectionUtils.isEmpty(largeKeyGridUsers)){ // 查询真实的汇总数据 List users = largeKeyGridUsers.stream().filter(largeKeyGridUser -> largeKeyGridUser.getTypeId().equals(largeKeyPersonnelType.getId())).collect(Collectors.toList()); largeKeyPersonnelType.setShowNumber(users.size()); } } return R.ok(list); } }