Bladeren bron

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

yonge 5 jaren geleden
bovenliggende
commit
30785627d3

+ 31 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1359,6 +1359,10 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void coursePostpone(CoursePostponeDto coursePostPoneInfo) {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (null == user) {
+            throw new BizException("获取用户信息失败");
+        }
         if(StringUtils.isBlank(coursePostPoneInfo.getClassGroupIds())){
             throw new BizException("请指定班级");
         }
@@ -1384,8 +1388,17 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
         classGroupCourseSchedulesWithDate.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 
+        List<CourseScheduleModifyLog> scheduleModifyLogs = new ArrayList<>(classGroupCourseSchedulesWithDate.size());
+        Date date = new Date();
+        //保存修改记录
         for (int i=0;i<classGroupCourseSchedulesWithDate.size();i++) {
             CourseSchedule courseSchedule=classGroupCourseSchedulesWithDate.get(i);
+            CourseScheduleModifyLog scheduleModifyLog = new CourseScheduleModifyLog();
+            scheduleModifyLog.setCourseScheduleId(courseSchedule.getId());
+            scheduleModifyLog.setPreviousCourseSchedule(JSONObject.toJSONString(courseSchedule));
+            scheduleModifyLog.setCreateTime(date);
+            scheduleModifyLog.setOperatorId(user.getId());
+
             calendar.setTime(courseSchedule.getClassDate());
             calendar.add(Calendar.DATE, betweenDays);
             try {
@@ -1405,9 +1418,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                 continue;
             }
             classGroupCourseSchedulesWithDate.get(i).setClassDate(calendar.getTime());
+            scheduleModifyLog.setCurrentCourseSchedule(JSONObject.toJSONString(courseSchedule));
+            scheduleModifyLogs.add(scheduleModifyLog);
         }
 //        checkNewCourseSchedules(classGroupCourseSchedulesWithDate,false);
         courseScheduleDao.batchUpdate(classGroupCourseSchedulesWithDate);
+        courseScheduleModifyLogDao.batchInsert(scheduleModifyLogs);
     }
 
     @Override
@@ -1625,6 +1641,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
     @Transactional(rollbackFor = Exception.class)
     public void classStartDateAdjust(List<CourseSchedule> newCourseSchedules) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (null == sysUser) {
+            throw new BizException("获取用户信息失败");
+        }
         List<Long> newCourseScheduleIds = newCourseSchedules.stream().map(CourseSchedule::getId).collect(Collectors.toList());
         //获取对应未修改的课程列表
         List<CourseSchedule> oldCourseScheduleList = courseScheduleDao.findByCourseScheduleIds(newCourseScheduleIds);
@@ -1651,8 +1670,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         Map<Long, CourseSchedule> oldCourseSchedules = new HashMap<>();
 
         List<Integer> classGroupIds = oldCourseScheduleList.stream().map(CourseSchedule::getClassGroupId).collect(Collectors.toList());
-        List<ClassGroup> classGroups = classGroupDao.findByClassGroupIds(classGroupIds);
-        Map<Integer, ClassGroup> idClassGroupMap = classGroups.stream().collect(Collectors.toMap(ClassGroup::getId, classGroup -> classGroup));
+//        List<ClassGroup> classGroups = classGroupDao.findByClassGroupIds(classGroupIds);
+//        Map<Integer, ClassGroup> idClassGroupMap = classGroups.stream().collect(Collectors.toMap(ClassGroup::getId, classGroup -> classGroup));
 
         SysConfig advanceLeaveHoursConfig = sysConfigService.findByParamName(SysConfigService.ENABLE_TEACHER_COURSE_ADJUST_DEFAULT_HOURS);
         Integer advanceLeaveHours=advanceLeaveHoursConfig.getParanValue(Integer.class);
@@ -1662,9 +1681,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         List<Map<Integer, Integer>> classGroupStudentNumMaps = classGroupStudentMapperDao.countClassGroupsStudentNum(classGroupIds, ClassGroupStudentStatusEnum.NORMAL);
         Map<Integer, Long> classGroupStudentNumMap = MapUtil.convertIntegerMap(classGroupStudentNumMaps);
 
