CourseScheduleController.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. package com.ym.mec.web.controller;
  2. import io.swagger.annotations.Api;
  3. import io.swagger.annotations.ApiOperation;
  4. import io.swagger.annotations.ApiParam;
  5. import java.math.BigDecimal;
  6. import java.util.ArrayList;
  7. import java.util.Arrays;
  8. import java.util.Date;
  9. import java.util.List;
  10. import java.util.Map;
  11. import java.util.Objects;
  12. import java.util.stream.Collectors;
  13. import org.apache.commons.lang.ArrayUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.http.MediaType;
  16. import org.springframework.security.access.prepost.PreAuthorize;
  17. import org.springframework.ui.ModelMap;
  18. import org.springframework.util.CollectionUtils;
  19. import org.springframework.util.StringUtils;
  20. import org.springframework.web.bind.annotation.GetMapping;
  21. import org.springframework.web.bind.annotation.PathVariable;
  22. import org.springframework.web.bind.annotation.PostMapping;
  23. import org.springframework.web.bind.annotation.RequestBody;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.RequestParam;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import com.ym.mec.auth.api.client.SysUserFeignService;
  28. import com.ym.mec.auth.api.entity.SysUser;
  29. import com.ym.mec.biz.dal.dao.ClassGroupTeacherMapperDao;
  30. import com.ym.mec.biz.dal.dao.EmployeeDao;
  31. import com.ym.mec.biz.dal.dto.BatchInsertCoursesDto;
  32. import com.ym.mec.biz.dal.dto.CoursePostponeDto;
  33. import com.ym.mec.biz.dal.dto.CreateCourseScheduleDto;
  34. import com.ym.mec.biz.dal.dto.VipGroupCourseAdjustInfoDto;
  35. import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
  36. import com.ym.mec.biz.dal.entity.CourseSchedule;
  37. import com.ym.mec.biz.dal.entity.CourseScheduleComplaints;
  38. import com.ym.mec.biz.dal.entity.Employee;
  39. import com.ym.mec.biz.dal.entity.MusicGroup;
  40. import com.ym.mec.biz.dal.enums.AuditStatusEnum;
  41. import com.ym.mec.biz.dal.enums.GroupType;
  42. import com.ym.mec.biz.dal.enums.TeachModeEnum;
  43. import com.ym.mec.biz.dal.page.EndCourseScheduleQueryInfo;
  44. import com.ym.mec.biz.dal.page.StudentAttendanceQueryInfo;
  45. import com.ym.mec.biz.dal.page.VipGroupQueryInfo;
  46. import com.ym.mec.biz.service.CourseScheduleComplaintsService;
  47. import com.ym.mec.biz.service.CourseScheduleService;
  48. import com.ym.mec.biz.service.MusicGroupService;
  49. import com.ym.mec.biz.service.StudentAttendanceService;
  50. import com.ym.mec.common.controller.BaseController;
  51. import com.ym.mec.common.exception.BizException;
  52. /**
  53. * @Author Joburgess
  54. * @Date 2019/9/10
  55. */
  56. @RequestMapping("courseSchedule")
  57. @Api(tags = "课程计划服务")
  58. @RestController
  59. public class CourseScheduleController extends BaseController {
  60. @Autowired
  61. private CourseScheduleService scheduleService;
  62. @Autowired
  63. private StudentAttendanceService studentAttendanceService;
  64. @Autowired
  65. private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
  66. @Autowired
  67. private CourseScheduleComplaintsService courseScheduleComplaintsService;
  68. @Autowired
  69. private SysUserFeignService sysUserFeignService;
  70. @Autowired
  71. private MusicGroupService musicGroupService;
  72. @Autowired
  73. private EmployeeDao employeeDao;
  74. @ApiOperation(value = "排课")
  75. @PostMapping("/batchAddCourseSchedule")
  76. @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchAddCourseSchedule')")
  77. public Object batchAddCourseSchedule(@RequestBody CreateCourseScheduleDto createCourseScheduleDto){
  78. if(Objects.isNull(createCourseScheduleDto.getMusicGroupID())){
  79. throw new BizException("请指定乐团");
  80. }
  81. MusicGroup musicGroup = musicGroupService.get(createCourseScheduleDto.getMusicGroupID());
  82. if(musicGroup == null){
  83. return failed("乐团信息不存在");
  84. }
  85. List<ClassGroupTeacherMapper> byMusicGroup = classGroupTeacherMapperDao.findByMusicGroup(createCourseScheduleDto.getMusicGroupID());
  86. Map<Integer, List<ClassGroupTeacherMapper>> teacherByClassGroup = byMusicGroup.stream().collect(Collectors.groupingBy(ClassGroupTeacherMapper::getClassGroupId));
  87. createCourseScheduleDto.getCourseSchedules().forEach(courseSchedule -> {
  88. List<ClassGroupTeacherMapper> classGroupTeacherMappers = teacherByClassGroup.get(courseSchedule.getClassGroupId());
  89. if(CollectionUtils.isEmpty(classGroupTeacherMappers)){
  90. throw new BizException("乐团老师设置有误");
  91. }
  92. courseSchedule.setTeacherId(classGroupTeacherMappers.get(0).getUserId());
  93. courseSchedule.setActualTeacherId(classGroupTeacherMappers.get(0).getUserId());
  94. courseSchedule.setSchoolId(musicGroup.getSchoolId());
  95. courseSchedule.setMusicGroupId(musicGroup.getId());
  96. courseSchedule.setGroupType(GroupType.MUSIC);
  97. courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
  98. });
  99. scheduleService.createCourseSchedules(createCourseScheduleDto);
  100. return succeed();
  101. }
  102. @ApiOperation(value = "批量跟新排课")
  103. @PostMapping("/batchUpdateCourseSchedule/{musicGroupID}")
  104. @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchUpdateCourseSchedule')")
  105. public Object batchUpdateCourseSchedule(@RequestBody List<CourseSchedule> courseSchedules,
  106. @ApiParam(value = "乐团编号", required = true) @PathVariable("musicGroupID") String musicGroupID){
  107. scheduleService.batchUpdateCourseSchedule(courseSchedules,musicGroupID);
  108. return succeed();
  109. }
  110. @ApiOperation(value = "批量删除课程")
  111. @PostMapping(value = "/batchDelete")
  112. @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchDelete')")
  113. public Object bathDelete(String courseScheduleIds){
  114. if(StringUtils.isEmpty(courseScheduleIds)){
  115. throw new BizException("请指定课程编号");
  116. }
  117. long[] ints = Arrays.asList(courseScheduleIds.split(",")).stream().mapToLong(Long::parseLong).toArray();
  118. Long[] longs = ArrayUtils.toObject(ints);
  119. scheduleService.deleteCourseSchedules(Arrays.asList(longs));
  120. return succeed();
  121. }
  122. @ApiOperation(value = "获取vip课程计划")
  123. @PostMapping(value = "/findVipGroupCourseSchedules")
  124. @PreAuthorize("@pcs.hasPermissions('courseSchedule/findVipGroupCourseSchedules')")
  125. public Object findVipGroupCourseSchedules(VipGroupQueryInfo queryInfo){
  126. return succeed(scheduleService.findVipGroupCourseSchedules(queryInfo));
  127. }
  128. @ApiOperation(value = "根据月份获取乐团在该月有课的日期")
  129. @GetMapping("/getCourseScheduleDateByMonth")
  130. @PreAuthorize("@pcs.hasPermissions('courseSchedule/getCourseScheduleDateByMonth')")
  131. public Object getCourseScheduleDateByMonth(@ApiParam(value = "乐团编号", required = true) @RequestParam Long musicGroupID,
  132. @ApiParam(value = "月份", required = true) @RequestParam Date month) {
  133. return succeed(scheduleService.getCourseScheduleDateByMonth(musicGroupID,month));
  134. }
  135. @ApiOperation(value = "根据课程ID查询正在或即将开始的课程")
  136. @GetMapping("/getCurrentCourseDetail/{courseID}")
  137. @PreAuthorize("@pcs.hasPermissions('courseSchedule/getCurrentCourseDetail')")
  138. public Object getCurrentCourseDetail(@ApiParam(value = "课程ID", required = true) @PathVariable("courseID") Long courseID){
  139. return succeed(scheduleService.getCurrentCourseDetail(courseID));
  140. }
  141. @ApiOperation(value = "根据班级ID获取当前课程的学生")
  142. @GetMapping("/getCurrentCourseStudents")
  143. @PreAuthorize("@pcs.hasPermissions('courseSchedule/getCurrentCourseStudents')")
  144. public Object getCurrentCourseStudents(@RequestBody StudentAttendanceQueryInfo queryInfo){
  145. return succeed(studentAttendanceService.getCurrentCourseStudents(queryInfo));
  146. }
  147. @ApiOperation(value = "课时调整")
  148. @PreAuthorize("@pcs.hasPermissions('courseSchedule/classStartDateAdjust','system')")
  149. @PostMapping(value = "/classStartDateAdjust",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  150. public Object classStartDateAdjust(CourseSchedule courseSchedule){
  151. CourseSchedule oldCourseSchedule = scheduleService.get(courseSchedule.getId());
  152. if(Objects.isNull(oldCourseSchedule)){
  153. return failed("未找到指定课程");
  154. }
  155. if(Objects.isNull(courseSchedule.getClassGroupId())){
  156. courseSchedule.setClassGroupId(oldCourseSchedule.getClassGroupId());
  157. }
  158. List<CourseSchedule> courseSchedules=new ArrayList<>();
  159. courseSchedules.add(courseSchedule);
  160. scheduleService.courseAdjust(courseSchedules);
  161. return succeed();
  162. }
  163. @ApiOperation(value = "课时调整-批量")
  164. @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchClassStartDateAdjust')")
  165. @PostMapping(value = "/batchClassStartDateAdjust")
  166. public Object batchClassStartDateAdjust(@RequestBody List<CourseSchedule> courseSchedules){
  167. scheduleService.courseAdjust(courseSchedules);
  168. return succeed();
  169. }
  170. @ApiOperation(value = "课时交换")
  171. @PreAuthorize("@pcs.hasPermissions('courseSchedule/courseSwap')")
  172. @GetMapping(value = "/courseSwap",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  173. public Object courseSwap(Long courseScheduleId1,Long courseScheduleId2){
  174. if(Objects.isNull(courseScheduleId1)||Objects.isNull(courseScheduleId2)){
  175. return failed("请指定课程");
  176. }
  177. scheduleService.courseSwap(courseScheduleId1,courseScheduleId2);
  178. return succeed();
  179. }
  180. @ApiOperation(value = "课程投诉审核")
  181. @PostMapping(value = "/courseScheduleCommplaintAudit")
  182. @PreAuthorize("@pcs.hasPermissions('courseSchedule/courseScheduleCommplaintAudit')")
  183. public Object courseScheduleCommplaintAudit(Long id, Double teacherLiabilityRatio, Double studentLiabilityRatio, AuditStatusEnum status) {
  184. scheduleService.courseScheduleCommplaintAudit(id, teacherLiabilityRatio, studentLiabilityRatio, status);
  185. return succeed();
  186. }
  187. @ApiOperation(value = "检测乐团下所有的班级是否都已排课")
  188. @PostMapping(value = "/checkMusicGroupClassCourse")
  189. @PreAuthorize("@pcs.hasPermissions('courseSchedule/checkMusicGroupClassCourse')")
  190. public Object checkMusicGroupClassCourse(String musicGroupId){
  191. scheduleService.checkMusicGroupClassCourse(musicGroupId);
  192. return succeed();
  193. }
  194. @ApiOperation(value = "课酬调整")
  195. @PostMapping("/updateTeacherCoursesSalary")
  196. @PreAuthorize("@pcs.hasPermissions('courseSchedule/updateTeacherCoursesSalary')")
  197. public Object updateTeacherCoursesSalary(Long courseScheduleId, Integer teacherId, BigDecimal salary, BigDecimal subsidy, String scope) {
  198. return succeed(musicGroupService.updateTeacherCoursesSalary(courseScheduleId, teacherId, salary, subsidy, scope));
  199. }
  200. @ApiOperation(value = "删除乐团下所有未上的课时")
  201. @GetMapping("/batchDeleteMusicGroupNotStartCourse")
  202. @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchDeleteMusicGroupNotStartCourse')")
  203. public Object batchDeleteMusicGroupNotStartCourse(String musicGroupId){
  204. scheduleService.batchDeleteMusicGroupNotStartCourse(musicGroupId,GroupType.MUSIC);
  205. return succeed();
  206. }
  207. @ApiOperation(value = "乐团详情--课酬调整--课程教师列表")
  208. @GetMapping("/queryTeacherSalary")
  209. @PreAuthorize("@pcs.hasPermissions('courseSchedule/queryTeacherSalary')")
  210. public Object queryTeacherSalary(Long courseScheduleId) {
  211. return succeed(musicGroupService.queryTeacherSalary(courseScheduleId));
  212. }
  213. @ApiOperation(value = "根据班级获取课程计划")
  214. @GetMapping("/findCourseScheduleByClassGroup")
  215. @PreAuthorize("@pcs.hasPermissions('courseSchedule/findCourseScheduleByClassGroup')")
  216. public Object findCourseScheduleByClassGroup(Integer classGroupId){
  217. return succeed(scheduleService.findCourseScheduleByClassGroup(classGroupId));
  218. }
  219. @ApiOperation(value = "查询课程投诉详情")
  220. @GetMapping("/queryCourseScheduleComplaintsDetail")
  221. @PreAuthorize("@pcs.hasPermissions('courseSchedule/queryCourseScheduleComplaintsDetail')")
  222. public Object queryCourseScheduleComplaintsDetail(Long courseScheduleComplaintsId){
  223. CourseScheduleComplaints complaints = courseScheduleComplaintsService.get(courseScheduleComplaintsId);
  224. if(complaints == null){
  225. return failed("参数输入不正确");
  226. }
  227. SysUser user = sysUserFeignService.queryUserById(complaints.getUserId());
  228. complaints.getUser().setUsername(user.getUsername());
  229. CourseSchedule courseSchedule = scheduleService.get(complaints.getCourseScheduleId());
  230. SysUser teacher = sysUserFeignService.queryUserById(courseSchedule.getActualTeacherId());
  231. courseSchedule.getTeacher().setUsername(teacher.getUsername());
  232. ModelMap model = new ModelMap();
  233. model.put("complaints", complaints);
  234. model.put("courseSchedule", courseSchedule);
  235. return succeed(model);
  236. }
  237. @ApiOperation(value = "vip课批量调整(网管课)")
  238. @PostMapping("/vipCourseAdjust")
  239. @PreAuthorize("@pcs.hasPermissions('courseSchedule/vipCourseAdjust')")
  240. public Object vipCourseAdjust(@RequestBody VipGroupCourseAdjustInfoDto vipGroupCourseAdjustInfo){
  241. scheduleService.vipCourseAdjust(vipGroupCourseAdjustInfo);
  242. return succeed();
  243. }
  244. @ApiOperation(value = "vip课批量新增")
  245. @PostMapping("/batchAppendVipGroupCourses")
  246. @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchAppendVipGroupCourses')")
  247. public Object batchAppendVipGroupCourses(@RequestBody VipGroupCourseAdjustInfoDto vipGroupCourseAdjustInfo){
  248. scheduleService.batchAppendVipGroupCourses(vipGroupCourseAdjustInfo);
  249. return succeed();
  250. }
  251. @ApiOperation(value = "批量新增")
  252. @PostMapping("/batchAddCourses")
  253. @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchAddCourses')")
  254. public Object batchAddCourses(@RequestBody BatchInsertCoursesDto batchInsertCoursesDto){
  255. scheduleService.batchAddCourseSchedule(batchInsertCoursesDto.getClassGroupId(), batchInsertCoursesDto.getCoursesTimes(),
  256. batchInsertCoursesDto.getStartDate(), batchInsertCoursesDto.getTeachingArrangement(), batchInsertCoursesDto.getTeachMode(),
  257. batchInsertCoursesDto.getType(), batchInsertCoursesDto.getSchoolId(), batchInsertCoursesDto.getIsJumpHoliday());
  258. return succeed();
  259. }
  260. @ApiOperation(value = "终极课表获取")
  261. @GetMapping("/superFindCourseSchedules")
  262. @PreAuthorize("@pcs.hasPermissions('courseSchedule/superFindCourseSchedules')")
  263. public Object superFindCourseSchedules(EndCourseScheduleQueryInfo queryInfo){
  264. SysUser sysUser = sysUserFeignService.queryUserInfo();
  265. if (sysUser == null) {
  266. return failed("用户信息获取失败");
  267. }
  268. if(!sysUser.getIsSuperAdmin()){
  269. Employee employee = employeeDao.get(sysUser.getId());
  270. if (org.apache.commons.lang3.StringUtils.isEmpty(queryInfo.getOrganIdList())) {
  271. queryInfo.setOrganIdList(employee.getOrganIdList());
  272. }else if(org.apache.commons.lang3.StringUtils.isEmpty(employee.getOrganIdList())){
  273. return failed("用户所在分部异常");
  274. }else {
  275. List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
  276. if(!list.containsAll(Arrays.asList(queryInfo.getOrganIdList().split(",")))){
  277. return failed("非法请求");
  278. }
  279. }
  280. }
  281. return succeed(scheduleService.endFindCourseSchedules(queryInfo));
  282. }
  283. @ApiOperation(value = "课程顺延")
  284. @PostMapping("/coursePostpone")
  285. @PreAuthorize("@pcs.hasPermissions('courseSchedule/coursePostpone')")
  286. public Object coursePostpone(CoursePostponeDto coursePostPoneInfo){
  287. scheduleService.coursePostpone(coursePostPoneInfo);
  288. return succeed();
  289. }
  290. @ApiOperation(value = "陪练课调整")
  291. @PostMapping("/practiceCourseAdjust")
  292. @PreAuthorize("@pcs.hasPermissions('courseSchedule/practiceCourseAdjust')")
  293. public Object practiceCourseAdjust(CourseSchedule courseSchedule){
  294. scheduleService.practiceCourseAdjust(courseSchedule);
  295. return succeed();
  296. }
  297. @ApiOperation(value = "陪练课老师调整")
  298. @PostMapping("/practiceCourseTeacherAdjust")
  299. @PreAuthorize("@pcs.hasPermissions('courseSchedule/practiceCourseTeacherAdjust')")
  300. public Object practiceCourseTeacherAdjust(Long courseScheduleId,Integer teacherId){
  301. scheduleService.practiceCourseTeacherAdjust(courseScheduleId,teacherId);
  302. return succeed();
  303. }
  304. @ApiOperation(value = "陪练课课程组老师调整")
  305. @PostMapping("/practiceGroupTeacherAdjust")
  306. @PreAuthorize("@pcs.hasPermissions('courseSchedule/practiceGroupTeacherAdjust')")
  307. public Object practiceGroupTeacherAdjust(String practiceGroupId, Integer teacherId){
  308. scheduleService.practiceGroupTeacherAdjust(practiceGroupId,teacherId);
  309. return succeed();
  310. }
  311. @ApiOperation(value = "清空老师和学生考勤记录")
  312. @PostMapping("/cleanAttendance")
  313. @PreAuthorize("@pcs.hasPermissions('courseSchedule/cleanAttendance')")
  314. public Object cleanAttendance(String courseScheduleIds){
  315. scheduleService.cleanAttendance(courseScheduleIds);
  316. return succeed();
  317. }
  318. }