You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
5.0 KiB

package com.dsideal.newUniversityExamination.selectcourse.controller;
import java.util.HashMap;
import com.alibaba.fastjson.JSONObject;
import com.dsideal.exception.SelectCourseException;
import com.dsideal.newUniversityExamination.exception.NewUniversityExaminationException;
import com.dsideal.newUniversityExamination.selectcourse.service.CoursetableRulesService;
import com.dsideal.newUniversityExamination.selectcourse.util.SelectCourseUtil;
import com.dsideal.newUniversityExamination.util.Constant;
import com.dsideal.newUniversityExamination.util.ParamUtil;
import com.jfinal.core.Controller;
/**
* 教师规则—不授课
* 尚显奇 2018-04-10
* @author Administrator
*
*/
public class SchedulingLockTeacherController extends Controller {
/**教师规则*/
private final String type ="3";
/**不授课*/
private final String typeSecondary="11";
/**
* 保存教师规则—不授课 规则内容
*/
public void saveLockTeacher(){
JSONObject returnJson=new JSONObject();
String taskId=getPara("task_id");
String teacherArrayStr=getPara("teacher_array");
String classNumberArrayStr=getPara("class_number_array");
//参数非空判断
HashMap<String,String> parameters=new HashMap<>(3);
parameters.put("teacher_array", teacherArrayStr);
parameters.put("task_id", taskId);
parameters.put("class_number_array", classNumberArrayStr);
try {
SelectCourseUtil.checkoutParameters(parameters);
returnJson = CoursetableRulesService.service.saveLockTeacher(taskId, type, typeSecondary, teacherArrayStr, classNumberArrayStr);
}catch (SelectCourseException e) {
returnJson.put("success", Constant.FALSE);
returnJson.put("info", e.getMessage());
}catch (Exception e){
returnJson.put("success", Constant.FALSE);
returnJson.put("info", Constant.FALSE_INFO);
}
renderJson(returnJson);
}
/**
* 查询教师规则—不授课 规则内容
*/
public void getLockTeacher(){
JSONObject returnJson=new JSONObject();
String taskId=getPara("task_id");
String teacherArrayStr=getPara("teacher_array");
//参数非空判断
HashMap<String,String> parameters=new HashMap<>(2);
parameters.put("teacher_array", teacherArrayStr);
parameters.put("task_id", taskId);
try {
SelectCourseUtil.checkoutParameters(parameters);
returnJson = CoursetableRulesService.service.getLockTeacher(taskId, teacherArrayStr);
}catch (SelectCourseException e) {
returnJson.put("success", Constant.FALSE);
returnJson.put("info", e.getMessage());
}
renderJson(returnJson);
}
/**
* 教师规则-不授课获取所有规则
*/
public void getLockTeacherList(){
JSONObject returnJson=new JSONObject();
String taskId=getPara("task_id");
int pageNumber=getParaToInt("pageNumber") == null ? 1: getParaToInt("pageNumber");
int pageSize=getParaToInt("pageSize") == null ? 20: getParaToInt("pageSize");
//参数非空判断
HashMap<String,String> parameters=new HashMap<>(1);
parameters.put("task_id", taskId);
try {
SelectCourseUtil.checkoutParameters(parameters);
returnJson = CoursetableRulesService.service.getLockTeacherJson (taskId, pageNumber, pageSize);
}catch (SelectCourseException e) {
returnJson.put("success", Constant.FALSE);
returnJson.put("info", e.getMessage());
}
returnJson.put("type", type);
returnJson.put("type_secondary", typeSecondary);
renderJson(returnJson);
}
public void saveStepYearTeacher(){
JSONObject returnJson = new JSONObject();
try {
String taskIds = ParamUtil.isEmpty(getPara("task_ids"),"task_ids");
String taskId = ParamUtil.isEmpty(getPara("task_id"),"task_id");
String type = ParamUtil.isEmpty(getPara("type"),"type");
String typeSecondary = ParamUtil.isEmpty(getPara("type_secondary"),"type_secondary");
int subjectId = ParamUtil.isNumber(getPara("subject_id"),"subject_id");
int personId = ParamUtil.isNumber(getPara("person_id"),"person_id");
returnJson = CoursetableRulesService.service.saveStepYearTeacher(type,typeSecondary,taskId,taskIds,subjectId,personId);
} catch (NewUniversityExaminationException e) {
returnJson.put("success", Constant.FALSE);
returnJson.put("info",e.getMessage());
}
renderJson(returnJson);
}
public void getStepYearList(){
JSONObject returnJson = new JSONObject();
try {
int taskId = ParamUtil.isNumber(getPara("task_id"),"task_id");
int type = ParamUtil.isNumber(getPara("type"),"type");
int typeSecondary = ParamUtil.isNumber(getPara("type_secondary"),"type_secondary");
int pageNumber = ParamUtil.isNumber(getPara("page_number"),"page_number");
int pageSize = ParamUtil.isNumber(getPara("page_size"),"page_size");
returnJson = CoursetableRulesService.service.getStepYearList(type,typeSecondary,taskId,pageNumber,pageSize);
} catch (NewUniversityExaminationException e) {
returnJson.put("success", Constant.FALSE);
returnJson.put("info",e.getMessage());
}
renderJson(returnJson);
}
}