Commit 77a4d296 by shenjunjie

Merge branch 'feature' into 'release'

恢复channel_influence更新

See merge request !154
parents 86217444 eec2b0b0
...@@ -10,6 +10,7 @@ import lombok.Setter; ...@@ -10,6 +10,7 @@ import lombok.Setter;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -113,7 +114,6 @@ public class Channel extends ChannelIndex { ...@@ -113,7 +114,6 @@ public class Channel extends ChannelIndex {
channel.setId(ObjectId.get().toString()); channel.setId(ObjectId.get().toString());
channel.setCTime(new Date().getTime()); channel.setCTime(new Date().getTime());
channel.setProjectId(channelIndex.getProjectId()); channel.setProjectId(channelIndex.getProjectId());
channel.setLinkedGroupId(channelIndex.getLinkedGroupId());
channel.setContendId(channelIndex.getContendId()); channel.setContendId(channelIndex.getContendId());
channel.setPlatform(channelIndex.getPlatform()); channel.setPlatform(channelIndex.getPlatform());
channel.setRealSource(channelIndex.getRealSource()); channel.setRealSource(channelIndex.getRealSource());
...@@ -123,9 +123,24 @@ public class Channel extends ChannelIndex { ...@@ -123,9 +123,24 @@ public class Channel extends ChannelIndex {
channel.setLastTime(record.getLastTime()); channel.setLastTime(record.getLastTime());
channel.setRecord(record); channel.setRecord(record);
channel.updateInfo(channelIndex,record);
return channel; return channel;
} }
public void updateInfo(ChannelIndex channelIndex, Record record) {
this.setInfluence(record.getInfluence());
String hitKey = Tools.concat(channelIndex.getProjectId(), channelIndex.getContendId());
List<Map<String, Object>> cacheMaps = record.getCacheMaps();
for (Map<String, Object> cacheMap : cacheMaps) {
if (hitKey.equals(cacheMap.get("key"))) {
Object channelType = cacheMap.get("channel_type");
if (null != channelType) {
this.setMediaType(channelType + "");
}
}
}
}
public Map<String, Object> createChannelCopyMap() { public Map<String, Object> createChannelCopyMap() {
JSONObject json = JSON.parseObject(JSON.toJSONString(this, JSON_CONFIG)); JSONObject json = JSON.parseObject(JSON.toJSONString(this, JSON_CONFIG));
json.remove("channel_index"); json.remove("channel_index");
......
...@@ -142,18 +142,27 @@ public class ChannelIndex extends AbstractBaseMongo { ...@@ -142,18 +142,27 @@ public class ChannelIndex extends AbstractBaseMongo {
@Setter @Setter
@Getter @Getter
@AllArgsConstructor
public static class Record { public static class Record {
private Long lastTime; private Long lastTime;
private List<Article> articles = new ArrayList<>(); private List<Article> articles = new ArrayList<>();
// 附带需要更新字段的部分
private Double influence;
private List<Map<String, Object>> cacheMaps;
public Record() { public Record() {
} }
public Record(Long lastTime, List<Article> articles) {
this.lastTime = lastTime;
this.articles = articles;
}
public Record(Map<String, Object> esMap) { public Record(Map<String, Object> esMap) {
this.lastTime = Long.parseLong(esMap.get("time") + ""); this.lastTime = Long.parseLong(esMap.get("time") + "");
this.articles.add(Article.fromEsMap(esMap)); this.articles.add(Article.fromEsMap(esMap));
this.influence = Double.valueOf(esMap.get("channel_influence") + "");
this.cacheMaps = (List<Map<String, Object>>) esMap.get(GenericAttribute.ES_BRANDKBS_CACHE_MAPS);
} }
public void setLastTime(Long lastTime) { public void setLastTime(Long lastTime) {
......
...@@ -186,7 +186,9 @@ public class TaskServiceImpl implements TaskService { ...@@ -186,7 +186,9 @@ public class TaskServiceImpl implements TaskService {
insertList.add(channelService.calculateChannelEmotionIndex(channel)); insertList.add(channelService.calculateChannelEmotionIndex(channel));
} else { } else {
channel.setRecord(entry.getValue()); channel.setRecord(entry.getValue());
channelDao.updateOne(channelService.calculateChannelEmotionIndex(channel)); Channel updateChannel = channelService.calculateChannelEmotionIndex(channel);
updateChannel.updateInfo(entry.getKey(), entry.getValue());
channelDao.updateOne(updateChannel);
updateList.add(channel); updateList.add(channel);
} }
// 设置查询数值 // 设置查询数值
......
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