dev_1.0.1
luotaiqian 2026-07-16 15:42:53 +08:00
parent 02e36b1f79
commit ea3b3465c1
1 changed files with 0 additions and 29 deletions

View File

@ -494,33 +494,4 @@ public class ComplianceCheckUtil {
} }
return assignedMap; return assignedMap;
} }
// 简单测试
public static void main(String[] args) {
Map<Long, Set<String>> personMap = new HashMap<>();
personMap.put(1L, new HashSet<>(Arrays.asList("A", "B")));
personMap.put(2L, new HashSet<>(Arrays.asList("A", "B")));
personMap.put(3L, new HashSet<>(Arrays.asList("A")));
personMap.put(4L, new HashSet<>(Arrays.asList("B")));
personMap.put(5L, new HashSet<>(Arrays.asList("A")));
// 场景1: A需2人, B需2人 → 可满足 (5人中A能力4人, B能力3人, 一人一岗后可分2+2=4)
Map<String, Long> required1 = new HashMap<>();
required1.put("A", 2L);
required1.put("B", 2L);
Map<String, Long> assigned1 = canFullyAssign(personMap, required1);
System.out.println("场景1 分配结果: " + assigned1);
System.out.println("场景1 是否满足: " + required1.entrySet().stream()
.allMatch(e -> assigned1.getOrDefault(e.getKey(), 0L) >= e.getValue()));
// 场景2: A需3人, B需2人 → 不可满足 (一人一岗最多用5人, 但A只有4人能干, 且B占走部分人后A不够)
Map<String, Long> required2 = new HashMap<>();
required2.put("A", 3L);
required2.put("B", 2L);
Map<String, Long> assigned2 = canFullyAssign(personMap, required2);
System.out.println("场景2 分配结果: " + assigned2);
System.out.println("场景2 是否满足: " + required2.entrySet().stream()
.allMatch(e -> assigned2.getOrDefault(e.getKey(), 0L) >= e.getValue()));
}
} }