Commit 9decf242 by shenjunjie

Merge branch 'release' into 'master'

Release

See merge request !473
parents 2a8ccb68 81de5ee6
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<qbjc.bean.version>1.1.7.1-SNAPSHOT</qbjc.bean.version> <qbjc.bean.version>1.1.7.1-SNAPSHOT</qbjc.bean.version>
<springfox.version>2.9.2</springfox.version> <springfox.version>2.9.2</springfox.version>
<fastjson.version>1.2.47</fastjson.version> <fastjson.version>1.2.47</fastjson.version>
<easyexcel.version>3.0.5</easyexcel.version> <easyexcel.version>3.3.4</easyexcel.version>
<marker.client.version>1.1.9-SNAPSHOT</marker.client.version> <marker.client.version>1.1.9-SNAPSHOT</marker.client.version>
<base-objects.version>2.1.6.1-SNAPSHOT</base-objects.version> <base-objects.version>2.1.6.1-SNAPSHOT</base-objects.version>
<es.version>7.9.2</es.version> <es.version>7.9.2</es.version>
...@@ -187,6 +187,17 @@ ...@@ -187,6 +187,17 @@
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version> <version>${easyexcel.version}</version>
<exclusions>
<exclusion>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.7.1</version>
</dependency> </dependency>
<!-- lombok --> <!-- lombok -->
<dependency> <dependency>
......
...@@ -2,10 +2,7 @@ package com.zhiwei.brandkbs2.common; ...@@ -2,10 +2,7 @@ package com.zhiwei.brandkbs2.common;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.pojo.ChannelTag; import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.pojo.HighlightWord;
import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.SensitiveChannel;
import com.zhiwei.brandkbs2.service.ChannelService; import com.zhiwei.brandkbs2.service.ChannelService;
import com.zhiwei.brandkbs2.service.SystemInfoService; import com.zhiwei.brandkbs2.service.SystemInfoService;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
...@@ -103,6 +100,11 @@ public class GlobalPojo { ...@@ -103,6 +100,11 @@ public class GlobalPojo {
*/ */
public static Map<String, SensitiveChannel> COMMON_SENSITIVE_CHANNEL = new HashMap<>(); public static Map<String, SensitiveChannel> COMMON_SENSITIVE_CHANNEL = new HashMap<>();
/**
* 字节定制指定渠道影响力信息
*/
public static Map<String, BytedanceCustomChannelInfluence> BYTEDANCE_CHANNEL_INFLUENCE = new HashMap<>();
@PostConstruct @PostConstruct
public void start() { public void start() {
try { try {
...@@ -139,9 +141,10 @@ public class GlobalPojo { ...@@ -139,9 +141,10 @@ public class GlobalPojo {
PROJECT_EMOTION_CHANNEL_DATA = channelService.getProjectEmotionChannelListData(); PROJECT_EMOTION_CHANNEL_DATA = channelService.getProjectEmotionChannelListData();
PROJECT_SENSITIVE_CHANNEL = systemInfoService.getProjectSensitiveChannel(); PROJECT_SENSITIVE_CHANNEL = systemInfoService.getProjectSensitiveChannel();
COMMON_SENSITIVE_CHANNEL = systemInfoService.getCommonSensitiveChannel(); COMMON_SENSITIVE_CHANNEL = systemInfoService.getCommonSensitiveChannel();
BYTEDANCE_CHANNEL_INFLUENCE = systemInfoService.getByteDanceChannelInfluence();
updateHighlightGraphs(); updateHighlightGraphs();
log.info("{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{},PROJECT_EMOTION_CHANNEL_DATA-size:{},PROJECT_SENSITIVE_CHANNEL-size:{}, COMMON_SENSITIVE_CHANNEL-size:{}", logMsg, PLATFORMS.size(), TAGS.size(), log.info("{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{},PROJECT_EMOTION_CHANNEL_DATA-size:{},PROJECT_SENSITIVE_CHANNEL-size:{}, COMMON_SENSITIVE_CHANNEL-size:{},BYTEDANCE_CHANNEL_INFLUENCE-size:{}", logMsg, PLATFORMS.size(), TAGS.size(),
LINKED_GROUP_ID_TAGS.size(), CHANNEL_TAGS.size(), MEDIA_TYPE.size(), PROJECT_MAP.size(), YU_QING_PROJECTS.size(), PROJECT_EMOTION_CHANNEL_DATA.size(), PROJECT_SENSITIVE_CHANNEL.size(), COMMON_SENSITIVE_CHANNEL.size()); LINKED_GROUP_ID_TAGS.size(), CHANNEL_TAGS.size(), MEDIA_TYPE.size(), PROJECT_MAP.size(), YU_QING_PROJECTS.size(), PROJECT_EMOTION_CHANNEL_DATA.size(), PROJECT_SENSITIVE_CHANNEL.size(), COMMON_SENSITIVE_CHANNEL.size(), BYTEDANCE_CHANNEL_INFLUENCE.size());
} catch (Exception e) { } catch (Exception e) {
log.info("{}-获取缓存值异常", logMsg, e); log.info("{}-获取缓存值异常", logMsg, e);
} }
......
...@@ -519,15 +519,22 @@ public class AppDownloadController extends BaseController { ...@@ -519,15 +519,22 @@ public class AppDownloadController extends BaseController {
@DownloadTask(taskName = "事件影响力更新模板下载", description = "事件影响力更新模板") @DownloadTask(taskName = "事件影响力更新模板下载", description = "事件影响力更新模板")
public ResponseResult downloadEventUpdateTemplate(){ public ResponseResult downloadEventUpdateTemplate(){
List<List<String>> head = new ArrayList<>(); List<List<String>> head = new ArrayList<>();
head.add(Collections.singletonList("序号"));
head.add(Collections.singletonList("平台类型")); head.add(Collections.singletonList("平台类型"));
head.add(Collections.singletonList("渠道名称")); head.add(Collections.singletonList("发布平台"));
head.add(Collections.singletonList("链接")); head.add(Collections.singletonList("渠道"));
head.add(Collections.singletonList("事件名")); head.add(Collections.singletonList("时间"));
head.add(Collections.singletonList("微博转发")); head.add(Collections.singletonList("标题"));
head.add(Collections.singletonList("微博评论")); head.add(Collections.singletonList("文本"));
head.add(Collections.singletonList("微博点赞")); head.add(Collections.singletonList("地址"));
head.add(Collections.singletonList("微信阅读")); head.add(Collections.singletonList("命中词"));
head.add(Collections.singletonList("微信在看")); head.add(Collections.singletonList("情感倾向"));
head.add(Collections.singletonList("事件标签"));
head.add(Collections.singletonList("在看"));
head.add(Collections.singletonList("阅读"));
head.add(Collections.singletonList("点赞"));
head.add(Collections.singletonList("评论"));
head.add(Collections.singletonList("转发"));
// excel写入至指定路径 // excel写入至指定路径
String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName(); String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName();
String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "事件更新模板"); String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "事件更新模板");
......
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelLevelInfo;
/**
* @ClassName: BytedanceCustomChannelDao
* @Description BytedanceCustomChannelDao
* @author: cjz
* @date: 2023-10-13 15:43
*/
public interface BytedanceCustomChannelLevelInfoDao extends BaseMongoDao<BytedanceCustomChannelLevelInfo>{
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.BytedanceCustomChannelLevelInfoDao;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelLevelInfo;
import org.springframework.stereotype.Component;
@Component("bytedanceCustomChannelLevelInfoDao")
public class BytedanceCustomChannelLevelInfoDaoImpl extends BaseMongoDaoImpl<BytedanceCustomChannelLevelInfo> implements BytedanceCustomChannelLevelInfoDao {
private static final String COLLECTION_NAME = "brandkbs_bytedance_custom_channel_level_info";
public BytedanceCustomChannelLevelInfoDaoImpl() {
super(COLLECTION_NAME);
}
}
...@@ -16,13 +16,15 @@ public class ExportBytedanceEventComputeResultDTO { ...@@ -16,13 +16,15 @@ public class ExportBytedanceEventComputeResultDTO {
@ExcelProperty("事件名") @ExcelProperty("事件名")
private String name; private String name;
@ExcelProperty("影响力指数") @ExcelProperty("渠道指标")
private Double inf; private Double inf;
@ExcelProperty("实时传播力") @ExcelProperty("流量指标")
private Double RMI; private Double RMI;
@ExcelProperty("传播影响力") @ExcelProperty("综合影响力")
private Double finalInf; private Double finalInf;
@ExcelProperty("传播量")
private Integer dataCount;
} }
...@@ -11,31 +11,51 @@ import lombok.Data; ...@@ -11,31 +11,51 @@ import lombok.Data;
*/ */
@Data @Data
public class UploadBytedanceEventDTO { public class UploadBytedanceEventDTO {
@ExcelProperty("序号")
private String number;
@ExcelProperty("平台类型") @ExcelProperty("平台类型")
private String platformType;
@ExcelProperty("发布平台")
private String platform; private String platform;
@ExcelProperty("渠道名称") @ExcelProperty("渠道")
private String channel; private String channel;
@ExcelProperty("链接") @ExcelProperty("时间")
private String time;
@ExcelProperty("标题")
private String title;
@ExcelProperty("文本")
private String content;
@ExcelProperty("地址")
private String url; private String url;
@ExcelProperty("事件名") @ExcelProperty("命中词")
private String hitWord;
@ExcelProperty("情感倾向")
private String emotion;
@ExcelProperty("事件标签")
private String eventName; private String eventName;
@ExcelProperty("微博转发") @ExcelProperty("在看")
private Integer weiboForward; private String reading;
@ExcelProperty("微博评论") @ExcelProperty("阅读")
private Integer weiboComment; private String read;
@ExcelProperty("微博点赞") @ExcelProperty("点赞")
private Integer weiboLike; private String like;
@ExcelProperty("微信阅读") @ExcelProperty("评论")
private Integer wechatRead; private String comment;
@ExcelProperty("微信在看") @ExcelProperty("转发")
private Integer wechatReading; private String forward;
} }
...@@ -4,11 +4,8 @@ import com.alibaba.excel.context.AnalysisContext; ...@@ -4,11 +4,8 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO; import com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTaskData; import com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTaskData;
import com.zhiwei.brandkbs2.util.Tools;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -33,20 +30,19 @@ public class BytedanceEventListener extends AnalysisEventListener<UploadBytedanc ...@@ -33,20 +30,19 @@ public class BytedanceEventListener extends AnalysisEventListener<UploadBytedanc
public void invoke(UploadBytedanceEventDTO dto, AnalysisContext context) { public void invoke(UploadBytedanceEventDTO dto, AnalysisContext context) {
BytedanceCustomEventUpdateTaskData taskData = new BytedanceCustomEventUpdateTaskData(); BytedanceCustomEventUpdateTaskData taskData = new BytedanceCustomEventUpdateTaskData();
taskData.setTaskId(taskId); taskData.setTaskId(taskId);
taskData.setEventName(dto.getEventName()); taskData.setPlatformType(dto.getPlatformType());
taskData.setChannel(dto.getChannel());
taskData.setPlatform(dto.getPlatform()); taskData.setPlatform(dto.getPlatform());
taskData.setUrl(dto.getUrl()); taskData.setChannel(dto.getChannel());
taskData.setWeiboComment(dto.getWeiboComment()); taskData.setEventName(dto.getEventName());
taskData.setWeiboForward(dto.getWeiboForward()); taskData.setReading(Objects.isNull(dto.getReading()) ? 0 : Integer.parseInt(dto.getReading()));
taskData.setWeiboLike(dto.getWeiboLike()); taskData.setRead(Objects.isNull(dto.getRead()) ? 0 : Integer.parseInt(dto.getRead()));
taskData.setWechatRead(dto.getWechatRead()); taskData.setLike(Objects.isNull(dto.getLike()) ? 0 : Integer.parseInt(dto.getLike()));
taskData.setWechatReading(dto.getWechatReading()); taskData.setComment(Objects.isNull(dto.getComment()) ? 0 : Integer.parseInt(dto.getComment()));
taskData.setForward(Objects.isNull(dto.getForward()) ? 0 : Integer.parseInt(dto.getForward()));
data.add(taskData); data.add(taskData);
} }
@Override @Override
public void doAfterAllAnalysed(AnalysisContext context) { public void doAfterAllAnalysed(AnalysisContext context) {
} }
} }
...@@ -11,6 +11,7 @@ import lombok.Setter; ...@@ -11,6 +11,7 @@ import lombok.Setter;
*/ */
@Getter @Getter
@Setter @Setter
@Deprecated // 2024.3.22 计算公式调整 弃用
public class BytedanceCustomChannel extends AbstractBaseMongo{ public class BytedanceCustomChannel extends AbstractBaseMongo{
/** /**
......
...@@ -27,4 +27,9 @@ public class BytedanceCustomChannelInfluence extends AbstractBaseMongo{ ...@@ -27,4 +27,9 @@ public class BytedanceCustomChannelInfluence extends AbstractBaseMongo{
* 影响力 * 影响力
*/ */
private double influence; private double influence;
/**
* 渠道等级
*/
private String level;
} }
package com.zhiwei.brandkbs2.pojo;
import lombok.Getter;
import lombok.Setter;
/**
* @ClassName: BytedanceCustomChannelLevelInfo
* @Description 字节定制渠道等级、拐点、极值、权重对照表
* @author: cjz
* @date: 2024-3-20 14:09
*/
@Getter
@Setter
public class BytedanceCustomChannelLevelInfo extends AbstractBaseMongo{
/**
* 等级
*/
private String level;
/**
* HMax
*/
private double HMax;
/**
* 权重
*/
private double weight;
/**
* 临界
*/
private double threshold;
/**
* 系数
*/
private double coefficient;
}
package com.zhiwei.brandkbs2.pojo; package com.zhiwei.brandkbs2.pojo;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO;
import lombok.*; import lombok.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @ClassName: BytedanceCustomEventInfluenceTask * @ClassName: BytedanceCustomEventInfluenceTask
...@@ -40,14 +38,6 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -40,14 +38,6 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
*/ */
private List<EventInfo> eventInfo; private List<EventInfo> eventInfo;
/** /**
* 事件数据
*/
// private Map<String, List<UploadBytedanceEventDTO>> eventData;
/**
* 报错数据
*/
private List<BytedanceCustomEventUpdateTaskData> errorData;
/**
* 竞品影响力指数 * 竞品影响力指数
*/ */
private Double contendInfluence; private Double contendInfluence;
...@@ -88,6 +78,10 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -88,6 +78,10 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
*/ */
private String name; private String name;
/** /**
* 传播量(该事件的数据量)
*/
private Integer dataCount;
/**
* 影响力指数 * 影响力指数
*/ */
private Double influence; private Double influence;
...@@ -145,7 +139,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -145,7 +139,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
task.setProcessStatus(ProcessStatus.CHANNEL_MATCH.getStatus()); task.setProcessStatus(ProcessStatus.CHANNEL_MATCH.getStatus());
task.setExtraCompute(extraCompute); task.setExtraCompute(extraCompute);
task.setEventInfo(new ArrayList<>()); task.setEventInfo(new ArrayList<>());
task.setErrorData(new ArrayList<>()); // task.setErrorData(new ArrayList<>());
task.setCancel(false); task.setCancel(false);
task.setSchedule(0); task.setSchedule(0);
task.setTotalSchedule(0); task.setTotalSchedule(0);
...@@ -165,7 +159,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -165,7 +159,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
task.setProcessStatus(ProcessStatus.QUERY_YUQING.getStatus()); task.setProcessStatus(ProcessStatus.QUERY_YUQING.getStatus());
task.setExtraCompute(false); task.setExtraCompute(false);
task.setEventInfo(null); task.setEventInfo(null);
task.setErrorData(null); // task.setErrorData(null);
task.setCancel(false); task.setCancel(false);
task.setSchedule(0); task.setSchedule(0);
task.setTotalSchedule(0); task.setTotalSchedule(0);
......
...@@ -6,7 +6,7 @@ import lombok.Setter; ...@@ -6,7 +6,7 @@ import lombok.Setter;
/** /**
* @ClassName: BytedanceCustomEventInfluenceTask * @ClassName: BytedanceCustomEventInfluenceTask
* @Description 字节定制事件影响力计算rw * @Description 字节定制事件影响力计算
* @author: cjz * @author: cjz
* @date: 2023-10-16 15:12 * @date: 2023-10-16 15:12
*/ */
...@@ -16,21 +16,21 @@ import lombok.Setter; ...@@ -16,21 +16,21 @@ import lombok.Setter;
public class BytedanceCustomEventUpdateTaskData extends AbstractBaseMongo { public class BytedanceCustomEventUpdateTaskData extends AbstractBaseMongo {
private String taskId; private String taskId;
private String platformType;
private String platform; private String platform;
private String channel; private String channel;
private String url;
private String eventName; private String eventName;
private Integer weiboForward; private Integer reading;
private Integer weiboComment; private Integer read;
private Integer weiboLike; private Integer like;
private Integer wechatRead; private Integer comment;
private Integer wechatReading; private Integer forward;
} }
package com.zhiwei.brandkbs2.service; package com.zhiwei.brandkbs2.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelInfluence;
import com.zhiwei.brandkbs2.pojo.ChannelTag; import com.zhiwei.brandkbs2.pojo.ChannelTag;
import com.zhiwei.brandkbs2.pojo.Project; import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.SensitiveChannel; import com.zhiwei.brandkbs2.pojo.SensitiveChannel;
...@@ -70,4 +71,10 @@ public interface SystemInfoService { ...@@ -70,4 +71,10 @@ public interface SystemInfoService {
* @return * @return
*/ */
Map<String, SensitiveChannel> getCommonSensitiveChannel(); Map<String, SensitiveChannel> getCommonSensitiveChannel();
/**
* 获取字节定制指定渠道影响力信息
* @return
*/
Map<String, BytedanceCustomChannelInfluence> getByteDanceChannelInfluence();
} }
...@@ -3,19 +3,15 @@ package com.zhiwei.brandkbs2.service.impl; ...@@ -3,19 +3,15 @@ package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.zhiwei.brandkbs2.dao.ChannelTagDao; import com.zhiwei.brandkbs2.dao.*;
import com.zhiwei.brandkbs2.dao.MediaTypeDao; import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.dao.ProjectDao;
import com.zhiwei.brandkbs2.dao.QbjcPojoDao;
import com.zhiwei.brandkbs2.pojo.ChannelTag;
import com.zhiwei.brandkbs2.pojo.MediaType;
import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.SensitiveChannel;
import com.zhiwei.brandkbs2.service.SystemInfoService; import com.zhiwei.brandkbs2.service.SystemInfoService;
import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform; import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import com.zhiwei.qbjc.bean.pojo.common.Tag; import com.zhiwei.qbjc.bean.pojo.common.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -48,6 +44,9 @@ public class SystemInfoServiceImpl implements SystemInfoService { ...@@ -48,6 +44,9 @@ public class SystemInfoServiceImpl implements SystemInfoService {
@Resource @Resource
private ProjectDao projectDao; private ProjectDao projectDao;
@Resource(name = "bytedanceCustomChannelInfluenceDao")
private BytedanceCustomChannelInfluenceDao bytedanceCustomChannelInfluenceDao;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
...@@ -132,4 +131,10 @@ public class SystemInfoServiceImpl implements SystemInfoService { ...@@ -132,4 +131,10 @@ public class SystemInfoServiceImpl implements SystemInfoService {
List<SensitiveChannel> commonSensitiveChannel = qbjcPojoDao.findCommonSensitiveChannel(); List<SensitiveChannel> commonSensitiveChannel = qbjcPojoDao.findCommonSensitiveChannel();
return commonSensitiveChannel.stream().collect(Collectors.toMap(SensitiveChannel::getName, o-> o, (k1, k2) -> k1)); return commonSensitiveChannel.stream().collect(Collectors.toMap(SensitiveChannel::getName, o-> o, (k1, k2) -> k1));
} }
@Override
public Map<String, BytedanceCustomChannelInfluence> getByteDanceChannelInfluence() {
return bytedanceCustomChannelInfluenceDao.findList(new Query())
.stream().collect(Collectors.toMap(data -> Tools.concat(data.getPlatform(), data.getChannel()), o -> o, (v1, v2) -> v1));
}
} }
package com.zhiwei.brandkbs2.service.impl; package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.GenericAttribute; import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.controller.app.AppToolsetController; import com.zhiwei.brandkbs2.controller.app.AppToolsetController;
import com.zhiwei.brandkbs2.dao.*; import com.zhiwei.brandkbs2.dao.*;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil; import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
...@@ -109,6 +109,9 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -109,6 +109,9 @@ public class ToolsetServiceImpl implements ToolsetService {
@Resource(name = "BytedanceCustomPlatformWeightDao") @Resource(name = "BytedanceCustomPlatformWeightDao")
private BytedanceCustomPlatformWeightDao bytedanceCustomPlatformWeightDao; private BytedanceCustomPlatformWeightDao bytedanceCustomPlatformWeightDao;
@Resource(name = "bytedanceCustomChannelLevelInfoDao")
private BytedanceCustomChannelLevelInfoDao bytedanceCustomChannelLevelInfoDao;
@Resource(name = "bytedanceCustomEventUpdateTaskDao") @Resource(name = "bytedanceCustomEventUpdateTaskDao")
private BytedanceCustomEventUpdateTaskDao bytedanceCustomEventUpdateTaskDao; private BytedanceCustomEventUpdateTaskDao bytedanceCustomEventUpdateTaskDao;
...@@ -388,6 +391,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -388,6 +391,7 @@ public class ToolsetServiceImpl implements ToolsetService {
} }
@Override @Override
@Deprecated // 2024.3.27 由于不再进行互动量更新故不再进行补充计算
public void eventAdditionalUpdate(MultipartFile file, String taskId) { public void eventAdditionalUpdate(MultipartFile file, String taskId) {
BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId); BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId);
updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.CHANNEL_MATCH); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.CHANNEL_MATCH);
...@@ -400,11 +404,9 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -400,11 +404,9 @@ public class ToolsetServiceImpl implements ToolsetService {
// 将旧数据与新数据合并 // 将旧数据与新数据合并
List<BytedanceCustomEventUpdateTaskData> taskData = bytedanceCustomEventUpdateTaskDataDao.findList(new Query(Criteria.where("taskId").is(taskId))); List<BytedanceCustomEventUpdateTaskData> taskData = bytedanceCustomEventUpdateTaskDataDao.findList(new Query(Criteria.where("taskId").is(taskId)));
taskData.addAll(data); taskData.addAll(data);
// 清空错误旧数据
task.getErrorData().clear();
// 更新进度 // 更新进度
resetProcessSchedule(task.getId(), taskData.size()); resetProcessSchedule(task.getId(), data.size());
ApplicationProjectListener.getThreadPool().execute(() -> processEventUpdate(taskData, task, task.getExtraCompute())); ApplicationProjectListener.getThreadPool().execute(() -> processEventUpdate(data, task, task.getExtraCompute()));
} }
@Override @Override
...@@ -451,7 +453,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -451,7 +453,7 @@ public class ToolsetServiceImpl implements ToolsetService {
return jsonObject; return jsonObject;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
JSONObject info = new JSONObject(); JSONObject info = new JSONObject();
info.put("error", CollectionUtils.isNotEmpty(task.getErrorData())); // info.put("error", CollectionUtils.isNotEmpty(task.getErrorData()));
PageVO<JSONObject> pageVo = PageVO.createPageVo(task.getEventInfo().size(), page, pageSize, list); PageVO<JSONObject> pageVo = PageVO.createPageVo(task.getEventInfo().size(), page, pageSize, list);
pageVo.setInfo(info); pageVo.setInfo(info);
return pageVo; return pageVo;
...@@ -475,6 +477,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -475,6 +477,7 @@ public class ToolsetServiceImpl implements ToolsetService {
dto.setInf(event.getInfluence()); dto.setInf(event.getInfluence());
dto.setRMI(event.getRMI()); dto.setRMI(event.getRMI());
dto.setFinalInf(event.getFinalInfluence()); dto.setFinalInf(event.getFinalInfluence());
dto.setDataCount(event.getDataCount());
return dto; return dto;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// excel写入至指定路径 // excel写入至指定路径
...@@ -485,13 +488,14 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -485,13 +488,14 @@ public class ToolsetServiceImpl implements ToolsetService {
} }
@Override @Override
@Deprecated // 2024.3.27 由于不再进行互动量更新故不会出现错误数据,无需再下载
public String downloadPrimaryErrorData(String taskId) { public String downloadPrimaryErrorData(String taskId) {
BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId); BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId);
// excel写入至指定路径 // excel写入至指定路径
String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName(); String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName();
String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "报错数据"); String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "报错数据");
List<UploadBytedanceEventDTO> collect = task.getErrorData().stream().map(errorData -> Tools.convertMap(errorData, UploadBytedanceEventDTO.class)).collect(Collectors.toList()); // List<UploadBytedanceEventDTO> collect = task.getErrorData().stream().map(errorData -> Tools.convertMap(errorData, UploadBytedanceEventDTO.class)).collect(Collectors.toList());
EasyExcelUtil.write(filePath, "sheet1", UploadBytedanceEventDTO.class, collect); EasyExcelUtil.write(filePath, "sheet1", UploadBytedanceEventDTO.class, Collections.emptyList());
return filePath; return filePath;
} }
...@@ -546,15 +550,20 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -546,15 +550,20 @@ public class ToolsetServiceImpl implements ToolsetService {
private void processEventUpdate(List<BytedanceCustomEventUpdateTaskData> taskData, BytedanceCustomEventUpdateTask task, Boolean extraCompute){ private void processEventUpdate(List<BytedanceCustomEventUpdateTaskData> taskData, BytedanceCustomEventUpdateTask task, Boolean extraCompute){
String taskId = task.getId(); String taskId = task.getId();
try { try {
List<BytedanceCustomEventUpdateTask.EventInfo> eventInfos = new ArrayList<>(); Map<String, BytedanceCustomEventUpdateTask.EventInfo> eventInfoMap = new HashMap<>();
Map<String, List<BytedanceCustomEventUpdateTaskData>> map = taskData.stream().collect(Collectors.groupingBy(BytedanceCustomEventUpdateTaskData::getEventName)); Map<String, List<BytedanceCustomEventUpdateTaskData>> map = taskData.stream().collect(Collectors.groupingBy(BytedanceCustomEventUpdateTaskData::getEventName));
// 渠道等级对照表
Map<String, BytedanceCustomChannelLevelInfo> levelInfoMap = bytedanceCustomChannelLevelInfoDao.findList(new Query()).stream()
.collect(Collectors.toMap(BytedanceCustomChannelLevelInfo::getLevel, o -> o, (v1, v2) -> v1));
for (Map.Entry<String, List<BytedanceCustomEventUpdateTaskData>> entry : map.entrySet()) { for (Map.Entry<String, List<BytedanceCustomEventUpdateTaskData>> entry : map.entrySet()) {
String eventName = entry.getKey();
List<BytedanceCustomEventUpdateTaskData> data = entry.getValue(); List<BytedanceCustomEventUpdateTaskData> data = entry.getValue();
BytedanceCustomEventUpdateTask.EventInfo eventInfo = new BytedanceCustomEventUpdateTask.EventInfo(); BytedanceCustomEventUpdateTask.EventInfo eventInfo = new BytedanceCustomEventUpdateTask.EventInfo();
eventInfo.setName(entry.getKey()); eventInfo.setName(eventName);
eventInfo.setDataCount(data.size());
// 计算影响力指数 // 计算影响力指数
eventInfo.setInfluence(computeInf(data)); eventInfo.setInfluence(computeInf(data, levelInfoMap));
eventInfos.add(eventInfo); eventInfoMap.put(eventName, eventInfo);
// 更新渠道匹配处理进度 // 更新渠道匹配处理进度
addProcessSchedule(taskId, data.size()); addProcessSchedule(taskId, data.size());
} }
...@@ -562,20 +571,19 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -562,20 +571,19 @@ public class ToolsetServiceImpl implements ToolsetService {
if (extraCompute) { if (extraCompute) {
// 更新为互动量更新处理状态 // 更新为互动量更新处理状态
updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INTERACTION_UPDATE); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INTERACTION_UPDATE);
long count = taskData.stream().filter(data -> Objects.isNull(data.getWechatRead()) && Objects.isNull(data.getWechatReading()) && Objects.isNull(data.getWeiboForward())
&& Objects.isNull(data.getWeiboComment()) && Objects.isNull(data.getWeiboLike())).count();
// 更新互动量更新处理进度 // 更新互动量更新处理进度
resetProcessSchedule(taskId, (int) count); resetProcessSchedule(taskId, taskData.size());
for (BytedanceCustomEventUpdateTask.EventInfo eventInfo : eventInfos) { for (Map.Entry<String, BytedanceCustomEventUpdateTask.EventInfo> entry : eventInfoMap.entrySet()) {
List<BytedanceCustomEventUpdateTaskData> data = map.get(eventInfo.getName()); List<BytedanceCustomEventUpdateTaskData> data = map.get(entry.getKey());
BytedanceCustomEventUpdateTask.EventInfo eventInfo = entry.getValue();
// 计算实时传播力 // 计算实时传播力
eventInfo.setRMI(computeRMI(data, task)); eventInfo.setRMI(computeRMI(data));
// 计算传播影响力 // 计算传播影响力
eventInfo.setFinalInfluence(computeFinalInf(eventInfo.getInfluence(), eventInfo.getRMI())); eventInfo.setFinalInfluence(computeFinalInf(eventInfo.getInfluence(), eventInfo.getRMI()));
} }
updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE);
} }
task.setEventInfo(eventInfos); task.setEventInfo(new ArrayList<>(eventInfoMap.values()));
updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.FINISH, BytedanceCustomEventUpdateTask.ProcessStatus.FINISH); updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.FINISH, BytedanceCustomEventUpdateTask.ProcessStatus.FINISH);
}catch (Exception e){ }catch (Exception e){
log.info("本品字节事件影响力补充计算出错-taskId:{}", taskId, e); log.info("本品字节事件影响力补充计算出错-taskId:{}", taskId, e);
...@@ -622,15 +630,18 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -622,15 +630,18 @@ public class ToolsetServiceImpl implements ToolsetService {
for (SearchHit hit : searchResponse.getHits().getHits()) { for (SearchHit hit : searchResponse.getHits().getHits()) {
BaseMap baseMap = Tools.getBaseFromEsMap(hit.getSourceAsMap()); BaseMap baseMap = Tools.getBaseFromEsMap(hit.getSourceAsMap());
BytedanceCustomEventUpdateTaskData dto = new BytedanceCustomEventUpdateTaskData(); BytedanceCustomEventUpdateTaskData dto = new BytedanceCustomEventUpdateTaskData();
dto.setPlatform(baseMap.getPlatform()); dto.setPlatformType(baseMap.getPlatform());
dto.setChannel(baseMap.getSource()); dto.setChannel(baseMap.getSource());
data.add(dto); data.add(dto);
} }
} }
updateStatus(taskId, null, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE); updateStatus(taskId, null, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE);
resetProcessSchedule(taskId, data.size()); resetProcessSchedule(taskId, data.size());
// 渠道等级对照表
Map<String, BytedanceCustomChannelLevelInfo> levelInfoMap = bytedanceCustomChannelLevelInfoDao.findList(new Query()).stream()
.collect(Collectors.toMap(BytedanceCustomChannelLevelInfo::getLevel, o -> o, (v1, v2) -> v1));
// 计算影响力指数 // 计算影响力指数
task.setContendInfluence(computeInf(data)); task.setContendInfluence(computeInf(data, levelInfoMap));
addProcessSchedule(taskId, data.size()); addProcessSchedule(taskId, data.size());
updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.FINISH, BytedanceCustomEventUpdateTask.ProcessStatus.FINISH); updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.FINISH, BytedanceCustomEventUpdateTask.ProcessStatus.FINISH);
}catch (Exception e){ }catch (Exception e){
...@@ -698,49 +709,45 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -698,49 +709,45 @@ public class ToolsetServiceImpl implements ToolsetService {
/** /**
* 计算影响力指数(Inf) * 计算影响力指数(Inf)
* @param data * @param datas
* @return * @return
*/ */
private double computeInf(List<BytedanceCustomEventUpdateTaskData> data){ private Double computeInf(List<BytedanceCustomEventUpdateTaskData> datas, Map<String, BytedanceCustomChannelLevelInfo> levelInfoMap){
double sumH = 0; Map<String, Double> levelSumH = new HashMap<>(5);
if (CollectionUtils.isEmpty(data)){ if (CollectionUtils.isEmpty(datas)){
return sumH; return 0d;
} }
for (BytedanceCustomEventUpdateTaskData datum : data) { for (BytedanceCustomEventUpdateTaskData data : datas) {
// 网媒、平媒、外媒和自媒体四个平台类型的渠道,匹配重要渠道表,如果匹配成功,则按照“网媒”算影响力值。 // 匹配渠道影响力,微博、微信以外的平台一律按照”网媒“处理
if (COMMON_MEDIA.contains(datum.getPlatform()) && bytedanceCustomChannelDao.exist(new Query(Criteria.where("channel").is(datum.getChannel())))){ BytedanceCustomChannelInfluence channelInfluence = GlobalPojo.BYTEDANCE_CHANNEL_INFLUENCE
datum.setPlatform("网媒"); .get(concat(Objects.equals("微博", data.getPlatformType()) && Objects.equals("微信", data.getPlatformType())
} ? data.getPlatformType() : "网媒", data.getChannel()));
// 匹配表中的渠道影响力 // 1.分别将等级为S,A,B,C的渠道各自加和
Query query = new Query();
query.addCriteria(Criteria.where("platform").is(datum.getPlatform()));
query.addCriteria(Criteria.where("channel").is(datum.getChannel()));
BytedanceCustomChannelInfluence channelInfluence = bytedanceCustomChannelInfluenceDao.findOne(query);
if (Objects.nonNull(channelInfluence)){ if (Objects.nonNull(channelInfluence)){
sumH = BigDecimal.valueOf(sumH).add(BigDecimal.valueOf(channelInfluence.getInfluence())).doubleValue(); levelSumH.compute(channelInfluence.getLevel(), (k, v) -> Objects.isNull(v)
}else { ? channelInfluence.getInfluence()
// 如果表中没有匹配,则取事见渠道库中的值 : BigDecimal.valueOf(v).add(BigDecimal.valueOf(channelInfluence.getInfluence())).doubleValue());
ResponseEntity<String> response = restTemplate.getForEntity(channelInfluenceUrl, String.class, datum.getPlatform(), datum.getChannel()); }else { // 如果表中没有匹配,则,影响力取1,渠道等级取D
JSONObject jsonObject = JSON.parseObject(response.getBody()); levelSumH.compute("D", (k, v) -> Objects.isNull(v) ? 1d : BigDecimal.valueOf(v).add(BigDecimal.valueOf(1)).doubleValue());
if (!jsonObject.getBoolean("status") && Objects.nonNull(jsonObject.getBigDecimal("data")) && -1 != jsonObject.getBigDecimal("data").doubleValue()){
sumH = BigDecimal.valueOf(sumH).add(jsonObject.getBigDecimal("data")).doubleValue();
}else { // 库中没有的结果取值为:1
sumH = BigDecimal.valueOf(sumH).add(BigDecimal.valueOf(1)).doubleValue();
}
} }
} }
BigDecimal lnSumH = BigDecimal.valueOf(Math.log(sumH)); // 2.分类各自的影响力计算
BigDecimal lnSumMaxAll = BigDecimal.valueOf(Math.log(SUM_MAX_ALL)); double result = 0;
BigDecimal partResult = lnSumH.divide(lnSumMaxAll, 9, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); BigDecimal bigDecimal100 = BigDecimal.valueOf(100);
// 若sumH<2000,inf=ln(sumH)/ln(sumMaxAll)*100*0.5+sumH/4268*100*0.5 for (Map.Entry<String, Double> entry : levelSumH.entrySet()) {
if (sumH < 2000){ BytedanceCustomChannelLevelInfo levelInfo = levelInfoMap.get(entry.getKey());
BigDecimal denominator = BigDecimal.valueOf(4268).multiply(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(0.5)); Double sumH = entry.getValue();
BigDecimal leftResult = partResult.multiply(BigDecimal.valueOf(0.5)); BigDecimal INF;
BigDecimal rightResult = BigDecimal.valueOf(sumH).divide(denominator, 9, RoundingMode.HALF_UP); // A.当相应等级的SUMH大于等于临界值 INF=LN(H)/LN(Hmax)*100
return leftResult.add(rightResult).setScale(7, RoundingMode.HALF_UP).doubleValue(); if (sumH >= levelInfo.getThreshold()){
INF = BigDecimal.valueOf(Math.log(sumH)).divide(BigDecimal.valueOf(Math.log(levelInfo.getHMax())), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
}else { // B.当相应等级的SUMH小于临界值 INF=sumH/系数*100
INF = BigDecimal.valueOf(sumH).divide(BigDecimal.valueOf(levelInfo.getCoefficient()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
}
// 3.各自乘以权重 结果相加
result = INF.multiply(BigDecimal.valueOf(levelInfo.getWeight())).add(BigDecimal.valueOf(result)).doubleValue();
} }
// 否则,inf=ln(sumH)/ln(sumMaxAll)*100 return BigDecimal.valueOf(result).setScale(1, RoundingMode.HALF_UP).doubleValue();
return partResult.setScale(7, RoundingMode.HALF_UP).doubleValue();
} }
/** /**
...@@ -748,124 +755,114 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -748,124 +755,114 @@ public class ToolsetServiceImpl implements ToolsetService {
* @param data * @param data
* @return * @return
*/ */
private double computeRMI(List<BytedanceCustomEventUpdateTaskData> data, BytedanceCustomEventUpdateTask task){ private Double computeRMI(List<BytedanceCustomEventUpdateTaskData> data){
List<BytedanceCustomEventUpdateTaskData> willBeInteractionUpdateData = new ArrayList<>(); // 1、初始值
int weiboForward = 0; // 微信文章数
int weiboComment = 0; int wechatArticle = (int) data.stream().filter(article -> Objects.equals("微信", article.getPlatformType())).count();
int weiboLike = 0; // 微信阅读数
int wechatRead = 0; int wechatRead = 0;
// 微信在看数
int wechatReading = 0; int wechatReading = 0;
// 微博消息数
int weiboArticle = (int) data.stream().filter(article -> Objects.equals("微博", article.getPlatform())).count(); // 微博消息数(文章数)
// 微信文章数 int weiboArticle = (int) data.stream().filter(article -> Objects.equals("微博", article.getPlatformType())).count();
int wechatArticle = (int) data.stream().filter(article -> Objects.equals("微信", article.getPlatform())).count(); // 微博互动数=转发+评论+点赞
// 网媒文章数 int weiboInteraction = 0;
int normalMediaArticle = (int) data.stream().filter(article -> Objects.equals("网媒", article.getPlatform())).count();
// 其他平台文章数 // 头条文章数
int otherPlatformArticle = (int) data.stream().filter(article -> !Objects.equals("网媒", article.getPlatform()) int toutiaoArticle = (int) data.stream().filter(article -> Objects.equals("今日头条", article.getPlatformType())).count();
&& !Objects.equals("微博", article.getPlatform()) && !Objects.equals("微信", article.getPlatform())).count(); // 头条阅读数
int toutiaoRead = 0;
// 头条互动数=点赞+pc评论
int toutiaoInteraction = 0;
// 网媒文章数=外媒+平媒+网媒+自媒体
int normalMediaArticle = (int) data.stream().filter(article -> Objects.equals("网媒", article.getPlatformType())
|| Objects.equals("外媒", article.getPlatformType()) || Objects.equals("平媒", article.getPlatformType())
|| Objects.equals("自媒体", article.getPlatformType())).count();
// 其他平台文章数 除以上平台以外
int otherPlatformArticle = (int) data.stream().filter(article -> !Objects.equals("网媒", article.getPlatformType())
&& !Objects.equals("微博", article.getPlatformType()) && !Objects.equals("微信", article.getPlatformType())
&& !Objects.equals("今日头条", article.getPlatformType()) && !Objects.equals("外媒", article.getPlatformType())
&& !Objects.equals("平媒", article.getPlatformType()) && !Objects.equals("自媒体", article.getPlatformType())).count();
// 2、统计数值
for (BytedanceCustomEventUpdateTaskData datum : data) { for (BytedanceCustomEventUpdateTaskData datum : data) {
// 选填字段全部未填,后续走互动量更新 if (Objects.equals("微信", datum.getPlatformType())) {
if (Objects.isNull(datum.getWechatRead()) && Objects.isNull(datum.getWechatReading()) && Objects.isNull(datum.getWeiboForward()) wechatRead = wechatRead + datum.getRead();
&& Objects.isNull(datum.getWeiboComment()) && Objects.isNull(datum.getWeiboLike())){ wechatReading = wechatReading + datum.getReading();
willBeInteractionUpdateData.add(datum);
continue;
} }
weiboForward = weiboForward + datum.getWeiboForward(); if (Objects.equals("微博", datum.getPlatformType())) {
weiboComment = weiboComment + datum.getWeiboComment(); // 微博互动数=转发+评论+点赞
weiboLike = weiboLike + datum.getWeiboLike(); weiboInteraction = weiboInteraction + datum.getForward() + datum.getComment() + datum.getLike();
wechatRead = wechatRead + datum.getWechatRead(); }
wechatReading = wechatReading + datum.getWechatReading(); if (Objects.equals("今日头条", datum.getPlatformType())) {
} // 头条阅读数中不包含微头条的数值
data.removeAll(willBeInteractionUpdateData); if (!Objects.equals("微头条", datum.getPlatform())){
// 选填字段全部未填的链接互动量更新结果 toutiaoRead = toutiaoRead + datum.getRead();
try {
List<String> successUrl = new ArrayList<>();
List<String> urls = willBeInteractionUpdateData.stream().map(BytedanceCustomEventUpdateTaskData::getUrl).collect(Collectors.toList());
Map<String, BytedanceCustomEventUpdateTaskData> urlMap = willBeInteractionUpdateData.stream().collect(Collectors.toMap(BytedanceCustomEventUpdateTaskData::getUrl, o -> o, (v1, v2) -> v1));
// 互动量更新
List<JSONObject> jsonObjects = urlInteractionUpdate(urls, task.getId());
for (JSONObject jsonObject : jsonObjects) {
if (200 == jsonObject.getInteger("code")) {
// 成功的链接
String url = jsonObject.getString("url");
successUrl.add(url);
// 转发数
int repostCount = Objects.isNull(jsonObject.getInteger("repostCount")) ? 0 : jsonObject.getIntValue("repostCount");
urlMap.get(url).setWeiboForward(repostCount);
// 评论数
int commentCount = Objects.isNull(jsonObject.getInteger("commentCount")) ? 0 : jsonObject.getIntValue("commentCount");
urlMap.get(url).setWeiboComment(commentCount);
// 点赞数
int likeCount = Objects.isNull(jsonObject.getInteger("likeCount")) ? 0 : jsonObject.getIntValue("likeCount");
urlMap.get(url).setWeiboLike(likeCount);
// 阅读数
int readCount = Objects.isNull(jsonObject.getInteger("readCount")) ? 0 : jsonObject.getIntValue("readCount");
urlMap.get(url).setWechatRead(readCount);
// 在看数,实际使用的是返回结果中的分享数
int shareCount = Objects.isNull(jsonObject.getInteger("shareCount")) ? 0 : jsonObject.getIntValue("shareCount");
urlMap.get(url).setWechatReading(shareCount);
// 累加
weiboForward = weiboForward + repostCount;
weiboComment = weiboComment + commentCount;
weiboLike = weiboLike + likeCount;
wechatRead = wechatRead + readCount;
wechatReading = wechatReading + shareCount;
} }
// 头条互动数=点赞+pc评论
toutiaoInteraction = toutiaoInteraction + datum.getLike() + datum.getComment();
} }
// 报错数据 }
urls.removeAll(successUrl); // 去除成功数据,剩余即为失败数据 // 3、根据公式计算结果
List<BytedanceCustomEventUpdateTaskData> errorData = urls.stream().map(urlMap::get).collect(Collectors.toList());
List<BytedanceCustomEventUpdateTaskData> error = task.getErrorData();
error.addAll(errorData);
task.setErrorData(error);
// 互动量更新成功数据
List<BytedanceCustomEventUpdateTaskData> successData = successUrl.stream().map(urlMap::get).collect(Collectors.toList());
data.addAll(successData);
}catch (Exception e){
log.info("字节事件影响力更新-互动量更新出错-id:{}", task.getId(), e);
List<BytedanceCustomEventUpdateTaskData> errorData = task.getErrorData();
errorData.addAll(willBeInteractionUpdateData);
task.setErrorData(errorData);
}
// 存储数据以用于补充计算
bytedanceCustomEventUpdateTaskDataDao.deleteOneByQuery(new Query(Criteria.where("taskId").is(task.getId())));
bytedanceCustomEventUpdateTaskDataDao.insertMany(data);
// 平台指标权重,常量 // 平台指标权重,常量
Map<String, BytedanceCustomPlatformWeight> weightMap = bytedanceCustomPlatformWeightDao.findList(new Query()) Map<String, BytedanceCustomPlatformWeight> weightMap = bytedanceCustomPlatformWeightDao.findList(new Query())
.stream() .stream()
.collect(Collectors.toMap(BytedanceCustomPlatformWeight::getType, o -> o)); .collect(Collectors.toMap(BytedanceCustomPlatformWeight::getType, o -> o));
BytedanceCustomPlatformWeight normalMediaArticleWeight = weightMap.get("网媒文章数"); BytedanceCustomPlatformWeight normalMediaArticleWeight = weightMap.get("网媒文章数");
BytedanceCustomPlatformWeight otherPlatformArticleWeight = weightMap.get("其他平台文章数"); BytedanceCustomPlatformWeight otherPlatformArticleWeight = weightMap.get("其他平台文章数");
BytedanceCustomPlatformWeight wechatArticleWeight = weightMap.get("微信文章数"); BytedanceCustomPlatformWeight wechatArticleWeight = weightMap.get("微信文章数");
BytedanceCustomPlatformWeight wechatReadWeight = weightMap.get("微信阅读数"); BytedanceCustomPlatformWeight wechatReadWeight = weightMap.get("微信阅读数");
BytedanceCustomPlatformWeight wechatReadingWeight = weightMap.get("微信在看数"); BytedanceCustomPlatformWeight wechatReadingWeight = weightMap.get("微信在看数");
BytedanceCustomPlatformWeight weiboArticleWeight = weightMap.get("微博消息数"); BytedanceCustomPlatformWeight weiboArticleWeight = weightMap.get("微博消息数");
BytedanceCustomPlatformWeight weiboForwardWeight = weightMap.get("微博转发数"); BytedanceCustomPlatformWeight weiboInteractionWeight = weightMap.get("微博互动数");
BytedanceCustomPlatformWeight weiboCommentWeight = weightMap.get("微博评论数");
BytedanceCustomPlatformWeight weiboLikeWeight = weightMap.get("微博点赞数"); BytedanceCustomPlatformWeight toutiaoArticleWeight = weightMap.get("头条文章数");
BytedanceCustomPlatformWeight toutiaoReadWeight = weightMap.get("头条阅读数");
BytedanceCustomPlatformWeight toutiaoInteractionWeight = weightMap.get("头条互动数");
// 标准值计算 // 标准值计算
BigDecimal bigDecimal100 = BigDecimal.valueOf(100); BigDecimal bigDecimal100 = BigDecimal.valueOf(100);
BigDecimal NM = BigDecimal.valueOf(normalMediaArticle).divide(BigDecimal.valueOf(normalMediaArticleWeight.getConstant()), 9, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal OP = BigDecimal.valueOf(otherPlatformArticle).divide(BigDecimal.valueOf(otherPlatformArticleWeight.getConstant()), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); // 网媒文章数:NM标= NM/NM常*100.0
BigDecimal WC = BigDecimal.valueOf(wechatArticle).divide(BigDecimal.valueOf(wechatArticleWeight.getConstant()), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); BigDecimal NM = BigDecimal.valueOf(normalMediaArticle).divide(BigDecimal.valueOf(normalMediaArticleWeight.getConstant()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal WCR = BigDecimal.valueOf(Math.log(wechatRead + 1)).divide(BigDecimal.valueOf(Math.log(wechatReadWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); // 其他平台文章数:OM标= OM/OM常*100.0
BigDecimal WCL = BigDecimal.valueOf(Math.log(wechatReading + 1)).divide(BigDecimal.valueOf(Math.log(wechatReadingWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); BigDecimal OM = BigDecimal.valueOf(otherPlatformArticle).divide(BigDecimal.valueOf(otherPlatformArticleWeight.getConstant()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal WB = BigDecimal.valueOf(weiboArticle).divide(BigDecimal.valueOf(weiboArticleWeight.getConstant()), 9, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal WBF = BigDecimal.valueOf(Math.log(weiboForward + 1)).divide(BigDecimal.valueOf(Math.log(weiboForwardWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); // 微信文章数:WC标= WC/WC常*100.0
BigDecimal WBC = BigDecimal.valueOf(Math.log(weiboComment + 1)).divide(BigDecimal.valueOf(Math.log(weiboCommentWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); BigDecimal WC = BigDecimal.valueOf(wechatArticle).divide(BigDecimal.valueOf(wechatArticleWeight.getConstant()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal WBL = BigDecimal.valueOf(Math.log(weiboLike + 1)).divide(BigDecimal.valueOf(Math.log(weiboLikeWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); // 微信阅读数:WCR标= ln(WCR+1)/ln(WCR常+1)*100.0
// 标准值与权重计算得RMI BigDecimal WCR = BigDecimal.valueOf(Math.log(wechatRead + 1)).divide(BigDecimal.valueOf(Math.log(wechatReadWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 微信在看数:WCL标= ln(WCL+1)/ln(WCL常+1)*100.0
BigDecimal WCL = BigDecimal.valueOf(Math.log(wechatReading + 1)).divide(BigDecimal.valueOf(Math.log(wechatReadingWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 微博消息数:WB标= ln(WB+1)/ln(WB常+1)*100.0
BigDecimal WB = BigDecimal.valueOf(Math.log(weiboArticle + 1)).divide(BigDecimal.valueOf(Math.log(weiboArticleWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 微博互动数:WBI标= ln(WBI+1)/ln(WBI常+1)*100.0
BigDecimal WBI = BigDecimal.valueOf(Math.log(weiboInteraction + 1)).divide(BigDecimal.valueOf(Math.log(weiboInteractionWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 头条文章数:T标= T/T常*100.0
BigDecimal T = BigDecimal.valueOf(toutiaoArticle).divide(BigDecimal.valueOf(toutiaoArticleWeight.getConstant()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 头条阅读数:TR标=ln(TR+1)/ln(TR常+1)*100.0
BigDecimal TR = BigDecimal.valueOf(Math.log(toutiaoRead + 1)).divide(BigDecimal.valueOf(Math.log(toutiaoReadWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 头条互动数:TI标= ln(TI+1)/ln(TI常+1)*100.0
BigDecimal TI = BigDecimal.valueOf(Math.log(toutiaoInteraction + 1)).divide(BigDecimal.valueOf(Math.log(toutiaoInteractionWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
log.info(data.get(0).getEventName() + "-【" + "NM:" + NM.toPlainString() + ",OM:" + OM.toPlainString() + ",WC:" + WC.toPlainString() + ",WCR:" + WCR.toPlainString() + ",WCL:"
+ WCL.toPlainString() + ",WB:" + WB.toPlainString() + ",WBI:" + WBI.toPlainString() + ",T:" + T.toPlainString() + ",TR:" + TR.toPlainString() + ",TI:" + TI.toPlainString() + "】");
// 标准值与权重计算取和得RMI
return NM.multiply(BigDecimal.valueOf(normalMediaArticleWeight.getWeight())) return NM.multiply(BigDecimal.valueOf(normalMediaArticleWeight.getWeight()))
.add(OP.multiply(BigDecimal.valueOf(otherPlatformArticleWeight.getWeight()))) .add(OM.multiply(BigDecimal.valueOf(otherPlatformArticleWeight.getWeight())))
.add(WC.multiply(BigDecimal.valueOf(wechatArticleWeight.getWeight()))) .add(WC.multiply(BigDecimal.valueOf(wechatArticleWeight.getWeight())))
.add(WCR.multiply(BigDecimal.valueOf(wechatReadWeight.getWeight()))) .add(WCR.multiply(BigDecimal.valueOf(wechatReadWeight.getWeight())))
.add(WCL.multiply(BigDecimal.valueOf(wechatReadingWeight.getWeight()))) .add(WCL.multiply(BigDecimal.valueOf(wechatReadingWeight.getWeight())))
.add(WB.multiply(BigDecimal.valueOf(weiboArticleWeight.getWeight()))) .add(WB.multiply(BigDecimal.valueOf(weiboArticleWeight.getWeight())))
.add(WBF.multiply(BigDecimal.valueOf(weiboForwardWeight.getWeight()))) .add(WBI.multiply(BigDecimal.valueOf(weiboInteractionWeight.getWeight())))
.add(WBC.multiply(BigDecimal.valueOf(weiboCommentWeight.getWeight()))) .add(T.multiply(BigDecimal.valueOf(toutiaoArticleWeight.getWeight())))
.add(WBL.multiply(BigDecimal.valueOf(weiboLikeWeight.getWeight()))) .add(TR.multiply(BigDecimal.valueOf(toutiaoReadWeight.getWeight())))
.setScale(7, RoundingMode.HALF_UP) .add(TI.multiply(BigDecimal.valueOf(toutiaoInteractionWeight.getWeight())))
.setScale(1, RoundingMode.HALF_UP)
.doubleValue(); .doubleValue();
} }
...@@ -876,7 +873,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -876,7 +873,7 @@ public class ToolsetServiceImpl implements ToolsetService {
* @return * @return
*/ */
private double computeFinalInf(double inf, double RMI){ private double computeFinalInf(double inf, double RMI){
return BigDecimal.valueOf(inf).add(BigDecimal.valueOf(RMI)).divide(BigDecimal.valueOf(2), 7, RoundingMode.HALF_UP).doubleValue(); return BigDecimal.valueOf(inf).add(BigDecimal.valueOf(RMI)).divide(BigDecimal.valueOf(2), 1, RoundingMode.HALF_UP).doubleValue();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment