Commit c9291125 by 陈健智

工具库-事件影响力更新调整

parent c1036fc1
...@@ -138,4 +138,10 @@ public class AppToolsetController { ...@@ -138,4 +138,10 @@ public class AppToolsetController {
public ResponseResult getIfUnread(){ public ResponseResult getIfUnread(){
return ResponseResult.success(toolsetService.getIfUnread()); return ResponseResult.success(toolsetService.getIfUnread());
} }
@ApiOperation("工具库-获取项目工具库功能显示列表")
@GetMapping("/show-list")
public ResponseResult getProjectToolsetShowList(){
return ResponseResult.success(toolsetService.getProjectToolsetShowList());
}
} }
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTaskData;
/**
* @ClassName: BytedanceCustomEventUpdateTaskDataDao
* @Description BytedanceCustomEventUpdateTaskDataDao
* @author: cjz
* @date: 2023-10-24 13:30
*/
public interface BytedanceCustomEventUpdateTaskDataDao extends BaseMongoDao<BytedanceCustomEventUpdateTaskData> {
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.BytedanceCustomEventUpdateTaskDataDao;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTaskData;
import org.springframework.stereotype.Component;
/**
* @ClassName: BytedanceCustomEventUpdateTaskDataDaoImpl
* @Description BytedanceCustomEventUpdateTaskDataDaoImpl
* @author: cjz
* @date: 2023-10-24 13:31
*/
@Component("bytedanceCustomEventUpdateTaskDataDao")
public class BytedanceCustomEventUpdateTaskDataDaoImpl extends BaseMongoDaoImpl<BytedanceCustomEventUpdateTaskData> implements BytedanceCustomEventUpdateTaskDataDao {
private static final String COLLECTION_NAME = "brandkbs_bytedance_custom_event_task_data";
public BytedanceCustomEventUpdateTaskDataDaoImpl() {
super(COLLECTION_NAME);
}
}
...@@ -3,6 +3,8 @@ package com.zhiwei.brandkbs2.easyexcel.listener; ...@@ -3,6 +3,8 @@ package com.zhiwei.brandkbs2.easyexcel.listener;
import com.alibaba.excel.context.AnalysisContext; 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.util.Tools;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -17,22 +19,30 @@ import java.util.Objects; ...@@ -17,22 +19,30 @@ import java.util.Objects;
*/ */
public class BytedanceEventListener extends AnalysisEventListener<UploadBytedanceEventDTO> { public class BytedanceEventListener extends AnalysisEventListener<UploadBytedanceEventDTO> {
private Map<String, List<UploadBytedanceEventDTO>> map; private String taskId;
private List<BytedanceCustomEventUpdateTaskData> data;
public BytedanceEventListener(Map<String, List<UploadBytedanceEventDTO>> map){
this.map = map; public BytedanceEventListener(String taskId, List<BytedanceCustomEventUpdateTaskData> data){
this.taskId = taskId;
this.data = data;
} }
@Override @Override
public void invoke(UploadBytedanceEventDTO data, AnalysisContext context) { public void invoke(UploadBytedanceEventDTO dto, AnalysisContext context) {
if (map.containsKey(data.getEventName())){ BytedanceCustomEventUpdateTaskData taskData = new BytedanceCustomEventUpdateTaskData();
map.get(data.getEventName()).add(data); taskData.setTaskId(taskId);
}else { taskData.setEventName(dto.getEventName());
List<UploadBytedanceEventDTO> list = new ArrayList<>(); taskData.setChannel(dto.getChannel());
list.add(data); taskData.setPlatform(dto.getPlatform());
map.put(data.getEventName(), list); taskData.setUrl(dto.getUrl());
} taskData.setWeiboComment(dto.getWeiboComment());
taskData.setWeiboForward(dto.getWeiboForward());
taskData.setWeiboLike(dto.getWeiboLike());
taskData.setWechatRead(dto.getWechatRead());
taskData.setWechatReading(dto.getWechatReading());
data.add(taskData);
} }
@Override @Override
......
...@@ -42,11 +42,11 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -42,11 +42,11 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
/** /**
* 事件数据 * 事件数据
*/ */
private Map<String, List<UploadBytedanceEventDTO>> eventData; // private Map<String, List<UploadBytedanceEventDTO>> eventData;
/** /**
* 报错数据 * 报错数据
*/ */
private List<UploadBytedanceEventDTO> errorData; private List<BytedanceCustomEventUpdateTaskData> errorData;
/** /**
* 竞品影响力指数 * 竞品影响力指数
*/ */
...@@ -136,7 +136,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -136,7 +136,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
task.setTaskStatus(TaskStatus.CALCULATING.getStatus()); task.setTaskStatus(TaskStatus.CALCULATING.getStatus());
task.setProcessStatus(ProcessStatus.CHANNEL_MATCH.getStatus()); task.setProcessStatus(ProcessStatus.CHANNEL_MATCH.getStatus());
task.setExtraCompute(extraCompute); task.setExtraCompute(extraCompute);
task.setEventInfo(null); task.setEventInfo(new ArrayList<>());
task.setErrorData(new ArrayList<>()); task.setErrorData(new ArrayList<>());
task.setCancel(false); task.setCancel(false);
task.setProjectId(UserThreadLocal.getProjectId()); task.setProjectId(UserThreadLocal.getProjectId());
......
package com.zhiwei.brandkbs2.pojo;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* @ClassName: BytedanceCustomEventInfluenceTask
* @Description 字节定制事件影响力计算rw
* @author: cjz
* @date: 2023-10-16 15:12
*/
@Getter
@Setter
@NoArgsConstructor
public class BytedanceCustomEventUpdateTaskData extends AbstractBaseMongo {
private String taskId;
private String platform;
private String channel;
private String url;
private String eventName;
private Integer weiboForward;
private Integer weiboComment;
private Integer weiboLike;
private Integer wechatRead;
private Integer wechatReading;
}
...@@ -123,9 +123,7 @@ public class Project extends AbstractProject { ...@@ -123,9 +123,7 @@ public class Project extends AbstractProject {
projectVO.setContendList(this.getContendList()); projectVO.setContendList(this.getContendList());
// 模块配置 // 模块配置
projectVO.setModuleShowList(this.getModuleShowList()); projectVO.setModuleShowList(this.getModuleShowList());
if (Objects.nonNull(this.getToolsetShowList())){
projectVO.setToolsetShowList(this.getToolsetShowList()); projectVO.setToolsetShowList(this.getToolsetShowList());
}
projectVO.setChannelFileUrl(this.getChannelFileUrl()); projectVO.setChannelFileUrl(this.getChannelFileUrl());
projectVO.setNegativeChannelParams(this.getNegativeChannelParams()); projectVO.setNegativeChannelParams(this.getNegativeChannelParams());
projectVO.setPositiveChannelParams(this.getPositiveChannelParams()); projectVO.setPositiveChannelParams(this.getPositiveChannelParams());
......
...@@ -100,7 +100,7 @@ public class ProjectVO { ...@@ -100,7 +100,7 @@ public class ProjectVO {
* 工具库功能入口展示列表(目前有:摘要提取,互动量更新,词云,字节影响力计算,其中前三者默认开启) * 工具库功能入口展示列表(目前有:摘要提取,互动量更新,词云,字节影响力计算,其中前三者默认开启)
*/ */
@ApiModelProperty("工具库功能入口展示列表(目前有:摘要提取,互动量更新,词云,字节影响力计算,其中前三者默认开启)") @ApiModelProperty("工具库功能入口展示列表(目前有:摘要提取,互动量更新,词云,字节影响力计算,其中前三者默认开启)")
private List<String> toolsetShowList = Arrays.asList("articleSummary", "interactionUpdate", "highWord"); private List<String> toolsetShowList;
/** /**
* 黑渠道对应组 * 黑渠道对应组
*/ */
......
...@@ -148,4 +148,10 @@ public interface ToolsetService { ...@@ -148,4 +148,10 @@ public interface ToolsetService {
* @param taskId 任务id * @param taskId 任务id
*/ */
void cancelTask(String taskId); void cancelTask(String taskId);
/**
* 获取项目工具库功能显示列表
* @return
*/
List<String> getProjectToolsetShowList();
} }
...@@ -443,27 +443,27 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -443,27 +443,27 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public PageVO<JSONObject> getToolsetBytedanceCustomInfo(int page, int size, String type) { public PageVO<JSONObject> getToolsetBytedanceCustomInfo(int page, int size, String type) {
Query query = new Query(); Query query = new Query();
long channelTotal = bytedanceCustomChannelDao.count(query);
long channelWeightTotal = bytedanceCustomPlatformWeightDao.count(query);
long channelInfluenceTotal = bytedanceCustomChannelInfluenceDao.count(query);
query.limit(size); query.limit(size);
query.skip((long) (page - 1) * size); query.skip((long) (page - 1) * size);
switch (type){ switch (type){
case "重要媒体": case "重要媒体":
long total = bytedanceCustomChannelDao.count(query); return PageVO.createPageVo(channelTotal, page, size, bytedanceCustomChannelDao.findList(query).stream().map(data ->{
return PageVO.createPageVo(total, page, size, bytedanceCustomChannelDao.findList(query).stream().map(data ->{
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("channel", data.getChannel()); jsonObject.put("channel", data.getChannel());
return jsonObject; return jsonObject;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
case "平台权重": case "平台权重":
long total2 = bytedanceCustomPlatformWeightDao.count(query); return PageVO.createPageVo(channelWeightTotal, page, size, bytedanceCustomPlatformWeightDao.findList(query).stream().map(data ->{
return PageVO.createPageVo(total2, page, size, bytedanceCustomPlatformWeightDao.findList(query).stream().map(data ->{
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("type", data.getType()); jsonObject.put("type", data.getType());
jsonObject.put("weight", data.getWeight()); jsonObject.put("weight", data.getWeight());
return jsonObject; return jsonObject;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
case "渠道影响力": case "渠道影响力":
long total3 = bytedanceCustomChannelInfluenceDao.count(query); return PageVO.createPageVo(channelInfluenceTotal, page, size, bytedanceCustomChannelInfluenceDao.findList(query).stream().map(data ->{
return PageVO.createPageVo(total3, page, size, bytedanceCustomChannelInfluenceDao.findList(query).stream().map(data ->{
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("platform", data.getPlatform()); jsonObject.put("platform", data.getPlatform());
jsonObject.put("channel", data.getChannel()); jsonObject.put("channel", data.getChannel());
......
...@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,10 +5,7 @@ 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.controller.app.AppToolsetController; import com.zhiwei.brandkbs2.controller.app.AppToolsetController;
import com.zhiwei.brandkbs2.dao.BytedanceCustomChannelDao; import com.zhiwei.brandkbs2.dao.*;
import com.zhiwei.brandkbs2.dao.BytedanceCustomChannelInfluenceDao;
import com.zhiwei.brandkbs2.dao.BytedanceCustomEventUpdateTaskDao;
import com.zhiwei.brandkbs2.dao.BytedanceCustomPlatformWeightDao;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil; import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.easyexcel.config.ReadExcelDTO; import com.zhiwei.brandkbs2.easyexcel.config.ReadExcelDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.*; import com.zhiwei.brandkbs2.easyexcel.dto.*;
...@@ -79,9 +76,6 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -79,9 +76,6 @@ public class ToolsetServiceImpl implements ToolsetService {
@Resource(name = "projectServiceImpl") @Resource(name = "projectServiceImpl")
private ProjectService projectService; private ProjectService projectService;
@Resource(name = "markDataServiceImpl")
MarkDataService markDataService;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
...@@ -118,6 +112,9 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -118,6 +112,9 @@ public class ToolsetServiceImpl implements ToolsetService {
@Resource(name = "bytedanceCustomEventUpdateTaskDao") @Resource(name = "bytedanceCustomEventUpdateTaskDao")
private BytedanceCustomEventUpdateTaskDao bytedanceCustomEventUpdateTaskDao; private BytedanceCustomEventUpdateTaskDao bytedanceCustomEventUpdateTaskDao;
@Resource(name = "bytedanceCustomEventUpdateTaskDataDao")
private BytedanceCustomEventUpdateTaskDataDao bytedanceCustomEventUpdateTaskDataDao;
@Resource(name = "esClientDao") @Resource(name = "esClientDao")
private EsClientDao esClientDao; private EsClientDao esClientDao;
...@@ -358,14 +355,15 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -358,14 +355,15 @@ public class ToolsetServiceImpl implements ToolsetService {
public void primaryEventUpdate(MultipartFile file, Boolean extraCompute) { public void primaryEventUpdate(MultipartFile file, Boolean extraCompute) {
BytedanceCustomEventUpdateTask task = BytedanceCustomEventUpdateTask.createTaskPrimary(extraCompute); BytedanceCustomEventUpdateTask task = BytedanceCustomEventUpdateTask.createTaskPrimary(extraCompute);
bytedanceCustomEventUpdateTaskDao.insertOne(task); bytedanceCustomEventUpdateTaskDao.insertOne(task);
Map<String, List<UploadBytedanceEventDTO>> map = new HashMap<>();
List<BytedanceCustomEventUpdateTaskData> data = new ArrayList<>();
// excel信息提取 // excel信息提取
ReadExcelDTO<UploadBytedanceEventDTO> readExcel = new ReadExcelDTO<>(); ReadExcelDTO<UploadBytedanceEventDTO> readExcel = new ReadExcelDTO<>();
readExcel.setClazz(UploadBytedanceEventDTO.class); readExcel.setClazz(UploadBytedanceEventDTO.class);
readExcel.setAnalysisEventListener(new BytedanceEventListener(map)); readExcel.setAnalysisEventListener(new BytedanceEventListener(task.getId(), data));
EasyExcelUtil.read(file, readExcel); EasyExcelUtil.read(file, readExcel);
task.setEventData(map);
ApplicationProjectListener.getThreadPool().execute(() -> processEventUpdate(task, extraCompute)); ApplicationProjectListener.getThreadPool().execute(() -> processEventUpdate(data, task, extraCompute));
} }
@Override @Override
...@@ -379,27 +377,16 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -379,27 +377,16 @@ public class ToolsetServiceImpl implements ToolsetService {
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);
List<BytedanceCustomEventUpdateTaskData> data = new ArrayList<>();
// excel信息提取 // excel信息提取
Map<String, List<UploadBytedanceEventDTO>> map = new HashMap<>();
ReadExcelDTO<UploadBytedanceEventDTO> readExcel = new ReadExcelDTO<>(); ReadExcelDTO<UploadBytedanceEventDTO> readExcel = new ReadExcelDTO<>();
readExcel.setClazz(UploadBytedanceEventDTO.class); readExcel.setClazz(UploadBytedanceEventDTO.class);
readExcel.setAnalysisEventListener(new BytedanceEventListener(map)); readExcel.setAnalysisEventListener(new BytedanceEventListener(taskId, data));
EasyExcelUtil.read(file, readExcel); EasyExcelUtil.read(file, readExcel);
// 将旧数据与新数据合并 // 将旧数据与新数据合并
Map<String, List<UploadBytedanceEventDTO>> eventData = task.getEventData(); List<BytedanceCustomEventUpdateTaskData> taskData = bytedanceCustomEventUpdateTaskDataDao.findList(new Query(Criteria.where("taskId").is(taskId)));
for (Map.Entry<String, List<UploadBytedanceEventDTO>> entry : map.entrySet()) { taskData.addAll(data);
String key = entry.getKey(); ApplicationProjectListener.getThreadPool().execute(() -> processEventUpdate(taskData, task, task.getExtraCompute()));
List<UploadBytedanceEventDTO> value = entry.getValue();
eventData.compute(key, (k, v) -> {
if (Objects.nonNull(v)) {
v.addAll(value);
return v;
}
return value;
});
}
task.setEventData(eventData);
ApplicationProjectListener.getThreadPool().execute(() -> processEventUpdate(task, task.getExtraCompute()));
} }
@Override @Override
...@@ -408,6 +395,10 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -408,6 +395,10 @@ public class ToolsetServiceImpl implements ToolsetService {
.with(Sort.by(Sort.Direction.DESC, "uTime")); .with(Sort.by(Sort.Direction.DESC, "uTime"));
BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOne(query); BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOne(query);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
if (Objects.isNull(task)){
jsonObject.put("stopSchedule", true);
return jsonObject;
}
jsonObject.put("type", task.getType()); jsonObject.put("type", task.getType());
jsonObject.put("taskStatus", task.getTaskStatus()); jsonObject.put("taskStatus", task.getTaskStatus());
jsonObject.put("processStatus", task.getProcessStatus()); jsonObject.put("processStatus", task.getProcessStatus());
...@@ -479,7 +470,8 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -479,7 +470,8 @@ public class ToolsetServiceImpl implements ToolsetService {
// 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(), "报错数据");
EasyExcelUtil.write(filePath, "sheet1", UploadBytedanceEventDTO.class, task.getErrorData()); List<UploadBytedanceEventDTO> collect = task.getErrorData().stream().map(errorData -> Tools.convertMap(errorData, UploadBytedanceEventDTO.class)).collect(Collectors.toList());
EasyExcelUtil.write(filePath, "sheet1", UploadBytedanceEventDTO.class, collect);
return filePath; return filePath;
} }
...@@ -520,18 +512,25 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -520,18 +512,25 @@ public class ToolsetServiceImpl implements ToolsetService {
bytedanceCustomEventUpdateTaskDao.updateOne(task); bytedanceCustomEventUpdateTaskDao.updateOne(task);
} }
@Override
public List<String> getProjectToolsetShowList() {
Project project = projectService.getProjectById(UserThreadLocal.getProjectId());
return project.getToolsetShowList();
}
/** /**
* 处理字节定制本品事件影响力更新 * 处理字节定制本品事件影响力更新
* @param task * @param task
* @param extraCompute * @param extraCompute
*/ */
private void processEventUpdate(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<>(); List<BytedanceCustomEventUpdateTask.EventInfo> eventInfos = new ArrayList<>();
Map<String, List<UploadBytedanceEventDTO>> map = task.getEventData(); Map<String, List<BytedanceCustomEventUpdateTaskData>> map =
for (Map.Entry<String, List<UploadBytedanceEventDTO>> entry : map.entrySet()) { taskData.stream().collect(Collectors.groupingBy(BytedanceCustomEventUpdateTaskData::getEventName));
List<UploadBytedanceEventDTO> data = entry.getValue(); for (Map.Entry<String, List<BytedanceCustomEventUpdateTaskData>> entry : map.entrySet()) {
List<BytedanceCustomEventUpdateTaskData> data = entry.getValue();
BytedanceCustomEventUpdateTask.EventInfo eventInfo = new BytedanceCustomEventUpdateTask.EventInfo(); BytedanceCustomEventUpdateTask.EventInfo eventInfo = new BytedanceCustomEventUpdateTask.EventInfo();
eventInfo.setName(entry.getKey()); eventInfo.setName(entry.getKey());
// 计算影响力指数 // 计算影响力指数
...@@ -543,7 +542,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -543,7 +542,7 @@ public class ToolsetServiceImpl implements ToolsetService {
// 更新为互动量更新处理状态 // 更新为互动量更新处理状态
updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INTERACTION_UPDATE); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INTERACTION_UPDATE);
for (BytedanceCustomEventUpdateTask.EventInfo eventInfo : eventInfos) { for (BytedanceCustomEventUpdateTask.EventInfo eventInfo : eventInfos) {
List<UploadBytedanceEventDTO> data = map.get(eventInfo.getName()); List<BytedanceCustomEventUpdateTaskData> data = map.get(eventInfo.getName());
// 计算实时传播力 // 计算实时传播力
eventInfo.setRMI(computeRMI(data, task)); eventInfo.setRMI(computeRMI(data, task));
// 计算传播影响力 // 计算传播影响力
...@@ -552,17 +551,17 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -552,17 +551,17 @@ public class ToolsetServiceImpl implements ToolsetService {
updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE);
} }
// 移除数据中的错误数据 // 移除数据中的错误数据
for (List<UploadBytedanceEventDTO> value : task.getEventData().values()) { if (CollectionUtils.isNotEmpty(task.getErrorData())){
if (CollectionUtils.isNotEmpty(task.getErrorData())) { taskData.removeAll(task.getErrorData());
value.removeAll(task.getErrorData());
}
} }
bytedanceCustomEventUpdateTaskDataDao.deleteOneByQuery(new Query(Criteria.where("taskId").is(taskId)));
bytedanceCustomEventUpdateTaskDataDao.insertMany(taskData);
task.setEventInfo(eventInfos); task.setEventInfo(eventInfos);
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);
if (!Objects.equals(e.getMessage(), "手动取消")){ if (!Objects.equals(e.getMessage(), "手动取消")){
updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.ERROR, null); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.ERROR);
} }
} }
} }
...@@ -599,11 +598,11 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -599,11 +598,11 @@ public class ToolsetServiceImpl implements ToolsetService {
searchHelper.setIndexes(indexes); searchHelper.setIndexes(indexes);
searchHelper.setPostFilter(postFilter); searchHelper.setPostFilter(postFilter);
List<SearchResponse> searchResponses = esClientDao.searchScrollResponse(searchHelper); List<SearchResponse> searchResponses = esClientDao.searchScrollResponse(searchHelper);
List<UploadBytedanceEventDTO> data = new ArrayList<>(); List<BytedanceCustomEventUpdateTaskData> data = new ArrayList<>();
for (SearchResponse searchResponse : searchResponses) { for (SearchResponse searchResponse : searchResponses) {
for (SearchHit hit : searchResponse.getHits().getHits()) { for (SearchHit hit : searchResponse.getHits().getHits()) {
BaseMap baseMap = Tools.getBaseFromEsMap(hit.getSourceAsMap()); BaseMap baseMap = Tools.getBaseFromEsMap(hit.getSourceAsMap());
UploadBytedanceEventDTO dto = new UploadBytedanceEventDTO(); BytedanceCustomEventUpdateTaskData dto = new BytedanceCustomEventUpdateTaskData();
dto.setPlatform(baseMap.getPlatform()); dto.setPlatform(baseMap.getPlatform());
dto.setChannel(baseMap.getSource()); dto.setChannel(baseMap.getSource());
data.add(dto); data.add(dto);
...@@ -616,7 +615,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -616,7 +615,7 @@ public class ToolsetServiceImpl implements ToolsetService {
}catch (Exception e){ }catch (Exception e){
log.info("竞品字节事件影响力补充计算出错-taskId:{}", taskId, e); log.info("竞品字节事件影响力补充计算出错-taskId:{}", taskId, e);
if (!Objects.equals(e.getMessage(), "手动取消")){ if (!Objects.equals(e.getMessage(), "手动取消")){
updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.ERROR, null); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.ERROR);
} }
} }
} }
...@@ -655,17 +654,24 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -655,17 +654,24 @@ public class ToolsetServiceImpl implements ToolsetService {
bytedanceCustomEventUpdateTaskDao.updateOne(task); bytedanceCustomEventUpdateTaskDao.updateOne(task);
} }
private void updateStatus(String taskId, BytedanceCustomEventUpdateTask.TaskStatus taskStatus){
BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId);
task.setUTime(System.currentTimeMillis());
task.setTaskStatus(taskStatus.getStatus());
bytedanceCustomEventUpdateTaskDao.updateOne(task);
}
/** /**
* 计算影响力指数(Inf) * 计算影响力指数(Inf)
* @param data * @param data
* @return * @return
*/ */
private double computeInf(List<UploadBytedanceEventDTO> data){ private double computeInf(List<BytedanceCustomEventUpdateTaskData> data){
double sumH = 0; double sumH = 0;
if (CollectionUtils.isEmpty(data)){ if (CollectionUtils.isEmpty(data)){
return sumH; return sumH;
} }
for (UploadBytedanceEventDTO datum : data) { for (BytedanceCustomEventUpdateTaskData datum : data) {
// 网媒、平媒、外媒和自媒体四个平台类型的渠道,匹配重要渠道表,如果匹配成功,则按照“网媒”算影响力值。 // 网媒、平媒、外媒和自媒体四个平台类型的渠道,匹配重要渠道表,如果匹配成功,则按照“网媒”算影响力值。
if (COMMON_MEDIA.contains(datum.getPlatform()) && bytedanceCustomChannelDao.exist(new Query(Criteria.where("channel").is(datum.getChannel())))){ if (COMMON_MEDIA.contains(datum.getPlatform()) && bytedanceCustomChannelDao.exist(new Query(Criteria.where("channel").is(datum.getChannel())))){
datum.setPlatform("网媒"); datum.setPlatform("网媒");
...@@ -707,8 +713,8 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -707,8 +713,8 @@ public class ToolsetServiceImpl implements ToolsetService {
* @param data * @param data
* @return * @return
*/ */
private double computeRMI(List<UploadBytedanceEventDTO> data, BytedanceCustomEventUpdateTask task){ private double computeRMI(List<BytedanceCustomEventUpdateTaskData> data, BytedanceCustomEventUpdateTask task){
List<UploadBytedanceEventDTO> willBeInteractionUpdateData = new ArrayList<>(); List<BytedanceCustomEventUpdateTaskData> willBeInteractionUpdateData = new ArrayList<>();
int weiboForward = 0; int weiboForward = 0;
int weiboComment = 0; int weiboComment = 0;
int weiboLike = 0; int weiboLike = 0;
...@@ -723,7 +729,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -723,7 +729,7 @@ public class ToolsetServiceImpl implements ToolsetService {
// 其他平台文章数 // 其他平台文章数
int otherPlatform = (int) data.stream().filter(article -> !Objects.equals("网媒", article.getPlatform()) int otherPlatform = (int) data.stream().filter(article -> !Objects.equals("网媒", article.getPlatform())
&& !Objects.equals("微博", article.getPlatform()) && !Objects.equals("微信", article.getPlatform())).count(); && !Objects.equals("微博", article.getPlatform()) && !Objects.equals("微信", article.getPlatform())).count();
for (UploadBytedanceEventDTO datum : data) { for (BytedanceCustomEventUpdateTaskData datum : data) {
// 选填字段全部未填,后续走互动量更新 // 选填字段全部未填,后续走互动量更新
if (Objects.isNull(datum.getWechatRead()) && Objects.isNull(datum.getWechatReading()) && Objects.isNull(datum.getWeiboForward()) if (Objects.isNull(datum.getWechatRead()) && Objects.isNull(datum.getWechatReading()) && Objects.isNull(datum.getWeiboForward())
&& Objects.isNull(datum.getWeiboComment()) && Objects.isNull(datum.getWeiboLike())){ && Objects.isNull(datum.getWeiboComment()) && Objects.isNull(datum.getWeiboLike())){
...@@ -738,7 +744,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -738,7 +744,7 @@ public class ToolsetServiceImpl implements ToolsetService {
} }
// 选填字段全部未填的链接互动量更新结果 // 选填字段全部未填的链接互动量更新结果
try { try {
List<String> urls = willBeInteractionUpdateData.stream().map(UploadBytedanceEventDTO::getUrl).collect(Collectors.toList()); List<String> urls = willBeInteractionUpdateData.stream().map(BytedanceCustomEventUpdateTaskData::getUrl).collect(Collectors.toList());
List<JSONObject> jsonObjects = urlInteractionUpdate(urls); List<JSONObject> jsonObjects = urlInteractionUpdate(urls);
for (JSONObject jsonObject : jsonObjects) { for (JSONObject jsonObject : jsonObjects) {
// 转发数 // 转发数
...@@ -760,7 +766,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -760,7 +766,7 @@ public class ToolsetServiceImpl implements ToolsetService {
}catch (Exception e){ }catch (Exception e){
// 报错数据:为互动量更新失败数据,更新失败数据不参与计算 // 报错数据:为互动量更新失败数据,更新失败数据不参与计算
log.info("字节事件影响力更新-互动量更新出错-id:{}", task.getId(), e); log.info("字节事件影响力更新-互动量更新出错-id:{}", task.getId(), e);
List<UploadBytedanceEventDTO> errorData = task.getErrorData(); List<BytedanceCustomEventUpdateTaskData> errorData = task.getErrorData();
errorData.addAll(willBeInteractionUpdateData); errorData.addAll(willBeInteractionUpdateData);
task.setErrorData(errorData); task.setErrorData(errorData);
} }
......
application.name = brandkbs2 application.name = brandkbs2
server.port=8888 server.port=8888
spring.flyway.encoding=UTF-8 spring.flyway.encoding=UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size=10MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size=20MB
server.servlet.context-path=/brandkbs server.servlet.context-path=/brandkbs
#jwt #jwt
jwt.key=Token jwt.key=Token
......
application.name = brandkbs2 application.name = brandkbs2
server.port=8888 server.port=8888
spring.flyway.encoding=UTF-8 spring.flyway.encoding=UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size=10MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size=20MB
server.servlet.context-path=/brandkbs server.servlet.context-path=/brandkbs
#jwt #jwt
jwt.key=Token jwt.key=Token
jwt.hour=120 jwt.hour=120
#\u8DEF\u5F84\u5B58\u653E #\u8DEF\u5F84\u5B58\u653E
brandkbs.file.url=E:\\work3\\brandkbs3\\ brandkbs.file.url=D:\\ExcelTest\\
brandkbs.img.url=E:\\work\\brandkbs2\\img\\ brandkbs.img.url=D:\\ExcelTest\\
brandkbs.head.url=E:\\work\\brandkbs2\\head\\ brandkbs.head.url=D:\\ExcelTest\\
brandkbs.image.url=https://brandkbs.zhiweidata.com/brandkbs/images/ brandkbs.image.url=https://brandkbs.zhiweidata.com/brandkbs/images/
#\u56FE\u7247\u8D44\u6E90\u8DEF\u5F84 #\u56FE\u7247\u8D44\u6E90\u8DEF\u5F84
cbs.imagesPath=file:${brandkbs.img.url},file:${brandkbs.head.url} cbs.imagesPath=file:${brandkbs.img.url},file:${brandkbs.head.url}
......
application.name = brandkbs2 application.name = brandkbs2
server.port=8888 server.port=8888
spring.flyway.encoding=UTF-8 spring.flyway.encoding=UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size=10MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size=20MB
server.servlet.context-path=/brandkbs server.servlet.context-path=/brandkbs
#jwt #jwt
jwt.key=Token jwt.key=Token
......
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