Browse Source

Merge remote-tracking branch 'remotes/origin/dev_oper_export' into dev

release
jianjun 3 years ago
parent
commit
56c7d82b54
  1. 36
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java
  2. 32
      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

36
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<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());
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();
}
}

32
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;
}

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;
//数据类型【组织agency 网格grid】
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 {
List<CustomerDataManage> list = new ArrayList<>();
List<CustomerDataManage> allGridList = new ArrayList<>();
private Integer total;
@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 List<AgencyGrid> agencyGridList;
/**
* 所有下级网格列表
*/
private List<AgencyGrid> allGridList;
@Data
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 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;
}
}

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;
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<CustomerDataManageResultDTO> operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException {
ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class);
formDTO.setExport(false);
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
* @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<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);
/**
* 获取组织信息
* @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<ScreenCustomerAgencyDTO> getSubAgencyListByAgency(@Param("agencyId") String agencyId, @Param("areaCode") String areaCode, @Param("list") List<String> 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<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
* @DateTime 2021/9/10 10:15 上午
* @DateTime 2021/9/10 10:10 上午
* @DESC
*/
@Data
public class CustomerDataManageExcel {
@Excel(name = "组织")
@Excel(name = "组织",width = 20)
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 = 10)
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;
/**

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;
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,32 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
@Override
public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception {
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)){
CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage();
c.setOrgName("合计");
@ -1897,9 +1924,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 +1982,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
*/
@Override
public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException {
CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO();
List<CustomerDataManageResultDTO.CustomerDataManage> dataManageList = new ArrayList<>();
//1.必要参数校验及处理
String startTimeForm = formDTO.getStartTime();
if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(startTimeForm)) {
@ -1974,7 +1997,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 +2005,22 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
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.setIdList(idList);
//获取组织级别数据
CustomerDataManageResultDTO resultDTO = getDataManageResultDTO(formDTO, startTimeForm, agencyGrid.getAgencyGridList(),agencyGrid.getLevel());
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.查询截止日期用户、群组、话题、议题、项目、巡查数据
formDTO.setSourceType("end");
@ -2029,7 +2067,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 +2121,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 +2137,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());
}

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> 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查询组织下一级分类项目总数统计

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;
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.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 +76,15 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService {
return evaluationIndexDao.getSubGridList(agencyId);
}
/**
* @Description 查询所有下级网格
* @author sun
*/
@Override
public List<ScreenCustomerGridDTO> getSubAllGridByAgencyPath(String fullAgencyPath) {
return evaluationIndexDao.getSubAllGridByAgencyPath(fullAgencyPath);
}
/**
* 根据组织ID获取治理指数
*
@ -165,7 +175,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<ScreenAgencyOrGridListDTO.AgencyGrid> agencyGridList = new ArrayList<>();
//1.查询组织信息
@ -178,6 +188,17 @@ public class EvaluationIndexServiceImpl implements EvaluationIndexService {
List<ScreenCustomerAgencyDTO> agencyList = new ArrayList<>();
List<ScreenCustomerGridDTO> gridList = new ArrayList<>();
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())) {
//2-1.直属下级组织列表
//2.判断客户是否存在子客户

21
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
@ -211,5 +212,23 @@
AND all_parent_ids LIKE CONCAT('%', #{agencyId}, '%')
GROUP BY org_id, DATE_FORMAT(project_create_time, "%Y%m%d")
</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>

Loading…
Cancel
Save