List<String> leadIdList = new ArrayList<>();
int i = 0;
while (i < 417) {
leadIdList.add(String.valueOf(i));
i++;
}
List<Student> students = new ArrayList<>();
Student stu = new Student();
stu.setName("33");
stu.setSex("A");
students.add(stu);
Student stu1 = new Student();
stu1.setName("52");
stu1.setSex("B");
students.add(stu1);
Student stu2 = new Student();
stu2.setName("15");
stu2.setSex("C");
students.add(stu2);
int indexStart = 0;
Map<String, List<String>> poolLeadIdMap = new HashMap<>(3);
for (Student item : students) {
double percent = Double.parseDouble(item.getName());
int length = (int) Math.round(leadIdList.size() * percent / 100);
List<String> leadIdIndexList = new ArrayList<>();
if (leadIdList.size() - indexStart <= length) {
length = length + (leadIdList.size() - indexStart - length);
}
int j = 0;
while (j < length) {
leadIdIndexList.add(leadIdList.get(indexStart + j));
j++;
}
indexStart += length;
poolLeadIdMap.put(item.getSex(), leadIdIndexList);
}
百分比相乘后四舍五入之和相加 超过总数方法
最新推荐文章于 2022-11-24 20:59:55 发布