Browse Source

Merge remote-tracking branch 'origin/dev_data_stats' into dev_data_stats

master
jiangyuying 5 years ago
parent
commit
896060f99d
  1. 7
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSubAgencyResultDTO.java
  2. 7
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSubGridResultDTO.java
  3. 2
      epmet-module/data-report/data-report-server/deploy/docker-compose-dev.yml
  4. 2
      epmet-module/data-report/data-report-server/pom.xml
  5. 5
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/group/impl/GroupServiceImpl.java
  6. 30
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java
  7. 42
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java
  8. 7
      epmet-module/data-report/data-report-server/src/main/resources/mapper/group/GroupDao.xml
  9. 8
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
  10. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java
  11. 2
      epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml
  12. 2
      epmet-module/data-statistical/data-statistical-server/pom.xml
  13. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
  14. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimMonthServiceImpl.java
  15. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimQuarterServiceImpl.java
  16. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimWeekServiceImpl.java
  17. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimYearServiceImpl.java
  18. 2
      epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-dev.yml
  19. 2
      epmet-module/epmet-job/epmet-job-server/pom.xml
  20. 9
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/DimInitService.java
  21. 19
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimInitServiceImpl.java
  22. 31
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DimInitTask.java

7
epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSubAgencyResultDTO.java

@ -1,5 +1,6 @@
package com.epmet.topic.dto.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
@ -32,4 +33,10 @@ public class TopicSubAgencyResultDTO implements Serializable {
* 机关Id
*/
private String agencyId;
/**
* 排序
*/
@JsonIgnore
private Integer sort;
}

7
epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSubGridResultDTO.java

@ -1,5 +1,6 @@
package com.epmet.topic.dto.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
@ -32,4 +33,10 @@ public class TopicSubGridResultDTO implements Serializable {
* 网格Id
*/
private String gridId;
/**
* 排序
*/
@JsonIgnore
private Integer sort;
}

2
epmet-module/data-report/data-report-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
data-report-server:
container_name: data-report-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/data-report-server:0.3.5
image: 192.168.1.130:10080/epmet-cloud-dev/data-report-server:0.3.7
ports:
- "8109:8109"
network_mode: host # 使用现有网络

2
epmet-module/data-report/data-report-server/pom.xml

@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.5</version>
<version>0.3.7</version>
<artifactId>data-report-server</artifactId>
<parent>

5
epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/group/impl/GroupServiceImpl.java

@ -15,7 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author zxc
@ -60,7 +62,8 @@ public class GroupServiceImpl implements GroupService {
}
});
});
return result;
//倒序
return result.stream().sorted(Comparator.comparing(GroupSubAgencyResultDTO::getValue).reversed()).collect(Collectors.toList());
}
return new ArrayList<>();
}

30
epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java

@ -14,9 +14,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -94,6 +92,7 @@ public class TopicServiceImpl implements TopicService {
public List<TopicSubGridResultDTO> topicSubGrid(TokenDto tokenDto) {
String agencyId = this.getLoginUserDetails(tokenDto);
List<TopicSubGridResultDTO> result = new ArrayList<>();
List<TopicSubGridResultDTO> resultAll = new ArrayList<>();
List<String> subGridIdList = topicDao.getSubGridIdList(agencyId);
if (subGridIdList.size() != NumConstant.ZERO){
List<TopicSubGridResultDTO> gridAllTopicInfoLastDay = topicDao.getGridAllTopicInfoLastDay();
@ -110,7 +109,17 @@ public class TopicServiceImpl implements TopicService {
}
});
});
return result;
Map<String, List<TopicSubGridResultDTO>> collect = result.stream().collect(Collectors.groupingBy(TopicSubGridResultDTO::getGridId));
Set<Map.Entry<String, List<TopicSubGridResultDTO>>> entries = collect.entrySet();
entries.forEach(entry -> {
List<TopicSubGridResultDTO> value = entry.getValue();
Integer sort = value.stream().collect(Collectors.summingInt(TopicSubGridResultDTO::getValue));
value.forEach(v -> {
v.setSort(sort);
resultAll.add(v);
});
});
return resultAll.stream().sorted(Comparator.comparing(TopicSubGridResultDTO::getSort).reversed()).collect(Collectors.toList());
}
return new ArrayList<>();
}
@ -124,6 +133,7 @@ public class TopicServiceImpl implements TopicService {
public List<TopicSubAgencyResultDTO> topicSubAgency(TokenDto tokenDto) {
String agencyId = this.getLoginUserDetails(tokenDto);
List<TopicSubAgencyResultDTO> result = new ArrayList<>();
List<TopicSubAgencyResultDTO> resultAll = new ArrayList<>();
List<String> subAgencyIdList = topicDao.getSubAgencyIdList(agencyId);
//存在下级机关
if (subAgencyIdList.size() != NumConstant.ZERO){
@ -142,7 +152,17 @@ public class TopicServiceImpl implements TopicService {
}
});
});
return result;
Map<String, List<TopicSubAgencyResultDTO>> collect = result.stream().collect(Collectors.groupingBy(TopicSubAgencyResultDTO::getAgencyId));
Set<Map.Entry<String, List<TopicSubAgencyResultDTO>>> entries = collect.entrySet();
entries.forEach(entry -> {
List<TopicSubAgencyResultDTO> value = entry.getValue();
Integer sort = value.stream().collect(Collectors.summingInt(TopicSubAgencyResultDTO::getValue));
value.forEach(v -> {
v.setSort(sort);
resultAll.add(v);
});
});
return resultAll.stream().sorted(Comparator.comparing(TopicSubAgencyResultDTO::getSort).reversed()).collect(Collectors.toList());
}
//不存在
return new ArrayList<>();