+        //记录调整日志
+        List<CourseScheduleModifyLog> courseScheduleModifyLogs = new ArrayList<>(oldCourseScheduleList.size());
         newCourseSchedules.forEach(newCourseSchedule -> {
-
+            CourseScheduleModifyLog scheduleModifyLog = new CourseScheduleModifyLog();
             CourseSchedule oldCourseSchedule = oldCourseScheduleMap.get(newCourseSchedule.getId()).get(0);
+            scheduleModifyLog.setPreviousCourseSchedule(JSONObject.toJSONString(oldCourseSchedule));
+            scheduleModifyLog.setCreateTime(now);
+            scheduleModifyLog.setCourseScheduleId(oldCourseSchedule.getId());
+            scheduleModifyLog.setOperatorId(sysUser.getId());
 
             if (!sysUser.getUserType().contains("SYSTEM") && sysUser.getUserType().contains("TEACHER")) {
                 Long normalStudentNum = classGroupStudentNumMap.get(oldCourseSchedule.getClassGroupId());
@@ -1826,6 +1851,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
             oldCourseSchedule.setActualTeacherId(newCourseSchedule.getActualTeacherId());
             courseScheduleDao.update(oldCourseSchedule);
+            scheduleModifyLog.setCurrentCourseSchedule(JSONObject.toJSONString(oldCourseSchedule));
+            courseScheduleModifyLogs.add(scheduleModifyLog);
             //删除被修改的教师课酬记录和考勤记录
             if (!CollectionUtils.isEmpty(beReplaceTeacherIds)) {
 //				courseScheduleTeacherSalaryDao.batchUpdateTeacherExpectSalary(newCourseSchedule.getId().intValue(),beReplaceTeacherIds);
@@ -1848,7 +1875,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                 vipGroupService.checkVipCourseIsInScore(Long.valueOf(oldCourseScheduleList.get(0).getMusicGroupId()));
             }
         }
-
+        courseScheduleModifyLogDao.batchInsert(courseScheduleModifyLogs);
 //        if(oldCourseScheduleList.get(0).getGroupType().equals(GroupType.VIP)){
 //            courseScheduleStudentPaymentService.updateVipGiveCourse(Long.valueOf(oldCourseScheduleList.get(0).getMusicGroupId()));
 //        }

+ 4 - 42
mec-biz/src/main/resources/config/mybatis/TeacherFreeTimeMapper.xml

@@ -44,48 +44,10 @@
 
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.TeacherFreeTime">
-		UPDATE teacher_free_time
-		<set>
-			<if test="monday != null">
-				monday_ = #{monday},
-			</if>
-			<if test="userId != null">
-				user_id_ = #{userId},
-			</if>
-			<if test="thursday != null">
-				thursday_ = #{thursday},
-			</if>
-			<if test="holiday != null">
-				holiday_ = #{holiday},
-			</if>
-			<if test="holiday == null">
-				holiday_ = null,
-			</if>
-			<if test="updateTime != null">
-				update_time_ = #{updateTime},
-			</if>
-			<if test="saturday != null">
-				saturday_ = #{saturday},
-			</if>
-			<if test="wednesday != null">
-				wednesday_ = #{wednesday},
-			</if>
-			<if test="friday != null">
-				friday_ = #{friday},
-			</if>
-			<if test="tuesday != null">
-				tuesday_ = #{tuesday},
-			</if>
-			<if test="sunday != null">
-				sunday_ = #{sunday},
-			</if>
-			<if test="totalTimes != null">
-				total_times_ = #{totalTimes},
-			</if>
-			<if test="totalTimes == null">
-				total_times_ = null,
-			</if>
-		</set>
+		UPDATE teacher_free_time SET
+		monday_ = #{monday},thursday_ = #{thursday},holiday_ = #{holiday},update_time_ = #{updateTime},
+		saturday_ = #{saturday},wednesday_ = #{wednesday},friday_ = #{friday},tuesday_ = #{tuesday},
+		sunday_ = #{sunday},total_times_ = #{totalTimes}
 		WHERE id_ = #{id}
 	</update>
 

+ 11 - 10
mec-web/src/main/java/com/ym/mec/web/controller/TeacherFreeTimeController.java

@@ -1,19 +1,18 @@
 package com.ym.mec.web.controller;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-
-import java.util.Date;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-
 import com.ym.mec.biz.dal.entity.TeacherFreeTime;
 import com.ym.mec.biz.service.TeacherFreeTimeService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 @RequestMapping("teacherFreeTime")
 @Api(tags = "老师空余时间设置服务")
@@ -32,12 +31,14 @@ public class TeacherFreeTimeController extends BaseController {
 	@ApiOperation("单查询")
 	@ApiImplicitParam(name = "id", value = "ID编号", required = true, dataType = "Integer", paramType = "path")
 	@GetMapping(value = "/query")
+	@PreAuthorize("@pcs.hasPermissions('teacherFreeTime/query')")
 	public Object query(Integer id) {
 		return succeed(teacherFreeTimeService.findTeacherFreeTime(id));
 	}
 
 	@ApiOperation("新增")
 	@PostMapping(value = "/updateSet")
+	@PreAuthorize("@pcs.hasPermissions('teacherFreeTime/updateSet')")
 	public Object add(TeacherFreeTime teacherFreeTime) {
 		teacherFreeTimeService.updateSet(teacherFreeTime);
 		return succeed();