private void mergeNewRecordsToMap(
        Long timeId,
        String itemId,
        ActiveRecord activeRecord,
        HashMap<Long, HashMap<String, HashMap<Integer, ActType>>> detailMap) {

      HashMap<String, HashMap<Integer, ActType>> itemMap;
      if (detailMap.containsKey(timeId)) {
        itemMap = detailMap.get(timeId);
      } else {
        itemMap = new HashMap<String, HashMap<Integer, ActType>>();
      }

      HashMap<Integer, ActType> actMap;
      if (itemMap.containsKey(itemId)) {
        actMap = itemMap.get(itemId);
      } else {
        actMap = new HashMap<Integer, ActType>();
      }

      long count = 1L;
      if (actMap.containsKey(activeRecord.getActType())) {
        count = count + actMap.get(activeRecord.getActType()).getCount();
      }
      ActType newActInfo =
          ActType.newBuilder()
              .setActType(activeRecord.getActType())
              .setCount(count)
              .setLastUpdateTime(activeRecord.getActTime())
              .build();

      actMap.put(activeRecord.getActType(), newActInfo);
      itemMap.put(itemId, actMap);
      detailMap.put(timeId, itemMap);
    }
    private void mergeOldToMap(
        UserActiveDetail oldValList,
        HashMap<Long, HashMap<String, HashMap<Integer, ActType>>> detailMap) {
      if (oldValList == null || oldValList.getTsegsCount() <= 0) {
        return;
      }

      for (UserActiveDetail.TimeSegment tsegs : oldValList.getTsegsList()) {
        HashMap<String, HashMap<Integer, ActType>> itemMap;
        if (detailMap.containsKey(tsegs.getTimeId())) {
          itemMap = detailMap.get(tsegs.getTimeId());
        } else {
          itemMap = new HashMap<String, HashMap<Integer, ActType>>();
        }

        for (UserActiveDetail.TimeSegment.ItemInfo item : tsegs.getItemsList()) {
          HashMap<Integer, ActType> actMap;
          if (itemMap.containsKey(item.getItem())) {
            actMap = itemMap.get(item.getItem());
          } else {
            actMap = new HashMap<Integer, ActType>();
          }

          for (UserActiveDetail.TimeSegment.ItemInfo.ActType act : item.getActsList()) {
            Long count = act.getCount();
            if (actMap.containsKey(act.getActType())) {
              count = count + actMap.get(act.getActType()).getCount();
            }
            ActType newActInfo =
                ActType.newBuilder()
                    .setActType(act.getActType())
                    .setCount(count)
                    .setLastUpdateTime(act.getLastUpdateTime())
                    .build();

            actMap.put(act.getActType(), newActInfo);
          }
          itemMap.put(item.getItem(), actMap);
        }
        detailMap.put(tsegs.getTimeId(), itemMap);
      }
    }