Commit 95ba7e02 by shenjunjie

Merge branch 'feature' into 'release'

Feature

See merge request !409
parents 641180ae e15cbc04
......@@ -50,7 +50,7 @@ public class CommonConfig {
public RestTemplate restTemplate() throws Exception {
final OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(120, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.readTimeout(120, TimeUnit.SECONDS)
// 忽略SSL证书验证
.sslSocketFactory(createSslSocketFactory(), new SkipX509TrustManager())
.hostnameVerifier((s, sslSession) -> true)
......
......@@ -37,16 +37,16 @@ public class ExportInteractionUpdateDTO {
private Date time;
@ExcelProperty("评论数")
private int commentCount;
private Integer commentCount;
@ExcelProperty("点赞数")
private int likeCount;
private Integer likeCount;
@ExcelProperty("转发数")
private int repostCount;
private Integer repostCount;
@ExcelProperty("阅读数")
private int readCount;
private Integer readCount;
public ExportInteractionUpdateDTO(String id, Map<Object, JSONObject> urlMap, String url){
this.id = id;
......@@ -54,27 +54,11 @@ public class ExportInteractionUpdateDTO {
this.url = url;
if (Objects.nonNull(urlMap.get(url))){
JSONObject jsonObject = urlMap.get(url);
this.commentCount = jsonObject.getIntValue("commentCount");
this.likeCount = jsonObject.getIntValue("likeCount");
this.repostCount = jsonObject.getIntValue("repostCount");
this.readCount = jsonObject.getIntValue("readCount");
this.commentCount = Objects.nonNull(jsonObject.getInteger("commentCount")) ? jsonObject.getIntValue("commentCount") : 0;
this.likeCount = Objects.nonNull(jsonObject.getInteger("likeCount")) ? jsonObject.getIntValue("likeCount") : 0;
this.repostCount = Objects.nonNull(jsonObject.getInteger("repostCount")) ? jsonObject.getIntValue("repostCount") : 0;
this.readCount = Objects.nonNull(jsonObject.getInteger("readCount")) ? jsonObject.getIntValue("readCount") : 0;
}
this.time = new Date();
}
public static ExportInteractionUpdateDTO createWithPlatform(String id, Map<String, String> urlPlatformMap, Map<Object, JSONObject> urlMap, String url){
ExportInteractionUpdateDTO dto = new ExportInteractionUpdateDTO();
dto.setId(id);
dto.setPlatform(urlPlatformMap.get(url));
dto.setUrl(url);
if (Objects.nonNull(urlMap.get(url))){
JSONObject jsonObject = urlMap.get(url);
dto.setCommentCount(jsonObject.getIntValue("commentCount"));
dto.setLikeCount(jsonObject.getIntValue("likeCount"));
dto.setRepostCount(jsonObject.getIntValue("repostCount"));
dto.setReadCount(jsonObject.getIntValue("readCount"));
}
dto.setTime(new Date());
return dto;
}
}
package com.zhiwei.brandkbs2.easyexcel.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.pojo.BaseMap;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
/**
* @author cjz
* @version 1.0
* @description 导出舆情库互动量更新结果数据实体类
* @date 2023年10月23日 15:44:08
*/
@Data
@ToString
public class ExportYuqingInteractionUpdateDTO {
@ExcelProperty("序号")
private String id;
@ExcelProperty("平台")
private String platform;
@ExcelProperty("渠道")
private String channel;
@ExcelProperty("标题")
private String title;
@ExcelProperty("文本")
private String content;
@ExcelProperty("发文时间")
private Date time;
@ExcelProperty("情感倾向")
private String emotion;
@ExcelProperty("地址")
private String url;
@ExcelProperty("更新时间")
private Date updateTime;
@ExcelProperty("评论数")
private Integer commentCount;
@ExcelProperty("点赞数")
private Integer likeCount;
@ExcelProperty("转发数")
private Integer repostCount;
@ExcelProperty("阅读数")
private Integer readCount;
@ExcelProperty("在看数")
private Integer shareCount;
@ExcelProperty("收藏数")
private Integer collectCount;
public ExportYuqingInteractionUpdateDTO(int id, Map<String, BaseMap> baseMap, Map<Object, JSONObject> resultMap, String url){
BaseMap baseMapEntity = baseMap.get(url);
this.id = String.valueOf(id);
this.platform = baseMapEntity.getPlatform();
this.channel = baseMapEntity.getSource();
this.title = baseMapEntity.getTitle();
this.content = baseMapEntity.getContent();
this.time = new Date(baseMapEntity.getTime());
this.emotion = baseMapEntity.getEmotion();
if (Objects.nonNull(resultMap.get(url))){
JSONObject jsonObject = resultMap.get(url);
this.commentCount = Objects.nonNull(jsonObject.getInteger("commentCount")) ? jsonObject.getIntValue("commentCount") : 0;
this.likeCount = Objects.nonNull(jsonObject.getInteger("likeCount")) ? jsonObject.getIntValue("likeCount") : 0;
this.repostCount = Objects.nonNull(jsonObject.getInteger("repostCount")) ? jsonObject.getIntValue("repostCount") : 0;
this.readCount = Objects.nonNull(jsonObject.getInteger("readCount")) ? jsonObject.getIntValue("readCount") : 0;
this.shareCount = Objects.nonNull(jsonObject.getInteger("shareCount")) ? jsonObject.getIntValue("shareCount") : 0;
this.collectCount = Objects.nonNull(jsonObject.getInteger("collectCount")) ? jsonObject.getIntValue("collectCount") : 0;
}
this.url = url;
this.updateTime = new Date();
}
}
package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -18,7 +17,7 @@ import com.zhiwei.brandkbs2.dao.AggreeResultDao;
import com.zhiwei.brandkbs2.dao.ChannelDao;
import com.zhiwei.brandkbs2.dao.HighlightWordDao;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportInteractionUpdateDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportYuqingInteractionUpdateDTO;
import com.zhiwei.brandkbs2.enmus.ChannelEmotion;
import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.enmus.ImportantChannelEnum;
......@@ -1544,14 +1543,15 @@ public class MarkDataServiceImpl implements MarkDataService {
result.addAll(toolsetService.getInteractionResult(ids));
}
}
Map<Object, JSONObject> urlMap = result.stream().collect(Collectors.toMap(jsonObject -> jsonObject.get("url"), o -> o));
List<ExportInteractionUpdateDTO> exportList = list.stream().map(BaseMap::getUrl)
.map(url -> ExportInteractionUpdateDTO.createWithPlatform(String.valueOf(id.incrementAndGet()), map, urlMap, url))
Map<Object, JSONObject> resultMap = result.stream().collect(Collectors.toMap(jsonObject -> jsonObject.get("url"), o -> o));
Map<String, BaseMap> baseMap = list.stream().collect(Collectors.toMap(BaseMap::getUrl, o -> o, (v1, v2) -> v2));
List<ExportYuqingInteractionUpdateDTO> exportList = list.stream().map(BaseMap::getUrl)
.map(url -> new ExportYuqingInteractionUpdateDTO(id.incrementAndGet(), baseMap, resultMap, url))
.collect(Collectors.toList());
// excel输出到指定路径
String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName();
String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "舆情库互动量更新结果");
EasyExcelUtil.write(filePath, "sheet1", ExportInteractionUpdateDTO.class, exportList);
EasyExcelUtil.write(filePath, "sheet1", ExportYuqingInteractionUpdateDTO.class, exportList);
JSONObject res = new JSONObject();
// 记录使用情况
extraService.decreaseInteractionRecord(InteractionUpdateRecord.UsedType.yuqing, list.size());
......
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