Commit 1c1bad6b by shenjunjie

Merge branch 'feature' into 'dev'

Feature

See merge request !32
parents 898b9f72 cfdc79ca
...@@ -33,7 +33,7 @@ public class GenericAttribute { ...@@ -33,7 +33,7 @@ public class GenericAttribute {
/** /**
* es media_type * es media_type
*/ */
public static final String ES_MEDIA_TYPE = "media_type"; // public static final String ES_MEDIA_TYPE = "media_type";
// es platform_id // es platform_id
public static final String ES_PLATFORM_ID = "platform_id"; public static final String ES_PLATFORM_ID = "platform_id";
// es channel_influence // es channel_influence
...@@ -122,6 +122,8 @@ public class GenericAttribute { ...@@ -122,6 +122,8 @@ public class GenericAttribute {
public static final String ROLE_ID = "roleId"; public static final String ROLE_ID = "roleId";
public static final String PROJECT_ID = "projectId"; public static final String PROJECT_ID = "projectId";
public static final String AVATAR_URL = "avatarUrl"; public static final String AVATAR_URL = "avatarUrl";
public static final String EXPORT_AMOUNT = "exportAmount";
public static final String EXPIRED_TIME = "expiredTime";
// public enum ChannelParam{ // public enum ChannelParam{
// 负面稿件数("negativeArticles"), // 负面稿件数("negativeArticles"),
......
...@@ -2,7 +2,6 @@ package com.zhiwei.brandkbs2.controller; ...@@ -2,7 +2,6 @@ package com.zhiwei.brandkbs2.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.Auth; import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.enmus.RoleEnum; import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.ProjectService; import com.zhiwei.brandkbs2.service.ProjectService;
...@@ -51,7 +50,7 @@ public class LoginController extends BaseController { ...@@ -51,7 +50,7 @@ public class LoginController extends BaseController {
@GetMapping("/user/getLoginInfo") @GetMapping("/user/getLoginInfo")
@Auth(role = RoleEnum.CUSTOMER) @Auth(role = RoleEnum.CUSTOMER)
public ResponseResult getLoginInfo() { public ResponseResult getLoginInfo() {
return ResponseResult.success(UserThreadLocal.get()); return ResponseResult.success(UserService.getLoginInfo());
} }
@ApiOperation("重置绑定关系(本地测试)") @ApiOperation("重置绑定关系(本地测试)")
......
...@@ -140,12 +140,6 @@ public class AppEventController extends BaseController { ...@@ -140,12 +140,6 @@ public class AppEventController extends BaseController {
return ResponseResult.success(jsonObject); return ResponseResult.success(jsonObject);
} }
@ApiOperation("最新事件")
@GetMapping("/getLastEventTop")
public ResponseResult getLastEventTop() {
return ResponseResult.success(eventService.getLastEventTop(null, 5));
}
@ApiOperation("关联事件") @ApiOperation("关联事件")
@ApiImplicitParam(name = "keyword", value = "关键词", paramType = "query", dataType = "String") @ApiImplicitParam(name = "keyword", value = "关键词", paramType = "query", dataType = "String")
@GetMapping("/getRelevanceEvent") @GetMapping("/getRelevanceEvent")
......
...@@ -118,7 +118,7 @@ public class AppHotController extends BaseController { ...@@ -118,7 +118,7 @@ public class AppHotController extends BaseController {
@ApiOperation("热点库-最新资讯") @ApiOperation("热点库-最新资讯")
@GetMapping("/latestNews") @GetMapping("/latestNews")
public ResponseResult latestNews(@RequestParam(value = "pageSize",defaultValue = "5") Integer size) throws IOException { public ResponseResult latestNews(@RequestParam(value = "size",defaultValue = "5") Integer size) throws IOException {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId(); String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId();
Date endDate = new Date(); Date endDate = new Date();
......
...@@ -7,9 +7,12 @@ import com.zhiwei.brandkbs2.auth.Auth; ...@@ -7,9 +7,12 @@ import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.config.Constant; import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.enmus.RoleEnum; import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO;
import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO; import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
import com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO; import com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO;
import com.zhiwei.brandkbs2.service.ChannelService; import com.zhiwei.brandkbs2.service.ChannelService;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.EventService;
import com.zhiwei.brandkbs2.service.MarkDataService; import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -57,13 +60,19 @@ public class AppSearchController { ...@@ -57,13 +60,19 @@ public class AppSearchController {
@Resource(name = "channelServiceImpl") @Resource(name = "channelServiceImpl")
ChannelService channelService; ChannelService channelService;
@Resource(name = "eventServiceImpl")
EventService eventService;
@Resource(name = "commonServiceImpl")
CommonService commonService;
@ApiOperation("搜索-查热点") @ApiOperation("搜索-查热点")
@GetMapping("/hot/list") @GetMapping("/hot/list")
public ResponseResult searchHotList(@RequestParam(value = "pageSize", defaultValue = "10") Integer limit, public ResponseResult searchHotList(@RequestParam(value = "pageSize", defaultValue = "10") Integer limit,
@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "type", defaultValue = "weibo") String type, @RequestParam(value = "type", defaultValue = "weibo") String type,
@RequestParam(value = "word") String word) { @RequestParam(value = "keyword") String keyword) {
ResponseEntity<JSONObject> jsonObjectResponseEntity = restTemplate.getForEntity(trendsSearchUrl, JSONObject.class, limit, page, type, word); ResponseEntity<JSONObject> jsonObjectResponseEntity = restTemplate.getForEntity(trendsSearchUrl, JSONObject.class, limit, page, type, keyword);
JSONObject result = jsonObjectResponseEntity.getBody(); JSONObject result = jsonObjectResponseEntity.getBody();
if (Objects.nonNull(result)) { if (Objects.nonNull(result)) {
return ResponseResult.success(result); return ResponseResult.success(result);
...@@ -106,46 +115,70 @@ public class AppSearchController { ...@@ -106,46 +115,70 @@ public class AppSearchController {
return ResponseResult.success(markDataService.searchWholeNetwork(dto)); return ResponseResult.success(markDataService.searchWholeNetwork(dto));
} }
@ApiOperation("舆情列表") @ApiOperation("搜索-舆情列表")
@PostMapping("/mark/list") @PostMapping("/mark/list")
public ResponseResult getYuqingMarkList(@RequestBody MarkSearchDTO markSearchDTO) { public ResponseResult getYuqingMarkList(@RequestBody MarkSearchDTO markSearchDTO) {
return ResponseResult.success(markDataService.getYuqingMarkList(markSearchDTO)); return ResponseResult.success(markDataService.getYuqingMarkList(markSearchDTO));
} }
@ApiOperation("舆情列表-搜索条件") @ApiOperation("搜索-舆情列表-搜索条件")
@GetMapping("/mark/list/criteria") @GetMapping("/mark/list/criteria")
public ResponseResult getYuqingMarkCriteria(@RequestParam(required = false) String linkedGroupId) { public ResponseResult getYuqingMarkCriteria(@RequestParam(required = false) String linkedGroupId) {
return ResponseResult.success(markDataService.getYuqingMarkCriteria(linkedGroupId)); return ResponseResult.success(markDataService.getYuqingMarkCriteria(linkedGroupId));
} }
@ApiOperation("搜索-活跃渠道")
@GetMapping("channel/list/active")
public ResponseResult getActiveChannelList(@RequestParam(value = "size", defaultValue = "2") int size) {
Long[] timeRangeDay = commonService.getTimeRangeDay();
return ResponseResult.success(channelService.getActiveChannelList("0", null, null, timeRangeDay[0], timeRangeDay[1], size));
}
@ApiOperation("渠道搜索条件") @ApiOperation("搜索-渠道搜索条件")
@GetMapping("/channel/getChannelSearchCriteria") @GetMapping("/channel/getChannelSearchCriteria")
public ResponseResult getChannelSearchCriteria() { public ResponseResult getChannelSearchCriteria() {
return ResponseResult.success(channelService.getChannelSearchCriteria()); return ResponseResult.success(channelService.getChannelSearchCriteria());
} }
@ApiOperation("查渠道 渠道库") @ApiOperation("搜索-渠道列表")
@GetMapping(value = "/channel/channelList") @PostMapping(value = "/channel/channelList")
public ResponseResult getChannelList(@RequestParam(value = "page", defaultValue = "1") int page, public ResponseResult getChannelList(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "pageSize", defaultValue = "20") int pageSize, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
@RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "platforms", defaultValue = "全部") List<String> platforms, @RequestParam(value = "platforms", required = false) List<String> platforms,
@RequestParam(value = "emotions", defaultValue = "") List<Integer> emotions, @RequestParam(value = "emotions", required = false) List<Integer> emotions,
@RequestParam(value = "mediaTypes", defaultValue = "全部") List<String> mediaTypes, @RequestParam(value = "mediaTypes", required = false) List<String> mediaTypes,
@RequestParam(value = "articlesCount", required = false) String[] articlesCount, @RequestParam(value = "articlesCount", required = false) String[] articlesCount,
@RequestParam(value = "sorter", defaultValue = "{\"influence\":\"descend\"}") String sorter) { @RequestParam(value = "sorter", defaultValue = "{\"influence\":\"descend\"}") String sorter) {
return ResponseResult.success(channelService.getChannelList(page, pageSize, keyword, platforms, emotions, mediaTypes, articlesCount, sorter)); return ResponseResult.success(channelService.getChannelList(page, pageSize, keyword, platforms, emotions, mediaTypes, articlesCount, sorter));
} }
@ApiOperation("查竞品") @ApiOperation("搜索-热门事件")
@GetMapping("/getLastEventTop")
public ResponseResult getLastEventTop() {
return ResponseResult.success(eventService.getLastEventTop(null, 5));
}
@ApiOperation("搜索-前台事件库-搜索条件")
@GetMapping("/event/list/criteria")
public ResponseResult getEventsSearchCriteria() {
return ResponseResult.success(eventService.getEventsSearchCriteria());
}
@ApiOperation("搜索-前台事件库-品牌事件库")
@PostMapping("/event/list")
public ResponseResult getEventList(@RequestBody EventSearchDTO eventSearchDTO) {
return ResponseResult.success(eventService.getEventList(eventSearchDTO));
}
@ApiOperation("搜索-查竞品")
@PostMapping("/contend/list") @PostMapping("/contend/list")
public ResponseResult getContendSearchList(@RequestBody MarkSearchDTO markSearchDTO) { public ResponseResult getContendSearchList(@RequestBody MarkSearchDTO markSearchDTO) {
return ResponseResult.success(markDataService.getContendSearchList(markSearchDTO)); return ResponseResult.success(markDataService.getContendSearchList(markSearchDTO));
} }
@ApiOperation("查竞品-搜索条件") @ApiOperation("搜索-查竞品-搜索条件")
@GetMapping("/contend/list/criteria") @GetMapping("/contend/list/criteria")
public ResponseResult getContendSearchCriteria(@RequestParam(required = false) String contendId) { public ResponseResult getContendSearchCriteria(@RequestParam(required = false) String contendId) {
return ResponseResult.success(markDataService.getContendSearchCriteria(contendId)); return ResponseResult.success(markDataService.getContendSearchCriteria(contendId));
......
...@@ -54,4 +54,16 @@ public enum ChannelEmotion { ...@@ -54,4 +54,16 @@ public enum ChannelEmotion {
throw new IllegalArgumentException("不识别的类型:" + state); throw new IllegalArgumentException("不识别的类型:" + state);
} }
public static int getEmotionRank(Double emotionIndex) {
int rank;
if (emotionIndex >= 80) {
rank = 1;
} else if (emotionIndex >= 60) {
rank = 2;
} else {
rank = 3;
}
return rank;
}
} }
...@@ -73,7 +73,7 @@ public class ChannelEsDao extends EsClientDao { ...@@ -73,7 +73,7 @@ public class ChannelEsDao extends EsClientDao {
BulkRequest bulkRequest = new BulkRequest(); BulkRequest bulkRequest = new BulkRequest();
Long startTime = null; Long startTime = null;
Long endTime = null; Long endTime = null;
for (List<ChannelRecord> records : ListUtils.partition(channelRecords, 1000)) { for (List<ChannelRecord> records : ListUtils.partition(channelRecords, 100)) {
for (ChannelRecord record : records) { for (ChannelRecord record : records) {
startTime = null == startTime ? record.getRangeStartTime() : Math.min(startTime, record.getRangeStartTime()); startTime = null == startTime ? record.getRangeStartTime() : Math.min(startTime, record.getRangeStartTime());
endTime = null == endTime ? record.getRangeEndTime() : Math.max(endTime, record.getRangeEndTime()); endTime = null == endTime ? record.getRangeEndTime() : Math.max(endTime, record.getRangeEndTime());
......
...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.pojo; ...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.pojo;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.common.GenericAttribute; import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -82,16 +83,16 @@ public class AggreeResult extends AbstractBaseMongo { ...@@ -82,16 +83,16 @@ public class AggreeResult extends AbstractBaseMongo {
*/ */
private boolean isFather; private boolean isFather;
public static AggreeResult createFather(JSONObject json, String taskId, Integer aggreeSize) { public static AggreeResult createFather(JSONObject json, String taskId,String projectId, Integer aggreeSize) {
AggreeResult aggreeResult = getInstance(json, taskId); AggreeResult aggreeResult = getInstance(json, taskId,projectId);
aggreeResult.setFather(true); aggreeResult.setFather(true);
aggreeResult.setAggreeSize(aggreeSize); aggreeResult.setAggreeSize(aggreeSize);
aggreeResult.setCTime(System.currentTimeMillis()); aggreeResult.setCTime(System.currentTimeMillis());
return aggreeResult; return aggreeResult;
} }
public static AggreeResult createSon(JSONObject json, String taskId, String fatherId, String fatherTitle) { public static AggreeResult createSon(JSONObject json, String taskId,String projectId, String fatherId,String fatherTitle) {
AggreeResult aggreeResult = getInstance(json, taskId); AggreeResult aggreeResult = getInstance(json, taskId,projectId);
aggreeResult.setFatherId(fatherId); aggreeResult.setFatherId(fatherId);
// 使用父聚合标题 // 使用父聚合标题
aggreeResult.setAggreeTitle(fatherTitle); aggreeResult.setAggreeTitle(fatherTitle);
...@@ -99,13 +100,13 @@ public class AggreeResult extends AbstractBaseMongo { ...@@ -99,13 +100,13 @@ public class AggreeResult extends AbstractBaseMongo {
return aggreeResult; return aggreeResult;
} }
private static AggreeResult getInstance(JSONObject json, String taskId) { private static AggreeResult getInstance(JSONObject json, String taskId,String projectId) {
AggreeResult aggreeResult = new AggreeResult(); AggreeResult aggreeResult = new AggreeResult();
aggreeResult.setTaskId(taskId); aggreeResult.setTaskId(taskId);
BaseMap baseMap = Tools.getBaseFromEsMap(json); BaseMap baseMap = Tools.getBaseFromEsMap(json);
aggreeResult.setTime(baseMap.getTime()); aggreeResult.setTime(baseMap.getTime());
aggreeResult.setPlatformId(json.getString(GenericAttribute.ES_PLATFORM_ID)); aggreeResult.setPlatformId(json.getString(GenericAttribute.ES_PLATFORM_ID));
String mediaType = json.getString(GenericAttribute.ES_MEDIA_TYPE); String mediaType = GlobalPojo.getMediaType(projectId, baseMap.getPlatform(), baseMap.getSource());
if (StringUtils.isNotEmpty(mediaType)) { if (StringUtils.isNotEmpty(mediaType)) {
aggreeResult.setMediaTypes(Arrays.asList(mediaType.split(","))); aggreeResult.setMediaTypes(Arrays.asList(mediaType.split(",")));
} }
......
package com.zhiwei.brandkbs2.pojo; package com.zhiwei.brandkbs2.pojo;
import com.zhiwei.brandkbs2.enmus.ChannelEmotion;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -63,6 +62,8 @@ public class Channel extends ChannelIndex { ...@@ -63,6 +62,8 @@ public class Channel extends ChannelIndex {
*/ */
private Long collectTime; private Long collectTime;
private Double influence;
public void setLastTime(Long lastTime) { public void setLastTime(Long lastTime) {
if (null == this.lastTime || this.lastTime < lastTime) { if (null == this.lastTime || this.lastTime < lastTime) {
this.lastTime = lastTime; this.lastTime = lastTime;
...@@ -101,17 +102,17 @@ public class Channel extends ChannelIndex { ...@@ -101,17 +102,17 @@ public class Channel extends ChannelIndex {
channel.setLastTime(record.getLastTime()); channel.setLastTime(record.getLastTime());
channel.setRecord(record); channel.setRecord(record);
// TODO 调性随机分配 // // TODO 调性随机分配
double random = Math.random(); // double random = Math.random();
if (random < 0.3) { // if (random < 0.3) {
channel.setEmotion(ChannelEmotion.POSITIVE.getState()); // channel.setEmotion(ChannelEmotion.POSITIVE.getState());
} else if (random < 0.6) { // } else if (random < 0.6) {
channel.setEmotion(ChannelEmotion.NEGATIVE.getState()); // channel.setEmotion(ChannelEmotion.NEGATIVE.getState());
} else { // } else {
channel.setEmotion(ChannelEmotion.NEUTRAL.getState()); // channel.setEmotion(ChannelEmotion.NEUTRAL.getState());
} // }
// TODO 情感指数随机分配 // // TODO 情感指数随机分配
channel.setEmotionIndex(Math.random() * 100); // channel.setEmotionIndex(Math.random() * 100);
return channel; return channel;
} }
......
...@@ -145,7 +145,7 @@ public class ChannelRecord { ...@@ -145,7 +145,7 @@ public class ChannelRecord {
Long lastTime = templateRecord.getLastTime(); Long lastTime = templateRecord.getLastTime();
List<ChannelIndex.Article> articles = templateRecord.getArticles(); List<ChannelIndex.Article> articles = templateRecord.getArticles();
int shards = 0; int shards = 0;
// 防止数据量过大无法存储,故按100 拆分 // 防止数据量过大无法存储,故按50 拆分
for (List<ChannelIndex.Article> partList : Lists.partition(articles, SHARDS_LIMIT)) { for (List<ChannelIndex.Article> partList : Lists.partition(articles, SHARDS_LIMIT)) {
ChannelRecord channelRecord = new ChannelRecord(rangeStartTime, rangeEndTime, entry.getKey(), entry.getValue()); ChannelRecord channelRecord = new ChannelRecord(rangeStartTime, rangeEndTime, entry.getKey(), entry.getValue());
// 保留最近发文时间,更新partList,articleCount和shards // 保留最近发文时间,更新partList,articleCount和shards
......
...@@ -48,7 +48,7 @@ public class CustomEvent extends AbstractBaseMongo { ...@@ -48,7 +48,7 @@ public class CustomEvent extends AbstractBaseMongo {
/** /**
* 关联项目组ID * 关联项目组ID
*/ */
private String linkedGroupId; private String contendId;
/** /**
* 将自定义事件传输对象转换为自定义事件对象 * 将自定义事件传输对象转换为自定义事件对象
......
...@@ -19,15 +19,16 @@ public class UserInfo { ...@@ -19,15 +19,16 @@ public class UserInfo {
private String userId; private String userId;
private Integer roleId; private Integer roleId;
private String projectId; private String projectId;
private Integer exportAmount;
private String avatarUrl; private String avatarUrl;
private Integer exportAmount;
private Long expiredTime;
public UserInfo setUserId(String userId){ public UserInfo setUserId(String userId) {
this.userId = userId; this.userId = userId;
return this; return this;
} }
public UserInfo setProjectId(String projectId){ public UserInfo setProjectId(String projectId) {
this.projectId = projectId; this.projectId = projectId;
return this; return this;
} }
...@@ -39,6 +40,8 @@ public class UserInfo { ...@@ -39,6 +40,8 @@ public class UserInfo {
res.put(GenericAttribute.USER_ID, this.userId); res.put(GenericAttribute.USER_ID, this.userId);
res.put(GenericAttribute.ROLE_ID, this.roleId); res.put(GenericAttribute.ROLE_ID, this.roleId);
res.put(GenericAttribute.AVATAR_URL, this.avatarUrl); res.put(GenericAttribute.AVATAR_URL, this.avatarUrl);
res.put(GenericAttribute.EXPORT_AMOUNT, this.exportAmount);
res.put(GenericAttribute.EXPIRED_TIME, this.expiredTime);
return res; return res;
} }
......
package com.zhiwei.brandkbs2.pojo.vo;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.enmus.ChannelEmotion;
import com.zhiwei.brandkbs2.pojo.Channel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class ChannelVO {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "渠道")
private String source;
@ApiModelProperty(value = "真实来源")
private String realSource;
@ApiModelProperty(value = "情感倾向")
private String emotion;
@ApiModelProperty(value = "情感倾向等级")
private Integer emotionRank;
@ApiModelProperty(value = "头像地址")
private String avatarUrl;
@ApiModelProperty(value = "参与事件数")
private Long eventCount;
@ApiModelProperty(value = "发布稿件数")
private Long articleCount;
@ApiModelProperty(value = "影响力")
private Double influence;
@ApiModelProperty(value = "媒体类型标签")
private String mediaType;
@ApiModelProperty(value = "最近发文链接")
private JSONObject lastArticle;
public static ChannelVO createFromChannelInfo(JSONObject channelInfo, String projectId) {
Channel channel = (Channel) channelInfo.get("channel");
JSONObject lastArticle = channelInfo.getJSONObject("lastArticle");
return createFromChannelVO(channel, projectId, lastArticle);
}
public static ChannelVO createFromChannelVO(Channel channel, String projectId, JSONObject lastArticle) {
ChannelVO channelVO = new ChannelVO();
channelVO.setId(channel.getId());
channelVO.setSource(channel.getSource());
channelVO.setRealSource(channel.getRealSource());
channelVO.setEmotion(ChannelEmotion.getNameFromState(channel.getEmotion()));
channelVO.setEmotionRank(ChannelEmotion.getEmotionRank(channel.getEmotionIndex()));
channelVO.setAvatarUrl(channel.getAvatarUrl());
channelVO.setEventCount(channel.getEventCount());
channelVO.setArticleCount(channel.getArticleCount());
// TODO influence实现
channelVO.setInfluence(null);
String mediaType = GlobalPojo.getMediaType(projectId, channel.getPlatform(), channel.getSource());
if (null != mediaType) {
channelVO.setMediaType(mediaType.replaceAll(",", " "));
}
channelVO.setLastArticle(lastArticle);
return channelVO;
}
}
...@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.pojo.Channel; ...@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.pojo.Channel;
import com.zhiwei.brandkbs2.pojo.dto.ChannelDTO; import com.zhiwei.brandkbs2.pojo.dto.ChannelDTO;
import com.zhiwei.brandkbs2.pojo.dto.ExportAppChannelEventDTO; import com.zhiwei.brandkbs2.pojo.dto.ExportAppChannelEventDTO;
import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO; import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO;
import com.zhiwei.brandkbs2.pojo.vo.ChannelVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO; import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import java.util.List; import java.util.List;
...@@ -258,6 +259,7 @@ public interface ChannelService { ...@@ -258,6 +259,7 @@ public interface ChannelService {
*/ */
JSONObject getChannelSearchCriteria(); JSONObject getChannelSearchCriteria();
PageVO<JSONObject> getChannelList(int page, int pageSize, String keyword, List<String> platforms, List<Integer> emotions, List<String> mediaTypes, String[] articlesCount, String sorter); PageVO<ChannelVO> getChannelList(int page, int pageSize, String keyword, List<String> platforms, List<Integer> emotions, List<String> mediaTypes,
String[] articlesCount, String sorter);
} }
...@@ -52,4 +52,6 @@ public interface CommonService { ...@@ -52,4 +52,6 @@ public interface CommonService {
Long[] getTimeRangeWeek(); Long[] getTimeRangeWeek();
Long[] getTimeRangeDay();
} }
...@@ -264,6 +264,6 @@ public interface MarkDataService { ...@@ -264,6 +264,6 @@ public interface MarkDataService {
*/ */
List<Map<String, Object>> getEsTopSource(Long startTime, Long endTime, String projectId, String linkedGroupId, String contendId, String emotion, int size) throws IOException; List<Map<String, Object>> getEsTopSource(Long startTime, Long endTime, String projectId, String linkedGroupId, String contendId, String emotion, int size) throws IOException;
String getLastMarkUrl(String projectId, String linkedGroupId, String contendId, String platform, String realSource, String source); JSONObject getLastMarkData(String projectId, String linkedGroupId, String contendId, String platform, String realSource, String source);
} }
...@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.pojo.dto.UserDTO; ...@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.pojo.dto.UserDTO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO; import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @ClassName: UserService * @ClassName: UserService
...@@ -23,6 +24,13 @@ public interface UserService { ...@@ -23,6 +24,13 @@ public interface UserService {
UserInfo login(); UserInfo login();
/** /**
* 获取登录信息
*
* @return
*/
Map<String, Object> getLoginInfo();
/**
* 查询用户信息 * 查询用户信息
* *
* @param userId * @param userId
......
...@@ -22,6 +22,7 @@ import com.zhiwei.brandkbs2.pojo.*; ...@@ -22,6 +22,7 @@ import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.pojo.dto.ChannelDTO; import com.zhiwei.brandkbs2.pojo.dto.ChannelDTO;
import com.zhiwei.brandkbs2.pojo.dto.ExportAppChannelEventDTO; import com.zhiwei.brandkbs2.pojo.dto.ExportAppChannelEventDTO;
import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO; import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO;
import com.zhiwei.brandkbs2.pojo.vo.ChannelVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO; import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.ChannelService; import com.zhiwei.brandkbs2.service.ChannelService;
import com.zhiwei.brandkbs2.service.CommonService; import com.zhiwei.brandkbs2.service.CommonService;
...@@ -781,13 +782,18 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -781,13 +782,18 @@ public class ChannelServiceImpl implements ChannelService {
// 平台 // 平台
result.put("platformList", commonService.getQbjcPlatform("id", "name")); result.put("platformList", commonService.getQbjcPlatform("id", "name"));
//渠道倾向 //渠道倾向
List<EmotionEnum> emotionList = Arrays.asList(EmotionEnum.ALL, EmotionEnum.POSITIVE, EmotionEnum.NEUTRAL, EmotionEnum.NEGATIVE); List<ChannelEmotion> emotionList = Arrays.asList(ChannelEmotion.POSITIVE, ChannelEmotion.NEUTRAL, ChannelEmotion.NEGATIVE);
result.put("emotionList", emotionList.stream().map(emotion -> { List<JSONObject> collect = emotionList.stream().map(emotion -> {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("id", emotion.getState()); json.put("id", emotion.getState());
json.put("name", emotion.getName()); json.put("name", emotion.getName());
return json; return json;
}).collect(Collectors.toList())); }).collect(Collectors.toList());
JSONObject allEmotion = new JSONObject();
allEmotion.put("id", -1);
allEmotion.put("name", "全部");
collect.add(0, allEmotion);
result.put("emotionList", collect);
//渠道级别 //渠道级别
List<String> mediaTypeList = ImportantChannelEnum.getAllTagExceptSpec(); List<String> mediaTypeList = ImportantChannelEnum.getAllTagExceptSpec();
mediaTypeList.add(0, "全部"); mediaTypeList.add(0, "全部");
...@@ -798,36 +804,47 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -798,36 +804,47 @@ public class ChannelServiceImpl implements ChannelService {
} }
@Override @Override
public PageVO<JSONObject> getChannelList(int page, int pageSize, String keyword, List<String> platforms, List<Integer> emotions, List<String> mediaTypes, public PageVO<ChannelVO> getChannelList(int page, int pageSize, String keyword, List<String> platforms, List<Integer> emotions, List<String> mediaTypes,
String[] articlesCount, String sorter) { String[] articlesCount, String sorter) {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
String contendId = "0"; String contendId = "0";
String linkedGroupId = projectService.getProjectByContendId(projectId, contendId).getBrandLinkedGroupId(); String linkedGroupId = projectService.getProjectByContendId(projectId, contendId).getBrandLinkedGroupId();
Query query = new Query(Criteria.where("projectId").is(projectId).and("contendId").is(contendId)); Query query = new Query(Criteria.where("projectId").is(projectId).and("contendId").is(contendId));
channelDao.addKeywordFuzz(query, keyword, "source"); channelDao.addKeywordFuzz(query, keyword, "source");
if (!platforms.contains("全部")) { if (!(null == platforms || platforms.contains("全部"))) {
query.addCriteria(Criteria.where("platform").in(platforms)); query.addCriteria(Criteria.where("platform").in(platforms));
} }
if (!emotions.contains(-1)) { if (!(null == emotions || emotions.contains(-1))) {
query.addCriteria(Criteria.where("emotion").in(emotions)); query.addCriteria(Criteria.where("emotion").in(emotions));
} }
if (!mediaTypes.contains("全部")) { if (!(null == mediaTypes || mediaTypes.contains("全部"))) {
// TODO // TODO
} }
if (null != articlesCount) { if (null != articlesCount) {
query.addCriteria(Criteria.where("articleCount").gte(articlesCount[0]).lt(articlesCount[1])); query.addCriteria(Criteria.where("articleCount").gte(articlesCount[0]).lt(articlesCount[1]));
} }
mongoUtil.start(page, pageSize, query);
long total = channelDao.count(query); long total = channelDao.count(query);
channelDao.addSort(query, sorter); channelDao.addSort(query, sorter);
List<Channel> channelList = channelDao.findList(query); List<Channel> channelList = channelDao.findList(query);
List<JSONObject> resultList = channelList.stream().map(channel -> { List<CompletableFuture<JSONObject>> futureList = channelList.stream().map(channel -> CompletableFuture.supplyAsync(() -> {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("channelInfo", channel); result.put("id", channel.getId());
result.put("lastArticle", markDataService.getLastMarkUrl(projectId, linkedGroupId, contendId, channel.getPlatform(), channel.getRealSource(), result.put("channel", channel);
result.put("lastArticle", markDataService.getLastMarkData(projectId, linkedGroupId, contendId, channel.getPlatform(), channel.getRealSource(),
channel.getSource())); channel.getSource()));
return result; return result;
}).collect(Collectors.toList()); }, esSearchExecutor)).collect(Collectors.toList());
return PageVO.createPageVo(total, page, pageSize, resultList); CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])).join();
Map<String, JSONObject> idMap = futureList.stream().map(CompletableFuture::join).collect(Collectors.toMap(json -> json.getString("id"), a -> a));
// List<JSONObject> resultList = channelList.stream().map(channel -> {
// JSONObject result = new JSONObject();
// result.put("channelInfo", channel);
// result.put("lastArticle", markDataService.getLastMarkUrl(projectId, linkedGroupId, contendId, channel.getPlatform(), channel.getRealSource(), channel.getSource()));
// return result;
// }).collect(Collectors.toList());
return PageVO.createPageVo(total, page, pageSize,
channelList.stream().map(channel -> ChannelVO.createFromChannelInfo(idMap.get(channel.getId()), projectId)).collect(Collectors.toList()));
} }
private List<JSONObject> getArticleList() { private List<JSONObject> getArticleList() {
...@@ -838,7 +855,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -838,7 +855,7 @@ public class ChannelServiceImpl implements ChannelService {
if ("全部".equals(name)) { if ("全部".equals(name)) {
json.put("value", null); json.put("value", null);
} else { } else {
String[] split = name.substring(name.length() - 1).split("-"); String[] split = name.substring(0, name.length() - 1).split("-");
json.put("value", new Long[]{Long.parseLong(split[0]), Long.parseLong(split[1])}); json.put("value", new Long[]{Long.parseLong(split[0]), Long.parseLong(split[1])});
} }
res.add(json); res.add(json);
...@@ -1424,7 +1441,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -1424,7 +1441,7 @@ public class ChannelServiceImpl implements ChannelService {
private String[] getTitleAndUrlById(String id) { private String[] getTitleAndUrlById(String id) {
try { try {
BaseMap baseMap = Tools.getBaseFromEsMap(esClientDao.searchById(id)); BaseMap baseMap = Tools.getBaseFromEsMap(esClientDao.searchById(id));
return new String[]{baseMap.getTitle(), baseMap.getUrl()}; return new String[]{baseMap.getTitleNullOptionalContent(), baseMap.getUrl()};
} catch (IOException ignored) { } catch (IOException ignored) {
} }
return new String[]{null, null}; return new String[]{null, null};
...@@ -1465,15 +1482,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -1465,15 +1482,7 @@ public class ChannelServiceImpl implements ChannelService {
} }
private String getChannelEmotionRank(Double emotionIndex, int emotion) { private String getChannelEmotionRank(Double emotionIndex, int emotion) {
int rank; return ChannelEmotion.getEmotionRank(emotionIndex) + "级" + ChannelEmotion.getNameFromState(emotion);
if (emotionIndex >= 80) {
rank = 1;
} else if (emotionIndex >= 60) {
rank = 2;
} else {
rank = 3;
}
return rank + "级" + ChannelEmotion.getNameFromState(emotion);
} }
} }
...@@ -110,4 +110,11 @@ public class CommonServiceImpl implements CommonService { ...@@ -110,4 +110,11 @@ public class CommonServiceImpl implements CommonService {
return new Long[]{startTime, endTime}; return new Long[]{startTime, endTime};
} }
@Override
public Long[] getTimeRangeDay() {
long endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
long startTime = DateUtils.addDays(new Date(endTime), -1).getTime();
return new Long[]{startTime, endTime};
}
} }
...@@ -118,11 +118,11 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -118,11 +118,11 @@ public class CustomEventServiceImpl implements CustomEventService {
@Override @Override
public void saveCustomEvent(CustomEventDTO customEventDTO) { public void saveCustomEvent(CustomEventDTO customEventDTO) {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId(); String contendId = "0";
CustomEvent customEvent = CustomEvent.creatFromCustomEventDTO(customEventDTO); CustomEvent customEvent = CustomEvent.creatFromCustomEventDTO(customEventDTO);
customEvent.setUpdateTime(System.currentTimeMillis()); customEvent.setUpdateTime(System.currentTimeMillis());
customEvent.setProjectId(projectId); customEvent.setProjectId(projectId);
customEvent.setLinkedGroupId(linkedGroupId); customEvent.setContendId(contendId);
customEventDao.insertOneWithoutId(customEvent); customEventDao.insertOneWithoutId(customEvent);
this.analyzeCustomEventData(customEvent); this.analyzeCustomEventData(customEvent);
} }
...@@ -293,8 +293,9 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -293,8 +293,9 @@ public class CustomEventServiceImpl implements CustomEventService {
customEventDao.updateOneByIdWithField(eventId, Update.update("status", false)); customEventDao.updateOneByIdWithField(eventId, Update.update("status", false));
ApplicationProjectListener.getThreadPool().execute(() -> { ApplicationProjectListener.getThreadPool().execute(() -> {
try { try {
String linkedGroupId = projectService.getProjectByContendId(customEvent.getProjectId(), customEvent.getContendId()).getBrandLinkedGroupId();
//查询符合该事件时间段的所有稿件信息 //查询符合该事件时间段的所有稿件信息
List<JSONObject> articles = markDataService.searchMarkDataByTime(customEvent.getProjectId(), customEvent.getLinkedGroupId(), "0", List<JSONObject> articles = markDataService.searchMarkDataByTime(customEvent.getProjectId(), linkedGroupId, customEvent.getContendId(),
customEvent.getStartTime(), customEvent.getEndTime()); customEvent.getStartTime(), customEvent.getEndTime());
log.info("自定义事件:{} 查询到符合该事件时间段的所有稿件数{}个", eventId, articles.size()); log.info("自定义事件:{} 查询到符合该事件时间段的所有稿件数{}个", eventId, articles.size());
List<String> keywords = customEvent.getKeywords(); List<String> keywords = customEvent.getKeywords();
......
...@@ -224,6 +224,10 @@ public class EventDataServiceImpl implements EventDataService { ...@@ -224,6 +224,10 @@ public class EventDataServiceImpl implements EventDataService {
details.add(entry.getKey()); details.add(entry.getKey());
details.add(new BigDecimal((double) (entry.getValue().get() * 100) / sum).setScale(2, RoundingMode.UP).toString()); details.add(new BigDecimal((double) (entry.getValue().get() * 100) / sum).setScale(2, RoundingMode.UP).toString());
}); });
if (details.size() == 2) {
details.add("其他");
details.add("0.00");
}
details.add(top8Titles.get(0).getKey()); details.add(top8Titles.get(0).getKey());
details.add(String.valueOf(top8Titles.get(0).getValue().size())); details.add(String.valueOf(top8Titles.get(0).getValue().size()));
return details; return details;
......
...@@ -546,11 +546,11 @@ public class EventServiceImpl implements EventService { ...@@ -546,11 +546,11 @@ public class EventServiceImpl implements EventService {
} }
query.addCriteria(volumeCriteria); query.addCriteria(volumeCriteria);
} }
mongoUtil.start(eventSearchDTO.getPage(), eventSearchDTO.getPageSize(), query);
// 总数 // 总数
long total = eventDao.count(query); long total = eventDao.count(query);
// 排序 // 排序
eventDao.addSort(query, eventSearchDTO.getSorter().toJSONString()); eventDao.addSort(query, eventSearchDTO.getSorter().toJSONString());
mongoUtil.start(eventSearchDTO.getPage(), eventSearchDTO.getPageSize(), query);
// 数据 // 数据
List<Event> eventList = eventDao.findList(query); List<Event> eventList = eventDao.findList(query);
// vo封装 // vo封装
......
...@@ -432,23 +432,23 @@ public class IndexServiceImpl implements IndexService { ...@@ -432,23 +432,23 @@ public class IndexServiceImpl implements IndexService {
private JSONObject getTopSource(long startTime, long endTime, String projectId, String linkedGroupId, String contendId) throws IOException { private JSONObject getTopSource(long startTime, long endTime, String projectId, String linkedGroupId, String contendId) throws IOException {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
// TODO 等待线上es数据格式调整 // TODO 等待线上es数据格式调整
// List<Map<String, Object>> positiveList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.POSITIVE.getName(), 3); List<Map<String, Object>> positiveList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.POSITIVE.getName(), 3);
// List<Map<String, Object>> negativeList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.NEGATIVE.getName(), 1); List<Map<String, Object>> negativeList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.NEGATIVE.getName(), 1);
result.put("positiveList", tempTopSource()); result.put("positiveList", positiveList);
result.put("negativeList", tempTopSource()); result.put("negativeList", negativeList);
return result; return result;
} }
private List<Map<String, Object>> tempTopSource() { // private List<Map<String, Object>> tempTopSource() {
List<Map<String, Object>> channelResultList = new ArrayList<>(); // List<Map<String, Object>> channelResultList = new ArrayList<>();
Map<String, Object> result = new HashMap<>(); // Map<String, Object> result = new HashMap<>();
result.put("id", "testId"); // result.put("id", "testId");
result.put("source", "source"); // result.put("source", "source");
result.put("platform", "微信"); // result.put("platform", "微信");
result.put("num", "1"); // result.put("num", "1");
channelResultList.add(result); // channelResultList.add(result);
return channelResultList; // return channelResultList;
} // }
/** /**
* 传播趋势 * 传播趋势
......
...@@ -190,7 +190,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -190,7 +190,7 @@ public class MarkDataServiceImpl implements MarkDataService {
List<List<JSONObject>> groupList = aggregation(hitsAndCounts.getLeft(), "id"); List<List<JSONObject>> groupList = aggregation(hitsAndCounts.getLeft(), "id");
log.info("taskId:{},聚合完成,聚合组:{}个", uuid, groupList.size()); log.info("taskId:{},聚合完成,聚合组:{}个", uuid, groupList.size());
// 入mongo缓存 // 入mongo缓存
cacheAggreeResult(groupList, uuid); cacheAggreeResult(groupList, uuid, projectId);
redisUtil.setExpire(redisKey, "100"); redisUtil.setExpire(redisKey, "100");
} catch (Exception e) { } catch (Exception e) {
log.error("generateYuqingMarkAggreeList-", e); log.error("generateYuqingMarkAggreeList-", e);
...@@ -279,11 +279,11 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -279,11 +279,11 @@ public class MarkDataServiceImpl implements MarkDataService {
query.addCriteria((orCriteria.orOperator(tagCriteria.toArray(new Criteria[0])))); query.addCriteria((orCriteria.orOperator(tagCriteria.toArray(new Criteria[0]))));
} }
// 关键词模糊查询 // 关键词模糊查询
aggreeResultDao.addKeywordFuzz(query, dto.getKeyword(), "aggreeTitle"); aggreeResultDao.addKeywordFuzz(query, dto.getKeyword(), "data.source");
return query; return query;
} }
private void cacheAggreeResult(List<List<JSONObject>> groupList, String taskId) { private void cacheAggreeResult(List<List<JSONObject>> groupList, String taskId, String projectId) {
int count = 0; int count = 0;
int percent; int percent;
for (List<JSONObject> list : groupList) { for (List<JSONObject> list : groupList) {
...@@ -294,12 +294,12 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -294,12 +294,12 @@ public class MarkDataServiceImpl implements MarkDataService {
AggreeResult aggreeResult; AggreeResult aggreeResult;
// 父聚合处理 // 父聚合处理
if (i == 0) { if (i == 0) {
aggreeResult = AggreeResult.createFather(json, taskId, list.size()); aggreeResult = AggreeResult.createFather(json, taskId, projectId, list.size());
aggreeResultDao.insertOneWithoutId(aggreeResult); aggreeResultDao.insertOneWithoutId(aggreeResult);
fatherId = aggreeResult.getId(); fatherId = aggreeResult.getId();
fatherTitle = aggreeResult.getAggreeTitle(); fatherTitle = aggreeResult.getAggreeTitle();
} else { } else {
aggreeResult = AggreeResult.createSon(json, taskId, fatherId, fatherTitle); aggreeResult = AggreeResult.createSon(json, taskId, projectId, fatherId, fatherTitle);
aggreeResultDao.insertOneWithoutId(aggreeResult); aggreeResultDao.insertOneWithoutId(aggreeResult);
} }
} }
...@@ -587,7 +587,8 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -587,7 +587,8 @@ public class MarkDataServiceImpl implements MarkDataService {
// keyword // keyword
if (StringUtils.isNotEmpty(dto.getKeyword())) { if (StringUtils.isNotEmpty(dto.getKeyword())) {
// Query // Query
String[] fieldSearch = "标题".equals(dto.getSearchField()) ? new String[]{GenericAttribute.ES_IND_TITLE} : new String[]{GenericAttribute.ES_IND_FULL_TEXT}; String[] fieldSearch = "仅标题".equals(dto.getSearchField()) ? new String[]{GenericAttribute.ES_IND_TITLE} :
new String[]{GenericAttribute.ES_IND_FULL_TEXT};
postFilter.must(EsQueryTools.assembleNormalKeywordQuery(dto.getKeyword(), fieldSearch)); postFilter.must(EsQueryTools.assembleNormalKeywordQuery(dto.getKeyword(), fieldSearch));
} }
// sourceKeyword // sourceKeyword
...@@ -973,7 +974,8 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -973,7 +974,8 @@ public class MarkDataServiceImpl implements MarkDataService {
// keyword // keyword
if (StringUtils.isNotEmpty(dto.getKeyword())) { if (StringUtils.isNotEmpty(dto.getKeyword())) {
// Query // Query
String[] fieldSearch = "标题".equals(dto.getSearchField()) ? new String[]{GenericAttribute.ES_IND_TITLE} : new String[]{GenericAttribute.ES_IND_FULL_TEXT}; String[] fieldSearch = "仅标题".equals(dto.getSearchField()) ? new String[]{GenericAttribute.ES_IND_TITLE} :
new String[]{GenericAttribute.ES_IND_FULL_TEXT};
postFilter.must(EsQueryTools.assembleNormalKeywordQuery(dto.getKeyword(), fieldSearch)); postFilter.must(EsQueryTools.assembleNormalKeywordQuery(dto.getKeyword(), fieldSearch));
} }
// sourceKeyword // sourceKeyword
...@@ -1431,38 +1433,32 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -1431,38 +1433,32 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
@Override @Override
public String getLastMarkUrl(String projectId, String linkedGroupId, String contendId, String platform, String realSource, String source) { public JSONObject getLastMarkData(String projectId, String linkedGroupId, String contendId, String platform, String realSource, String source) {
try { try {
EsClientDao.SearchHelper searchHelper = EsClientDao.createSearchHelper(); EsClientDao.SearchHelper searchHelper = EsClientDao.createSearchHelper();
BoolQueryBuilder query = projectLinkedGroupContendIdQuery(projectId, linkedGroupId, contendId); BoolQueryBuilder query = projectLinkedGroupContendIdQuery(projectId, linkedGroupId, contendId);
query.must(QueryBuilders.termQuery("platform", platform)); query.must(QueryBuilders.termQuery("platform_id", GlobalPojo.getPlatformIdByName(platform)));
query.must(QueryBuilders.termQuery("real_source", realSource)); query.must(QueryBuilders.termQuery("real_source", realSource));
query.must(QueryBuilders.termQuery("source", source)); query.must(QueryBuilders.termQuery("source", source));
searchHelper.setQuery(query); searchHelper.setQuery(query);
searchHelper.setSort(SortBuilders.fieldSort("time").order(SortOrder.DESC)); searchHelper.setSort(SortBuilders.fieldSort("time").order(SortOrder.DESC));
searchHelper.setSize(1); searchHelper.setSize(1);
searchHelper.setFetchSource(new String[]{"url", "question_url", "answer_url"});
SearchHits searchHits = esClientDao.searchHits(searchHelper); SearchHits searchHits = esClientDao.searchHits(searchHelper);
if (0 == searchHits.getTotalHits().value) { if (0 == searchHits.getTotalHits().value) {
return null; return null;
} }
return getUrl(searchHits.getAt(0).getSourceAsMap()); return getTitleAndUrl(searchHits.getAt(0).getSourceAsMap());
} catch (IOException e) { } catch (IOException e) {
return null; return null;
} }
} }
private static String getUrl(Map<String, Object> map) { private static JSONObject getTitleAndUrl(Map<String, Object> map) {
JSONObject json = new JSONObject(map); JSONObject json = new JSONObject();
String url = json.getString("url"); BaseMap baseMap = Tools.getBaseFromEsMap(map);
// 如果url为空,则查询QA类型url字段 json.put("title", baseMap.getTitleNullOptionalContent());
if (null == url) { json.put("url", baseMap.getUrl());
url = json.getString("answer_url"); return json;
}
if (null == url) {
url = json.getString("question_url");
}
return url;
} }
/** /**
......
...@@ -118,7 +118,6 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -118,7 +118,6 @@ public class MarkFlowServiceImpl implements MarkFlowService {
sourceDetails.put("followersNum", followersNum); sourceDetails.put("followersNum", followersNum);
} }
// 渠道标签 // 渠道标签
String channelTag = tJson.getString("channel_tag"); String channelTag = tJson.getString("channel_tag");
if (null != channelTag) { if (null != channelTag) {
sourceDetails.put("channelTag", channelTag.replaceAll(",", "|")); sourceDetails.put("channelTag", channelTag.replaceAll(",", "|"));
......
...@@ -98,6 +98,7 @@ public class UserServiceImpl implements UserService { ...@@ -98,6 +98,7 @@ public class UserServiceImpl implements UserService {
userInfo.setRoleId(userRole.getRoleId()); userInfo.setRoleId(userRole.getRoleId());
userInfo.setAvatarUrl(user.getAvatarUrl()); userInfo.setAvatarUrl(user.getAvatarUrl());
userInfo.setExportAmount(userRole.getExportAmount()); userInfo.setExportAmount(userRole.getExportAmount());
userInfo.setExpiredTime(userRole.getExpiredTime());
}); });
if (!hit.get()) { if (!hit.get()) {
return null; return null;
...@@ -278,6 +279,11 @@ public class UserServiceImpl implements UserService { ...@@ -278,6 +279,11 @@ public class UserServiceImpl implements UserService {
userOldDao.updateOneByIdWithField(userOld.getId(), Update.update("bindUser", false)); userOldDao.updateOneByIdWithField(userOld.getId(), Update.update("bindUser", false));
} }
@Override
public Map<String, Object> getLoginInfo() {
return queryUserInfo(UserThreadLocal.getUserId(), UserThreadLocal.getProjectId()).toMap();
}
private User createNewUser(UserDTO userDTO) { private User createNewUser(UserDTO userDTO) {
User user = new User(); User user = new User();
user.setId(userDTO.getId()); user.setId(userDTO.getId());
......
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