自处理案件统计

This commit is contained in:
Renpc-kilig 2024-04-15 16:12:19 +08:00
parent 79bc386be5
commit bb0a564ae4
7 changed files with 1639 additions and 1181 deletions

View File

@ -14,6 +14,7 @@ import com.cm.systemcity.pojo.vos.IdsVO;
import com.cm.systemcity.pojo.vos.reportcase.*;
import com.cm.systemcity.service.readstate.IReadStateService;
import com.cm.systemcity.service.reportcase.IReportCaseService;
import com.cm.systemcity.service.reportcase.impl.ReportCaseServiceImpl;
import freemarker.template.TemplateException;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
@ -624,4 +625,22 @@ public class ReportCaseController extends AbstractController {
reportCaseService.updateReportCase(params);
return new SuccessResult();
}
/**
* 区域下数据数量
* 需要传入 areaParentId 统计该地区下级信息
*/
@GetMapping("data-counts/{level}")
public List<CaseCountDTO> dataCount(@PathVariable("level") Integer level){
Map<String, Object> params = requestParams();
return reportCaseService.dataCount(level, params);
}
@ApiOperation(value = "导出自上报案件数量", notes = "导出自上报案件数量接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("export-datacount")
public void exportDataCount(HttpServletResponse response) throws Exception {
Map<String, Object> params = requestParams();
reportCaseService.exportDataCount(response, params);
}
}

View File

@ -384,4 +384,6 @@ public interface IReportCaseDao {
List<HandleDepartmentDTO> listDept(Map<String, Object> params);
Integer countReportCaseAssign(Map<String, Object> reportCaseAssignMap);
List<Map<String, Object>> countData(Map<String, Object> params);
}

View File

@ -0,0 +1,80 @@
package com.cm.systemcity.pojo.dtos.reportcase;
import io.swagger.annotations.ApiModelProperty;
/**
* @author xwangs
* @create 2020-12-07 14:29
* @description
*/
public class CaseCountDTO {
@ApiModelProperty(name = "name", value = "级别")
private String name;
@ApiModelProperty(name = "count", value = "数量")
private String count;
@ApiModelProperty(name = "level", value = "级别")
private Integer level;
@ApiModelProperty(name = "dataId", value = "数据ID")
private String dataId;
@ApiModelProperty(name = "prpeDataId", value = "上一级数据ID")
private String prpeDataId;
@ApiModelProperty(name = "dataId", value = "上一级级别")
private Integer prpeLevel;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
public String getPrpeDataId() {
return prpeDataId;
}
public void setPrpeDataId(String prpeDataId) {
this.prpeDataId = prpeDataId;
}
public Integer getPrpeLevel() {
return prpeLevel;
}
public void setPrpeLevel(Integer prpeLevel) {
this.prpeLevel = prpeLevel;
}
@Override
public String toString() {
return "CaseCountDTO{" +
"name='" + name + '\'' +
", count='" + count + '\'' +
'}';
}
}

View File

@ -9,6 +9,7 @@ import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.systemcity.pojo.dtos.reportcase.*;
import com.cm.systemcity.service.reportcase.impl.ReportCaseServiceImpl;
import freemarker.template.TemplateException;
import javax.servlet.http.HttpServletResponse;
@ -492,5 +493,9 @@ public interface IReportCaseService {
SuccessResultList<List<ReportCaseDTO>> listReportCaseComplex(ListPage page);
void removeToComplexCases(Map<String, Object> params);
void removeToComplexCases(java.util.Map<java.lang.String,java.lang.Object> params);
List<CaseCountDTO> dataCount(Integer level, Map<String, Object> params);
void exportDataCount(HttpServletResponse response, Map<String, Object> params);
}

View File

