|
@@ -86,31 +86,32 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
|
|
|
return winners;
|
|
|
}
|
|
|
- // 从集合中抽取多个学校
|
|
|
- public static List<String> chouclass(List<String> candidates, int numberOfWinners) {
|
|
|
- if (candidates == null || candidates.isEmpty()) {
|
|
|
- throw new IllegalArgumentException("候选列表不能为空");
|
|
|
- }
|
|
|
- if (numberOfWinners <= 0 || numberOfWinners > candidates.size()) {
|
|
|
- throw new IllegalArgumentException("中签人数必须大于0且不超过候选人数");
|
|
|
- }
|
|
|
-
|
|
|
- Random random = new Random();
|
|
|
- Set<Integer> selectedIndices = new HashSet<>(); // 用于存储已选中的索引
|
|
|
- List<String> winners = new ArrayList<>(); // 存储中签者
|
|
|
-
|
|
|
- while (winners.size() < numberOfWinners) {
|
|
|
- int randomIndex = random.nextInt(candidates.size()); // 生成随机索引
|
|
|
- if (selectedIndices.add(randomIndex)) { // 如果索引未被选中过
|
|
|
- winners.add(candidates.get(randomIndex)); // 添加到中签者列表
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return winners;
|
|
|
- }
|
|
|
+// // 从集合中抽取多个班级
|
|
|
+// public static List<String> chouclass(List<String> candidates, int numberOfWinners) {
|
|
|
+// if (candidates == null || candidates.isEmpty()) {
|
|
|
+// throw new IllegalArgumentException("候选列表不能为空");
|
|
|
+// }
|
|
|
+// if (numberOfWinners <= 0 || numberOfWinners > candidates.size()) {
|
|
|
+// throw new IllegalArgumentException("中签人数必须大于0且不超过候选人数");
|
|
|
+// }
|
|
|
+//
|
|
|
+// Random random = new Random();
|
|
|
+// Set<Integer> selectedIndices = new HashSet<>(); // 用于存储已选中的索引
|
|
|
+// List<String> winners = new ArrayList<>(); // 存储中签者
|
|
|
+//
|
|
|
+// while (winners.size() < numberOfWinners) {
|
|
|
+// int randomIndex = random.nextInt(candidates.size()); // 生成随机索引
|
|
|
+// if (selectedIndices.add(randomIndex)) { // 如果索引未被选中过
|
|
|
+// winners.add(candidates.get(randomIndex)); // 添加到中签者列表
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// return winners;
|
|
|
+// }
|
|
|
//学校抽签
|
|
|
@Override
|
|
|
- public List<CqXxxq> cqxx(CqXxxq cqXxxq) {
|
|
|
+ public Map<String,List<CqXxxq>> cqxx(CqXxxq cqXxxq) {
|
|
|
+ Map<String,List<CqXxxq>> CqXxxqlistmap=new HashMap<>();
|
|
|
List<CqXxxq> cqXxList=new ArrayList<>();//被抽签到到学校
|
|
|
List<CqXxxq> cqXxxqList=new ArrayList<>();
|
|
|
List<CqXxxq> cqXxxqLists=new ArrayList<>();//接口抛错使用
|
|
@@ -120,7 +121,7 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
if (cqXxxq.getDistrictname().equals("市直属")) {
|
|
|
cqXxList=cqXxxqMapper.cqxxxqszs(cqXxxq);
|
|
|
if(cqXxList.isEmpty()){
|
|
|
- return cqXxList;
|
|
|
+ CqXxxqlistmap.put("市直属",cqXxList);
|
|
|
// throw new JeecgBootException("没有可抽签的学校!");
|
|
|
}else {
|
|
|
//保存被抽签的学校
|
|
@@ -135,56 +136,53 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
cqYcqxx.setSchoolpopulation(xxxq.getSchoolpopulation());
|
|
|
cqYcqxxMapper.insert(cqYcqxx);
|
|
|
}
|
|
|
- return cqXxList;
|
|
|
+ CqXxxqlistmap.put("市直属",cqXxList);
|
|
|
}
|
|
|
}else {
|
|
|
- //获取当前地市有多少个等级
|
|
|
-// List<String> dengji=cqXxxqMapper.huoqudsxxdj(cqXxxq.getDistrictname());
|
|
|
-// for (String estate : dengji) {
|
|
|
-// cqXxxq.setEstate(estate);
|
|
|
-// }
|
|
|
- //根据县区名称、年级、层次获取符合的学校
|
|
|
- cqXxxqList=cqXxxqMapper.cqxxxq(cqXxxq);
|
|
|
- if(cqXxxqList.isEmpty()){
|
|
|
- return cqXxList;
|
|
|
+ //获取当前地市有多少个等级
|
|
|
+ List<String> dengji = cqXxxqMapper.huoqudsxxdj(cqXxxq.getDistrictname());
|
|
|
+ for (String estate : dengji) {
|
|
|
+ cqXxxq.setEstate(estate);
|
|
|
+ //根据县区名称、年级、层次获取符合的学校
|
|
|
+ cqXxxqList = cqXxxqMapper.cqxxxq(cqXxxq);
|
|
|
+ if (cqXxxqList.isEmpty()) {
|
|
|
+ CqXxxqlistmap.put(estate,cqXxList);
|
|
|
// throw new JeecgBootException("没有可抽签的学校!");
|
|
|
- }else if(cqXxxqList.size()<Integer.parseInt(cqXxxq.getSchooamount())) {
|
|
|
- cqXxxqs.setId("1");
|
|
|
- cqXxxqLists.add(cqXxxqs);
|
|
|
- return cqXxxqLists;
|
|
|
+ } else if (cqXxxqList.size() < Integer.parseInt(cqXxxq.getSchooamount())) {
|
|
|
+ CqXxxqlistmap.put(estate,cqXxxqLists);
|
|
|
// throw new JeecgBootException("可抽签的学数量不能大于以抽签学校数量!");
|
|
|
- }else {
|
|
|
- //检查当前区是否已经抽签
|
|
|
- LambdaQueryWrapper<CqYcqxx> query = new LambdaQueryWrapper<>();
|
|
|
- query.eq(CqYcqxx::getDistrictname, cqXxxq.getDistrictname())
|
|
|
- .eq(CqYcqxx::getEstate, cqXxxq.getEstate());
|
|
|
- Long count = cqYcqxxMapper.selectCount(query);
|
|
|
- if (Integer.parseInt(count+"") >0) {
|
|
|
- cqXxxqs.setId("2");
|
|
|
- cqXxxqLists.add(cqXxxqs);
|
|
|
- return cqXxxqLists;
|
|
|
+ } else {
|
|
|
+ //检查当前区是否已经抽签
|
|
|
+ LambdaQueryWrapper<CqYcqxx> query = new LambdaQueryWrapper<>();
|
|
|
+ query.eq(CqYcqxx::getDistrictname, cqXxxq.getDistrictname())
|
|
|
+ .eq(CqYcqxx::getEstate, cqXxxq.getEstate());
|
|
|
+ Long count = cqYcqxxMapper.selectCount(query);
|
|
|
+ if (Integer.parseInt(count + "") > 0) {
|
|
|
+ CqXxxqlistmap.put(estate,cqXxxqLists);
|
|
|
// throw new JeecgBootException("该区当前等级已经有抽签记录无法重复抽签!");
|
|
|
- }else if(Integer.parseInt(count+"") ==0){
|
|
|
- cqXxList=chouschool(cqXxxqList, Integer.parseInt(cqXxxq.getSchooamount()));
|
|
|
- //保存被抽签的学校
|
|
|
- for (CqXxxq xxxq : cqXxList) {
|
|
|
- cqYcqxx.setId(null);
|
|
|
- cqYcqxx.setDistrictname(xxxq.getDistrictname());
|
|
|
- cqYcqxx.setSchoolname(xxxq.getSchoolname());
|
|
|
- cqYcqxx.setSchoolcode(xxxq.getSchoolcode());
|
|
|
- cqYcqxx.setClasscode(xxxq.getClasscode());
|
|
|
- cqYcqxx.setNianji(xxxq.getNianji());
|
|
|
- cqYcqxx.setEstate(xxxq.getEstate());
|
|
|
- //获取抽签学校的考生数
|
|
|
- cqYcqxx.setSchoolpopulation(xxxq.getSchoolpopulation());
|
|
|
- cqYcqxxMapper.insert(cqYcqxx);
|
|
|
+ } else if (Integer.parseInt(count + "") == 0) {
|
|
|
+ cqXxList = chouschool(cqXxxqList, Integer.parseInt(cqXxxq.getSchooamount()));
|
|
|
+ //保存被抽签的学校
|
|
|
+ for (CqXxxq xxxq : cqXxList) {
|
|
|
+ cqYcqxx.setId(null);
|
|
|
+ cqYcqxx.setDistrictname(xxxq.getDistrictname());
|
|
|
+ cqYcqxx.setSchoolname(xxxq.getSchoolname());
|
|
|
+ cqYcqxx.setSchoolcode(xxxq.getSchoolcode());
|
|
|
+ cqYcqxx.setClasscode(xxxq.getClasscode());
|
|
|
+ cqYcqxx.setNianji(xxxq.getNianji());
|
|
|
+ cqYcqxx.setEstate(xxxq.getEstate());
|
|
|
+ //获取抽签学校的考生数
|
|
|
+ cqYcqxx.setSchoolpopulation(xxxq.getSchoolpopulation());
|
|
|
+ cqYcqxxMapper.insert(cqYcqxx);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ System.out.println("异常");
|
|
|
}
|
|
|
- }else {
|
|
|
- System.out.println("异常");
|
|
|
+ CqXxxqlistmap.put(estate,cqXxList);
|
|
|
}
|
|
|
- return cqXxList;
|
|
|
}
|
|
|
}
|
|
|
+ return CqXxxqlistmap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -278,7 +276,6 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
LambdaQueryWrapper<CqCqbjxx> query1 = new LambdaQueryWrapper<>();
|
|
|
query1.eq(CqCqbjxx::getDistrictname, cqXxxq.getDistrictname());
|
|
|
CqCqbjxx cqCqbjxx=cqCqbjxxMapper.selectOne(query1);
|
|
|
- System.out.println("----------------------");
|
|
|
int studentamount = 45;//抽取人数
|
|
|
//判断是否是市直属学校
|
|
|
if (cqXxxq.getDistrictname().equals("市直属")) {
|
|
@@ -297,6 +294,7 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
List<String> dengji=cqXxxqMapper.huoqudsxxdj(cqXxxq.getDistrictname());
|
|
|
for (String estate : dengji) {
|
|
|
cqXxxq.setEstate(estate);
|
|
|
+ System.out.println("显示cqXxxq:"+cqXxxq);
|
|
|
//获取需要抽签的学校
|
|
|
LambdaQueryWrapper<CqYcqxx> query = new LambdaQueryWrapper<>();
|
|
|
query.eq(CqYcqxx::getDistrictname, cqXxxq.getDistrictname())
|
|
@@ -308,7 +306,6 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
for (CqYcqxx cqYcqxx : cqYcqxxList) {
|
|
|
//调用抽班级方法
|
|
|
rycqsjsbj(cqYcqxx,cqCqbjxx,studentamount);
|
|
|
- System.out.println(cqYcqxx);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -320,6 +317,8 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
List<CqCqks> cqCqksList=new ArrayList<>();//学校抽取考生集合
|
|
|
int remainder = 0;//随机数取余的值
|
|
|
String banji="";//班级
|
|
|
+ System.out.println("cqYcqxx详情:"+cqYcqxx);
|
|
|
+ System.out.println("班级随机数:"+cqCqbjxx.getBz());
|
|
|
if(cqYcqxx.getSchoolpopulation()>45){
|
|
|
System.out.println("够45人开始从班级里抽取人员");
|
|
|
//判断抽到的班级是否够45人
|
|
@@ -334,7 +333,7 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
//小于则随机数除以班级数量取余获取抽到的班级
|
|
|
remainder=Integer.parseInt(cqCqbjxx.getBz())%Integer.parseInt(cqYcqxx.getClasscode());
|
|
|
if (remainder==0){
|
|
|
- remainder=remainder+1;
|
|
|
+ remainder=Integer.parseInt(cqYcqxx.getClasscode());
|
|
|
}
|
|
|
banji=cqYcqxx.getNianji()+convertNumberToChinese(remainder)+"班";
|
|
|
System.out.println("banji2:"+banji);
|
|
@@ -380,8 +379,8 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
System.out.println("大于45,随机抽人");
|
|
|
//班级人数大于抽签人数时随机抽取考试人员
|
|
|
cqKsxxListcz= choustudent(cqKsxxList,studentamount);
|
|
|
- System.out.println(cqKsxxListcz);
|
|
|
- System.out.println(cqKsxxListcz.size());
|
|
|
+// System.out.println(cqKsxxListcz);
|
|
|
+// System.out.println(cqKsxxListcz.size());
|
|
|
cqCqksList=this.cqbanji(cqKsxxListcz);
|
|
|
for (CqCqks cqCqks : cqCqksList) {
|
|
|
cqCqks.setId(null);
|
|
@@ -591,27 +590,31 @@ public class CqXxxqServiceImpl extends ServiceImpl<CqXxxqMapper, CqXxxq> impleme
|
|
|
//学校人数不够是补充别的学校里的人
|
|
|
public boolean bcxxbanjiry(String districtname,String estate,int studentamount) {
|
|
|
int chouqurenshu=0;
|
|
|
+ int schoolcode=0;
|
|
|
//获取需要补足的学校
|
|
|
- List<CqYcqxx> cqycqxx= cqYcqxxMapper.chabzrsxx(districtname,estate,studentamount);
|
|
|
+ List<CqYcqxx> cqYcqxxList= cqYcqxxMapper.chabzrsxx(districtname,estate,studentamount);
|
|
|
System.out.println("显示不够抽签人数的学校");
|
|
|
- System.out.println(cqycqxx);
|
|
|
- System.out.println(cqycqxx.size());
|
|
|
- for (CqYcqxx cqYcqxx : cqycqxx) {
|
|
|
+ System.out.println(cqYcqxxList);
|
|
|
+ System.out.println(cqYcqxxList.size());
|
|
|
+ for (CqYcqxx cqYcqxx : cqYcqxxList) {
|
|
|
chouqurenshu=studentamount-cqYcqxx.getSchoolpopulation();
|
|
|
- //获取的学校剩余班级人数需要大于需抽签人数
|
|
|
- List<CqYcqxx> cqycqxxbc= cqYcqxxMapper.chabzrsxxbz(districtname,estate,studentamount,cqYcqxx.getSchoolname());
|
|
|
- //获取能够补足的学校
|
|
|
- System.out.println("cqycqxxbc"+cqycqxxbc);
|
|
|
- //学校剩余班级人数是否够抽取的
|
|
|
- for (CqYcqxx cqYcqxxbc : cqycqxxbc) {
|
|
|
- System.out.println(chouqurenshu);
|
|
|
- //判断剩余人数是否狗
|
|
|
- if(cqKsxxMapper.chaclassrs(cqYcqxxbc.getSchoolname())>chouqurenshu){
|
|
|
- System.out.println("执行");
|
|
|
-// this.cqbanjibxx(cqYcqxxbc,cqYcqxxbc.getSchoolname(),chouqurenshu);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ //获取当前学校序号,去他邻近的下一所学校去补人
|
|
|
+// schoolcode=Integer.parseInt(cqYcqxx.getSchoolcode());
|
|
|
+
|
|
|
+// //获取的学校剩余班级人数需要大于需抽签人数
|
|
|
+// List<CqYcqxx> cqycqxxbc= cqYcqxxMapper.chabzrsxxbz(districtname,estate,studentamount,cqYcqxx.getSchoolname());
|
|
|
+// //获取能够补足的学校
|
|
|
+// System.out.println("cqycqxxbc"+cqycqxxbc);
|
|
|
+// //学校剩余班级人数是否够抽取的
|
|
|
+// for (CqYcqxx cqYcqxxbc : cqycqxxbc) {
|
|
|
+// System.out.println(chouqurenshu);
|
|
|
+// //判断剩余人数是否狗
|
|
|
+// if(cqKsxxMapper.chaclassrs(cqYcqxxbc.getSchoolname())>chouqurenshu){
|
|
|
+// System.out.println("执行");
|
|
|
+//// this.cqbanjibxx(cqYcqxxbc,cqYcqxxbc.getSchoolname(),chouqurenshu);
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
return true;
|
|
|
}
|