|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.dsideal.base.Teacher.Controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.PhoneUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.dsideal.base.ExcelImportTemplate.TeacherImportExcelUtil;
|
|
|
|
@ -14,7 +15,6 @@ import com.jfinal.ext.interceptor.GET;
|
|
|
|
|
import com.jfinal.ext.interceptor.POST;
|
|
|
|
|
import com.jfinal.kit.PathKit;
|
|
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.upload.UploadFile;
|
|
|
|
@ -27,7 +27,7 @@ import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public class TeacherController extends Controller {
|
|
|
|
|
TeacherModel _teacherModel = new TeacherModel();
|
|
|
|
|
TeacherModel tm = new TeacherModel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -38,20 +38,20 @@ public class TeacherController extends Controller {
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsLoginInterface({})
|
|
|
|
|
@IsGuidInterface({"org_id"})
|
|
|
|
|
@EmptyInterface({"org_id", "person_name", "t_teaching_date", "xl_id", "zc_id", "xb", "mz", "t_duty_charge", "zzmm"})
|
|
|
|
|
@EmptyInterface({"org_id", "person_name", "t_teaching_date", "xl_id", "zc_id", "xb", "mz", "t_duty_charge", "zzmm", "telephone"})
|
|
|
|
|
@IsSysAdminInterface({"1", "4"})
|
|
|
|
|
@IsNumericInterface({"stage_id", "subject_id", "sort_id"})
|
|
|
|
|
@AuthorityInterface({})
|
|
|
|
|
@LengthInterface({"person_name,2,64", "xl_id,2,2", "zc_id,2,2"})
|
|
|
|
|
public void addTeacher(String org_id, String person_name, String t_teaching_date, String xl_id,
|
|
|
|
|
String zc_id, String xb, String mz, String t_duty_charge, String zzmm, String id_card, String birthday, int sort_id
|
|
|
|
|
String zc_id, String xb, String mz, String t_duty_charge, String zzmm, String id_card, String birthday, int sort_id, String telephone
|
|
|
|
|
, int stage_id, int subject_id) {
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
|
|
try {
|
|
|
|
|
//判断姓名长度
|
|
|
|
|
if (person_name.length() > 36) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "教师姓名长度不正确!");
|
|
|
|
|
resultJson.put("message", "职工姓名长度不正确!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -108,6 +108,23 @@ public class TeacherController extends Controller {
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//判断是不是合法的手机号
|
|
|
|
|
boolean isValid = PhoneUtil.isMobile(telephone);
|
|
|
|
|
if (!isValid) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "手机号码不正确!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//检查手机号码是不是唯一
|
|
|
|
|
Record rPerson = tm.getPersonByTelephone(telephone);
|
|
|
|
|
if (rPerson != null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "手机号码已存在!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取部门所在单位ID
|
|
|
|
|
String bureauId = rs.get(0).get("bureau_id").toString();
|
|
|
|
|
String cityId = rs.get(0).get("city_id").toString();
|
|
|
|
@ -123,22 +140,19 @@ public class TeacherController extends Controller {
|
|
|
|
|
//客户端ip_address
|
|
|
|
|
String ip_address = IpUtil.getIpAddr(getRequest());
|
|
|
|
|
|
|
|
|
|
if (_teacherModel.addTeacherInfo(pwd, person_name, org_id, xb, mz, id_card, birthday, originalPwd, cityId, areaId, mainSchoolId, bureauId, xl_id, stage_id, subject_id, zc_id, t_teaching_date, sort_id, t_duty_charge, zzmm, operator, ip_address)) {
|
|
|
|
|
if (tm.addTeacherInfo(pwd, person_name, org_id, xb, mz, id_card, birthday, originalPwd, cityId, areaId, mainSchoolId, bureauId, xl_id, stage_id, subject_id, zc_id, t_teaching_date, sort_id, t_duty_charge, zzmm, operator, ip_address, telephone)) {
|
|
|
|
|
resultJson.put("success", true);
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "增加教师异常!");
|
|
|
|
|
resultJson.put("message", "增加职工异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "增加教师异常!");
|
|
|
|
|
resultJson.put("message", "增加职工异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -159,25 +173,22 @@ public class TeacherController extends Controller {
|
|
|
|
|
try {
|
|
|
|
|
Page<?> dt;
|
|
|
|
|
if (person_name == null || person_name == "") {
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(_teacherModel.getTeacherListByOrgId(org_id, page, limit));
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(tm.getTeacherListByOrgId(org_id, page, limit));
|
|
|
|
|
} else {
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(_teacherModel.getTeacherListByOrgIdPersonName(org_id, person_name, page, limit));
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(tm.getTeacherListByOrgIdPersonName(org_id, person_name, page, limit));
|
|
|
|
|
}
|
|
|
|
|
if (dt == null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "获取教师列表异常!");
|
|
|
|
|
resultJson.put("message", "获取职工列表异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(dt));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "获取教师列表异常!");
|
|
|
|
|
resultJson.put("message", "获取职工列表异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -197,13 +208,13 @@ public class TeacherController extends Controller {
|
|
|
|
|
try {
|
|
|
|
|
Page<?> dt;
|
|
|
|
|
if (person_name == null || person_name == "") {
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(_teacherModel.getTeacherListByBureauId(bureau_id, page, limit));
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(tm.getTeacherListByBureauId(bureau_id, page, limit));
|
|
|
|
|
} else {
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(_teacherModel.getTeacherListByPersonNameAndBureauId(bureau_id, person_name, page, limit));
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(tm.getTeacherListByPersonNameAndBureauId(bureau_id, person_name, page, limit));
|
|
|
|
|
}
|
|
|
|
|
if (dt == null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "获取教师列表异常!");
|
|
|
|
|
resultJson.put("message", "获取职工列表异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
@ -213,7 +224,7 @@ public class TeacherController extends Controller {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "获取教师列表异常!");
|
|
|
|
|
resultJson.put("message", "获取职工列表异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -234,13 +245,13 @@ public class TeacherController extends Controller {
|
|
|
|
|
try {
|
|
|
|
|
Page<?> dt;
|
|
|
|
|
if (person_name == null || person_name == "") {
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(_teacherModel.getTeacherListByBureauId(bureau_id, 1, 10000));
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(tm.getTeacherListByBureauId(bureau_id, 1, 10000));
|
|
|
|
|
} else {
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(_teacherModel.getTeacherListByPersonNameAndBureauId(bureau_id, person_name, 1, 10000));
|
|
|
|
|
dt = CommonUtil.ConvertLoginRs(tm.getTeacherListByPersonNameAndBureauId(bureau_id, person_name, 1, 10000));
|
|
|
|
|
}
|
|
|
|
|
if (dt == null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "获取教师列表异常!");
|
|
|
|
|
resultJson.put("message", "获取职工列表异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
@ -253,14 +264,14 @@ public class TeacherController extends Controller {
|
|
|
|
|
String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xls";
|
|
|
|
|
ExcelExportUtil.export(dt, jo, excelFile);
|
|
|
|
|
//提供下载
|
|
|
|
|
String filename = "教师账号.xls";
|
|
|
|
|
String filename = "职工账号.xls";
|
|
|
|
|
renderFile(new File(excelFile), filename);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "获取教师列表异常!");
|
|
|
|
|
resultJson.put("message", "获取职工列表异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -278,7 +289,7 @@ public class TeacherController extends Controller {
|
|
|
|
|
@AuthorityInterface({})
|
|
|
|
|
public void getTeacherInfoByTeacherId(String person_id) {
|
|
|
|
|
try {
|
|
|
|
|
Record record = _teacherModel.getTeacherInfoByTeacherId(person_id);
|
|
|
|
|
Record record = tm.getTeacherInfoByTeacherId(person_id);
|
|
|
|
|
|
|
|
|
|
if (record != null) {
|
|
|
|
|
//替换掉职务与分管工作为JSON对象
|
|
|
|
@ -315,7 +326,7 @@ public class TeacherController extends Controller {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
record.set("success", false);
|
|
|
|
|
record.set("message", "获取教师信息异常,人员不存在!");
|
|
|
|
|
record.set("message", "获取职工信息异常,人员不存在!");
|
|
|
|
|
renderJson(record);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -323,9 +334,8 @@ public class TeacherController extends Controller {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("success", false);
|
|
|
|
|
record.set("message", "获取教师信息异常!");
|
|
|
|
|
record.set("message", "获取职工信息异常!");
|
|
|
|
|
renderJson(record);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -336,7 +346,7 @@ public class TeacherController extends Controller {
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsLoginInterface({})
|
|
|
|
|
@EmptyInterface({"person_id", "person_name", "org_id", "t_duty_charge", "xl_id", "zc_id", "xb", "mz", "zzmm"})
|
|
|
|
|
@EmptyInterface({"person_id", "person_name", "org_id", "t_duty_charge", "xl_id", "zc_id", "xb", "mz", "zzmm", "telephone"})
|
|
|
|
|
@IsNumericInterface({"sort_id", "stage_id", "subject_id"})
|
|
|
|
|
@IsSysAdminInterface({"1", "4"})
|
|
|
|
|
@AuthorityInterface({})
|
|
|
|
@ -345,14 +355,14 @@ public class TeacherController extends Controller {
|
|
|
|
|
String t_duty_charge, String xl_id,
|
|
|
|
|
String xb, String mz, String zzmm,
|
|
|
|
|
int sort_id, String zc_id, String org_id, String id_card, String birthday, String t_teaching_date,
|
|
|
|
|
int stage_id, int subject_id) {
|
|
|
|
|
int stage_id, int subject_id, String telephone) {
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
//判断姓名长度
|
|
|
|
|
if (person_name.length() > 36) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "教师姓名长度不正确!");
|
|
|
|
|
resultJson.put("message", "职工姓名长度不正确!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -401,28 +411,42 @@ public class TeacherController extends Controller {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断是不是合法的手机号
|
|
|
|
|
boolean isValid = PhoneUtil.isMobile(telephone);
|
|
|
|
|
if (!isValid) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "手机号码不正确!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//检查手机号码是不是唯一
|
|
|
|
|
Record rPerson = tm.getPersonByTelephone(telephone);
|
|
|
|
|
if (rPerson != null && !rPerson.getStr("person_id").equals(person_id)) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "手机号码已存在!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//操作人
|
|
|
|
|
String operator = getCookie("person_id");
|
|
|
|
|
//客户端ip_address
|
|
|
|
|
String ip_address = IpUtil.getIpAddr(getRequest());
|
|
|
|
|
|
|
|
|
|
if (_teacherModel.updateTeacher(person_id, person_name, xb, mz, id_card, birthday, xl_id, stage_id, subject_id, zc_id, t_teaching_date, sort_id, t_duty_charge, org_id, zzmm, operator, ip_address)) {
|
|
|
|
|
if (tm.updateTeacher(person_id, person_name, xb, mz, id_card, birthday, xl_id, stage_id, subject_id, zc_id, t_teaching_date, sort_id, t_duty_charge, org_id, zzmm, operator, ip_address,telephone)) {
|
|
|
|
|
resultJson.put("success", true);
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "修改教师信息异常!");
|
|
|
|
|
resultJson.put("message", "修改职工信息异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "修改教师信息异常!");
|
|
|
|
|
resultJson.put("message", "修改职工信息异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -448,7 +472,7 @@ public class TeacherController extends Controller {
|
|
|
|
|
for (int i = 0; i < teacherArr.length; i++) {
|
|
|
|
|
String teacherId = teacherArr[i];
|
|
|
|
|
|
|
|
|
|
if (!_teacherModel.deleteTeacher(teacherId, operator, ip_address)) {
|
|
|
|
|
if (!tm.deleteTeacher(teacherId, operator, ip_address)) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "删除教师异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
@ -485,7 +509,7 @@ public class TeacherController extends Controller {
|
|
|
|
|
String ip_address = IpUtil.getIpAddr(getRequest());
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < personIdArray.length; i++) {
|
|
|
|
|
_teacherModel.changeOrgByPersonIdAndOrgId(personIdArray[i], org_id, operator, ip_address);
|
|
|
|
|
tm.changeOrgByPersonIdAndOrgId(personIdArray[i], org_id, operator, ip_address);
|
|
|
|
|
}
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
|
|
resultJson.put("success", true);
|
|
|
|
|