Browse Source

导出运营数据 网格

dev
jianjun 3 years ago
parent
commit
7baca77d87
  1. 30
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java
  2. 23
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java
  3. 5
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java
  4. 1
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java
  5. 4
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java
  6. 64
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenCustomerGridDTO.java
  7. 11
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java
  8. 26
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/EvaluationIndexDao.java
  9. 28
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java
  10. 174
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  11. 4
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/EvaluationIndexService.java
  12. 25
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java
  13. 21
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml

30
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.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams; 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.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
@ -19,12 +21,8 @@ import org.springframework.util.CollectionUtils;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/** /**
* Excel工具类 * Excel工具类
@ -121,8 +119,11 @@ public class ExcelUtils {
out.flush(); out.flush();
out.close(); 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"); fileName = URLEncoder.encode(fileName, "UTF-8");
if (!fileName.endsWith(".xls") ||!fileName.endsWith(".xlsx")){
fileName = fileName + ".xlsx";
}
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf8"); response.setCharacterEncoding("utf8");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
@ -131,4 +132,21 @@ public class ExcelUtils {
return response.getOutputStream(); return response.getOutputStream();
} }
public static void exportMultiSheetExcel(String fileName, List<ExportMultiView> list, HttpServletResponse response) throws Exception {
List<Map<String,Object>> excel = new ArrayList<>();
for(ExportMultiView view :list){
Map<String,Object> sheet = new HashMap<>();
sheet.put("title",view.getExportParams());
sheet.put("entity",view.getCls());
List<?> dataList = view.getDataList();
sheet.put("data", dataList);
excel.add(sheet);
}
Workbook workbook = ExcelExportUtil.exportExcel(excel, ExcelType.XSSF);
ServletOutputStream outputStream = ExcelUtils.getOutputStreamForExcel(fileName, response);
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
}
} }

23
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java

@ -0,0 +1,23 @@
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;
private Class<?> cls;
}

5
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; private String sourceType;
//数据类型【组织agency 网格grid】 //数据类型【组织agency 网格grid】
private String dataType; private String dataType;
/**
* desc:是否是导出
*/
private boolean export;
} }

