Commit d035081d by shenjunjie

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

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