蛇形平均分配委案,按比例分配委案记录

package com.svtech.icbc.report.service.dividecase;

import com.svtech.icbc.report.entity.original.RptOfCaseOriginal;
import com.svtech.icbc.report.vo.changecase.Teller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**

  • Created with IntelliJ IDEA.

  • @Auther: ZZJ

  • @Date: 2020/09/09/11:08

  • @Description:
    */
    @Slf4j
    @Service
    public class DivisionService {

    //按比分配
    public static List divideCaseByPercent(List tellers, List cases){
    int index=0;//定义下标
    List divisionResult=new ArrayList();//分案结果
    while (cases.size()!=0){//只要案件没分完就一直循环
    if (index>tellers.size()-1){//当分完一轮后,重置下标,用户顺序翻转
    index=0;
    Collections.reverse(tellers);
    }else {
    int count=tellers.get(index).getSplitCount();
    int size=tellers.get(index).getCases().size();
    if (count<=size){//判断用户所能分配的数目是否达到最大值,如果不可分,将该用户移除
    divisionResult.add(tellers.get(index));
    tellers.remove(index);
    if (tellers.size()==1){//如果只剩最后一个用户则将剩余案件全部分给这个人
    divisionResult.addAll(tellers);
    }else {//否则向下递归寻找可分配的人
    divisionResult.addAll(divideCaseByPercent(tellers,cases));
    }

             }else {//当前用户可分案件未达到最大值则直接分配,并将案件从列表中移除,游标下移
                 tellers.get(index).getCases().add(cases.get(0));
                 index++;
                 cases.remove(0);
             }
    
         }
    
     }
     return divisionResult;
    

    }
    //平均分配
    public static List divideCase( List tellers,List cases){
    int index=0;
    while (cases.size()!=0){
    if (index>tellers.size()-1){
    index=0;
    Collections.reverse(tellers);
    }else {
    tellers.get(index).getCases().add(cases.get(0));
    index++;
    cases.remove(0);
    }

     }
     return tellers;
    

    }
    }

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值