Browse Source

mlgb

master
sunyuchao 4 years ago
parent
commit
a27dbf979a
  1. 76
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java
  2. 4
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java
  3. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java
  4. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java
  5. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java
  6. 92
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  7. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java
  8. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java
  9. 25
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml
  10. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml

76
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java

@ -3,6 +3,9 @@ package com.epmet.dataaggre.dto.datastats.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @Description 运营情况数据导出-接口返参
* @Auth sun
@ -10,38 +13,45 @@ import lombok.Data;
@Data
public class CustomerDataManageResultDTO {
//组织、网格Id
private String orgId;
//组织、网格名称
private String orgName;
//用户数
private Integer userCount = 0;
//居民数
private Integer residentCount = 0;
//党员数
private Integer partyMemberCount = 0;
//小组数
private Integer groupCount = 0;
//话题数
private Integer topicCount = 0;
//议题数
private Integer issueCount = 0;
//项目数
private Integer projectCount = 0;
//结案项目数
private Integer closedProjectCount = 0;
//巡查人数
private Integer patrolPeopleCount = 0;
//巡查次数
private Integer patrolCount = 0;
//巡查时长
private String patrolDuration;
//未转换前的巡查时长
private Integer patrolDurationInteger = 0;
//数据对应dateId
@JsonIgnore
private String dateId;
@JsonIgnore
private String staffId;
List<CustomerDataManage> dataManageList = new ArrayList<>();
private Integer total;
@Data
public static class CustomerDataManage {
//组织、网格Id
private String orgId;
//组织、网格名称
private String orgName;
//用户数
private Integer userCount = 0;
//居民数
private Integer residentCount = 0;
//党员数
private Integer partyMemberCount = 0;
//小组数
private Integer groupCount = 0;
//话题数
private Integer topicCount = 0;
//议题数
private Integer issueCount = 0;
//项目数
private Integer projectCount = 0;
//结案项目数
private Integer closedProjectCount = 0;
//巡查人数
private Integer patrolPeopleCount = 0;
//巡查次数
private Integer patrolCount = 0;
//巡查时长
private String patrolDuration;
//未转换前的巡查时长
private Integer patrolDurationInteger = 0;
//数据对应dateId
@JsonIgnore
private String dateId;
@JsonIgnore
private String staffId;
}
}

4
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java

@ -237,9 +237,9 @@ public class DataStatsController {
* @author sun
*/
@PostMapping("operatedata")
public Result<List<CustomerDataManageResultDTO>> operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException {
public Result<CustomerDataManageResultDTO> operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException {
ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class);
return new Result<List<CustomerDataManageResultDTO>>().ok(dataStatsService.operateExport(formDTO));
return new Result<CustomerDataManageResultDTO>().ok(dataStatsService.operateExport(formDTO));
}
}

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

