Commit fb2a085f by 陈健智

非人工项目-舆情库调整

parent c141eeb3
......@@ -60,6 +60,7 @@ public class NonManualProjectPlan extends AbstractBaseMongo{
private String submitter;
public NonManualProjectPlan(NonManualProjectPlanDTO dto){
this.id = dto.getId();
this.projectId = UserThreadLocal.getProjectId();
this.name = dto.getName();
this.keyword = dto.getKeyword();
......
......@@ -169,12 +169,12 @@ public class MarkSearchDTO {
* 内容类型(原创/转发),仅非人工项目
*/
@ApiModelProperty(value = "内容类型(原创/转发)")
private String forward;
private Boolean forward;
/**
* 信息浏览(已读/未读),仅非人工项目
*/
@ApiModelProperty(value = "信息浏览(已读/未读)")
private String read;
private Boolean read;
/**
* 数据类型(长文本/短文本/问答/视频),仅非人工项目
*/
......
......@@ -183,7 +183,6 @@ public class ProjectVO {
} else {
project.setAvatarUrl(vo.getAvatarUrl());
}
project.setModuleShowList(Collections.emptyList());
project.setToolsetShowList(Arrays.asList("articleSummary", "interactionUpdate", "highWord"));
// 新建项目时默认数据量50w
project.setDataBalance(500000);
......
......@@ -81,6 +81,7 @@ public interface MarkFlowService {
private String contendId;
private String linkedGroupId;
private String planId;
private Long gid;
public MarkInfoSource(JSONObject json, String projectId, String contendId) {
this.json = json;
......@@ -93,11 +94,12 @@ public interface MarkFlowService {
this.linkedGroupId = linkedGroupId;
}
public MarkInfoSource(JSONObject json, String projectId, String contendId, String planId) {
public MarkInfoSource(JSONObject json, String projectId, String contendId, String planId, Long gid) {
this.json = json;
this.projectId = projectId;
this.contendId = contendId;
this.planId = planId;
this.gid = gid;
}
}
......
......@@ -301,11 +301,11 @@ public class EsSearchServiceImpl implements EsSearchService {
}
// forward
if (Objects.nonNull(dto.getForward())){
postFilter.must(EsQueryTools.assembleForward2Query(Objects.equals(dto.getForward(), "转发")));
postFilter.must(EsQueryTools.assembleForward2Query(dto.getForward()));
}
// gid 已读 未读
if (Objects.nonNull(dto.getRead()) && Objects.nonNull(dto.getGid())){
if (Objects.equals(dto.getRead(), "已读")){
if (Objects.nonNull(dto.getRead())){
if (dto.getRead()){
postFilter.must(QueryBuilders.rangeQuery(GenericAttribute.ES_GID).lte(dto.getGid()));
}else {
postFilter.must(QueryBuilders.rangeQuery(GenericAttribute.ES_GID).gt(dto.getGid()));
......
......@@ -620,6 +620,13 @@ public class MarkDataServiceImpl implements MarkDataService {
projectService.getProjectVOById(projectId).getContendList().stream().filter(contend -> contend.getId().equals(markSearchDTO.getContendId())).findFirst();
contendOptional.ifPresent(contend -> markSearchDTO.setLinkedGroupId(contend.getBrandLinkedGroupId()));
}
// gid
String gid = redisUtil.get(RedisUtil.getNonManualProjectMarkMaxGidKey(UserThreadLocal.getProjectId(), markSearchDTO.getPlanId(), UserThreadLocal.getUserId()));
if (Objects.isNull(gid)) {
markSearchDTO.setGid(-1L);
}else {
markSearchDTO.setGid(Long.parseLong(gid));
}
}
private List<List<JSONObject>> aggregation(SearchHits[] searchHitsList) {
......@@ -1704,7 +1711,6 @@ public class MarkDataServiceImpl implements MarkDataService {
if (nonManualProjectPlanDao.count(new Query(Criteria.where("projectId").is(UserThreadLocal.getProjectId()))) >= 5) {
return ResponseResult.failure("超过方案数量上限5");
}
// TODO 数据预估超限返回
NonManualProjectPlan plan = new NonManualProjectPlan(dto);
nonManualProjectPlanDao.insertOne(plan);
return ResponseResult.success();
......@@ -1725,7 +1731,7 @@ public class MarkDataServiceImpl implements MarkDataService {
NonManualProjectPlan existPlan = nonManualProjectPlanDao.findOneById(dto.getId());
NonManualProjectPlan plan = new NonManualProjectPlan(dto);
plan.setCTime(existPlan.getCTime());
nonManualProjectPlanDao.updateOne(existPlan);
nonManualProjectPlanDao.updateOne(plan);
return ResponseResult.success();
}
......@@ -1847,10 +1853,6 @@ public class MarkDataServiceImpl implements MarkDataService {
result.put("dataType", dataType.stream().filter(jsonObject -> !jsonObject.getString("name").equals("图片")));
// 信息浏览
result.put("read", Arrays.asList("已读", "未读"));
// 其他标签组(筛选器)
// result.put("tagFilterList", tagFilterService.getTagFilter());
// 地域
// result.put("regionList", getFilterRegionList());
// 自定义标签列表
List<CustomTagVo> customTagList = customTagService.findCustomTagList(1, 1).getList();
if (CollectionUtils.isNotEmpty(customTagList)) {
......@@ -1864,11 +1866,6 @@ public class MarkDataServiceImpl implements MarkDataService {
try {
//设置默认的时间、页码、排序方式等
defaultMarkSearch(markSearchDTO);
// gid
String gid = redisUtil.get(RedisUtil.getNonManualProjectMarkMaxGidKey(UserThreadLocal.getProjectId(), markSearchDTO.getPlanId(), UserThreadLocal.getUserId()));
if (Objects.nonNull(gid)) {
markSearchDTO.setGid(Long.parseLong(gid));
}
// 搜索es数据
Pair<SearchHits[], Map<String, Long>> hitsAndCounts = esSearchService.searchNonManualHitsAndCount(markSearchDTO, false);
// 总量
......@@ -2101,11 +2098,15 @@ public class MarkDataServiceImpl implements MarkDataService {
List<JSONObject> res = new ArrayList<>();
String projectId = UserThreadLocal.getProjectId();
List<NonManualProjectPlan> planList = nonManualProjectPlanDao.findList(new Query(Criteria.where("projectId").is(projectId)));
long startTime = Constant.DF_yyyyMMdd.parse(Constant.DF_yyyyMMdd.format(new Date())).getTime();
long endTime = System.currentTimeMillis();
for (NonManualProjectPlan plan : planList) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", plan.getId());
jsonObject.put("name", plan.getName());
jsonObject.put("count", esClientDao.count(EsQueryTools.assembleCacheMapsPlanQuery(projectId, plan.getId())));
BoolQueryBuilder query = EsQueryTools.assembleCacheMapsPlanQuery(projectId, plan.getId());
query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime));
jsonObject.put("count", esClientDao.count(query));
res.add(jsonObject);
}
return res;
......@@ -2468,6 +2469,7 @@ public class MarkDataServiceImpl implements MarkDataService {
String projectId = markSearchDTO.getProjectId();
String contendId = markSearchDTO.getContendId();
String planId = markSearchDTO.getPlanId();
Long gid = markSearchDTO.getGid();
// 重复消息折叠
if (markSearchDTO.isFold()) {
// 根据旧顺序排序
......@@ -2481,17 +2483,17 @@ public class MarkDataServiceImpl implements MarkDataService {
return sortList.stream().map(id -> {
List<Map<String, Object>> maps = collect.get(id);
if (null != maps) {
return MarkFlowEntity.getFoldInstance(maps.stream().map(map -> getNonManualMarkFlowEntity(map, projectId, contendId, planId)).collect(Collectors.toList()));
return MarkFlowEntity.getFoldInstance(maps.stream().map(map -> getNonManualMarkFlowEntity(map, projectId, contendId, planId, gid)).collect(Collectors.toList()));
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toList());
}
return Arrays.stream(searchHits.getHits()).map(hit -> getNonManualMarkFlowEntity(hit.getSourceAsMap(), projectId, contendId, planId)).collect(Collectors.toList());
return Arrays.stream(searchHits.getHits()).map(hit -> getNonManualMarkFlowEntity(hit.getSourceAsMap(), projectId, contendId, planId, gid)).collect(Collectors.toList());
}
private MarkFlowEntity getNonManualMarkFlowEntity(Map<String, Object> map, String projectId, String contendId, String planId) {
private MarkFlowEntity getNonManualMarkFlowEntity(Map<String, Object> map, String projectId, String contendId, String planId, Long gid) {
MarkFlowEntity instance = new MarkFlowEntity(new JSONObject(map));
instance.setInfo(markFlowService.createNonManualMarkFlowInfo(new MarkFlowService.MarkInfoSource(new JSONObject(map), projectId, contendId, planId)));
instance.setInfo(markFlowService.createNonManualMarkFlowInfo(new MarkFlowService.MarkInfoSource(new JSONObject(map), projectId, contendId, planId, gid)));
return instance;
}
......@@ -2605,7 +2607,8 @@ public class MarkDataServiceImpl implements MarkDataService {
for (AggreeResult aggreeResult : fatherList) {
List<MarkFlowEntity> markFlowEntities = new ArrayList<>();
MarkFlowEntity instance = new MarkFlowEntity(aggreeResult.getData(), dto.getLinkedGroupId());
instance.setInfo(createMarkFlowInfo.create(new MarkFlowService.MarkInfoSource(aggreeResult.getData(), dto.getProjectId(), dto.getContendId(), dto.getPlanId(), dto.getLinkedGroupId())));
instance.setInfo(createMarkFlowInfo.create(new MarkFlowService.MarkInfoSource(aggreeResult.getData(), dto.getProjectId(), dto.getContendId(),
dto.getPlanId(), dto.getLinkedGroupId(), dto.getGid())));
markFlowEntities.add(instance);
// 添加父标题集下的子标题集
resList.add(MarkFlowEntity.getAggreeInstance(markFlowEntities, aggreeResult, sonDetails));
......
......@@ -91,6 +91,9 @@ public class MarkFlowServiceImpl implements MarkFlowService {
resultInfo.put("highLightWord", getHighLightWords(json, markInfoSource.getProjectId(), markInfoSource.getPlanId()));
// 词频
resultInfo.put("keywordCount", getKeywordCount(json, markInfoSource.getProjectId(), markInfoSource.getPlanId()));
// 已读
Long esGid = json.getLong(GenericAttribute.ES_GID);
resultInfo.put("read", markInfoSource.getGid() >= esGid);
return resultInfo;
}
......@@ -214,11 +217,14 @@ public class MarkFlowServiceImpl implements MarkFlowService {
if (Objects.isNull(keyword)){
continue;
}
String[] keywordAndFrequency = keyword.split(":");
String word = keywordAndFrequency[0];
Integer frequency = Integer.valueOf(keywordAndFrequency[1]);
String[] manyKeywordAndFrequency = keyword.split(",");
for (String keywordAndFrequency : manyKeywordAndFrequency) {
String[] split = keywordAndFrequency.split(":");
String word = split[0];
Integer frequency = Integer.valueOf(split[1]);
res.put(word, frequency);
}
}
return res;
}
......@@ -229,13 +235,16 @@ public class MarkFlowServiceImpl implements MarkFlowService {
if (Objects.isNull(keyword)){
continue;
}
String[] keywordAndFrequency = keyword.split(":");
String words = keywordAndFrequency[0];
String[] manyKeywordAndFrequency = keyword.split(",");
for (String keywordAndFrequency : manyKeywordAndFrequency) {
String[] split = keywordAndFrequency.split(":");
String words = split[0];
if (Objects.nonNull(words)){
String[] word = words.split(" ");
res.addAll(new ArrayList<>(Arrays.asList(word)));
}
}
}
return res.stream().distinct().collect(Collectors.toList());
}
......
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