package com.cm.systemcity.controller.datarelease; import com.cm.common.base.AbstractController; import com.cm.common.component.SecurityComponent; import com.cm.common.constants.ISystemConstant; import com.cm.common.exception.ParamsException; import com.cm.common.exception.SearchException; import com.cm.common.plugin.oauth.service.user.IUserService; import com.cm.common.pojo.ListPage; import com.cm.common.pojo.dtos.department.DepartmentSortDTO; import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.common.utils.DateUtil; import com.cm.plugin.map.pojo.dto.GridDTO; import com.cm.systemcity.dao.datarelease.IDataReleaseDao; import com.cm.systemcity.dao.reportcase.IReportCaseDao; import com.cm.systemcity.pojo.dtos.community.CommunityDTO; import com.cm.systemcity.pojo.dtos.communityboss.CommunityBossDTO; import com.cm.systemcity.pojo.dtos.dict.DictDTO; import com.cm.systemcity.pojo.dtos.reportcase.CaseStatisticDTO; import com.cm.systemcity.pojo.dtos.reportcase.ReportCaseAssignDTO; import com.cm.systemcity.pojo.dtos.reportcase.ReportCaseDTO; import com.cm.systemcity.pojo.dtos.reportcase.ReportCaseLogDTO; import com.cm.systemcity.pojo.dtos.userlocation.UserLocationDTO; import com.cm.systemcity.service.bindingdepartment.IBindingDepartmentService; import com.cm.systemcity.service.community.ICommunityService; import com.cm.systemcity.service.communityboss.ICommunityBossService; import com.cm.systemcity.service.dict.IDictService; import com.cm.systemcity.service.grid.IGridService; import com.cm.systemcity.service.readstate.IReadStateService; import com.cm.systemcity.service.reportcase.IReportCaseService; import com.cm.systemcity.service.userlocation.IUserLocationService; import com.cm.systemcity.service.userpoints.IUserPointsService; import com.cm.systemcity.utils.BigDataResult; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.*; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Query; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; /** * 网格治理对外提供数据接口类 * @author xwangs * @create 2021-07-22 10:50 * @description */ @Api(tags = ISystemConstant.API_PREFIX + "网格治理对外提供数据接口类") @RestController @RequestMapping(ISystemConstant.APP_PREFIX + "/data-external-release") public class DataReleaseController extends AbstractController { @Autowired private IDataReleaseDao dataReleaseDao; @Autowired private MongoTemplate mongoTemplate; @Autowired private IDictService dictService; @Autowired private IReportCaseService reportCaseService; @Autowired private IUserLocationService userLocationService; @Autowired private IUserPointsService userPointsService; @Autowired private ICommunityService communityService; @Autowired private ICommunityBossService communityBossService; @Autowired private IBindingDepartmentService bindingDepartmentService; @Autowired private IGridService gridService; /** * 大数据网格详情页接口 */ @GetMapping("get-big-data-grid-detail") public Map listBigDataGridDetail(){ Map query = requestParams(); Map res = new HashMap<>(8); if(query.get("gridId") == null || "".equals(query.get("gridId").toString())){ return res; } String gridId = query.get("gridId").toString(); // 查询网格信息 com.cm.systemcity.pojo.dtos.grid.GridDTO gridDTO = gridService.get(gridId); res.put("gridInfo", gridDTO); // 查询网格内所有网格员或专管员 List> gridUserList = dataReleaseDao.listUserByGridId(gridId); for(Map item : gridUserList){ // 判断用户是否为专管员 String userId = item.get("userId").toString(); Map roleObj = dataReleaseDao.getUserRoleForCheckNPerson(userId); item.put("deptOrCommunity", ""); item.put("reportCaseNum", "0"); item.put("handleCaseNum", "0"); if(roleObj != null){ // 专管员 List> usersDept = dataReleaseDao.listDepartmentByUserId(userId); String deptNames = ""; for(Map deptItem : usersDept){ if("".equals(deptNames)){ deptNames += deptItem.get("departmentName").toString(); } else{ deptNames += "," + deptItem.get("departmentName").toString(); } } item.put("deptOrCommunity", deptNames); // 查询案件信息 item.put("reportCaseNum", "-"); List> handleCaseNum = dataReleaseDao.listHandleCaseByUserId(userId); item.put("handleCaseNum", handleCaseNum.size()); } else { // 网格员 query.put("communityBossUserId", userId); CommunityBossDTO communityBoss = communityBossService.getCommunityBoss(query); query.put("communityId", communityBoss.getCommunityId()); CommunityDTO community = communityService.getCommunity(query); String deptOrCommunity = ""; deptOrCommunity += communityBoss.getAreaName(); if(community != null){ deptOrCommunity += "/" + community.getCommunityName(); } item.put("deptOrCommunity", deptOrCommunity); // 查询案件信息 query.put("creator", userId); List> listReport = dataReleaseDao.listReportCase(query); item.put("reportCaseNum", listReport.size()); List> handleCaseNum = dataReleaseDao.listHandleCaseByUserId(userId); item.put("handleCaseNum", handleCaseNum.size()); } } res.put("gridUser", gridUserList == null ? new ArrayList<>(0) : gridUserList); return res; } /** * 大数据二级页面-地图大网格 */ @GetMapping("list-big-data-map-grid") public List> listBigDataMapGrid(){ Map query = new HashMap<>(8); List> resList = new ArrayList<>(0); List gridIds = new ArrayList<>(0); // 万水泉街道网格一 gridIds.add("9074df15-de5b-42d1-ae08-d8207b26a2d7"); // 万水泉街道网格二 gridIds.add("cea3a6af-f67f-4cdf-9c50-a28479d72ac5"); // 稀土路街道网格(稀土) gridIds.add("6901b73b-7ace-4fd6-9977-20ec85166bbe"); // 希望工业园区网格(民馨路) gridIds.add("99bb2615-907e-466d-96c5-093b6ef3333a"); for(String gridId : gridIds){ query.put("gridId", gridId); List> gridList = dataReleaseDao.listMapGrid(query); for(Map grid : gridList){ Map temp = new HashMap<>(8); temp.put("gridColor", grid.get("fill_color").toString()); temp.put("gridName", grid.get("grid_name").toString()); List> pointList = dataReleaseDao.listMapGridPoint(query); temp.put("gridPointList", pointList); if(gridId.equals("9074df15-de5b-42d1-ae08-d8207b26a2d7") || gridId.equals("cea3a6af-f67f-4cdf-9c50-a28479d72ac5")){ // 案件数-万水泉 query.put("areaId", "8d62a0cc-2c15-4355-906c-6720f8f3617e"); List> reportCaseList = dataReleaseDao.listReportCase(query); temp.put("reportCount", reportCaseList.size()); // 网格员数 List> communityBossList = dataReleaseDao.countOfCommunityBoss(query); temp.put("sysUserCount", communityBossList.size()); // 小区数 query.put("areaId", "752237"); List> districtList = dataReleaseDao.listDistrict(query); temp.put("districtCount", districtList.size()); // 房屋数 // 人口数 query.put("areaParentId", "752237"); Integer populationCount = dataReleaseDao.countOfBasePopulation(query); temp.put("populationCount", populationCount); resList.add(temp); } if(gridId.equals("6901b73b-7ace-4fd6-9977-20ec85166bbe")){ // 案件数-稀土 query.put("areaId", "7ed23f06-566d-43b7-acd9-4f0b5db08974"); List> reportCaseList = dataReleaseDao.listReportCase(query); temp.put("reportCount", reportCaseList.size()); // 网格员数 List> communityBossList = dataReleaseDao.countOfCommunityBoss(query); temp.put("sysUserCount", communityBossList.size()); // 小区数 query.put("areaId", "752235"); List> districtList = dataReleaseDao.listDistrict(query); temp.put("districtCount", districtList.size()); // 房屋数 // 人口数 query.put("areaParentId", "752235"); Integer populationCount = dataReleaseDao.countOfBasePopulation(query); temp.put("populationCount", populationCount); resList.add(temp); } if(gridId.equals("99bb2615-907e-466d-96c5-093b6ef3333a")){ // 案件数-民馨 query.put("areaId", "6e922367-f21f-4daf-b38c-c55a67d9a35b"); List> reportCaseList = dataReleaseDao.listReportCase(query); temp.put("reportCount", reportCaseList.size()); // 网格员数 List> communityBossList = dataReleaseDao.countOfCommunityBoss(query); temp.put("sysUserCount", communityBossList.size()); // 小区数 query.put("areaId", "752236"); List> districtList = dataReleaseDao.listDistrict(query); temp.put("districtCount", districtList.size()); // 房屋数 // 人口数 query.put("areaParentId", "752236"); Integer populationCount = dataReleaseDao.countOfBasePopulation(query); temp.put("populationCount", populationCount); resList.add(temp); } } } return resList; } /** * 大数据地图二级页面-定位-查询当日人员定位 */ @GetMapping("list-user-location") public List> listUserLocation(){ Map query = requestParams(); if(query.get("nodeIds") == null || "".equals(query.get("nodeIds").toString())){ return new ArrayList<>(0); } List> resList = new ArrayList<>(0); String nodeIdStr = query.get("nodeIds").toString(); String[] nodeIds = nodeIdStr.split(","); for(String userId : nodeIds){ query.put("userId", userId); Map location = dataReleaseDao.getLastUserLocationInfo(query); if(location != null){ Map temp = new HashMap<>(8); temp.put("lastPointTime", location.get("gmt_create").toString().substring(0,19)); temp.put("lng", location.get("user_longitude").toString()); temp.put("lat", location.get("user_latitude").toString()); temp.put("userName", location.get("user_name").toString()); temp.put("userAvatar", location.get("user_avatar").toString()); temp.put("userPhone", location.get("user_phone").toString()); temp.put("userAccount", location.get("user_username").toString()); resList.add(temp); } } return resList; } /** * 大数据地图二级页面-点击案件类型获取案件点位地点等信息 */ @GetMapping("list-report-info-by-case-id") public List> listReportInfoByCaseId(){ Map query = requestParams(); if(query.get("nodeIds") == null || "".equals(query.get("nodeIds").toString())){ return new ArrayList<>(0); } query.put("caseTypeId", query.get("nodeIds").toString()); // 仅查询 待转派 待处理 的案件 query.put("caseStatus", "2,3"); List> resList = new ArrayList<>(0); List> list = dataReleaseDao.listReportCase(query); for(Map item : list){ Map temp = new HashMap<>(8); temp.put("reportCaseId", item.get("report_case_id")); temp.put("text", item.get("case_content")); temp.put("lng", item.get("case_longitude")); temp.put("lat", item.get("case_latitude")); temp.put("reportTime", item.get("gmt_create").toString().substring(0,19)); temp.put("caseStatus", item.get("case_status")); temp.put("caseTypeName", item.get("case_type_name")); resList.add(temp); } return resList; } /** * 大数据地图二级页面-案件类型树 */ @GetMapping("list-tree-all-case-type") public List> listTreeAllCaseType(){ Map query = new HashMap<>(8); List> resList= new ArrayList<>(0); // 顶级节点 query.put("dictParentId","46d108b2-4ef9-4f6f-b30c-0c700e3ee852"); List topList = dictService.listDict(query); for(DictDTO item : topList){ Map topNode = new HashMap<>(8); topNode.put("lable", item.getDictName()); topNode.put("nodeTag", "top"); topNode.put("nodeId", item.getDictId()); List> caseTypeList = new ArrayList<>(0); topNode.put("children", caseTypeList); // 查询案件子类型列表 query.put("dictParentId",item.getDictId()); List childrenList = dictService.listDict(query); for(DictDTO children : childrenList){ Map childrenNode = new HashMap<>(8); childrenNode.put("nodeTag", "caseType"); childrenNode.put("nodeId", children.getDictId()); childrenNode.put("lable", children.getDictName()); childrenNode.put("children", new ArrayList<>()); caseTypeList.add(childrenNode); } resList.add(topNode); } return resList; } /** * 大数据地图二级页面-点击节点查询网格 */ @GetMapping("list-map-grid") public List> listMapGrid(){ List> mapGridResult = new ArrayList<>(0); String street = "street"; String community = "community"; String dept = "dept"; String user = "user"; Map query = requestParams(); Map param = new HashMap<>(8); // 如果没传该参数, 则返回大网格 if(query.get("nodeTag") == null || "top".equals(query.get("nodeTag").toString()) || "".equals(query.get("nodeTag").toString())){ // 放入高新区大网格 List gridIds = new ArrayList<>(0); // 万水泉街道网格一 gridIds.add("9074df15-de5b-42d1-ae08-d8207b26a2d7"); // 万水泉街道网格二 gridIds.add("cea3a6af-f67f-4cdf-9c50-a28479d72ac5"); // 稀土路街道网格 gridIds.add("6901b73b-7ace-4fd6-9977-20ec85166bbe"); // 希望工业园区网格 gridIds.add("99bb2615-907e-466d-96c5-093b6ef3333a"); for(String gridId : gridIds){ param.clear(); param.put("gridId", gridId); List> gridList = dataReleaseDao.listMapGrid(param); for(Map grid : gridList){ Map temp = new HashMap<>(8); temp.put("gridId", grid.get("grid_id").toString()); temp.put("gridName", grid.get("grid_name").toString()); temp.put("gridColor", grid.get("fill_color").toString()); // 放入当前网格的边界点 param.put("gridId", grid.get("grid_id").toString()); List> pointList = dataReleaseDao.listMapGridPoint(param); temp.put("gridPointList", pointList); mapGridResult.add(temp); } } return mapGridResult; } String nodeTag = query.get("nodeTag").toString(); // 点击街道 if(street.equals(nodeTag)){ String nodeId; try { nodeId = query.get("nodeId").toString(); } catch (Exception e){ // 没传ID返回空内容 return mapGridResult; } param.put("areaId", nodeId); List communityList = communityService.listCommunity(param); for (CommunityDTO item : communityList){ param.clear(); param.put("areaCode", item.getCommunityId()); // 到map_grid表中查询网格 List> gridList = dataReleaseDao.listMapGrid(param); for(Map grid : gridList){ Map temp = new HashMap<>(8); temp.put("gridId", grid.get("grid_id").toString()); temp.put("gridName", grid.get("grid_name").toString()); temp.put("gridColor", grid.get("fill_color").toString()); // 放入当前网格的边界点 。。。。 param.put("gridId", grid.get("grid_id").toString()); List> pointList = dataReleaseDao.listMapGridPoint(param); temp.put("gridPointList", pointList); mapGridResult.add(temp); } } return mapGridResult; } // 点击社区 if(community.equals(nodeTag)){ String nodeId; try { nodeId = query.get("nodeId").toString(); } catch (Exception e){ // 没传ID返回空内容 return mapGridResult; } param.put("areaCode", nodeId); // 到map_grid表中查询网格 List> gridList = dataReleaseDao.listMapGrid(param); for(Map grid : gridList){ param.clear(); Map temp = new HashMap<>(8); temp.put("gridId", grid.get("grid_id").toString()); temp.put("gridName", grid.get("grid_name").toString()); temp.put("gridColor", grid.get("fill_color").toString()); // 放入当前网格的边界点 param.put("gridId", grid.get("grid_id").toString()); List> pointList = dataReleaseDao.listMapGridPoint(param); temp.put("gridPointList", pointList); mapGridResult.add(temp); } return mapGridResult; } // 点击部门 if(dept.equals(nodeTag)){ String nodeId; try { nodeId = query.get("nodeId").toString(); } catch (Exception e){ // 没传ID返回空内容 return mapGridResult; } param.put("departmentId", nodeId); Map deptObj = dataReleaseDao.getDepartment(param); String deptName = deptObj.get("department_name").toString(); // 画网格时专管员部门列表取的是city_community表中新建的数据 // 需要根据专管单位名称查询sys_department表中的部门ID, 根据部门ID取到该部门下所有专管员的所有网格 param.put("communityName", deptName); List> communityInfo = dataReleaseDao.getCommunityInfo(param); for (Map item : communityInfo){ param.clear(); String communityId = item.get("community_id").toString(); param.put("areaCode", communityId); // 到map_grid表中查询网格 List> gridList = dataReleaseDao.listMapGrid(param); for(Map grid : gridList){ Map temp = new HashMap<>(8); temp.put("gridId", grid.get("grid_id").toString()); temp.put("gridName", grid.get("grid_name").toString()); temp.put("gridColor", grid.get("fill_color").toString()); // 放入当前网格的边界点 param.put("gridId", grid.get("grid_id").toString()); List> pointList = dataReleaseDao.listMapGridPoint(param); temp.put("gridPointList", pointList); mapGridResult.add(temp); } } return mapGridResult; } // 点击用户 if(user.equals(nodeTag)){ String nodeId; try { nodeId = query.get("nodeId").toString(); } catch (Exception e){ // 没传ID返回空内容 return mapGridResult; } param.put("relationId", nodeId); List> relationList = dataReleaseDao.listMapGridRelation(param); for(Map relation : relationList){ param.clear(); String gridId = relation.get("grid_id").toString(); param.put("gridId", gridId); List> gridList = dataReleaseDao.listMapGrid(param); for(Map grid : gridList){ Map temp = new HashMap<>(8); temp.put("gridId", grid.get("grid_id").toString()); temp.put("gridName", grid.get("grid_name").toString()); temp.put("gridColor", grid.get("fill_color").toString()); // 放入当前网格的边界点 param.put("gridId", grid.get("grid_id").toString()); List> pointList = dataReleaseDao.listMapGridPoint(param); temp.put("gridPointList", pointList); mapGridResult.add(temp); } } return mapGridResult; } return mapGridResult; } /** * 大数据地图二级页面-网格-专管单位 * @return */ @GetMapping("list-tree-all-dept-grid") public List> listTreeAllDeptGrid(){ Map query = requestParams(); List> resList= new ArrayList<>(0); // 顶级节点 Map topNode = new HashMap<>(8); topNode.put("nodeTag", "top"); topNode.put("nodeId", ""); topNode.put("lable", "专管单位"); List> deptNodeList = new ArrayList<>(0); topNode.put("children", deptNodeList); // 专管单位节点 List departmentSortDTOs = bindingDepartmentService.listDepartmentForMainPanel(query); for(DepartmentSortDTO item : departmentSortDTOs){ Map deptNode = new HashMap<>(8); deptNode.put("nodeTag", "dept"); deptNode.put("nodeId", item.getDepartmentId()); deptNode.put("lable", item.getDepartmentName()); List> userNodeList = new ArrayList<>(0); deptNode.put("children", userNodeList); deptNodeList.add(deptNode); // 查询专管员 query.put("departmentId", item.getDepartmentId()); List> userList = bindingDepartmentService.listNPerson(query); for(Map user : userList){ Map userNode = new HashMap<>(8); userNode.put("nodeId", user.get("userId") == null ? "缺失" : user.get("userId").toString()); userNode.put("lable", user.get("userName") == null ? "缺失" : user.get("userName").toString()); userNode.put("nodeTag", "user"); userNode.put("children", new ArrayList<>(0)); userNodeList.add(userNode); } } resList.add(topNode); return resList; } /** * 大数据地图二级页面-网格-所有网格 * @return */ @GetMapping("list-tree-all-normal-grid") public List> listTreeAllNormalGrid(){ Map query = requestParams(); List> resList= new ArrayList<>(0); // 顶级节点 Map topNode = new HashMap<>(8); topNode.put("lable", "所有网格"); topNode.put("nodeTag", "top"); topNode.put("nodeId", ""); List> streetNodeList = new ArrayList<>(0); topNode.put("children", streetNodeList); // 街道节点 query.put("dictParentId", "9d179f05-3ea0-48f7-853c-d3b7124b791c"); List streetList = dictService.listDict(query); for(DictDTO item : streetList){ String dictName = item.getDictName(); if("专管员区域".equals(dictName)){ continue; } Map streetNode = new HashMap<>(8); streetNode.put("lable", dictName); streetNode.put("nodeTag", "street"); streetNode.put("nodeId", item.getDictId()); List> communityNodeList = new ArrayList<>(0); streetNode.put("children", communityNodeList); streetNodeList.add(streetNode); // 社区节点 query.put("areaId", item.getDictId()); List communityDTOS = communityService.listCommunity(query); for(CommunityDTO item2 : communityDTOS){ Map communityNode = new HashMap<>(8); communityNode.put("lable", item2.getCommunityName()); communityNode.put("nodeTag", "community"); communityNode.put("nodeId", item2.getCommunityId()); List> userNodeList = new ArrayList<>(0); communityNode.put("children", userNodeList); communityNodeList.add(communityNode); // 查询网格员 query.put("communityId", item2.getCommunityId()); List gridUser = communityBossService.listGridUser(query); for(CommunityBossDTO user : gridUser){ Map userNode = new HashMap<>(8); userNode.put("lable", user.getCommunityBossName()); userNode.put("nodeTag", "user"); userNode.put("nodeId", user.getCommunityBossUserId()); userNode.put("children", new ArrayList<>(0)); userNode.put("areaId", item.getDictId()); userNode.put("communityId", item2.getCommunityId()); userNodeList.add(userNode); } } } resList.add(topNode); return resList; } @GetMapping("repair-data") public void repairData(){ // 更新地图左侧人员树缓存 mongoTemplate.remove(new Query(), "INDEX_PANEL_GRID_TREE"); } @ApiOperation(value = "案件情况-数量", notes = "案件情况-数量") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get-case-report-count-info") public BigDataResult getCaseReportCountInfo(){ Map reqParams = requestParams(); // 判断获取哪类案件的标识 if(reqParams.get("dataCatalog") == null && reqParams.get("dataCatalog").toString().length() == 0){ return new BigDataResult(); } String dataCatalog = reqParams.get("dataCatalog").toString(); // dept职能部门案件 street街镇案件 person群众上报 special特殊案件 // {type:'up',value:98625,percentage:15.6} BigDataResult bdr = new BigDataResult(); Map query = new HashMap<>(8); Map bdrData = new HashMap<>(8); bdrData.put("value",0); bdrData.put("type","up"); bdrData.put("percentage","0"); String nowMonth = DateUtil.getDay().substring(0,7); String lastMonth = bdr.lastMonth(); query.put("caseStatus","6"); query.put("dataCatalog",dataCatalog); switch (dataCatalog){ case "dept" : List> deptList = dataReleaseDao.listReportCase(query); bdrData.put("value",deptList.size()); // 本月数据 query.put("gmtModified", nowMonth); List> nowMonthList = dataReleaseDao.listReportCase(query); // 上月数据 query.put("gmtModified", lastMonth); List> lastMonthList = dataReleaseDao.listReportCase(query); bdrData.put("type" ,nowMonthList.size() - lastMonthList.size() >= 0 ? "up" : "down"); bdrData.put("percentage", Math.abs(nowMonthList.size() - lastMonthList.size()) + "件"); break; case "street" : List> streetList = dataReleaseDao.listReportCase(query); bdrData.put("value",streetList.size()); // 本月数据 query.put("gmtModified", nowMonth); List> nowMonthStreetList = dataReleaseDao.listReportCase(query); // 上月数据 query.put("gmtModified", lastMonth); List> lastMonthStreetList = dataReleaseDao.listReportCase(query); bdrData.put("type" ,nowMonthStreetList.size() - lastMonthStreetList.size() >= 0 ? "up" : "down"); bdrData.put("percentage", Math.abs(nowMonthStreetList.size() - lastMonthStreetList.size()) + "件"); break; case "person" : List> personList = dataReleaseDao.listReportCase(query); bdrData.put("value",personList.size()); // 本月数据 query.put("gmtModified", nowMonth); List> nowMonthPersonList = dataReleaseDao.listReportCase(query); // 上月数据 query.put("gmtModified", lastMonth); List> lastMonthPersonList = dataReleaseDao.listReportCase(query); bdrData.put("type" ,nowMonthPersonList.size() - lastMonthPersonList.size() >= 0 ? "up" : "down"); bdrData.put("percentage", Math.abs(nowMonthPersonList.size() - lastMonthPersonList.size()) + "件"); break; case "special" : List> specialList = dataReleaseDao.listSpecialReportCase(query); bdrData.put("value",specialList.size()); // 本月数据 query.put("gmtModified", nowMonth); List> nowMonthSpecialList = dataReleaseDao.listSpecialReportCase(query); // 上月数据 query.put("gmtModified", lastMonth); List> lastMonthSpecialList = dataReleaseDao.listSpecialReportCase(query); bdrData.put("type" ,nowMonthSpecialList.size() - lastMonthSpecialList.size() >= 0 ? "up" : "down"); bdrData.put("percentage", Math.abs(nowMonthSpecialList.size() - lastMonthSpecialList.size()) + "件"); break; default: return bdr; } bdr.setData(bdrData); return bdr; } @ApiOperation(value = "各区域案件占比-包含特殊案件量", notes = "各区域案件占比-包含特殊案件量") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get-community-report-case") public BigDataResult getCommunityReportCase(){ // {data:{},list:[{name:'万水泉镇',value:300},{name:'民馨路',value:1200},{name:'稀土路',value:3600}],msg:'加载成功',state:'200'} Map reqParams = requestParams(); reqParams.put("dictParentId","9d179f05-3ea0-48f7-853c-d3b7124b791c"); List dictDTOS = dictService.listDict(reqParams); if(dictDTOS == null || dictDTOS.size() == 0){ return new BigDataResult(); } List> resList = new ArrayList<>(); for(DictDTO dictItem : dictDTOS){ reqParams.clear(); Map resItem = new HashMap<>(8); resItem.put("name",dictItem.getDictName()); // 查询该街镇下所有普通案件 已完结 reqParams.put("caseStatus", "6"); reqParams.put("areaId",dictItem.getDictId()); List> normalList = dataReleaseDao.listReportCase(reqParams); // 查询该街镇下所有特殊案件 /*List> specialList = dataReleaseDao.listSpecialReportCase(reqParams);*/ resItem.put("value",normalList.size()); resList.add(resItem); } BigDataResult bdr = new BigDataResult(); bdr.setList(resList); return bdr; } @ApiOperation(value = "案件类型TOP10", notes = "案件类型TOP10") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get-case-type-top10") public BigDataResult getCaseTypeTop10(){ // {data:{nameColumns:['案件数量']},list:[{name:'餐厨垃圾',columns:[3]},{name:'污水管网及井盖养护',columns:[0]},{name:'暂住人口问题',columns:[5]}, // {name:'道路交通设施',columns:[5]},{name:'人行道维修养护',columns:[25]}],msg:'加载成功',state:'200'} Map reqParams = requestParams(); List> caseTypeList = dataReleaseDao.getCaseTypeTop10(reqParams); if(caseTypeList == null || caseTypeList.size() == 0){ return new BigDataResult(); } List> resList = new ArrayList<>(); for(Map caseTypeItem : caseTypeList){ Map resItem = new HashMap<>(8); resItem.put("name",caseTypeItem.get("dictName").toString()); List columnsList = new ArrayList<>(); columnsList.add(Integer.parseInt(caseTypeItem.get("caseTypeCount").toString())); resItem.put("columns",columnsList); resItem.put("caseTypeId",caseTypeItem.get("caseTypeId")); resList.add(resItem); } BigDataResult bdr = new BigDataResult(); Map resData = new HashMap<>(4); resData.put("nameColumns","案件数量"); bdr.setData(resData); bdr.setList(resList); return bdr; } @ApiOperation(value = "7日案件进展情况", notes = "7日案件进展情况") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get-7day-report-case") public BigDataResult get7DayReportCase(){ Map reqParams = requestParams(); // 为了避免案件类型没传,单独处理 if(reqParams.get("caseFlowType") == null || "".equals(reqParams.get("caseFlowType").toString().trim())){ reqParams.put("caseFlowType", "1,2"); } List> resList = new ArrayList<>(); Map itemMap; String nowDate = DateUtil.getDay(); String last7Date = DateUtil.getBeforeDate(6,"yyyy-MM-dd"); reqParams.put("startTime",last7Date + " 00:00:00"); reqParams.put("endTime", nowDate + " 23:59:59"); // 受理 /*reqParams.put("caseStatusCompareUp","1"); List> list1 = dataReleaseDao.listReportCase(reqParams); itemMap = new HashMap<>(4); itemMap.put("name", "受理"); itemMap.put("value", list1 == null ? 0 : list1.size()); resList.add(itemMap);*/ // 立案 /*reqParams.put("caseStatusCompareUp","2"); List> list2 = dataReleaseDao.listReportCase(reqParams); itemMap = new HashMap<>(4); itemMap.put("name", "立案"); itemMap.put("value", list2 == null ? 0 : list2.size()); resList.add(itemMap);*/ // 待下中 reqParams.put("caseStatus","2"); List> list3 = dataReleaseDao.listReportCase(reqParams); itemMap = new HashMap<>(4); itemMap.put("name", "下派中"); itemMap.put("value", list3 == null ? 0 : list3.size()); resList.add(itemMap); // 处理 reqParams.put("caseStatus","3"); List> list4 = dataReleaseDao.listReportCase(reqParams); itemMap = new HashMap<>(4); itemMap.put("name", "处理中"); itemMap.put("value", list4 == null ? 0 : list4.size()); resList.add(itemMap); // 检查 reqParams.put("caseStatus","4"); List> list5 = dataReleaseDao.listReportCase(reqParams); itemMap = new HashMap<>(4); itemMap.put("name", "检查中"); itemMap.put("value", list5 == null ? 0 : list5.size()); resList.add(itemMap); // 归档 reqParams.put("caseStatus","6"); List> list6 = dataReleaseDao.listReportCase(reqParams); itemMap = new HashMap<>(4); itemMap.put("name", "已归档"); itemMap.put("value", list6 == null ? 0 : list6.size()); resList.add(itemMap); BigDataResult bdr = new BigDataResult(); bdr.setList(resList); return bdr; } @ApiOperation(value = "案件处理满意度", notes = "案件处理满意度") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get-grade-ratio") public BigDataResult getGradeRatio(){ Map reqParams = requestParams(); BigDataResult bdr = new BigDataResult(); // {data:{value:96.5},list:[],msg:'加载成功',state:'200'} reqParams.put("caseStatus","6"); List> gradeList = dataReleaseDao.listReportCase(reqParams); if(gradeList == null || gradeList.size() == 0){ return new BigDataResult(); } Integer totalGrade = gradeList.size() * 5; Integer nowGrade = 0; for (Map gradeItem : gradeList){ if(gradeItem.get("grade") == null || "".equals(gradeItem.get("grade").toString()) || "null".equals(gradeItem.get("grade").toString()) || "0".equals(gradeItem.get("grade").toString()) ){ nowGrade += 3; } else { nowGrade += Integer.parseInt(gradeItem.get("grade").toString()); } } BigDecimal ratioBigDecimal = new BigDecimal(( nowGrade.doubleValue() / totalGrade.doubleValue() ) * 100) .setScale(2,BigDecimal.ROUND_HALF_UP); //bdr.getRatio(nowGrade.doubleValue(), totalGrade.doubleValue(), 2); Map resData = new HashMap<>(4); resData.put("value",ratioBigDecimal.doubleValue()); bdr.setData(resData); return bdr; } @ApiOperation(value = "案件满意度二级列表", notes = "案件满意度二级列表") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("list-grade-ratio") public SuccessResultList>> listGradeRatio(){ Map params = requestParams(); params.put("caseStatus","6"); List> gradeList = dataReleaseDao.listReportCase(params); Integer totalGrade = 0; Integer nowGrade = 0; totalGrade = gradeList.size() * 5; for(Map item : gradeList){ item.put("gmt_create", item.get("gmt_create").toString().substring(0,19)); if(item.get("grade") == null || "0".equals(item.get("grade").toString()) || "".equals(item.get("grade").toString())){ nowGrade += 3; } else { nowGrade += Integer.parseInt(item.get("grade").toString()); } } if(totalGrade == 0){ return new SuccessResultList<>(new ArrayList<>(), 1, 0L); } Map totalInfoMap = new HashMap<>(8); totalInfoMap.put("case_reporter", "合计: " + gradeList.size() + "件"); BigDecimal ratioBigDecimal = new BigDecimal(( nowGrade.doubleValue() / totalGrade.doubleValue() ) * 100) .setScale(2,BigDecimal.ROUND_HALF_UP); totalInfoMap.put("grade", "总体满意度: " + ratioBigDecimal.doubleValue()); List> resList = new LinkedList<>(); resList.add(totalInfoMap); for(Map item : gradeList){ resList.add(item); } return new SuccessResultList<>(resList, 1, 0L); } @ApiOperation(value = "各月份案件情况统计", notes = "各月份案件情况统计") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get-month-report-case") public BigDataResult getMonthReportCase(){ Map reqParams = requestParams(); BigDataResult bdr = new BigDataResult(); Integer year = Integer.parseInt(DateUtil.getYear()); Integer month; if(DateUtil.getMonth().length() > 1 && "0".equals(DateUtil.getMonth().substring(0,1))){ month = Integer.parseInt(DateUtil.getMonth().replaceAll("0", "")); } else { month = Integer.parseInt(DateUtil.getMonth()); } List monthList = new ArrayList<>(); for(int i = 0; i < 12; i++){ if(month - i == 0){ monthList.add((year - 1) + "-" + 12); continue; } if(month - i < 0){ monthList.add((year -1) + "-" + (12 + (month - i))); continue; } monthList.add(year + "-" + (month - i)); } List> resList = new ArrayList<>(); for(String str : monthList){ Map resMap = new HashMap<>(8); String queryTime = str.length() == 6 ? str.replace("-", "-0") : str; reqParams.put("gmtCreateLike", queryTime); List> list = dataReleaseDao.listReportCase(reqParams); resMap.put("name", queryTime); resMap.put("value", list == null ? 0 : list.size()); resList.add(resMap); } bdr.setList(resList); return bdr; } @ApiOperation(value = "案件动态", notes = "案件动态") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get-report-case-dynamic") public BigDataResult getReportCaseDynamic(){ Map reqParams = requestParams(); // {title:'万水泉 ',content:'村名王某因为被隔壁邻居的狗咬了,产生了纠纷,村名报警。',date:'2021-03-15'} // 默认查询10条 List> logList = dataReleaseDao.listReportCaseLog(reqParams); if(logList == null || logList.size() == 0){ return new BigDataResult(); } List> resList = new ArrayList<>(); for (Map logItem : logList){ Map resData = new HashMap<>(8); resData.put("title", "【" + logItem.get("optionType").toString() + "】- " + logItem.get("userName").toString()); resData.put("date", logItem.get("gmtCreate").toString().substring(0,19)); resData.put("content", logItem.get("caseContent").toString()); resData.put("caseNumber", logItem.get("caseNumber").toString()); resList.add(resData); } BigDataResult bdr = new BigDataResult(); bdr.setList(resList); return bdr; } @ApiOperation(value = "人员实时活跃情况", notes = "人员实时活跃情况") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get-user-dynamic-position") public BigDataResult getUserDynamicPosition(){ Map reqParams = requestParams(); Date nowData = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("HH"); String nowHour = sdf.format(nowData); //nowHour = "10"; String nowDate = DateUtil.getDay() + " "; //nowDate = "2021-07-19 "; System.out.println(nowHour); List> resList = new ArrayList<>(); // 分割当前小时为6段 10分钟一段 统计活跃人数 最后一段统计59分59秒 for(int i = 0; i < 6; i++){ Map resData = new HashMap<>(8); Map query = new HashMap<>(8); if(i == 0){ query.put("timeStr",nowDate + nowHour + ":00:00"); } else { query.put("timeStr",nowDate + nowHour + ":" + (i * 10) + ":00"); } if(i == 5){ query.put("timeEnd",nowDate + nowHour + ":59:59"); query.put("time", nowHour + ":59"); resData.put("time", nowHour + ":59"); } else { query.put("timeEnd",nowDate + nowHour + ":" + (i + 1) * 10 + ":00"); query.put("time", nowHour + ":" + (i + 1) * 10); resData.put("time", nowHour + ":" + (i + 1) * 10); } List> positionList = dataReleaseDao.listUserDynamicPosition(query); resData.put("value", positionList == null ? 0 : positionList.size()); resList.add(resData); } BigDataResult bdr = new BigDataResult(); bdr.setList(resList); return bdr; } /** * 查询街道信息 city_dict表 */ @GetMapping("get-area-info-city-dict") public List> getAreaInfo(){ Map param = requestParams(); if(param.get("dictParentId") == null || "".equals(param.get("dictParentId").toString())){ return new ArrayList<>(0); } List> list = dataReleaseDao.getAreaInfoFromCityDict(param); return list; } /** * 查询社区信息 city_community表 */ @GetMapping("get-community-info") public List> getCommunityInfo(){ Map param = requestParams(); if(param.get("areaId") == null || "".equals(param.get("areaId").toString())){ return new ArrayList<>(0); } List> list = dataReleaseDao.getCommunityInfo(param); return list; } /** * 查询社区信息 案件查询 */ @GetMapping("list-page-report-case") public SuccessResultList> listPageReportCase(ListPage page) throws SearchException { Map params = requestParams(); // 为了避免案件类型没传,单独处理 if(params.get("caseFlowType") == null || "".equals(params.get("caseFlowType").toString().trim())){ params.put("caseFlowType", "1,2"); } page.setParams(params); SuccessResultList> resList = reportCaseService.listPageReportCase(page); return resList; } /** * 7日案件进展情况列表 */ @GetMapping("list-page-7day-report-case") public SuccessResultList> listPage7DayReportCase(ListPage page) throws SearchException { Map params = requestParams(); // 为了避免案件类型没传,单独处理 if(params.get("caseFlowType") == null || "".equals(params.get("caseFlowType").toString().trim())){ params.put("caseFlowType", "1,2"); } // 查询7天内的数据 if(params.get("startTime") == null && params.get("endTime") == null){ String startTime = DateUtil.getBeforeDate(6, "yyyy-MM-dd"); String endTime = DateUtil.getDay(); params.put("startTime", startTime); params.put("endTime", endTime); } // 案件状态没传情况 if(params.get("caseStatus") == null || "".equals(params.get("caseStatus").toString())){ params.put("caseStatus", "2,3,4,5,6"); } page.setParams(params); SuccessResultList> resList = reportCaseService.listPageReportCase(page); return resList; } /** * 查看案件详情 */ @GetMapping("get-report-case-detail/{reportCaseId}") public ReportCaseDTO getReportCaseDetail(@PathVariable("reportCaseId") String reportCaseId) throws SearchException { Map params = getParams(); params.put("reportCaseId", reportCaseId); ReportCaseDTO reportCaseDTO = reportCaseService.getReportCase(params); return reportCaseDTO; } @GetMapping("get-report-case-by-number/{caseNumber}") public ReportCaseDTO getReportCaseByCaseNumber(@PathVariable("caseNumber") String caseNumber) throws SearchException { Map params = getParams(); params.put("caseNumber", caseNumber); ReportCaseDTO reportCaseDTO = reportCaseService.getReportCase(params); return reportCaseDTO; } /** * 案件日志 */ @GetMapping("list-report-case-log/{reportCaseId}") public List listReportCaseLog(@PathVariable("reportCaseId") String reportCaseId) throws SearchException { Map params = requestParams(); params.put("caseId", reportCaseId); return reportCaseService.listReportCaseLog(params); } @GetMapping("list-case-in-map") public BigDataResult listCaseInMap(){ BigDataResult bdr = new BigDataResult(); List> resList = new ArrayList<>(); Map query = requestParams(); String startTime = DateUtil.getAfterDayDate("-60"); String endTime = DateUtil.getDay(); query.put("startTime", startTime); query.put("endTime", endTime); List> caseList = dataReleaseDao.listCaseInMap(query); for(Map item : caseList){ if(item.get("case_longitude") != null && item.get("case_latitude") != null){ Map resObj = new HashMap<>(8); resObj.put("gmtCreate", item.get("gmt_create").toString().substring(0,19)); resObj.put("long", item.get("case_longitude").toString()); resObj.put("lat", item.get("case_latitude").toString()); resObj.put("text", item.get("case_content") == null ? "" : item.get("case_content").toString()); resObj.put("reportCaseId", item.get("report_case_id") == null ? "" : item.get("report_case_id").toString()); resObj.put("caseReporter", item.get("case_reporter") == null ? "" : item.get("case_reporter").toString()); resList.add(resObj); } } bdr.setList(resList); return bdr; } @GetMapping("list-case-statistic-ratio") public SuccessResultList> listCaseStatistic(){ Map params = requestParams(); return reportCaseService.listCaseStatisticRatio(params); } /** * 各月份案件统计情况 -大数据 * @return */ @GetMapping("list-report-case-month") public SuccessResultList>> listReportCaseMonth(){ Map params = requestParams(); Integer year = Integer.parseInt(DateUtil.getYear()); Integer month; if(DateUtil.getMonth().length() > 1 && "0".equals(DateUtil.getMonth().substring(0,1))){ month = Integer.parseInt(DateUtil.getMonth().replaceAll("0", "")); } else { month = Integer.parseInt(DateUtil.getMonth()); } List monthList = new ArrayList<>(); for(int i = 0; i < 12; i++){ if(month - i == 0){ monthList.add((year - 1) + "-" + 12); continue; } if(month - i < 0){ monthList.add((year -1) + "-" + (12 + (month - i))); continue; } monthList.add(year + "-" + (month - i)); } List> resList = new ArrayList<>(); for(String str : monthList){ Map resMap = new HashMap<>(8); String queryTime = str.length() == 6 ? str.replace("-", "-0") : str; params.put("gmtCreateLike", queryTime); List> list = dataReleaseDao.listReportCase(params); resMap.put("yearMonth", queryTime); resMap.put("totalCount", list.size()); // 下派中 Integer xiapai = 0; // 处理中 Integer chuli = 0; // 检查中 Integer jiancha = 0; // 已归档 Integer guidang = 0; for(Map item : list){ if(item.get("case_status") != null && "2".equals(item.get("case_status").toString())){ xiapai++; } if(item.get("case_status") != null && "3".equals(item.get("case_status").toString())){ chuli++; } if(item.get("case_status") != null && "4".equals(item.get("case_status").toString())){ jiancha++; } if(item.get("case_status") != null && "6".equals(item.get("case_status").toString())){ guidang++; } } resMap.put("xiapai", xiapai); resMap.put("chuli", chuli); resMap.put("jiancha", jiancha); resMap.put("guidang", guidang); resList.add(resMap); } return new SuccessResultList<>(resList, 1, 0L); } /** * 大数据页面人员实施定位 二级弹窗列表页数据接口 * @param page * @return */ @GetMapping("list-page-user-location") public SuccessResultList> listPageUserLocation (ListPage page){ Map params = requestParams(); PageHelper.startPage(page.getPage(), page.getRows()); List> userLocationList = dataReleaseDao.listUserLocation(params); List resList = new ArrayList<>(); // 查询用户上传的最新的一条定位信息 for(Map item : userLocationList){ String userId = item.get("creator").toString(); params.put("userId", userId); Map temp = dataReleaseDao.getLastUserLocationInfo(params); UserLocationDTO dto = new UserLocationDTO(); dto.setUserLocationId(temp.get("user_location_id") == null ? "" : temp.get("user_location_id").toString()); dto.setUserLongitude(temp.get("user_longitude") == null ? "" : temp.get("user_longitude").toString()); dto.setUserLatitude(temp.get("user_latitude") == null ? "" : temp.get("user_latitude").toString()); dto.setUserLocation(temp.get("user_location") == null ? "" : temp.get("user_location").toString()); dto.setIsOverstep(temp.get("is_overstep") == null ? "" : temp.get("is_overstep").toString()); dto.setUserName(temp.get("user_name") == null ? "" : temp.get("user_name").toString()); dto.setCreator(temp.get("creator") == null ? "" : temp.get("creator").toString()); dto.setGmtCreate(temp.get("gmt_create") == null ? "" : temp.get("gmt_create").toString().substring(11,19)); dto.setUserAvatar(temp.get("user_avatar") == null ? "" : temp.get("user_avatar").toString()); // 如果取不到手机号 则使用登录账号 if(temp.get("user_phone") == null){ dto.setUserPhone(temp.get("user_username") == null ? "" : temp.get("user_username").toString()); } else { dto.setUserPhone(temp.get("user_phone").toString()); } resList.add(dto); } PageInfo> pageInfo = new PageInfo<>(userLocationList); return new SuccessResultList<>(resList, pageInfo.getPageNum(), pageInfo.getTotal()); } @GetMapping("list-user-and-points-by-userids-by-grid-service") public List listUserAndPointsByUserIdsByGridService () throws ParamsException, SearchException{ Map params = requestParams(); if (params.get("userIds") == null || StringUtils.isBlank(params.get("userIds").toString())) { return new ArrayList<>(); } return userPointsService.listUserAndPointsByUserIdsByGridService(params); } }