Browse Source

网格活跃度查询统计初版

dev
sunyuchao 4 years ago
parent
commit
91406709ad
  1. 37
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/GridLivelyFormDTO.java
  2. 20
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridDateIdResultDTO.java
  3. 33
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridLivelyResultDTO.java
  4. 29
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java
  5. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java
  6. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StaffPatrolRecordDao.java
  7. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java
  8. 72
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java
  9. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java
  10. 11
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  11. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  12. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  13. 18
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  14. 108
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  15. 15
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml
  16. 16
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffPatrolRecordDao.xml
  17. 13
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml

37
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/GridLivelyFormDTO.java

@ -0,0 +1,37 @@
package com.epmet.dataaggre.dto.govorg.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @Description 网格活跃度-接口入参
* @Author sun
*/
@Data
public class GridLivelyFormDTO implements Serializable {
private static final long serialVersionUID = -3651225675593357002L;
public interface Grid extends CustomerClientShowGroup {
}
/**
* 组织Id
*/
@NotBlank(message = "组织ID不能为空", groups = {Grid.class})
private String agencyId;
/**
* 起始查询时间yyyyMMdd
*/
@NotBlank(message = "起始查询时间不能为空", groups = {Grid.class})
private String startTime;
/**
* 结束查询时间yyyyMMdd
*/
@NotBlank(message = "结束查询时间不能为空", groups = {Grid.class})
private String endTime;
}

20
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridDateIdResultDTO.java

@ -0,0 +1,20 @@
package com.epmet.dataaggre.dto.govorg.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 网格下按天的上报事件或直接立项数据-接口返参
* @Author sun
*/
@Data
public class GridDateIdResultDTO implements Serializable {
private static final long serialVersionUID = -4304356050545598564L;
//网格Id
private String gridId;
//日维度Id
private String dateId;
//网格所属组织的所有上级Id
private String pids;
}

33
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridLivelyResultDTO.java

@ -0,0 +1,33 @@
package com.epmet.dataaggre.dto.govorg.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 网格活跃度-接口返参
* @Author sun
*/
@Data
public class GridLivelyResultDTO implements Serializable {
private static final long serialVersionUID = -4304356050545598564L;
//组织Id
private String agencyId;
//组织名称
private String agencyName;
//组织下所有网格总数
private Integer gridSumNum;
//活跃网格数
private Integer gridLivelyNum;
//活跃网格数占比
private String gridLivelyRatio;
//正常运行网格数
private Integer gridOrdinaryNum;
//正常运行网格数占比
private String gridOrdinaryRatio;
//僵尸网格数
private Integer gridLazyNum;
//僵尸网格数占比
private String gridLazyRatio;
}

29
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java

@ -5,6 +5,7 @@ import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.RequirePermissionEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
@ -26,6 +27,7 @@ import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import com.epmet.dataaggre.enums.GridMemberDataAnalysisEnums;
import com.epmet.dataaggre.service.AggreGridService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dto.form.patrol.PcworkRecordListFormDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@ -373,4 +375,31 @@ public class GovOrgController {
sb.append("的工作统计");
return sb.toString();
}
/**
* @Description 查询组织的直属下级组织下网格活跃度统计查平阴实际是查的下边八个街道的活跃程度
* @author sun
* 网格按运行情况分为活跃网格正常运行网格和僵尸网格三个类别
* 以自然周为计量单位对末级网格运行情况进行考核
* 1周内每个末级网格有5天及5天以上上传事件或开展例行工作的为活跃网格
* 有2天及2天以上5天以下上传事件或开展例行工作的为正常运行网格
* 只有1天上传事件或开展例行工作的为僵尸网格
*/
@PostMapping("gridlively")
public Result<List<GridLivelyResultDTO>> grdiLively(@RequestBody GridLivelyFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GridLivelyFormDTO.Grid.class);
return new Result<List<GridLivelyResultDTO>>().ok(govOrgService.grdiLively(formDTO));
}
/**
* @Author sun
* @Description 查询组织的直属下级组织下网格活跃度统计--文件导出
**/
@NoRepeatSubmit
@PostMapping("export")
public void pcworkRecordListExport(HttpServletResponse response, @RequestBody GridLivelyFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GridLivelyFormDTO.Grid.class);
govOrgService.grdiLivelyExport(response, formDTO);
}
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java

@ -25,6 +25,8 @@ 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.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO;
import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO;
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
@ -358,4 +360,10 @@ public interface DataStatsDao {
@Param("orgId")String orgId,
@Param("dateId") String dateId,
@Param("configIds") List<String> configIds);
/**
* @Description 查询直属下级组织下网格在查询时间段内存在上报事件(直接立项)数的网格一天一条
* @author sun
*/
List<GridDateIdResultDTO> gridDateProjectIncrList(GridLivelyFormDTO formDTO);
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StaffPatrolRecordDao.java