42
epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java

@ -28,9 +28,9 @@ import org.springframework.util.CollectionUtils;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* 组织能力用户相关接口
@ -169,10 +169,23 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
logger.error(String.format("各机关注册用户数缺少记录:date_id=%s,agencyId=%s",formDTO.getDateId(),dimInitResultDto.getAgencyId()));
}
}
logger.info("排序前");
for(UserSubAgencyResultDTO m:dimList){
logger.info("机关名:"+m.getName()+",总数="+m.getTotal());
}
//返回集合按照total降序排序
List<UserSubAgencyResultDTO> returnList = dimList.stream().sorted(Comparator.comparing(UserSubAgencyResultDTO::getTotal))
.collect(Collectors.toList());
return returnList;
Collections.sort(dimList, new Comparator<UserSubAgencyResultDTO>() {
@Override
public int compare(UserSubAgencyResultDTO o1, UserSubAgencyResultDTO o2) {
int i=o2.getTotal()-o1.getTotal();//降序
return i;
}
});
logger.info("排序后");
for(UserSubAgencyResultDTO m:dimList){
logger.info("机关名:"+m.getName()+",总数="+m.getTotal());
}
return dimList;
}
private List<UserSubAgencyResultDTO> initUserSubAgencyResultDTO(String myAgencyId) {
@ -273,10 +286,23 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
logger.error(String.format("直属网格注册用户数缺少记录:date_id=%s,gridId=%s",formDTO.getDateId(),dimInitResultDto.getGridId()));
}
}
logger.info("排序前");
for(UserSubGridResultDTO m:dimList){
logger.info("网格名:"+m.getName()+",总数="+m.getTotal());
}
//返回集合按照total降序排序
List<UserSubGridResultDTO> returnList = dimList.stream().sorted(Comparator.comparing(UserSubGridResultDTO::getTotal))
.collect(Collectors.toList());
return returnList;
Collections.sort(dimList, new Comparator<UserSubGridResultDTO>() {
@Override
public int compare(UserSubGridResultDTO o1, UserSubGridResultDTO o2) {
int i=o2.getTotal()-o1.getTotal();//降序
return i;
}
});
logger.info("排序后");
for(UserSubGridResultDTO m:dimList){
logger.info("网格名:"+m.getName()+",总数="+m.getTotal());
}
return dimList;
}
private List<UserSubGridResultDTO> initUserSubGridResultDTO(String myAgencyId) {
@ -399,7 +425,7 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
for(UserIncrTrendResDTO userIncrTrendResDTO:list){
String date="";
if(UserAnalysisConstant.DAY_TYPE.equals(formDTO.getType())){
date=DateUtils.getxAxisDatePattern(userIncrTrendResDTO.getDateIdOrMonthId(),".");
date=DateUtils.getxAxisDatePattern(userIncrTrendResDTO.getDateIdOrMonthId(),"/");
}else if(UserAnalysisConstant.MONTH_TYPE.equals(formDTO.getType())){
date=DateUtils.getxAxisDatePattern(userIncrTrendResDTO.getDateIdOrMonthId(),"/");
}

7
epmet-module/data-report/data-report-server/src/main/resources/mapper/group/GroupDao.xml

@ -42,8 +42,7 @@
AND da.del_flag = '0'
WHERE
fgad.del_flag = '0'
GROUP BY fgad.agency_id
ORDER BY fgad.date_id desc
AND fgad.date_id = (SELECT MAX(date_id) FROM fact_group_agency_daily WHERE del_flag = '0')
</select>
<!--获取直属网格下的小组数-->
@ -59,6 +58,8 @@
WHERE
fggd.del_flag = '0'
AND fggd.agency_id = #{agencyId}
AND fggd.date_id = (SELECT MAX(date_id) FROM fact_group_grid_daily WHERE del_flag = '0')
ORDER BY value DESC
</select>
<!--小组数量 日增长-->
@ -89,7 +90,7 @@
del_flag = '0'
AND agency_id = #{agencyId}
ORDER BY
month_id DESC
month_id DESC, value DESC
LIMIT 12
</select>

8
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java

@ -128,4 +128,12 @@ public interface DataStatisticalOpenFeignClient {
@PostMapping("/data/stats/statsproject/gridprojectstats")
Result gridProjectStats();
/**
* 初始化所有维度
*
* @return
*/
@PostMapping("/data/stats/dim/all/init")
Result initAllDims();
}

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java

@ -132,4 +132,9 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp
public Result gridProjectStats() {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "gridProjectStats");
}
@Override
public Result initAllDims() {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "initAllDims");
}
}

