Commit 00cc4f36 by 陈健智

Merge remote-tracking branch 'origin/feature' into feature

parents f077b961 ba4b55cf
......@@ -4,6 +4,7 @@ package com.zhiwei.brandkbs2.controller.app;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
......@@ -71,6 +72,9 @@ public class AppSearchController extends BaseController {
@Resource(name = "commonServiceImpl")
CommonService commonService;
@Resource(name = "projectServiceImpl")
ProjectService projectService;
@ApiOperation("搜索-查热点")
@GetMapping("/hot/list")
public ResponseResult searchHotList(@RequestParam(value = "pageSize", defaultValue = "10") Integer limit,
......@@ -129,15 +133,18 @@ public class AppSearchController extends BaseController {
@ApiOperation("搜索-全网搜")
@PostMapping("/searchWhole")
public ResponseResult searchWholeNetwork(@RequestBody SearchFilterDTO dto) {
long time = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), -89).getTime();
if (time > dto.getStartTime()) {
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return ResponseResult.failure("仅能搜索近3个月内信息");
}
Period periodDay = new Period(dto.getStartTime(), dto.getEndTime(), PeriodType.days());
if (periodDay.getDays() > 30) {
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return ResponseResult.failure("时间跨度不能超过30天");
// 针对商业数据库做限制
if (2 == projectService.getProjectById(UserThreadLocal.getProjectId()).getWholeSearchDataSource()) {
long time = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), -89).getTime();
if (time > dto.getStartTime()) {
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return ResponseResult.failure("仅能搜索近3个月内信息");
}
Period periodDay = new Period(dto.getStartTime(), dto.getEndTime(), PeriodType.days());
if (periodDay.getDays() > 30) {
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return ResponseResult.failure("时间跨度不能超过30天");
}
}
return ResponseResult.success(markDataService.searchWholeNetwork(dto));
}
......
......@@ -85,11 +85,13 @@ public class ResponseResult {
/**
* 操作失败带返回数据
*
* @param data 返回数据
* @param message 失败信息
* @return 操作失败带返回数据
*/
public static ResponseResult failure(Object data) {
return new ResponseResult(CommonCodeEnum.FAIL, data);
public static ResponseResult failure(String message) {
ResponseResult responseResult = new ResponseResult(CommonCodeEnum.FAIL, null);
responseResult.setMessage(message);
return responseResult;
}
/**
......
......@@ -1160,10 +1160,10 @@ public class MarkDataServiceImpl implements MarkDataService {
result.put("priGtAvg", priGreaterThanAvg);
// 获取主品牌传播峰值时信息
LineVO primaryMax = primarySpread.stream().max(Comparator.comparing(LineVO::getCount)).orElse(new LineVO());
result.put("priMaxTime", sdf.format(primaryMax.getDate()));
result.put("priMaxTime", primaryMax.getDate());
result.put("priMaxCount", primaryMax.getCount());
long priMaxDayStartTime = primaryMax.getDate();
long priMaxDayEndTime = DateUtils.addDays(new Date(primaryMax.getDate()), 1).getTime();
long priMaxDayStartTime = Tools.truncDate(primaryMax.getDate(), Constant.DAY_PATTERN);
long priMaxDayEndTime = DateUtils.addDays(new Date(priMaxDayStartTime), 1).getTime();
// 获取时间段某情感数据最多的标题
List<Map.Entry<String, Integer>> priTopTitle = getMarkTopTitle(priMaxDayStartTime, priMaxDayEndTime, EmotionEnum.ALL.getName(), projectId,
project.getBrandLinkedGroupId(), Constant.PRIMARY_CONTEND_ID, 1);
......@@ -1175,7 +1175,8 @@ public class MarkDataServiceImpl implements MarkDataService {
result.put("priTopTitleUrl", priFirstArticle.getUrl());
}
// 获取主品牌热门媒体方向
List<Map.Entry<String, Integer>> priHotTitles = getMarkTopTitle(priMaxDayStartTime, priMaxDayEndTime, EmotionEnum.ALL.getName(), projectId, project.getBrandLinkedGroupId(), Constant.PRIMARY_CONTEND_ID, hotArticleSize);
List<Map.Entry<String, Integer>> priHotTitles = getMarkTopTitle(startTime, endTime, 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();
......@@ -1206,10 +1207,11 @@ public class MarkDataServiceImpl implements MarkDataService {
result.put("conGtAvg", conGreaterThanAvg);
//获取竞品传播峰值信息
LineVO contendMax = contendSpread.stream().max(Comparator.comparing(LineVO::getCount)).orElse(new LineVO());
result.put("conMaxTime", sdf.format(contendMax.getDate()));
result.put("conMaxTime", contendMax.getDate());
result.put("conMaxCount", contendMax.getCount());
long conMaxDayStartTime = contendMax.getDate();
long conMaxDayEndTime = DateUtils.addDays(new Date(contendMax.getDate()), 1).getTime();
long conMaxDayStartTime = Tools.truncDate(contendMax.getDate(), Constant.DAY_PATTERN);
long conMaxDayEndTime = DateUtils.addDays(new Date(conMaxDayStartTime), 1).getTime();
List<Map.Entry<String, Integer>> conTopTitle = getMarkTopTitle(conMaxDayStartTime, conMaxDayEndTime, EmotionEnum.ALL.getName(),projectId,
contendLinkedGroupId, contendId, 1);
if (CollectionUtils.isNotEmpty(conTopTitle)) {
......@@ -1220,7 +1222,7 @@ public class MarkDataServiceImpl implements MarkDataService {
result.put("conTopTitleUrl", conFirstArticle.getUrl());
}
// 获取竞品热门媒体方向
List<Map.Entry<String, Integer>> conHotTitles = getMarkTopTitle(conMaxDayStartTime, conMaxDayEndTime, EmotionEnum.ALL.getName(), projectId,
List<Map.Entry<String, Integer>> conHotTitles = getMarkTopTitle(startTime, endTime, EmotionEnum.ALL.getName(), projectId,
contendLinkedGroupId, contendId, hotArticleSize);
if (CollectionUtils.isNotEmpty(conHotTitles)) {
List<JSONObject> conHotArticle = conHotTitles.stream().map(map -> {
......
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