Search in sources :

Example 1 with TimelineBehaviorHistoryCondition

use of com.alibaba.otter.manager.biz.statistics.table.param.TimelineBehaviorHistoryCondition in project otter by alibaba.

the class BehaviorHistoryCurve method execute.

public void execute(@Param("d5221") String startTime, @Param("d5222") String endTime, @Param("dataMediaPairId") Long dataMediaPairId, HttpSession session, Context context) throws Exception {
    Date end = null;
    Date start = null;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) {
        start = new Date(System.currentTimeMillis() / 60000 * 60000 - 24 * 60 * 60 * 1000);
        end = new Date(System.currentTimeMillis() / 60000 * 60000);
    } else {
        // 当前24小时,时间取整分钟
        sdf.setLenient(false);
        if (null != startTime && null != endTime) {
            start = sdf.parse(startTime);
            end = sdf.parse(endTime);
        }
    }
    DataMediaPair dataMediaPair = dataMediaPairService.findById(dataMediaPairId);
    Channel channel = channelService.findByPipelineId(dataMediaPair.getPipelineId());
    Map<Long, BehaviorHistoryInfo> behaviourHistoryInfos = new LinkedHashMap<Long, BehaviorHistoryInfo>();
    TimelineBehaviorHistoryCondition condition = new TimelineBehaviorHistoryCondition();
    if (null != start && null != end) {
        condition.setStart(start);
        condition.setEnd(end);
        condition.setPairId(dataMediaPairId);
        behaviourHistoryInfos = tableStatService.listTimelineBehaviorHistory(condition);
    }
    Long totalInsert = 0L;
    Long totalUpdate = 0L;
    Long totalDelete = 0L;
    Long totalFileCount = 0L;
    Long totalFileSize = 0L;
    for (BehaviorHistoryInfo info : behaviourHistoryInfos.values()) {
        totalInsert += info.getInsertNumber();
        totalUpdate += info.getUpdateNumber();
        totalDelete += info.getDeleteNumber();
        totalFileCount += info.getFileNumber();
        totalFileSize += info.getFileSize();
    }
    context.put("totalInsert", totalInsert);
    context.put("totalUpdate", totalUpdate);
    context.put("totalDelete", totalDelete);
    context.put("totalFileCount", totalFileCount);
    context.put("totalFileSize", totalFileSize);
    context.put("behaviourHistoryInfos", behaviourHistoryInfos);
    context.put("start", sdf.format(start));
    context.put("end", sdf.format(end));
    context.put("dataMediaPair", dataMediaPair);
    context.put("channel", channel);
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) BehaviorHistoryInfo(com.alibaba.otter.manager.biz.statistics.table.param.BehaviorHistoryInfo) TimelineBehaviorHistoryCondition(com.alibaba.otter.manager.biz.statistics.table.param.TimelineBehaviorHistoryCondition) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

BehaviorHistoryInfo (com.alibaba.otter.manager.biz.statistics.table.param.BehaviorHistoryInfo)1 TimelineBehaviorHistoryCondition (com.alibaba.otter.manager.biz.statistics.table.param.TimelineBehaviorHistoryCondition)1 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)1 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1