@ -22,6 +22,8 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO;
import com.epmet.dataaggre.dto.epmetuser.form.StaffListFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.StaffListResultDTO;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO;
import com.epmet.dataaggre.entity.epmetuser.StaffPatrolRecordEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -60,4 +62,10 @@ public interface StaffPatrolRecordDao extends BaseDao<StaffPatrolRecordEntity> {
* @author sun
*/
List<StaffListResultDTO> gridMemberPatrol(GridMemberPatrolListFormDTO formDTO);
/**
* @Description 查询直属下级组织下网格在查询时间段内存在例行工作次数的网格
* @author sun
*/
List<GridDateIdResultDTO> gridDateRoutineWorkList(GridLivelyFormDTO formDTO);
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java

@ -23,8 +23,8 @@ import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
/**
* 机关单位信息表
@ -100,4 +100,9 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
*/
List<String> getOrgList(@Param("staffId") String staffId);
/**
* @Description 查询当前组织的直属下级组织列表及组织下的网格总数
* @author sun
*/
LinkedList<GridLivelyResultDTO> subAgencyListAndGridSumNum(@Param("agencyId") String agencyId);
}

72
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java

@ -0,0 +1,72 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dataaggre.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
/**
* @Description 网格活跃度文件导出-接口返参
* @Author sun
*/
@Data
public class GridLivelyExcel {
@ExcelProperty("组织ID")
@ExcelIgnore
private String agencyId;
//组织名称
@ExcelProperty("组织名称")
@ColumnWidth(15)
private String agencyName;
//组织下所有网格总数
@ExcelProperty("网格总数")
@ColumnWidth(15)
private Integer gridSumNum;
//活跃网格数
@ExcelProperty("活跃网格数")
@ColumnWidth(15)
private Integer gridLivelyNum;
//活跃网格数占比
@ExcelProperty("活跃网格数占比")
@ColumnWidth(15)
private String gridLivelyRatio;
//正常运行网格数
@ExcelProperty("正常运行网格数")
@ColumnWidth(15)
private Integer gridOrdinaryNum;
//正常运行网格数占比
@ExcelProperty("正常运行网格数占比")
@ColumnWidth(15)
private String gridOrdinaryRatio;
//僵尸网格数
@ExcelProperty("僵尸网格数")
@ColumnWidth(15)
private Integer gridLazyNum;
//僵尸网格数占比
@ExcelProperty("僵尸网格数占比")
@ColumnWidth(15)
private String gridLazyRatio;
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java

@ -6,6 +6,8 @@ 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.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.govproject.result.ProjectMonthIncrResultDTO;
@ -284,4 +286,10 @@ public interface DataStatsService {
List<FactIcuserCategoryAnalysisDailyDTO> queryGridIcUserCategoryData(String orgId, String dateId, List<String> configIds);
List<FactIcuserCategoryAnalysisDailyDTO> queryAgencyIcUserCategoryData(String gridPids, String orgId,String dateId, List<String> configIds);
/**
* @Description 查询直属下级组织下网格在查询时间段内存在上报事件(直接立项)数的网格一天一条
* @author sun
*/
List<GridDateIdResultDTO> getGridDateProjectIncrList(GridLivelyFormDTO formDTO);
}

11
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

@ -24,6 +24,8 @@ 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;
@ -2187,4 +2189,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
return dataStatsDao.queryAgencyIcUserCategoryData(gridPids,orgId,dateId,configIds);
}
/**
* @Description 查询直属下级组织下网格在查询时间段内存在上报事件(直接立项)数的网格一天一条
* @author sun
*/
@Override
public List<GridDateIdResultDTO> getGridDateProjectIncrList(GridLivelyFormDTO formDTO) {
return dataStatsDao.gridDateProjectIncrList(formDTO);
}
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java

@ -2,8 +2,10 @@ package com.epmet.dataaggre.service.epmetuser;
import com.epmet.dataaggre.dto.epmetuser.form.*;
import com.epmet.dataaggre.dto.epmetuser.result.*;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO;
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectAnalysisResultDTO;
import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity;
@ -184,4 +186,10 @@ public interface EpmetUserService {
* @return
*/
List<IcUserCategoryResultDTO> queryIcUserCategoryData(IcUserCategoryFormDTO formDTO);
/**
* @Description 查询直属下级组织下网格在查询时间段内存在例行工作次数的网格
* @author sun
*/
List<GridDateIdResultDTO> getGridDateRoutineWorkList(GridLivelyFormDTO formDTO);
}

