Administrator
2025-02-20 06ed77d317b8012ea0389cfd1405db9a425c0c7d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.taoke.autopay.utils;
 
import com.taoke.autopay.entity.OrderDistributeCountInfo;
 
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
 
/**
 * @author hxh
 * @title: ClientDistributeUtil
 * @description: TODO
 * @date 2024/8/8 23:36
 */
public class ClientDistributeUtil {
 
    public static Long computeDistributeClient(List<OrderDistributeCountInfo> infoList){
        if(infoList.size()<1){
            return null;
        }
        infoList.sort(new Comparator<OrderDistributeCountInfo>() {
            @Override
            public int compare(OrderDistributeCountInfo o1,OrderDistributeCountInfo o2) {
                return (int)(o1.getCount()-o2.getCount());
            }
        });
        if(infoList.size()>1) {
            for (int i = 1; i < infoList.size(); i++) {
                if (infoList.get(i).getCount() != infoList.get(i - 1).getCount()) {
                    infoList = infoList.subList(0, i);
                    break;
                }
            }
        }
        Collections.shuffle(infoList);
        return infoList.get(0).getUid();
 
    }
}