From 75b91cc4c3df0589d3a3ff6e752e8b086d82e9b1 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Mon, 20 May 2024 10:29:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=88=E4=BB=B6=E7=BB=9F=E8=AE=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datarelease/DataReleaseController.java | 52 +- .../dao/reportcase/IReportCaseDao.java | 2 + .../pojo/dtos/reportcase/CaseCountDTO.java | 10 + .../reportcase/IReportCaseService.java | 4 + .../impl/ReportCaseServiceImpl.java | 619 ++++++++++++++++-- .../mapper/reportcase/reportcase-mapper.xml | 66 ++ .../route/bigdata/list-area-case-bigdata.html | 363 ++++++++++ .../route/bigdata/list-case-handle-year.html | 1 + .../route/reportcase/list-area-case.html | 40 +- 9 files changed, 1076 insertions(+), 81 deletions(-) create mode 100644 src/main/resources/static/route/bigdata/list-area-case-bigdata.html diff --git a/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java b/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java index c41741c..b712559 100644 --- a/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java +++ b/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java @@ -18,10 +18,7 @@ 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.reportcase.*; import com.cm.systemcity.pojo.dtos.userlocation.UserLocationDTO; import com.cm.systemcity.service.bindingdepartment.IBindingDepartmentService; import com.cm.systemcity.service.community.ICommunityService; @@ -43,8 +40,10 @@ import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Query; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -1290,4 +1289,49 @@ public class DataReleaseController extends AbstractController { return resList; } + @GetMapping("data-counts-bigdata/{level}") + public List dataCountBigdata(@PathVariable("level") Integer level){ + Map params = requestParams(); + if(null == params.get("start")) { + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + + // 获取当前年份 + int currentYear = currentDate.getYear(); + params.put("start", currentYear + "01-01"); + } + if(null == params.get("end")) { + params.put("start", LocalDate.now()); + } + return reportCaseService.dataCountBigdata(level, params); + } + + @GetMapping("update-case-bigdata") + public SuccessResultData updateCaseBigData() { + long startTime = System.currentTimeMillis(); + Map params = requestParams(); + reportCaseService.updateCaseCount(params); + long endTime = System.currentTimeMillis(); + return new SuccessResultData<>("used " + (endTime - startTime) + " ms"); + } + + @ApiOperation(value = "导出自上报案件数量", notes = "导出自上报案件数量接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("export-datacount-bigdata") + public void exportDataCountBigData(HttpServletResponse response) throws Exception { + Map params = requestParams(); + if(null == params.get("start")) { + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + + // 获取当前年份 + int currentYear = currentDate.getYear(); + params.put("start", currentYear + "01-01"); + } + if(null == params.get("end")) { + params.put("start", LocalDate.now()); + } + reportCaseService.exportDataCountBigdata(response, params); + } + } diff --git a/src/main/java/com/cm/systemcity/dao/reportcase/IReportCaseDao.java b/src/main/java/com/cm/systemcity/dao/reportcase/IReportCaseDao.java index e0712f8..62a9cd5 100755 --- a/src/main/java/com/cm/systemcity/dao/reportcase/IReportCaseDao.java +++ b/src/main/java/com/cm/systemcity/dao/reportcase/IReportCaseDao.java @@ -433,4 +433,6 @@ public interface IReportCaseDao { void updateCase(Map params); List dataCountLevel1(Map params); + + List dataCountReportCase(Map caseParams); } diff --git a/src/main/java/com/cm/systemcity/pojo/dtos/reportcase/CaseCountDTO.java b/src/main/java/com/cm/systemcity/pojo/dtos/reportcase/CaseCountDTO.java index dd6f6c7..0a81b5d 100644 --- a/src/main/java/com/cm/systemcity/pojo/dtos/reportcase/CaseCountDTO.java +++ b/src/main/java/com/cm/systemcity/pojo/dtos/reportcase/CaseCountDTO.java @@ -27,6 +27,8 @@ public class CaseCountDTO { private Integer prpeLevel; @ApiModelProperty(name = "userId", value = "网格员ID") private String userId; + @ApiModelProperty(name = "departmentId", value = "部门ID") + private String departmentId; public String getName() { return name; @@ -100,6 +102,14 @@ public class CaseCountDTO { this.userId = userId; } + public String getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } + @Override public String toString() { return "CaseCountDTO{" + diff --git a/src/main/java/com/cm/systemcity/service/reportcase/IReportCaseService.java b/src/main/java/com/cm/systemcity/service/reportcase/IReportCaseService.java index 76715df..4988379 100755 --- a/src/main/java/com/cm/systemcity/service/reportcase/IReportCaseService.java +++ b/src/main/java/com/cm/systemcity/service/reportcase/IReportCaseService.java @@ -502,4 +502,8 @@ public interface IReportCaseService { SuccessResultList> listPageHandleCase(ListPage page); void updateCaseCount(Map params); + + List dataCountBigdata(Integer level, Map params); + + void exportDataCountBigdata(HttpServletResponse response, Map params); } diff --git a/src/main/java/com/cm/systemcity/service/reportcase/impl/ReportCaseServiceImpl.java b/src/main/java/com/cm/systemcity/service/reportcase/impl/ReportCaseServiceImpl.java index 05aa81a..1c3aed4 100755 --- a/src/main/java/com/cm/systemcity/service/reportcase/impl/ReportCaseServiceImpl.java +++ b/src/main/java/com/cm/systemcity/service/reportcase/impl/ReportCaseServiceImpl.java @@ -48,7 +48,6 @@ import com.cm.systemcity.service.readstate.IReadStateService; import com.cm.systemcity.service.reportcase.IReportCaseService; import com.cm.systemcity.service.userpoints.IUserPointsService; import com.cm.systemcity.service.worknote.IWorkNoteService; -import com.cm.systemcity.utils.BigDataResult2; import com.cm.systemcity.utils.ImageUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -60,7 +59,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.shiro.util.CollectionUtils; import org.joda.time.DateTime; import org.joda.time.Days; -import org.joda.time.LocalDateTime; import org.joda.time.format.DateTimeFormat; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -75,6 +73,8 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.List; import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.LongAdder; import java.util.stream.Collectors; /** @@ -2185,34 +2185,94 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer List caseCountDTOList = new ArrayList<>(); + String dataId = null; + for (String key : groupMap.keySet()) { List value = groupMap.get(key); - CaseCountDTO caseCountDTO = new CaseCountDTO(); - caseCountDTO.setName(key); - long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); - long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); - caseCountDTO.setAllCount("" + value.size()); - caseCountDTO.setSelfCount("" + (int) selfCount); - caseCountDTO.setHandleCount("" + (int) handleCount); - caseCountDTO.setDataId(value.get(0).getAreaId()); - caseCountDTO.setLevel(2); - caseCountDTO.setPrpeLevel(1); - caseCountDTO.setPrpeDataId("9d179f05-3ea0-48f7-853c-d3b7124b791c"); - caseCountDTOList.add(caseCountDTO); - + if(!key.equals("专管员区域")) { + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName(key); + long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); + long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); + caseCountDTO.setAllCount("" + value.size()); + caseCountDTO.setSelfCount("" + (int) selfCount); + caseCountDTO.setHandleCount("" + (int) handleCount); + caseCountDTO.setDataId(value.get(0).getAreaId()); + caseCountDTO.setLevel(2); + caseCountDTO.setPrpeLevel(1); + caseCountDTO.setPrpeDataId("9d179f05-3ea0-48f7-853c-d3b7124b791c"); + caseCountDTOList.add(caseCountDTO); + }else { + dataId = value.get(0).getAreaId(); + } } + // 列出所有的专管机构 + params.put("departmentParentId", "0"); + List handleDepartmentDTOS = reportCaseDao.listDept(params); + for (int i = 0; i < handleDepartmentDTOS.size(); i++) { + HandleDepartmentDTO handleDepartmentDTO = handleDepartmentDTOS.get(i); + handleDepartmentDTO.setCaseCount(0); + } + AtomicInteger zgyAllCount = new AtomicInteger(); + AtomicInteger zgySelfCount = new AtomicInteger(); + AtomicInteger zgyHandleCount = new AtomicInteger(); + handleDepartmentDTOS.forEach(handleDepartmentDTO -> { + // 查询需要专管员的案件 + Map caseParams = getHashMap(2); + caseParams.put("startTime", params.get("start")); + caseParams.put("endTime", params.get("end")); + caseParams.put("handleDepartmentId", handleDepartmentDTO.getDepartmentId()); + List reportCaseDTOList = reportCaseDao.dataCountReportCase(caseParams); + if(!CollectionUtils.isEmpty(reportCaseDTOList)) { + zgyAllCount.addAndGet(reportCaseDTOList.size()); + zgySelfCount.addAndGet((int) reportCaseDTOList.stream().filter(element -> element.getIsSelf() == 1).count()); + + List caseIdList = reportCaseDTOList.stream() + .map(ReportCaseDTO::getReportCaseId) + .collect(Collectors.toList()); + + final int batchSize = 5000; + int start = 0; + int totalHandleCount = 0; + while (start < caseIdList.size()) { + int end = Math.min(start + batchSize, caseIdList.size()); + List batchCaseIds = caseIdList.subList(start, end); + + params.put("caseIds", batchCaseIds); + Integer i1 = reportCaseDao.handleCountData(params); + totalHandleCount += i1; + + start += batchSize; + } + + zgyHandleCount.addAndGet(totalHandleCount); + } + + }); + + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName("专管员区域"); + caseCountDTO.setAllCount("" + zgyAllCount); + caseCountDTO.setSelfCount("" + zgySelfCount); + caseCountDTO.setHandleCount("" + zgyHandleCount); + caseCountDTO.setDataId(dataId); + caseCountDTO.setLevel(2); + caseCountDTO.setPrpeLevel(1); + caseCountDTO.setPrpeDataId("9d179f05-3ea0-48f7-853c-d3b7124b791c"); + caseCountDTOList.add(caseCountDTO); + if (CollectionUtils.isEmpty(caseCountDTOList)) { - CaseCountDTO caseCountDTO = new CaseCountDTO(); - caseCountDTO.setName("暂无数据"); - caseCountDTO.setSelfCount("0"); - caseCountDTO.setHandleCount("0"); - caseCountDTO.setAllCount("0"); - caseCountDTO.setDataId("9999"); - caseCountDTO.setLevel(2); - caseCountDTO.setPrpeLevel(1); - caseCountDTO.setPrpeDataId("9d179f05-3ea0-48f7-853c-d3b7124b791c"); - caseCountDTOList.add(caseCountDTO); + CaseCountDTO caseCountDTO1 = new CaseCountDTO(); + caseCountDTO1.setName("暂无数据"); + caseCountDTO1.setSelfCount("0"); + caseCountDTO1.setHandleCount("0"); + caseCountDTO1.setAllCount("0"); + caseCountDTO1.setDataId("9999"); + caseCountDTO1.setLevel(2); + caseCountDTO1.setPrpeLevel(1); + caseCountDTO1.setPrpeDataId("9d179f05-3ea0-48f7-853c-d3b7124b791c"); + caseCountDTOList.add(caseCountDTO1); } return caseCountDTOList; @@ -2223,31 +2283,97 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer if (null == params.get("areaId")) { throw new SearchException("areaId不能为空"); } - List casePOList = reportCaseDao.dataCountLevel1(params); - Map> groupMap = casePOList.stream() - .collect(Collectors.groupingBy(CasePO::getCommunityId)); List caseCountDTOList = new ArrayList<>(); - for (String key : groupMap.keySet()) { - List value = groupMap.get(key); - String communityName = value.get(0).getCommunityName(); - if(communityName.equals("油房村") || communityName.equals("高油房村")) { - continue; + if(!params.get("areaId").toString().equals("e64a0a05-45ca-4452-a869-a4dcbff74593")) { + List casePOList = reportCaseDao.dataCountLevel1(params); + Map> groupMap = casePOList.stream() + .collect(Collectors.groupingBy(CasePO::getCommunityId)); + + for (String key : groupMap.keySet()) { + List value = groupMap.get(key); + String communityName = value.get(0).getCommunityName(); + if (communityName.equals("油房村") || communityName.equals("高油房村")) { + continue; + } + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName(value.get(0).getCommunityName().equals("高油房村") ? + "油房村" : value.get(0).getCommunityName()); + long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); + long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); + caseCountDTO.setAllCount("" + value.size()); + caseCountDTO.setSelfCount("" + (int) selfCount); + caseCountDTO.setHandleCount("" + (int) handleCount); + caseCountDTO.setDataId(value.get(0).getCommunityId()); + caseCountDTO.setLevel(3); + caseCountDTO.setPrpeLevel(2); + caseCountDTO.setPrpeDataId(params.get("areaId").toString()); + caseCountDTOList.add(caseCountDTO); } - CaseCountDTO caseCountDTO = new CaseCountDTO(); - caseCountDTO.setName(value.get(0).getCommunityName().equals("高油房村") ? - "油房村" : value.get(0).getCommunityName()); - long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); - long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); - caseCountDTO.setAllCount("" + value.size()); - caseCountDTO.setSelfCount("" + (int) selfCount); - caseCountDTO.setHandleCount("" + (int) handleCount); - caseCountDTO.setDataId(value.get(0).getCommunityId()); - caseCountDTO.setLevel(3); - caseCountDTO.setPrpeLevel(2); - caseCountDTO.setPrpeDataId(params.get("areaId").toString()); - caseCountDTOList.add(caseCountDTO); + }else { + // 列出所有的专管机构 + params.put("departmentParentId", "0"); + List handleDepartmentDTOS = reportCaseDao.listDept(params); + for (int i = 0; i < handleDepartmentDTOS.size(); i++) { + HandleDepartmentDTO handleDepartmentDTO = handleDepartmentDTOS.get(i); + handleDepartmentDTO.setCaseCount(0); + } + AtomicInteger zgyAllCount = new AtomicInteger(); + AtomicInteger zgySelfCount = new AtomicInteger(); + AtomicInteger zgyHandleCount = new AtomicInteger(); + handleDepartmentDTOS.forEach(handleDepartmentDTO -> { + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName(handleDepartmentDTO.getDepartmentName()); + caseCountDTO.setDepartmentId(handleDepartmentDTO.getDepartmentId()); + + // 查询需要专管员的案件 + Map caseParams = getHashMap(2); + caseParams.put("startTime", params.get("start")); + caseParams.put("endTime", params.get("end")); + caseParams.put("handleDepartmentId", handleDepartmentDTO.getDepartmentId()); + List reportCaseDTOList = reportCaseDao.dataCountReportCase(caseParams); + if (!CollectionUtils.isEmpty(reportCaseDTOList)) { + zgyAllCount.addAndGet(reportCaseDTOList.size()); + zgySelfCount.addAndGet((int) reportCaseDTOList.stream().filter(element -> element.getIsSelf() == 1).count()); + + List caseIdList = reportCaseDTOList.stream() + .map(ReportCaseDTO::getReportCaseId) + .collect(Collectors.toList()); + + final int batchSize = 5000; + int start = 0; + int totalHandleCount = 0; + while (start < caseIdList.size()) { + int end = Math.min(start + batchSize, caseIdList.size()); + List batchCaseIds = caseIdList.subList(start, end); + + params.put("caseIds", batchCaseIds); + Integer i1 = reportCaseDao.handleCountData(params); + totalHandleCount += i1; + + start += batchSize; + } + + zgyHandleCount.addAndGet(totalHandleCount); + + + long selfCount = reportCaseDTOList.stream().filter(element -> element.getIsSelf() == 1).count(); + caseCountDTO.setAllCount("" + reportCaseDTOList.size()); + caseCountDTO.setSelfCount("" + (int) selfCount); + caseCountDTO.setHandleCount("" + totalHandleCount); + caseCountDTO.setDataId(reportCaseDTOList.get(0).getCommunityId()); + }else { + caseCountDTO.setAllCount("0"); + caseCountDTO.setSelfCount("0"); + caseCountDTO.setHandleCount("0"); + caseCountDTO.setDataId(params.get("areaId").toString()); + } + caseCountDTO.setLevel(3); + caseCountDTO.setPrpeLevel(2); + caseCountDTO.setPrpeDataId(params.get("areaId").toString()); + caseCountDTOList.add(caseCountDTO); + }); } if (CollectionUtils.isEmpty(caseCountDTOList)) { @@ -2272,27 +2398,80 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer throw new SearchException("communityId不能为空"); } - List casePOList = reportCaseDao.dataCountLevel1(params); - Map> groupMap = casePOList.stream() - .collect(Collectors.groupingBy(CasePO::getReportUserName)); + String communityId = params.get("communityId").toString(); + + if(null == params.get("prpedataId")) { + throw new SearchException("prpedataId不能为空"); + } + + String prpedataId = params.get("prpedataId").toString(); List caseCountDTOList = new ArrayList<>(); - for (String key : groupMap.keySet()) { - List value = groupMap.get(key); - CaseCountDTO caseCountDTO = new CaseCountDTO(); - caseCountDTO.setName(key); - long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); - long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); - caseCountDTO.setAllCount("" + value.size()); - caseCountDTO.setSelfCount("" + (int) selfCount); - caseCountDTO.setHandleCount("" + (int) handleCount); - caseCountDTO.setDataId(value.get(0).getReportUserId()); - caseCountDTO.setLevel(4); - caseCountDTO.setPrpeLevel(3); - caseCountDTO.setPrpeDataId(params.get("prpeDataId").toString()); - caseCountDTO.setDataId(params.get("communityId").toString()); - caseCountDTOList.add(caseCountDTO); + if(!prpedataId.equals("e64a0a05-45ca-4452-a869-a4dcbff74593")) { + List casePOList = reportCaseDao.dataCountLevel1(params); + Map> groupMap = casePOList.stream() + .collect(Collectors.groupingBy(CasePO::getReportUserName)); + + for (String key : groupMap.keySet()) { + List value = groupMap.get(key); + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName(key); + long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); + long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); + caseCountDTO.setAllCount("" + value.size()); + caseCountDTO.setSelfCount("" + (int) selfCount); + caseCountDTO.setHandleCount("" + (int) handleCount); + caseCountDTO.setDataId(value.get(0).getReportUserId()); + caseCountDTO.setLevel(4); + caseCountDTO.setPrpeLevel(3); + caseCountDTO.setPrpeDataId(params.get("prpeDataId").toString()); + caseCountDTO.setDataId(params.get("communityId").toString()); + caseCountDTOList.add(caseCountDTO); + } + }else { + // 查询需要专管员的案件 + Map caseParams = getHashMap(2); + caseParams.put("startTime", params.get("start")); + caseParams.put("endTime", params.get("end")); + caseParams.put("handleDepartmentId", params.get("departmentId")); + List reportCaseDTOList = reportCaseDao.dataCountReportCase(caseParams); + Map> collect = reportCaseDTOList.stream() + .collect(Collectors.groupingBy(ReportCaseDTO::getCaseReporter)); + + for (String key : collect.keySet()) { + List value = collect.get(key); + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName(key); + long selfCount = value.stream().filter(element -> element.getIsSelf() == 1).count(); + caseCountDTO.setAllCount("" + value.size()); + caseCountDTO.setSelfCount("" + (int) selfCount); + + List caseIdList = value.stream() + .map(ReportCaseDTO::getReportCaseId) + .collect(Collectors.toList()); + final int batchSize = 5000; + int start = 0; + int totalHandleCount = 0; + while (start < caseIdList.size()) { + int end = Math.min(start + batchSize, caseIdList.size()); + List batchCaseIds = caseIdList.subList(start, end); + + params.put("caseIds", batchCaseIds); + Integer i1 = reportCaseDao.handleCountData(params); + totalHandleCount += i1; + + start += batchSize; + } + + caseCountDTO.setHandleCount("" + totalHandleCount); + caseCountDTO.setDataId(value.get(0).getCaseReporter()); + caseCountDTO.setLevel(4); + caseCountDTO.setPrpeLevel(3); + caseCountDTO.setPrpeDataId(params.get("prpeDataId").toString()); + caseCountDTO.setDataId(params.get("communityId").toString()); + caseCountDTOList.add(caseCountDTO); + } } if (CollectionUtils.isEmpty(caseCountDTOList)) { @@ -2305,7 +2484,7 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer caseCountDTO.setLevel(4); caseCountDTO.setPrpeLevel(3); caseCountDTO.setPrpeDataId(params.get("prpeDataId").toString()); - caseCountDTO.setDataId(params.get("communityId").toString()); + caseCountDTO.setDataId(communityId); caseCountDTOList.add(caseCountDTO); } @@ -2801,4 +2980,314 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer } }); } + + @Override + public List dataCountBigdata(Integer level, Map params) { + String userType = params.get("userType").toString(); + switch (level) { + case 1: + return dataCountBigdataLevel1(params, userType); + case 2: + return dataCountBigdataLevel2(params, userType); + case 3: + return dataCountBigdataLevel3(params, userType); + case 4: + return dataCountBigdataLevel4(params, userType); + } + return new ArrayList<>(); + } + + @Override + public void exportDataCountBigdata(HttpServletResponse response, Map params) { + Integer level = Integer.parseInt(params.get("level").toString()); + List caseCountDTOS = dataCountBigdata(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> listHeader = new ArrayList<>(); + for (String item : headers) { + List title = new ArrayList<>(); + title.add(item); + listHeader.add(title); + } + + List> listData = new ArrayList<>(); + int i = 0; + for (CaseCountDTO caseCountDTO : caseCountDTOS) { + i++; + List data = new ArrayList<>(); + data.add(i); + data.add(caseCountDTO.getName()); + data.add(caseCountDTO.getAllCount()); + data.add(caseCountDTO.getHandleCount()); + data.add(caseCountDTO.getSelfCount()); + listData.add(data); + } + try { + EasyExcel.write(response.getOutputStream()).sheet("自处理案件统计").head(listHeader).doWrite(listData); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private List getUserMsg(String userType, Map params) { + List userList = new ArrayList<>(); + if (userType.equals("网格员")) { + // 查询所有网格员 + List communityBossDTOS = communityBossService.listCommunityBoss(params); + userList = communityBossDTOS.stream() + .map(CommunityBossDTO::getCommunityBossUserId).collect(Collectors.toList()); + } + + if (userType.equals("专管员")) { + params.put("roleId", "bc405346-8714-4ded-89ac-9cc4d755f66a"); + + List> roleUserMap = communityBossService.getRoleUser(params); + userList = roleUserMap.stream() + .map(map -> map.get("userId").toString()).collect(Collectors.toList()); + } + + return userList; + } + + private List dataCountBigdataLevel1(Map params, String userType) { + Map newParams = new HashMap<>(); + newParams.putAll(params); + // 获取所有网格员处理数 + final int batchSize = 5000; + int start = 0; + long selfCount = 0L; + long handleCount = 0L; + List allPOList = new ArrayList<>(); + List userList = getUserMsg(userType, newParams); + + while (start < userList.size()) { + int end = Math.min(start + batchSize, userList.size()); + List batchBossIds = userList.subList(start, end); + + params.put("bossIds", batchBossIds); + List casePOList = reportCaseDao.dataCountLevel1(params); + + allPOList.addAll(casePOList); + + start += batchSize; + } + + if (!CollectionUtils.isEmpty(allPOList)) { + selfCount = allPOList.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); + handleCount = allPOList.stream().filter(element -> element.getIsHandle() == 1).count(); + } + + CaseCountDTO dto = new CaseCountDTO(); + dto.setName("全区"); + dto.setAllCount("" + allPOList.size()); + dto.setSelfCount("" + (int) selfCount); + dto.setHandleCount("" + (int) handleCount); + dto.setLevel(1); + List caseCountDTOList = new ArrayList<>(); + caseCountDTOList.add(dto); + return caseCountDTOList; + + } + + private List dataCountBigdataLevel2(Map params, String userType) { + Map newParams = new HashMap<>(); + newParams.putAll(params); + params.put("dictParentId", "9d179f05-3ea0-48f7-853c-d3b7124b791c"); + // 获取所有网格员处理数 + final int batchSize = 5000; + int start = 0; + List casePOList = new ArrayList<>(); + List userList = getUserMsg(userType, newParams); + + while (start < userList.size()) { + int end = Math.min(start + batchSize, userList.size()); + List batchBossIds = userList.subList(start, end); + + params.put("bossIds", batchBossIds); + List subList = reportCaseDao.dataCountLevel1(params); + + casePOList.addAll(subList); + + start += batchSize; + } + + Map> groupMap = casePOList.stream() + .collect(Collectors.groupingBy(CasePO::getAreaName)); + + List caseCountDTOList = new ArrayList<>(); + + for (String key : groupMap.keySet()) { + List value = groupMap.get(key); + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName(key); + long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); + long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); + caseCountDTO.setAllCount("" + value.size()); + caseCountDTO.setSelfCount("" + (int) selfCount); + caseCountDTO.setHandleCount("" + (int) handleCount); + caseCountDTO.setDataId(value.get(0).getAreaId()); + caseCountDTO.setLevel(2); + caseCountDTO.setPrpeLevel(1); + caseCountDTO.setPrpeDataId("9d179f05-3ea0-48f7-853c-d3b7124b791c"); + caseCountDTOList.add(caseCountDTO); + + } + + if (CollectionUtils.isEmpty(caseCountDTOList)) { + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName("暂无数据"); + caseCountDTO.setSelfCount("0"); + caseCountDTO.setHandleCount("0"); + caseCountDTO.setAllCount("0"); + caseCountDTO.setDataId("9999"); + caseCountDTO.setLevel(2); + caseCountDTO.setPrpeLevel(1); + caseCountDTO.setPrpeDataId("9d179f05-3ea0-48f7-853c-d3b7124b791c"); + caseCountDTOList.add(caseCountDTO); + } + + return caseCountDTOList; + } + + private List dataCountBigdataLevel3(Map params, String userType) { + Map newParams = new HashMap<>(); + newParams.putAll(params); + params.put("community", "yes"); + if (null == params.get("areaId")) { + throw new SearchException("areaId不能为空"); + } + + // 获取所有网格员处理数 + final int batchSize = 5000; + int start = 0; + List casePOList = new ArrayList<>(); + List userList = getUserMsg(userType, newParams); + + while (start < userList.size()) { + int end = Math.min(start + batchSize, userList.size()); + List batchBossIds = userList.subList(start, end); + + params.put("bossIds", batchBossIds); + List subList = reportCaseDao.dataCountLevel1(params); + + casePOList.addAll(subList); + + start += batchSize; + } + + Map> groupMap = casePOList.stream() + .collect(Collectors.groupingBy(CasePO::getCommunityId)); + + List caseCountDTOList = new ArrayList<>(); + + for (String key : groupMap.keySet()) { + List value = groupMap.get(key); + String communityName = value.get(0).getCommunityName(); + if(communityName.equals("油房村") || communityName.equals("高油房村")) { + continue; + } + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName(value.get(0).getCommunityName().equals("高油房村") ? + "油房村" : value.get(0).getCommunityName()); + long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); + long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); + caseCountDTO.setAllCount("" + value.size()); + caseCountDTO.setSelfCount("" + (int) selfCount); + caseCountDTO.setHandleCount("" + (int) handleCount); + caseCountDTO.setDataId(value.get(0).getCommunityId()); + caseCountDTO.setLevel(3); + caseCountDTO.setPrpeLevel(2); + caseCountDTO.setPrpeDataId(params.get("areaId").toString()); + caseCountDTOList.add(caseCountDTO); + } + + if (CollectionUtils.isEmpty(caseCountDTOList)) { + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName("暂无数据"); + caseCountDTO.setSelfCount("0"); + caseCountDTO.setHandleCount("0"); + caseCountDTO.setAllCount("0"); + caseCountDTO.setDataId("9999"); + caseCountDTO.setLevel(3); + caseCountDTO.setPrpeLevel(2); + caseCountDTO.setPrpeDataId(params.get("areaId").toString()); + caseCountDTOList.add(caseCountDTO); + } + + return caseCountDTOList; + } + + private List dataCountBigdataLevel4(Map params, String userType) { + Map newParams = new HashMap<>(); + newParams.putAll(params); + params.put("creator", "yes"); + if (null == params.get("communityId")) { + throw new SearchException("communityId不能为空"); + } + + // 获取所有网格员处理数 + final int batchSize = 5000; + int start = 0; + List casePOList = new ArrayList<>(); + List userList = getUserMsg(userType, newParams); + + while (start < userList.size()) { + int end = Math.min(start + batchSize, userList.size()); + List batchBossIds = userList.subList(start, end); + + params.put("bossIds", batchBossIds); + List subList = reportCaseDao.dataCountLevel1(params); + + casePOList.addAll(subList); + + start += batchSize; + } + + Map> groupMap = casePOList.stream() + .collect(Collectors.groupingBy(CasePO::getReportUserName)); + + List caseCountDTOList = new ArrayList<>(); + + for (String key : groupMap.keySet()) { + List value = groupMap.get(key); + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName(key); + long selfCount = value.stream().filter(element -> element.getIsSelf() == 1 && element.getIsHandle() == 1).count(); + long handleCount = value.stream().filter(element -> element.getIsHandle() == 1).count(); + caseCountDTO.setAllCount("" + value.size()); + caseCountDTO.setSelfCount("" + (int) selfCount); + caseCountDTO.setHandleCount("" + (int) handleCount); + caseCountDTO.setDataId(value.get(0).getReportUserId()); + caseCountDTO.setLevel(4); + caseCountDTO.setPrpeLevel(3); + caseCountDTO.setPrpeDataId(params.get("prpeDataId").toString()); + caseCountDTO.setDataId(params.get("communityId").toString()); + caseCountDTOList.add(caseCountDTO); + } + + if (CollectionUtils.isEmpty(caseCountDTOList)) { + CaseCountDTO caseCountDTO = new CaseCountDTO(); + caseCountDTO.setName("暂无数据"); + caseCountDTO.setSelfCount("0"); + caseCountDTO.setHandleCount("0"); + caseCountDTO.setAllCount("0"); + caseCountDTO.setDataId("9999"); + caseCountDTO.setLevel(4); + caseCountDTO.setPrpeLevel(3); + caseCountDTO.setPrpeDataId(params.get("prpeDataId").toString()); + caseCountDTO.setDataId(params.get("communityId").toString()); + caseCountDTOList.add(caseCountDTO); + } + + return caseCountDTOList; + } } \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/reportcase/reportcase-mapper.xml b/src/main/resources/mybatis/mapper/reportcase/reportcase-mapper.xml index 4a41313..eddb9c6 100755 --- a/src/main/resources/mybatis/mapper/reportcase/reportcase-mapper.xml +++ b/src/main/resources/mybatis/mapper/reportcase/reportcase-mapper.xml @@ -3061,7 +3061,73 @@ AND community_id = #{communityId} + + AND report_user_id IN + + #{bossIds[${index}]} + + + + \ No newline at end of file diff --git a/src/main/resources/static/route/bigdata/list-area-case-bigdata.html b/src/main/resources/static/route/bigdata/list-area-case-bigdata.html new file mode 100644 index 0000000..c6a960a --- /dev/null +++ b/src/main/resources/static/route/bigdata/list-area-case-bigdata.html @@ -0,0 +1,363 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+ +
+ +
+ +
+ + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + +
级别已上报数量已处理数量自处理数量
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/route/bigdata/list-case-handle-year.html b/src/main/resources/static/route/bigdata/list-case-handle-year.html index c99f8b9..1effe88 100644 --- a/src/main/resources/static/route/bigdata/list-case-handle-year.html +++ b/src/main/resources/static/route/bigdata/list-case-handle-year.html @@ -142,6 +142,7 @@ initCaseType(); initChildCaseType('');*/ initTable('网格员'); + initArea() } init(); diff --git a/src/main/resources/static/route/reportcase/list-area-case.html b/src/main/resources/static/route/reportcase/list-area-case.html index bd1343e..11cf4f3 100644 --- a/src/main/resources/static/route/reportcase/list-area-case.html +++ b/src/main/resources/static/route/reportcase/list-area-case.html @@ -63,7 +63,8 @@ data-level="{{item.level}}" data-dataId="{{item.dataId}}" data-prpeLevel="{{item.prpeLevel}}" - data-prpeDataId="{{item.prpeDataId}}">{{item.name}} + data-prpeDataId="{{item.prpeDataId}}" + data-departmentId="{{item.departmentId}}">{{item.name}} {{# } }} {{# if(item.name != '暂无数据'){ }} @@ -73,7 +74,8 @@ data-level="{{item.level}}" data-dataId="{{item.dataId}}" data-prpeLevel="{{item.prpeLevel}}" - data-prpeDataId="{{item.prpeDataId}}">{{item.name}} + data-prpeDataId="{{item.prpeDataId}}" + data-departmentId="{{item.departmentId}}">{{item.name}} {{# } }} @@ -141,7 +143,9 @@ dataId: '', level: 0, nowLevel: '', - nowDataId: '' + nowDataId: '', + prpedataid: '', + departmentId: '' }; $('#left-card-div').height($win.height() - 30); @@ -164,6 +168,8 @@ dataMsg.nowDataId = data[0].dataId; dataMsg.level = data[0].prpeLevel; dataMsg.dataId = data[0].prpeDataId; + dataMsg.prpedataid = data[0].prpeDataId; + dataMsg.departmentId = data[0].departmentId; console.log(dataMsg) laytpl(document.getElementById('areaUserCountTemplate').innerHTML).render(data, function (html) { document.getElementById('areaUserCountBox').innerHTML = html; @@ -181,7 +187,8 @@ var dataId = $(this).data().dataid; var url = ''; - console.log("level==" + level + "-------" + "dataId==" + dataId) + var prpedataid = $(this).data().prpedataid; + var departmentId = $(this).data().departmentid; var start = $('#start').val(); var end = $('#end').val(); @@ -193,7 +200,8 @@ url = 'api/reportcase/data-counts/{level}?areaId={areaId}&start=' + start + '&end='+ end; } if(level == 4) { - url = 'api/reportcase/data-counts/{level}?communityId={communityId}&prpeDataId={prpeDataId}&start=' + start + '&end='+ end; + url = 'api/reportcase/data-counts/{level}?communityId={communityId}&prpeDataId={prpeDataId}&start=' + + start + '&end='+ end + '&prpedataId=' + prpedataid + '&departmentId=' + departmentId; } if(level > 4) { @@ -206,9 +214,11 @@ function changeSearchData() { // 假设 elem 是你已经获取到的元素引用 let elem = document.querySelector('.change-area'); - + console.log(elem) let level = elem.dataset.level; let dataId = elem.dataset.dataid; + let prpedataid = elem.dataset.prpedataid; + var departmentId = elem.dataset.departmentid; console.log(level, "------------", dataId) var url = ''; @@ -226,7 +236,8 @@ url = 'api/reportcase/data-counts/{level}?areaId={areaId}&start=' + start + '&end='+ end; } if(level == 4) { - url = 'api/reportcase/data-counts/{level}?communityId={communityId}&prpeDataId={prpeDataId}&start=' + start + '&end='+ end; + url = 'api/reportcase/data-counts/{level}?communityId={communityId}&prpeDataId={prpeDataId}&start=' + + start + '&end='+ end + '&prpedataId=' + prpedataid + '&departmentId=' + departmentId; } if(level > 4) { @@ -240,19 +251,25 @@ $(document).on('click', '#backToArea', function () { var level = dataMsg.level; var dataId = dataMsg.dataId; + var prpedataid = dataMsg.prpedataid; + var departmentId = dataMsg.departmentId; + var start = $('#start').val(); + var end = $('#end').val(); var url; if(level == 1) { - url = 'api/reportcase/data-counts/{level}'; + url = 'api/reportcase/data-counts/{level}?start=' + start + '&end='+ end; } + if(level == 2) { - url = 'api/reportcase/data-counts/{level}'; + url = 'api/reportcase/data-counts/{level}?start=' + start + '&end='+ end; } if(level == 3) { - url = 'api/reportcase/data-counts/{level}?areaId={areaId}'; + url = 'api/reportcase/data-counts/{level}?areaId={areaId}&start=' + start + '&end='+ end; } if(level == 4) { - url = 'api/reportcase/data-counts/{level}?communityId={communityId}'; + url = 'api/reportcase/data-counts/{level}?communityId={communityId}&prpeDataId={prpeDataId}&start=' + + start + '&end='+ end + '&prpedataId=' + prpedataid + '&departmentId=' + departmentId; } listAreaUserCounts(url, level, dataId); }); @@ -316,7 +333,6 @@ $win.on('resize', function () { clearTimeout(resizeTimeout); resizeTimeout = setTimeout(function () { - reloadTable(); }, 500); });