admin
10 天以前 f318c9c7c127b00f353bf45f273096d1dc4b424f
src/main/java/com/taoke/autopay/service/impl/js2/OrderTaskServiceImpl.java
@@ -58,7 +58,7 @@
            throw new OrderTaskException(OrderTaskException.CODE_COMMON, "下单任务需求下单数量不能为空");
        }
        if(orderTask.getReceiveCycleHours()==null){
        if(orderTask.getReceiveCycleMinutes()==null){
            throw new OrderTaskException(OrderTaskException.CODE_COMMON, "下单任务收货周期不能为空");
        }
@@ -95,7 +95,15 @@
        }
        return orderTaskMapper.selectByPrimaryKey(id);
    }
    @Override
    public List<OrderTask> getOrderTaskByIds(List<Long> ids) {
        if(ids==null||ids.isEmpty()){
            return new ArrayList<>();
        }
       return  orderTaskMapper.listByIds(ids);
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public OrderTask getOrderTaskByIdForUpdate(Long id) {
@@ -203,13 +211,18 @@
            }
        }
        // 统计所有设备正在执行任务的数量
        List<ClientCountDTO> clientCountList =   orderTaskExecutionDetailMapper.statisticClientIdsCountByStatus(Arrays.asList( new Integer[]{OrderTaskExecutionDetail.STATUS_NOT_ORDERED}));
        Map<Long,  Integer> clientCountMap = new HashMap<>();
        for(ClientCountDTO dto:clientCountList){
            clientCountMap.put(dto.getClientId(), dto.getCount());
        }
        // 剔除已经存在2个任务以上的设备
        for(int i=0;i<clientInfoList.size();i++){
            if(clientCountMap.containsKey(clientInfoList.get(i).getId())&&clientCountMap.get(clientInfoList.get(i).getId())>=2){
                clientInfoList.remove(i);
                i--;
            }
        }
        clientInfoList.sort(new Comparator<ClientInfo>() {
            @Override