Commit 36b3570e by shenjunjie

修复事件传播bug

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