From b96e254bcb1750b701096f576d0c4ec5c5c908a4 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Mon, 22 Apr 2024 15:37:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=88=E4=BB=B6=E7=BB=9F=E8=AE=A1=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E4=BF=AE=E6=94=B9=E3=80=82=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=9C=AC=E5=B9=B4=E5=A4=84=E7=90=86=E6=A1=88=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datarelease/DataReleaseController.java | 73 ++++++++++++ .../dao/communityboss/ICommunityBossDao.java | 2 + .../dao/reportcase/IReportCaseDao.java | 8 ++ .../communityboss/ICommunityBossService.java | 2 + .../impl/CommunityBossServiceImpl.java | 5 + .../impl/ReportCaseServiceImpl.java | 110 +++++++++++++++++- .../cm/systemcity/utils/BigDataResult2.java | 101 ++++++++++++++++ .../communityboss/communityboss-mapper.xml | 8 ++ .../mapper/reportcase/reportcase-mapper.xml | 28 +++++ 9 files changed, 332 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/cm/systemcity/utils/BigDataResult2.java 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 f7c9b60..903f826 100644 --- a/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java +++ b/src/main/java/com/cm/systemcity/controller/datarelease/DataReleaseController.java @@ -33,6 +33,7 @@ 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.cm.systemcity.utils.BigDataResult2; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.*; @@ -45,6 +46,7 @@ import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; /** * 网格治理对外提供数据接口类 @@ -67,6 +69,8 @@ public class DataReleaseController extends AbstractController { @Autowired private IReportCaseService reportCaseService; @Autowired + private IReportCaseDao reportCaseDao; + @Autowired private IUserLocationService userLocationService; @Autowired private IUserPointsService userPointsService; @@ -1205,4 +1209,73 @@ public class DataReleaseController extends AbstractController { return userPointsService.listUserAndPointsByUserIdsByGridService(params); } + @ApiOperation(value = "本年案件处理情况", notes = "本年案件处理情况") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("get-case-handle-year") + public BigDataResult2 getCaseHandleYear() { + Map reqParams = requestParams(); + // 查询所有网格员 + List communityBossDTOS = communityBossService.listCommunityBoss(reqParams); + List bossList = communityBossDTOS.stream() + .map(CommunityBossDTO::getCommunityBossUserId).collect(Collectors.toList()); + + // 获取当前年份 + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + + // 查询所有的专管员(ID: bc405346-8714-4ded-89ac-9cc4d755f66a) + reqParams.put("roleId", "bc405346-8714-4ded-89ac-9cc4d755f66a"); + List> roleUserMap = communityBossService.getRoleUser(reqParams); + List roleList = roleUserMap.stream() + .map(map -> map.get("userId").toString()).collect(Collectors.toList()); + + BigDataResult2 bdr = new BigDataResult2(); + List countClassList = new ArrayList<>(); + + // 获取所有网格员处理数 + final int batchSize = 5000; + for (int i = 1; i <= 12; i++) { + int start = 0; + int totalHandleCount1 = 0; + int totalHandleCount2 = 0; + String time = year + "-" + i; + if (i < 10) { + time = year + "-0" + i; + } + + reqParams.put("time", time); + + while (start < bossList.size()) { + int end = Math.min(start + batchSize, bossList.size()); + List batchBossIds = bossList.subList(start, end); + + reqParams.put("bossIds", batchBossIds); + Integer count = reportCaseDao.handleCountData(reqParams); + + totalHandleCount1 += count; + + start += batchSize; + } + + start = 0; + + while (start < roleList.size()) { + int end = Math.min(start + batchSize, roleList.size()); + List batchUserIds = roleList.subList(start, end); + + reqParams.put("bossIds", batchUserIds); + Integer count = reportCaseDao.handleCountData(reqParams); + + totalHandleCount2 += count; + start += batchSize; + } + + BigDataResult2.CountClass class1 = new BigDataResult2.CountClass(time, totalHandleCount1, totalHandleCount2); + countClassList.add(class1); + } + + bdr.setCountClass(countClassList); + return bdr; + } + } diff --git a/src/main/java/com/cm/systemcity/dao/communityboss/ICommunityBossDao.java b/src/main/java/com/cm/systemcity/dao/communityboss/ICommunityBossDao.java index 584a524..7dc00ba 100755 --- a/src/main/java/com/cm/systemcity/dao/communityboss/ICommunityBossDao.java +++ b/src/main/java/com/cm/systemcity/dao/communityboss/ICommunityBossDao.java @@ -232,4 +232,6 @@ public interface ICommunityBossDao { List> listGridUser(Map query); void deleteCommunityAndGridUserBind(Map query); + + List> getRoleUser(Map reqParams); } 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 27409d0..2f8445c 100755 --- a/src/main/java/com/cm/systemcity/dao/reportcase/IReportCaseDao.java +++ b/src/main/java/com/cm/systemcity/dao/reportcase/IReportCaseDao.java @@ -390,4 +390,12 @@ public interface IReportCaseDao { List> allCountData(Map params); Integer handleCountData(Map params); + + Integer queryCountWithTempTable(Map params); + + void createTempTable(Map params); + + void insertIntoTempTable(Map params); + + void cleanUpTempTable(); } diff --git a/src/main/java/com/cm/systemcity/service/communityboss/ICommunityBossService.java b/src/main/java/com/cm/systemcity/service/communityboss/ICommunityBossService.java index 0e79843..f5bd19c 100755 --- a/src/main/java/com/cm/systemcity/service/communityboss/ICommunityBossService.java +++ b/src/main/java/com/cm/systemcity/service/communityboss/ICommunityBossService.java @@ -230,4 +230,6 @@ public interface ICommunityBossService { List listGridUser(Map params); List listCommunityBossByLevel(int level); + + List> getRoleUser(Map reqParams); } diff --git a/src/main/java/com/cm/systemcity/service/communityboss/impl/CommunityBossServiceImpl.java b/src/main/java/com/cm/systemcity/service/communityboss/impl/CommunityBossServiceImpl.java index 071a29f..3f2e1bf 100755 --- a/src/main/java/com/cm/systemcity/service/communityboss/impl/CommunityBossServiceImpl.java +++ b/src/main/java/com/cm/systemcity/service/communityboss/impl/CommunityBossServiceImpl.java @@ -721,4 +721,9 @@ public class CommunityBossServiceImpl extends AbstractService implements ICommun List> nPeopleList = communityBossDao.listNPeopleByRoleId(roleId); return nPeopleList; } + + @Override + public List> getRoleUser(Map reqParams) { + return communityBossDao.getRoleUser(reqParams); + } } \ No newline at end of file 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 41f7f5f..fc5755c 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 @@ -2202,8 +2202,30 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer } params.put("caseIds", caseIdList); - Integer i = reportCaseDao.handleCountData(params); - caseCountDTOList.get(0).setHandleCount(i.toString()); + /*Integer i = reportCaseDao.handleCountData(params); + caseCountDTOList.get(0).setHandleCount(i.toString());*/ + + 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); + /* reportCaseDao.createTempTable(params); + reportCaseDao.insertIntoTempTable(params); + Integer i1 = reportCaseDao.queryCountWithTempTable(params); + reportCaseDao.cleanUpTempTable();*/ + Integer i1 = reportCaseDao.handleCountData(params); + totalHandleCount += i1; + + start += batchSize; + } + + // 更新DTO + caseCountDTOList.get(0).setHandleCount(String.valueOf(totalHandleCount)); + return caseCountDTOList; } @@ -2251,7 +2273,7 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer caseIdMap.put(caseCountDTO.getDataId(), caseIdList); } - for (String key : caseIdMap.keySet()) { + /*for (String key : caseIdMap.keySet()) { params.put("caseIds", caseIdMap.get(key)); Integer i = reportCaseDao.handleCountData(params); for (CaseCountDTO caseCountDTO : caseCountDTOList) { @@ -2259,6 +2281,32 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer caseCountDTO.setHandleCount(i.toString()); } } + }*/ + + for (String key : caseIdMap.keySet()) { + params.put("caseIds", caseIdMap.get(key)); + final int batchSize = 5000; + int start = 0; + int totalHandleCount = 0; + while (start < caseIdMap.get(key).size()) { + int end = Math.min(start + batchSize, caseIdMap.get(key).size()); + List batchCaseIds = caseIdMap.get(key).subList(start, end); + + params.put("caseIds", batchCaseIds); + /* reportCaseDao.createTempTable(params); + reportCaseDao.insertIntoTempTable(params); + Integer i1 = reportCaseDao.queryCountWithTempTable(params); + reportCaseDao.cleanUpTempTable();*/ + Integer i1 = reportCaseDao.handleCountData(params); + totalHandleCount += i1; + + start += batchSize; + } + for (CaseCountDTO caseCountDTO : caseCountDTOList) { + if (key.equals(caseCountDTO.getDataId())) { + caseCountDTO.setHandleCount(String.valueOf(totalHandleCount)); + } + } } return caseCountDTOList; @@ -2310,7 +2358,7 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer caseIdMap.put(caseCountDTO.getDataId(), caseIdList); } - for (String key : caseIdMap.keySet()) { + /*for (String key : caseIdMap.keySet()) { params.put("caseIds", caseIdMap.get(key)); Integer i = reportCaseDao.handleCountData(params); for (CaseCountDTO caseCountDTO : caseCountDTOList) { @@ -2318,6 +2366,32 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer caseCountDTO.setHandleCount(i.toString()); } } + }*/ + + for (String key : caseIdMap.keySet()) { + params.put("caseIds", caseIdMap.get(key)); + final int batchSize = 5000; + int start = 0; + int totalHandleCount = 0; + while (start < caseIdMap.get(key).size()) { + int end = Math.min(start + batchSize, caseIdMap.get(key).size()); + List batchCaseIds = caseIdMap.get(key).subList(start, end); + + params.put("caseIds", batchCaseIds); + /* reportCaseDao.createTempTable(params); + reportCaseDao.insertIntoTempTable(params); + Integer i1 = reportCaseDao.queryCountWithTempTable(params); + reportCaseDao.cleanUpTempTable();*/ + Integer i1 = reportCaseDao.handleCountData(params); + totalHandleCount += i1; + + start += batchSize; + } + for (CaseCountDTO caseCountDTO : caseCountDTOList) { + if (key.equals(caseCountDTO.getDataId())) { + caseCountDTO.setHandleCount(String.valueOf(totalHandleCount)); + } + } } return caseCountDTOList; @@ -2365,7 +2439,7 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer caseIdMap.put(caseCountDTO.getDataId(), caseIdList); } - for (String key : caseIdMap.keySet()) { + /*for (String key : caseIdMap.keySet()) { params.put("caseIds", caseIdMap.get(key)); Integer i = reportCaseDao.handleCountData(params); for (CaseCountDTO caseCountDTO : caseCountDTOList) { @@ -2373,6 +2447,32 @@ public class ReportCaseServiceImpl extends BaseService implements IReportCaseSer caseCountDTO.setHandleCount(i.toString()); } } + }*/ + + for (String key : caseIdMap.keySet()) { + params.put("caseIds", caseIdMap.get(key)); + final int batchSize = 5000; + int start = 0; + int totalHandleCount = 0; + while (start < caseIdMap.get(key).size()) { + int end = Math.min(start + batchSize, caseIdMap.get(key).size()); + List batchCaseIds = caseIdMap.get(key).subList(start, end); + + params.put("caseIds", batchCaseIds); + /* reportCaseDao.createTempTable(params); + reportCaseDao.insertIntoTempTable(params); + Integer i1 = reportCaseDao.queryCountWithTempTable(params); + reportCaseDao.cleanUpTempTable();*/ + Integer i1 = reportCaseDao.handleCountData(params); + totalHandleCount += i1; + + start += batchSize; + } + for (CaseCountDTO caseCountDTO : caseCountDTOList) { + if (key.equals(caseCountDTO.getDataId())) { + caseCountDTO.setHandleCount(String.valueOf(totalHandleCount)); + } + } } return caseCountDTOList; diff --git a/src/main/java/com/cm/systemcity/utils/BigDataResult2.java b/src/main/java/com/cm/systemcity/utils/BigDataResult2.java new file mode 100644 index 0000000..f504751 --- /dev/null +++ b/src/main/java/com/cm/systemcity/utils/BigDataResult2.java @@ -0,0 +1,101 @@ +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 BigDataResult2 { + + private List countClass; + + private String msg = "加载成功"; + + private String state = "200"; + + public List getCountClass() { + if(null == countClass) { + return new ArrayList<>(); + } + return countClass; + } + + public void setCountClass(List countClass) { + this.countClass = countClass; + } + + public static BigDataResult2 getInstance() { + return new BigDataResult2(); + } + + 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); + } + + public static class CountClass { + private String dateTime; + private Integer bossCount; + private Integer zgyCount; + + public CountClass(String dateTime, Integer bossCount, Integer zgyCount) { + this.dateTime = dateTime; + this.bossCount = bossCount; + this.zgyCount = zgyCount; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } + + public Integer getBossCount() { + return bossCount; + } + + public void setBossCount(Integer bossCount) { + this.bossCount = bossCount; + } + + public Integer getZgyCount() { + return zgyCount; + } + + public void setZgyCount(Integer zgyCount) { + this.zgyCount = zgyCount; + } + } +} \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/communityboss/communityboss-mapper.xml b/src/main/resources/mybatis/mapper/communityboss/communityboss-mapper.xml index 4b6e9c4..05e7c1e 100755 --- a/src/main/resources/mybatis/mapper/communityboss/communityboss-mapper.xml +++ b/src/main/resources/mybatis/mapper/communityboss/communityboss-mapper.xml @@ -71,6 +71,10 @@ + + + + INSERT INTO city_community_boss( @@ -703,4 +707,8 @@ DELETE FROM city_community_boss_community where community_boss_id = #{communityBossId} + + \ 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 3fa96c8..6efc33a 100755 --- a/src/main/resources/mybatis/mapper/reportcase/reportcase-mapper.xml +++ b/src/main/resources/mybatis/mapper/reportcase/reportcase-mapper.xml @@ -2301,12 +2301,40 @@ WHERE creator ]]> '1' AND is_delete = 0 + + AND LEFT(gmt_create, 7) = #{time} + AND case_id IN #{caseIds[${index}]} + + AND creator IN + + #{bossIds[${index}]} + + + + + CREATE TEMPORARY TABLE temp_table (case_id VARCHAR(36)); + + + + INSERT INTO temp_table (case_id) VALUES + + (#{caseId}) + + + + + + DROP TEMPORARY TABLE temp_table + \ No newline at end of file