|
@@ -3,13 +3,11 @@ package com.tzld.longarticle.recommend.server.service;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.AccountBusinessTypeEnum;
|
|
|
-import com.tzld.longarticle.recommend.server.model.MiniprogramTaskParam;
|
|
|
-import com.tzld.longarticle.recommend.server.model.NewSortStrategyExport;
|
|
|
-import com.tzld.longarticle.recommend.server.model.ProduceAuditLayoutContentObjVO;
|
|
|
-import com.tzld.longarticle.recommend.server.model.PublishContentParam;
|
|
|
+import com.tzld.longarticle.recommend.server.model.*;
|
|
|
import com.tzld.longarticle.recommend.server.repository.aigc.*;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.ArticleDetailInfoRepository;
|
|
@@ -445,16 +443,18 @@ public class DataDashboardService {
|
|
|
|
|
|
// 先删除掉已存在的dateStr数据
|
|
|
HttpEntity<Object> queryEntity = new HttpEntity<>(httpHeaders);
|
|
|
+ int deleteRowNum = rowNum < 20 ? startRowIndex + dateStrList.size() * rowNum : startRowIndex + (rowNum * 2);
|
|
|
ResponseEntity<String> queryResponseEntity = restTemplate.exchange(
|
|
|
String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/values/%s!A"
|
|
|
- + startRowIndex + ":A" + (startRowIndex + (rowNum * 2)), sheetToken, sheetId),
|
|
|
+ + startRowIndex + ":A" + deleteRowNum, sheetToken, sheetId),
|
|
|
HttpMethod.GET, queryEntity, String.class);
|
|
|
JSONArray values = JSON.parseObject(queryResponseEntity.getBody())
|
|
|
.getJSONObject("data")
|
|
|
.getJSONObject("valueRange")
|
|
|
.getJSONArray("values");
|
|
|
int count = 0;
|
|
|
- if (!values.isEmpty() && Objects.nonNull(values.get(0))
|
|
|
+ if (!values.isEmpty() && Objects.nonNull(values.get(0)) && !((JSONArray) values.get(0)).isEmpty()
|
|
|
+ && Objects.nonNull(((JSONArray) values.get(0)).get(0))
|
|
|
&& dateStrList.contains(((JSONArray) values.get(0)).get(0).toString())) {
|
|
|
for (Object value : values) {
|
|
|
if (((JSONArray) value).get(0) != null) {
|
|
@@ -495,11 +495,11 @@ public class DataDashboardService {
|
|
|
.builder()
|
|
|
.put("valueRange", MapBuilder
|
|
|
.builder()
|
|
|
- .put("range", String.format("%s!A" + startRow + ":AZ", sheetId) + (partition.size() + startRow - 1))
|
|
|
+ .put("range", String.format("%s!A" + startRow + ":CH", sheetId) + (partition.size() + startRow - 1))
|
|
|
.put("values", partition)
|
|
|
.build())
|
|
|
.build(), httpHeaders);
|
|
|
- restTemplate.exchange(String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/values_prepend",
|
|
|
+ ResponseEntity<String> response = restTemplate.exchange(String.format("https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/%s/values_prepend",
|
|
|
sheetToken),
|
|
|
HttpMethod.POST, postEntity, String.class);
|
|
|
startRow += partition.size();
|
|
@@ -555,4 +555,612 @@ public class DataDashboardService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @XxlJob("scheduleExportIntermediateIndicators")
|
|
|
+ public ReturnT<String> scheduleIntermediateIndicatorsExport(String param) {
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(null, 3);
|
|
|
+ for (String date : dateStrList) {
|
|
|
+ exportFeishuIntermediateIndicators(date, dateStrList, sheetToken, "OuaLWV");
|
|
|
+ }
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void intermediateIndicatorsExport(String dateStr) {
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(dateStr, 3);
|
|
|
+ for (String date : dateStrList) {
|
|
|
+ exportFeishuIntermediateIndicators(date, dateStrList, sheetToken, "OuaLWV");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportFeishuIntermediateIndicators(String dateStr, List<String> dateStrList, String sheetToken, String sheetId) {
|
|
|
+ List<IntermediateIndicatorsExport> newContentsYesData = intermediateIndicatorsData(dateStr);
|
|
|
+ if (CollectionUtil.isEmpty(newContentsYesData)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ long dateStrLong = DateUtils.dateStrToTimestamp(dateStr, "yyyyMMdd");
|
|
|
+ List<String> dateStrs = dateStrList.stream().filter(o -> {
|
|
|
+ long date = DateUtils.dateStrToTimestamp(o, "yyyyMMdd");
|
|
|
+ return date >= dateStrLong;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ int rowNum = newContentsYesData.size();
|
|
|
+ List<List<Object>> rows = new ArrayList<>();
|
|
|
+ Field[] fields = IntermediateIndicatorsExport.class.getDeclaredFields();
|
|
|
+ for (IntermediateIndicatorsExport datum : newContentsYesData) {
|
|
|
+ List<Object> rowDatas = new ArrayList<>();
|
|
|
+ rows.add(rowDatas);
|
|
|
+
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true);
|
|
|
+ try {
|
|
|
+ rowDatas.add(field.get(datum));
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ log.error("获取值出错:{}", field.getName());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Pair<String, String>> styles = Arrays
|
|
|
+ .asList(
|
|
|
+ Pair.of("V", "#,##0.00"),
|
|
|
+ Pair.of("AH", "#,##0.00"),
|
|
|
+ Pair.of("AM", "#,##0.00"),
|
|
|
+ Pair.of("BB", "#,##0.00"),
|
|
|
+ Pair.of("BK", "#,##0.00"),
|
|
|
+ Pair.of("F", "0.00%"),
|
|
|
+ Pair.of("O", "0.00%"),
|
|
|
+ Pair.of("P", "0.00%"),
|
|
|
+ Pair.of("Q", "0.00%"),
|
|
|
+ Pair.of("R", "0.00%"),
|
|
|
+ Pair.of("W", "0.00%"),
|
|
|
+ Pair.of("X", "0.00%"),
|
|
|
+ Pair.of("Y", "0.00%"),
|
|
|
+ Pair.of("Z", "0.00%"),
|
|
|
+ Pair.of("AE", "0.00%"),
|
|
|
+ Pair.of("AF", "0.00%"),
|
|
|
+ Pair.of("AG", "0.00%"),
|
|
|
+ Pair.of("AN", "0.00%"),
|
|
|
+ Pair.of("AO", "0.00%"),
|
|
|
+ Pair.of("AP", "0.00%"),
|
|
|
+ Pair.of("AQ", "0.00%"),
|
|
|
+ Pair.of("AV", "0.00%"),
|
|
|
+ Pair.of("AW", "0.00%"),
|
|
|
+ Pair.of("AX", "0.00%"),
|
|
|
+ Pair.of("BC", "0.00%"),
|
|
|
+ Pair.of("BD", "0.00%"),
|
|
|
+ Pair.of("BE", "0.00%"),
|
|
|
+ Pair.of("BF", "0.00%"),
|
|
|
+ Pair.of("BL", "0.00%"),
|
|
|
+ Pair.of("BM", "0.00%"),
|
|
|
+ Pair.of("BN", "0.00%"),
|
|
|
+ Pair.of("BO", "0.00%")
|
|
|
+ );
|
|
|
+
|
|
|
+ doSendFeishuSheet(dateStrs, sheetToken, sheetId, rowNum, rows, 3, styles);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<IntermediateIndicatorsExport> intermediateIndicatorsData(String dateStr) {
|
|
|
+ List<IntermediateIndicatorsExport> result = buildIntermediateIndicatorsData(dateStr);
|
|
|
+ Map<String, IntermediateIndicatorsExport> resultMap = result.stream().collect(Collectors.toMap(
|
|
|
+ IntermediateIndicatorsExport::getType, o -> o));
|
|
|
+ List<String> small = Arrays.asList("gh_084a485e859a", "gh_183d80deffb8", "gh_1b27dd1beeca", "gh_29074b51f2b7",
|
|
|
+ "gh_4568b5a7e2fe", "gh_5ff48e9fb9ef", "gh_6d9f36e3a7be", "gh_72bace6b3059", "gh_7b4a5f86d68c",
|
|
|
+ "gh_9f8dc5b0c74e", "gh_b676b7ad9b74", "gh_ee78360d06f5", "gh_f25b5fb01977", "gh_f902cea89e48");
|
|
|
+ Long dateStart = DateUtils.getStartOfDay(dateStr, "yyyyMMdd");
|
|
|
+ Long dateEnd = DateUtils.getEndOfDay(dateStr, "yyyyMMdd");
|
|
|
+ long timestamp = DateUtils.dateStrToTimestamp(dateStr, "yyyyMMdd");
|
|
|
+ String dateStrS = DateUtils.timestampToYMDStr(timestamp, "yyyy-MM-dd");
|
|
|
+ List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByUpdateTimeLessThanEqual(dateStrS);
|
|
|
+ Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap = accountAvgInfoList.stream()
|
|
|
+ .filter(o -> Objects.nonNull(o.getReadAvg()) && o.getReadAvg() > 0 && o.getFans() > 1000)
|
|
|
+ .collect(Collectors.groupingBy(AccountAvgInfo::getGhId, Collectors.groupingBy(AccountAvgInfo::getUpdateTime,
|
|
|
+ Collectors.toMap(AccountAvgInfo::getPosition, o -> o))));
|
|
|
+ List<String> ghIds = accountAvgInfoList.stream().map(AccountAvgInfo::getGhId).distinct().collect(Collectors.toList());
|
|
|
+ List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeLessThanAndTypeEquals(ghIds, dateEnd, "9");
|
|
|
+ Map<String, Article> articleMap = articleList.stream().collect(Collectors.toMap(Article::getWxSn, o -> o));
|
|
|
+ List<Article> todayPublish = articleList.stream().filter(o -> o.getUpdateTime() > dateStart).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(todayPublish)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ Map<String, List<Article>> hisPublishMap = articleList.stream().collect(Collectors.groupingBy(Article::getTitle));
|
|
|
+ List<String> wxSnList = articleList.stream().map(Article::getWxSn).distinct().collect(Collectors.toList());
|
|
|
+ List<ArticleDetailInfo> articleDetailInfoList = new ArrayList<>();
|
|
|
+ for (List<String> partitions : Lists.partition(wxSnList, 1000)) {
|
|
|
+ articleDetailInfoList.addAll(articleDetailInfoRepository.getAllByWxSnIn(partitions));
|
|
|
+ }
|
|
|
+ Map<String, List<ArticleDetailInfo>> articleDetailInfoMap = articleDetailInfoList.stream()
|
|
|
+ .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
|
|
|
+ List<PublishSortLog> publishSortLogList = publishSortLogRepository.findByDateStrGreaterThanEqual(dateStr);
|
|
|
+ Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap = publishSortLogList.stream()
|
|
|
+ .collect(Collectors.groupingBy(PublishSortLog::getGhId,
|
|
|
+ Collectors.groupingBy(PublishSortLog::getDateStr, Collectors.toMap(
|
|
|
+ PublishSortLog::getIndex, o -> o, (existing, replacement) -> replacement
|
|
|
+ ))));
|
|
|
+ List<NewSortStrategyExport> newSortStrategyExportList = getNewSortStrategyExportList(todayPublish,
|
|
|
+ articleDetailInfoMap, accountAvgInfoIndexMap);
|
|
|
+
|
|
|
+ List<Article> futurePublishList = articleRepository.getByUpdateTimeGreaterThanAndTypeEquals(dateEnd, "9");
|
|
|
+ Map<String, List<Article>> futurePublishMap = futurePublishList.stream().collect(Collectors.groupingBy(Article::getTitle));
|
|
|
+
|
|
|
+ Map<String, List<String>> titleTypeMap = new HashMap<>();
|
|
|
+ Map<String, Integer> scoreHisPublishTimeMap = new HashMap<>();
|
|
|
+ Map<String, Map<Integer, List<String>>> titleTypePoolMap = new HashMap<>();
|
|
|
+ Map<String, Set<String>> wxsnHisDistinctSetMap = new HashMap<>();
|
|
|
+ for (NewSortStrategyExport data : newSortStrategyExportList) {
|
|
|
+ String type = getArticleType(data, small);
|
|
|
+ Article article = articleMap.get(data.getWxSn());
|
|
|
+ IntermediateIndicatorsExport item = resultMap.get(type);
|
|
|
+ List<Article> list = hisPublishMap.get(data.getTitle());
|
|
|
+ list = list.stream().filter(publish -> publish.getUpdateTime() < (article.getUpdateTime() - 3600 * 8))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Integer poolLevel = getArticlePoolLevel(data, list, small);
|
|
|
+ List<String> titles = titleTypeMap.computeIfAbsent(type, k -> new ArrayList<>());
|
|
|
+ Map<Integer, List<String>> titlePoolMap = titleTypePoolMap.computeIfAbsent(type, k -> new HashMap<>());
|
|
|
+ List<String> poolTitles = titlePoolMap.computeIfAbsent(poolLevel, k -> new ArrayList<>());
|
|
|
+
|
|
|
+ // 发布情况
|
|
|
+ setPublishSituation(item, type, titleTypeMap, titleTypePoolMap, poolLevel, data);
|
|
|
+ // 发布表现
|
|
|
+ setPublishPerformance(item, data, publishSortLogMap);
|
|
|
+ // 发布依赖表现
|
|
|
+ setPublishSourcePerformance(item, accountAvgInfoIndexMap, articleDetailInfoMap, publishSortLogMap,
|
|
|
+ type, scoreHisPublishTimeMap, wxsnHisDistinctSetMap, list);
|
|
|
+ // 发布未来表现
|
|
|
+ setPublishFuturePerformance(item, data, poolLevel, futurePublishMap, publishSortLogMap, small);
|
|
|
+
|
|
|
+ titles.add(data.getTitle());
|
|
|
+ poolTitles.add(data.getTitle());
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPublishFuturePerformance(IntermediateIndicatorsExport item, NewSortStrategyExport data, Integer poolLevel,
|
|
|
+ Map<String, List<Article>> futurePublishMap,
|
|
|
+ Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap,
|
|
|
+ List<String> small) {
|
|
|
+ List<Article> futurePublishList = futurePublishMap.get(data.getTitle());
|
|
|
+ if (CollectionUtils.isEmpty(futurePublishList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int futurePoolLevel = getArticlePoolLevel(data, futurePublishList, small);
|
|
|
+ if (futurePoolLevel > poolLevel) {
|
|
|
+ if (futurePoolLevel == 2) {
|
|
|
+ item.setPromotionCountL2(item.getPromotionCountL2() + 1);
|
|
|
+ item.setPromotionRateL2((item.getPromotionCountL2() * 1.0) / item.getActualArticleReleaseCount());
|
|
|
+ } else if (futurePoolLevel == 3) {
|
|
|
+ item.setPromotionCountL3(item.getPromotionCountL3() + 1);
|
|
|
+ item.setPromotionRateL3((item.getPromotionCountL3() * 1.0) / item.getActualArticleReleaseCount());
|
|
|
+ } else if (futurePoolLevel == 4) {
|
|
|
+ item.setPromotionCountL4(item.getPromotionCountL4() + 1);
|
|
|
+ item.setPromotionRateL4((item.getPromotionCountL4() * 1.0) / item.getActualArticleReleaseCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setT1DayFirstLayerUV(item.getT1DayFirstLayerUV() + data.getSecondFirstLevel());
|
|
|
+ item.setT1DayT0FissionUV(item.getT1DayT0FissionUV() + data.getSecondFission0());
|
|
|
+ item.setT2DayFirstLayerUV(item.getT2DayFirstLayerUV() + data.getThirdFirstLevel());
|
|
|
+ item.setT2DayT0FissionUV(item.getT2DayT0FissionUV() + data.getThirdFission0());
|
|
|
+ item.setT1DayAccountArticleRelevanceAvg(item.getAccountArticleRelevanceAvg());
|
|
|
+ item.setT2DayAccountArticleRelevanceAvg(item.getAccountArticleRelevanceAvg());
|
|
|
+ item.setT1DayViewBase(item.getViewBase());
|
|
|
+ item.setT2DayViewBase(item.getViewBase());
|
|
|
+ item.setT1DayViewCount(item.getViewCount());
|
|
|
+ item.setT2DayViewCount(item.getViewCount());
|
|
|
+ double t1DayAverageViewToBaseRatio = item.getT1DayAverageViewToBaseRatio();
|
|
|
+ if (data.getViewCount() > 0 && data.getAvgViewCount() > 0) {
|
|
|
+ double t1DayViewToBaseRatio = data.getViewCount() / data.getAvgViewCount();
|
|
|
+ t1DayAverageViewToBaseRatio = (t1DayAverageViewToBaseRatio * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t1DayViewToBaseRatio) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setT1DayAverageViewToBaseRatio(t1DayAverageViewToBaseRatio);
|
|
|
+ double t1DayAverageMiniAppOpenRate = item.getT1DayAverageMiniAppOpenRate();
|
|
|
+ if (data.getSecondFirstLevel() > 0 && data.getAvgViewCount() > 0) {
|
|
|
+ double t1DayMiniAppOpenRate = data.getSecondFirstLevel() / data.getAvgViewCount();
|
|
|
+ t1DayAverageMiniAppOpenRate = (t1DayAverageMiniAppOpenRate * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t1DayMiniAppOpenRate) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setT1DayAverageMiniAppOpenRate(t1DayAverageMiniAppOpenRate);
|
|
|
+ double t1DayAverageT0FissionRate = item.getT1DayAverageT0FissionRate();
|
|
|
+ if (data.getSecondFission0() > 0 && data.getSecondFirstLevel() > 0) {
|
|
|
+ double t1DayT0FissionRate = data.getSecondFission0() / (double) data.getSecondFirstLevel();
|
|
|
+ t1DayAverageT0FissionRate = (t1DayAverageT0FissionRate * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t1DayT0FissionRate) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setT1DayAverageT0FissionRate(t1DayAverageT0FissionRate);
|
|
|
+ double t1DayAverageFirstLayerFissionToViewBaseRatio = item.getT1DayAverageFirstLayerFissionToViewBaseRatio();
|
|
|
+ if (data.getSecondFission0() > 0 && data.getAvgViewCount() > 0) {
|
|
|
+ double t1DayFirstLayerFissionToViewBaseRatio = data.getSecondFission0() / data.getAvgViewCount();
|
|
|
+ t1DayAverageFirstLayerFissionToViewBaseRatio = (t1DayAverageFirstLayerFissionToViewBaseRatio * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t1DayFirstLayerFissionToViewBaseRatio) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setT1DayAverageFirstLayerFissionToViewBaseRatio(t1DayAverageFirstLayerFissionToViewBaseRatio);
|
|
|
+ double t2DayAverageViewToBaseRatio = item.getT2DayAverageViewToBaseRatio();
|
|
|
+ if (data.getViewCount() > 0 && data.getAvgViewCount() > 0) {
|
|
|
+ double t2DayViewToBaseRatio = data.getViewCount() / data.getAvgViewCount();
|
|
|
+ t2DayAverageViewToBaseRatio = (t2DayAverageViewToBaseRatio * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t2DayViewToBaseRatio) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setT2DayAverageViewToBaseRatio(t2DayAverageViewToBaseRatio);
|
|
|
+ double t2DayAverageMiniAppOpenRate = item.getT2DayAverageMiniAppOpenRate();
|
|
|
+ if (data.getThirdFirstLevel() > 0 && data.getAvgViewCount() > 0) {
|
|
|
+ double t2DayMiniAppOpenRate = data.getThirdFirstLevel() / data.getAvgViewCount();
|
|
|
+ t2DayAverageMiniAppOpenRate = (t2DayAverageMiniAppOpenRate * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t2DayMiniAppOpenRate) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setT2DayAverageMiniAppOpenRate(t2DayAverageMiniAppOpenRate);
|
|
|
+ double t2DayAverageT0FissionRate = item.getT2DayAverageT0FissionRate();
|
|
|
+ if (data.getThirdFission0() > 0 && data.getSecondFirstLevel() > 0) {
|
|
|
+ double t2DayT0FissionRate = data.getThirdFission0() / (double) data.getSecondFirstLevel();
|
|
|
+ t2DayAverageT0FissionRate = (t2DayAverageT0FissionRate * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t2DayT0FissionRate) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setT2DayAverageT0FissionRate(t2DayAverageT0FissionRate);
|
|
|
+ double t2DayAverageFirstLayerFissionToViewBaseRatio = item.getT2DayAverageFirstLayerFissionToViewBaseRatio();
|
|
|
+ if (data.getThirdFission0() > 0 && data.getAvgViewCount() > 0) {
|
|
|
+ double t2DayFirstLayerFissionToViewBaseRatio = data.getThirdFission0() / data.getAvgViewCount();
|
|
|
+ t2DayAverageFirstLayerFissionToViewBaseRatio = (t2DayAverageFirstLayerFissionToViewBaseRatio * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t2DayFirstLayerFissionToViewBaseRatio) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setT2DayAverageFirstLayerFissionToViewBaseRatio(t2DayAverageFirstLayerFissionToViewBaseRatio);
|
|
|
+
|
|
|
+ item.setT3DayViewCount(item.getT3DayViewCount());
|
|
|
+ item.setT3DayFirstLayerUV(item.getT3DayFirstLayerUV());
|
|
|
+ item.setT3DayT0FissionUV(item.getT3DayT0FissionUV());
|
|
|
+ item.setT3DayAccountArticleRelevanceAvg(item.getT3DayAccountArticleRelevanceAvg());
|
|
|
+ item.setT3DayAverageViewToBaseRatio(item.getT3DayAverageViewToBaseRatio());
|
|
|
+ item.setT3DayAverageMiniAppOpenRate(item.getT3DayAverageMiniAppOpenRate());
|
|
|
+ item.setT3DayAverageT0FissionRate(item.getT3DayAverageT0FissionRate());
|
|
|
+ item.setT3DayAverageFirstLayerFissionToViewBaseRatio(item.getT3DayAverageFirstLayerFissionToViewBaseRatio());
|
|
|
+ item.setT3DayViewBase(item.getT3DayViewBase());
|
|
|
+ item.setT3PlusDayViewCount(item.getT3PlusDayViewCount());
|
|
|
+ item.setT3PlusDayFirstLayerUV(item.getT3PlusDayFirstLayerUV());
|
|
|
+ item.setT3PlusDayT0FissionUV(item.getT3PlusDayT0FissionUV());
|
|
|
+ item.setT3PlusDayAccountArticleRelevanceAvg(item.getT3PlusDayAccountArticleRelevanceAvg());
|
|
|
+ item.setT3PlusDayAverageViewToBaseRatio(item.getT3PlusDayAverageViewToBaseRatio());
|
|
|
+ item.setT3PlusDayAverageMiniAppOpenRate(item.getT3PlusDayAverageMiniAppOpenRate());
|
|
|
+ item.setT3PlusDayAverageT0FissionRate(item.getT3PlusDayAverageT0FissionRate());
|
|
|
+ item.setT3PlusDayAverageFirstLayerFissionToViewBaseRatio(item.getT3PlusDayAverageFirstLayerFissionToViewBaseRatio());
|
|
|
+ item.setT3PlusDayViewBase(item.getT3PlusDayViewBase());
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<NewSortStrategyExport> getNewSortStrategyExportList(List<Article> todayPublish,
|
|
|
+ Map<String, List<ArticleDetailInfo>> articleDetailInfoMap,
|
|
|
+ Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap) {
|
|
|
+ List<NewSortStrategyExport> result = new ArrayList<>();
|
|
|
+ for (Article article : todayPublish) {
|
|
|
+ List<ArticleDetailInfo> articleDetailInfos = articleDetailInfoMap.get(article.getWxSn());
|
|
|
+ if (CollectionUtils.isEmpty(articleDetailInfos)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Date minDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).min(Date::compareTo).orElse(new Date());
|
|
|
+ Date secondDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).filter(o -> o.after(minDate)).min(Date::compareTo).orElse(new Date());
|
|
|
+ Date thirdDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).filter(o -> o.after(secondDate)).min(Date::compareTo).orElse(new Date());
|
|
|
+ int sumFirstLevel = 0;
|
|
|
+ int sumFission0 = 0;
|
|
|
+ int sumFission1 = 0;
|
|
|
+ int sumFission2 = 0;
|
|
|
+ int sumSecondFirstLevel = 0;
|
|
|
+ int sumSecondFission0 = 0;
|
|
|
+ int sumSecondFission1 = 0;
|
|
|
+ int sumSecondFission2 = 0;
|
|
|
+ int sumThirdFirstLevel = 0;
|
|
|
+ int sumThirdFission0 = 0;
|
|
|
+ int sumThirdFission1 = 0;
|
|
|
+ int sumThirdFission2 = 0;
|
|
|
+ for (ArticleDetailInfo articleDetailInfo : articleDetailInfos) {
|
|
|
+ if (articleDetailInfo.getRecallDt().equals(minDate)) {
|
|
|
+ sumFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
|
|
|
+ sumFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
|
|
|
+ sumFission1 += Optional.ofNullable(articleDetailInfo.getFission1()).orElse(0);
|
|
|
+ sumFission2 += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
|
|
|
+ }
|
|
|
+ if (articleDetailInfo.getRecallDt().equals(secondDate)) {
|
|
|
+ sumSecondFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
|
|
|
+ sumSecondFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
|
|
|
+ sumSecondFission1 += Optional.ofNullable(articleDetailInfo.getFission1()).orElse(0);
|
|
|
+ sumSecondFission2 += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
|
|
|
+ }
|
|
|
+ if (articleDetailInfo.getRecallDt().equals(thirdDate)) {
|
|
|
+ sumThirdFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
|
|
|
+ sumThirdFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
|
|
|
+ sumThirdFission1 += Optional.ofNullable(articleDetailInfo.getFission1()).orElse(0);
|
|
|
+ sumThirdFission2 += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Map<String, AccountAvgInfo>> dateAvgMap = accountAvgInfoIndexMap.get(article.getGhId());
|
|
|
+ String hisPublishDate = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyy-MM-dd");
|
|
|
+ AccountAvgInfo avgInfo = null;
|
|
|
+ if (Objects.nonNull(dateAvgMap)) {
|
|
|
+ List<String> avgMapDateList = new ArrayList<>(dateAvgMap.keySet());
|
|
|
+ hisPublishDate = DateUtils.findNearestDate(avgMapDateList, hisPublishDate, "yyyy-MM-dd");
|
|
|
+ Map<String, AccountAvgInfo> accountAvgInfoMap = dateAvgMap.get(hisPublishDate);
|
|
|
+ if (Objects.nonNull(accountAvgInfoMap)) {
|
|
|
+ avgInfo = accountAvgInfoMap.get(article.getItemIndex().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String date = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyyMMdd");
|
|
|
+ NewSortStrategyExport obj = new NewSortStrategyExport();
|
|
|
+ obj.setGhId(article.getGhId());
|
|
|
+ obj.setAccountName(article.getAccountName());
|
|
|
+ obj.setTitle(article.getTitle());
|
|
|
+ obj.setLink(article.getContentUrl());
|
|
|
+ obj.setPosition(article.getItemIndex());
|
|
|
+ obj.setViewCount(article.getShowViewCount());
|
|
|
+ obj.setDateStr(date);
|
|
|
+ obj.setFirstLevel(sumFirstLevel);
|
|
|
+ obj.setFission0(sumFission0);
|
|
|
+ obj.setFission1(sumFission1);
|
|
|
+ obj.setFission2(sumFission2);
|
|
|
+ obj.setSecondFirstLevel(sumSecondFirstLevel);
|
|
|
+ obj.setSecondFission0(sumSecondFission0);
|
|
|
+ obj.setSecondFission1(sumSecondFission1);
|
|
|
+ obj.setSecondFission2(sumSecondFission2);
|
|
|
+ obj.setThirdFirstLevel(sumThirdFirstLevel);
|
|
|
+ obj.setThirdFission0(sumThirdFission0);
|
|
|
+ obj.setThirdFission1(sumThirdFission1);
|
|
|
+ obj.setThirdFission2(sumThirdFission2);
|
|
|
+ obj.setWxSn(article.getWxSn());
|
|
|
+ if (Objects.nonNull(avgInfo)) {
|
|
|
+ obj.setAccountMode(avgInfo.getAccountMode());
|
|
|
+ obj.setAccountSource(avgInfo.getAccountSource());
|
|
|
+ obj.setAccountType(avgInfo.getAccountType());
|
|
|
+ obj.setAccountStatus(avgInfo.getAccountStatus());
|
|
|
+ obj.setBusinessType(AccountBusinessTypeEnum.from(avgInfo.getBusinessType()).getDescription());
|
|
|
+ obj.setFans(avgInfo.getFans());
|
|
|
+ obj.setAvgViewCount(avgInfo.getReadAvg());
|
|
|
+ if (avgInfo.getReadAvg() > 0) {
|
|
|
+ obj.setReadRate((article.getShowViewCount() * 1.0) / avgInfo.getReadAvg());
|
|
|
+ obj.setFission0ReadAvgRate((sumFission0 * 1.0) / avgInfo.getReadAvg());
|
|
|
+ }
|
|
|
+ if (avgInfo.getFans() > 0) {
|
|
|
+ obj.setReadFansRate((article.getShowViewCount() * 1.0) / avgInfo.getFans());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sumFirstLevel > 0) {
|
|
|
+ obj.setFission0FirstRate((sumFission0 * 1.0) / sumFirstLevel);
|
|
|
+ }
|
|
|
+ if (article.getShowViewCount() > 0) {
|
|
|
+ obj.setFirstReadRate((sumFirstLevel * 1.0) / article.getShowViewCount());
|
|
|
+ }
|
|
|
+ if (sumFission0 > 0) {
|
|
|
+ obj.setFission1Fission0Rate((sumFission1 * 1.0) / sumFission0);
|
|
|
+ }
|
|
|
+ result.add(obj);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPublishSourcePerformance(IntermediateIndicatorsExport item,
|
|
|
+ Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap,
|
|
|
+ Map<String, List<ArticleDetailInfo>> articleDetailInfoMap,
|
|
|
+ Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap,
|
|
|
+ String type,
|
|
|
+ Map<String, Integer> scoreHisPublishTimeMap,
|
|
|
+ Map<String, Set<String>> wxsnHisDistinctSetMap,
|
|
|
+ List<Article> hisPublish) {
|
|
|
+ Long hisMinDate = hisPublish.stream().mapToLong(Article::getUpdateTime).min().orElse(0);
|
|
|
+ int scorePublishTime = scoreHisPublishTimeMap.computeIfAbsent(type, k -> 0);
|
|
|
+ Set<String> wxsnHisDistinctSet = wxsnHisDistinctSetMap.computeIfAbsent(type, k -> new HashSet<>());
|
|
|
+ for (Article publish : hisPublish) {
|
|
|
+ Map<String, Map<String, AccountAvgInfo>> dateAvgMap = accountAvgInfoIndexMap.get(publish.getGhId());
|
|
|
+ String hisPublishDate = DateUtils.timestampToYMDStr(publish.getUpdateTime(), "yyyy-MM-dd");
|
|
|
+ AccountAvgInfo avgInfo = null;
|
|
|
+ if (Objects.nonNull(dateAvgMap)) {
|
|
|
+ List<String> avgMapDateList = new ArrayList<>(dateAvgMap.keySet());
|
|
|
+ hisPublishDate = DateUtils.findNearestDate(avgMapDateList, hisPublishDate, "yyyy-MM-dd");
|
|
|
+ Map<String, AccountAvgInfo> accountAvgInfoMap = dateAvgMap.get(hisPublishDate);
|
|
|
+ if (Objects.nonNull(accountAvgInfoMap)) {
|
|
|
+ avgInfo = accountAvgInfoMap.get(publish.getItemIndex().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (wxsnHisDistinctSet.contains(publish.getWxSn())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ wxsnHisDistinctSet.add(publish.getWxSn());
|
|
|
+ item.setTotalArticleReleaseCountNonInfinite(item.getTotalArticleReleaseCountNonInfinite() + 1);
|
|
|
+ item.setRedundantViewCount(item.getRedundantViewCount() + publish.getShowViewCount());
|
|
|
+ if (Objects.nonNull(avgInfo)) {
|
|
|
+ item.setRedundantViewBase(item.getRedundantViewBase() + avgInfo.getReadAvg());
|
|
|
+ }
|
|
|
+ if (item.getRedundantViewBase() > 0 && item.getRedundantViewCount() > 0) {
|
|
|
+ item.setAverageViewToBaseRatio(item.getRedundantViewCount() / (double) item.getRedundantViewBase());
|
|
|
+ }
|
|
|
+ List<ArticleDetailInfo> articleDetailInfos = articleDetailInfoMap.get(publish.getWxSn());
|
|
|
+ if (CollectionUtils.isEmpty(articleDetailInfos)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int sumFirstLevel = 0;
|
|
|
+ int sumFission0 = 0;
|
|
|
+ Date minDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).min(Date::compareTo).orElse(new Date());
|
|
|
+ for (ArticleDetailInfo articleDetailInfo : articleDetailInfos) {
|
|
|
+ if (articleDetailInfo.getRecallDt().equals(minDate)) {
|
|
|
+ sumFirstLevel += Optional.ofNullable(articleDetailInfo.getFirstLevel()).orElse(0);
|
|
|
+ sumFission0 += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setRedundantFirstLayerUV(item.getRedundantFirstLayerUV() + sumFirstLevel);
|
|
|
+ item.setRedundantT0FissionUV(item.getRedundantT0FissionUV() + sumFission0);
|
|
|
+ double averageMiniAppOpenRate = item.getAverageMiniAppOpenRate();
|
|
|
+ if (item.getRedundantFirstLayerUV() > 0 && item.getRedundantViewCount() > 0) {
|
|
|
+ double miniAppOpenRate = item.getRedundantFirstLayerUV() / (double) item.getRedundantViewCount();
|
|
|
+ averageMiniAppOpenRate = (averageMiniAppOpenRate * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + miniAppOpenRate) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setAverageMiniAppOpenRate(averageMiniAppOpenRate);
|
|
|
+ double averageT0FissionRate = item.getAverageT0FissionRate();
|
|
|
+ if (item.getRedundantT0FissionUV() > 0 && item.getRedundantFirstLayerUV() > 0) {
|
|
|
+ double t0FissionRate = item.getRedundantT0FissionUV() / (double) item.getRedundantFirstLayerUV();
|
|
|
+ averageT0FissionRate = (averageT0FissionRate * (item.getActualArticleReleaseCount() - 1)
|
|
|
+ + t0FissionRate) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setAverageT0FissionRate(averageT0FissionRate);
|
|
|
+ double averageFirstLayerFissionToViewBaseRatio = item.getAverageFirstLayerFissionToViewBaseRatio();
|
|
|
+ if (item.getRedundantViewBase() > 0 && item.getRedundantT0FissionUV() > 0) {
|
|
|
+ double firstLayerFissionToViewBaseRatio = item.getRedundantT0FissionUV() / (double) item.getRedundantViewBase();
|
|
|
+ averageFirstLayerFissionToViewBaseRatio = (averageFirstLayerFissionToViewBaseRatio *
|
|
|
+ (item.getActualArticleReleaseCount() - 1) + firstLayerFissionToViewBaseRatio) / item.getActualArticleReleaseCount();
|
|
|
+ }
|
|
|
+ item.setAverageFirstLayerFissionToViewBaseRatio(averageFirstLayerFissionToViewBaseRatio);
|
|
|
+ Map<String, Map<Integer, PublishSortLog>> dateSortMap = publishSortLogMap.get(publish.getGhId());
|
|
|
+ if (Objects.nonNull(dateSortMap)) {
|
|
|
+ String publishDateStr = DateUtils.timestampToYMDStr(publish.getUpdateTime(), "yyyyMMdd");
|
|
|
+ Map<Integer, PublishSortLog> indexMap = dateSortMap.get(publishDateStr);
|
|
|
+ if (Objects.nonNull(indexMap)) {
|
|
|
+ PublishSortLog log = indexMap.get(publish.getItemIndex());
|
|
|
+ double scoreAvg = item.getRedundantAccountArticleRelevanceAvg();
|
|
|
+ double score = 0.0;
|
|
|
+ if (Objects.nonNull(log) && Objects.nonNull(log.getScore())) {
|
|
|
+ JSONObject scoreMap = JSONObject.parseObject(log.getScoreMap());
|
|
|
+ if (scoreMap.containsKey("SimilarityStrategy")) {
|
|
|
+ score = scoreMap.getDoubleValue("SimilarityStrategy");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scorePublishTime++;
|
|
|
+ scoreAvg = (scoreAvg * (scorePublishTime - 1) + score) / scorePublishTime;
|
|
|
+ item.setRedundantAccountArticleRelevanceAvg(scoreAvg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ double firstExplorationIntervalAvg = Double.isNaN(item.getFirstExplorationIntervalAvg()) ? 0.0 : item.getFirstExplorationIntervalAvg();
|
|
|
+ double explorationInterval = (publish.getUpdateTime() - hisMinDate) / 86400.0;
|
|
|
+ firstExplorationIntervalAvg = (firstExplorationIntervalAvg * (item.getTotalArticleReleaseCountNonInfinite() - 1)
|
|
|
+ + explorationInterval) / item.getTotalArticleReleaseCountNonInfinite();
|
|
|
+ item.setFirstExplorationIntervalAvg(firstExplorationIntervalAvg);
|
|
|
+ }
|
|
|
+ scoreHisPublishTimeMap.put(type, scorePublishTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPublishPerformance(IntermediateIndicatorsExport item, NewSortStrategyExport data,
|
|
|
+ Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap) {
|
|
|
+ item.setViewCount(item.getViewCount() + data.getViewCount());
|
|
|
+ item.setFirstLayerUV(item.getFirstLayerUV() + data.getFirstLevel());
|
|
|
+ item.setT0FissionUV(item.getT0FissionUV() + data.getFission0());
|
|
|
+ item.setViewBase(item.getViewBase() + data.getAvgViewCount());
|
|
|
+ if (item.getViewBase() > 0 && item.getViewCount() > 0) {
|
|
|
+ item.setViewToBaseRatio(item.getViewCount() / (double) item.getViewBase());
|
|
|
+ }
|
|
|
+ if (item.getFirstLayerUV() > 0 && item.getViewCount() > 0) {
|
|
|
+ item.setMiniAppOpenRate(item.getFirstLayerUV() / (double) item.getViewCount());
|
|
|
+ }
|
|
|
+ if (item.getFirstLayerUV() > 0 && item.getT0FissionUV() > 0) {
|
|
|
+ item.setT0FissionRate(item.getT0FissionUV() / (double) item.getFirstLayerUV());
|
|
|
+ item.setT0FissionRateAgain(item.getT0FissionUV() / (double) item.getFirstLayerUV());
|
|
|
+ }
|
|
|
+ item.setT0FissionCount(item.getT0FissionCount() + data.getFission0());
|
|
|
+ item.setT1FissionCount(item.getT1FissionCount() + data.getFission1());
|
|
|
+ item.setT2FissionCount(item.getT2FissionCount() + data.getFission2());
|
|
|
+ if (item.getT0FissionCount() > 0 && item.getViewBase() > 0) {
|
|
|
+ item.setFirstLayerFissionToViewBaseRatio(item.getT0FissionCount() / (double) item.getViewBase());
|
|
|
+ }
|
|
|
+ if (item.getT0FissionCount() + item.getT1FissionCount() > 0 && item.getFirstLayerUV() > 0) {
|
|
|
+ item.setT1CumulativeFissionRate((item.getT0FissionCount() + item.getT1FissionCount()) / (double) item.getFirstLayerUV());
|
|
|
+ }
|
|
|
+ if (item.getT0FissionCount() + item.getT1FissionCount() + item.getT2FissionCount() > 0 && item.getViewBase() > 0) {
|
|
|
+ item.setT2CumulativeFissionRate((item.getT0FissionCount() + item.getT1FissionCount() + item.getT2FissionCount()) / (double) item.getFirstLayerUV());
|
|
|
+ }
|
|
|
+ Map<String, Map<Integer, PublishSortLog>> dateSortMap = publishSortLogMap.get(data.getGhId());
|
|
|
+ if (Objects.nonNull(dateSortMap)) {
|
|
|
+ Map<Integer, PublishSortLog> indexMap = dateSortMap.get(item.getDateStr());
|
|
|
+ if (Objects.nonNull(indexMap)) {
|
|
|
+ PublishSortLog log = indexMap.get(data.getPosition());
|
|
|
+ double scoreAvg = item.getAccountArticleRelevanceAvg();
|
|
|
+ double score = 0.0;
|
|
|
+ if (Objects.nonNull(log) && Objects.nonNull(log.getScore())) {
|
|
|
+ JSONObject scoreMap = JSONObject.parseObject(log.getScoreMap());
|
|
|
+ if (scoreMap.containsKey("SimilarityStrategy")) {
|
|
|
+ score = scoreMap.getDoubleValue("SimilarityStrategy");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scoreAvg = (scoreAvg * (item.getActualArticleReleaseCount() - 1) + score) / item.getActualArticleReleaseCount();
|
|
|
+ item.setAccountArticleRelevanceAvg(scoreAvg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPublishSituation(IntermediateIndicatorsExport item, String type, Map<String, List<String>> titleTypeMap,
|
|
|
+ Map<String, Map<Integer, List<String>>> titleTypePoolMap, Integer poolLevel,
|
|
|
+ NewSortStrategyExport data) {
|
|
|
+ item.setArticleReleaseSlot(item.getArticleReleaseSlot() + 1);
|
|
|
+ item.setActualArticleReleaseCount(item.getActualArticleReleaseCount() + 1);
|
|
|
+ if (titleTypeMap.containsKey(type) && !titleTypeMap.get(type).contains(data.getTitle())) {
|
|
|
+ item.setDistinctArticleReleaseCount(item.getDistinctArticleReleaseCount() + 1);
|
|
|
+ }
|
|
|
+ item.setDistinctArticleReleaseRatio(item.getDistinctArticleReleaseCount() / (double) item.getActualArticleReleaseCount());
|
|
|
+
|
|
|
+ if (4 == poolLevel) {
|
|
|
+ item.setActualReleaseCountL4(item.getActualReleaseCountL4() + 1);
|
|
|
+ } else if (3 == poolLevel) {
|
|
|
+ item.setActualReleaseCountL3(item.getActualReleaseCountL3() + 1);
|
|
|
+ } else if (2 == poolLevel) {
|
|
|
+ item.setActualReleaseCountL2(item.getActualReleaseCountL2() + 1);
|
|
|
+ } else {
|
|
|
+ item.setActualReleaseCountL1(item.getActualReleaseCountL1() + 1);
|
|
|
+ }
|
|
|
+ if (titleTypePoolMap.containsKey(type)
|
|
|
+ && titleTypePoolMap.get(type).containsKey(poolLevel)
|
|
|
+ && !titleTypePoolMap.get(type).get(poolLevel).contains(data.getTitle())) {
|
|
|
+ if (4 == poolLevel) {
|
|
|
+ item.setDistinctReleaseCountL4(item.getDistinctReleaseCountL4() + 1);
|
|
|
+ } else if (3 == poolLevel) {
|
|
|
+ item.setDistinctReleaseCountL3(item.getDistinctReleaseCountL3() + 1);
|
|
|
+ } else if (2 == poolLevel) {
|
|
|
+ item.setDistinctReleaseCountL2(item.getDistinctReleaseCountL2() + 1);
|
|
|
+ } else {
|
|
|
+ item.setDistinctReleaseCountL1(item.getDistinctReleaseCountL1() + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.getActualReleaseCountL1() > 0 && item.getDistinctReleaseCountL1() > 0) {
|
|
|
+ item.setDistinctToActualRatioL1(item.getDistinctReleaseCountL1() / (double) item.getActualReleaseCountL1());
|
|
|
+ }
|
|
|
+ if (item.getActualReleaseCountL2() > 0 && item.getDistinctReleaseCountL2() > 0) {
|
|
|
+ item.setDistinctToActualRatioL2(item.getDistinctReleaseCountL2() / (double) item.getActualReleaseCountL2());
|
|
|
+ }
|
|
|
+ if (item.getActualReleaseCountL3() > 0 && item.getDistinctReleaseCountL3() > 0) {
|
|
|
+ item.setDistinctToActualRatioL3(item.getDistinctReleaseCountL3() / (double) item.getActualReleaseCountL3());
|
|
|
+ }
|
|
|
+ if (item.getActualReleaseCountL4() > 0 && item.getDistinctReleaseCountL4() > 0) {
|
|
|
+ item.setDistinctToActualRatioL4(item.getDistinctReleaseCountL4() / (double) item.getActualReleaseCountL4());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getArticlePoolLevel(NewSortStrategyExport data, List<Article> list, List<String> small) {
|
|
|
+ int minPosition = list.stream().mapToInt(Article::getItemIndex).min().orElse(8);
|
|
|
+ if (minPosition == 1) {
|
|
|
+ if (small.contains(data.getGhId())) {
|
|
|
+ return 3;
|
|
|
+ } else {
|
|
|
+ return 4;
|
|
|
+ }
|
|
|
+ } else if (minPosition == 2) {
|
|
|
+ return 2;
|
|
|
+ } else {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getArticleType(NewSortStrategyExport data, List<String> small) {
|
|
|
+ if (data.getPosition() == 1) {
|
|
|
+ if (small.contains(data.getGhId())) {
|
|
|
+ return "L3";
|
|
|
+ } else {
|
|
|
+ return "L4";
|
|
|
+ }
|
|
|
+ } else if (data.getPosition() == 2) {
|
|
|
+ return "L2";
|
|
|
+ } else {
|
|
|
+ return "L1";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<IntermediateIndicatorsExport> buildIntermediateIndicatorsData(String dateStr) {
|
|
|
+ List<IntermediateIndicatorsExport> result = new ArrayList<>();
|
|
|
+ List<String> typeList = Arrays.asList("L4", "L3", "L2", "L1");
|
|
|
+ for (String type : typeList) {
|
|
|
+ IntermediateIndicatorsExport item = new IntermediateIndicatorsExport();
|
|
|
+ item.setDateStr(dateStr);
|
|
|
+ item.setType(type);
|
|
|
+ result.add(item);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|