10
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -23,8 +23,10 @@ import com.epmet.dataaggre.dto.epmetuser.result.*;
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO;
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.dto.govorg.result.StaffOrgNameResultDTO;
import com.epmet.dataaggre.dto.govorg.result.StaffOrgRelationResultDTO;
@ -816,6 +818,14 @@ public class EpmetUserServiceImpl implements EpmetUserService {
return resList;
}
/**
* @Description 查询直属下级组织下网格在查询时间段内存在例行工作次数的网格
* @author sun
*/
@Override
public List<GridDateIdResultDTO> getGridDateRoutineWorkList(GridLivelyFormDTO formDTO) {
return staffPatrolRecordDao.gridDateRoutineWorkList(formDTO);
}
}

18
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java

@ -4,14 +4,12 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO;
import com.epmet.dataaggre.dto.govorg.form.SubOrgFormDTO;
import com.epmet.dataaggre.dto.govorg.form.*;
import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -172,4 +170,16 @@ public interface GovOrgService {
* @date 2021/11/5 2:57 下午
*/
CustomerGridDTO getGridInfo(String gridId);
/**
* @Description 查询组织的直属下级组织下网格活跃度统计查平阴实际是查的下边八个街道的活跃程度
* @author sun
*/
List<GridLivelyResultDTO> grdiLively(GridLivelyFormDTO formDTO);
/**
* @Author sun
* @Description 查询组织的直属下级组织下网格活跃度统计--文件导出
**/
void grdiLivelyExport(HttpServletResponse response, GridLivelyFormDTO formDTO);
}

108
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -1,35 +1,44 @@
package com.epmet.dataaggre.service.govorg.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
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.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.OptionDataResultDTO;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.govorg.*;
import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO;
import com.epmet.dataaggre.dto.govorg.*;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO;
import com.epmet.dataaggre.dto.govorg.form.SubOrgFormDTO;
import com.epmet.dataaggre.dto.govorg.form.*;
import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import com.epmet.dataaggre.excel.GridLivelyExcel;
import com.epmet.dataaggre.service.commonservice.AreaCodeService;
import com.epmet.dataaggre.service.datastats.DataStatsService;
import com.epmet.dataaggre.service.epmetuser.EpmetUserService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import com.epmet.dto.result.PcworkRecordListResultDTO;
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.text.NumberFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -58,6 +67,8 @@ public class GovOrgServiceImpl implements GovOrgService {
private CustomerStaffGridDao customerStaffGridDao;
@Autowired
private EpmetUserService epmetUserService;
@Autowired
private DataStatsService dataStatsService;
/**
* @param staffId
@ -590,5 +601,94 @@ public class GovOrgServiceImpl implements GovOrgService {
return customerGridDao.getGridInfo(gridId);
}
/**
* @Description 查询组织的直属下级组织下网格活跃度统计查平阴实际是查的下边八个街道的活跃程度
* @author sun
* 网格按运行情况分为活跃网格正常运行网格和僵尸网格三个类别
* 以自然周为计量单位对末级网格运行情况进行考核
* 1周内每个末级网格有5天及5天以上上传事件或开展例行工作的为活跃网格
* 有2天及2天以上5天以下上传事件或开展例行工作的为正常运行网格
* 只有1天上传事件或开展例行工作的为僵尸网格
*/
@Override
public List<GridLivelyResultDTO> grdiLively(GridLivelyFormDTO formDTO) {
//1.查询当前组织的直属下级组织列表及组织下的网格总数
LinkedList<GridLivelyResultDTO> subList = customerAgencyDao.subAgencyListAndGridSumNum(formDTO.getAgencyId());
//2.查询直属下级组织下网格在查询时间段内存在例行工作次数的网格,一天一条
List<GridDateIdResultDTO> workList = epmetUserService.getGridDateRoutineWorkList(formDTO);
//3.查询直属下级组织下网格在查询时间段内存在上报事件(直接立项)数的网格,一天一条
List<GridDateIdResultDTO> projectList = dataStatsService.getGridDateProjectIncrList(formDTO);
//4.汇总数据,一个网格一天只记录一条数据,这条数据可能是例行工作的也可能是上报事件的,也可能某一天两个数都有,但只记录一条
Map<String, String> map = new HashMap<>();
workList.forEach(w -> {
map.put(w.getGridId() + w.getDateId(), w.getDateId());
});
//projectList.stream().filter(pro -> !map.containsKey(pro.getGridId() + pro.getDateId())).forEach(p -> workList.add(p));
projectList.forEach(pro -> {
if (!map.containsKey(pro.getGridId() + pro.getDateId())) {
workList.add(pro);
}
});
//5.按组织封装数据
//计算百分比使用,保留小数点后两位
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(NumConstant.TWO);
subList.forEach(sub -> {
Map<String, Integer> hash = new HashMap<>();
workList.forEach(w -> {
if (w.getPids().contains(sub.getAgencyId())) {
if (hash.containsKey(w.getGridId())) {
hash.put(w.getGridId(), hash.get(w.getGridId()) + NumConstant.ONE);
} else {
hash.put(w.getGridId(), NumConstant.ONE);
}
}
});
//活跃网格数、普通网格数、僵尸网格数
int gridLivelyNum = 0;
int gridOrdinaryNum = 0;
int gridLazyNum = 0;
for (Integer val : hash.values()) {
if (val >= NumConstant.FIVE) {
gridLivelyNum++;
} else if (val >= NumConstant.TWO && val < NumConstant.FIVE) {
gridOrdinaryNum++;
} else {
gridLazyNum++;
}
}
sub.setGridLivelyNum(gridLivelyNum);
sub.setGridLivelyRatio((sub.getGridSumNum() == 0 || gridLivelyNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLivelyNum / (float) sub.getGridSumNum()) * 100) + "%");
sub.setGridOrdinaryNum(gridOrdinaryNum);
sub.setGridOrdinaryRatio((sub.getGridSumNum() == 0 || gridOrdinaryNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridOrdinaryNum / (float) sub.getGridSumNum()) * 100) + "%");
sub.setGridLazyNum(gridLazyNum);
sub.setGridLazyRatio((sub.getGridSumNum() == 0 || gridLazyNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLazyNum / (float) sub.getGridSumNum()) * 100) + "%");
});
return subList;
}
/**
* @Author sun
* @Description 查询组织的直属下级组织下网格活跃度统计--文件导出
**/
@Override
public void grdiLivelyExport(HttpServletResponse response, GridLivelyFormDTO formDTO) {
ExcelWriter excelWriter = null;
try {
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("网格活跃度统计表.xlsx", response)).build();
WriteSheet writeSheet = EasyExcel.writerSheet("sheet").build();
writeSheet.setClazz(GridLivelyExcel.class);
List<GridLivelyExcel> data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class);
excelWriter.write(data, writeSheet);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (excelWriter != null) {
excelWriter.finish();
}
}
}
}