@ -1,5 +1,6 @@
package com.cm.systemcity.service.reportcase.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cm.common.component.SecurityComponent;
@ -15,7 +16,6 @@ import com.cm.common.plugin.oauth.service.department.IDepartmentService;
import com.cm.common.plugin.pojo.dtos.file.FileInfoWithPathDTO;
import com.cm.common.pojo.ListPage;
import com.cm.common.pojo.bos.UserInfoBO;
import com.cm.common.pojo.dtos.FileDTO;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
@ -23,7 +23,6 @@ import com.cm.common.token.app.AppTokenManager;
import com.cm.common.token.app.entity.AppToken;
import com.cm.common.token.app.entity.AppTokenUser;
import com.cm.common.utils.DateUtil;
import com.cm.common.utils.RequestUtil;
import com.cm.common.utils.UUIDUtil;
import com.cm.common.utils.ZipUtil;
import com.cm.common.utils.point.Point;
@ -34,6 +33,7 @@ import com.cm.systemcity.pojo.ImageBase64;
import com.cm.systemcity.pojo.dtos.AreaPointsDTO;
import com.cm.systemcity.pojo.dtos.areapoints.GridAndPointsDTO;
import com.cm.systemcity.pojo.dtos.bindingdepartment.BindingDepartmentDTO;
import com.cm.systemcity.pojo.dtos.community.CommunityDTO;
import com.cm.systemcity.pojo.dtos.dict.DictDTO;
import com.cm.systemcity.pojo.dtos.readstate.ReadStateDTO;
import com.cm.systemcity.pojo.dtos.reportcase.*;
@ -60,12 +60,10 @@ import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -2122,4 +2120,160 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer
}
return !PointUtil.isPointInPoly(point, points);
}
@Override
public List<CaseCountDTO> dataCount(Integer level, Map<String, Object> params) {
switch (level) {
case 1:
return dataCountLevel1(params);
case 2:
return dataCountLevel2(params);
case 3:
return dataCountLevel3(params);
case 4:
return dataCountLevel4(params);
}
return new ArrayList<>();
}
@Override
public void exportDataCount(HttpServletResponse response, Map<String, Object> params) {
Integer level = Integer.parseInt(params.get("level").toString());
List<CaseCountDTO> caseCountDTOS = dataCount(level, params);
String excelName = "自处理案件统计";
String fileName = null;
try {
fileName = URLEncoder.encode(excelName, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
String [] headers = {"序号", "级别", "数量"};
List<List<String>> listHeader = new ArrayList<>();
for(String item : headers) {
List<String> title = new ArrayList<>();
title.add(item);
listHeader.add(title);
}
List<List<Object>> listData = new ArrayList<>();
int i = 0;
for (CaseCountDTO caseCountDTO : caseCountDTOS) {
i++;
List<Object> data = new ArrayList<>();
data.add(i);
data.add(caseCountDTO.getName());
data.add(caseCountDTO.getCount());
listData.add(data);
}
try {
EasyExcel.write(response.getOutputStream()).sheet("自处理案件统计").head(listHeader).doWrite(listData);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* 全区数据
*
* @param params
*/
private List<CaseCountDTO> dataCountLevel1(Map<String, Object> params) {
List<Map<String, Object>> resultMap = reportCaseDao.countData(params);
CaseCountDTO caseCountDTO = new CaseCountDTO();
caseCountDTO.setName("全区");
caseCountDTO.setCount(resultMap.get(0).get("count").toString());
caseCountDTO.setLevel(1);
List<CaseCountDTO> caseCountDTOList = new ArrayList<>();
caseCountDTOList.add(caseCountDTO);
return caseCountDTOList;
}
/**
* 街道数据
*
* @param params
*/
private List<CaseCountDTO> dataCountLevel2(Map<String, Object> params) {
// 获取所有的街道数据
params.put("dictParentId", "9d179f05-3ea0-48f7-853c-d3b7124b791c");
params.put("area", "yes");
List<Map<String, Object>> resultMapList = reportCaseDao.countData(params);
List<DictDTO> dictDTOS = dictService.listDict(params);
List<CaseCountDTO> caseCountDTOList = new ArrayList<>();
for (DictDTO dictDTO : dictDTOS) {
for (Map<String, Object> stringObjectMap : resultMapList) {
if (dictDTO.getDictId().equals(stringObjectMap.get("areaId").toString())) {
CaseCountDTO caseCountDTO = new CaseCountDTO();
caseCountDTO.setName(dictDTO.getDictName());
caseCountDTO.setCount(stringObjectMap.get("count").toString());
caseCountDTO.setDataId(stringObjectMap.get("areaId").toString());
caseCountDTO.setLevel(2);
caseCountDTO.setPrpeLevel(1);
caseCountDTO.setPrpeDataId("9d179f05-3ea0-48f7-853c-d3b7124b791c");
caseCountDTOList.add(caseCountDTO);
}
}
}
return caseCountDTOList;
}
/**
* 社区数据
*
* @param params
*/
private List<CaseCountDTO> dataCountLevel3(Map<String, Object> params) {
// 获取所有的街道数据
List<CommunityDTO> communityDTOS = communityService.listCommunity(params);
params.put("community", "yes");
if(null == params.get("areaId")) {
throw new SearchException("areaId不能为空");
}
List<Map<String, Object>> resultMapList = reportCaseDao.countData(params);
List<CaseCountDTO> caseCountDTOList = new ArrayList<>();
for (CommunityDTO communityDTO : communityDTOS) {
for (Map<String, Object> stringObjectMap : resultMapList) {
if (communityDTO.getCommunityId().equals(stringObjectMap.get("communityId").toString())) {
CaseCountDTO caseCountDTO = new CaseCountDTO();
caseCountDTO.setName(communityDTO.getCommunityName());
caseCountDTO.setCount(stringObjectMap.get("count").toString());
caseCountDTO.setDataId(stringObjectMap.get("communityId").toString());
caseCountDTO.setLevel(3);
caseCountDTO.setPrpeLevel(2);
caseCountDTO.setPrpeDataId(params.get("areaId").toString());
caseCountDTOList.add(caseCountDTO);
}
}
}
return caseCountDTOList;
}
/**
* 网格员数据
*
* @param params
*/
private List<CaseCountDTO> dataCountLevel4(Map<String, Object> params) {
params.put("creator", "yes");
if(null == params.get("communityId")) {
throw new SearchException("communityId不能为空");
}
List<Map<String, Object>> maps = reportCaseDao.countData(params);
List<CaseCountDTO> caseCountDTOList = new ArrayList<>();
for (Map<String, Object> map : maps) {
CaseCountDTO caseCountDTO = new CaseCountDTO();
caseCountDTO.setName(map.get("caseReporter").toString());
caseCountDTO.setCount(map.get("count").toString());
caseCountDTO.setDataId(map.get("creator").toString());
caseCountDTO.setLevel(4);
caseCountDTO.setPrpeLevel(3);
caseCountDTO.setPrpeDataId(params.get("prpeDataId").toString());
caseCountDTO.setDataId(params.get("communityId").toString());
caseCountDTOList.add(caseCountDTO);
}
return caseCountDTOList;
}
}

View File

@ -0,0 +1,218 @@
<!doctype html>
<html lang="en">
<head>
<base href="/servicecity/">
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-card" id="left-card-div" style="">
<div class="layui-card-body">
<div style="padding: 10px 0px; border-bottom: 1px solid #DDDDDD;text-align: right">
<button typeof="button" id="backToArea" class="layui-btn layui-btn-sm">返回上级</button>
<button typeof="button" id="exportExcel" class="layui-btn layui-btn-sm">导出本级数据</button>
</div>
<div>
<table class="layui-table">
<colgroup>
<col width="200">
<col width="150">
</colgroup>
<thead>
<tr>
<th style="text-align: center;">级别</th>
<th style="text-align: center;">数量</th>
</tr>
</thead>
<tbody id="areaUserCountBox"></tbody>
<script type="text/html" id="areaUserCountTemplate">
{{# for(var i = 0, item; item = d[i++];) { }}
<tr>
<td style="text-align: center;">
<a href="javascript:void(0)"
data-hansubarea="{{item.name}}" class="change-area"
style="color: #0a54a6;text-decoration: underline"
data-level="{{item.level}}"
data-dataId="{{item.dataId}}"
data-prpeLevel="{{item.prpeLevel}}"
data-prpeDataId="{{item.prpeDataId}}">{{item.name}}</a>
</td>
<td style="text-align: center;">
<a href="javascript:void(0)">{{item.count}}</a>
</td>
</tr>
{{# } }}
</script>
</table>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laytpl', 'laydate', 'common'], function () {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var laytpl = layui.laytpl;
var common = layui.common;
var resizeTimeout = null;
var tableUrl = 'api/building/listpage';
var residentialId = top.restAjax.params(window.location.href).residentialId;
var dataMsg = {
url: '',
dataId: '',
level: '',
nowLevel: '',
nowDataId: ''
};
var areaCode = '';
$('#left-card-div').height($win.height() - 30);
$('#left-card-div').css('overflow', 'auto');
function initData() {
listAreaUserCounts('api/reportcase/data-counts/{level}', 1, '');
}
initData();
function listAreaUserCounts(url, level, searchData, prpeDataId) {
var loadIndex = layer.load(0, {shade: 0.3});
top.restAjax.get(top.restAjax.path(url, [level, searchData, prpeDataId]),
{}, null, function (code, data) {
debugger
dataMsg.nowLevel = data[0].level;
dataMsg.nowDataId = data[0].dataId;
dataMsg.level = data[0].prpeLevel;
dataMsg.dataId = data[0].prpeDataId;
console.log(dataMsg)
laytpl(document.getElementById('areaUserCountTemplate').innerHTML).render(data, function (html) {
document.getElementById('areaUserCountBox').innerHTML = html;
});
layer.close(loadIndex);
}, function (code, data) {
top.dialog.msg(data.msg);
});
}
// 绑定点击区域切换事件
$(document).on('click', '.change-area', function () {
var level = $(this).data().level;
level+=1;
var dataId = $(this).data().dataid;
var url = '';
if(level == 2) {
url = 'api/reportcase/data-counts/{level}';
}
if(level == 3) {
url = 'api/reportcase/data-counts/{level}?areaId={areaId}';
}
if(level == 4) {
url = 'api/reportcase/data-counts/{level}?communityId={communityId}&prpeDataId={prpeDataId}';
}
if(level > 4) {
return false;
}
listAreaUserCounts(url, level, dataId, dataMsg.dataId);
reloadTable();
});
// 返回上级
$(document).on('click', '#backToArea', function () {
var level = dataMsg.level;
var dataId = dataMsg.dataId;
var url;
debugger
if(level == 1) {
url = 'api/reportcase/data-counts/{level}';
}
if(level == 2) {
url = 'api/reportcase/data-counts/{level}';
}
if(level == 3) {
url = 'api/reportcase/data-counts/{level}?areaId={areaId}';
}
if(level == 4) {
url = 'api/reportcase/data-counts/{level}?communityId={communityId}';
}
listAreaUserCounts(url, level, dataId);
reloadTable();
});
// 导出数据
$(document).on('click', '#exportExcel', function () {
top.dialog.msg('确定导出吗?', {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var level = dataMsg.nowLevel;
var dataId = dataMsg.nowDataId;
var url;
if(level == 1) {
url = 'api/reportcase/export-datacount?level={level}';
}
if(level == 2) {
url = 'api/reportcase/export-datacount?level={level}';
}
if(level == 3) {
url = 'api/reportcase/export-datacount?level={level}&areaId={areaId}';
}
if(level == 4) {
url = 'api/reportcase/export-datacount?level={level}&communityId={communityId}&prpeDataId={prpeDataId}';
}
window.open(top.restAjax.path(url, [level, dataId, dataMsg.dataId]));
}
});
});
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
url: top.restAjax.path(tableUrl, [residentialId]),
where: {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val()
},
page: {
curr: currentPage
},
height: $win.height() - 90,
});
}
// 事件 - 页面变化
$win.on('resize', function () {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function () {
reloadTable();
}, 500);
});
});
</script>
</body>
</html>