|
@@ -3,6 +3,7 @@ package com.pig4cloud.pig.statistics.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.pig4cloud.pig.statistics.Util.ConfigUtils;
|
|
|
+import com.pig4cloud.pig.statistics.Util.PageUtils;
|
|
|
import com.pig4cloud.pig.statistics.api.dto.uninstall.*;
|
|
|
import com.pig4cloud.pig.statistics.api.entity.ConfigItem;
|
|
|
import com.pig4cloud.pig.statistics.api.entity.uninstall.*;
|
|
@@ -10,13 +11,15 @@ import com.pig4cloud.pig.statistics.api.vo.uninstall.*;
|
|
|
import com.pig4cloud.pig.statistics.mapper.*;
|
|
|
import com.pig4cloud.pig.statistics.service.UninstallAnalyseService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author: wcl
|
|
@@ -42,104 +45,171 @@ public class UninstallAnalyseServiceImpl implements UninstallAnalyseService {
|
|
|
|
|
|
@Override
|
|
|
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;
|
|
|
- }
|
|
|
-
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+ String timeUnit = dto.getTimeUnit() == null ? "week" : dto.getTimeUnit();
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ if ("week".equalsIgnoreCase(timeUnit)) {
|
|
|
+ if (now.getDayOfWeek().getValue() < DayOfWeek.THURSDAY.getValue()) {
|
|
|
+ startDate = now.minusWeeks(2).with(DayOfWeek.MONDAY);
|
|
|
+ endDate = now.minusWeeks(2).with(DayOfWeek.SUNDAY);
|
|
|
+ } else {
|
|
|
+ startDate = now.minusWeeks(1).with(DayOfWeek.MONDAY);
|
|
|
+ endDate = now.minusWeeks(1).with(DayOfWeek.SUNDAY);
|
|
|
+ }
|
|
|
+ } else if ("month".equalsIgnoreCase(timeUnit)) {
|
|
|
+ if (now.getDayOfMonth() < 4) {
|
|
|
+ LocalDate lastMonth = now.minusMonths(2);
|
|
|
+ startDate = lastMonth.withDayOfMonth(1);
|
|
|
+ endDate = lastMonth.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ } else {
|
|
|
+ LocalDate lastMonth = now.minusMonths(1);
|
|
|
+ startDate = lastMonth.withDayOfMonth(1);
|
|
|
+ endDate = lastMonth.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ startDate = now;
|
|
|
+ endDate = now;
|
|
|
+ }
|
|
|
+ // 支持前端传参覆盖
|
|
|
+ if (!StringUtils.isEmpty(dto.getStartDate())) {
|
|
|
+ startDate = LocalDate.parse(dto.getStartDate());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(dto.getEndDate())) {
|
|
|
+ endDate = LocalDate.parse(dto.getEndDate());
|
|
|
+ }
|
|
|
QueryWrapper<MktTrendSummary> wrapper = new QueryWrapper<>();
|
|
|
wrapper.between("stat_date", startDate, endDate);
|
|
|
+ if (!StringUtils.isEmpty(dto.getAppId())) {
|
|
|
+ wrapper.eq("app_id", dto.getAppId());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(dto.getChannel())) {
|
|
|
+ wrapper.eq("channel", dto.getChannel());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(dto.getVersion())) {
|
|
|
+ wrapper.eq("app_version", dto.getVersion());
|
|
|
+ }
|
|
|
+ wrapper.eq("stat_cycle", timeUnit);
|
|
|
List<MktTrendSummary> list = mktTrendSummaryMapper.selectList(wrapper);
|
|
|
- UninstallTrendVO vo = new UninstallTrendVO();
|
|
|
- if (!list.isEmpty()) {
|
|
|
- // 这里只取第一个,实际可按业务聚合
|
|
|
- MktTrendSummary summary = list.get(0);
|
|
|
- vo.setStartDate(summary.getStatDate() != null ? summary.getStatDate().toString() : null);
|
|
|
- vo.setUninstallCounts(summary.getCount());
|
|
|
- vo.setUninstallRates(summary.getRate());
|
|
|
- // 其他字段可根据VO结构补充
|
|
|
+
|
|
|
+ UninstallTrendVO vo = new UninstallTrendVO();
|
|
|
+
|
|
|
+ int uninstallCount = 0, recallCount = 0;
|
|
|
+ Double uninstallRate = 0.0, recallRate = 0.0;
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ for (MktTrendSummary summary : list) {
|
|
|
+ if (summary.getTrendType() != null) {
|
|
|
+ // 卸载
|
|
|
+ if (summary.getTrendType() == 0) {
|
|
|
+ uninstallCount += summary.getCount();
|
|
|
+ uninstallRate += summary.getRate();
|
|
|
+ }
|
|
|
+ // 召回
|
|
|
+ else if (summary.getTrendType() == 1) {
|
|
|
+ recallCount += summary.getCount();
|
|
|
+ recallRate += summary.getRate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ vo.setStartDate(String.valueOf(startDate));
|
|
|
+ vo.setEndDate(String.valueOf(endDate));
|
|
|
+ vo.setUninstallCounts(uninstallCount);
|
|
|
+ vo.setRecallCounts(recallCount);
|
|
|
+ vo.setUninstallRates(uninstallRate);
|
|
|
+ vo.setRecallRates(recallRate);
|
|
|
+
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Page<UninstallTrendDtlVO> getUninstallTrendDetail(GetUninstallTrendDetailDTO dto) {
|
|
|
- // 假设dto有pageNum和pageSize字段
|
|
|
+ // 分页参数
|
|
|
int pageNum = dto.getPageNum() == null ? 1 : dto.getPageNum();
|
|
|
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
|
|
- Page<MktTrendSummary> page = new Page<>(pageNum, pageSize);
|
|
|
+
|
|
|
+ String timeUnit = StringUtils.isEmpty(dto.getTimeUnit()) ? "week" : dto.getTimeUnit();
|
|
|
QueryWrapper<MktTrendSummary> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("stat_date", dto.getStartDate());
|
|
|
- Page<MktTrendSummary> entityPage = mktTrendSummaryMapper.selectPage(page, wrapper);
|
|
|
- Page<UninstallTrendDtlVO> voPage = new Page<>();
|
|
|
- voPage.setCurrent(entityPage.getCurrent());
|
|
|
- voPage.setSize(entityPage.getSize());
|
|
|
- voPage.setTotal(entityPage.getTotal());
|
|
|
- voPage.setPages(entityPage.getPages());
|
|
|
- List<UninstallTrendDtlVO> voList = new ArrayList<>();
|
|
|
- for (MktTrendSummary summary : entityPage.getRecords()) {
|
|
|
- UninstallTrendDtlVO vo = new UninstallTrendDtlVO();
|
|
|
- vo.setStartDate(summary.getStatDate() != null ? summary.getStatDate().toString() : null);
|
|
|
- vo.setUninstallCounts(summary.getCount());
|
|
|
- // 其他字段可根据VO结构补充
|
|
|
- voList.add(vo);
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(dto.getAppId())) {
|
|
|
+ wrapper.eq("app_id", dto.getAppId());
|
|
|
}
|
|
|
- voPage.setRecords(voList);
|
|
|
- return voPage;
|
|
|
+ if (!StringUtils.isEmpty(dto.getChannel())) {
|
|
|
+ wrapper.eq("channel", dto.getChannel());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(dto.getVersion())) {
|
|
|
+ wrapper.eq("app_version", dto.getVersion());
|
|
|
+ }
|
|
|
+ wrapper.eq("stat_cycle", timeUnit);
|
|
|
+
|
|
|
+ List<MktTrendSummary> list = mktTrendSummaryMapper.selectList(wrapper);
|
|
|
+ log.info("查询结果数量: {}", list.size());
|
|
|
+
|
|
|
+ // 使用Stream API优化分组和统计逻辑
|
|
|
+ List<UninstallTrendDtlVO> voList = new ArrayList<>(list.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ summary -> getCycleKey(summary.getStatDate(), timeUnit),
|
|
|
+ TreeMap::new,
|
|
|
+ Collectors.collectingAndThen(
|
|
|
+ Collectors.toList(),
|
|
|
+ summaries -> buildUninstallTrendDtlVO(summaries, timeUnit)
|
|
|
+ )
|
|
|
+ ))
|
|
|
+ .values());
|
|
|
+
|
|
|
+ log.info("分页参数: pageNum={}, pageSize={}, voList.size={}", pageNum, pageSize, voList.size());
|
|
|
+
|
|
|
+ // 使用PageUtils工具类处理分页
|
|
|
+ return PageUtils.buildPage(voList, pageNum, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取周期分组key
|
|
|
+ */
|
|
|
+ private String getCycleKey(Date statDate, String timeUnit) {
|
|
|
+ LocalDate date = statDate.toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDate();
|
|
|
+ if ("week".equalsIgnoreCase(timeUnit)) {
|
|
|
+ return date.with(DayOfWeek.MONDAY).toString();
|
|
|
+ } else if ("month".equalsIgnoreCase(timeUnit)) {
|
|
|
+ return date.withDayOfMonth(1).toString();
|
|
|
+ } else {
|
|
|
+ return date.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建卸载趋势明细VO
|
|
|
+ */
|
|
|
+ private UninstallTrendDtlVO buildUninstallTrendDtlVO(List<MktTrendSummary> summaries, String timeUnit) {
|
|
|
+ LocalDate start = LocalDate.parse(getCycleKey(summaries.get(0).getStatDate(), timeUnit));
|
|
|
+ LocalDate end;
|
|
|
+
|
|
|
+ if ("week".equalsIgnoreCase(timeUnit)) {
|
|
|
+ end = start.with(DayOfWeek.SUNDAY);
|
|
|
+ } else if ("month".equalsIgnoreCase(timeUnit)) {
|
|
|
+ end = start.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ } else {
|
|
|
+ end = start;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用Stream API统计数据
|
|
|
+ int uninstallCount = summaries.stream()
|
|
|
+ .filter(summary -> summary.getTrendType() != null && summary.getTrendType() == 0)
|
|
|
+ .mapToInt(MktTrendSummary::getCount)
|
|
|
+ .sum();
|
|
|
+
|
|
|
+ int recallCount = summaries.stream()
|
|
|
+ .filter(summary -> summary.getTrendType() != null && summary.getTrendType() == 1)
|
|
|
+ .mapToInt(MktTrendSummary::getCount)
|
|
|
+ .sum();
|
|
|
+
|
|
|
+ UninstallTrendDtlVO vo = new UninstallTrendDtlVO();
|
|
|
+ vo.setStartDate(start.toString());
|
|
|
+ vo.setEndDate(end.toString());
|
|
|
+ vo.setUninstallCounts(uninstallCount);
|
|
|
+ vo.setRecallCounts(recallCount);
|
|
|
+
|
|
|
+ return vo;
|
|
|
}
|
|
|
-
|
|
|
- private int generateRandomCount(int min, int max) {
|
|
|
- return new Random().nextInt(max - min + 1) + min;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成时间点列表
|
|
|
- */
|
|
|
- private List<String> generateTimePoints(String startDate, String endDate, String timeUnit) {
|
|
|
- List<String> timePoints = new ArrayList<>();
|
|
|
- DateTimeFormatter formatter;
|
|
|
- int stepDays;
|
|
|
-
|
|
|
- switch (timeUnit) {
|
|
|
- case "day":
|
|
|
- formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- stepDays = 1;
|
|
|
- break;
|
|
|
- case "week":
|
|
|
- formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- stepDays = 7;
|
|
|
- break;
|
|
|
- case "month":
|
|
|
- formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
- stepDays = 30; // 简化处理
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new IllegalArgumentException("不支持的timeUnit: " + timeUnit);
|
|
|
- }
|
|
|
-
|
|
|
- LocalDate start = LocalDate.parse(startDate);
|
|
|
- LocalDate end = LocalDate.parse(endDate);
|
|
|
-
|
|
|
- LocalDate current = start;
|
|
|
- while (!current.isAfter(end)) {
|
|
|
- timePoints.add(current.format(formatter));
|
|
|
- current = current.plusDays(stepDays);
|
|
|
- }
|
|
|
-
|
|
|
- return timePoints;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 计算比率列表
|
|
|
- */
|
|
|
- private Double calculateRates(Integer numerators, int denominator) {
|
|
|
- return (double)numerators / denominator * 100;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public UninstallInsightVO getUninstallDeviceActive(GetUninstallInsightDTO dto) {
|
|
@@ -147,8 +217,17 @@ public class UninstallAnalyseServiceImpl implements UninstallAnalyseService {
|
|
|
}
|
|
|
|
|
|
public UninstallInsightVO getUninstallDeviceActiveVO(GetUninstallInsightDTO dto) {
|
|
|
+
|
|
|
+ Map<String, LocalDate> timeRangeMap = getTimeRangeMap(StringUtils.isEmpty(dto.getType()) ? "week" : dto.getType());
|
|
|
QueryWrapper<MktDeviceTime> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("type", dto.getType());
|
|
|
+ // 添加时间范围查询
|
|
|
+ wrapper.between("stat_date", timeRangeMap.get("startDate"), timeRangeMap.get("endDate"));
|
|
|
+ // 动态添加其他查询条件
|
|
|
+ if (!StringUtils.isEmpty(dto.getAppId())) wrapper.eq("app_id", dto.getAppId());
|
|
|
+ if (!StringUtils.isEmpty(dto.getChannel())) wrapper.eq("channel", dto.getChannel());
|
|
|
+ if (!StringUtils.isEmpty(dto.getVersion())) wrapper.eq("app_version", dto.getVersion());
|
|
|
+
|
|
|
List<MktDeviceTime> list = mktDeviceTimeMapper.selectList(wrapper);
|
|
|
List<InstallStockVO> voList = new ArrayList<>();
|
|
|
for (MktDeviceTime entity : list) {
|
|
@@ -164,11 +243,57 @@ public class UninstallAnalyseServiceImpl implements UninstallAnalyseService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private Map<String, LocalDate> getTimeRangeMap(String timeUnit) {
|
|
|
+
|
|
|
+ Map<String, LocalDate> timeRangeMap = new HashMap<>();
|
|
|
+ // 根据当前日期计算查询时间范围
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+ if (StringUtils.isEmpty(timeUnit)) timeUnit = "week";
|
|
|
+
|
|
|
+ if ("week".equalsIgnoreCase(timeUnit)) {
|
|
|
+ // 默认查上周:本周一~三查上上周,本周四~日查上周
|
|
|
+ if (now.getDayOfWeek().getValue() < DayOfWeek.THURSDAY.getValue()) {
|
|
|
+ startDate = now.minusWeeks(2).with(DayOfWeek.MONDAY);
|
|
|
+ endDate = now.minusWeeks(2).with(DayOfWeek.SUNDAY);
|
|
|
+ } else {
|
|
|
+ startDate = now.minusWeeks(1).with(DayOfWeek.MONDAY);
|
|
|
+ endDate = now.minusWeeks(1).with(DayOfWeek.SUNDAY);
|
|
|
+ }
|
|
|
+ } else if ("month".equalsIgnoreCase(timeUnit)) {
|
|
|
+ // 查上月:本月1-3号查上上月,本月4号及以后查上月
|
|
|
+ if (now.getDayOfMonth() < 4) {
|
|
|
+ LocalDate lastMonth = now.minusMonths(2);
|
|
|
+ startDate = lastMonth.withDayOfMonth(1);
|
|
|
+ endDate = lastMonth.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ } else {
|
|
|
+ LocalDate lastMonth = now.minusMonths(1);
|
|
|
+ startDate = lastMonth.withDayOfMonth(1);
|
|
|
+ endDate = lastMonth.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 默认查上周
|
|
|
+ if (now.getDayOfWeek().getValue() < DayOfWeek.THURSDAY.getValue()) {
|
|
|
+ startDate = now.minusWeeks(2).with(DayOfWeek.MONDAY);
|
|
|
+ endDate = now.minusWeeks(2).with(DayOfWeek.SUNDAY);
|
|
|
+ } else {
|
|
|
+ startDate = now.minusWeeks(1).with(DayOfWeek.MONDAY);
|
|
|
+ endDate = now.minusWeeks(1).with(DayOfWeek.SUNDAY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ timeRangeMap.put("startDate", startDate);
|
|
|
+ timeRangeMap.put("endDate", endDate);
|
|
|
+ return timeRangeMap;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public UninstallBeforeVO uninstallBefore(GetUninstallInsightDTO dto) {
|
|
|
// 1. 卸载时间差分布
|
|
|
QueryWrapper<MktDeviceTime> timeWrapper = new QueryWrapper<>();
|
|
|
timeWrapper.eq("type", dto.getType());
|
|
|
+ if (!StringUtils.isEmpty(dto.getAppId())) timeWrapper.eq("app_id", dto.getAppId());
|
|
|
+ if (!StringUtils.isEmpty(dto.getChannel())) timeWrapper.eq("channel", dto.getChannel());
|
|
|
+ if (!StringUtils.isEmpty(dto.getVersion())) timeWrapper.eq("app_version", dto.getVersion());
|
|
|
List<MktDeviceTime> timeList = mktDeviceTimeMapper.selectList(timeWrapper);
|
|
|
List<UninstallTimeDiffVO> timeDiffs = new ArrayList<>();
|
|
|
for (MktDeviceTime entity : timeList) {
|
|
@@ -182,53 +307,101 @@ public class UninstallAnalyseServiceImpl implements UninstallAnalyseService {
|
|
|
// 2. 卸载前7天使用次数分布
|
|
|
QueryWrapper<MktDeviceCount> countWrapper = new QueryWrapper<>();
|
|
|
countWrapper.eq("type", dto.getType());
|
|
|
+ if (!StringUtils.isEmpty(dto.getAppId())) countWrapper.eq("app_id", dto.getAppId());
|
|
|
+ if (!StringUtils.isEmpty(dto.getChannel())) countWrapper.eq("channel", dto.getChannel());
|
|
|
+ if (!StringUtils.isEmpty(dto.getVersion())) countWrapper.eq("app_version", dto.getVersion());
|
|
|
List<MktDeviceCount> countList = mktDeviceCountMapper.selectList(countWrapper);
|
|
|
List<UninstallBeforeSevenVO> beforeSevens = new ArrayList<>();
|
|
|
for (MktDeviceCount entity : countList) {
|
|
|
UninstallBeforeSevenVO vo = new UninstallBeforeSevenVO();
|
|
|
- ConfigItem configValue = ConfigUtils.getConfigValue("Count_range", entity.getCountRange());
|
|
|
+ ConfigItem configValue = ConfigUtils.getConfigValue("Count_range", String.valueOf(entity.getCountRange()));
|
|
|
|
|
|
vo.setTime(configValue.getLabel());
|
|
|
vo.setCount(entity.getNum());
|
|
|
vo.setRate(entity.getRate());
|
|
|
beforeSevens.add(vo);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ UninstallBeforeVO result = new UninstallBeforeVO();
|
|
|
+ result.setUninstallTimeDiffs(timeDiffs);
|
|
|
+ result.setUninstallBeforeSevens(beforeSevens);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 体验干扰
|
|
|
+ *
|
|
|
+ * @param dto
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public UninstallBeforeInterfereVO uninstallInterfere(GetUninstallInsightDTO dto) {
|
|
|
+
|
|
|
+ UninstallBeforeInterfereVO result = new UninstallBeforeInterfereVO();
|
|
|
+ ConfigItem configValue = null;
|
|
|
+ if (!StringUtils.isEmpty(dto.getType())){
|
|
|
+ configValue = ConfigUtils.getConfigValue("Interfere_type", dto.getType());
|
|
|
+ }
|
|
|
+ List<Map<String, Integer>> value = new ArrayList<>();
|
|
|
// 3. 卸载前干扰指标
|
|
|
QueryWrapper<MktDeviceInterfere> interfereWrapper = new QueryWrapper<>();
|
|
|
+ interfereWrapper.eq("interfere_type", dto.getType());
|
|
|
+ if (!StringUtils.isEmpty(dto.getAppId())) interfereWrapper.eq("app_id", dto.getAppId());
|
|
|
+ if (!StringUtils.isEmpty(dto.getChannel())) interfereWrapper.eq("channel", dto.getChannel());
|
|
|
+ if (!StringUtils.isEmpty(dto.getVersion())) interfereWrapper.eq("app_version", dto.getVersion());
|
|
|
List<MktDeviceInterfere> interfereList = mktDeviceInterfereMapper.selectList(interfereWrapper);
|
|
|
Map<String, Map<String, Integer>> interfereMap = new LinkedHashMap<>();
|
|
|
for (MktDeviceInterfere entity : interfereList) {
|
|
|
- ConfigItem configValue = ConfigUtils.getConfigValue("Count_range", entity.getCountRange());
|
|
|
- interfereMap.computeIfAbsent(entity.getInterfereType(), k -> new LinkedHashMap<>())
|
|
|
- .put(configValue.getLabel(), entity.getNum());
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ ConfigItem countValue = ConfigUtils.getConfigValue("Count_range", String.valueOf(entity.getCountRange()));
|
|
|
+ map.put(countValue.getLabel(), entity.getNum());
|
|
|
+ value.add(map);
|
|
|
+ }
|
|
|
+ if (configValue != null) {
|
|
|
+ result.setType(configValue.getLabel());
|
|
|
+ }else {
|
|
|
+ result.setType("");
|
|
|
}
|
|
|
- List<UninstallBeforeInterfereVO> interfereVOList = new ArrayList<>();
|
|
|
- for (Map.Entry<String, Map<String, Integer>> entry : interfereMap.entrySet()) {
|
|
|
- UninstallBeforeInterfereVO vo = new UninstallBeforeInterfereVO();
|
|
|
- vo.setType(entry.getKey());
|
|
|
- vo.setValue(entry.getValue());
|
|
|
- interfereVOList.add(vo);
|
|
|
+ result.setValue(value);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 行为还原
|
|
|
+ *
|
|
|
+ * @param dto
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public UninstallBeforeActionVO uninstallAction(GetUninstallInsightDTO dto) {
|
|
|
+
|
|
|
+ UninstallBeforeActionVO result = new UninstallBeforeActionVO();
|
|
|
+ ConfigItem configValue = null;
|
|
|
+ if (!StringUtils.isEmpty(dto.getType())){
|
|
|
+ configValue = ConfigUtils.getConfigValue("Action_type", dto.getType());
|
|
|
}
|
|
|
// 4. 卸载前行为还原
|
|
|
QueryWrapper<MktDeviceAction> actionWrapper = new QueryWrapper<>();
|
|
|
+ actionWrapper.eq("actionType", dto.getType());
|
|
|
+ if (!StringUtils.isEmpty(dto.getAppId())) actionWrapper.eq("app_id", dto.getAppId());
|
|
|
+ if (!StringUtils.isEmpty(dto.getChannel())) actionWrapper.eq("channel", dto.getChannel());
|
|
|
+ if (!StringUtils.isEmpty(dto.getVersion())) actionWrapper.eq("app_version", dto.getVersion());
|
|
|
List<MktDeviceAction> actionList = mktDeviceActionMapper.selectList(actionWrapper);
|
|
|
- Map<String, Map<String, Integer>> actionMap = new LinkedHashMap<>();
|
|
|
+ List<Map<String, Integer>> list = new ArrayList<>();
|
|
|
for (MktDeviceAction entity : actionList) {
|
|
|
- actionMap.computeIfAbsent(entity.getActionType(), k -> new LinkedHashMap<>())
|
|
|
- .put(entity.getActionValue(), entity.getTriggerCount());
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ ConfigItem actionType = ConfigUtils.getConfigValue("Action_type", String.valueOf(entity.getActionType()));
|
|
|
+ map.put(actionType.getLabel(), entity.getTriggerCount());
|
|
|
+
|
|
|
+ list.add(map);
|
|
|
}
|
|
|
- List<UninstallBeforeActionVO> actionVOList = new ArrayList<>();
|
|
|
- for (Map.Entry<String, Map<String, Integer>> entry : actionMap.entrySet()) {
|
|
|
- UninstallBeforeActionVO vo = new UninstallBeforeActionVO();
|
|
|
- vo.setActionType(entry.getKey());
|
|
|
- vo.setValue(entry.getValue());
|
|
|
- actionVOList.add(vo);
|
|
|
+ result.setValue(list);
|
|
|
+
|
|
|
+ if (configValue != null) {
|
|
|
+ result.setActionType(configValue.getLabel());
|
|
|
+ }else {
|
|
|
+ result.setActionType("");
|
|
|
}
|
|
|
- UninstallBeforeVO result = new UninstallBeforeVO();
|
|
|
- result.setUninstallTimeDiffs(timeDiffs);
|
|
|
- result.setUninstallBeforeSevens(beforeSevens);
|
|
|
- result.setUninstallBeforeInterferences(interfereVOList);
|
|
|
- result.setUninstallBeforeActions(actionVOList);
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|