|
|
package com.dsideal.newUniversityExamination.selectcourse.service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
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;
|
|
|
|
|
|
public class SelectCoursePlanService {
|
|
|
public static final SelectCoursePlanService service = new SelectCoursePlanService();
|
|
|
|
|
|
|
|
|
/*更新t_select_course_plan 的发布状态*/
|
|
|
public void updatePlanIsRelease(String planId){
|
|
|
/*本此计划下的 班级*/
|
|
|
List<Record> classList = SelectCoursePlanModel.dao.getClassListByplanId(planId);
|
|
|
if(!COMMON.isEmpty(classList)){
|
|
|
String classIds = ToolsUtil.getIds(classList, "class_id");
|
|
|
/*选择过班级 的计划s*/
|
|
|
List<Record> planList = SelectCoursePlanModel.dao.getPlanListByClassIdAndStatus(classIds, "","");
|
|
|
if(!COMMON.isEmpty(planList)){
|
|
|
/*所有计划变无效*/
|
|
|
String planIds = ToolsUtil.getIds(planList, "plan_id");
|
|
|
/*未生成报告的 - 状态 变成 8 */
|
|
|
SelectCoursePlanModel.dao.updatePlanStatus("8", planIds,"1,2,3,4");
|
|
|
/*生成报告的-状态改成 7 */
|
|
|
SelectCoursePlanModel.dao.updatePlanStatus("7", planIds,"5");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
private int String2Integer(String str){
|
|
|
int value = 0 ;
|
|
|
try {
|
|
|
value = Integer.parseInt(str);
|
|
|
} catch (NumberFormatException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return value ;
|
|
|
}
|
|
|
|
|
|
/*新增和修改选科计划*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public JSONObject setCoursePlan(String planId, String planName, String startTime,
|
|
|
String endTime, String type, String curriculumId,
|
|
|
String maxStudentCount, String minStudentCount, String classIds,
|
|
|
String classRoomIds,String bureauId,String status,String sequenceYear,String sequenceStage,String testId,String testIndex,String subjectType,String subjects,String classRoomCount,String courseType,String isReport) {
|
|
|
Record record= new Record();
|
|
|
record.set("bureau_id", bureauId);
|
|
|
record.set("plan_name", planName);
|
|
|
record.set("start_time", startTime);
|
|
|
record.set("end_time", endTime);
|
|
|
record.set("type", type);
|
|
|
record.set("curriculum_id", curriculumId);
|
|
|
record.set("max_student_count", maxStudentCount);
|
|
|
record.set("min_student_count", minStudentCount);
|
|
|
record.set("status", COMMON.isEmpty(status)?"1":status);
|
|
|
record.set("sequence_year", sequenceYear);
|
|
|
record.set("sequence_stage", sequenceStage);
|
|
|
record.set("test_index", testIndex);
|
|
|
record.set("subject_type", subjectType);
|
|
|
record.set("subjects", subjects);
|
|
|
record.set("class_room_count", classRoomCount);
|
|
|
record.set("course_type", courseType);
|
|
|
record.set("is_report", isReport);
|
|
|
int test_id = String2Integer(testId);
|
|
|
record.set("test_id", test_id);
|
|
|
JSONObject returnJson = new JSONObject() ;
|
|
|
/*校验是否上报*/
|
|
|
if(!COMMON.isEmpty(classIds)&&"1".equals(isReport)){
|
|
|
List<Record> list = SelectCoursePlanModel.dao.getIsReportByPlanList(bureauId, classIds,planId);
|
|
|
if(!COMMON.isEmpty(list)){
|
|
|
returnJson.put("success", false);
|
|
|
returnJson.put("info", "本计划下班级已存在上报记录,不允许上报");
|
|
|
return returnJson;
|
|
|
}
|
|
|
}
|
|
|
/*校验班级是否正常*/
|
|
|
String[] classStr = classIds.split(",");
|
|
|
int [] classTypeArray = new int [classStr.length];
|
|
|
for(int i=0;i<classStr.length;i++){
|
|
|
int classType = 1;
|
|
|
classTypeArray[i] = classType;
|
|
|
}
|
|
|
String classTypes = ToolsUtil.getIds(classTypeArray) ;
|
|
|
JSONObject mapJson = SelectCourseBaseService.service.getClassInfoByClassId(classIds, classTypes, 3);
|
|
|
Map<String, Record> map = new HashMap<>();
|
|
|
map = (Map<String, Record>) mapJson.get("map");
|
|
|
boolean flag = mapJson.getBooleanValue("success");
|
|
|
if(!flag){
|
|
|
returnJson.put("info", "计划对应的班级存在无效班级,不允许操作");
|
|
|
returnJson.put("success", false);
|
|
|
return returnJson ;
|
|
|
}
|
|
|
|
|
|
/*校验计划名是否重复*/
|
|
|
List<Record> list = SelectCoursePlanModel.dao.getCoursePlanNameListYz(planName, bureauId, planId);
|
|
|
if(!COMMON.isEmpty(list)){
|
|
|
returnJson.put("success", false);
|
|
|
returnJson.put("info", "选科计划名称已存在");
|
|
|
return returnJson;
|
|
|
}else{
|
|
|
if(COMMON.isEmpty(planId)){
|
|
|
SelectCoursePlanModel.dao.saveCoursePlan(record);
|
|
|
planId = String.valueOf(record.get("id"));
|
|
|
}else{
|
|
|
record.set("plan_id", planId);
|
|
|
SelectCoursePlanModel.dao.updateCoursePlan(record);
|
|
|
}
|
|
|
}
|
|
|
/*删除之前的计划绑定的班级 和人*/
|
|
|
SelectCoursePlanModel.dao.delCoursePlanClass(planId);
|
|
|
SelectCoursePlanModel.dao. delCoursePlanClassPerson(planId);
|
|
|
/*插入班级 和学生*/
|
|
|
List<Record> batchClassList = new ArrayList<>();
|
|
|
List<Record> batchPersonList = new ArrayList<>();
|
|
|
for(int i=0;i<classStr.length;i++){
|
|
|
String classId = classStr[i];
|
|
|
int classType = classTypeArray [i];
|
|
|
String key = classId+"|"+classType;
|
|
|
Record recordOb = map.get(key);
|
|
|
Record classRecord = new Record();
|
|
|
classRecord.set("plan_id", planId);
|
|
|
classRecord.set("class_id", recordOb.get("class_id"));
|
|
|
classRecord.set("class_type", classType);
|
|
|
classRecord.set("class_name", recordOb.get("class_name"));
|
|
|
batchClassList.add(classRecord);
|
|
|
JSONArray personArray = recordOb.get("student_list");
|
|
|
for(int j = 0 ; j < personArray.size() ; j++){
|
|
|
JSONObject json = personArray.getJSONObject(j);
|
|
|
Record personRecord = new Record();
|
|
|
personRecord.set("plan_id", planId);
|
|
|
personRecord.set("class_id", json.get("class_id"));
|
|
|
personRecord.set("class_type", json.get("class_type"));
|
|
|
personRecord.set("person_id", json.get("person_id"));
|
|
|
personRecord.set("student_name", json.get("person_name"));
|
|
|
batchPersonList.add(personRecord);
|
|
|
}
|
|
|
}
|
|
|
SelectCoursePlanModel.dao.batchSavePlanClass(batchClassList);
|
|
|
SelectCoursePlanModel.dao.batchSavePlanClassPerson(batchPersonList);
|
|
|
/*查询出 不应该在本此计划有志愿的学生ids,然后删除*/
|
|
|
Record students = StudentApplyModel.dao.getDeleteStudentApplyPersonIds(planId);
|
|
|
String personIds = String.valueOf(students.get("personIds"));
|
|
|
StudentApplyModel.dao.delCourseApply(planId, personIds, "");
|
|
|
returnJson.put("success", true);
|
|
|
returnJson.put("info", "操作成功");
|
|
|
return returnJson;
|
|
|
}
|
|
|
//0 选 1 学 2 行政班
|
|
|
public List<Record> getClassListByPlanIdAndType(String planId,String type){
|
|
|
List<Record> list = new ArrayList<>();
|
|
|
Page<Record> pageRecord= getClassPageByPlanIdAndType(planId, type);
|
|
|
list = pageRecord.getList();
|
|
|
return list ;
|
|
|
}
|
|
|
/**
|
|
|
* @Description:获取未成班学生 personIds
|
|
|
* @author :周明升
|
|
|
* @date: 2019-1-19 上午8:52:53
|
|
|
* @return: String
|
|
|
* @throws
|
|
|
*/
|
|
|
private String getNotInClassStudent(String planId){
|
|
|
String personIds = "" ;
|
|
|
List<Record> coreResultList = SelectCoursePlanModel.dao.getCoreResult(planId, "", "", "", "0", "1", "0", "0");
|
|
|
if(!COMMON.isEmpty(coreResultList)){
|
|
|
String resultId = String.valueOf(coreResultList.get(0).get("result_id"));
|
|
|
Page<Record> noClass =SelectCoursePlanModel.dao.getNotClassStudentList(resultId, planId, "999", "1");
|
|
|
List<Record> notClassStudentList = noClass.getList();
|
|
|
personIds = ToolsUtil.getIds(notClassStudentList, "person_id");
|
|
|
}
|
|
|
return personIds ;
|
|
|
}
|
|
|
|
|
|
public Page<Record> getClassPageByPlanIdAndType(String planId,String type){
|
|
|
Page<Record> pageRecord = null ;
|
|
|
if("2".equals(type)){
|
|
|
pageRecord= SelectCoursePlanModel.dao.getResultClassList(planId, "", "", "0", "", "1", "0", "","0,1", "","","0","",999,1);
|
|
|
}else if("1".equals(type)){
|
|
|
/*学考获取未成班的学生*/
|
|
|
String personIds = getNotInClassStudent(planId);
|
|
|
pageRecord = SelectCoursePlanModel.dao.getResultClassList(planId, "", "", "1", "2", "0", "0", "", "2", "","","0",personIds,999,1);
|
|
|
}else if("0".equals(type)){
|
|
|
pageRecord = SelectCoursePlanModel.dao.getResultClassList(planId, "", "", "0", "", "1", "", "", "2", "","","0","",999,1);
|
|
|
}
|
|
|
return pageRecord ;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Description:根据ID获取选课计划详情
|
|
|
* @author huyue
|
|
|
* @date 2018-1-19
|
|
|
*/
|
|
|
public JSONObject getPlanInfoById(String planId,String classId,String status,String personName,String pageSize,String pageNumber,String calculateType,String type){
|
|
|
//获取先科计划信息
|
|
|
JSONObject coursePlanOb = new JSONObject();
|
|
|
coursePlanOb = CoreUtil.getCoursePlanStudentCount(planId);
|
|
|
Record record = SelectCoursePlanModel.dao.getPlanInfo(planId);
|
|
|
/*获取班级List*/
|
|
|
List<Record> classList = SelectCoursePlanModel.dao.getClassListByplanId(planId);
|
|
|
String total_person_count = String.valueOf(coursePlanOb.get("total_person_count"));
|
|
|
String finish_person_count = String.valueOf(coursePlanOb.get("finish_person_count"));
|
|
|
String unfinish_person_count = String.valueOf(coursePlanOb.get("unfinish_person_count"));
|
|
|
record.set("finish_person_count", finish_person_count);
|
|
|
record.set("unfinish_person_count", Integer.parseInt(unfinish_person_count));
|
|
|
record.set("total_person_count", total_person_count);
|
|
|
|
|
|
for(Record classListRecord:classList){
|
|
|
String count1 = String.valueOf(classListRecord.get("count"));
|
|
|
classListRecord.set("student_count", count1);
|
|
|
}
|
|
|
record.set("class_list", classList );
|
|
|
/*获取学生列表*/
|
|
|
List<Record> resulList = new ArrayList<>();
|
|
|
Page<Record> pageRecord = new Page<>(resulList,Integer.parseInt(pageNumber) , Integer.parseInt(pageSize), 0, 0);
|
|
|
List<Record> records = new ArrayList<>();
|
|
|
// type = 1 没有学生列表 type = 2 学生基础班级 列表 3 学生的新班级列表
|
|
|
if("1".equals(type)){
|
|
|
|
|
|
}else if ("2".equals(type)){
|
|
|
pageRecord = SelectCoursePlanModel.dao.getStudentListByPlanId(planId, classId, status, personName, pageSize, pageNumber);
|
|
|
records = pageRecord.getList();
|
|
|
for(int i=0;i<records.size();i++){
|
|
|
Record recordStudent = records.get(i);
|
|
|
String studentId = String.valueOf(recordStudent.get("student_id"));
|
|
|
recordStudent.set("person_id", studentId);
|
|
|
//获取当前选择算法的planId
|
|
|
recordStudent.set("courseClassNameStr", "");
|
|
|
recordStudent.set("jxClassName", "未成班");
|
|
|
//获取学生第一志愿、第二志愿
|
|
|
JSONObject studnetApplyOb = CoreUtil.getStudentApply(planId,studentId);
|
|
|
boolean statusDesc = studnetApplyOb.getBooleanValue("is_exist");
|
|
|
if(statusDesc){
|
|
|
recordStudent.set("status", 0);
|
|
|
recordStudent.set("statusDesc", "已选择");
|
|
|
}else{
|
|
|
recordStudent.set("status", 1);
|
|
|
recordStudent.set("statusDesc", "未选择");
|
|
|
}
|
|
|
//查询学生一二志愿选择学科
|
|
|
recordStudent.set("firstSubject", studnetApplyOb.get("firstSubject"));
|
|
|
recordStudent.set("sedSubject",studnetApplyOb.get("sedSubject") );
|
|
|
recordStudent.set("firstSubjectId",studnetApplyOb.get("firstSubjectId") );
|
|
|
recordStudent.set("sedSubjectId", studnetApplyOb.get("sedSubjectId"));
|
|
|
}
|
|
|
}else if ("3".equals(type)){
|
|
|
pageRecord = SelectCoursePlanModel.dao.getResultClassStudentList(planId, "", "", "0", "", "1", "0", "","0,1", "",classId,"0","999","1" );
|
|
|
List<Record> studentList = pageRecord.getList();
|
|
|
Map<String,Record> studentMap = ToolsUtil.list2Map(studentList, "person_id");
|
|
|
pageRecord = SelectCoursePlanModel.dao.getStudentListByPlanId(planId, classId, status, personName, pageSize, pageNumber);
|
|
|
records = pageRecord.getList();
|
|
|
for(int i=0;i<records.size();i++){
|
|
|
Record recordStudent = records.get(i);
|
|
|
String studentId = String.valueOf(recordStudent.get("student_id"));
|
|
|
recordStudent.set("person_id", studentId);
|
|
|
Record stuOb = studentMap.get(studentId);
|
|
|
if(!COMMON.isEmpty(stuOb)){
|
|
|
String course = String.valueOf(stuOb.get("course"));
|
|
|
String jxClassName = String.valueOf(stuOb.get("teach_class_name"));
|
|
|
String courseStr = Constant.getSubjectMap().get(course);
|
|
|
recordStudent.set("courseClassNameStr", courseStr);
|
|
|
recordStudent.set("jxClassName", jxClassName);
|
|
|
recordStudent.set("calculate_type", stuOb.get("calculate_type"));
|
|
|
}else{
|
|
|
recordStudent.set("courseClassNameStr", "");
|
|
|
recordStudent.set("jxClassName", "未成班");
|
|
|
}
|
|
|
}
|
|
|
/*获取学生成绩map 获取test_id*/
|
|
|
String testId= String.valueOf(record.get("test_id")) ;
|
|
|
StudentSelectCourseService.service.addPmToStudentlist(records, planId, testId);
|
|
|
}
|
|
|
//未成班 放在后面
|
|
|
List<Record> resulListClass = new ArrayList<>();
|
|
|
for(Record recordOb: records){
|
|
|
String courseClassNameStr = recordOb.get("courseClassNameStr");
|
|
|
if(!COMMON.isEmpty(courseClassNameStr)){
|
|
|
resulList.add(recordOb);
|
|
|
}else{
|
|
|
resulListClass.add(recordOb);
|
|
|
}
|
|
|
}
|
|
|
resulList.addAll(resulListClass);
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
resultJson.put("studentList", COMMON.convertListRecord2(resulList));
|
|
|
resultJson.put("pageNumber", pageRecord.getPageNumber());
|
|
|
resultJson.put("pageSize", pageRecord.getPageSize());
|
|
|
resultJson.put("totalPage", pageRecord.getTotalPage());
|
|
|
resultJson.put("totalRow", pageRecord.getTotalRow());
|
|
|
resultJson.put("coursePlanInfo", COMMON.convertRecord2Json2(record));
|
|
|
resultJson.put("success", true);
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Description: 删除选科计划
|
|
|
* @author :周明升
|
|
|
* @date: 2018-12-25 下午4:32:26
|
|
|
* @return: String
|
|
|
* @throws
|
|
|
*/
|
|
|
public JSONObject delSelectCoursePlan(String planId,String type) {
|
|
|
//验证排课任务 是否使用
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
//1删除 2还原
|
|
|
if("2".equals(type)){
|
|
|
/*校验选科计划是否可以还原*/
|
|
|
resultJson = checkCoursePlanCanDel(planId);
|
|
|
boolean success = resultJson.getBooleanValue("success");
|
|
|
if(!success){
|
|
|
return resultJson ;
|
|
|
}
|
|
|
}
|
|
|
//获取 resultIds
|
|
|
List<Record> list = SelectCoursePlanModel.dao.getCoreResult(planId, "","", "", "", "", "","");
|
|
|
String resultIds = ToolsUtil.getIds(list, "result_id");
|
|
|
//获取班级Ids
|
|
|
Page<Record> pageRecord = SelectCoursePlanModel.dao.getResultClassList(planId, "", "", "", "", "", "", "", "", "", "","" ,"",9999, 1);
|
|
|
List<Record> classList = pageRecord.getList();
|
|
|
String classIds = ToolsUtil.getIds(classList, "class_id");
|
|
|
if(!COMMON.isEmpty(resultIds)){
|
|
|
// 删除 未成班的 学生
|
|
|
CoreCourseModel.dao.delResultNotInClass(resultIds);
|
|
|
//删除 算法分出来的班级
|
|
|
CoreCourseModel.dao.delResultClass(resultIds);
|
|
|
// 删除 算法计算出的教师剩余情况
|
|
|
CoreCourseModel.dao.delResultTeacherCount(resultIds);
|
|
|
}
|
|
|
// 删除选科 计划日志
|
|
|
SelectCoursePlanModel.dao.delSelectCoursePlanLog(planId);
|
|
|
// 删除学生志愿
|
|
|
StudentApplyModel.dao.delStudentApplyByPlanId(planId);
|
|
|
// 删除 算法结果
|
|
|
CoreCourseModel.dao.delResultCore(planId,"","","");
|
|
|
if(!COMMON.isEmpty(classIds)){
|
|
|
CoreCourseModel.dao.delResultClassPerson(classIds);
|
|
|
}
|
|
|
//还原 把同步状态改掉
|
|
|
if("2".equals(type)){
|
|
|
SelectCoursePlanModel.dao.updateCoursePlanIsRelease(planId, "0");
|
|
|
}
|
|
|
if("1".equals(type)){
|
|
|
SelectCoursePlanModel.dao.delCoursePlan(planId);
|
|
|
//删除 计划对应的班级
|
|
|
SelectCoursePlanModel.dao.delCoursePlanClass(planId);
|
|
|
//删除 计划班级对应的人
|
|
|
SelectCoursePlanModel.dao.delCoursePlanClassPerson(planId);
|
|
|
}
|
|
|
resultJson.put("info", "删除成功");
|
|
|
resultJson.put("success", true);
|
|
|
|
|
|
return resultJson;
|
|
|
}
|
|
|
private JSONObject checkCoursePlanCanDel(String planId){
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
returnJson.put("success", true);
|
|
|
/*无效计划不让还原*/
|
|
|
JSONObject planInfo = getPlanInfo(planId);
|
|
|
String status = String.valueOf(planInfo.get("status"));
|
|
|
if("7".equals(status)||"8".equals(status)){
|
|
|
returnJson.put("info", "选科计划无效,不能还原!");
|
|
|
returnJson.put("success", false);
|
|
|
return returnJson;
|
|
|
}
|
|
|
List<Record> resultList = SelectCoursePlanModel.dao.getCoreResult(planId, "","", "", "0", "", "0","0");
|
|
|
int resultLenth = 0 ;
|
|
|
if(!COMMON.isEmpty(resultList)&&resultList.size()>0){
|
|
|
resultLenth = resultList.size();
|
|
|
}
|
|
|
if(resultLenth != 3){
|
|
|
returnJson.put("info", "选科计划下走班策略报告正在生成中,不能还原!");
|
|
|
returnJson.put("success", false);
|
|
|
return returnJson;
|
|
|
}
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
|
|
|
/*获取选科计划列表*/
|
|
|
public JSONObject getCoursePlanList(String bureauId, String pageNumber,
|
|
|
String pageSize, String stageId, String type, String status,
|
|
|
String planName,String isRelease) {
|
|
|
Page<Record> pageRecord = SelectCoursePlanModel.dao.getCoursePlanList(stageId, type, status, planName, bureauId, isRelease,pageSize, pageNumber);
|
|
|
List<Record> records = pageRecord.getList();
|
|
|
for(Record recordPlan:records){
|
|
|
String planId = String.valueOf(recordPlan.get("plan_id"));
|
|
|
//获取先科计划信息
|
|
|
JSONObject coursePlanOb = new JSONObject();
|
|
|
coursePlanOb = CoreUtil.getCoursePlanStudentCount(planId);
|
|
|
String total_person_count = String.valueOf(coursePlanOb.get("total_person_count"));
|
|
|
String finish_person_count = String.valueOf(coursePlanOb.get("finish_person_count"));
|
|
|
String unfinish_person_count = String.valueOf(coursePlanOb.get("unfinish_person_count"));
|
|
|
recordPlan.set("finish_person_count", finish_person_count);
|
|
|
recordPlan.set("unfinish_person_count", Integer.parseInt(unfinish_person_count));
|
|
|
recordPlan.set("total_person_count", total_person_count);
|
|
|
|
|
|
//查询已选择算法的内容,添加已分班人数,未分班人数,和算法名称
|
|
|
List<Record> classDetailList = SelectCoursePlanModel.dao.getAllStudentByPlanId(planId);
|
|
|
int inClassCount = 0;
|
|
|
int notInClassCount =0;
|
|
|
String calculateType = "";;
|
|
|
for(Record classDetailRecord:classDetailList){
|
|
|
int count = Integer.parseInt(String.valueOf(classDetailRecord.get("count")));
|
|
|
int indexs = Integer.parseInt(String.valueOf(classDetailRecord.get("indexs")));
|
|
|
if(indexs==0){
|
|
|
inClassCount = count;
|
|
|
if(!COMMON.isEmpty(classDetailRecord.get("calculate_type"))){
|
|
|
calculateType = String.valueOf(classDetailRecord.get("calculate_type"));
|
|
|
}
|
|
|
}else{
|
|
|
notInClassCount = count ;
|
|
|
}
|
|
|
}
|
|
|
recordPlan.set("inClassCount", inClassCount);
|
|
|
recordPlan.set("notInClassCount", notInClassCount);
|
|
|
recordPlan.set("calculate_type", calculateType);
|
|
|
if("0".equals(calculateType)){
|
|
|
recordPlan.set("calculate_type_name", "优先三科成班");
|
|
|
recordPlan.set("check_flag", 1);
|
|
|
}else if ("1".equals(calculateType)){
|
|
|
recordPlan.set("calculate_type_name", "定二走一");
|
|
|
recordPlan.set("check_flag", 1);
|
|
|
}else if ("2".equals(calculateType)){
|
|
|
recordPlan.set("calculate_type_name", "大走班");
|
|
|
recordPlan.set("check_flag", 1);
|
|
|
}else{
|
|
|
recordPlan.set("calculate_type_name", "还未选择算法,暂无教学班分班信息");
|
|
|
recordPlan.set("check_flag", 0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
resultJson.put("coursePlanList", 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);
|
|
|
return resultJson;
|
|
|
}
|
|
|
/**
|
|
|
* @Description: 清空选科计划
|
|
|
* @author :周明升
|
|
|
* @date: 2018-12-26 上午8:53:34
|
|
|
* @return: String
|
|
|
* @throws
|
|
|
*/
|
|
|
public JSONObject delCoursePlanApply(String planId) {
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
Record record = SelectCoursePlanModel.dao.getPlanInfo(planId);
|
|
|
int status=Integer.valueOf(String.valueOf(record.get("status"))) ;
|
|
|
if(status==1){
|
|
|
resultJson.put("info", "任务尚未开始,系统暂无选科数据");
|
|
|
resultJson.put("success", false);
|
|
|
}else if(status==2){
|
|
|
resultJson.put("info", "选科计划正在进行中,请'暂停'后,再选择'清空选科结果'操作");
|
|
|
resultJson.put("success", false);
|
|
|
}else{
|
|
|
StudentApplyModel.dao.delStudentApplyByPlanId(planId);
|
|
|
resultJson.put("info", "删除成功");
|
|
|
resultJson.put("success", true);
|
|
|
}
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Description: 获取计划详情
|
|
|
* @author :周明升
|
|
|
* @date: 2018-12-26 上午8:59:15
|
|
|
* @return: String
|
|
|
* @throws
|
|
|
*/
|
|
|
public JSONObject getPlanInfo(String planId) {
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
Record record = SelectCoursePlanModel.dao.getPlanInfo(planId);
|
|
|
String planName = String.valueOf(record.get("plan_name"));
|
|
|
String startTime = String.valueOf(record.get("start_time"));
|
|
|
String endTime = String.valueOf(record.get("end_time"));
|
|
|
String type = String.valueOf(record.get("type"));
|
|
|
String curriculumId = String.valueOf(record.get("curriculum_id"));
|
|
|
String maxStudentCount = String.valueOf(record.get("max_student_count"));
|
|
|
String minStudentCount = String.valueOf(record.get("min_student_count"));
|
|
|
String sequenceYear = String.valueOf(record.get("sequence_year"));
|
|
|
String sequenceStage = String.valueOf(record.get("sequence_stage"));
|
|
|
String testId = String.valueOf(record.get("test_id"));
|
|
|
String testIndex = String.valueOf(record.get("test_index"));
|
|
|
String subjectType = String.valueOf(record.get("subject_type"));
|
|
|
String classRoomCount = String.valueOf(record.get("class_room_count"));
|
|
|
String courseType = String.valueOf(record.get("course_type"));
|
|
|
String isReport = String.valueOf(record.get("is_report"));
|
|
|
String status = String.valueOf(record.get("status"));
|
|
|
String subjects = String.valueOf(record.get("subjects"));
|
|
|
String subjectName="";
|
|
|
String [] subjectArray = subjects.split(",");
|
|
|
Map<String,String> map=Constant.getThreeSubjectMap();
|
|
|
for (int i = 0; i < subjectArray.length; i++) {
|
|
|
subjectName += map.get(subjectArray[i]);
|
|
|
if(i!=subjectArray.length-1){
|
|
|
subjectName +=",";
|
|
|
}
|
|
|
}
|
|
|
JSONArray classArr = new JSONArray();
|
|
|
List<Record> classList = SelectCoursePlanModel.dao.getClassListByplanId(planId);
|
|
|
for(Record classRecord : classList){
|
|
|
JSONObject ob = new JSONObject();
|
|
|
String classId = String.valueOf(classRecord.get("class_id"));
|
|
|
String className = String.valueOf(classRecord.get("class_name"));
|
|
|
ob.put("class_id", classId);
|
|
|
ob.put("class_name", className);
|
|
|
classArr.add(ob);
|
|
|
}
|
|
|
JSONArray roomArr = new JSONArray();
|
|
|
resultJson.put("subject_type", subjectType);
|
|
|
resultJson.put("subjects", subjects);
|
|
|
resultJson.put("subjectName", subjectName);
|
|
|
resultJson.put("class_room_count", classRoomCount);
|
|
|
resultJson.put("classArr", classArr);
|
|
|
resultJson.put("classCount", classArr.size());
|
|
|
resultJson.put("roomArr", roomArr);
|
|
|
resultJson.put("plan_id", planId);
|
|
|
resultJson.put("plan_name", planName);
|
|
|
resultJson.put("start_time", startTime.substring(0, startTime.length()-2));
|
|
|
resultJson.put("end_time", endTime.substring(0, startTime.length()-2));
|
|
|
resultJson.put("type", type);
|
|
|
resultJson.put("curriculum_id", curriculumId);
|
|
|
resultJson.put("max_student_count", maxStudentCount);
|
|
|
resultJson.put("min_student_count", minStudentCount);
|
|
|
resultJson.put("sequence_stage", sequenceStage);
|
|
|
resultJson.put("sequence_year", sequenceYear);
|
|
|
resultJson.put("test_id", testId);
|
|
|
resultJson.put("test_index", testIndex);
|
|
|
resultJson.put("course_type", courseType);
|
|
|
resultJson.put("is_report", isReport);
|
|
|
resultJson.put("status", status);
|
|
|
resultJson.put("stage_id", record.get("stage_id"));
|
|
|
resultJson.put("entrance_year", record.get("grade"));
|
|
|
resultJson.put("bureau_id", record.get("bureau_id"));
|
|
|
resultJson.put("success", true);
|
|
|
resultJson.put("info", "查询成功");
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
|
|
public JSONObject saveCoursePlanStatus(String planId, String status) {
|
|
|
JSONObject resultJson= new JSONObject();
|
|
|
SelectCoursePlanModel.dao.updatePlanStatus(status, planId,"");
|
|
|
resultJson.put("info", "操作成功");
|
|
|
resultJson.put("success", true);
|
|
|
if("4".equals(status)){
|
|
|
//这直接调用service
|
|
|
CoreCourseService.service.startSelectCoursePlan(planId);
|
|
|
}
|
|
|
return resultJson;
|
|
|
}
|
|
|
private JSONObject checkTheSelectionToBegin(String planId, String status){
|
|
|
JSONObject resultJson=new JSONObject();
|
|
|
resultJson.put("success", false);
|
|
|
/*校验课程计划下数据*/
|
|
|
JSONObject planInfo = getPlanInfo(planId);
|
|
|
//校验选课开始时 是否有班级在别的选课计划下进行选课
|
|
|
if("2".equals(status)){
|
|
|
//求出当前计划的班级Ids
|
|
|
List<Record> classList = SelectCoursePlanModel.dao.getClassListByplanId(planId);
|
|
|
String classIds = ToolsUtil.getIds(classList, "class_id");
|
|
|
List<Record> planList = SelectCoursePlanModel.dao.getPlanListByClassIdAndStatus(classIds,"2,3",planId);
|
|
|
if(!COMMON.isEmpty(planList)){
|
|
|
resultJson.put("info", "存在部分班级正在选科!");
|
|
|
return resultJson ;
|
|
|
}
|
|
|
String curriculumId=String.valueOf(planInfo.get("curriculum_id"));
|
|
|
JSONObject subjectTimeJson= CurriculumPlanService.service.getSubjectTimeList(curriculumId, "1");
|
|
|
//校验 所有科目是否有课时(所有)
|
|
|
JSONArray subjectArray = subjectTimeJson.getJSONArray("subject_list");
|
|
|
JSONArray baseSubjectArray = subjectTimeJson.getJSONArray("base_subject_list");
|
|
|
baseSubjectArray.addAll(subjectArray);
|
|
|
int timeSum = 0 ;
|
|
|
for(int i = 0 ;i <baseSubjectArray.size() ; i++){
|
|
|
JSONObject json = baseSubjectArray.getJSONObject(i);
|
|
|
int time = json.getIntValue("times");
|
|
|
int timesChoice = json.getIntValue("times_choice");
|
|
|
timeSum += (time+timesChoice);
|
|
|
/*学科课时是否是100%*/
|
|
|
String percentage = json.getString("percentage");
|
|
|
if(!"100%".equals(percentage)){
|
|
|
resultJson.put("info", "部分教师没有设置课时!");
|
|
|
return resultJson ;
|
|
|
}
|
|
|
/*部分学科没有设置教师*/
|
|
|
if(COMMON.isEmpty(json.get("personNames"))){
|
|
|
resultJson.put("info", json.get("subject_name")+"..没有设置教师!");
|
|
|
return resultJson ;
|
|
|
}
|
|
|
}
|
|
|
if(timeSum == 0){
|
|
|
resultJson.put("info", "所对应的课程计划中所有科目课时为0!");
|
|
|
return resultJson ;
|
|
|
}
|
|
|
}
|
|
|
if("4".equals(status)){
|
|
|
JSONObject planInfoCount = CoreUtil.getCoursePlanStudentCount(planId);
|
|
|
long finishPersonCount = planInfoCount.getLongValue("finish_person_count");
|
|
|
if(0==finishPersonCount){
|
|
|
resultJson.put("info", "当前选科计划中没有学生进行志愿选择,不允许进行结束操作!");
|
|
|
resultJson.put("error", 1);
|
|
|
return resultJson ;
|
|
|
}
|
|
|
/*校验年级课时*/
|
|
|
String bureauId=String.valueOf(planInfo.get("bureau_id"));
|
|
|
String year=String.valueOf(planInfo.get("entrance_year"));
|
|
|
String stageId=String.valueOf(planInfo.get("stage_id"));
|
|
|
JSONObject dayJson = CourseSelectTimeService.service.getCoursetableTime(bureauId, year, stageId,"");
|
|
|
if(COMMON.isEmpty(dayJson)){
|
|
|
resultJson.put("info","未设置"+year+"年级课时!");
|
|
|
resultJson.put("error", 1);
|
|
|
return resultJson ;
|
|
|
}
|
|
|
/*查询学生志愿 是否正常*/
|
|
|
List<Record> studentList = StudentApplyModel.dao.getStudentApplyList(planId);
|
|
|
if(!COMMON.isEmpty(studentList)){
|
|
|
resultJson.put("info", "学生志愿存在异常,联系管理员!");
|
|
|
resultJson.put("error", 1);
|
|
|
return resultJson ;
|
|
|
}
|
|
|
/*校验选科计划是否是套餐模式*/
|
|
|
if(!checkSubectType(planInfo)){
|
|
|
resultJson.put("info", "部分选科志愿结果与计划不匹配,是否继续? 选择确定,将以当前志愿结果进行分班排课,与当前选科计划不一致!");
|
|
|
resultJson.put("error", 2);
|
|
|
return resultJson ;
|
|
|
}
|
|
|
}
|
|
|
resultJson.put("success", true);
|
|
|
resultJson.put("info", Constant.SUCCESS_INFO);
|
|
|
return resultJson;
|
|
|
}
|
|
|
public void updateCoursePlanIsRelease(String planId,String IsRelease){
|
|
|
SelectCoursePlanModel.dao.updateCoursePlanIsRelease(String.valueOf(planId), IsRelease);
|
|
|
}
|
|
|
private boolean checkSubectType(JSONObject planInfo){
|
|
|
String subjectType = String.valueOf(planInfo.get("subject_type"));
|
|
|
String planId = String.valueOf(planInfo.get("plan_id"));
|
|
|
//非全科模式
|
|
|
if(!"0".equals(subjectType)){
|
|
|
String subjects = String.valueOf(planInfo.get("subjects"));
|
|
|
List<Record> list = StudentApplyModel.dao.getStudentApplyNotInSubjectIds(planId, subjects);
|
|
|
if(!COMMON.isEmpty(list)){
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true ;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Description: 校验 是否存在正在发布中的 选科计划
|
|
|
* @author :周明升
|
|
|
* @date: 2019-1-7 上午8:46:49
|
|
|
* @return: JSONObject
|
|
|
* @throws
|
|
|
*/
|
|
|
public JSONObject checkPlanExistIsRelease(String bureauId,String planId) {
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
List<Record> list = SelectCoursePlanModel.dao.getCoursePlanListByRelease(bureauId, "2");
|
|
|
if(!COMMON.isEmpty(list)){
|
|
|
returnJson.put("success", Constant.FALSE);
|
|
|
returnJson.put("info", "存在正在发布中的选科计划,不允许发布!");
|
|
|
return returnJson ;
|
|
|
}
|
|
|
// String personIds = getNotInClassStudent(planId);
|
|
|
// if(!COMMON.isEmpty(personIds)){
|
|
|
// returnJson.put("success", Constant.FALSE);
|
|
|
// returnJson.put("info", "存在未成班的学生,不允许发布");
|
|
|
// return returnJson ;
|
|
|
// }
|
|
|
returnJson.put("success", Constant.TRUE);
|
|
|
returnJson.put("info", Constant.SUCCESS_INFO);
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
public JSONObject checkPlanChangeStatus(String planId, String status) {
|
|
|
JSONObject returnJson= checkTheSelectionToBegin(planId, status);
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
public JSONObject getChoiceExam(String personId) {
|
|
|
return SelectCourseUtil.getChoiceExam(personId);
|
|
|
}
|
|
|
public void updateBaseClassId(List<Record> list){
|
|
|
SelectCoursePlanModel.dao.updateBaseClassId(list);
|
|
|
}
|
|
|
/**
|
|
|
* @Description: 保存发布后的班级分层信息
|
|
|
* @author :周明升
|
|
|
* @date: 2019-2-23 下午4:19:27
|
|
|
* @return: void
|
|
|
* @throws
|
|
|
*/
|
|
|
public void inserCoursePlanClassRelease(int planId, List<Record> list) {
|
|
|
/*删除之前的发布的班级记录*/
|
|
|
SelectCoursePlanModel.dao.delCoursePlanClassRelease(planId);
|
|
|
List<Record> batchList = new ArrayList<>() ;
|
|
|
for(Record record : list ){
|
|
|
Record recordOb = new Record() ;
|
|
|
recordOb.set("plan_id", planId);
|
|
|
recordOb.set("class_id", record.get("class_id"));
|
|
|
recordOb.set("level", record.get("level"));
|
|
|
recordOb.set("base_class_id", record.get("base_class_id"));
|
|
|
recordOb.set("base_class_type", record.get("base_class_type"));
|
|
|
recordOb.set("classtype_teaching", record.get("classtype_teaching"));
|
|
|
String baseClassType = String.valueOf(record.get("base_class_type"));
|
|
|
String classtypeTeaching = String.valueOf(record.get("classtype_teaching"));
|
|
|
int classType = SelectCourseBaseService.service.getCusinessClassType(baseClassType, classtypeTeaching);
|
|
|
recordOb.set("class_type",classType);
|
|
|
batchList.add(recordOb);
|
|
|
}
|
|
|
SelectCoursePlanModel.dao.batchInserCoursePlanClassRelease(batchList);
|
|
|
}
|
|
|
|
|
|
}
|