2
epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
data-statistical-server:
container_name: data-statistical-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.3
image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.7
ports:
- "8108:8108"
network_mode: host # 使用现有网络

2
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.3</version>
<version>0.3.7</version>
<parent>
<artifactId>data-statistical</artifactId>
<groupId>com.epmet</groupId>

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java

@ -46,7 +46,7 @@ public class DimController {
* @return
*/
@PostMapping("/all/init")
public Result initAll() {
public Result initAllDims() {
try {
dimDateService.initDimDate();
logger.info("初始化按日维度成功");

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimMonthServiceImpl.java

@ -118,16 +118,16 @@ public class DimMonthServiceImpl extends BaseServiceImpl<DimMonthDao, DimMonthEn
}
Date now = new Date();
Date startMonth;
Date targetMonth = DateUtils.addDateMonths(DateUtils.integrate(now, DateUtils.DATE_PATTERN_YYYYMM), -1);
Date startMonth;// 起始月份,包含该月份
Date targetMonth = DateUtils.integrate(now, DateUtils.DATE_PATTERN_YYYYMM);// 统计至当月,包含当月
if (lastExecRecord.getExecTime() == null) {
initMonthDim(targetMonth);
lastExecRecord.setExecTime(now);
lastExecRecordService.updateById(lastExecRecord);
} else {
startMonth = DateUtils.integrate(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYYMM);
if (targetMonth.equals(startMonth) || targetMonth.after(startMonth)) {
startMonth = DateUtils.addDateMonths(DateUtils.integrate(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYYMM), 1);
if (targetMonth.after(startMonth) || targetMonth.equals(startMonth)) {
initMonthDims(startMonth, targetMonth);
lastExecRecord.setExecTime(now);
lastExecRecordService.updateById(lastExecRecord);

20
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimQuarterServiceImpl.java

@ -120,24 +120,24 @@ public class DimQuarterServiceImpl extends BaseServiceImpl<DimQuarterDao, DimQua
lastExecRecord = lastExecRecordService.createLastExecRecord(StatsSubject.DIM_QUARTER);
}
//Date now = new Date();
Date now = DateUtils.parse("20210430", DateUtils.DATE_PATTERN_YYYYMMDD);
Date now = new Date();
//Date now = DateUtils.parse(now, DateUtils.DATE_PATTERN_YYYYMMDD);
Date targetQuarter;
Date startQuarter;
Date targetQMonth;//初始化至,包含当季
Date startQMonth;//从该季开始初始化,不包含该季
targetQuarter = DateUtils.integrate(DateUtils.addDateMonths(now, -3), DateUtils.DATE_PATTERN_YYYYMM);
targetQMonth = DateUtils.integrate(now, DateUtils.DATE_PATTERN_YYYYMM);
if (lastExecRecord.getExecTime() == null) {
// 初始化上一个季度
initQuarterDim(targetQuarter);
lastExecRecord.setExecTime(new Date());
initQuarterDim(targetQMonth);
lastExecRecord.setExecTime(now);
lastExecRecordService.updateById(lastExecRecord);
} else {
// 连续初始化多个季度
startQuarter = DateUtils.integrate(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYYMM);
if (initQuarterDim(startQuarter, targetQuarter)) {
lastExecRecord.setExecTime(new Date());
startQMonth = DateUtils.addDateMonths(DateUtils.integrate(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYYMM), 3);
if (initQuarterDim(startQMonth, targetQMonth)) {
lastExecRecord.setExecTime(now);
lastExecRecordService.updateById(lastExecRecord);
}
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimWeekServiceImpl.java

@ -117,7 +117,7 @@ public class DimWeekServiceImpl extends BaseServiceImpl<DimWeekDao, DimWeekEntit
Date now = new Date();
Date startWeekDay;
Date targetWeekDay = DateUtils.getWeekStartAndEnd(DateUtils.addDateDays(now, -7))[0];
Date targetWeekDay = DateUtils.getWeekStartAndEnd(now)[0];
if (lastExecRecord.getExecTime() == null) {
// 首次执行
@ -125,7 +125,7 @@ public class DimWeekServiceImpl extends BaseServiceImpl<DimWeekDao, DimWeekEntit
lastExecRecord.setExecTime(now);
lastExecRecordService.updateById(lastExecRecord);
} else {
startWeekDay = DateUtils.getWeekStartAndEnd(lastExecRecord.getExecTime())[0];
startWeekDay = DateUtils.addDateWeeks(DateUtils.getWeekStartAndEnd(lastExecRecord.getExecTime())[0], 1);
if (targetWeekDay.equals(startWeekDay) || targetWeekDay.after(startWeekDay)) {
initWeekDim(startWeekDay, targetWeekDay);
lastExecRecord.setExecTime(now);

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimYearServiceImpl.java

@ -120,7 +120,7 @@ public class DimYearServiceImpl extends BaseServiceImpl<DimYearDao, DimYearEntit
Date startYear;
Date targetYear;
targetYear = DateUtils.integrate(DateUtils.addDateYears(now, -1), DateUtils.DATE_PATTERN_YYYY);
targetYear = DateUtils.integrate(now, DateUtils.DATE_PATTERN_YYYY);
if (lastExecRecord.getExecTime() == null) {
// 第一次执行统计
initYearDim(targetYear);
@ -128,7 +128,7 @@ public class DimYearServiceImpl extends BaseServiceImpl<DimYearDao, DimYearEntit
// 记录最后一次统计时间
lastExecRecordService.updateById(lastExecRecord);
} else {
startYear = DateUtils.integrate(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYY);
startYear = DateUtils.addDateYears(DateUtils.integrate(lastExecRecord.getExecTime(), DateUtils.DATE_PATTERN_YYYY), 1);
if (targetYear.equals(startYear) || targetYear.after(startYear)) {
initYearDims(startYear, targetYear);
lastExecRecord.setExecTime(now);

2
epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-job-server:
container_name: epmet-job-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-job-server:0.3.10
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-job-server:0.3.11
ports:
- "8084:8084"
network_mode: host # 使用现有网络

2
epmet-module/epmet-job/epmet-job-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.10</version>
<version>0.3.11</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-job</artifactId>

9
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/DimInitService.java

@ -0,0 +1,9 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
public interface DimInitService {
Result initAllDims();
}

19
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/DimInitServiceImpl.java

@ -0,0 +1,19 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.utils.Result;
import com.epmet.feign.DataStatisticalOpenFeignClient;
import com.epmet.service.DimInitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DimInitServiceImpl implements DimInitService {
@Autowired
private DataStatisticalOpenFeignClient statsFeignClient;
@Override
public Result initAllDims() {
return statsFeignClient.initAllDims();
}
}

31
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DimInitTask.java

@ -0,0 +1,31 @@
package com.epmet.task;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.DimInitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/6/23 14:36
*/
@Slf4j
@Component("dimInitTask")
public class DimInitTask implements ITask {
@Autowired
private DimInitService dimInitService;
@Override
public void run(String params) {
log.debug("DimInitTask定时任务正在执行,参数为:{}", params);
Result result = dimInitService.initAllDims();
if (result.success()){
log.debug("DimInitTask定时任务正在执行定时任务执行成功");
}else {
log.debug("DimInitTask定时任务正在执行定时任务执行失败:" + result.getMsg());
}
}
}
Loading…
Cancel
Save