Commit d32e6bad by shenjunjie

调整简报竞品格式

parent 8313d494
......@@ -190,4 +190,12 @@ public class AppArticleController extends BaseController {
return ResponseResult.success();
}
@ApiOperation("舆情简报-简报状态轮询接口")
@ApiImplicitParam(name = "idList", value = "报告ID列表", required = true, paramType = "body", dataType = "list")
@PostMapping("report/schedule")
public ResponseResult scheduleReportStatus(@RequestBody JSONObject json) {
List<String> idList = json.getJSONArray("idList").toJavaList(String.class);
return reportService.getReportSchedule(idList);
}
}
package com.zhiwei.brandkbs2.controller.app;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.pojo.dto.ExportAppYuqingDTO;
import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.service.ProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ClassName AppContendController
......@@ -60,8 +53,10 @@ public class AppContendController extends BaseController {
@ApiOperation("竞品库-竞品对比-传播分析页面")
@PostMapping("/spread/analyze")
public ResponseResult getSpreadAnalyze(@RequestBody MarkSearchDTO markSearchDTO) throws IOException {
return ResponseResult.success(markDataService.getContendSpreadAnalyze(markSearchDTO, 5, true));
public ResponseResult getSpreadAnalyze(@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "contendId") String contendId) throws IOException {
return ResponseResult.success(markDataService.getContendSpreadAnalyze(startTime, endTime, UserThreadLocal.getProjectId(), contendId, 5, true));
}
@ApiOperation("竞品库-竞品舆情-舆情导出")
......
......@@ -34,7 +34,7 @@ public class ExceptionCatch {
Exception exception = customException.getException();
//记录日志
if (null == exception) {
log.error("catch exception-custom:{}", resultCode.message());
log.info("catch exception-custom:{}", resultCode.message());
} else {
log.error("catch exception-custom:{}", resultCode.message(), exception);
}
......
......@@ -57,6 +57,8 @@ public class Report extends AbstractBaseMongo {
*/
private String userId;
private boolean status;
public static Report createFromReportDTO(ReportDTO reportDTO) {
Report report = new Report();
report.setTitle(reportDTO.getTitle());
......
......@@ -228,7 +228,7 @@ public interface MarkDataService {
* @param cache 是否启用缓存
* @return JSONObject
*/
JSONObject getContendSpreadAnalyze(MarkSearchDTO markSearchDTO, int hotArticleSize, boolean cache) throws IOException;
JSONObject getContendSpreadAnalyze(Long startTime, Long endTime, String projectId, String contendId, int hotArticleSize, boolean useCache) throws IOException;
/**
* 竞品库-舆情导出
......
package com.zhiwei.brandkbs2.service;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.AbstractProject;
import com.zhiwei.brandkbs2.pojo.Report;
import com.zhiwei.brandkbs2.pojo.ReportSettings;
......@@ -111,4 +112,11 @@ public interface ReportService {
*/
void deleteReportById(String id);
/**
* 获取ID列表查询状态结果
* @param idList
* @return
*/
ResponseResult getReportSchedule(List<String> idList);
}
......@@ -1108,46 +1108,45 @@ public class MarkDataServiceImpl implements MarkDataService {
}
@Override
public JSONObject getContendSpreadAnalyze(MarkSearchDTO dto, int hotArticleSize, boolean cache) throws IOException {
defaultContendDTO(dto);
ProjectVO project = projectService.getProjectVOById(dto.getProjectId());
public JSONObject getContendSpreadAnalyze(Long startTime, Long endTime, String projectId, String contendId, int hotArticleSize, boolean cache) throws IOException {
ProjectVO project = projectService.getProjectVOById(projectId);
// 竞品的名字
AbstractProject projectByContendId = projectService.getProjectByContendId(dto.getProjectId(), dto.getContendId());
AbstractProject projectByContendId = projectService.getProjectByContendId(projectId, contendId);
String brandName = projectByContendId.getBrandName();
String contendLinkedGroupId = projectByContendId.getBrandLinkedGroupId();
// 缓存
SimpleDateFormat sdf = new SimpleDateFormat(Constant.DAY_PATTERN);
String startTimeStr = sdf.format(dto.getStartTime());
String endTimeStr = sdf.format(dto.getEndTime());
String redisKey = RedisKeyPrefix.INDEX_COMPARE_ANALYZE + Tools.concat(dto.getProjectId(), dto.getContendId(), startTimeStr, endTimeStr, hotArticleSize);
String startTimeStr = sdf.format(startTime);
String endTimeStr = sdf.format(endTime);
String redisKey = RedisKeyPrefix.INDEX_COMPARE_ANALYZE + Tools.concat(projectId, contendId, startTimeStr, endTimeStr, hotArticleSize);
if (cache) {
String result = redisUtil.get(redisKey);
if (Objects.nonNull(result)) {
return JSON.parseObject(result);
}
}
List<Map<String, Long>> dayList = Tools.parseToDays(dto.getStartTime(), dto.getEndTime());
List<Map<String, Long>> dayList = Tools.parseToDays(startTime, endTime);
List<JSONObject> resList = new ArrayList<>(2);
JSONObject result = new JSONObject();
// 开始时间
result.put("startTime", dto.getStartTime());
result.put("startTime", startTime);
// 结束时间
result.put("endTime", dto.getEndTime());
result.put("endTime", endTime);
// 主品牌图谱
JSONObject primaryLine = new JSONObject();
primaryLine.put("id", Constant.PRIMARY_CONTEND_ID);
primaryLine.put("brand", project.getBrandName());
List<LineVO> primarySpread = getArticleSpread(dto.getProjectId(), dto.getLinkedGroupId(), Constant.PRIMARY_CONTEND_ID, dayList);
List<LineVO> primarySpread = getArticleSpread(projectId, project.getBrandLinkedGroupId(), Constant.PRIMARY_CONTEND_ID, dayList);
primaryLine.put("spread", primarySpread);
resList.add(primaryLine);
result.put("days", primarySpread.size());
// 竞品图谱
JSONObject contendLine = new JSONObject();
contendLine.put("id", dto.getContendId());
contendLine.put("id", contendId);
contendLine.put("brand", brandName);
List<LineVO> contendSpread = getArticleSpread(dto.getProjectId(), contendLinkedGroupId, dto.getContendId(), dayList);
List<LineVO> contendSpread = getArticleSpread(projectId, contendLinkedGroupId, contendId, dayList);
contendLine.put("spread", contendSpread);
resList.add(contendLine);
result.put("spread", resList);
......@@ -1167,20 +1166,23 @@ public class MarkDataServiceImpl implements MarkDataService {
long priMaxDayStartTime = primaryMax.getDate();
long priMaxDayEndTime = DateUtils.addDays(new Date(primaryMax.getDate()), 1).getTime();
// 获取时间段某情感数据最多的标题
List<Map.Entry<String, Integer>> priTopTitle = getMarkTopTitle(priMaxDayStartTime, priMaxDayEndTime, EmotionEnum.ALL.getName(), dto.getProjectId(), dto.getLinkedGroupId(), Constant.PRIMARY_CONTEND_ID, 1);
List<Map.Entry<String, Integer>> priTopTitle = getMarkTopTitle(priMaxDayStartTime, priMaxDayEndTime, EmotionEnum.ALL.getName(), projectId,
project.getBrandLinkedGroupId(), Constant.PRIMARY_CONTEND_ID, 1);
if (CollectionUtils.isNotEmpty(priTopTitle)) {
// 首发稿件
BaseMap priFirstArticle = getFirstArticle(priMaxDayStartTime, priMaxDayEndTime, priTopTitle.get(0).getKey(), dto.getProjectId(), dto.getLinkedGroupId(), Constant.PRIMARY_CONTEND_ID);
BaseMap priFirstArticle = getFirstArticle(priMaxDayStartTime, priMaxDayEndTime, priTopTitle.get(0).getKey(), projectId, project.getBrandLinkedGroupId(),
Constant.PRIMARY_CONTEND_ID);
result.put("priTopTitle", priFirstArticle.getTitle());
result.put("priTopTitleUrl", priFirstArticle.getUrl());
}
// 获取主品牌热门媒体方向
List<Map.Entry<String, Integer>> priHotTitles = getMarkTopTitle(priMaxDayStartTime, priMaxDayEndTime, EmotionEnum.ALL.getName(), dto.getProjectId(), dto.getLinkedGroupId(), Constant.PRIMARY_CONTEND_ID, hotArticleSize);
List<Map.Entry<String, Integer>> priHotTitles = getMarkTopTitle(priMaxDayStartTime, priMaxDayEndTime, EmotionEnum.ALL.getName(), projectId, project.getBrandLinkedGroupId(), Constant.PRIMARY_CONTEND_ID, hotArticleSize);
if (CollectionUtils.isNotEmpty(priHotTitles)) {
List<JSONObject> priHotArticle = priHotTitles.stream().map(map -> {
JSONObject jsonObject = new JSONObject();
try {
BaseMap priFirstArticle = getFirstArticle(dto.getStartTime(), dto.getEndTime(), map.getKey(), dto.getProjectId(), dto.getLinkedGroupId(), Constant.PRIMARY_CONTEND_ID);
BaseMap priFirstArticle = getFirstArticle(startTime, endTime, map.getKey(), projectId, project.getBrandLinkedGroupId(),
Constant.PRIMARY_CONTEND_ID);
if (null != priFirstArticle) {
jsonObject.put("title", priFirstArticle.getTitle());
jsonObject.put("url", priFirstArticle.getUrl());
......@@ -1209,20 +1211,23 @@ public class MarkDataServiceImpl implements MarkDataService {
result.put("conMaxCount", contendMax.getCount());
long conMaxDayStartTime = contendMax.getDate();
long conMaxDayEndTime = DateUtils.addDays(new Date(contendMax.getDate()), 1).getTime();
List<Map.Entry<String, Integer>> conTopTitle = getMarkTopTitle(conMaxDayStartTime, conMaxDayEndTime, EmotionEnum.ALL.getName(), dto.getProjectId(), contendLinkedGroupId, dto.getContendId(), 1);
List<Map.Entry<String, Integer>> conTopTitle = getMarkTopTitle(conMaxDayStartTime, conMaxDayEndTime, EmotionEnum.ALL.getName(),projectId,
contendLinkedGroupId, contendId, 1);
if (CollectionUtils.isNotEmpty(conTopTitle)) {
// 首发稿件
BaseMap conFirstArticle = getFirstArticle(conMaxDayStartTime, conMaxDayEndTime, conTopTitle.get(0).getKey(), dto.getProjectId(), contendLinkedGroupId, dto.getContendId());
BaseMap conFirstArticle = getFirstArticle(conMaxDayStartTime, conMaxDayEndTime, conTopTitle.get(0).getKey(), projectId, contendLinkedGroupId,
contendId);
result.put("conTopTitle", conFirstArticle.getTitle());
result.put("conTopTitleUrl", conFirstArticle.getUrl());
}
// 获取竞品热门媒体方向
List<Map.Entry<String, Integer>> conHotTitles = getMarkTopTitle(conMaxDayStartTime, conMaxDayEndTime, EmotionEnum.ALL.getName(), dto.getProjectId(), contendLinkedGroupId, dto.getContendId(), hotArticleSize);
List<Map.Entry<String, Integer>> conHotTitles = getMarkTopTitle(conMaxDayStartTime, conMaxDayEndTime, EmotionEnum.ALL.getName(), projectId,
contendLinkedGroupId, contendId, hotArticleSize);
if (CollectionUtils.isNotEmpty(conHotTitles)) {
List<JSONObject> conHotArticle = conHotTitles.stream().map(map -> {
JSONObject jsonObject = new JSONObject();
try {
BaseMap conFirstArticle = getFirstArticle(dto.getStartTime(), dto.getEndTime(), map.getKey(), dto.getProjectId(), contendLinkedGroupId, dto.getContendId());
BaseMap conFirstArticle = getFirstArticle(startTime, endTime, map.getKey(), projectId, contendLinkedGroupId, contendId);
if (null != conFirstArticle) {
jsonObject.put("title", conFirstArticle.getTitle());
jsonObject.put("url", conFirstArticle.getUrl());
......
......@@ -15,6 +15,7 @@ import com.zhiwei.brandkbs2.enmus.response.ReportCodeEnum;
import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.listener.ApplicationProjectListener;
import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.AbstractProject;
import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.pojo.Report;
......@@ -212,6 +213,7 @@ public class ReportServiceImpl implements ReportService {
@Override
public JSONObject getPcReportAnalyze(String id, boolean cache) {
switchReportStatus(id, false);
return getPcReportAnalyze(reportDao.findOneById(id), cache);
}
......@@ -273,7 +275,8 @@ public class ReportServiceImpl implements ReportService {
List<JSONObject> resList = reportList.stream().map(report -> {
JSONObject result = new JSONObject();
result.put("id", report.getId());
result.put("status", null != redisUtil.get(RedisKeyPrefix.REPORT_PC + report.getId()));
// result.put("status", null != redisUtil.get(RedisKeyPrefix.REPORT_PC + report.getId()));
result.put("status", report.isStatus());
result.put("title", report.getTitle());
result.put("startTime", report.getStartTime());
result.put("endTime", report.getEndTime());
......@@ -302,6 +305,30 @@ public class ReportServiceImpl implements ReportService {
reportDao.deleteOneByIdWithQuery(id, Query.query(Criteria.where("type").is(ReportTypeEnum.CUSTOM.getState())));
}
@Override
public ResponseResult getReportSchedule(List<String> idList) {
if (null == idList || idList.isEmpty()) {
return ResponseResult.success();
}
boolean isEnd = true;
Map<String, Boolean> listStatus = new HashMap<>();
for (String id : idList) {
Report report = reportDao.findOneById(id);
if (null == report) {
listStatus.put(id, true);
continue;
}
if (!report.isStatus()) {
isEnd = false;
}
listStatus.put(id, report.isStatus());
}
JSONObject res = new JSONObject();
res.put("isEnd", isEnd);
res.put("listStatus", listStatus);
return ResponseResult.success(res);
}
/**
* 获取PC端月报结果
*
......@@ -331,7 +358,11 @@ public class ReportServiceImpl implements ReportService {
AbstractProject abstractProject = projectService.getProjectByContendId(projectId, brandContendId);
json.put("id", brandContendId);
json.put("brand", abstractProject.getBrandName());
json.put("brandCompare", indexService.getSpreadingTend(startTime, endTime, projectId, contendId, true));
try {
json.put("brandCompare", markDataService.getContendSpreadAnalyze(startTime, endTime, projectId, contendId, 5, true));
} catch (IOException e) {
log.error("getPcReportResult-brandCompare-", e);
}
return json;
}).collect(Collectors.toList());
result.put("contendCompare", contendCompare);
......
......@@ -10,8 +10,8 @@ dev.robot.push.filterclass=org.apache.dubbo.common.Version,com.alibaba.dubbo.com
dev.robot.push.level=error
dev.robot.push.app.name=brandkbs2-dev
prod.robot.push.address=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=759b600c-d47a-4c6b-9a9b-90b6c80d343c
prod.robot.push.enable=true
prod.robot.push.filterclass=org.apache.dubbo.common.Version,com.alibaba.dubbo.common.Version,org.apache.dubbo.monitor.dubbo.DubboMonitor,com.alibaba.dubbo\.monitor.dubbo.DubboMonitor
prod.robot.push.level=error
prod.robot.push.app.name=brandkbs2-prod
\ No newline at end of file
pro.robot.push.address=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=759b600c-d47a-4c6b-9a9b-90b6c80d343c
pro.robot.push.enable=true
pro.robot.push.filterclass=org.apache.dubbo.common.Version,com.alibaba.dubbo.common.Version,org.apache.dubbo.monitor.dubbo.DubboMonitor,com.alibaba.dubbo.monitor.dubbo.DubboMonitor
pro.robot.push.level=error
pro.robot.push.app.name=brandkbs2-prod
\ No newline at end of file
......@@ -167,8 +167,11 @@ public class MarkDataServiceTest {
@Test
public void getContendSpreadAnalyzeTest() throws IOException {
MarkSearchDTO dto = new MarkSearchDTO();
JSONObject contendSpreadAnalyze = markDataService.getContendSpreadAnalyze(dto, 5, false);
Long startTime = null;
Long endTime = null;
String projectId = null;
String contendId = null;
JSONObject contendSpreadAnalyze = markDataService.getContendSpreadAnalyze(startTime, endTime, projectId, contendId, 5, false);
System.out.println(contendSpreadAnalyze);
}
......
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