|
@@ -6,6 +6,7 @@ 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.ContentPositionEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.ChannelEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.ProduceContentAuditStatusEnum;
|
|
@@ -13,10 +14,7 @@ import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputS
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoAuditStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.longArticle.ArticleVideoBadStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.longArticle.VideoPoolPlatformEnum;
|
|
|
-import com.tzld.longarticle.recommend.server.common.enums.recommend.AccountBusinessTypeEnum;
|
|
|
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleTypeEnum;
|
|
|
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
|
|
|
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.recommend.*;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.aigc.PublishContentMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
|
|
@@ -46,6 +44,7 @@ import com.tzld.longarticle.recommend.server.repository.longArticle.*;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
|
|
|
import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
|
import com.tzld.longarticle.recommend.server.util.MapBuilder;
|
|
|
+import com.tzld.longarticle.recommend.server.util.Md5Util;
|
|
|
import com.tzld.longarticle.recommend.server.util.feishu.FeiShu;
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
@@ -53,6 +52,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.util.Pair;
|
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -123,6 +123,9 @@ public class DataDashboardService {
|
|
|
private static List<String> ghIdList;
|
|
|
@ApolloJsonValue("${audit.producePlan.list:[]}")
|
|
|
private static List<String> auditProducePlanList;
|
|
|
+
|
|
|
+ @Value("${category.active.version:1}")
|
|
|
+ private Integer activeVersion;
|
|
|
private static final String dailyDetailSheetToken = "M0pLs3uF6hfL0htn2dMcB9eFn8e";
|
|
|
private static final String dailySafeSheetToken = "Xoass3ZGYhi9BVtZDoMclGFpnYe";
|
|
|
|
|
@@ -3498,7 +3501,7 @@ public class DataDashboardService {
|
|
|
@XxlJob("dailyAuditProduceExport")
|
|
|
public ReturnT<String> dailyAuditProduceJob(String param) {
|
|
|
List<String> dateStrList = DateUtils.getBeforeDays(null, null, 1);
|
|
|
- contentEffectGroupBySource(dateStrList);
|
|
|
+ dailyAuditProduce(dateStrList);
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
@@ -3568,15 +3571,135 @@ public class DataDashboardService {
|
|
|
}
|
|
|
for (DailyAuditProduceExport item : result) {
|
|
|
item.setDateStr(dateStr);
|
|
|
- if (item.getAuditCount()!= null && item.getAuditCount()!= 0) {
|
|
|
+ if (item.getAuditCount() != null && item.getAuditCount() != 0) {
|
|
|
item.setAuditPassRate((double) item.getAuditPassCount() / item.getAuditCount());
|
|
|
}
|
|
|
- if (item.getVideoAuditCount()!= null && item.getVideoAuditCount()!= 0) {
|
|
|
+ if (item.getVideoAuditCount() != null && item.getVideoAuditCount() != 0) {
|
|
|
item.setVideoAuditPassRate((double) item.getVideoAuditPassCount() / item.getVideoAuditCount());
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @XxlJob("categoryGroupDataExport")
|
|
|
+ public ReturnT<String> categoryGroupDataJob(String param) {
|
|
|
+ List<String> dateStrList = DateUtils.getBeforeDays(null, null, 1);
|
|
|
+ categoryGroupData(dateStrList);
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void categoryGroupData(String dateStr) {
|
|
|
+ if (!StringUtils.hasText(dateStr)) {
|
|
|
+ dateStr = DateUtils.getBeforeDaysDateStr("yyyyMMdd", 1);
|
|
|
+ }
|
|
|
+ categoryGroupData(Collections.singletonList(dateStr));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void categoryGroupData(List<String> dateStrList) {
|
|
|
+ List<CategoryGroupDataExport> exportList = new ArrayList<>();
|
|
|
+ dateStrList = Lists.reverse(dateStrList);
|
|
|
+ for (String dateStr : dateStrList) {
|
|
|
+ exportList.addAll(buildCategoryGroupDataExport(dateStr));
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isEmpty(exportList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int rowNum = exportList.size();
|
|
|
+ List<List<Object>> rows = new ArrayList<>();
|
|
|
+ Field[] fields = CategoryGroupDataExport.class.getDeclaredFields();
|
|
|
+ for (CategoryGroupDataExport datum : exportList) {
|
|
|
+ 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("G", "0.00%")
|
|
|
+ );
|
|
|
+ doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "bl1eL2", rowNum, rows,
|
|
|
+ 2, styles, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<CategoryGroupDataExport> buildCategoryGroupDataExport(String dateStr) {
|
|
|
+ List<DatastatSortStrategy> list = datastatSortStrategyRepository.getByDateStr(dateStr);
|
|
|
+ List<ArticleCategory> articleCategoryList = articleCategoryRepository.getByStatusAndVersion(
|
|
|
+ ArticleCategoryStatusEnum.SUCCESS.getCode(), activeVersion);
|
|
|
+ Map<String, ArticleCategory> categoryMap = articleCategoryList.stream()
|
|
|
+ .collect(Collectors.toMap(ArticleCategory::getProduceContentId, Function.identity()));
|
|
|
+ Map<String, ArticleCategory> titleCategoryMap = articleCategoryList.stream()
|
|
|
+ .collect(Collectors.toMap(ArticleCategory::getTitleMd5, Function.identity(), (a, b) -> a));
|
|
|
+ Map<String, Map<String, CategoryGroupDataExport>> resultMap = new HashMap<>();
|
|
|
+ for (DatastatSortStrategy item : list) {
|
|
|
+ if (Objects.isNull(item.getViewCount()) || Objects.isNull(item.getFirstLevel()) || Objects.isNull(item.getFans())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, CategoryGroupDataExport> positionMap = resultMap.get(ContentPositionEnum.from(item.getPosition()));
|
|
|
+ if (MapUtils.isEmpty(positionMap)) {
|
|
|
+ positionMap = new HashMap<>();
|
|
|
+ resultMap.put(ContentPositionEnum.from(item.getPosition()), positionMap);
|
|
|
+ }
|
|
|
+ ArticleCategory articleCategory = categoryMap.get(item.getSourceId());
|
|
|
+ if (Objects.isNull(articleCategory)) {
|
|
|
+ String titleMd5 = Md5Util.encoderByMd5(item.getTitle());
|
|
|
+ articleCategory = titleCategoryMap.get(titleMd5);
|
|
|
+ }
|
|
|
+ if (Objects.isNull(articleCategory)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ CategoryGroupDataExport export = positionMap.get(articleCategory.getCategory());
|
|
|
+ if (Objects.isNull(export)) {
|
|
|
+ export = new CategoryGroupDataExport();
|
|
|
+ export.setDateStr(dateStr);
|
|
|
+ export.setPosition(ContentPositionEnum.from(item.getPosition()));
|
|
|
+ export.setCategory(articleCategory.getCategory());
|
|
|
+ positionMap.put(articleCategory.getCategory(), export);
|
|
|
+ }
|
|
|
+ export.setViewCount(export.getViewCount() + item.getViewCount());
|
|
|
+ export.setFirstLevel(export.getFirstLevel() + item.getFirstLevel());
|
|
|
+ export.setFansCount(export.getFansCount() + item.getFans());
|
|
|
+ }
|
|
|
+ List<CategoryGroupDataExport> result = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, Map<String, CategoryGroupDataExport>> entry : resultMap.entrySet()) {
|
|
|
+ for (Map.Entry<String, CategoryGroupDataExport> item : entry.getValue().entrySet()) {
|
|
|
+ CategoryGroupDataExport export = item.getValue();
|
|
|
+ if (export.getFansCount() != null && export.getFansCount() != 0) {
|
|
|
+ export.setOpenRate((double) export.getFirstLevel() / export.getFansCount());
|
|
|
+ }
|
|
|
+ result.add(export);
|
|
|
+ }
|
|
|
+ result.add(buildCategoryGroupDataSum(dateStr, entry.getKey(), entry.getValue()));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private CategoryGroupDataExport buildCategoryGroupDataSum(String dateStr, String position,
|
|
|
+ Map<String, CategoryGroupDataExport> categoryMap) {
|
|
|
+ CategoryGroupDataExport sum = new CategoryGroupDataExport();
|
|
|
+ sum.setDateStr(dateStr);
|
|
|
+ sum.setPosition(position);
|
|
|
+ sum.setCategory("SUM");
|
|
|
+ for (Map.Entry<String, CategoryGroupDataExport> entry : categoryMap.entrySet()) {
|
|
|
+ CategoryGroupDataExport export = entry.getValue();
|
|
|
+ sum.setViewCount(sum.getViewCount() + export.getViewCount());
|
|
|
+ sum.setFirstLevel(sum.getFirstLevel() + export.getFirstLevel());
|
|
|
+ sum.setFansCount(sum.getFansCount() + export.getFansCount());
|
|
|
+ }
|
|
|
+ if (sum.getFansCount() != null && sum.getFansCount() != 0) {
|
|
|
+ sum.setOpenRate((double) sum.getFirstLevel() / sum.getFansCount());
|
|
|
+ }
|
|
|
+ return sum;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|