Commit f4a7feae by shenjunjie

Merge branch 'feature' into 'release'

竞品对比分析图谱时间间隔调整3

See merge request !224
parents cb87de34 d035081d
......@@ -1131,15 +1131,7 @@ public class MarkDataServiceImpl implements MarkDataService {
result.put("startTime", startTime);
// 结束时间
result.put("endTime", endTime);
// 时间超过三天则选用day
List<Map<String, Long>> cutList;
if (endTime - startTime > Constant.ONE_DAY * 3) {
cutList = Tools.parseToDays(startTime, endTime);
result.put("timeType", "day");
} else {
cutList = Tools.parseToHours(startTime, endTime);
result.put("timeType", "hour");
}
List<Map<String, Long>> cutList = Tools.getCutList(startTime, endTime).getRight();
// 主品牌图谱
JSONObject primaryLine = new JSONObject();
primaryLine.put("id", Constant.PRIMARY_CONTEND_ID);
......@@ -1912,5 +1904,4 @@ public class MarkDataServiceImpl implements MarkDataService {
return instance;
}
}
\ No newline at end of file
......@@ -28,7 +28,6 @@ import com.zhiwei.brandkbs2.service.ReportService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import com.zhiwei.brandkbs2.util.RedisUtil;
import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.event.core.EventClient;
import com.zhiwei.middleware.event.pojo.entity.BrandkbsBasicInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -346,8 +345,9 @@ public class ReportServiceImpl implements ReportService {
result.put("status", true);
result.put("type", ReportTypeEnum.getInstanceByState(report.getType()).getDescribe());
result.put("brandSummary", this.getPcBrandSummary(startTime, endTime, lastStartTimeStr, projectId, linkedGroupId, contendId));
List<Map<String, Long>> dayList = Tools.parseToDays(startTime, DateUtils.addDays(new Date(endTime), -1).getTime());
result.put("brandSpread", this.getPcBrandSpread(dayList, projectId, linkedGroupId, contendId));
Pair<Boolean, List<Map<String, Long>>> pair = Tools.getCutList(startTime, endTime);
result.put("timeType", pair.getLeft() ? "day" : "hour");
result.put("brandSpread", this.getPcBrandSpread(pair.getRight(), projectId, linkedGroupId, contendId));
result.put("brandEvent", this.getPcBrandEvent(startTime, endTime, projectId, contendId));
List<JSONObject> contendCompare = report.getContends().stream().map(brandContendId -> {
JSONObject json = new JSONObject();
......
......@@ -24,6 +24,7 @@ import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.commons.lang3.tuple.Pair;
import org.dozer.DozerBeanMapper;
import org.joda.time.Period;
import org.joda.time.PeriodType;
......@@ -853,6 +854,19 @@ public class Tools {
return dayList;
}
public static Pair<Boolean, List<Map<String, Long>>> getCutList(Long startTime, Long endTime) {
// 时间超过三天则选用day
boolean dayType = true;
List<Map<String, Long>> cutList;
if (endTime - startTime > Constant.ONE_DAY * 3) {
cutList = Tools.parseToDays(startTime, endTime);
} else {
cutList = Tools.parseToHours(startTime, endTime);
dayType = false;
}
return Pair.of(dayType, cutList);
}
public static boolean isContains(String keyword, String content) {
if (null == keyword) {
return true;
......
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