From cb093a1548c0c5b77501ec5adaad93d929f1a612 Mon Sep 17 00:00:00 2001 From: wans <747101512@qq.com> Date: Tue, 27 Jul 2021 15:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=88=E4=BB=B6=E4=BF=A1=E6=81=AF=E6=83=85?= =?UTF-8?q?=E5=86=B5=E5=A4=A7=E6=95=B0=E6=8D=AE=E9=A1=B5=E9=9D=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datarelease/DataReleaseController.java | 362 ++++++++++++++++++ .../dao/datarelease/IDataReleaseDao.java | 53 +++ .../datarelease/IDataReleaseService.java | 12 + .../impl/DataReleaseServiceImpl.java | 15 + .../cm/systemcity/utils/BigDataResult.java | 75 ++++ .../mapper/datarelease/datarelease-mapper.xml | 109 ++++++ 6 files changed, 626 insertions(+) create mode 100644 src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java create mode 100644 src/main/java/com/cm/systemcity/dao/datarelease/IDataReleaseDao.java create mode 100644 src/main/java/com/cm/systemcity/service/datarelease/IDataReleaseService.java create mode 100644 src/main/java/com/cm/systemcity/service/datarelease/impl/DataReleaseServiceImpl.java create mode 100644 src/main/java/com/cm/systemcity/utils/BigDataResult.java create mode 100644 src/main/resources/mybatis/mapper/datarelease/datarelease-mapper.xml diff --git a/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java b/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java new file mode 100644 index 0000000..195b1fe --- /dev/null +++ b/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java @@ -0,0 +1,362 @@ +package com.cm.systemcity.controller.datarelease; + +import com.cm.common.base.AbstractController; +import com.cm.common.constants.ISystemConstant; +import com.cm.common.result.ErrorResult; +import com.cm.common.utils.DateUtil; +import com.cm.systemcity.dao.datarelease.IDataReleaseDao; +import com.cm.systemcity.pojo.dtos.dict.DictDTO; +import com.cm.systemcity.service.datarelease.IDataReleaseService; +import com.cm.systemcity.service.dict.IDictService; +import com.cm.systemcity.utils.BigDataResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +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 IDataReleaseService dataReleaseService; + @Autowired + private IDataReleaseDao dataReleaseDao; + @Autowired + private IDictService dictService; + + @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("areaId",dictItem.getDictId()); + List> normalList = dataReleaseDao.listReportCase(reqParams); + // 查询该街镇下所有特殊案件 + List> specialList = dataReleaseDao.listSpecialReportCase(reqParams); + resItem.put("value",normalList.size() + specialList.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); + resList.add(resItem); + } + BigDataResult bdr = new BigDataResult(); + Map resData = new HashMap<>(4); + resData.put("caseTypeCount","案件数量"); + 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(); + // {data:{},list:[{name:'受理',value:585},{name:'立案',value:25},{name:'下派',value:89},{name:'处理',value:856}, + // {name:'检查',value:856},{name:'归档',value:856}],msg:'加载成功',state:'200'} + List> resList = new ArrayList<>(); + Map itemMap; + String nowDate = DateUtil.getDay(); + String last7Date = DateUtil.getBeforeDate(7,"yyyy-MM-dd"); + reqParams.put("modifiedStr",last7Date + " 00:00:00"); + reqParams.put("modifiedEnd", nowDate + " 00:00:00"); + // 受理 + 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("caseStatusCompareUp","3"); + 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("caseStatusCompareUp","4"); + 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("caseStatusCompareUp","5"); + 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("caseStatusCompareUp","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()) + ){ + nowGrade += Integer.parseInt(gradeItem.get("grade").toString()); + } + } + BigDecimal ratioBigDecimal = 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("get-month-report-case") + public BigDataResult getMonthReportCase(){ + Map reqParams = requestParams(); + // {data:{},list:[{name:' 1月',value:22},{name:'2月',value:'968'},{name:'3月',value:6952},{name:'4月',value:5955},{name:'5月', + // value:1204},{name:'6月',value:2054},{name:'7月',value:3250},{name:'8月',value:1048}, + // {name:'9月',value:458},{name:'10月',value:1520},{name:'11月',value:1952},{name:'12月',value:702},],msg:'加载成功',state:'200'} + BigDataResult bdr = new BigDataResult(); + String year = DateUtil.getYear(); + List monthList = new ArrayList<>(); + List> resList = new ArrayList<>(); + for(int i = 1;i <= 12; i++){ + if(i < 10){ + monthList.add(year + "-0" + i); + continue; + } + monthList.add(year + "-" + i); + } + for(int i = 0; i < monthList.size(); i++){ + reqParams.clear(); + reqParams.put("gmtCreateLike", monthList.get(i)); + Map itemMap = new HashMap<>(4); + List> list = dataReleaseDao.listReportCase(reqParams); + itemMap.put("name", (i+1) + "月"); + itemMap.put("value", list == null ? 0 : list.size()); + resList.add(itemMap); + } + 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()); + 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; + } +} diff --git a/src/main/java/com/cm/systemcity/dao/datarelease/IDataReleaseDao.java b/src/main/java/com/cm/systemcity/dao/datarelease/IDataReleaseDao.java new file mode 100644 index 0000000..c9c4014 --- /dev/null +++ b/src/main/java/com/cm/systemcity/dao/datarelease/IDataReleaseDao.java @@ -0,0 +1,53 @@ +package com.cm.systemcity.dao.datarelease; + +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +/** + * @author xwangs + * @create 2021-07-23 14:00 + * @description + */ +@Repository +public interface IDataReleaseDao { + + /** + * 查询案件数量接口 + * @param query case_flow_type 1职能部门 2街镇案件(上报人不是微信用户) + * case_status 6归档 + * case_reporter 上报人姓名 + * + * @return + */ + List> listReportCase(Map query); + + /** + * 查询特殊案件数量接口 + * @param query + * @return + */ + List> listSpecialReportCase(Map query); + + /** + * 查询案件类型TOP10 + * @param reqParams + * @return + */ + List> getCaseTypeTop10(Map reqParams); + + /** + * 案件动态查询-log表 + * @param reqParams + * @return + */ + List> listReportCaseLog(Map reqParams); + + /** + * 实时定位列表查询 + * @param query + * @return + */ + List> listUserDynamicPosition(Map query); +} diff --git a/src/main/java/com/cm/systemcity/service/datarelease/IDataReleaseService.java b/src/main/java/com/cm/systemcity/service/datarelease/IDataReleaseService.java new file mode 100644 index 0000000..a5a781c --- /dev/null +++ b/src/main/java/com/cm/systemcity/service/datarelease/IDataReleaseService.java @@ -0,0 +1,12 @@ +package com.cm.systemcity.service.datarelease; + +import com.cm.systemcity.service.BaseService; + +/** + * @author xwangs + * @create 2021-07-23 11:40 + * @description + */ +public interface IDataReleaseService { + +} diff --git a/src/main/java/com/cm/systemcity/service/datarelease/impl/DataReleaseServiceImpl.java b/src/main/java/com/cm/systemcity/service/datarelease/impl/DataReleaseServiceImpl.java new file mode 100644 index 0000000..9f782ff --- /dev/null +++ b/src/main/java/com/cm/systemcity/service/datarelease/impl/DataReleaseServiceImpl.java @@ -0,0 +1,15 @@ +package com.cm.systemcity.service.datarelease.impl; + +import com.cm.systemcity.service.BaseService; +import com.cm.systemcity.service.datarelease.IDataReleaseService; +import org.springframework.stereotype.Service; + +/** + * @author xwangs + * @create 2021-07-23 11:41 + * @description + */ +@Service +public class DataReleaseServiceImpl extends BaseService implements IDataReleaseService { + +} diff --git a/src/main/java/com/cm/systemcity/utils/BigDataResult.java b/src/main/java/com/cm/systemcity/utils/BigDataResult.java new file mode 100644 index 0000000..8644ddd --- /dev/null +++ b/src/main/java/com/cm/systemcity/utils/BigDataResult.java @@ -0,0 +1,75 @@ +package com.cm.systemcity.utils; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class BigDataResult { + + private Map data = new HashMap(); + + private List list = new ArrayList(); + + private String msg = "加载成功"; + + private String state = "200"; + + public static BigDataResult getInstance() { + return new BigDataResult(); + } + + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } + + public List getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(List list) { + this.list = list; + } + + public String getMsg() { + return msg == null ? "" : msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public String getState() { + return state == null ? "" : state; + } + + public void setState(String state) { + this.state = state; + } + + public BigDecimal getRatio(Double val1, Double val2, int decimal){ + if(val2 == 0d || val1 == 0d){ + return new BigDecimal(0); + } + BigDecimal ratioDecimal = new BigDecimal(( val1 / val2 ) * 100); + ratioDecimal.setScale(decimal,BigDecimal.ROUND_HALF_UP); + return ratioDecimal; + } + + public String lastMonth() { + LocalDate today = LocalDate.now(); + today = today.minusMonths(1); + DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM"); + return formatters.format(today); + } +} \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/datarelease/datarelease-mapper.xml b/src/main/resources/mybatis/mapper/datarelease/datarelease-mapper.xml new file mode 100644 index 0000000..b6f727a --- /dev/null +++ b/src/main/resources/mybatis/mapper/datarelease/datarelease-mapper.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + \ No newline at end of file