diff --git a/src/main/java/cn/com/tenlion/controller/api/classplan/ClassPlanController.java b/src/main/java/cn/com/tenlion/controller/api/classplan/ClassPlanController.java index 6cffdd8..3389dda 100644 --- a/src/main/java/cn/com/tenlion/controller/api/classplan/ClassPlanController.java +++ b/src/main/java/cn/com/tenlion/controller/api/classplan/ClassPlanController.java @@ -42,7 +42,7 @@ public class ClassPlanController extends DefaultBaseController { @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PostMapping("save") @CheckRequestBodyAnnotation - public SuccessResult save(@RequestBody JSONObject obj) { + public SuccessResult save(@RequestBody JSONObject obj) throws Exception{ classPlanService.saveJson(obj); return new SuccessResult(); } diff --git a/src/main/java/cn/com/tenlion/dao/teacher/ITeacherDao.java b/src/main/java/cn/com/tenlion/dao/teacher/ITeacherDao.java index ccb1e0a..7525d01 100644 --- a/src/main/java/cn/com/tenlion/dao/teacher/ITeacherDao.java +++ b/src/main/java/cn/com/tenlion/dao/teacher/ITeacherDao.java @@ -60,4 +60,17 @@ public interface ITeacherDao { * @return */ Map count(Map params); + + /** + * 根据身份证查询讲师授课列表 + * @param idCardNumber + * @return + */ + List> listTeacherLessonsTime(String idCardNumber); + + /** + * 保存讲师授课记录 + * @param params + */ + void saveTeacherLessonsTime(Map params); } diff --git a/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java b/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java index d2a0f8e..8471bce 100644 --- a/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java +++ b/src/main/java/cn/com/tenlion/service/classplan/IClassPlanService.java @@ -207,7 +207,7 @@ public interface IClassPlanService { * 保存培训计划 * @param obj */ - void saveJson(JSONObject obj); + void saveJson(JSONObject obj) throws Exception; /** * 提交培训计划报备 diff --git a/src/main/java/cn/com/tenlion/service/classplan/impl/ClassPlanServiceImpl.java b/src/main/java/cn/com/tenlion/service/classplan/impl/ClassPlanServiceImpl.java index 6adce95..f2f19f8 100644 --- a/src/main/java/cn/com/tenlion/service/classplan/impl/ClassPlanServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/classplan/impl/ClassPlanServiceImpl.java @@ -9,6 +9,7 @@ import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO; import cn.com.tenlion.pojo.dtos.classplan.ClassPlanReportExamDTO; import cn.com.tenlion.pojo.dtos.distributioncard.DistributionCardDTO; import cn.com.tenlion.pojo.dtos.examapply.ExamApplyDTO; +import cn.com.tenlion.pojo.dtos.teacher.TeacherDTO; import cn.com.tenlion.pojo.dtos.worktype.WorkTypeDTO; import cn.com.tenlion.pojo.pos.classplan.ClassPlanPO; import cn.com.tenlion.pojo.vos.classplan.ClassPlanVO; @@ -19,26 +20,27 @@ import cn.com.tenlion.service.classplan.IClassPlanService; import cn.com.tenlion.service.examapply.IExamApplyService; import cn.com.tenlion.service.examcheck.IExamCheckService; import cn.com.tenlion.service.examination.distributioncard.IDistributionCardService; +import cn.com.tenlion.service.service.ITeacherService; import cn.com.tenlion.service.worktype.IWorkTypeService; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.exceptions.SaveException; import ink.wgink.module.dictionary.pojo.dtos.DataDTO; import ink.wgink.module.dictionary.service.IDataService; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.util.UUIDUtil; +import ink.wgink.util.date.DateUtil; import ink.wgink.util.map.HashMapUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * @ClassName: ClassPlanServiceImpl @@ -71,6 +73,8 @@ public class ClassPlanServiceImpl extends DefaultBaseService implements IClassPl @Autowired // 准考证 private IDistributionCardService distributionCardService; + @Autowired + private ITeacherService teacher; @Override public void save(ClassPlanVO classPlanVO) { @@ -102,8 +106,12 @@ public class ClassPlanServiceImpl extends DefaultBaseService implements IClassPl } @Override - public void saveJson(JSONObject obj) { + public void saveJson(JSONObject obj) throws Exception{ + // 校验教师是否存在授课冲突 + String planStartTime = obj.getString("planStartTime"); + String planEndTime = obj.getString("planEndTime"); String classPlanId = UUIDUtil.getUUID(); + //保存开班计划 ClassPlanVO classPlanVO = new ClassPlanVO(); classPlanVO.setClassPlanId(classPlanId); classPlanVO.setOrgId(obj.getString("orgId")); @@ -112,25 +120,81 @@ public class ClassPlanServiceImpl extends DefaultBaseService implements IClassPl classPlanVO.setPlanType(obj.getString("planType")); classPlanVO.setProjectCatalogId(obj.getString("projectCatalogId")); classPlanVO.setWorkerCatalog(obj.getString("workerCatalog")); - classPlanVO.setPlanPersonNum(Integer.parseInt(obj.getString("planPersonNum"))); classPlanVO.setPlanStartTime(obj.getString("planStartTime")); classPlanVO.setPlanEndTime(obj.getString("planEndTime")); - classPlanVO.setSignUpStartTime(obj.getString("signUpStartTime")); - classPlanVO.setSignUpEndTime(obj.getString("signUpEndTime")); classPlanVO.setPlanAddress(obj.getString("planAddress")); classPlanVO.setChargePerson(obj.getString("chargePerson")); classPlanVO.setChargePersonTel(obj.getString("chargePersonTel")); - classPlanVO.setReportType("0"); - classPlanVO.setReportReason(""); Map params = HashMapUtil.beanToMap(classPlanVO); params.put("classPlanId", classPlanId); setSaveInfo(params); classPlanDao.save(params); + // 开班申请提交后是否需要先将考试人员信息从报名表中转移到班级表 //保存课程及讲师 + List dayList = new ArrayList<>(); + long daySub = DateUtil.getDaySub("2021-05-15", "2021-05-15"); + if(daySub == 0L){ + dayList.add(planStartTime); + } else { + for(long i = 0; i <= daySub; i++){ + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); + Date startDate = sd.parse(planStartTime); + String formatDate = sd.format(startDate.getTime() + (i * 24 * 60 * 60 * 1000)); + dayList.add(formatDate); + } + } JSONArray array = obj.getJSONArray("lessonList"); params.clear(); for(int i = 0; i < array.size(); i++){ JSONObject item = array.getJSONObject(i); + String lessonStartTime = item.getString("lessonStartTime") + ":00"; + String lessonEndTime = item.getString("lessonEndTime") + ":00"; + // 查询当前教师信息 + TeacherDTO teacherDTO = teacher.getById(item.getString("teacherId")); + List> tlList = teacher.listTeacherLessonsTime(teacherDTO.getIdCardNumber()); + if(tlList != null && tlList.size() > 0){ + for(String tempDate : dayList){ + String sDateTime = tempDate + " " + lessonStartTime; + String eDateTime = tempDate + " " + lessonEndTime; + for(Map tlMap : tlList){ + String ssDateTime = tlMap.get("start_time").toString(); + String eeDateTime = tlMap.get("end_time").toString(); + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if(sd.parse(eDateTime).getTime() < sd.parse(ssDateTime).getTime() + || sd.parse(sDateTime).getTime() > sd.parse(eeDateTime).getTime()){ + //...没有发生冲突 + } else { + throw new SaveException(tlMap.toString()); + } + } + params.put("classPlanId",classPlanId); + params.put("teacherId",teacherDTO.getTeacherId()); + params.put("teacherIdCard", teacherDTO.getIdCardNumber()); + params.put("orgId",teacherDTO.getOrgId()); + params.put("projectCatalogId",obj.getString("projectCatalogId")); + params.put("workerCatalog",obj.getString("workerCatalog")); + params.put("lessonId",item.getString("lessonId")); + params.put("startTime",sDateTime); + params.put("endTime",eDateTime); + teacher.saveTeacherLessonsTime(params); + } + } else { + for(String tempDate : dayList){ + String sDateTime = tempDate + " " + lessonStartTime; + String eDateTime = tempDate + " " + lessonEndTime; + params.put("classPlanId",classPlanId); + params.put("teacherId",teacherDTO.getTeacherId()); + params.put("teacherIdCard", teacherDTO.getIdCardNumber()); + params.put("orgId",teacherDTO.getOrgId()); + params.put("projectCatalogId",obj.getString("projectCatalogId")); + params.put("workerCatalog",obj.getString("workerCatalog")); + params.put("lessonId",item.getString("lessonId")); + params.put("startTime",sDateTime); + params.put("endTime",eDateTime); + teacher.saveTeacherLessonsTime(params); + } + } + params.clear(); params.put("classPlanId",classPlanId); params.put("lessonId",item.getString("lessonId")); params.put("teacherId",item.getString("teacherId")); diff --git a/src/main/java/cn/com/tenlion/service/service/ITeacherService.java b/src/main/java/cn/com/tenlion/service/service/ITeacherService.java index 271c15d..dbf4978 100644 --- a/src/main/java/cn/com/tenlion/service/service/ITeacherService.java +++ b/src/main/java/cn/com/tenlion/service/service/ITeacherService.java @@ -90,4 +90,17 @@ public interface ITeacherService { * @return */ Map count(String orgId); + + /** + * 根据身份证查询教师授课记录 + * @param idCardNumber + * @return + */ + List> listTeacherLessonsTime(String idCardNumber); + + /** + * 保存讲师授课时间记录 + * @param params + */ + void saveTeacherLessonsTime(Map params); } diff --git a/src/main/java/cn/com/tenlion/service/service/impl/TeacherServiceImpl.java b/src/main/java/cn/com/tenlion/service/service/impl/TeacherServiceImpl.java index eedd7b6..7b9a36c 100644 --- a/src/main/java/cn/com/tenlion/service/service/impl/TeacherServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/service/impl/TeacherServiceImpl.java @@ -130,6 +130,15 @@ public class TeacherServiceImpl extends DefaultBaseService implements ITeacherSe return institutionDTO; } + @Override + public List> listTeacherLessonsTime(String idCardNumber) { + return teacherDao.listTeacherLessonsTime(idCardNumber); + } + + @Override + public void saveTeacherLessonsTime(Map params) { + teacherDao.saveTeacherLessonsTime(params); + } public Map count(String orgId){ Map params = new HashMap<>(); diff --git a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml index 7d459e3..7df455e 100644 --- a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml +++ b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml @@ -212,4 +212,19 @@ WHERE is_delete = 0 AND org_id = #{orgId} + + + + INSERT INTO e_teach_lessons_time ( + teacher_id,teacher_id_card,org_id,project_catalog_id,worker_catalog,lesson_id,start_time,end_time + ) VALUES( + #{teacherId}, #{teacherIdCard},#{orgId},#{projectCatalogId},#{workerCatalog},#{lessonId}, #{startTime},#{endTime} + ) + + \ No newline at end of file diff --git a/src/main/resources/static/route/apply/audit.html b/src/main/resources/static/route/apply/audit.html index 73e25c4..092df64 100644 --- a/src/main/resources/static/route/apply/audit.html +++ b/src/main/resources/static/route/apply/audit.html @@ -12,14 +12,14 @@ -
+
-
+
diff --git a/src/main/resources/static/route/apply/show.html b/src/main/resources/static/route/apply/show.html index 0cfa160..087048f 100644 --- a/src/main/resources/static/route/apply/show.html +++ b/src/main/resources/static/route/apply/show.html @@ -12,14 +12,8 @@ -
+
-
@@ -164,7 +158,7 @@ -
+