开发细节

收集重复的门店,给出异常提示

背景:需要建立一个门店组,门店明细不允许重复,重复时收集重复的门店

点击查看代码
	
public Map getByStoreList(String bufferId,List storeList) {
    Map allMap = new HashMap<>();
    if (storeList == null || storeList.isEmpty()) {
      return allMap;
    }
    /**
     * 举个例子:重复的明细行不用收集太多,收集达到200的上限就可以了.
     * storeIds.size() = 1000
     *
     * 200 只统计200以内的重复的明细行
     */
    List storeIds = new ArrayList<>(storeList);
    int fromIndex = 0;
    while (fromIndex < storeIds.size()) {
      int toIndex = Math.min(fromIndex + 200, storeIds.size());
      List ids = storeIds.subList(fromIndex, toIndex);
      List lines = lineDao.getByStoreList(bufferId, ids);
      Map storeMap = new HashMap<>();
      for (BFreshGoodsAdjStoreLine line : lines) {
        storeMap.put(line.getStoreId(), line);
      }
      allMap.putAll(storeMap);
      fromIndex = toIndex;
    }
    return allMap;
  }
posted @ 2021-04-14 17:17  眼睛会发光ω  阅读(26)  评论(0编辑  收藏  举报