diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java index 8ef978f3c3..b61f2fefb1 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java @@ -1,29 +1,38 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ package com.epmet.commons.mybatis.config; import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.epmet.commons.mybatis.interceptor.DataFilterInterceptor; +import com.epmet.commons.tools.redis.RedisUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; +import java.util.Random; + /** * mybatis-plus配置 * * @author Mark sunlightcs@gmail.com * @since 1.0.0 */ +@Slf4j @Configuration public class MybatisPlusConfig { + @Autowired + private RedisUtils redisUtils; /** * 配置数据权限 @@ -45,4 +54,18 @@ public class MybatisPlusConfig { return interceptor; } + /** + * id生成器指定2个参数 防止id重复 + */ + @Bean + @Order(0) + public DefaultIdentifierGenerator myIdentifierGenerator() { + Random random = new Random(); + int workerId = random.nextInt(30) + 1; + int dataCenterId = random.nextInt(30) + 1; + DefaultIdentifierGenerator interceptor = new DefaultIdentifierGenerator(workerId, dataCenterId); + log.info("workerId:{},dataCenterId:{}", workerId, dataCenterId); + return interceptor; + } + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java index 754cdf012d..9bc34d0a39 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java @@ -10,6 +10,8 @@ package com.epmet.commons.tools.utils; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import com.epmet.commons.tools.utils.excel.ExportMultiView; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -19,12 +21,8 @@ import org.springframework.util.CollectionUtils; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.io.OutputStream; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; +import java.util.*; /** * Excel工具类 @@ -121,8 +119,11 @@ public class ExcelUtils { out.flush(); out.close(); } - public static OutputStream getOutputStreamForExcel(String fileName, HttpServletResponse response) throws Exception { + public static ServletOutputStream getOutputStreamForExcel(String fileName, HttpServletResponse response) throws Exception { fileName = URLEncoder.encode(fileName, "UTF-8"); + if (!fileName.endsWith(".xls") ||!fileName.endsWith(".xlsx")){ + fileName = fileName + ".xlsx"; + } response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf8"); response.setHeader("Content-Disposition", "attachment;filename=" + fileName); @@ -131,4 +132,27 @@ public class ExcelUtils { return response.getOutputStream(); } + /** + * desc:easypoi导出多个sheet + * @param fileName + * @param list + * @param response + * @throws Exception + */ + public static void exportMultiSheetExcel(String fileName, List list, HttpServletResponse response) throws Exception { + List> excel = new ArrayList<>(); + for(ExportMultiView view :list){ + Map sheet = new HashMap<>(); + sheet.put("title",view.getExportParams()); + sheet.put("entity",view.getCls()); + sheet.put("data", view.getDataList()); + excel.add(sheet); + } + Workbook workbook = ExcelExportUtil.exportExcel(excel, ExcelType.XSSF); + ServletOutputStream outputStream = ExcelUtils.getOutputStreamForExcel(fileName, response); + workbook.write(outputStream); + outputStream.flush(); + outputStream.close(); + } + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java new file mode 100644 index 0000000000..ff69b2c4b0 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java @@ -0,0 +1,32 @@ +package com.epmet.commons.tools.utils.excel; + +import cn.afterturn.easypoi.excel.entity.ExportParams; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * desc:easypoi 导出多个sheet + * + * @author: LiuJanJun + * @date: 2022/3/29 1:13 下午 + * @version: 1.0 + */ +@Data +@AllArgsConstructor +public class ExportMultiView { + /** + * 导出的参数 比如设置表头 + */ + private ExportParams exportParams; + /** + * 要导出的数据列 + */ + private List dataList; + /** + * excel对应的类 + */ + private Class cls; + +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java index e707ef6d6c..3b8b737a37 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java @@ -64,4 +64,9 @@ public class CustomerDataManageFormDTO implements Serializable { private String sourceType; //数据类型【组织agency 网格grid】 private String dataType; + + /** + * desc:是否是导出 + */ + private boolean export; } diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java index f293af93d0..8ea839f03f 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java @@ -14,6 +14,7 @@ import java.util.List; public class CustomerDataManageResultDTO { List list = new ArrayList<>(); + List allGridList = new ArrayList<>(); private Integer total; @Data diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java index 02c5c9cbc8..76adaddc40 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java @@ -3,6 +3,7 @@ package com.epmet.dataaggre.dto.evaluationindex; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; /** @@ -16,6 +17,10 @@ public class ScreenAgencyOrGridListDTO implements Serializable { private String level; //直属下级组织或网格集合 private List agencyGridList; + /** + * 所有下级网格列表 + */ + private List allGridList = new ArrayList<>(); @Data public static class AgencyGrid { diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java index e57fd42ac5..fc22bd2fb4 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java @@ -20,7 +20,6 @@ package com.epmet.dataaggre.dto.evaluationindex; import lombok.Data; import java.io.Serializable; -import java.util.Date; /** @@ -54,66 +53,5 @@ public class ScreenCustomerGridDTO implements Serializable { */ private String gridName; - /** - * 网格所属组织id - */ - private String parentAgencyId; - - /** - * 坐标区域 - */ - private String areaMarks; - - /** - * 中心点位 - */ - private String centerMark; - - /** - * 党支部(=网格)的位置 - */ - private String partyMark; - - /** - * 删除标识 0.未删除 1.已删除 - */ - private Integer delFlag; - - /** - * 乐观锁 - */ - private Integer revision; - - /** - * 创建人 - */ - private String createdBy; - - /** - * 创建时间 - */ - private Date createdTime; - - /** - * 更新人 - */ - private String updatedBy; - - /** - * 更新时间 - */ - private Date updatedTime; - - /** - * 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增) - */ - private String dataEndTime; - - /** - * 所有上级ID,用英文逗号分开 - */ - private String allParentIds; - private String pid; - private String pids; -} \ No newline at end of file +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govproject/result/CategoryProjectResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govproject/result/CategoryProjectResultDTO.java index 5386febe19..8dc9102b84 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govproject/result/CategoryProjectResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govproject/result/CategoryProjectResultDTO.java @@ -54,6 +54,8 @@ public class CategoryProjectResultDTO implements Serializable { //二级分类code @JsonIgnore private String categoryCode; + + private String topicId; } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java index 9e1929056d..a4d88b3a91 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java @@ -1,21 +1,20 @@ package com.epmet.dataaggre.controller; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dataaggre.dto.datastats.form.*; import com.epmet.dataaggre.dto.datastats.result.*; -import com.epmet.dataaggre.excel.CustomerDataManageExcel; import com.epmet.dataaggre.service.datastats.DataStatsService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; import java.text.ParseException; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * @Author sun @@ -228,6 +227,7 @@ public class DataStatsController { @PostMapping("operateexport") public void CustomerDataManage(@RequestBody CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception { ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class); + formDTO.setExport(true); dataStatsService.CustomerDataManage(formDTO,response); } @@ -239,6 +239,7 @@ public class DataStatsController { @PostMapping("operatedata") public Result operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException { ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class); + formDTO.setExport(false); return new Result().ok(dataStatsService.operateExport(formDTO)); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java index da7f97b6bf..ab22fe402c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java @@ -32,7 +32,7 @@ import java.util.List; /** * @Author sun - * @Description 指标统计服务 + * @Description 指标统计服务 */ @Mapper public interface EvaluationIndexDao { @@ -64,20 +64,22 @@ public interface EvaluationIndexDao { /** * 根据组织Id查询治理指数 - * @author zhaoqifeng - * @date 2021/6/25 16:36 + * * @param agencyIds * @param dateId * @return java.util.List + * @author zhaoqifeng + * @date 2021/6/25 16:36 */ ScreenGovernRankDataDailyDTO getGovernRankList(@Param("agencyIds") List agencyIds, @Param("dateId") String dateId); /** * 获取组织信息 - * @author zhaoqifeng - * @date 2021/6/29 13:58 + * * @param agencyId * @return com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO + * @author zhaoqifeng + * @date 2021/6/29 13:58 */ ScreenCustomerAgencyDTO getAgencyInfo(@Param("agencyId") String agencyId); @@ -100,12 +102,12 @@ public interface EvaluationIndexDao { List getSubAgencyListByAgency(@Param("agencyId") String agencyId, @Param("areaCode") String areaCode, @Param("list") List list); /** - * @Description 根据组织ID查询组织名 + * @Description 根据组织ID查询组织名 * @Param agencyId * @author zxc * @date 2021/9/10 3:54 下午 */ - String selectAgencyNameByAgencyId(@Param("agencyId")String agencyId); + String selectAgencyNameByAgencyId(@Param("agencyId") String agencyId); /** * @Description 按dateId查询组织下一级分类项目总数统计 @@ -118,4 +120,12 @@ public interface EvaluationIndexDao { * @author sun */ List getGridProejctToProjectMain(GridLivelyFormDTO formDTO); -} \ No newline at end of file + + /** + * desc:根据组织全路径 获取所有网格 + * + * @param fullAgencyPath + * @return + */ + List getSubAllGridByAgencyPath(@Param("fullAgencyPath") String fullAgencyPath); +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govissue/IssueDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govissue/IssueDao.java index 17d16fd72d..39b9184284 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govissue/IssueDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govissue/IssueDao.java @@ -39,15 +39,15 @@ import java.util.List; public interface IssueDao extends BaseDao { /** - * @Description 查询议题【表决中、已关闭】 + * @Description 查询议题【表决中、已关闭】 * @Param gridIds * @author zxc * @date 2020/12/25 下午2:19 */ - List issueStatusClosedOrVoting(@Param("gridIds") List gridIds, @Param("issueStatus")String issueStatus); + List issueStatusClosedOrVoting(@Param("gridIds") List gridIds, @Param("issueStatus") String issueStatus); /** - * @Description 查询已转项目议题 + * @Description 查询已转项目议题 * @Param gridIds * @author zxc * @date 2020/12/25 下午5:27 @@ -72,7 +72,7 @@ public interface IssueDao extends BaseDao { **/ List selectClosedListGov(ClosedIssueListFormDTO fromDTO); - Integer selectIssueCount(@Param("gridIds") List gridIds,@Param("issueType")String issueType); + Integer selectIssueCount(@Param("gridIds") List gridIds, @Param("issueType") String issueType); List selectShiftProjectIssueList(@Param("customerId") String customerId, @Param("gridId") String gridId); @@ -81,4 +81,12 @@ public interface IssueDao extends BaseDao { * @author sun **/ List getCategoryList(@Param("customerId") String customerId, @Param("level") String level, @Param("isDisable") String isDisable); -} \ No newline at end of file + + /** + * desc:根据议题id获取对应的话题id + * + * @param ids + * @return + */ + List selectIssueTopicIdType(@Param("ids") List ids); +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java index 65f55557fe..80cbe66693 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java @@ -5,49 +5,49 @@ import lombok.Data; /** * @Author zxc - * @DateTime 2021/9/10 10:15 上午 + * @DateTime 2021/9/10 10:10 上午 * @DESC */ @Data public class CustomerDataManageExcel { - @Excel(name = "组织") + @Excel(name = "组织",width = 25) private String orgName; - @Excel(name = "用户数") + @Excel(name = "用户数",width = 10) private Integer userCount; - @Excel(name = "居民数") + @Excel(name = "居民数",width = 10) private Integer residentCount; - @Excel(name = "党员数") + @Excel(name = "党员数",width = 10) private Integer partyMemberCount; - @Excel(name = "小组数") + @Excel(name = "小组数",width = 10) private Integer groupCount; - @Excel(name = "话题数") + @Excel(name = "话题数",width = 10) private Integer topicCount; - @Excel(name = "议题数") + @Excel(name = "议题数",width = 10) private Integer issueCount; - @Excel(name = "项目数") + @Excel(name = "项目数",width = 10) private Integer projectCount; - @Excel(name = "结案项目数") + @Excel(name = "结案项目数",width = 12) private Integer closedProjectCount; - @Excel(name = "巡查人数") + @Excel(name = "巡查人数",width = 10) private Integer patrolPeopleCount; - @Excel(name = "巡查次数") + @Excel(name = "巡查次数",width = 10) private Integer patrolCount; - @Excel(name = "巡查时长") + @Excel(name = "巡查时长",width = 15) private String patrolDuration; - @Excel(name = "例行工作次数") + @Excel(name = "例行工作次数",width = 15) private Integer patrolRoutineWorkTimes; /** diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index fbf54c353c..e55db49a65 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1,61 +1,63 @@ package com.epmet.dataaggre.service.datastats.impl; - import com.alibaba.fastjson.JSON; - import com.epmet.commons.dynamic.datasource.annotation.DataSource; - import com.epmet.commons.tools.constant.NumConstant; - import com.epmet.commons.tools.enums.OrgLevelEnum; - import com.epmet.commons.tools.enums.OrgTypeEnum; - import com.epmet.commons.tools.exception.RenException; - import com.epmet.commons.tools.feign.ResultDataResolver; - import com.epmet.commons.tools.utils.ConvertUtils; - import com.epmet.commons.tools.utils.DateUtils; - import com.epmet.commons.tools.utils.ExcelUtils; - import com.epmet.dataaggre.constant.DataSourceConstant; - import com.epmet.dataaggre.constant.OrgConstant; - import com.epmet.dataaggre.dao.datastats.DataStatsDao; - import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; - import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; - import com.epmet.dataaggre.dto.datastats.form.*; - import com.epmet.dataaggre.dto.datastats.result.*; - import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO; - import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO; - import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; - import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; - import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; - import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; - import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; - import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; - import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; - import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO; - import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; - import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO; - import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; - import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; - import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; - import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; - import com.epmet.dataaggre.excel.CustomerDataManageExcel; - import com.epmet.dataaggre.service.datastats.DataStatsService; - import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; - import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; - import com.epmet.dataaggre.service.govorg.GovOrgService; - import com.epmet.dataaggre.service.opercrm.CustomerRelation; - import com.github.pagehelper.PageHelper; - import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.CollectionUtils; - import org.apache.commons.lang3.StringUtils; - import org.springframework.beans.factory.annotation.Autowired; - import org.springframework.stereotype.Service; - - import javax.servlet.http.HttpServletResponse; - import java.math.BigDecimal; - import java.math.RoundingMode; - import java.text.NumberFormat; - import java.text.ParseException; - import java.text.SimpleDateFormat; - import java.util.*; - import java.util.concurrent.atomic.AtomicInteger; - import java.util.concurrent.atomic.AtomicReference; - import java.util.stream.Collectors; + import cn.afterturn.easypoi.excel.entity.ExportParams; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.enums.OrgLevelEnum; +import com.epmet.commons.tools.enums.OrgTypeEnum; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.excel.ExportMultiView; +import com.epmet.dataaggre.constant.DataSourceConstant; +import com.epmet.dataaggre.constant.OrgConstant; +import com.epmet.dataaggre.dao.datastats.DataStatsDao; +import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; +import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; +import com.epmet.dataaggre.dto.datastats.form.*; +import com.epmet.dataaggre.dto.datastats.result.*; +import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO; +import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO; +import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; +import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; +import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; +import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; +import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; +import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO; +import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; +import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO; +import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; +import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; +import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; +import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; +import com.epmet.dataaggre.excel.CustomerDataManageExcel; +import com.epmet.dataaggre.service.datastats.DataStatsService; +import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; +import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; +import com.epmet.dataaggre.service.govorg.GovOrgService; +import com.epmet.dataaggre.service.opercrm.CustomerRelation; +import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.NumberFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; /** * @Author sun @@ -1878,7 +1880,28 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve @Override public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception { String openTime = formDTO.getStartTime(); - List result = operateExport(formDTO).getList(); + CustomerDataManageResultDTO operateExport = operateExport(formDTO); + List result = operateExport.getList(); + setTotal(result); + formDTO.setStartTime(openTime); + String fileName = excelName(formDTO); + + ExportParams exportParams = new ExportParams(fileName,fileName); + List exportList = new ArrayList<>(); + List excelList = ConvertUtils.sourceToTarget(result, CustomerDataManageExcel.class); + exportList.add(new ExportMultiView(exportParams,excelList,CustomerDataManageExcel.class)); + if (CollectionUtils.isNotEmpty(operateExport.getAllGridList())){ + List gridResult = operateExport.getAllGridList(); + setTotal(gridResult); + ExportParams exportParams2 = new ExportParams(fileName,"网格数据"); + List excelList2 = ConvertUtils.sourceToTarget(gridResult, CustomerDataManageExcel.class); + exportList.add(new ExportMultiView(exportParams2,excelList2,CustomerDataManageExcel.class)); + } + ExcelUtils.exportMultiSheetExcel(fileName, exportList, response); + + } + + public void setTotal(List result) { if (!CollectionUtils.isEmpty(result)){ CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage(); c.setOrgName("合计"); @@ -1897,9 +1920,6 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve c.setPatrolDuration(getHm(c.getPatrolDurationInteger())); result.add(c); } - formDTO.setStartTime(openTime); - String fileName = excelName(formDTO); - ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class); } /** @@ -1958,8 +1978,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve */ @Override public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { - CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO(); - List dataManageList = new ArrayList<>(); + //1.必要参数校验及处理 String startTimeForm = formDTO.getStartTime(); if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(startTimeForm)) { @@ -1974,7 +1993,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } //2.查询组织信息,判断查询下级组织还是网格数据 - ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId()); + ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId(), formDTO.isExport()); if (null == agencyGrid) { return new CustomerDataManageResultDTO(); } @@ -1982,7 +2001,23 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve List idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode()); formDTO.setIdList(idList); + //获取组织级别数据 + CustomerDataManageResultDTO resultDTO = getDataManageResultDTO(formDTO, startTimeForm, agencyGrid.getAgencyGridList(),agencyGrid.getLevel()); resultDTO.setTotal(idList.size()); + //网格List不为空则 查询网格数据 (仅限查询组织id为街道级别时) + if (CollectionUtils.isNotEmpty(agencyGrid.getAllGridList())){ + formDTO.setDataType(OrgTypeEnum.GRID.getCode()); + idList = agencyGrid.getAllGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); + formDTO.setIdList(idList); + CustomerDataManageResultDTO allGridData = getDataManageResultDTO(formDTO, startTimeForm, agencyGrid.getAllGridList(),agencyGrid.getLevel()); + resultDTO.setAllGridList(allGridData.getList()); + } + return resultDTO; + } + + public CustomerDataManageResultDTO getDataManageResultDTO(CustomerDataManageFormDTO formDTO, String startTimeForm, List agencyGridList,String orgLevel) { + CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO(); + List dataManageList = new ArrayList<>(); //3.查询截止日期用户、群组、话题、议题、项目、巡查数据 formDTO.setSourceType("end"); @@ -2029,7 +2064,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve } //5.封装数据 - for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGrid.getAgencyGridList()) { + for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGridList) { CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); dto.setOrgId(org.getOrgId()); dto.setOrgName(org.getOrgName()); @@ -2083,12 +2118,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve int patrolDurationInteger = NumConstant.ZERO; HashSet set = new HashSet(); for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { - if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) { + if (OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && org.getOrgId().equals(u.getOrgId())) { patroCount += u.getPatrolCount(); patrolDurationInteger += u.getPatrolDurationInteger(); set.add(u.getStaffId()); } - if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) { + if (!OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && u.getOrgId().contains(org.getOrgId())) { patroCount += u.getPatrolCount(); patrolDurationInteger += u.getPatrolDurationInteger(); set.add(u.getStaffId()); @@ -2099,10 +2134,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve int patrolRoutineWorkTimes = NumConstant.ZERO; if (CollectionUtils.isNotEmpty(workCountList) && workCountList.get(NumConstant.ZERO) != null) { for (CustomerDataManageResultDTO.CustomerDataManage work : workCountList) { - if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(work.getOrgId())) { + if (OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && org.getOrgId().equals(work.getOrgId())) { patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); set.add(work.getStaffId()); - } else if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && work.getOrgId().contains(org.getOrgId())) { + } else if (!OrgLevelEnum.COMMUNITY.getCode().equals(orgLevel) && work.getOrgId().contains(org.getOrgId())) { patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes(); set.add(work.getStaffId()); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java index 381b6f9625..a5260a60ba 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java @@ -44,6 +44,8 @@ public interface EvaluationIndexService { */ List getSubGridList(String agencyId); + List getSubAllGridByAgencyPath(String fullAgencyPath); + /** * 根据组织ID获取治理指数 * @author zhaoqifeng @@ -88,7 +90,7 @@ public interface EvaluationIndexService { * @Description 根据组织Id判断查询直属下级组织/网格列表,组织存在子客户的查询包含子客户组织数据 * @author sun */ - ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId); + ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId, Boolean isGetSubAllGrid); /** * @Description 按dateId查询组织下一级分类项目总数统计 diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java index 3e8f60d6a9..7fa4518b2d 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java @@ -1,8 +1,8 @@ package com.epmet.dataaggre.service.evaluationindex.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.enums.OrgLevelEnum; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.evaluationindex.EvaluationIndexDao; import com.epmet.dataaggre.dto.datastats.form.GovrnRatioFormDTO; @@ -75,6 +75,15 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { return evaluationIndexDao.getSubGridList(agencyId); } + /** + * @Description 查询所有下级网格 + * @author sun + */ + @Override + public List getSubAllGridByAgencyPath(String fullAgencyPath) { + return evaluationIndexDao.getSubAllGridByAgencyPath(fullAgencyPath); + } + /** * 根据组织ID获取治理指数 * @@ -165,7 +174,7 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { * @author sun */ @Override - public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId) { + public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId, Boolean isGetSubAllGrid) { ScreenAgencyOrGridListDTO resultDTO = new ScreenAgencyOrGridListDTO(); List agencyGridList = new ArrayList<>(); //1.查询组织信息 @@ -177,12 +186,23 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { //2.根据组织级别判断查询直属组织或网格列表 List agencyList = new ArrayList<>(); List gridList = new ArrayList<>(); - List finalAgencyGridList = agencyGridList; + //孔村和组织级别为街道的查询下级所有网格 + if (isGetSubAllGrid && (OrgLevelEnum.STREET.getCode().equals(dto.getLevel()) || "1234085031077498881".equals(agencyId))){ + gridList = evaluationIndexDao.getSubAllGridByAgencyPath(dto.getAgencyId()); + List allGridList = new ArrayList<>(); + gridList.forEach(gr->{ + ScreenAgencyOrGridListDTO.AgencyGrid org = new ScreenAgencyOrGridListDTO.AgencyGrid(); + org.setOrgId(gr.getGridId()); + org.setOrgName(gr.getGridName()); + allGridList.add(org); + }); + resultDTO.setAllGridList(allGridList); + } if (!"community".equals(dto.getLevel())) { //2-1.直属下级组织列表 //2.判断客户是否存在子客户 List list = customerRelation.haveSubCustomer(dto.getCustomerId()); - if (!CollectionUtils.isNotEmpty(list)) { + if (CollectionUtils.isEmpty(list)) { agencyList = evaluationIndexDao.getSubAgencyListByAgency(agencyId, null, null); } else { list.add(dto.getCustomerId()); @@ -192,7 +212,7 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { ScreenAgencyOrGridListDTO.AgencyGrid org = new ScreenAgencyOrGridListDTO.AgencyGrid(); org.setOrgId(gr.getAgencyId()); org.setOrgName(gr.getAgencyName()); - finalAgencyGridList.add(org); + agencyGridList.add(org); }); } else { //2-2.直属下级网格列表 @@ -201,7 +221,7 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService { ScreenAgencyOrGridListDTO.AgencyGrid org = new ScreenAgencyOrGridListDTO.AgencyGrid(); org.setOrgId(gr.getGridId()); org.setOrgName(gr.getGridName()); - finalAgencyGridList.add(org); + agencyGridList.add(org); }); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/GovIssueService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/GovIssueService.java index 3e87ea18d3..93001af72b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/GovIssueService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/GovIssueService.java @@ -52,4 +52,11 @@ public interface GovIssueService { * @author sun **/ List categoryList(String customerId, String level, String isDisable); + + /** + * desc:根据id 获取议题的话题的话题Id + * @param collect + * @return + */ + List selectIssueTopicIdType(List collect); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/impl/GovIssueServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/impl/GovIssueServiceImpl.java index 5556d2d3f0..761adb17b2 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/impl/GovIssueServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/impl/GovIssueServiceImpl.java @@ -333,4 +333,13 @@ public class GovIssueServiceImpl implements GovIssueService { return issueDao.getCategoryList(customerId, level, isDisable); } + @Override + public List selectIssueTopicIdType(List ids) { + List dtoList = issueDao.selectIssueTopicIdType(ids); + if (CollectionUtils.isEmpty(dtoList)){ + return new ArrayList<>(); + } + return dtoList; + } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java index 114e4caa75..8aa052b52e 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java @@ -13,6 +13,7 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; @@ -79,6 +80,8 @@ public class GovProjectServiceImpl implements GovProjectService { private EvaluationIndexService evaluationIndexService; @Autowired private EpmetUserService epmetUserService; + @Autowired + private LoginUserUtil loginUserUtil; /** * @Description 查询项目信息 @@ -414,13 +417,13 @@ public class GovProjectServiceImpl implements GovProjectService { formDTO.setToDateId(DateUtils.dateOrmonthId(formDTO.getDateId(), "date", 1)); //1.查询客户下分类信息 List categoryList = govIssueService.categoryList(formDTO.getCustomerId(), null, null); - List categoreCodeList = categoryList.stream().filter(ca -> ca.getParentCategoryCode().equals(formDTO.getCategoryCode())).map(m -> m.getCategoryCode()).collect(Collectors.toList()); + List categoreCodeList = categoryList.stream().filter(ca -> ca.getParentCategoryCode().equals(formDTO.getCategoryCode())).map(IssueProjectCategoryDictDTO::getCategoryCode).collect(Collectors.toList()); formDTO.setCategoreCodeList(categoreCodeList); //2.查询组织及下级截止某一天的某个一级分类下的项目列表 PageInfo result = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> projectDao.categoryProjectList(formDTO)); - if (org.springframework.util.CollectionUtils.isEmpty(result.getList())) { + if (CollectionUtils.isEmpty(result.getList())) { return resultDTO; } resultDTO.setTotal((int) result.getTotal()); @@ -430,7 +433,7 @@ public class GovProjectServiceImpl implements GovProjectService { List list = projectDao.getCategoryList(projectIds); //4.查询来源事件的项目上报的组织信息 - List eventIds = result.getList().stream().filter(re -> "resi_event".equals(re.getOrigin())).map(m -> m.getOriginId()).collect(Collectors.toList()); + List eventIds = result.getList().stream().filter(re -> "resi_event".equals(re.getOrigin())).map(CategoryProjectResultDTO.Project::getOriginId).collect(Collectors.toList()); List eventOrgList = projectDao.getEventOrgList(eventIds); Map eventMap = eventOrgList.stream().collect(Collectors.toMap(ResiEventReportOrgDTO::getResiEventId, Function.identity())); @@ -438,11 +441,19 @@ public class GovProjectServiceImpl implements GovProjectService { List eventUser = projectDao.getEventList(projectIds); List topicUser = projectDao.getTopicUser(projectIds); + //市北客户查询 下议题区分下来源 设置topicId + Map issueTopicSourceMap = new HashMap<>(); + if (CustomerIdConstant.SHI_BEI_CUSTOMER_ID.equals(loginUserUtil.getLoginUserCustomerId())){ + issueTopicSourceMap = govIssueService.selectIssueTopicIdType(result.getList().stream() + .filter(re -> "issue".equals(re.getOrigin())) + .map(CategoryProjectResultDTO.Project::getOriginId) + .collect(Collectors.toList())).stream().collect(Collectors.toMap(IssueInfoDTO::getIssueId,IssueInfoDTO::getTopicId)); + } + //5.封装数据 //组织或网格id->组织或网格名称 Map map = new HashMap<>(); - result.getList().forEach(re -> { - //所属组织 + for (CategoryProjectResultDTO.Project re : result.getList()) {//所属组织 if ("issue".equals(re.getOrigin())) { if (map.containsKey(re.getGridId())) { re.setOrgName(map.get(re.getGridId())); @@ -453,6 +464,9 @@ public class GovProjectServiceImpl implements GovProjectService { map.put(re.getGridId(), gridInfo.getGridName()); } } + //市北议题来源的设置话题Id + re.setTopicId(issueTopicSourceMap.get(re.getOriginId())); + } else if ("agency".equals(re.getOrigin())) { if (map.containsKey(re.getAgencyId())) { re.setOrgName(map.get(re.getAgencyId())); @@ -517,7 +531,7 @@ public class GovProjectServiceImpl implements GovProjectService { re.setUserId(to.getUserId()); } }); - }); + } resultDTO.setList(result.getList()); return resultDTO; diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml index 37f8d40bd6..70c5f2d7d6 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml @@ -118,7 +118,8 @@ agency_name AS agencyName, level AS level, area_code AS areaCode, - parent_area_code AS parentAreaCode + parent_area_code AS parentAreaCode, + pids pids FROM screen_customer_agency WHERE @@ -164,6 +165,11 @@ AND parent_area_code = #{areaCode} + + + AND PIDS like concat(#{agencyId},'%') + AND LEVEL = 'community' + AND pid = #{agencyId} @@ -211,5 +217,23 @@ AND all_parent_ids LIKE CONCAT('%', #{agencyId}, '%') GROUP BY org_id, DATE_FORMAT(project_create_time, "%Y%m%d") + diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govissue/IssueDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govissue/IssueDao.xml index 90ecda4b20..495473205c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govissue/IssueDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govissue/IssueDao.xml @@ -139,5 +139,20 @@ ORDER BY category_code + - \ No newline at end of file + diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java index 0c27cbc878..cf4e4359c4 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java @@ -561,6 +561,8 @@ public class AgencyServiceImpl implements AgencyService { return nodes.get(0); } + + private void convertOrgTreeNode(List nodeList, ScreenCustomerAgencyDTO currentAgency) { OrgTreeNode orgTreeNode = ConvertUtils.sourceToTarget(currentAgency, OrgTreeNode.class); orgTreeNode.setOrgId(currentAgency.getAgencyId()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java index 466774ecc5..efc03d5e79 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java @@ -39,15 +39,15 @@ public class ScreenExtractDailyController { */ @PostMapping("extractdailyall") public Result screenExtractDaily(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { - executorService.submit(() -> { - log.info("screenExtractDaily start,param:{}", JSON.toJSONString(extractOriginFormDTO)); - try { - screenExtractService.extractDailyAll(extractOriginFormDTO); - log.info("screenExtractDaily end"); - } catch (Exception e) { - log.error("screenExtractDaily exception", e); - } - }); + + log.info("screenExtractDaily start,param:{}", JSON.toJSONString(extractOriginFormDTO)); + try { + screenExtractService.extractDailyAll(extractOriginFormDTO); + log.info("screenExtractDaily end"); + } catch (Exception e) { + log.error("screenExtractDaily exception", e); + } + return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java index e3ed39133b..b3217ceef5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java @@ -342,7 +342,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } log.info("===== extractDaily method end customerId:{}======",customerId); } catch (Exception e) { - log.error("extractDaily exception msg:{}", e); + log.error("extractDaily exception msg", e); } finally { distributedLock.unLock(lock); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java index 0ae964e3ee..db975af203 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java @@ -306,7 +306,7 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl getProjectList(String customerId, List projectId, Integer pageNo, Integer pageSize) { - PageHelper.startPage(pageNo, pageSize); + PageHelper.startPage(pageNo, pageSize, false); return baseDao.selectProjectList(customerId, projectId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java index 0752b72424..3bc6b5969d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DataReportingServiceImpl.java @@ -137,11 +137,14 @@ public class DataReportingServiceImpl implements DataReportingService { public List getEventInfo(EventInfoFormDTO formDTO) { List list; //根据入参,获取项目 + long start = System.currentTimeMillis(); List projectList = screenProjectDataService.getProjectList(formDTO.getCustomerId(), formDTO.getProjectId(), formDTO.getPageNo(), formDTO.getPageSize()); + log.error("事件上报-查询项目列表耗时:{}ms",System.currentTimeMillis()-start); //项目列表为空,返回空数组 if(CollectionUtils.isEmpty(projectList)) { return Collections.emptyList(); } + start = System.currentTimeMillis(); Map epmetCodeMap = new HashMap<>(); Result parentCustomer = operCrmOpenFeignClient.getExternalAndParentCustomerId(formDTO.getCustomerId()); if (StringUtils.isNotBlank(parentCustomer.getData())) { @@ -194,6 +197,7 @@ public class DataReportingServiceImpl implements DataReportingService { return dto; }).collect(Collectors.toList()); } + log.error("事件上报-组装数据耗时:{}ms",System.currentTimeMillis()-start); return list.stream().collect(collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(EventInfoResultDTO::getId))), ArrayList::new)); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml index b159668ec9..530c216a2d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml @@ -28,6 +28,7 @@ spring: url: @datasource.druid.stats.url@ username: @datasource.druid.stats.username@ password: @datasource.druid.stats.password@ + max-active: 100 cloud: nacos: discovery: @@ -173,6 +174,7 @@ dynamic: url: @datasource.druid.evaluationIndex.url@ username: @datasource.druid.evaluationIndex.username@ password: @datasource.druid.evaluationIndex.password@ + max-active: 100 partyMember: driver-class-name: com.mysql.cj.jdbc.Driver url: @datasource.druid.partyMember.url@ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java index 1d4419e661..510fe28f3b 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/ImportGeneralDTO.java @@ -68,7 +68,7 @@ public class ImportGeneralDTO implements Serializable { /** * 单元号、ID */ - private Integer buildingUnit; + private String buildingUnit; private String buildingUnitId; /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java index 5d2a444f90..792192c7d7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java @@ -13,6 +13,9 @@ import org.hibernate.validator.constraints.Length; @Data public class HouseErrorInfoModel { + @Excel(name = "行号(不计算表头)", width = 20) + private Integer num; + @Excel(name = "所属小区", width = 20) private String neighborHoodName; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java index 9330a1a2d0..be716f7c94 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseInfoModel.java @@ -1,5 +1,6 @@ package com.epmet.model; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -26,7 +27,7 @@ public class HouseInfoModel { private String buildingName; @ExcelProperty(value = "单元号") - private Integer buildingUnit; + private String buildingUnit; @ExcelProperty(value = "门牌号") private String doorName; @@ -49,4 +50,7 @@ public class HouseInfoModel { @ExcelProperty(value = "房主身份证") private String ownerIdCard; + @ExcelIgnore + private Integer num; + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java index ffc6a950c6..4cd6ae33d6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java @@ -67,7 +67,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener buildingIdSet = new ConcurrentHashSet<>(); +// private Set buildingIdSet = new ConcurrentHashSet<>(); private ImportInfoFormDTO formDTO; private IcBuildingDao icBuildingDao; @@ -96,6 +96,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener houseNum = icBuildingDao.selectHouseNum(buildingIdSet); if (!CollectionUtils.isEmpty(houseNum)){ icBuildingDao.allUpdateHouseNum(houseNum); } buildingIdSet = null; - } + }*/ // 删除缓存 icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); @@ -582,7 +587,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener houses){ if (!CollectionUtils.isEmpty(houses)){ icHouseService.insertBatch(ConvertUtils.sourceToTarget(houses, IcHouseEntity.class)); - buildingIdSet.addAll(houses.stream().map(ImportGeneralDTO::getBuildingId).collect(Collectors.toSet())); +// buildingIdSet.addAll(houses.stream().map(ImportGeneralDTO::getBuildingId).collect(Collectors.toSet())); } } @@ -590,7 +595,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener houses){ if (!CollectionUtils.isEmpty(houses)){ icHouseService.houseUpdate(houses); - buildingIdSet.addAll(houses.stream().map(ImportGeneralDTO::getBuildingId).collect(Collectors.toSet())); +// buildingIdSet.addAll(houses.stream().map(ImportGeneralDTO::getBuildingId).collect(Collectors.toSet())); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java index 3b8409c0cd..ae1fd471a9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcBuildingUnitServiceImpl.java @@ -148,7 +148,7 @@ public class IcBuildingUnitServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(IcBuildingUnitEntity::getBuildingId, buildingId); - wrapper.eq(IcBuildingUnitEntity::getUnitNum, unitName); + wrapper.eq(IcBuildingUnitEntity::getUnitName, unitName); IcBuildingUnitEntity entity = baseDao.selectOne(wrapper); return ConvertUtils.sourceToTarget(entity, IcBuildingUnitDTO.class); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 331552e4a3..791f2beb4e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -526,7 +526,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl SELECT u.ID AS buildingUnitId, - u.UNIT_NUM AS buildingUnit, + u.UNIT_NAME AS buildingUnit, u.BUILDING_ID,b.NEIGHBOR_HOOD_ID FROM ic_building_unit u INNER JOIN ic_building b ON (b.ID = u.BUILDING_ID AND b.DEL_FLAG = '0') diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java index a9c2b50e57..c2cd63b509 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java @@ -6,6 +6,8 @@ import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.RedisKeys; @@ -77,10 +79,6 @@ public class OpenDataPatrolChangeEventListener implements MessageListenerConcurr if (!StrConstant.PY_CUSTOMER.equals(msgObj.getCustomerId())) { return; } - if (msgObj == null) { - log.warn("consumeMessage msg body is blank"); - return; - } RLock lock = null; try { lock = distributedLock.getLock(String.format("lock:open_data_patrol:%s:%s",tags, msgObj.getObjectId()), @@ -104,6 +102,9 @@ public class OpenDataPatrolChangeEventListener implements MessageListenerConcurr log.error("错误的消息类型:{}", tags); } + if (aBoolean == null || !aBoolean){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"消费失败!"); + } } catch (RenException e) { // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java index 0716e24990..81ca02745e 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseDisputeProcessServiceImpl.java @@ -72,8 +72,10 @@ public class BaseDisputeProcessServiceImpl extends BaseServiceImpl> result = dataStatisticalOpenFeignClient.getEventInfo(formDTO); if (!result.success()) { + log.error("getEventinfo cost:{}ms",System.currentTimeMillis()-start); throw new RenException(result.getInternalMsg()); } Map deptMap = exDeptService.getDeptDTOMap(); diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java index 064b6c9219..c8a6b37881 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java @@ -71,12 +71,8 @@ public class UserPatrolRecordServiceImpl extends BaseServiceImpl data = record.getData(); if (CollectionUtils.isEmpty(data)) { - //数据已被删除了 - //暂时设置error 用于排错 - log.error("insertPatrolRecord获取巡查记录返回为空,param:{}", JSON.toJSONString(midPatrolFormDTO)); - int effectRow = baseDao.deleteById(patrolRecordForm.getId()); - log.warn("del effectRow:{}", effectRow); - throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode()); + //数据还未被插入 + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"获取巡查记录返回为空,param:"+ JSON.toJSONString(midPatrolFormDTO)); } List insertList = new ArrayList<>(); data.forEach(o-> insertList.add(buildEntity(o))); @@ -103,10 +99,7 @@ public class UserPatrolRecordServiceImpl extends BaseServiceImpl{ UserPatrolRecordEntity recordEntity = buildEntity(o); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 08930bbb75..c7e6bad9df 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -24,6 +24,7 @@ import com.alibaba.excel.write.metadata.fill.FillWrapper; import com.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; @@ -486,6 +487,15 @@ public class IcResiUserController implements ResultDataResolver { } catch (IOException e) { log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); } + + //推送MQ事件 + IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); + mqMsg.setCustomerId(EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID)); + //mqMsg.setIcResiUser(resiUserId); + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(SystemMessageType.IC_RESI_USER_ADD); + form.setContent(mqMsg); + epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); } }); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java index 8a1648fdb4..aca5ac654b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java @@ -172,7 +172,23 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { //根据buildingID,tableName he columnName获取名字 //限制条数 一栋楼内最多显示1000 即可 - PageHelper.startPage(NumConstant.ONE,NumConstant.ONE_THOUSAND,false).doSelectPage(()->{ + for (String s : buildingIdList) { + PageHelper.startPage(NumConstant.ONE,NumConstant.ONE_HUNDRED,false).doSelectPage(()->{ + List dtos = icStatsResiWarnDao.userWarnListDTO(customerId, Arrays.asList(s), icResiCategoryWarnConfigDTO.getTableName(), icResiCategoryWarnConfigDTO.getColumnName()); + if (!CollectionUtils.isEmpty(dtos)){ + Map> groupByBuild = dtos.stream().collect(Collectors.groupingBy(UserWarnNameListResultDTO::getBuildingId)); + result.forEach(item->{ + item.setConfigId(configId); + groupByBuild.forEach((k,v) -> { + if (item.getBuildingId().equals(k)){ + item.setUserList(v); + } + }); + }); + } + }); + } + /*PageHelper.startPage(NumConstant.ONE,NumConstant.ONE_THOUSAND,false).doSelectPage(()->{ List dtos = icStatsResiWarnDao.userWarnListDTO(customerId, buildingIdList, icResiCategoryWarnConfigDTO.getTableName(), icResiCategoryWarnConfigDTO.getColumnName()); if (!CollectionUtils.isEmpty(dtos)){ Map> groupByBuild = dtos.stream().collect(Collectors.groupingBy(UserWarnNameListResultDTO::getBuildingId)); @@ -185,7 +201,7 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService { }); }); } - }); + });*/ return mapResult; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 8854f92192..a808b172e7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -279,7 +279,8 @@ public class UserBadgeServiceImpl implements UserBadgeService { userBadgeDao.insertUserBadgeCertificateRecord(form); //TODO 站内信发送 String badgeName = badgeDao.selectBadgeName(form.getCustomerId(), form.getBadgeId()); - String msg = String.format(BadgeConstant.MESSAGE_CONTENT, userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()), badgeName); + String s = StringUtils.isBlank(userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict()) ? userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName() : userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()); + String msg = String.format(BadgeConstant.MESSAGE_CONTENT, s, badgeName); // 记录待审核id,和消息类型 sendMessage(BadgeConstant.AUTH_TITLE,msg,form.getGridId(),form.getUserId(),form.getCustomerId(), UserMessageTypeConstant.BADGE_AUTH_APPLY, diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/util/MySequence.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/util/MySequence.java new file mode 100644 index 0000000000..28475b916f --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/util/MySequence.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2011-2021, baomidou (jobob@qq.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.epmet.util; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.Assert; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.SystemClock; +import com.epmet.commons.tools.utils.HttpClientManager; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.logging.Log; +import org.apache.ibatis.logging.LogFactory; + +import java.lang.management.ManagementFactory; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.concurrent.ThreadLocalRandom; + +/** + * 分布式高效有序 ID 生产黑科技(sequence) + * + *

优化开源项目:https://gitee.com/yu120/sequence

+ * + * @author hubin + * @since 2016-08-18 + */ +@Slf4j +public class MySequence { + + private static final Log logger = LogFactory.getLog(MySequence.class); + /** + * 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动) + */ + private final long twepoch = 1288834974657L; + /** + * 机器标识位数 + */ + private final long workerIdBits = 5L; + private final long datacenterIdBits = 5L; + private final long maxWorkerId = -1L ^ (-1L << workerIdBits); + private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); + /** + * 毫秒内自增位 + */ + private final long sequenceBits = 12L; + private final long workerIdShift = sequenceBits; + private final long datacenterIdShift = sequenceBits + workerIdBits; + /** + * 时间戳左移动位 + */ + private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; + private final long sequenceMask = -1L ^ (-1L << sequenceBits); + + private final long workerId; + + /** + * 数据标识 ID 部分 + */ + private final long datacenterId; + /** + * 并发控制 + */ + private long sequence = 0L; + /** + * 上次生产 ID 时间戳 + */ + private long lastTimestamp = -1L; + + public MySequence() { + this.datacenterId = getDatacenterId(maxDatacenterId); + this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); + String msg = "MySequence datacenterId:" + this.datacenterId + ";workerId:" + this.workerId; + log.info(msg); + HttpClientManager.getInstance().sendAlarmMsg(msg); + } + + /** + * 有参构造器 + * + * @param workerId 工作机器 ID + * @param datacenterId 序列号 + */ + public MySequence(long workerId, long datacenterId) { + Assert.isFalse(workerId > maxWorkerId || workerId < 0, + String.format("MySequence worker Id can't be greater than %d or less than 0", maxWorkerId)); + Assert.isFalse(datacenterId > maxDatacenterId || datacenterId < 0, + String.format("MySequence datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); + this.workerId = workerId; + this.datacenterId = datacenterId; + } + + /** + * 获取 maxWorkerId + */ + protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { + StringBuilder mpid = new StringBuilder(); + mpid.append(datacenterId); + String name = ManagementFactory.getRuntimeMXBean().getName(); + String msg = "MySequence getMaxWorkerId name:" + name; + log.info(msg); + HttpClientManager.getInstance().sendAlarmMsg(msg); + if (StringUtils.isNotBlank(name)) { + /* + * GET jvmPid + */ + mpid.append(name.split(StringPool.AT)[0]); + } + /* + * MAC + PID 的 hashcode 获取16个低位 + */ + return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); + } + + /** + * 数据标识id部分 + */ + protected static long getDatacenterId(long maxDatacenterId) { + long id = 0L; + try { + InetAddress ip = InetAddress.getLocalHost(); + NetworkInterface network = NetworkInterface.getByInetAddress(ip); + String msg = "MySequence ip:" + JSON.toJSONString(ip) + ";network: " + JSON.toJSONString(network); + log.info(msg); + HttpClientManager.getInstance().sendAlarmMsg(msg); + if (network == null) { + id = 1L; + log.info("MySequen cenetwork ==null "); + } else { + byte[] mac = network.getHardwareAddress(); + if (null != mac) { + id = ((0x000000FF & (long) mac[mac.length - 2]) | (0x0000FF00 & (((long) mac[mac.length - 1]) << 8))) >> 6; + id = id % (maxDatacenterId + 1); + } + } + } catch (Exception e) { + logger.warn(" getDatacenterId: " + e.getMessage()); + } + return id; + } + + /** + * 获取下一个 ID + * + * @return 下一个 ID + */ + public synchronized long nextId() { + long timestamp = timeGen(); + //闰秒 + if (timestamp < lastTimestamp) { + long offset = lastTimestamp - timestamp; + if (offset <= 5) { + try { + wait(offset << 1); + timestamp = timeGen(); + if (timestamp < lastTimestamp) { + throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", offset)); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", offset)); + } + } + + if (lastTimestamp == timestamp) { + // 相同毫秒内,序列号自增 + sequence = (sequence + 1) & sequenceMask; + if (sequence == 0) { + // 同一毫秒的序列数已经达到最大 + timestamp = tilNextMillis(lastTimestamp); + } + } else { + // 不同毫秒内,序列号置为 1 - 3 随机数 + sequence = ThreadLocalRandom.current().nextLong(1, 3); + } + + lastTimestamp = timestamp; + + // 时间戳部分 | 数据中心部分 | 机器标识部分 | 序列号部分 + return ((timestamp - twepoch) << timestampLeftShift) + | (datacenterId << datacenterIdShift) + | (workerId << workerIdShift) + | sequence; + } + + protected long tilNextMillis(long lastTimestamp) { + long timestamp = timeGen(); + while (timestamp <= lastTimestamp) { + timestamp = timeGen(); + } + return timestamp; + } + + protected long timeGen() { + return SystemClock.now(); + } + +} + diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index 8636a8411e..a9ec2fcadb 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -106,6 +106,9 @@ mybatis-plus: field-strategy: NOT_NULL #驼峰下划线转换 column-underline: true + worker-id: ${random.int(1,31)} + datacenter-id: ${random.int(1,31)} + banner: false #原生配置 configuration: diff --git a/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java b/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java index 06d674a4e3..751a7b7be1 100644 --- a/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java +++ b/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java @@ -1,7 +1,10 @@ package com.epmet.epmetuser.test; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.dao.UserDao; import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.entity.UserEntity; import com.epmet.service.UserService; import org.junit.Test; import org.junit.runner.RunWith; @@ -15,11 +18,25 @@ public class UserControllerTest { @Autowired private UserService userService; + @Autowired + private UserDao userDao; @Test public void getLoginUserDetails() { LoginUserDetailsResultDTO loginUserDetails = userService.getLoginUserDetails(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP, "4aaab913d9f11d90a2cb4dd21b075259"); System.out.println(loginUserDetails); } + @Test + public void insertUser() { + UserEntity entity = new UserEntity(); + + entity.setCustomerId("test_ljj"); + String idStr = IdWorker.getIdStr(); + System.out.println(idStr); + + + //int insert = userDao.insert(entity); + //System.out.println(insert); + } }