Commit 39cbeb45 by 陈健智

舆情外部接口:获取消息流标签

parent abd25b4c
...@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* @ClassName: InterfaceController * @ClassName: InterfaceController
...@@ -95,4 +96,9 @@ public class InterfaceController { ...@@ -95,4 +96,9 @@ public class InterfaceController {
projectWarnService.newCrisisCaseWarn(caseWarnVO); projectWarnService.newCrisisCaseWarn(caseWarnVO);
} }
@ApiOperation("根据关联组id获取所有的hitTags(舆情项目调用)")
@GetMapping("/hitTags")
public ResponseResult getHitTagsByLinkedGroupId(String linkedGroupId) {
return projectService.getHitTagsByLinkedGroupId(linkedGroupId);
}
} }
package com.zhiwei.brandkbs2.service; package com.zhiwei.brandkbs2.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.AbstractProject; import com.zhiwei.brandkbs2.pojo.AbstractProject;
import com.zhiwei.brandkbs2.pojo.Project; import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.vo.PageVO; import com.zhiwei.brandkbs2.pojo.vo.PageVO;
...@@ -126,4 +127,10 @@ public interface ProjectService { ...@@ -126,4 +127,10 @@ public interface ProjectService {
*/ */
List<Project> getAllProjectsWithStart(); List<Project> getAllProjectsWithStart();
/**
* 根据 linkedGroupId 获取该 linkedGroupId 关联的所有 hitTags
* @param linkedGroupId
* @return
*/
ResponseResult getHitTagsByLinkedGroupId(String linkedGroupId);
} }
...@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.dao.UserDao; ...@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.dao.UserDao;
import com.zhiwei.brandkbs2.enmus.response.ProjectCodeEnum; import com.zhiwei.brandkbs2.enmus.response.ProjectCodeEnum;
import com.zhiwei.brandkbs2.exception.ExceptionCast; import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.model.CommonCodeEnum; import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.AbstractProject; import com.zhiwei.brandkbs2.pojo.AbstractProject;
import com.zhiwei.brandkbs2.pojo.Contend; import com.zhiwei.brandkbs2.pojo.Contend;
import com.zhiwei.brandkbs2.pojo.Project; import com.zhiwei.brandkbs2.pojo.Project;
...@@ -22,7 +23,12 @@ import com.zhiwei.brandkbs2.util.Tools; ...@@ -22,7 +23,12 @@ import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.auth.util.JwtUtil; import com.zhiwei.middleware.auth.util.JwtUtil;
import com.zhiwei.middleware.event.core.EventTagClient; import com.zhiwei.middleware.event.core.EventTagClient;
import com.zhiwei.middleware.event.pojo.dto.EventTagRelatedDTO; import com.zhiwei.middleware.event.pojo.dto.EventTagRelatedDTO;
import com.zhiwei.middleware.event.pojo.entity.BrandkbsBasicInfo;
import com.zhiwei.middleware.event.pojo.entity.Event;
import com.zhiwei.middleware.mark.vo.MarkerTag;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
...@@ -45,6 +51,7 @@ import java.util.stream.Collectors; ...@@ -45,6 +51,7 @@ import java.util.stream.Collectors;
*/ */
@Service("projectServiceImpl") @Service("projectServiceImpl")
public class ProjectServiceImpl implements ProjectService { public class ProjectServiceImpl implements ProjectService {
private static final Logger log = LogManager.getLogger(ProjectServiceImpl.class);
@Resource(name = "userDao") @Resource(name = "userDao")
private UserDao userDao; private UserDao userDao;
...@@ -350,6 +357,47 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -350,6 +357,47 @@ public class ProjectServiceImpl implements ProjectService {
return projectDao.findList(Query.query(Criteria.where("isStart").is(true))); return projectDao.findList(Query.query(Criteria.where("isStart").is(true)));
} }
@Override
public ResponseResult getHitTagsByLinkedGroupId(String linkedGroupId) {
try {
List<JSONObject> result = new ArrayList<>();
Query query = new Query();
Criteria criteria = new Criteria();
criteria.orOperator(Criteria.where("brandLinkedGroupId").is(linkedGroupId), Criteria.where("contendList.brandLinkedGroupId").is(linkedGroupId));
query.addCriteria(criteria);
// 暂且将测试项目排除
query.addCriteria(Criteria.where("_id").ne("632052f0abed641ef800476c"));
List<Project> projects = projectDao.findList(query);
for (Project project : projects) {
if (Objects.equals(project.getBrandLinkedGroupId(), linkedGroupId)) {
if (!Tools.isEmpty(project.getHitTags())) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("tags", project.getHitTags().stream().collect(Collectors.groupingBy(MarkerTag::getGroupName)));
BrandkbsBasicInfo brandkbsBasicInfo = new BrandkbsBasicInfo(project.getProjectName(), project.getId(), project.getBrandName(), project.getId());
jsonObject.put("brandkbsBasicInfo", brandkbsBasicInfo);
result.add(jsonObject);
}
} else {
if (!Tools.isEmpty(project.getContendList())) {
for (Contend contend : project.getContendList()) {
if (Objects.equals(contend.getBrandLinkedGroupId(), linkedGroupId) && !Tools.isEmpty(contend.getHitTags())) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("tags", contend.getHitTags().stream().collect(Collectors.groupingBy(MarkerTag::getGroupName)));
BrandkbsBasicInfo brandkbsBasicInfo = new BrandkbsBasicInfo(project.getProjectName(), project.getId(), contend.getBrandName(), contend.getId());
jsonObject.put("brandkbsBasicInfo", brandkbsBasicInfo);
result.add(jsonObject);
}
}
}
}
}
return ResponseResult.success(result);
}catch (Exception e){
log.error("外部接口获取hitTags出错", e);
return ResponseResult.failure("获取hitTags出错");
}
}
// public JSONObject getUserInfoAndProjectConfig(User user) { // public JSONObject getUserInfoAndProjectConfig(User user) {
// long start = System.currentTimeMillis(); // long start = System.currentTimeMillis();
// JSONObject result = new JSONObject(); // JSONObject result = new JSONObject();
......
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