Commit 36b3570e by shenjunjie

修复事件传播bug

parent db6bc9bd
......@@ -77,12 +77,12 @@ public class EventDisseminationTrend extends AbstractBaseMongo {
Map<String, Object> element = new HashMap<>();
element.put("time", start);
element.put("sum", count);
negativeSpread.add(element);
totalSpread.add(element);
// 负面统计
Map<String, Object> negElement = new HashMap<>();
negElement.put("time", start);
negElement.put("sum", negCount);
totalSpread.add(negElement);
negativeSpread.add(negElement);
// 推进节点并重置计量值
count = 0;
negCount = 0;
......
package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.service.CommonService;
......@@ -13,7 +14,6 @@ import com.zhiwei.middleware.mark.vo.TagSearch;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
......@@ -77,14 +77,18 @@ public class CommonServiceImpl implements CommonService {
@Override
public List<String> getQbjcPlatformNames() {
HttpEntity<JSONObject> entity = restTemplate.getForEntity(qbjcPlatformUrl, JSONObject.class);
return Objects.requireNonNull(entity.getBody()).getJSONArray("data").toJavaList(JSONObject.class).stream().map(json -> json.getString("name")).collect(Collectors.toList());
return getQbjcPlatform("name").stream().map(json -> json.getString("name")).collect(Collectors.toList());
}
@Override
public List<JSONObject> getQbjcPlatform(String... includeFields) {
HttpEntity<JSONObject> entity = restTemplate.getForEntity(qbjcPlatformUrl, JSONObject.class);
return Objects.requireNonNull(entity.getBody()).getJSONArray("data").toJavaList(JSONObject.class).stream().map(json -> {
List<JSONObject> collect = GlobalPojo.PLATFORMS.stream().filter(messagePlatform -> !"外媒".equals(messagePlatform.getName())).map(messagePlatform -> {
JSONObject json = new JSONObject();
json.put("id", messagePlatform.getId());
json.put("name", messagePlatform.getName());
return json;
}).collect(Collectors.toList());
return collect.stream().map(json -> {
if (null == includeFields) {
return json;
}
......@@ -94,6 +98,17 @@ public class CommonServiceImpl implements CommonService {
}
return res;
}).collect(Collectors.toList());
// HttpEntity<JSONObject> entity = restTemplate.getForEntity(qbjcPlatformUrl, JSONObject.class);
// return Objects.requireNonNull(entity.getBody()).getJSONArray("data").toJavaList(JSONObject.class).stream().map(json -> {
// if (null == includeFields) {
// return json;
// }
// JSONObject res = new JSONObject();
// for (String field : includeFields) {
// res.put(field, json.get(field));
// }
// return res;
// }).collect(Collectors.toList());
}
@Override
......
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