Commit 553c2390 by 陈健智

渠道库-重要渠道清单

parent 386ac95d
......@@ -315,4 +315,19 @@ public class AppChannelController extends BaseController {
}
return ResponseResult.failure("渠道申请失败");
}
@ApiOperation("重要渠道清单-清单列表")
@GetMapping("/important-channel/list")
public ResponseResult getImportantChannelList(@RequestParam(value = "type", defaultValue = "市监局") String type,
@RequestParam(value = "keyword", required = false) String keyword) {
return ResponseResult.success(channelService.getImportantChannelList(type, keyword));
}
@ApiOperation("重要渠道清单-清单列表-详情")
@GetMapping("/important-channel/list/detail")
public ResponseResult getImportantChannelListDetail(@RequestParam(value = "type") String type,
@RequestParam(value = "name") String name,
@RequestParam(value = "keyword", required = false) String keyword) {
return ResponseResult.success(channelService.getImportantChannelListDetail(type, name, keyword));
}
}
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.ImportantChannel;
/**
* @ClassName: ImportantChannelDao
* @Description 重要渠道清单dao
* @author: cjz
* @date: 2024-06-14 14:03
*/
public interface ImportantChannelDao extends BaseMongoDao<ImportantChannel>{
}
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.ImportantChannelOverview;
/**
* @ClassName: ImportantChannelOverviewDao
* @Description 重要渠道清单概览dao
* @author: cjz
* @date: 2024-06-17 10:03
*/
public interface ImportantChannelOverviewDao extends BaseMongoDao<ImportantChannelOverview>{
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.ImportantChannelDao;
import com.zhiwei.brandkbs2.pojo.ImportantChannel;
import org.springframework.stereotype.Component;
/**
* @ClassName: ImportantChannelDaoImpl
* @Description 重要渠道清单dao
* @author: cjz
* @date: 2024-06-14 14:03
*/
@Component("importantChannelDao")
public class ImportantChannelDaoImpl extends BaseMongoDaoImpl<ImportantChannel> implements ImportantChannelDao {
private static final String COLLECTION_NAME = "brandkbs_important_channel";
public ImportantChannelDaoImpl() {
super(COLLECTION_NAME);
}
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.ImportantChannelOverviewDao;
import com.zhiwei.brandkbs2.pojo.ImportantChannelOverview;
import org.springframework.stereotype.Component;
/**
* @ClassName: ImportantChannelOverviewDao
* @Description 重要渠道清单概览dao
* @author: cjz
* @date: 2024-06-17 10:03
*/
@Component("importantChannelOverviewDao")
public class ImportantChannelOverviewDaoImpl extends BaseMongoDaoImpl<ImportantChannelOverview> implements ImportantChannelOverviewDao {
private static final String COLLECTION_NAME = "brandkbs_important_channel_overview";
public ImportantChannelOverviewDaoImpl() {
super(COLLECTION_NAME);
}
}
package com.zhiwei.brandkbs2.pojo;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* @author cjz
* @version 1.0
* @description 重要渠道清单
* @date 2024年6月14日10:06:46
*/
@Getter
@Setter
public class ImportantChannel extends AbstractBaseMongo{
/**
* 机构类型
*/
private String institution;
/**
* 机构标签
*/
private List<String> institutionTags;
/**
* 地域
*/
private String region;
/**
* 细分地域
*/
private String subdivideRegion;
/**
* 平台
*/
private String platform;
/**
* 渠道
*/
private String source;
/**
* 媒体类型
*/
private String media;
/**
* 媒体标签
*/
private List<String> mediaTags;
/**
* 主体
*/
private String mainBody;
/**
* 单位名称
*/
private String organization;
/**
* 应用程序
*/
private String application;
/**
* 创建时间
*/
private Long cTime;
/**
* 修改时间
*/
private Long uTime;
}
package com.zhiwei.brandkbs2.pojo;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* @author cjz
* @version 1.0
* @description 重要渠道清单
* @date 2024年6月14日10:06:46
*/
@Getter
@Setter
public class ImportantChannelOverview extends AbstractBaseMongo{
/**
* 机构类型
*/
private String type;
/**
* 机构标签
*/
private List<String> tags;
// /**
// * 媒体类型
// */
// private String media;
// /**
// * 媒体标签
// */
// private List<String> mediaTags;
// /**
// * 地域
// */
// private String region;
//
// /**
// * 单位名称
// */
// private String mainBody;
/**
* 具体信息
*/
private List<JSONObject> info;
// private List<String> source;
/**
* 创建时间
*/
private Long cTime;
/**
* 修改时间
*/
private Long uTime;
}
......@@ -309,5 +309,28 @@ public interface ChannelService {
*/
Map<String, JSONObject> getProjectEmotionChannelListData() throws IOException;
/**
* 匹配舆情重要渠道
* @param linkedGroupId
* @param source
* @return
*/
JSONObject matchYuQingSensitiveChannel(String linkedGroupId, String source);
/**
* 获取重要渠道清单列表
* @param type
* @param keyword
* @return
*/
List<JSONObject> getImportantChannelList(String type, String keyword);
/**
* 获取重要渠道清单列表详情
* @param type
* @param name
* @param keyword
* @return
*/
JSONObject getImportantChannelListDetail(String type, String name, String keyword);
}
......@@ -69,6 +69,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
......@@ -120,6 +121,12 @@ public class ChannelServiceImpl implements ChannelService {
@Resource(name = "eventMiddlewareDao")
EventMiddlewareDao eventMiddlewareDao;
@Resource(name = "importantChannelDao")
private ImportantChannelDao importantChannelDao;
@Resource(name = "importantChannelOverviewDao")
private ImportantChannelOverviewDao importantChannelOverviewDao;
@Resource(name = "mongoUtil")
MongoUtil mongoUtil;
......@@ -759,6 +766,122 @@ public class ChannelServiceImpl implements ChannelService {
}
@Override
public List<JSONObject> getImportantChannelList(String type, String keyword) {
Query query = new Query();
query.addCriteria(Criteria.where("type").is(type));
ImportantChannelOverview overview = importantChannelOverviewDao.findOne("type", type);
if (StringUtils.isNotEmpty(keyword)){
List<JSONObject> res = new ArrayList<>();
Pattern pattern = Pattern.compile(keyword);
for (JSONObject jsonObject : overview.getInfo()) {
List<String> sources = jsonObject.getJSONArray("source").toJavaList(String.class);
for (String source : sources) {
if (pattern.matcher(source).find()){
res.add(jsonObject);
break;
}
}
}
return res;
}
return overview.getInfo();
}
@Override
public JSONObject getImportantChannelListDetail(String type, String name, String keyword) {
String searchType = Arrays.asList("18家媒体", "区域媒体").contains(type) ? "media" : "institution";
String searchName = Objects.equals("18家媒体", type) ? "mainBody" : "region";
List<String> platformSort = Arrays.asList("18家媒体", "区域媒体").contains(type) ? Arrays.asList("新浪微博", "微信", "网媒", "B站", "头条", "抖音") : Arrays.asList("微信公众号", "新浪微博", "网媒");
// query
Query query = new Query();
query.addCriteria(Criteria.where(searchType).is(type));
query.addCriteria(Criteria.where(searchName).is(name));
if (StringUtils.isNotEmpty(keyword)){
importantChannelOverviewDao.addKeywordFuzz(query, keyword, "source");
}
List<ImportantChannel> list = importantChannelDao.findList(query);
// 顺序需按照平台命中 例:微博不为空的优先放前面
List<ImportantChannel> sortList = new ArrayList<>();
Map<String, List<ImportantChannel>> platformGroup = list.stream().collect(Collectors.groupingBy(ImportantChannel::getPlatform, LinkedHashMap::new, Collectors.toList()));
for (String platform : platformSort){
if (Objects.nonNull(platformGroup.get(platform))){
sortList.addAll(platformGroup.get(platform));
}
}
if (Objects.equals("区域媒体", type)){
return regionMediaDataProcess(sortList);
}else if (Arrays.asList("纪检委", "政法委").contains(type)){
return provinceDataProcess(sortList);
}else {
return dataProcess(sortList, type);
}
}
private JSONObject provinceDataProcess(List<ImportantChannel> sortList){
List<JSONObject> resList = new ArrayList<>();
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
LinkedHashMap<String, List<ImportantChannel>> platformMap = sortList.stream().collect(Collectors.groupingBy(ImportantChannel::getPlatform, LinkedHashMap::new, Collectors.toList()));
for (Map.Entry<String, List<ImportantChannel>> entry : platformMap.entrySet()) {
jsonObject.put(entry.getKey(), entry.getValue().stream().map(ImportantChannel::getSource).collect(Collectors.toList()));
}
resList.add(jsonObject);
JSONObject res = new JSONObject();
res.put("count", sortList.size());
res.put("list", resList);
return res;
}
private JSONObject dataProcess(List<ImportantChannel> sortList, String type){
Map<String, List<ImportantChannel>> map = Objects.equals("18家媒体", type)
? sortList.stream().collect(Collectors.groupingBy(ImportantChannel::getOrganization, LinkedHashMap::new, Collectors.toList()))
: sortList.stream().collect(Collectors.groupingBy(ImportantChannel::getSubdivideRegion, LinkedHashMap::new, Collectors.toList()));
List<JSONObject> resList = new ArrayList<>();
for (Map.Entry<String, List<ImportantChannel>> entry : map.entrySet()) {
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
jsonObject.put(Objects.equals("18家媒体", type) ? "单位名称" : "细分地域", entry.getKey());
if (Objects.equals("18家媒体", type)) {
jsonObject.put("应用程序", entry.getValue().stream().map(ImportantChannel::getApplication).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
}
LinkedHashMap<String, List<ImportantChannel>> platformMap = entry.getValue().stream().collect(Collectors.groupingBy(ImportantChannel::getPlatform, LinkedHashMap::new, Collectors.toList()));
for (Map.Entry<String, List<ImportantChannel>> platformEntry : platformMap.entrySet()) {
jsonObject.put(platformEntry.getKey(), platformEntry.getValue().stream().map(ImportantChannel::getSource).collect(Collectors.toList()));
}
resList.add(jsonObject);
}
JSONObject res = new JSONObject();
res.put("count", sortList.size());
res.put("list", resList);
return res;
}
private JSONObject regionMediaDataProcess(List<ImportantChannel> sortList){
Map<String, List<ImportantChannel>> map = sortList.stream().collect(Collectors.groupingBy(ImportantChannel::getMainBody, LinkedHashMap::new, Collectors.toList()));
List<JSONObject> resList = new ArrayList<>();
for (Map.Entry<String, List<ImportantChannel>> entry : map.entrySet()) {
JSONObject mainBodyJson = new JSONObject(new LinkedHashMap<>());
mainBodyJson.put("主体", entry.getKey());
LinkedHashMap<String, List<ImportantChannel>> organizationMap = entry.getValue().stream().collect(Collectors.groupingBy(ImportantChannel::getOrganization, LinkedHashMap::new, Collectors.toList()));
List<JSONObject> platformJson = new ArrayList<>();
for (Map.Entry<String, List<ImportantChannel>> organizationEntry : organizationMap.entrySet()) {
LinkedHashMap<String, List<ImportantChannel>> platformMap = organizationEntry.getValue().stream().collect(Collectors.groupingBy(ImportantChannel::getPlatform, LinkedHashMap::new, Collectors.toList()));
JSONObject dataJson = new JSONObject(new LinkedHashMap<>());
dataJson.put("单位名称", organizationEntry.getKey());
dataJson.put("应用程序", organizationEntry.getValue().stream().map(ImportantChannel::getApplication).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
for (Map.Entry<String, List<ImportantChannel>> platformEntry : platformMap.entrySet()) {
dataJson.put(platformEntry.getKey(), platformEntry.getValue().stream().map(ImportantChannel::getSource).collect(Collectors.toList()));
}
platformJson.add(dataJson);
}
mainBodyJson.put("list", platformJson);
resList.add(mainBodyJson);
}
JSONObject res = new JSONObject();
res.put("count", sortList.size());
res.put("list", resList);
return res;
}
@Override
public JSONObject getSpreadingTend(String channelId, String type, String contendIds, Long startTime, Long endTime) {
JSONObject res = new JSONObject();
// 默认全部 TODO
......
......@@ -964,10 +964,11 @@ public class ToolsetServiceImpl implements ToolsetService {
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId();
jsonObject = restTemplate.getForEntity(articleInfoUrl, JSONObject.class, url, linkedGroupId, UserThreadLocal.getNickname()).getBody();
} catch (Exception e) {
log.info("url:{},访问链接信息提取接口异常-", url, e);
log.error("url:{},访问链接信息提取接口异常-", url, e);
return null;
}
if (Objects.isNull(jsonObject) || !jsonObject.getBoolean("status")) {
log.error("url:{},访问链接信息提取接口异常-返回信息:{}", url, JSONObject.toJSONString(jsonObject));
return null;
}
return jsonObject.getJSONObject("data");
......@@ -994,7 +995,7 @@ public class ToolsetServiceImpl implements ToolsetService {
ResponseEntity<String> response = restTemplate.postForEntity(articleSummaryUrl, request, String.class);
return response.getBody();
}catch (Exception e){
log.info("访问摘要提取接口异常-", e);
log.error("访问摘要提取接口异常-", e);
return errorString;
}
}
......
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