1
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 { public class CustomerDataManageResultDTO {
List<CustomerDataManage> list = new ArrayList<>(); List<CustomerDataManage> list = new ArrayList<>();
List<CustomerDataManage> allGridList = new ArrayList<>();
private Integer total; private Integer total;
@Data @Data

4
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/ScreenAgencyOrGridListDTO.java

@ -16,6 +16,10 @@ public class ScreenAgencyOrGridListDTO implements Serializable {
private String level; private String level;
//直属下级组织或网格集合 //直属下级组织或网格集合
private List<AgencyGrid> agencyGridList; private List<AgencyGrid> agencyGridList;
/**
* 所有下级网格列表
*/
private List<AgencyGrid> allGridList;
@Data @Data
public static class AgencyGrid { public static class AgencyGrid {

64
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 lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
@ -54,66 +53,5 @@ public class ScreenCustomerGridDTO implements Serializable {
*/ */
private String gridName; 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;
} }

11
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; package com.epmet.dataaggre.controller;
import com.epmet.commons.tools.exception.RenException; 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.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dataaggre.dto.datastats.form.*; import com.epmet.dataaggre.dto.datastats.form.*;
import com.epmet.dataaggre.dto.datastats.result.*; import com.epmet.dataaggre.dto.datastats.result.*;
import com.epmet.dataaggre.excel.CustomerDataManageExcel;
import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.datastats.DataStatsService;
import org.springframework.beans.factory.annotation.Autowired; 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 javax.servlet.http.HttpServletResponse;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Author sun * @Author sun
@ -228,6 +227,7 @@ public class DataStatsController {
@PostMapping("operateexport") @PostMapping("operateexport")
public void CustomerDataManage(@RequestBody CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception { public void CustomerDataManage(@RequestBody CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception {
ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class); ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class);
formDTO.setExport(true);
dataStatsService.CustomerDataManage(formDTO,response); dataStatsService.CustomerDataManage(formDTO,response);
} }
@ -239,6 +239,7 @@ public class DataStatsController {
@PostMapping("operatedata") @PostMapping("operatedata")
public Result<CustomerDataManageResultDTO> operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException { public Result<CustomerDataManageResultDTO> operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException {
ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class); ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class);
formDTO.setExport(true);
return new Result<CustomerDataManageResultDTO>().ok(dataStatsService.operateExport(formDTO)); return new Result<CustomerDataManageResultDTO>().ok(dataStatsService.operateExport(formDTO));
} }

26
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 * @Author sun
* @Description 指标统计服务 * @Description 指标统计服务
*/ */
@Mapper @Mapper
public interface EvaluationIndexDao { public interface EvaluationIndexDao {
@ -64,20 +64,22 @@ public interface EvaluationIndexDao {
/** /**
* 根据组织Id查询治理指数 * 根据组织Id查询治理指数
* @author zhaoqifeng *
* @date 2021/6/25 16:36
* @param agencyIds * @param agencyIds
* @param dateId * @param dateId
* @return java.util.List<com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO> * @return java.util.List<com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO>
* @author zhaoqifeng
* @date 2021/6/25 16:36
*/ */
ScreenGovernRankDataDailyDTO getGovernRankList(@Param("agencyIds") List<String> agencyIds, @Param("dateId") String dateId); ScreenGovernRankDataDailyDTO getGovernRankList(@Param("agencyIds") List<String> agencyIds, @Param("dateId") String dateId);
/** /**
* 获取组织信息 * 获取组织信息
* @author zhaoqifeng *
* @date 2021/6/29 13:58
* @param agencyId * @param agencyId
* @return com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO * @return com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO
* @author zhaoqifeng
* @date 2021/6/29 13:58
*/ */
ScreenCustomerAgencyDTO getAgencyInfo(@Param("agencyId") String agencyId); ScreenCustomerAgencyDTO getAgencyInfo(@Param("agencyId") String agencyId);
@ -100,12 +102,12 @@ public interface EvaluationIndexDao {
List<ScreenCustomerAgencyDTO> getSubAgencyListByAgency(@Param("agencyId") String agencyId, @Param("areaCode") String areaCode, @Param("list") List<String> list); List<ScreenCustomerAgencyDTO> getSubAgencyListByAgency(@Param("agencyId") String agencyId, @Param("areaCode") String areaCode, @Param("list") List<String> list);
/** /**
* @Description 根据组织ID查询组织名 * @Description 根据组织ID查询组织名
* @Param agencyId * @Param agencyId
* @author zxc * @author zxc
* @date 2021/9/10 3:54 下午 * @date 2021/9/10 3:54 下午
*/ */
String selectAgencyNameByAgencyId(@Param("agencyId")String agencyId); String selectAgencyNameByAgencyId(@Param("agencyId") String agencyId);
/** /**
* @Description 按dateId查询组织下一级分类项目总数统计 * @Description 按dateId查询组织下一级分类项目总数统计
@ -118,4 +120,12 @@ public interface EvaluationIndexDao {
* @author sun * @author sun
*/ */
List<GridDateIdResultDTO> getGridProejctToProjectMain(GridLivelyFormDTO formDTO); List<GridDateIdResultDTO> getGridProejctToProjectMain(GridLivelyFormDTO formDTO);
}
/**
* desc:根据组织全路径 获取所有网格
*
* @param fullAgencyPath
* @return
*/
List<ScreenCustomerGridDTO> getSubAllGridByAgencyPath(@Param("fullAgencyPath") String fullAgencyPath);
}

28
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 * @Author zxc
* @DateTime 2021/9/10 10:15 上午 * @DateTime 2021/9/10 10:10 上午
* @DESC * @DESC
*/ */
@Data @Data
public class CustomerDataManageExcel { public class CustomerDataManageExcel {
@Excel(name = "组织") @Excel(name = "组织",width = 20)
private String orgName; private String orgName;
@Excel(name = "用户数") @Excel(name = "用户数",width = 10)
private Integer userCount; private Integer userCount;
@Excel(name = "居民数") @Excel(name = "居民数",width = 10)
private Integer residentCount; private Integer residentCount;
@Excel(name = "党员数") @Excel(name = "党员数",width = 10)
private Integer partyMemberCount; private Integer partyMemberCount;
@Excel(name = "小组数") @Excel(name = "小组数",width = 10)
private Integer groupCount; private Integer groupCount;
@Excel(name = "话题数") @Excel(name = "话题数",width = 10)
private Integer topicCount; private Integer topicCount;
@Excel(name = "议题数") @Excel(name = "议题数",width = 10)
private Integer issueCount; private Integer issueCount;
@Excel(name = "项目数") @Excel(name = "项目数",width = 10)
private Integer projectCount; private Integer projectCount;
@Excel(name = "结案项目数") @Excel(name = "结案项目数",width = 10)
private Integer closedProjectCount; private Integer closedProjectCount;
@Excel(name = "巡查人数") @Excel(name = "巡查人数",width = 10)
private Integer patrolPeopleCount; private Integer patrolPeopleCount;
@Excel(name = "巡查次数") @Excel(name = "巡查次数",width = 10)
private Integer patrolCount; private Integer patrolCount;
@Excel(name = "巡查时长") @Excel(name = "巡查时长",width = 15)
private String patrolDuration; private String patrolDuration;
@Excel(name = "例行工作次数") @Excel(name = "例行工作次数",width = 15)
private Integer patrolRoutineWorkTimes; private Integer patrolRoutineWorkTimes;
/** /**

174
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; package com.epmet.dataaggre.service.datastats.impl;
import com.alibaba.fastjson.JSON; import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.enums.OrgLevelEnum; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.enums.OrgLevelEnum;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.enums.OrgTypeEnum;
import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.dataaggre.constant.OrgConstant; import com.epmet.commons.tools.utils.excel.ExportMultiView;
import com.epmet.dataaggre.dao.datastats.DataStatsDao; import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao; import com.epmet.dataaggre.constant.OrgConstant;
import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO; import com.epmet.dataaggre.dao.datastats.DataStatsDao;
import com.epmet.dataaggre.dto.datastats.form.*; import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao;
import com.epmet.dataaggre.dto.datastats.result.*; import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO;
import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO; import com.epmet.dataaggre.dto.datastats.form.*;
import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO; import com.epmet.dataaggre.dto.datastats.result.*;
import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO; import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO;
import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult; import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO; import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO; import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO; import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO; import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO; import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO; import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO;
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO; import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO;
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO; import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO;
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity; import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity; import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
import com.epmet.dataaggre.excel.CustomerDataManageExcel; import com.epmet.dataaggre.entity.datastats.DimAgencyEntity;
import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity;
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService; import com.epmet.dataaggre.excel.CustomerDataManageExcel;
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService; import com.epmet.dataaggre.service.datastats.DataStatsService;
import com.epmet.dataaggre.service.govorg.GovOrgService; import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation; import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService;
import com.github.pagehelper.PageHelper; import com.epmet.dataaggre.service.govorg.GovOrgService;
import lombok.extern.slf4j.Slf4j; import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import org.apache.commons.collections4.CollectionUtils; import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode; import javax.servlet.http.HttpServletResponse;
import java.text.NumberFormat; import java.math.BigDecimal;
import java.text.ParseException; import java.math.RoundingMode;
import java.text.SimpleDateFormat; import java.text.NumberFormat;
import java.util.*; import java.text.ParseException;
import java.util.concurrent.atomic.AtomicInteger; import java.text.SimpleDateFormat;
import java.util.concurrent.atomic.AtomicReference; import java.util.*;
import java.util.stream.Collectors; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/** /**
* @Author sun * @Author sun
@ -1878,7 +1880,32 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
@Override @Override
public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception { public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception {
String openTime = formDTO.getStartTime(); String openTime = formDTO.getStartTime();
List<CustomerDataManageResultDTO.CustomerDataManage> result = operateExport(formDTO).getList(); CustomerDataManageResultDTO operateExport = operateExport(formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> result = operateExport.getList();
setTotal(result);
formDTO.setStartTime(openTime);
String fileName = excelName(formDTO);
ExportParams exportParams = new ExportParams(fileName,fileName);
//exportParams.setAutoSize(true);
List<ExportMultiView> exportList = new ArrayList<>();
List<CustomerDataManageExcel> excelList = ConvertUtils.sourceToTarget(result, CustomerDataManageExcel.class);
exportList.add(new ExportMultiView(exportParams,excelList,CustomerDataManageExcel.class));
if (formDTO.isExport()){
List<CustomerDataManageResultDTO.CustomerDataManage> gridResult = operateExport.getAllGridList();
setTotal(gridResult);
ExportParams exportParams2 = new ExportParams(fileName,"网格数据");
//exportParams2.setAutoSize(true);
List<CustomerDataManageExcel> excelList2 = ConvertUtils.sourceToTarget(gridResult, CustomerDataManageExcel.class);
exportList.add(new ExportMultiView(exportParams2,excelList2,CustomerDataManageExcel.class));
}
//ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class);
ExcelUtils.exportMultiSheetExcel(fileName, exportList, response);
}
public void setTotal(List<CustomerDataManageResultDTO.CustomerDataManage> result) {
if (!CollectionUtils.isEmpty(result)){ if (!CollectionUtils.isEmpty(result)){
CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage(); CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage();
c.setOrgName("合计"); c.setOrgName("合计");
@ -1897,9 +1924,6 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
c.setPatrolDuration(getHm(c.getPatrolDurationInteger())); c.setPatrolDuration(getHm(c.getPatrolDurationInteger()));
result.add(c); result.add(c);
} }
formDTO.setStartTime(openTime);
String fileName = excelName(formDTO);
ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class);
} }
/** /**
@ -1958,8 +1982,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
*/ */
@Override @Override
public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException {
CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO();
List<CustomerDataManageResultDTO.CustomerDataManage> dataManageList = new ArrayList<>();
//1.必要参数校验及处理 //1.必要参数校验及处理
String startTimeForm = formDTO.getStartTime(); String startTimeForm = formDTO.getStartTime();
if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(startTimeForm)) { if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(startTimeForm)) {
@ -1974,7 +1997,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
//2.查询组织信息,判断查询下级组织还是网格数据 //2.查询组织信息,判断查询下级组织还是网格数据
ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId()); ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId(), formDTO.isExport());
if (null == agencyGrid) { if (null == agencyGrid) {
return new CustomerDataManageResultDTO(); return new CustomerDataManageResultDTO();
} }
@ -1982,7 +2005,22 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); List<String> 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.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode());
formDTO.setIdList(idList); formDTO.setIdList(idList);
//获取组织级别数据
CustomerDataManageResultDTO resultDTO = getDataManageResultDTO(formDTO, startTimeForm, agencyGrid.getAgencyGridList(),agencyGrid.getLevel());
resultDTO.setTotal(idList.size()); resultDTO.setTotal(idList.size());
if (formDTO.isExport()){
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<ScreenAgencyOrGridListDTO.AgencyGrid> agencyGridList,String orgLevel) {
CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO();
List<CustomerDataManageResultDTO.CustomerDataManage> dataManageList = new ArrayList<>();
//3.查询截止日期用户、群组、话题、议题、项目、巡查数据 //3.查询截止日期用户、群组、话题、议题、项目、巡查数据
formDTO.setSourceType("end"); formDTO.setSourceType("end");
@ -2029,7 +2067,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
} }
//5.封装数据 //5.封装数据
for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGrid.getAgencyGridList()) { for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGridList) {
CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage();
dto.setOrgId(org.getOrgId()); dto.setOrgId(org.getOrgId());
dto.setOrgName(org.getOrgName()); dto.setOrgName(org.getOrgName());
@ -2083,12 +2121,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
int patrolDurationInteger = NumConstant.ZERO; int patrolDurationInteger = NumConstant.ZERO;
HashSet set = new HashSet(); HashSet set = new HashSet();
for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { 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(); patroCount += u.getPatrolCount();
patrolDurationInteger += u.getPatrolDurationInteger(); patrolDurationInteger += u.getPatrolDurationInteger();
set.add(u.getStaffId()); 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(); patroCount += u.getPatrolCount();
patrolDurationInteger += u.getPatrolDurationInteger(); patrolDurationInteger += u.getPatrolDurationInteger();
set.add(u.getStaffId()); set.add(u.getStaffId());
@ -2099,10 +2137,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
int patrolRoutineWorkTimes = NumConstant.ZERO; int patrolRoutineWorkTimes = NumConstant.ZERO;
if (CollectionUtils.isNotEmpty(workCountList) && workCountList.get(NumConstant.ZERO) != null) { if (CollectionUtils.isNotEmpty(workCountList) && workCountList.get(NumConstant.ZERO) != null) {
for (CustomerDataManageResultDTO.CustomerDataManage work : workCountList) { 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(); patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes();
set.add(work.getStaffId()); 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(); patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes();
set.add(work.getStaffId()); set.add(work.getStaffId());
} }

4
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<ScreenCustomerGridDTO> getSubGridList(String agencyId); List<ScreenCustomerGridDTO> getSubGridList(String agencyId);
List<ScreenCustomerGridDTO> getSubAllGridByAgencyPath(String fullAgencyPath);
/** /**
* 根据组织ID获取治理指数 * 根据组织ID获取治理指数
* @author zhaoqifeng * @author zhaoqifeng
@ -88,7 +90,7 @@ public interface EvaluationIndexService {
* @Description 根据组织Id判断查询直属下级组织/网格列表组织存在子客户的查询包含子客户组织数据 * @Description 根据组织Id判断查询直属下级组织/网格列表组织存在子客户的查询包含子客户组织数据
* @author sun * @author sun
*/ */
ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId); ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId, Boolean isGetSubAllGrid);
/** /**
* @Description 按dateId查询组织下一级分类项目总数统计 * @Description 按dateId查询组织下一级分类项目总数统计

25
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/EvaluationIndexServiceImpl.java

@ -1,8 +1,9 @@
package com.epmet.dataaggre.service.evaluationindex.impl; package com.epmet.dataaggre.service.evaluationindex.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.enums.OrgLevelEnum;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.evaluationindex.EvaluationIndexDao; import com.epmet.dataaggre.dao.evaluationindex.EvaluationIndexDao;
import com.epmet.dataaggre.dto.datastats.form.GovrnRatioFormDTO; import com.epmet.dataaggre.dto.datastats.form.GovrnRatioFormDTO;
@ -75,6 +76,15 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService {
return evaluationIndexDao.getSubGridList(agencyId); return evaluationIndexDao.getSubGridList(agencyId);
} }
/**
* @Description 查询所有下级网格
* @author sun
*/
@Override
public List<ScreenCustomerGridDTO> getSubAllGridByAgencyPath(String fullAgencyPath) {
return evaluationIndexDao.getSubAllGridByAgencyPath(fullAgencyPath);
}
/** /**
* 根据组织ID获取治理指数 * 根据组织ID获取治理指数
* *
@ -165,7 +175,7 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService {
* @author sun * @author sun
*/ */
@Override @Override
public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId) { public ScreenAgencyOrGridListDTO getSubAgencyOrGridList(String agencyId, Boolean isGetSubAllGrid) {
ScreenAgencyOrGridListDTO resultDTO = new ScreenAgencyOrGridListDTO(); ScreenAgencyOrGridListDTO resultDTO = new ScreenAgencyOrGridListDTO();
List<ScreenAgencyOrGridListDTO.AgencyGrid> agencyGridList = new ArrayList<>(); List<ScreenAgencyOrGridListDTO.AgencyGrid> agencyGridList = new ArrayList<>();
//1.查询组织信息 //1.查询组织信息
@ -178,6 +188,17 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService {
List<ScreenCustomerAgencyDTO> agencyList = new ArrayList<>(); List<ScreenCustomerAgencyDTO> agencyList = new ArrayList<>();
List<ScreenCustomerGridDTO> gridList = new ArrayList<>(); List<ScreenCustomerGridDTO> gridList = new ArrayList<>();
List<ScreenAgencyOrGridListDTO.AgencyGrid> finalAgencyGridList = agencyGridList; List<ScreenAgencyOrGridListDTO.AgencyGrid> finalAgencyGridList = agencyGridList;
if (isGetSubAllGrid && OrgLevelEnum.STREET.getCode().equals(dto.getLevel())){
gridList = evaluationIndexDao.getSubAllGridByAgencyPath(dto.getPids().concat(StrConstant.COLON).concat(dto.getAgencyId()));
List<ScreenAgencyOrGridListDTO.AgencyGrid> 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())) { if (!"community".equals(dto.getLevel())) {
//2-1.直属下级组织列表 //2-1.直属下级组织列表
//2.判断客户是否存在子客户 //2.判断客户是否存在子客户

21
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/EvaluationIndexDao.xml

@ -118,7 +118,8 @@
agency_name AS agencyName, agency_name AS agencyName,
level AS level, level AS level,
area_code AS areaCode, area_code AS areaCode,
parent_area_code AS parentAreaCode parent_area_code AS parentAreaCode,
pids pids
FROM FROM
screen_customer_agency screen_customer_agency
WHERE WHERE
@ -211,5 +212,23 @@
AND all_parent_ids LIKE CONCAT('%', #{agencyId}, '%') AND all_parent_ids LIKE CONCAT('%', #{agencyId}, '%')
GROUP BY org_id, DATE_FORMAT(project_create_time, "%Y%m%d") GROUP BY org_id, DATE_FORMAT(project_create_time, "%Y%m%d")
</select> </select>
<select id="getSubAllGridByAgencyPath" resultType="com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO">
SELECT
customer_id AS customerId,
grid_id AS gridId,
grid_name AS gridName,
parent_agency_id AS parentAgencyId,
area_marks AS areaMarks,
center_mark AS centerMark,
party_mark AS partyMark,
data_end_time AS dataEndTime,
all_parent_ids AS allParentIds
FROM
screen_customer_grid
WHERE
del_flag = '0'
AND all_parent_ids LIKE concat(#{fullAgencyPath},'%')
order by parentAgencyId,gridName
</select>
</mapper> </mapper>

Loading…
Cancel
Save