15
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml

@ -1146,4 +1146,19 @@
</if>
group by m.CONFIG_ID,m.COLUMN_NAME
</select>
<select id="gridDateProjectIncrList" resultType="com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO">
SELECT
grid_id gridId,
date_id dateId,
pids pids
FROM
fact_grid_member_statistics_daily
WHERE del_flag = '0'
AND DATE_FORMAT(created_time,'%Y%m%d') <![CDATA[ >= ]]> #{startTime}
AND DATE_FORMAT(created_time,'%Y%m%d') <![CDATA[ <= ]]> #{endTime}
AND project_incr > 0
AND pids LIKE CONCAT('%', #{agencyId}, '%')
GROUP BY grid_id, date_id
</select>
</mapper>

16
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffPatrolRecordDao.xml

@ -141,4 +141,20 @@
GROUP BY staff_id
</select>
<select id="gridDateRoutineWorkList" resultType="com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO">
SELECT
grid_id gridId,
date_id dateId,
grid_pids pids
FROM
stats_staff_patrol_record_daily
WHERE
del_flag = '0'
AND DATE_FORMAT(created_time,'%Y%m%d') <![CDATA[ >= ]]> #{startTime}
AND DATE_FORMAT(created_time,'%Y%m%d') <![CDATA[ <= ]]> #{endTime}
AND routine_work_count > 0
AND grid_pids LIKE CONCAT('%', #{agencyId}, '%')
GROUP BY grid_id, date_id
</select>
</mapper>

13
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml

@ -286,4 +286,17 @@
AND USER_ID = #{staffId}
</select>
<select id="subAgencyListAndGridSumNum" resultType="com.epmet.dataaggre.dto.govorg.result.GridLivelyResultDTO">
SELECT
ca.id agencyId,
ca.organization_name agencyName,
(select COUNT(0) from customer_grid where del_flag = '0' and pids LIKE CONCAT('%',ca.id,'%')) gridSumNum
FROM
customer_agency ca
WHERE
del_flag = '0'
AND pid = #{agencyId}
ORDER BY created_time ASC
</select>
</mapper>

Loading…
Cancel
Save