admin
2020-11-30 6e281067fe81dbf180c63a2833f74c1615d32f18
service-lucky/src/main/java/com/ks/lucky/util/LuckyRunUtil.java
@@ -8,24 +8,31 @@
public class LuckyRunUtil {
    private static Set<Long> run(Map<Long, Integer> map, int number) {
    /**
     * 计算开奖的人
     *
     * @param map
     * @param number
     * @return
     */
    public static Set<String> compute(Map<String, Integer> map, int number) {
        List<Long> mList = new ArrayList<>();
        for (Iterator<Long> its = map.keySet().iterator(); its.hasNext(); ) {
            Long uid = its.next();
        List<String> mList = new ArrayList<>();
        for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) {
            String uid = its.next();
            int c = map.get(uid);
            for (int i = 0; i < c; i++) {
                mList.add(uid);
            }
        }
        Set<Long> luckyUids = new HashSet<>();
        Set<String> luckyUids = new HashSet<>();
        for (int i = 0; i < number; i++) {
            if (mList.size() == 0)
                break;
            long startTime = System.currentTimeMillis();
            int p = (int) (mList.size() * Math.random());
            long uid = mList.get(p);
            String uid = mList.get(p);
            luckyUids.add(uid);
            //移除列表右面的相同uid
@@ -35,7 +42,7 @@
            //查询相同uid的列表左侧起点
            for (int j = p - 1; j >= 0; j--) {
                if (mList.get(j).longValue() != uid) {
                if (!mList.get(j).equalsIgnoreCase(uid)) {
                    p = j + 1;
                    break;
                } else if (j == 0) {