|
@@ -2,7 +2,9 @@ package com.pig4cloud.pig.statistics.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.pig4cloud.pig.statistics.Util.ConfigUtils;
|
|
import com.pig4cloud.pig.statistics.api.dto.uninstall.*;
|
|
import com.pig4cloud.pig.statistics.api.dto.uninstall.*;
|
|
|
|
+import com.pig4cloud.pig.statistics.api.entity.ConfigItem;
|
|
import com.pig4cloud.pig.statistics.api.entity.uninstall.*;
|
|
import com.pig4cloud.pig.statistics.api.entity.uninstall.*;
|
|
import com.pig4cloud.pig.statistics.api.vo.uninstall.*;
|
|
import com.pig4cloud.pig.statistics.api.vo.uninstall.*;
|
|
import com.pig4cloud.pig.statistics.mapper.*;
|
|
import com.pig4cloud.pig.statistics.mapper.*;
|
|
@@ -11,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.time.DayOfWeek;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -39,8 +42,18 @@ public class UninstallAnalyseServiceImpl implements UninstallAnalyseService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public UninstallTrendVO getUninstallTrend(GetUninstallTrendDTO dto) {
|
|
public UninstallTrendVO getUninstallTrend(GetUninstallTrendDTO dto) {
|
|
|
|
+ LocalDate startDate, endDate;
|
|
|
|
+ if (dto.getStartDate() == null) {
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
+ startDate = now.minusWeeks(1).with(DayOfWeek.MONDAY);
|
|
|
|
+ endDate = now.minusWeeks(1).with(DayOfWeek.SUNDAY);
|
|
|
|
+ } else {
|
|
|
|
+ startDate = LocalDate.parse(dto.getStartDate());
|
|
|
|
+ endDate = dto.getEndDate() != null ? LocalDate.parse(dto.getEndDate()) : startDate;
|
|
|
|
+ }
|
|
|
|
+
|
|
QueryWrapper<MktTrendSummary> wrapper = new QueryWrapper<>();
|
|
QueryWrapper<MktTrendSummary> wrapper = new QueryWrapper<>();
|
|
- wrapper.eq("stat_date", dto.getStartDate());
|
|
|
|
|
|
+ wrapper.between("stat_date", startDate, endDate);
|
|
List<MktTrendSummary> list = mktTrendSummaryMapper.selectList(wrapper);
|
|
List<MktTrendSummary> list = mktTrendSummaryMapper.selectList(wrapper);
|
|
UninstallTrendVO vo = new UninstallTrendVO();
|
|
UninstallTrendVO vo = new UninstallTrendVO();
|
|
if (!list.isEmpty()) {
|
|
if (!list.isEmpty()) {
|
|
@@ -135,12 +148,13 @@ public class UninstallAnalyseServiceImpl implements UninstallAnalyseService {
|
|
|
|
|
|
public UninstallInsightVO getUninstallDeviceActiveVO(GetUninstallInsightDTO dto) {
|
|
public UninstallInsightVO getUninstallDeviceActiveVO(GetUninstallInsightDTO dto) {
|
|
QueryWrapper<MktDeviceTime> wrapper = new QueryWrapper<>();
|
|
QueryWrapper<MktDeviceTime> wrapper = new QueryWrapper<>();
|
|
- wrapper.eq("type", "insight");
|
|
|
|
|
|
+ wrapper.eq("type", dto.getType());
|
|
List<MktDeviceTime> list = mktDeviceTimeMapper.selectList(wrapper);
|
|
List<MktDeviceTime> list = mktDeviceTimeMapper.selectList(wrapper);
|
|
List<InstallStockVO> voList = new ArrayList<>();
|
|
List<InstallStockVO> voList = new ArrayList<>();
|
|
for (MktDeviceTime entity : list) {
|
|
for (MktDeviceTime entity : list) {
|
|
InstallStockVO vo = new InstallStockVO();
|
|
InstallStockVO vo = new InstallStockVO();
|
|
- vo.setTime(entity.getTimeRange());
|
|
|
|
|
|
+ ConfigItem configValue = ConfigUtils.getConfigValue("Time-range", entity.getTimeRange());
|
|
|
|
+ vo.setTime(configValue.getLabel());
|
|
vo.setUninstallCount(entity.getDeviceCount());
|
|
vo.setUninstallCount(entity.getDeviceCount());
|
|
vo.setUninstallRate(entity.getRate());
|
|
vo.setUninstallRate(entity.getRate());
|
|
voList.add(vo);
|
|
voList.add(vo);
|
|
@@ -154,24 +168,27 @@ public class UninstallAnalyseServiceImpl implements UninstallAnalyseService {
|
|
public UninstallBeforeVO uninstallBefore(GetUninstallInsightDTO dto) {
|
|
public UninstallBeforeVO uninstallBefore(GetUninstallInsightDTO dto) {
|
|
// 1. 卸载时间差分布
|
|
// 1. 卸载时间差分布
|
|
QueryWrapper<MktDeviceTime> timeWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MktDeviceTime> timeWrapper = new QueryWrapper<>();
|
|
- timeWrapper.eq("type", "before");
|
|
|
|
|
|
+ timeWrapper.eq("type", dto.getType());
|
|
List<MktDeviceTime> timeList = mktDeviceTimeMapper.selectList(timeWrapper);
|
|
List<MktDeviceTime> timeList = mktDeviceTimeMapper.selectList(timeWrapper);
|
|
List<UninstallTimeDiffVO> timeDiffs = new ArrayList<>();
|
|
List<UninstallTimeDiffVO> timeDiffs = new ArrayList<>();
|
|
for (MktDeviceTime entity : timeList) {
|
|
for (MktDeviceTime entity : timeList) {
|
|
UninstallTimeDiffVO vo = new UninstallTimeDiffVO();
|
|
UninstallTimeDiffVO vo = new UninstallTimeDiffVO();
|
|
- vo.setTime(entity.getTimeRange());
|
|
|
|
|
|
+ ConfigItem configValue = ConfigUtils.getConfigValue("Time-range", entity.getTimeRange());
|
|
|
|
+ vo.setTime(configValue.getLabel());
|
|
vo.setCount(entity.getDeviceCount());
|
|
vo.setCount(entity.getDeviceCount());
|
|
vo.setRate(entity.getRate());
|
|
vo.setRate(entity.getRate());
|
|
timeDiffs.add(vo);
|
|
timeDiffs.add(vo);
|
|
}
|
|
}
|
|
// 2. 卸载前7天使用次数分布
|
|
// 2. 卸载前7天使用次数分布
|
|
QueryWrapper<MktDeviceCount> countWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MktDeviceCount> countWrapper = new QueryWrapper<>();
|
|
- countWrapper.eq("type", "before");
|
|
|
|
|
|
+ countWrapper.eq("type", dto.getType());
|
|
List<MktDeviceCount> countList = mktDeviceCountMapper.selectList(countWrapper);
|
|
List<MktDeviceCount> countList = mktDeviceCountMapper.selectList(countWrapper);
|
|
List<UninstallBeforeSevenVO> beforeSevens = new ArrayList<>();
|
|
List<UninstallBeforeSevenVO> beforeSevens = new ArrayList<>();
|
|
for (MktDeviceCount entity : countList) {
|
|
for (MktDeviceCount entity : countList) {
|
|
UninstallBeforeSevenVO vo = new UninstallBeforeSevenVO();
|
|
UninstallBeforeSevenVO vo = new UninstallBeforeSevenVO();
|
|
- vo.setTime(entity.getCountRange());
|
|
|
|
|
|
+ ConfigItem configValue = ConfigUtils.getConfigValue("Count_range", entity.getCountRange());
|
|
|
|
+
|
|
|
|
+ vo.setTime(configValue.getLabel());
|
|
vo.setCount(entity.getNum());
|
|
vo.setCount(entity.getNum());
|
|
vo.setRate(entity.getRate());
|
|
vo.setRate(entity.getRate());
|
|
beforeSevens.add(vo);
|
|
beforeSevens.add(vo);
|
|
@@ -181,8 +198,9 @@ public class UninstallAnalyseServiceImpl implements UninstallAnalyseService {
|
|
List<MktDeviceInterfere> interfereList = mktDeviceInterfereMapper.selectList(interfereWrapper);
|
|
List<MktDeviceInterfere> interfereList = mktDeviceInterfereMapper.selectList(interfereWrapper);
|
|
Map<String, Map<String, Integer>> interfereMap = new LinkedHashMap<>();
|
|
Map<String, Map<String, Integer>> interfereMap = new LinkedHashMap<>();
|
|
for (MktDeviceInterfere entity : interfereList) {
|
|
for (MktDeviceInterfere entity : interfereList) {
|
|
|
|
+ ConfigItem configValue = ConfigUtils.getConfigValue("Count_range", entity.getCountRange());
|
|
interfereMap.computeIfAbsent(entity.getInterfereType(), k -> new LinkedHashMap<>())
|
|
interfereMap.computeIfAbsent(entity.getInterfereType(), k -> new LinkedHashMap<>())
|
|
- .put(entity.getCountRange(), entity.getNum());
|
|
|
|
|
|
+ .put(configValue.getLabel(), entity.getNum());
|
|
}
|
|
}
|
|
List<UninstallBeforeInterfereVO> interfereVOList = new ArrayList<>();
|
|
List<UninstallBeforeInterfereVO> interfereVOList = new ArrayList<>();
|
|
for (Map.Entry<String, Map<String, Integer>> entry : interfereMap.entrySet()) {
|
|
for (Map.Entry<String, Map<String, Integer>> entry : interfereMap.entrySet()) {
|