@ -314,25 +314,25 @@ public interface DataStatsDao {
* @Description 直属组织或网格下注册用户数据
* @author sun
*/
List<CustomerDataManageResultDTO> regUserList(CustomerDataManageFormDTO formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> regUserList(CustomerDataManageFormDTO formDTO);
/**
* @Description 直属组织或网格下群组数据
* @author sun
*/
List<CustomerDataManageResultDTO> groupList(CustomerDataManageFormDTO formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> groupList(CustomerDataManageFormDTO formDTO);
/**
* @Description 直属组织或网格下话题数据
* @author sun
*/
List<CustomerDataManageResultDTO> topicList(CustomerDataManageFormDTO formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> topicList(CustomerDataManageFormDTO formDTO);
/**
* @Description 直属组织或网格下议题数据
* @author sun
*/
List<CustomerDataManageResultDTO> issueList(CustomerDataManageFormDTO formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> issueList(CustomerDataManageFormDTO formDTO);
/**
* @Description 直属组织或网格下项目数据
* @author sun
*/
List<CustomerDataManageResultDTO> projectList(CustomerDataManageFormDTO formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> projectList(CustomerDataManageFormDTO formDTO);
}

2
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java

@ -50,5 +50,5 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao<StatsStaffPatrol
* @Description 直属组织或网格下巡查数据
* @author sun
*/
List<CustomerDataManageResultDTO> patrolList(CustomerDataManageFormDTO formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> patrolList(CustomerDataManageFormDTO formDTO);
}

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

@ -245,6 +245,6 @@ public interface DataStatsService {
* @Description 运营情况数据查询
* @author sun
*/
List<CustomerDataManageResultDTO> operateExport(CustomerDataManageFormDTO formDTO) throws ParseException;
CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException;
}

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

@ -1933,16 +1933,13 @@ public class DataStatsServiceImpl implements DataStatsService {
* @author sun
*/
@Override
public List<CustomerDataManageResultDTO> operateExport(CustomerDataManageFormDTO formDTO) throws ParseException {
List<CustomerDataManageResultDTO> resultList = new ArrayList<>();
public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException {
CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO();
List<CustomerDataManageResultDTO.CustomerDataManage> dataManageList = new ArrayList<>();
//1.必要参数校验及处理
if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(formDTO.getStartTime())) {
throw new RenException("请选择开始时间或查询累计值");
}
if (formDTO.getIsPage()) {
int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize();
formDTO.setPageNo(pageIndex);
}
//入参有开始时间的则需要减去一天
if (StringUtils.isNotBlank(formDTO.getStartTime())) {
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD);
@ -1954,27 +1951,29 @@ public class DataStatsServiceImpl implements DataStatsService {
//2.查询组织信息,判断查询下级组织还是网格数据
ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId());
if (null == agencyGrid) {
return new ArrayList<>();
return new CustomerDataManageResultDTO();
}
//组织或网格Id集合
List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList());
formDTO.setDataType(!"community".equals(agencyGrid.getLevel()) ? "agency" : "grid");
formDTO.setIdList(idList);
resultDTO.setTotal(idList.size());
//3.查询截止日期用户、群组、话题、议题、项目、巡查数据
List<CustomerDataManageResultDTO> userEnd = dataStatsDao.regUserList(formDTO);
List<CustomerDataManageResultDTO> groupEnd = dataStatsDao.groupList(formDTO);
List<CustomerDataManageResultDTO> topicEnd = dataStatsDao.topicList(formDTO);
List<CustomerDataManageResultDTO> issueEnd = dataStatsDao.issueList(formDTO);
List<CustomerDataManageResultDTO> projectEnd = dataStatsDao.projectList(formDTO);
List<CustomerDataManageResultDTO> patrolEnd = statsStaffPatrolRecordDailyService.patrolList(formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> userEnd = dataStatsDao.regUserList(formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> groupEnd = dataStatsDao.groupList(formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> topicEnd = dataStatsDao.topicList(formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> issueEnd = dataStatsDao.issueList(formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> projectEnd = dataStatsDao.projectList(formDTO);
//巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员
List<CustomerDataManageResultDTO.CustomerDataManage> patrolEnd = statsStaffPatrolRecordDailyService.patrolList(formDTO);
//4.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据
List<CustomerDataManageResultDTO> userStart = new ArrayList<>();
List<CustomerDataManageResultDTO> groupStart = new ArrayList<>();
List<CustomerDataManageResultDTO> topicStart = new ArrayList<>();
List<CustomerDataManageResultDTO> issueStart = new ArrayList<>();
List<CustomerDataManageResultDTO> projectStart = new ArrayList<>();
List<CustomerDataManageResultDTO.CustomerDataManage> userStart = new ArrayList<>();
List<CustomerDataManageResultDTO.CustomerDataManage> groupStart = new ArrayList<>();
List<CustomerDataManageResultDTO.CustomerDataManage> topicStart = new ArrayList<>();
List<CustomerDataManageResultDTO.CustomerDataManage> issueStart = new ArrayList<>();
List<CustomerDataManageResultDTO.CustomerDataManage> projectStart = new ArrayList<>();
if ("Interval".equals(formDTO.getType())) {
userStart = dataStatsDao.regUserList(formDTO);
groupStart = dataStatsDao.groupList(formDTO);
@ -1984,25 +1983,25 @@ public class DataStatsServiceImpl implements DataStatsService {
}
//5.封装数据
List<CustomerDataManageResultDTO> finalUserStart = userStart;
List<CustomerDataManageResultDTO> finalGroupStart = groupStart;
List<CustomerDataManageResultDTO> finalTopicStart = topicStart;
List<CustomerDataManageResultDTO> finalIssueStart = issueStart;
List<CustomerDataManageResultDTO> finalProjectStart = projectStart;
List<CustomerDataManageResultDTO.CustomerDataManage> finalUserStart = userStart;
List<CustomerDataManageResultDTO.CustomerDataManage> finalGroupStart = groupStart;
List<CustomerDataManageResultDTO.CustomerDataManage> finalTopicStart = topicStart;
List<CustomerDataManageResultDTO.CustomerDataManage> finalIssueStart = issueStart;
List<CustomerDataManageResultDTO.CustomerDataManage> finalProjectStart = projectStart;
agencyGrid.getAgencyGridList().forEach(org -> {
CustomerDataManageResultDTO dto = new CustomerDataManageResultDTO();
CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage();
dto.setOrgId(org.getOrgId());
dto.setOrgName(org.getOrgName());
int user = 0;
int resi = 0;
int part = 0;
for (CustomerDataManageResultDTO u : userEnd) {
for (CustomerDataManageResultDTO.CustomerDataManage u : userEnd) {
if (org.getOrgId().equals(u.getOrgId())) {
user = u.getUserCount();
resi = u.getResidentCount();
part = u.getPartyMemberCount();
if ("Interval".equals(formDTO.getType())) {
for (CustomerDataManageResultDTO s : finalUserStart) {
for (CustomerDataManageResultDTO.CustomerDataManage s : finalUserStart) {
if (u.getOrgId().equals(s.getOrgId())) {
user = user - s.getUserCount();
resi = resi - s.getResidentCount();
@ -2013,11 +2012,11 @@ public class DataStatsServiceImpl implements DataStatsService {
}
}
int group = 0;
for (CustomerDataManageResultDTO u : groupEnd) {
for (CustomerDataManageResultDTO.CustomerDataManage u : groupEnd) {
if (org.getOrgId().equals(u.getOrgId())) {
group = u.getGroupCount();
if ("Interval".equals(formDTO.getType())) {
for (CustomerDataManageResultDTO s : finalGroupStart) {
for (CustomerDataManageResultDTO.CustomerDataManage s : finalGroupStart) {
if (u.getOrgId().equals(s.getOrgId())) {
group = group - s.getGroupCount();
}
@ -2026,11 +2025,11 @@ public class DataStatsServiceImpl implements DataStatsService {
}
}
int topic = 0;
for (CustomerDataManageResultDTO u : topicEnd) {
for (CustomerDataManageResultDTO.CustomerDataManage u : topicEnd) {
if (org.getOrgId().equals(u.getOrgId())) {
topic = u.getTopicCount();
if ("Interval".equals(formDTO.getType())) {
for (CustomerDataManageResultDTO s : finalTopicStart) {
for (CustomerDataManageResultDTO.CustomerDataManage s : finalTopicStart) {
if (u.getOrgId().equals(s.getOrgId())) {
topic = topic - s.getTopicCount();
}
@ -2039,11 +2038,11 @@ public class DataStatsServiceImpl implements DataStatsService {
}
}
int issue = 0;
for (CustomerDataManageResultDTO u : issueEnd) {
for (CustomerDataManageResultDTO.CustomerDataManage u : issueEnd) {
if (org.getOrgId().equals(u.getOrgId())) {
issue = u.getIssueCount();
if ("Interval".equals(formDTO.getType())) {
for (CustomerDataManageResultDTO s : finalIssueStart) {
for (CustomerDataManageResultDTO.CustomerDataManage s : finalIssueStart) {
if (u.getOrgId().equals(s.getOrgId())) {
issue = issue - s.getIssueCount();
}
@ -2053,12 +2052,12 @@ public class DataStatsServiceImpl implements DataStatsService {
}
int project = 0;
int closed = 0;
for (CustomerDataManageResultDTO u : projectEnd) {
for (CustomerDataManageResultDTO.CustomerDataManage u : projectEnd) {
if (org.getOrgId().equals(u.getOrgId())) {
project = u.getProjectCount();
closed = u.getClosedProjectCount();
if ("Interval".equals(formDTO.getType())) {
for (CustomerDataManageResultDTO s : finalProjectStart) {
for (CustomerDataManageResultDTO.CustomerDataManage s : finalProjectStart) {
if (u.getOrgId().equals(s.getOrgId())) {
project = project - s.getProjectCount();
closed = closed - s.getClosedProjectCount();
@ -2071,15 +2070,14 @@ public class DataStatsServiceImpl implements DataStatsService {
int patroCount = 0;
String patrolDuration = "";
int patrolDurationInteger = 0;
List<String> list = new ArrayList<>();
for (CustomerDataManageResultDTO u : patrolEnd) {
HashSet set = new HashSet();
for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) {
if (org.getOrgId().equals(u.getOrgId())) {
patroCount += u.getPatrolCount();
patrolDurationInteger += u.getPatrolDurationInteger();
list.add(u.getStaffId());
set.add(u.getStaffId());
}
}
HashSet set = new HashSet(list);
patro = set.size();
Integer minutes = patrolDurationInteger / 60;
patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟");
@ -2097,18 +2095,28 @@ public class DataStatsServiceImpl implements DataStatsService {
dto.setPatrolDuration(patrolDuration);
dto.setPatrolDurationInteger(patrolDurationInteger);
resultList.add(dto);
dataManageList.add(dto);
});
//6.默认按用户总数降序
Collections.sort(resultList, new Comparator<CustomerDataManageResultDTO>() {
Collections.sort(dataManageList, new Comparator<CustomerDataManageResultDTO.CustomerDataManage>() {
@Override
public int compare(CustomerDataManageResultDTO o1, CustomerDataManageResultDTO o2) {
public int compare(CustomerDataManageResultDTO.CustomerDataManage o1, CustomerDataManageResultDTO.CustomerDataManage o2) {
return o2.getUserCount().compareTo(o1.getUserCount());
}
});
return resultList;
//7.物理分页并返回
if (formDTO.getIsPage()) {
int firstIndex = (formDTO.getPageNo() - 1) * formDTO.getPageSize();
int lastIndex = formDTO.getPageNo() * formDTO.getPageSize();
List<CustomerDataManageResultDTO.CustomerDataManage> list = dataManageList.subList((firstIndex > dataManageList.size() ? dataManageList.size() : firstIndex), (lastIndex > dataManageList.size() ? dataManageList.size() : lastIndex));
resultDTO.setDataManageList(list);
return resultDTO;
}
resultDTO.setDataManageList(dataManageList);
return resultDTO;
}
}

2
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java

@ -46,5 +46,5 @@ public interface StatsStaffPatrolRecordDailyService extends BaseService<StatsSta
* @Description 直属组织或网格下巡查数据
* @author sun
*/
List<CustomerDataManageResultDTO> patrolList(CustomerDataManageFormDTO formDTO);
List<CustomerDataManageResultDTO.CustomerDataManage> patrolList(CustomerDataManageFormDTO formDTO);
}

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

@ -43,7 +43,7 @@ public class StatsStaffPatrolRecordDailyServiceImpl extends BaseServiceImpl<Stat
* @author sun
*/
@Override
public List<CustomerDataManageResultDTO> patrolList(CustomerDataManageFormDTO formDTO) {
public List<CustomerDataManageResultDTO.CustomerDataManage> patrolList(CustomerDataManageFormDTO formDTO) {
return baseDao.patrolList(formDTO);
}

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

@ -797,7 +797,7 @@
GROUP BY staff_id
</select>
<select id="regUserList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO">
<select id="regUserList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO$CustomerDataManage">
SELECT
t.orgId, t.dateId, t.userCount, t.partyMemberCount,t.residentCount
FROM
@ -836,11 +836,8 @@
</choose>
) t
GROUP BY t.orgId
<if test='isPage == true '>
LIMIT #{pageNo}, #{pageSize}
</if>
</select>
<select id="groupList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO">
<select id="groupList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO$CustomerDataManage">
SELECT
t.orgId, t.dateId, t.groupCount
FROM
@ -879,11 +876,8 @@
</choose>
) t
GROUP BY t.orgId
<if test='isPage == true '>
LIMIT #{pageNo}, #{pageSize}
</if>
</select>
<select id="topicList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO">
<select id="topicList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO$CustomerDataManage">
SELECT
t.orgId, t.dateId, t.topicCount
FROM
@ -922,11 +916,8 @@
</choose>
) t
GROUP BY t.orgId
<if test='isPage == true '>
LIMIT #{pageNo}, #{pageSize}
</if>
</select>
<select id="issueList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO">
<select id="issueList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO$CustomerDataManage">
SELECT
t.orgId, t.dateId, t.issueCount
FROM
@ -965,11 +956,8 @@
</choose>
) t
GROUP BY t.orgId
<if test='isPage == true '>
LIMIT #{pageNo}, #{pageSize}
</if>
</select>
<select id="projectList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO">
<select id="projectList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO$CustomerDataManage">
SELECT
t.orgId, t.dateId, t.projectCount, t.closedProjectCount
FROM
@ -1008,9 +996,6 @@
</choose>
) t
GROUP BY t.orgId
<if test='isPage == true '>
LIMIT #{pageNo}, #{pageSize}
</if>
</select>
</mapper>

2
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml

@ -16,7 +16,7 @@
</select>
<select id="patrolList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO">
<select id="patrolList" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO$CustomerDataManage">
SELECT
t.dateId, t.orgId, t.staffId, sum(t.patrolCount),SUM(t.patrolDurationInteger)
FROM (

Loading…
Cancel
Save