|
|
package com.dsideal.newUniversityExamination.selectcourse.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dsideal.newUniversityExamination.selectcourse.core.util.Common;
|
|
|
import com.dsideal.newUniversityExamination.selectcourse.model.CoreCourseModel;
|
|
|
import com.dsideal.newUniversityExamination.selectcourse.model.SelectCoursePlanModel;
|
|
|
import com.dsideal.newUniversityExamination.selectcourse.model.StudentApplyModel;
|
|
|
import com.dsideal.newUniversityExamination.selectcourse.util.CoreUtil;
|
|
|
import com.dsideal.newUniversityExamination.selectcourse.util.SelectCourseUtil;
|
|
|
import com.dsideal.newUniversityExamination.util.COMMON;
|
|
|
import com.dsideal.newUniversityExamination.util.Constant;
|
|
|
import com.dsideal.newUniversityExamination.util.ToolsUtil;
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
public class StudentSelectCourseService {
|
|
|
public static final StudentSelectCourseService service = new StudentSelectCourseService();
|
|
|
|
|
|
public JSONObject getStudentSelectCourseInfo(String personId,String identityId) {
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
/*获取学生详细信息*/
|
|
|
JSONObject personInfo = SelectCourseUtil.getPersonInfo(personId,identityId);
|
|
|
// 获取学校的选科计划,一个班级同时开启的选科计划只能有一个
|
|
|
JSONObject tableList = JSONObject.parseObject(String.valueOf(personInfo.get("table_List")));
|
|
|
String classId = String.valueOf(tableList.get("class_id"));
|
|
|
List<Record> planList = SelectCoursePlanModel.dao.getPlanListByClassIdAndStatus(classId, "2","");
|
|
|
if(COMMON.isEmpty(planList)){
|
|
|
returnJson.put("success", false);
|
|
|
returnJson.put("info", "所在班级不存在选科计划");
|
|
|
return returnJson ;
|
|
|
}
|
|
|
/*获取计划的详情*/
|
|
|
Record classRecord = planList.get(0);
|
|
|
String start_time = String.valueOf(classRecord.get("start_time"));
|
|
|
String end_time = String.valueOf(classRecord.get("end_time"));
|
|
|
String planId = String.valueOf(classRecord.get("plan_id"));
|
|
|
String planName = String.valueOf(classRecord.get("plan_name"));
|
|
|
personInfo.put("start_time", start_time.substring(0,start_time.length()-2));
|
|
|
personInfo.put("end_time", end_time.substring(0,end_time.length()-2));
|
|
|
personInfo.put("plan_id", planId);
|
|
|
personInfo.put("plan_name", planName);
|
|
|
|
|
|
//获取plan信息
|
|
|
JSONObject planDetailJSON = SelectCoursePlanService.service.getPlanInfo(planId);
|
|
|
String testId=planDetailJSON.getString("test_id");
|
|
|
//推荐数组
|
|
|
JSONArray arr = getZyghReport(personId, identityId, personInfo, testId);
|
|
|
personInfo.put("ad_list", arr);
|
|
|
|
|
|
// 查询所有科目及学生选科情况
|
|
|
JSONObject studentSelectCourse = getStudentSelectCourseInfo(planId, personId, identityId,planDetailJSON);
|
|
|
if(studentSelectCourse.getBooleanValue("flag")){
|
|
|
personInfo.put("xk_flag", "已选");
|
|
|
}else{
|
|
|
personInfo.put("xk_flag", "未选");
|
|
|
}
|
|
|
personInfo.put("student_select_course", studentSelectCourse);
|
|
|
personInfo.put("success", true);
|
|
|
personInfo.put("info", "存在选科计划");
|
|
|
return personInfo ;
|
|
|
}
|
|
|
|
|
|
public JSONArray getZyghReport(String personId,String identityId,JSONObject personInfo,String testId){
|
|
|
//推荐数组
|
|
|
JSONArray arr = new JSONArray();
|
|
|
// 职业兴趣组合
|
|
|
Record report = SelectCourseUtil.getReport(personId, identityId);
|
|
|
personInfo.put("zyxq_subjecta", report.get("zyxq_name"));
|
|
|
JSONObject obZyxq = new JSONObject();
|
|
|
obZyxq.put("subject", report.get("zyxq_name"));
|
|
|
obZyxq.put("name", "职业兴趣组合");
|
|
|
obZyxq.put("subjectId", report.get("zyxq_id"));
|
|
|
//组装学生对象,获取成绩信息,获取排名
|
|
|
String pm = CoreUtil.getStudentPmInfo(testId,personId,String.valueOf(report.get("zyxq_id")));
|
|
|
obZyxq.put("pm", pm);
|
|
|
|
|
|
// 学科潜能组合
|
|
|
personInfo.put("xkqn_subjecta", report.get("xkqn_name"));
|
|
|
personInfo.put("xkqn_id", report.get("xkqn_id"));
|
|
|
JSONObject obXkqn = new JSONObject();
|
|
|
obXkqn.put("subject", report.get("xkqn_name"));
|
|
|
obXkqn.put("subjectId", report.get("xkqn_id"));
|
|
|
obXkqn.put("name", "学科潜能组合");
|
|
|
pm = CoreUtil.getStudentPmInfo(testId,personId,String.valueOf(report.get("xkqn_id")));
|
|
|
obXkqn.put("pm", pm);
|
|
|
|
|
|
// 成绩优势组合,暂无
|
|
|
JSONObject cjXkqn = new JSONObject();
|
|
|
personInfo.put("cjys_subjecta", report.get("cjys_name"));
|
|
|
cjXkqn.put("subject", report.get("cjys_name"));
|
|
|
cjXkqn.put("subjectId", report.get("cjys_id"));
|
|
|
cjXkqn.put("name", "成绩优势组合");
|
|
|
pm = CoreUtil.getStudentPmInfo(testId,personId,String.valueOf(report.get("cjys_id")));
|
|
|
cjXkqn.put("pm", pm);
|
|
|
arr.add(cjXkqn);
|
|
|
arr.add(obZyxq);
|
|
|
arr.add(obXkqn);
|
|
|
return arr ;
|
|
|
}
|
|
|
/*志愿填报详情*/
|
|
|
public JSONObject getStudentSelectCourseInfo(String planId,String personId, String identityId,JSONObject planDetailJSON) {
|
|
|
JSONObject ob = new JSONObject();
|
|
|
/*获取学生志愿*/
|
|
|
List<Record> recordList = StudentApplyModel.dao.getStudengApply(planId, personId,"");
|
|
|
String firstSubject = "";
|
|
|
String secondSubject = "";
|
|
|
if( !COMMON.isEmpty(recordList)){
|
|
|
for (int i = 0; i < recordList.size(); i++) {
|
|
|
Record record = recordList.get(i);
|
|
|
String level = String.valueOf(record.get("level"));
|
|
|
if ("1".equals(level)) {
|
|
|
firstSubject = String.valueOf(record.get("subjects"));
|
|
|
record.set("firstSubject", firstSubject );
|
|
|
}
|
|
|
if ("2".equals(level)) {
|
|
|
secondSubject = String.valueOf(record.get("subjects"));
|
|
|
record.set("secondSubject",secondSubject);
|
|
|
}
|
|
|
}
|
|
|
ob.put("flag", true);
|
|
|
}else{
|
|
|
ob.put("flag", false);
|
|
|
}
|
|
|
String subjectType = String.valueOf(planDetailJSON.get("subject_type"));
|
|
|
String subjects = String.valueOf(planDetailJSON.get("subjects"));
|
|
|
|
|
|
ob.put("subjectType", subjectType);
|
|
|
ob.put("subjects", subjects);
|
|
|
Map<String, String> map = Constant.getThreeSubjectMap();
|
|
|
JSONArray subjectList = new JSONArray();
|
|
|
int buse = 0;
|
|
|
//不是单科,是套餐模式和3+1+2模式
|
|
|
if(!COMMON.isEmpty(subjects)&&!"0".equals(subjectType)){
|
|
|
//如果是 套餐模式 第一志愿和第二志愿 不在套餐范围内
|
|
|
boolean flag = ob.getBooleanValue("flag");
|
|
|
if(flag){
|
|
|
if(!ToolsUtil.arrayIncludeStr(subjects, firstSubject)||!ToolsUtil.arrayIncludeStr(subjects, secondSubject)){
|
|
|
buse = 1 ;
|
|
|
}
|
|
|
}
|
|
|
String[] str = subjects.split(",");
|
|
|
for(int i=0;i<str.length;i++){
|
|
|
JSONObject subject = new JSONObject();
|
|
|
String subjectName = map.get(str[i]);
|
|
|
subject.put("subjectName", subjectName);
|
|
|
subject.put("subjectId", str[i]);
|
|
|
subjectList.add(subject);
|
|
|
}
|
|
|
}
|
|
|
ob.put("b_use", buse);
|
|
|
ob.put("subjectList", subjectList);
|
|
|
ob.put("selectCourse", COMMON.convertListRecord2(recordList));
|
|
|
return ob;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Description: 保存学生志愿
|
|
|
* @author :周明升
|
|
|
* @date: 2018-12-25 上午9:29:46
|
|
|
* @return: boolean
|
|
|
* @throws
|
|
|
*/
|
|
|
public JSONObject saveStudentSelectCourse(String applyIdFirst,
|
|
|
String applyIdSecond, String subjectFirst, String subjectSecond,
|
|
|
String personId, String identityId, String planId) {
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
returnJson.put("success", false);
|
|
|
returnJson.put("info", "操作失败");
|
|
|
//验证计划是否结束
|
|
|
Record plan = SelectCoursePlanModel.dao.getPlanInfo(planId);
|
|
|
/*计划不存在*/
|
|
|
if(COMMON.isEmpty(plan)){
|
|
|
return returnJson ;
|
|
|
}
|
|
|
/*计划是否在进行中*/
|
|
|
String status = String.valueOf(plan.get("status"));
|
|
|
if(!"2".equals(status)){
|
|
|
return returnJson ;
|
|
|
}
|
|
|
boolean flag1 = false;
|
|
|
boolean flag2 = false;
|
|
|
if("000000".equals(subjectFirst)&&"000000".equals(subjectSecond)){
|
|
|
if(!COMMON.isEmpty(applyIdFirst)&&!COMMON.isEmpty(applyIdSecond)){
|
|
|
StudentApplyModel.dao.delCourseApply(applyIdFirst);
|
|
|
StudentApplyModel.dao.delCourseApply(applyIdSecond);
|
|
|
returnJson.put("success", true);
|
|
|
returnJson.put("info", "操作成功");
|
|
|
return returnJson;
|
|
|
}
|
|
|
}else{
|
|
|
String physics1 = subjectFirst.substring(0, 1);
|
|
|
String chemistry1 = subjectFirst.substring(1, 2);
|
|
|
String biology1 = subjectFirst.substring(2, 3);
|
|
|
String politics1 = subjectFirst.substring(3, 4);
|
|
|
String history1 = subjectFirst.substring(4, 5);
|
|
|
String geography1 = subjectFirst.substring(5, 6);
|
|
|
Record record1 = new Record();
|
|
|
record1.set("person_id", personId);
|
|
|
record1.set("identity_id", identityId);
|
|
|
record1.set("plan_id", planId);
|
|
|
record1.set("physics", physics1);
|
|
|
record1.set("chemistry", chemistry1);
|
|
|
record1.set("biology", biology1);
|
|
|
record1.set("politics", politics1);
|
|
|
record1.set("history", history1);
|
|
|
record1.set("geography", geography1);
|
|
|
record1.set("level", 1);
|
|
|
String physics2 = subjectSecond.substring(0, 1);
|
|
|
String chemistry2 = subjectSecond.substring(1, 2);
|
|
|
String biology2 = subjectSecond.substring(2, 3);
|
|
|
String politics2 = subjectSecond.substring(3, 4);
|
|
|
String history2 = subjectSecond.substring(4, 5);
|
|
|
String geography2 = subjectSecond.substring(5, 6);
|
|
|
Record record2 = new Record();
|
|
|
record2.set("person_id", personId);
|
|
|
record2.set("identity_id", identityId);
|
|
|
record2.set("plan_id", planId);
|
|
|
record2.set("physics", physics2);
|
|
|
record2.set("chemistry", chemistry2);
|
|
|
record2.set("biology", biology2);
|
|
|
record2.set("politics", politics2);
|
|
|
record2.set("history", history2);
|
|
|
record2.set("geography", geography2);
|
|
|
record2.set("level", 2);
|
|
|
/*学生志愿删除 ->学生志愿保存*/
|
|
|
StudentApplyModel.dao.delCourseApply(planId, personId, "");
|
|
|
flag1 = StudentApplyModel.dao.saveCourseApply(record1);
|
|
|
flag2 =StudentApplyModel.dao.saveCourseApply(record2);
|
|
|
}
|
|
|
if(flag1 && flag2){
|
|
|
returnJson.put("success", true);
|
|
|
returnJson.put("info", "操作成功");
|
|
|
}
|
|
|
return returnJson;
|
|
|
}
|
|
|
/**
|
|
|
* @Description: 获取班级
|
|
|
* @author :周明升
|
|
|
* @date: 2018-12-25 上午9:41:16
|
|
|
* @return: String
|
|
|
* @throws
|
|
|
*/
|
|
|
public JSONObject getStudentJxClassList(int pageSize, int pageNumber,
|
|
|
String planId, String calculateType,String groupId) {
|
|
|
Page<Record> pageRecord= SelectCoursePlanModel.dao.getResultClassList(planId, "", "", "0", "", "1", "0", "","0,1", "",groupId,"0","",999,1);
|
|
|
List<Record> records = pageRecord.getList();
|
|
|
String resultId = "";
|
|
|
for(Record recordClass:records){
|
|
|
resultId = String.valueOf(recordClass.get("result_id"));
|
|
|
}
|
|
|
/*未成班*/
|
|
|
if(records.size()<pageSize){
|
|
|
Record notInClass = addNoInClassStudent(resultId,calculateType);
|
|
|
if(!COMMON.isEmpty(notInClass)){
|
|
|
records.add(notInClass);
|
|
|
}
|
|
|
}
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
addReturnJsonIsExistFc(records, resultJson);
|
|
|
if("2".equals(calculateType)){
|
|
|
resultJson.put("isExistFc",false);
|
|
|
}
|
|
|
resultJson.put("curriculumPlanList", COMMON.convertListRecord2(records));
|
|
|
resultJson.put("pageNumber", pageRecord.getPageNumber());
|
|
|
resultJson.put("pageSize", pageRecord.getPageSize());
|
|
|
resultJson.put("totalPage", pageRecord.getTotalPage());
|
|
|
resultJson.put("totalRow", pageRecord.getTotalRow());
|
|
|
resultJson.put("success", true);
|
|
|
resultJson.put("info", "查询成功");
|
|
|
return resultJson;
|
|
|
}
|
|
|
private void addReturnJsonIsExistFc(List<Record> list,JSONObject returnJson){
|
|
|
String testId = "";
|
|
|
for(Record recordClass:list){
|
|
|
testId = String.valueOf(recordClass.get("test_id"));
|
|
|
break;
|
|
|
}
|
|
|
if(!"null".equals(testId)&&!"0".equals(testId)){
|
|
|
returnJson.put("isExistFc", true);
|
|
|
}else{
|
|
|
returnJson.put("isExistFc", false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*获取 算法分出来的班级的学生详情*/
|
|
|
public JSONObject getStudentJxStudentList(String pageSize, String pageNumber,
|
|
|
String classId,String planId,String resultId,String calculateType) {
|
|
|
Record planTest= SelectCoursePlanModel.dao.getPlanInfo(planId);
|
|
|
String testId= String.valueOf(planTest.get("test_id"));
|
|
|
|
|
|
//获取的是未成班学生信息
|
|
|
Page<Record> pageRecord = null;
|
|
|
if(COMMON.isEmpty(classId) ){
|
|
|
pageRecord = SelectCoursePlanModel.dao.getNotClassStudentList(resultId, planId, pageSize, pageNumber);
|
|
|
}else{
|
|
|
pageRecord = SelectCoursePlanModel.dao.getResultClassStudentList(planId, "", resultId, "", "", "", "0", classId, "","", "","0",pageSize, pageNumber);
|
|
|
}
|
|
|
List<Record> records = pageRecord.getList();
|
|
|
|
|
|
//查询当前页学生成绩数据
|
|
|
// **************************************
|
|
|
addPmToStudentlist(records, planId, testId);
|
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
resultJson.put("curriculumPlanList", COMMON.convertListRecord2(records));
|
|
|
resultJson.put("pageNumber", pageRecord.getPageNumber());
|
|
|
resultJson.put("pageSize", pageRecord.getPageSize());
|
|
|
resultJson.put("totalPage", pageRecord.getTotalPage());
|
|
|
resultJson.put("totalRow", pageRecord.getTotalRow());
|
|
|
resultJson.put("success", true);
|
|
|
resultJson.put("info", "查询成功");
|
|
|
return resultJson;
|
|
|
}
|
|
|
public void addPmToStudentlist(List<Record> records,String planId,String testId){
|
|
|
//获取一二志愿排名
|
|
|
List<Record> studentRecord = new ArrayList<>();
|
|
|
//教学班json
|
|
|
JSONArray arrJx = new JSONArray();
|
|
|
for(Record recordStudent:records){
|
|
|
recordStudent.set("calculate_type", String.valueOf(recordStudent.get("calculate_type")));
|
|
|
Record recordStudnet = new Record();
|
|
|
String personId = String.valueOf(recordStudent.get("person_id"));
|
|
|
//查询学生是否选科 获取学生第一志愿、第二志愿
|
|
|
JSONObject studentApply = CoreUtil.getStudentApply(planId, personId);
|
|
|
boolean statusDesc = studentApply.getBooleanValue("is_exist");
|
|
|
if(statusDesc){
|
|
|
recordStudent.set("status", 0);
|
|
|
recordStudent.set("statusDesc", "已选择");
|
|
|
}else{
|
|
|
recordStudent.set("status", 1);
|
|
|
recordStudent.set("statusDesc", "未选择");
|
|
|
}
|
|
|
//查询学生一二志愿选择学科
|
|
|
recordStudent.set("firstSubject", studentApply.get("firstSubject"));
|
|
|
recordStudent.set("sedSubject",studentApply.get("sedSubject") );
|
|
|
recordStudent.set("firstSubjectId",studentApply.get("firstSubjectId") );
|
|
|
recordStudent.set("sedSubjectId", studentApply.get("sedSubjectId"));
|
|
|
String firstSubjectId = String.valueOf(studentApply.get("firstSubjectId")).replaceAll("\\|", ",");
|
|
|
String sedSubjectId = String.valueOf(studentApply.get("sedSubjectId")).replaceAll("\\|", ",");
|
|
|
recordStudnet.set("studentId", personId);
|
|
|
recordStudnet.set("testId", testId);
|
|
|
JSONArray arrSubjects = new JSONArray();
|
|
|
arrSubjects.add(firstSubjectId);
|
|
|
arrSubjects.add(sedSubjectId);
|
|
|
recordStudnet.set("subjects", arrSubjects);
|
|
|
studentRecord.add(recordStudnet);
|
|
|
|
|
|
|
|
|
//填充获取教学班排名信息
|
|
|
JSONObject studentOb = new JSONObject();
|
|
|
studentOb.put("studentId", personId);
|
|
|
studentOb.put("testId", testId);
|
|
|
JSONArray arrSubject = new JSONArray();
|
|
|
arrSubject.add(firstSubjectId);
|
|
|
studentOb.put("subjects", arrSubject);
|
|
|
arrJx.add(studentOb);
|
|
|
|
|
|
}
|
|
|
JSONObject xyy = new JSONObject();
|
|
|
xyy.put("studentList", arrJx);
|
|
|
|
|
|
//获取排名map
|
|
|
Map<String,String> studentJxClassPmMap = new HashMap<>();
|
|
|
JSONObject jsonJxStudentPm = SelectCourseUtil.getStudentsPm(JSONObject.toJSONString(xyy));
|
|
|
if(jsonJxStudentPm.getBoolean("success")){
|
|
|
JSONArray studentPmArr = (JSONArray)jsonJxStudentPm.get("studentsPm");
|
|
|
for(int i=0;i < studentPmArr.size() ; i++){
|
|
|
JSONObject studnetPmOb = (JSONObject) studentPmArr.get(i);
|
|
|
String pm = String.valueOf(studnetPmOb.get("pm"));
|
|
|
String studentId = String.valueOf(studnetPmOb.get("studentId"));
|
|
|
studentJxClassPmMap.put(studentId, pm);
|
|
|
}
|
|
|
}
|
|
|
/*获取学生排名*/
|
|
|
HashMap<String,HashMap<Integer,String>> mapStudentPm = getStudentPmList(studentRecord, testId);
|
|
|
|
|
|
for(Record recordStudent:records){
|
|
|
String personId = String.valueOf(recordStudent.get("person_id"));
|
|
|
String firstSubject = String.valueOf(recordStudent.get("firstSubject"));
|
|
|
HashMap<Integer,String> pmMap = mapStudentPm.get(personId);
|
|
|
if(COMMON.isEmpty(pmMap)){
|
|
|
recordStudent.set("firstSubjectPM", "0");
|
|
|
recordStudent.set("sedSubjectPM", "0");
|
|
|
}else{
|
|
|
recordStudent.set("firstSubjectPM", pmMap.get(1));
|
|
|
recordStudent.set("sedSubjectPM", pmMap.get(2));
|
|
|
}
|
|
|
recordStudent.set("firstSubject", firstSubject);
|
|
|
|
|
|
String pm = studentJxClassPmMap.get(personId);
|
|
|
if(COMMON.isEmpty(pm)){
|
|
|
recordStudent.set("studentJxClassPm", "0");
|
|
|
}else{
|
|
|
recordStudent.set("studentJxClassPm", pm);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public HashMap<String,HashMap<Integer,String>> getStudentPmList(List<Record> studentList ,String testId){
|
|
|
//HashMap<String,List<String>> mapStudentPm = new HashMap<String,List<String>>();
|
|
|
JSONObject pmJson = SelectCourseUtil.getStudentPm(studentList,testId);
|
|
|
JSONArray PMList = JSONArray.parseArray(String.valueOf(pmJson.get("PMList")));
|
|
|
HashMap<String,HashMap<Integer,String>> mapStudentPm = dealingWithStudentRanking(studentList, PMList);
|
|
|
// if(!COMMON.isEmpty(PMList)){
|
|
|
// for(int i=0;i<PMList.size();i++){
|
|
|
// JSONObject listOb = (JSONObject) PMList.get(i);
|
|
|
// String personId = String.valueOf(listOb.get("groupIndex"));
|
|
|
// JSONArray list = JSONArray.parseArray(String.valueOf(listOb.get("list")));
|
|
|
// List<String> listPm = new ArrayList<>();
|
|
|
// for(int j=0;j<list.size();j++){
|
|
|
// JSONObject json = (JSONObject)list.get(j);
|
|
|
// String categoryId = String.valueOf(json.get("categoryId"));
|
|
|
// listPm.add(categoryId);
|
|
|
// }
|
|
|
// mapStudentPm.put(personId, listPm);
|
|
|
// }
|
|
|
// }
|
|
|
return mapStudentPm ;
|
|
|
}
|
|
|
|
|
|
public HashMap<String,HashMap<Integer,String>> dealingWithStudentRanking(List<Record> studentList,JSONArray PMList){
|
|
|
HashMap<String,HashMap<Integer,String>> mapStudentPm = new HashMap<String,HashMap<Integer,String>>();
|
|
|
Map<String, Record> studentApplyMap = ToolsUtil.list2Map(studentList, "studentid");
|
|
|
//遍历成绩
|
|
|
if(!COMMON.isEmpty(PMList)){
|
|
|
for(int i=0;i<PMList.size();i++){
|
|
|
JSONObject listOb = (JSONObject) PMList.get(i);
|
|
|
String personId = String.valueOf(listOb.get("groupIndex"));
|
|
|
JSONArray list = JSONArray.parseArray(String.valueOf(listOb.get("list")));
|
|
|
/*获取学生志愿,初始化学生排名*/
|
|
|
Record studentApply = studentApplyMap.get(personId);
|
|
|
String firstSubjectId ="";
|
|
|
String secSubjectId ="";
|
|
|
if(!COMMON.isEmpty(studentApply)){
|
|
|
JSONArray subjectApply = studentApply.get("subjects");
|
|
|
HashMap<Integer, String> cjMap = new HashMap<>();
|
|
|
mapStudentPm.put(personId, cjMap);
|
|
|
if(!COMMON.isEmpty(subjectApply)){
|
|
|
firstSubjectId = (String) subjectApply.get(0);
|
|
|
cjMap.put(1, "0");
|
|
|
if(subjectApply.size() == 2){
|
|
|
secSubjectId = (String) subjectApply.get(1);
|
|
|
cjMap.put(2, "0");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
for(int j=0;j<list.size();j++){
|
|
|
JSONObject json = (JSONObject)list.get(j);
|
|
|
String category = String.valueOf(json.get("category"));
|
|
|
String categoryId = String.valueOf(json.get("categoryId"));
|
|
|
HashMap<Integer, String> cjMap = mapStudentPm.get(personId);
|
|
|
if(getSubjectSort(category).equals(getSubjectSort(firstSubjectId))&&j==0){
|
|
|
cjMap.put(1, categoryId);
|
|
|
continue ;
|
|
|
}
|
|
|
if (getSubjectSort(category).equals(getSubjectSort(secSubjectId))){
|
|
|
cjMap.put(2, categoryId);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return mapStudentPm ;
|
|
|
}
|
|
|
private String getSubjectSort(String value){
|
|
|
String[] array = value.split(",");
|
|
|
String result = "";
|
|
|
if(array.length == 1) {
|
|
|
result = array[0];
|
|
|
} else if(array.length == 2){
|
|
|
result = Common.generalDoubleSubject(array[0],array[1]);
|
|
|
}else if(array.length == 3){
|
|
|
result = Common.generalTripleSubject(array[0],array[1],array[2]);
|
|
|
}
|
|
|
return result;
|
|
|
// Arrays.sort(array);
|
|
|
// return ToolsUtil.getIds(array);
|
|
|
// System.out.println(array.toString());
|
|
|
// return array.toString();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @Description: 根据志愿查询学生要调整的班级
|
|
|
* @author :周明升
|
|
|
* @date: 2018-12-25 上午10:49:07
|
|
|
* @return: String
|
|
|
* @throws
|
|
|
*/
|
|
|
public JSONObject getStudentChosseClass(String personId,String personName,String planId) {
|
|
|
JSONObject json=new JSONObject();
|
|
|
//学生志愿
|
|
|
JSONObject studnetApplyOb = CoreUtil.getStudentApply(planId,personId);
|
|
|
//获取学生详细信息
|
|
|
studnetApplyOb.put("personName", personName);
|
|
|
studnetApplyOb.put("personId", personId);
|
|
|
String calculate_type = "";
|
|
|
String courseType = "" ;
|
|
|
Page<Record> pageRecord = SelectCoursePlanModel.dao.getResultClassList(planId, "", "", "0", "", "1", "0", "", "", "", "","0","",999, 1);
|
|
|
List<Record> resultClassList = pageRecord.getList();
|
|
|
//获取所有教学班信息
|
|
|
List<Record> listSingle=new ArrayList<>();
|
|
|
List<Record> listTwo=new ArrayList<>();
|
|
|
List<Record> listThree=new ArrayList<>();
|
|
|
JSONObject planInfo = new JSONObject();
|
|
|
if(!COMMON.isEmpty(resultClassList)){
|
|
|
calculate_type = String.valueOf(resultClassList.get(0).get("calculate_type"));
|
|
|
courseType = String.valueOf(resultClassList.get(0).get("course_type"));
|
|
|
planInfo.put("calculate_type", calculate_type);
|
|
|
planInfo.put("course_type", courseType);
|
|
|
for(Record eachClassRecord : resultClassList){
|
|
|
//班级类型:0-三科 1-两颗 2-一科
|
|
|
String classType = String.valueOf(eachClassRecord.get("class_type"));
|
|
|
if("2".equals(classType)){
|
|
|
listSingle.add(eachClassRecord);
|
|
|
}else if("1".equals(classType)){
|
|
|
listTwo.add(eachClassRecord);
|
|
|
}else if("0".equals(classType)&&!"0".equals(String.valueOf(eachClassRecord.get("course")))){
|
|
|
listThree.add(eachClassRecord);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//查询出所有的学考班级
|
|
|
Page<Record> pageRecordXue = SelectCoursePlanModel.dao.getResultClassList(planId, "", "", "1", "2", "", "0", "", "", "", "","0","",999, 1);
|
|
|
List<Record> resultXueClassList =pageRecordXue.getList();
|
|
|
json.put("isGray", false);
|
|
|
if(!COMMON.isEmpty(calculate_type)&&"1".equals(calculate_type)&&COMMON.isEmpty(listThree)&&COMMON.isEmpty(listTwo)){
|
|
|
json.put("isGray", true);
|
|
|
}
|
|
|
json.put("plan_info", planInfo);
|
|
|
json.put("success", true);
|
|
|
json.put("listSingle_list", COMMON.convertListRecord2(listSingle));
|
|
|
json.put("listTwo_list", COMMON.convertListRecord2(listTwo));
|
|
|
json.put("listThree_list", COMMON.convertListRecord2(listThree));
|
|
|
json.put("listXue_list", COMMON.convertListRecord2(resultXueClassList));
|
|
|
json.put("person_info", studnetApplyOb);
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
|
|
|
//保存学生新的教学班
|
|
|
/**
|
|
|
* @Description: 保存学生新的教学班
|
|
|
* @author :周明升
|
|
|
* @date: 2018-12-25 上午10:59:43
|
|
|
* @return: String
|
|
|
* @throws
|
|
|
*/
|
|
|
public JSONObject saveNewJxClass(String personId, String planId, String classId) {
|
|
|
JSONObject resultjson=new JSONObject();
|
|
|
//获取学生是否是未成班
|
|
|
List<Record> resultIdList = SelectCoursePlanModel.dao.getCoreResult(planId, "","", "", "0", "1", "0","0");
|
|
|
if(!COMMON.isEmpty(resultIdList)){
|
|
|
Record resultResult = resultIdList.get(0);
|
|
|
String resultId = String.valueOf(resultResult.get("result_id"));
|
|
|
List<Record> notInClassList = SelectCoursePlanModel.dao.getNoInClassList(resultId, personId,"");
|
|
|
/*学生所在的班级*/
|
|
|
List<Record> list= SelectCoursePlanModel.dao.getStudentExistClassList(planId, personId);
|
|
|
String classIds = ToolsUtil.getIds(list, "class_id");
|
|
|
if(!COMMON.isEmpty(classIds)){
|
|
|
CoreCourseModel.dao.updateClassPerson(personId, classIds);
|
|
|
CoreCourseModel.dao.updateResultClass(classIds,1);
|
|
|
}
|
|
|
/*未成班的学生*/
|
|
|
if(!COMMON.isEmpty(notInClassList)){
|
|
|
Record record = notInClassList.get(0);
|
|
|
String id = String.valueOf(record.get("id"));
|
|
|
CoreCourseModel.dao.updateNotInClassStudent(id);
|
|
|
}
|
|
|
}
|
|
|
String []classArray = classId.split(",");
|
|
|
List<Record> classList = new ArrayList<>();
|
|
|
for (int i = 0; i < classArray.length; i++) {
|
|
|
Record recordOb=new Record();
|
|
|
recordOb.set("class_id", classArray[i]);
|
|
|
recordOb.set("person_id", personId);
|
|
|
recordOb.set("b_use", 1);
|
|
|
recordOb.set("majors", 0);
|
|
|
classList.add(recordOb);
|
|
|
}
|
|
|
CoreCourseModel.dao.batchResultClassPerson(classList);
|
|
|
CoreCourseModel.dao.updateResultClass(classId,0);
|
|
|
resultjson.put("info", "保存成功");
|
|
|
resultjson.put("success",true);
|
|
|
return resultjson;
|
|
|
}
|
|
|
|
|
|
public JSONObject setStudentLimitSubject(String personId, String subjectIdArray) {
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
boolean flag=false;
|
|
|
/*删除限考数据*/
|
|
|
SelectCoursePlanModel.dao.delLimitSubject(personId,"");
|
|
|
if(!COMMON.isEmpty(subjectIdArray)){
|
|
|
String [] array = subjectIdArray.split(",");
|
|
|
for (int i = 0; i < array.length; i++) {
|
|
|
if(!COMMON.isEmpty(array[i])){
|
|
|
Record record=new Record();
|
|
|
record.set("person_id", personId);
|
|
|
record.set("subject_id", array[i]);
|
|
|
flag = SelectCoursePlanModel.dao.saveLimitSubject(record);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
returnJson.put("success", flag);
|
|
|
if(flag){
|
|
|
returnJson.put("info", "操作成功");
|
|
|
}else{
|
|
|
returnJson.put("info", "失败");
|
|
|
}
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
public JSONObject getStudentLimitSubject(String personId) {
|
|
|
List<Record> list= SelectCoursePlanModel.dao.getLimitSubjectList(personId);
|
|
|
JSONArray jsonArray=new JSONArray();
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
JSONObject resultJson=new JSONObject();
|
|
|
Record record=list.get(i);
|
|
|
resultJson.put("subjectId", String.valueOf(record.get("subject_id")));
|
|
|
resultJson.put("subjectName", String.valueOf(record.get("subject_name")));
|
|
|
jsonArray.add(resultJson);
|
|
|
}
|
|
|
JSONObject returnJson=new JSONObject();
|
|
|
returnJson.put("subject_list", jsonArray);
|
|
|
returnJson.put("success", true);
|
|
|
return returnJson;
|
|
|
}
|
|
|
public JSONObject delectStudentLimitSubject(String personId,String subjectId) {
|
|
|
JSONObject returnJson=new JSONObject();
|
|
|
boolean flag= SelectCoursePlanModel.dao.delLimitSubject(personId,subjectId);
|
|
|
returnJson.put("success", flag);
|
|
|
if(flag){
|
|
|
returnJson.put("info", "操作成功");
|
|
|
}else{
|
|
|
returnJson.put("info", "失败");
|
|
|
}
|
|
|
return returnJson;
|
|
|
}
|
|
|
public JSONObject getStudentXzStudentList(String planId) {
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
List<Record> classList1 = SelectCoursePlanModel.dao.getClassListByplanId(planId);
|
|
|
for(Record classListRecord:classList1){
|
|
|
String count1 = String.valueOf(classListRecord.get("count"));
|
|
|
classListRecord.set("student_count", count1);
|
|
|
}
|
|
|
returnJson.put("success", true);
|
|
|
returnJson.put("info", "查询行政班成功");
|
|
|
returnJson.put("class_list",classList1);
|
|
|
return returnJson;
|
|
|
}
|
|
|
//学考教学班
|
|
|
public JSONObject selectLearningTestClassStudentList(int pageSize,
|
|
|
int pageNumber, String planId, String calculateType) {
|
|
|
Record record = new Record();
|
|
|
record.set("plan_id", planId);
|
|
|
Page<Record> pageRecord =SelectCoursePlanService.service.getClassPageByPlanIdAndType(planId, "1");
|
|
|
List<Record> records = pageRecord.getList();
|
|
|
//查询result_id 学考教学班不显示 未成班
|
|
|
// List<Record> resultList = SelectCoursePlanModel.dao.getCoreResult(planId, "","", "", "0", "1", "0","0");
|
|
|
// if(!COMMON.isEmpty(resultList)){
|
|
|
// Record recordResult = resultList.get(0);
|
|
|
// String resultId = String.valueOf(recordResult.get("result_id"));
|
|
|
// if(records.size()<pageSize){
|
|
|
// addNoInClassStudent(records, resultId);
|
|
|
// }
|
|
|
// }
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
addReturnJsonIsExistFc(records, resultJson);
|
|
|
resultJson.put("curriculumPlanList", COMMON.convertListRecord2(records));
|
|
|
resultJson.put("pageNumber", pageRecord.getPageNumber());
|
|
|
resultJson.put("pageSize", pageRecord.getPageSize());
|
|
|
resultJson.put("totalPage", pageRecord.getTotalPage());
|
|
|
resultJson.put("totalRow", pageRecord.getTotalRow());
|
|
|
resultJson.put("success", true);
|
|
|
resultJson.put("info", "查询成功");
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
|
|
private Record addNoInClassStudent(String resultId,String calculateType){
|
|
|
Record notInClass = new Record();
|
|
|
notInClass.set("class_id", "");
|
|
|
notInClass.set("student_count", "需要再查询");
|
|
|
notInClass.set("course", "");
|
|
|
notInClass.set("class_name", "未成班");
|
|
|
notInClass.set("result_id", Integer.parseInt(resultId));
|
|
|
notInClass.set("calculate_type", calculateType);
|
|
|
List<Record> notInClassList = SelectCoursePlanModel.dao.getNoInClassList(resultId,"","");
|
|
|
int count = notInClassList.size();
|
|
|
if (count>0){
|
|
|
notInClass.set("student_count", count);
|
|
|
return notInClass ;
|
|
|
}
|
|
|
return null ;
|
|
|
}
|
|
|
public JSONObject getSelectExaminationJxClassList(int pageSize, int pageNumber,
|
|
|
String planId, String calculateType,String groupId ) {
|
|
|
Page<Record> pageRecord = SelectCoursePlanModel.dao.getResultClassList(planId, "", "", "0", "", "1", "", "", "2", "",groupId,"0","",999,1);
|
|
|
List<Record> resultLis = pageRecord.getList();
|
|
|
//查询result_id
|
|
|
List<Record> resultList = SelectCoursePlanModel.dao.getCoreResult(planId, "","", "", "0", "1", "0","0");
|
|
|
if(!COMMON.isEmpty(resultList)){
|
|
|
Record recordResult = resultList.get(0);
|
|
|
String resultId = String.valueOf(recordResult.get("result_id"));
|
|
|
if(resultLis.size()<pageSize){
|
|
|
Record notInClass = addNoInClassStudent(resultId,calculateType);
|
|
|
if(!COMMON.isEmpty(notInClass)){
|
|
|
resultLis.add(notInClass);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
addReturnJsonIsExistFc(resultLis, resultJson);
|
|
|
resultJson.put("curriculumPlanList", COMMON.convertListRecord2(resultLis));
|
|
|
resultJson.put("pageNumber", pageRecord.getPageNumber());
|
|
|
resultJson.put("pageSize", pageRecord.getPageSize());
|
|
|
resultJson.put("totalPage", pageRecord.getTotalPage());
|
|
|
resultJson.put("totalRow", pageRecord.getTotalRow());
|
|
|
resultJson.put("success", true);
|
|
|
resultJson.put("info", "查询成功");
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
|
|
//获取学生三科组合排名
|
|
|
public JSONObject getStudentApplyPm(String subjectIds ,String planId,String personId){
|
|
|
Record planDetail = SelectCoursePlanModel.dao.getPlanInfo(planId);
|
|
|
String testId= String.valueOf(planDetail.get("test_id"));
|
|
|
String pm ="0";
|
|
|
pm = CoreUtil.getStudentPmInfo(testId,personId,subjectIds);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("success", true);
|
|
|
json.put("info", "查询学生成绩成功");
|
|
|
json.put("pm", pm);
|
|
|
return json ;
|
|
|
}
|
|
|
/**
|
|
|
* @description 导出分班结果
|
|
|
* @author Mr.zms
|
|
|
* @date 2019/4/17
|
|
|
*/
|
|
|
public HSSFWorkbook getExportClassList(String planId) {
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
//获取行政班列表
|
|
|
List<Record> xzList = SelectCoursePlanModel.dao.getClassStudentList(planId);
|
|
|
HSSFSheet sheet = wb.createSheet("行政班");
|
|
|
String [] heahs = {"学生ID","学生姓名","新行政班","原行政班"};
|
|
|
String [] names = {"person_id","student_name","class_name","old_class_name"};
|
|
|
addDataToSheet(sheet,xzList,heahs,names) ;
|
|
|
//获取选考教学班
|
|
|
List<Record> selectList = SelectCoursePlanModel.dao.getTeachingClassStudentList(planId,"0","1","");
|
|
|
HSSFSheet selectSheet = wb.createSheet("选考教学班");
|
|
|
String [] selectHeads = {"学生ID","学生姓名","新行政班","原行政班","教学班"};
|
|
|
String [] selectNames = {"person_id","student_name","new_xz_class_name","old_class_name","new_class_name"};
|
|
|
addDataToSheet(selectSheet,selectList,selectHeads,selectNames) ;
|
|
|
//查询 计划 是否是仅限选考
|
|
|
Record planDetail = SelectCoursePlanModel.dao.getPlanInfo(planId);
|
|
|
String courseType = String.valueOf(planDetail.get("course_type"));
|
|
|
if("1".equals(courseType)){
|
|
|
//获取学考教学班
|
|
|
List<Record> studyList = SelectCoursePlanModel.dao.getTeachingClassStudentList(planId,"1","","2");
|
|
|
HSSFSheet studySheet = wb.createSheet("学考教学班");
|
|
|
addDataToSheet(studySheet,studyList,selectHeads,selectNames) ;
|
|
|
}
|
|
|
return wb;
|
|
|
}
|
|
|
private void addDataToSheet(HSSFSheet sheet,List<Record> list,String [] heahs,String [] names){
|
|
|
HSSFRow row1 = sheet.createRow(0);
|
|
|
sheet.setColumnWidth(0, 3766);
|
|
|
for (int i = 0; i < heahs.length; i++) {
|
|
|
HSSFCell cell= row1.createCell(i);
|
|
|
cell.setCellValue(heahs[i]) ;
|
|
|
}
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
Record record = list.get(i);
|
|
|
HSSFRow row = sheet.createRow(i+1);
|
|
|
sheet.setColumnWidth(i+1, 3766);
|
|
|
for (int j = 0; j < names.length; j++) {
|
|
|
HSSFCell cell= row.createCell(j);
|
|
|
String value = String.valueOf(record.get(names[j]));
|
|
|
cell.setCellValue(value) ;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|