Commit 750f0d0c by 陈健智

工具集-事件影响力计算调整

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