Commit e4503941 by 陈健智

趋势图修复

parent c5ed5b2d
......@@ -889,16 +889,17 @@ public class SearchWholeServiceImpl implements SearchWholeService {
long count = bucket.getDocCount();
res.add(new LineVO(count, time));
});
List<LineVO> resLine = Tools.completeLine(res, dto.getStartTime(), dto.getEndTime());
// 由于结束点为开区间,将结束点数据补完
if (CollectionUtils.isNotEmpty(res)){
res.get(0).setDate(dto.getStartTime());
if (CollectionUtils.isNotEmpty(resLine)){
// res.get(0).setDate(dto.getStartTime());
SearchFilterDTO searchFilterDTO = Tools.convertMap(dto, SearchFilterDTO.class);
searchFilterDTO.setStartTime(dto.getEndTime());
searchFilterDTO.setEndTime(dto.getEndTime() + 1);
Long count = esClientDao.count(indexes, searchWholeAnalyzeQuery(searchFilterDTO), null);
res.add(new LineVO(count, dto.getEndTime()));
resLine.add(new LineVO(count, dto.getEndTime()));
}
return res;
return resLine;
}
/**
......@@ -966,9 +967,10 @@ public class SearchWholeServiceImpl implements SearchWholeService {
platformLines.forEach((k1, v1) -> {
List<LineVO> line = new ArrayList<>();
v1.forEach((k2, v2) -> line.add(new LineVO(v2, Long.valueOf(k2))));
List<LineVO> resLine = Tools.completeLine(line, dto.getStartTime(), dto.getEndTime());
// 结束点数据补充完全
if (CollectionUtils.isNotEmpty(line)){
line.get(0).setDate(dto.getStartTime());
if (CollectionUtils.isNotEmpty(resLine)){
// line.get(0).setDate(dto.getStartTime());
SearchFilterDTO searchFilterDTO = Tools.convertMap(dto, SearchFilterDTO.class);
searchFilterDTO.setPlatforms(Collections.singletonList(GlobalPojo.getPlatformIdByName(k1)));
searchFilterDTO.setStartTime(dto.getEndTime());
......@@ -978,9 +980,9 @@ public class SearchWholeServiceImpl implements SearchWholeService {
count = esClientDao.count(indexes, searchWholeAnalyzeQuery(searchFilterDTO), null);
} catch (IOException ignore) {
}
line.add(new LineVO(count, dto.getEndTime()));
resLine.add(new LineVO(count, dto.getEndTime()));
}
res.put(k1, line);
res.put(k1, resLine);
});
return res;
}
......
......@@ -17,6 +17,7 @@ import com.zhiwei.brandkbs2.easyexcel.dto.UploadKeywordDTO;
import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.pojo.vo.LineVO;
import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import com.zhiwei.qbjc.bean.pojo.common.Tag;
import com.zhiwei.qbjc.bean.tools.BeanTools;
......@@ -1422,4 +1423,51 @@ public class Tools {
}
return new Long[]{calendar1.getTime().getTime(), calendar2.getTime().getTime()};
}
/**
* 补全图谱
* @param lines
* @param startTime
* @param endTime
* @return
*/
public static List<LineVO> completeLine(List<LineVO> lines, Long startTime, Long endTime){
int size = endTime - startTime > 7 * Constant.ONE_DAY ? 30 : (endTime - startTime <= Constant.ONE_DAY ? 24 : 7);
long timeRange = 7 == size || 30 == size ? Constant.ONE_DAY : Constant.ONE_HOUR;
if (lines.size() < size){
// 无数据,按时间段全部补为0
if (CollectionUtils.isEmpty(lines)){
for (int i = 0; i < size; i++) {
lines.add(new LineVO(0L, startTime));
startTime = startTime + timeRange;
if (startTime >= endTime || lines.size() >= size){
break;
}
}
return lines;
}else {
// 往前补0
LineVO startLine = lines.get(0);
Long startLineTime = startLine.getDate();
for (int i = 0; i < size; i++) {
startLineTime = startLineTime - timeRange;
if (startLineTime <= startTime || lines.size() >= size){
break;
}
lines.add(0, new LineVO(0L, startLineTime));
}
// 往后补0
LineVO endLine = lines.get(lines.size() - 1);
Long endLineTime = endLine.getDate();
for (int i = 0; i < size; i++) {
endLineTime = endLineTime + timeRange;
if (endLineTime >= endTime || lines.size() >= size){
break;
}
lines.add(new LineVO(0L, endLineTime));
}
}
}
return lines;
}
}
\ No newline at end of file
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