BaseStudentAssessmentInspectionController.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. package com.xjrsoft.module.student.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import cn.dev33.satoken.stp.StpUtil;
  4. import cn.hutool.core.bean.BeanUtil;
  5. import cn.hutool.core.util.ObjectUtil;
  6. import cn.hutool.core.util.StrUtil;
  7. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  8. import com.baomidou.mybatisplus.core.metadata.IPage;
  9. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  10. import com.github.yulichang.toolkit.MPJWrappers;
  11. import com.xjrsoft.common.model.result.RT;
  12. import com.xjrsoft.common.page.ConventPage;
  13. import com.xjrsoft.common.page.PageOutput;
  14. import com.xjrsoft.common.utils.VoToColumnUtil;
  15. import com.xjrsoft.module.base.entity.BaseClass;
  16. import com.xjrsoft.module.base.mapper.BaseClassMapper;
  17. import com.xjrsoft.module.student.dto.AddBaseStudentAssessmentInspectionDto;
  18. import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionPageDto;
  19. import com.xjrsoft.module.student.dto.UpdateBaseStudentAssessmentInspectionDto;
  20. import com.xjrsoft.module.student.entity.BaseStudentAssessmentCategory;
  21. import com.xjrsoft.module.student.entity.BaseStudentAssessmentClassRelation;
  22. import com.xjrsoft.module.student.entity.BaseStudentAssessmentInspection;
  23. import com.xjrsoft.module.student.entity.BaseStudentAssessmentProject;
  24. import com.xjrsoft.module.student.entity.BaseStudentAssessmentStudentRelation;
  25. import com.xjrsoft.module.student.mapper.BaseStudentAssessmentCategoryMapper;
  26. import com.xjrsoft.module.student.mapper.BaseStudentAssessmentProjectMapper;
  27. import com.xjrsoft.module.student.service.IBaseStudentAssessmentClassRelationService;
  28. import com.xjrsoft.module.student.service.IBaseStudentAssessmentInspectionService;
  29. import com.xjrsoft.module.student.service.IBaseStudentAssessmentStudentRelationService;
  30. import com.xjrsoft.module.student.vo.BaseStudentAssessmentClassRelationListVo;
  31. import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionPageVo;
  32. import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionVo;
  33. import com.xjrsoft.module.student.vo.BaseStudentAssessmentStudentRelationVo;
  34. import com.xjrsoft.module.teacher.entity.XjrUser;
  35. import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
  36. import io.swagger.annotations.Api;
  37. import io.swagger.annotations.ApiOperation;
  38. import lombok.AllArgsConstructor;
  39. import org.springframework.web.bind.annotation.DeleteMapping;
  40. import org.springframework.web.bind.annotation.GetMapping;
  41. import org.springframework.web.bind.annotation.PostMapping;
  42. import org.springframework.web.bind.annotation.PutMapping;
  43. import org.springframework.web.bind.annotation.RequestBody;
  44. import org.springframework.web.bind.annotation.RequestMapping;
  45. import org.springframework.web.bind.annotation.RequestParam;
  46. import org.springframework.web.bind.annotation.RestController;
  47. import javax.validation.Valid;
  48. import java.util.ArrayList;
  49. import java.util.List;
  50. /**
  51. * @title: 学生班级巡查考核
  52. * @Author dzx
  53. * @Date: 2023-11-16
  54. * @Version 1.0
  55. */
  56. @RestController
  57. @RequestMapping("/student" + "/basestudentassessmentinspection")
  58. @Api(value = "/student" + "/basestudentassessmentinspection", tags = "学生班级巡查考核代码")
  59. @AllArgsConstructor
  60. public class BaseStudentAssessmentInspectionController {
  61. private final IBaseStudentAssessmentInspectionService baseStudentAssessmentInspectionService;
  62. private final IBaseStudentAssessmentClassRelationService baseStudentAssessmentClassRelationService;
  63. private final IBaseStudentAssessmentStudentRelationService baseStudentAssessmentStudentRelationService;
  64. private final BaseStudentAssessmentProjectMapper baseStudentAssessmentProjectMapper;
  65. private final BaseStudentAssessmentCategoryMapper baseStudentAssessmentCategoryMapper;
  66. private final XjrUserMapper xjrUserMapper;
  67. private final BaseClassMapper baseClassMapper;
  68. @GetMapping(value = "/page")
  69. @ApiOperation(value = "学生班级巡查考核列表(分页)")
  70. @SaCheckPermission("basestudentassessmentinspection:detail")
  71. public RT<PageOutput<BaseStudentAssessmentInspectionPageVo>> page(@Valid BaseStudentAssessmentInspectionPageDto dto) {
  72. Page<BaseStudentAssessmentInspectionPageVo> page = baseStudentAssessmentInspectionService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  73. return RT.ok(ConventPage.getPageOutput(page, BaseStudentAssessmentInspectionPageVo.class));
  74. }
  75. @GetMapping(value = "/mibliePage")
  76. @ApiOperation(value = "学生操行分记录管理列表(移动端分页)")
  77. @SaCheckPermission("basestudentbehaviormanage:detail")
  78. public RT<PageOutput<BaseStudentAssessmentInspectionPageVo>> mibliePage(@Valid BaseStudentAssessmentInspectionPageDto dto) {
  79. List<BaseClass> classList = baseClassMapper.selectList(
  80. MPJWrappers.<BaseClass>lambdaJoin()
  81. .eq(BaseClass::getTeacherId, StpUtil.getLoginIdAsLong())
  82. .select(BaseClass.class, x -> VoToColumnUtil.fieldsToColumns(BaseClass.class).contains(x.getProperty()))
  83. );
  84. List<Long> classIds = new ArrayList<>();
  85. for (BaseClass baseClass : classList) {
  86. classIds.add(baseClass.getId());
  87. }
  88. dto.setClassIds(classIds);
  89. return RT.ok(getData(dto));
  90. }
  91. PageOutput<BaseStudentAssessmentInspectionPageVo> getData(BaseStudentAssessmentInspectionPageDto dto) {
  92. IPage<BaseStudentAssessmentInspectionPageVo> page = baseStudentAssessmentInspectionService.selectJoinListPage(ConventPage.getPage(dto), BaseStudentAssessmentInspectionPageVo.class,
  93. MPJWrappers.<BaseStudentAssessmentInspection>lambdaJoin()
  94. .like(StrUtil.isNotEmpty(dto.getCreateUserName()), XjrUser::getName, dto.getCreateUserName())
  95. .like(StrUtil.isNotEmpty(dto.getModifyUserName()), XjrUser::getName, dto.getModifyUserName())
  96. .eq(StrUtil.isNotEmpty(dto.getEnrollType()), BaseClass::getEnrollType, dto.getEnrollType())
  97. .eq(ObjectUtil.isNotNull(dto.getGradeId()), BaseClass::getGradeId, dto.getGradeId())
  98. .eq(BaseStudentAssessmentInspection::getStatus, 1)
  99. .in(ObjectUtil.isNotNull(dto.getClassIds()), BaseStudentAssessmentClassRelation::getClassId, dto.getClassIds())
  100. .in(ObjectUtil.isNotNull(dto.getBaseStudentAssessmentProjectIds()), BaseStudentAssessmentInspection::getBaseStudentAssessmentProjectId, dto.getBaseStudentAssessmentProjectIds())
  101. .between(ObjectUtil.isNotNull(dto.getStartDate()) && ObjectUtil.isNotNull(dto.getEndDate()), BaseStudentAssessmentInspection::getCreateDate, dto.getStartDate(), dto.getEndDate())
  102. .in(ObjectUtil.isNotNull(dto.getBaseStudentAssessmentProjectIds()), BaseStudentAssessmentInspection::getBaseStudentAssessmentProjectId, dto.getBaseStudentAssessmentProjectIds())
  103. .select("c.name as class_name")
  104. .select("u.name as class_teacher")
  105. .select("d.name as dept_name")
  106. .select("(SELECT COUNT(*) FROM base_student_assessment_student_relation WHERE base_student_assessment_inspection_id = t.id) as student_count")
  107. .select("(SELECT name FROM xjr_user WHERE id = t.assessment_user_id) as assessment_user_name")
  108. .select(BaseStudentAssessmentInspection::getScore)
  109. .select(BaseStudentAssessmentInspection::getSortCode)
  110. .select(BaseStudentAssessmentInspection::getReason)
  111. .select(BaseStudentAssessmentInspection::getId)
  112. .select(BaseStudentAssessmentInspection::getFileId)
  113. .selectAs(BaseStudentAssessmentCategory::getName, BaseStudentAssessmentInspectionPageVo::getAssessmentCategoryName)
  114. .selectAs(BaseStudentAssessmentProject::getName, BaseStudentAssessmentInspectionPageVo::getAssessmentProjectName)
  115. .innerJoin(BaseStudentAssessmentCategory.class, BaseStudentAssessmentCategory::getId, BaseStudentAssessmentInspection::getBaseStudentAssessmentCategoryId)
  116. .innerJoin(BaseStudentAssessmentProject.class, BaseStudentAssessmentProject::getId, BaseStudentAssessmentInspection::getBaseStudentAssessmentProjectId)
  117. .leftJoin(XjrUser.class, XjrUser::getId, BaseStudentAssessmentInspection::getAssessmentUserId)
  118. .innerJoin("base_class c ON t.class_ids LIKE CONCAT('%', c.id, '%')")
  119. .innerJoin("xjr_user u on c.teacher_id = u.id")
  120. .innerJoin("xjr_department d on c.org_id = d.id")
  121. .leftJoin(BaseStudentAssessmentClassRelation.class, BaseStudentAssessmentClassRelation::getBaseStudentAssessmentInspectionId, BaseStudentAssessmentInspection::getId)
  122. );
  123. return ConventPage.getPageOutput(page, BaseStudentAssessmentInspectionPageVo.class);
  124. }
  125. // @GetMapping(value = "/moblieInfo")
  126. // @ApiOperation(value="根据id查询学生班级巡查考核信息")
  127. // @SaCheckPermission("basestudentassessmentinspection:detail")
  128. // public RT<List<BaseStudentAssessmentInspectionPageVo>> moblieInfo(@RequestParam Long id){
  129. // BaseStudentAssessmentInspection baseStudentAssessmentInspection = baseStudentAssessmentInspectionService.getById(id);
  130. // if (baseStudentAssessmentInspection == null) {
  131. // return RT.error("找不到此数据!");
  132. // }
  133. // List<BaseStudentAssessmentInspectionPageVo> list = baseStudentAssessmentInspectionService.selectJoinList(BaseStudentAssessmentInspectionPageVo.class,
  134. // MPJWrappers.<BaseStudentAssessmentInspection>lambdaJoin()
  135. // .eq(ObjectUtil.isNotNull(id), BaseStudentAssessmentInspection::getId, id)
  136. // .eq(BaseStudentAssessmentInspection::getStatus, 1)
  137. // .selectAs(BaseClass::getName, BaseStudentAssessmentInspectionPageVo::getClassName)
  138. // .select("u.name as class_teacher")
  139. // .select("d.name as dept_name")
  140. // .select("(SELECT COUNT(*) FROM base_student_assessment_student_relation WHERE base_student_assessment_inspection_id = t.id) as student_count")
  141. // .select("(SELECT name FROM xjr_user WHERE id = t.assessment_user_id) as assessment_user_name")
  142. // .select(BaseStudentAssessmentInspection::getScore)
  143. // .select(BaseStudentAssessmentInspection::getSortCode)
  144. // .select(BaseStudentAssessmentInspection::getReason)
  145. // .select(BaseStudentAssessmentInspection::getId)
  146. // .select(BaseStudentAssessmentInspection::getFileId)
  147. // .selectAs(BaseStudentAssessmentCategory::getName, BaseStudentAssessmentInspectionPageVo::getAssessmentCategoryName)
  148. // .selectAs(BaseStudentAssessmentProject::getName, BaseStudentAssessmentInspectionPageVo::getAssessmentProjectName)
  149. // .innerJoin(BaseStudentAssessmentCategory.class, BaseStudentAssessmentCategory::getId, BaseStudentAssessmentInspection::getBaseStudentAssessmentCategoryId)
  150. // .innerJoin(BaseStudentAssessmentProject.class, BaseStudentAssessmentProject::getId, BaseStudentAssessmentInspection::getBaseStudentAssessmentProjectId)
  151. // .leftJoin(XjrUser.class, XjrUser::getId, BaseStudentAssessmentInspection::getAssessmentUserId)
  152. // .innerJoin(BaseStudentAssessmentClassRelation.class, BaseStudentAssessmentClassRelation::getBaseStudentAssessmentInspectionId, BaseStudentAssessmentInspection::getId)
  153. // .innerJoin(BaseClass.class, BaseClass::getId, BaseStudentAssessmentClassRelation::getClassId)
  154. // .innerJoin("xjr_user u on t5.teacher_id = u.id")
  155. // .innerJoin("xjr_department d on t5.org_id = d.id")
  156. // );
  157. // for (BaseStudentAssessmentInspectionPageVo inspectionPageVo : list) {
  158. // //查询学生
  159. // LambdaQueryWrapper<BaseStudentAssessmentStudentRelation> studentQueryWrapper = new LambdaQueryWrapper<>();
  160. // studentQueryWrapper
  161. // .eq(BaseStudentAssessmentStudentRelation::getBaseStudentAssessmentInspectionId, inspectionPageVo.getId())
  162. // .select(BaseStudentAssessmentStudentRelation.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentAssessmentStudentRelationVo.class).contains(x.getProperty()));
  163. // List<BaseStudentAssessmentStudentRelation> studentList = baseStudentAssessmentStudentRelationService.list(studentQueryWrapper);
  164. // inspectionPageVo.setStudentList(BeanUtil.copyToList(studentList, BaseStudentAssessmentStudentRelationVo.class));
  165. // inspectionPageVo.setStudentCount(studentList.size());
  166. // }
  167. // return RT.ok(list);
  168. // }
  169. @GetMapping(value = "/info")
  170. @ApiOperation(value = "根据id查询学生班级巡查考核信息")
  171. @SaCheckPermission("basestudentassessmentinspection:detail")
  172. public RT<BaseStudentAssessmentInspectionVo> info(@RequestParam Long id) {
  173. BaseStudentAssessmentInspection baseStudentAssessmentInspection = baseStudentAssessmentInspectionService.getById(id);
  174. if (baseStudentAssessmentInspection == null) {
  175. return RT.error("找不到此数据!");
  176. }
  177. BaseStudentAssessmentInspectionVo baseStudentAssessmentInspectionVo = BeanUtil.toBean(baseStudentAssessmentInspection, BaseStudentAssessmentInspectionVo.class);
  178. //查询班级
  179. LambdaQueryWrapper<BaseStudentAssessmentClassRelation> classQueryWrapper = new LambdaQueryWrapper<>();
  180. classQueryWrapper
  181. .eq(BaseStudentAssessmentClassRelation::getBaseStudentAssessmentInspectionId, id)
  182. .select(BaseStudentAssessmentClassRelation.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentAssessmentClassRelationListVo.class).contains(x.getProperty()));
  183. List<BaseStudentAssessmentClassRelation> classList = baseStudentAssessmentClassRelationService.list(classQueryWrapper);
  184. baseStudentAssessmentInspectionVo.setClassList(BeanUtil.copyToList(classList, BaseStudentAssessmentClassRelationListVo.class));
  185. //查询学生
  186. LambdaQueryWrapper<BaseStudentAssessmentStudentRelation> studentQueryWrapper = new LambdaQueryWrapper<>();
  187. studentQueryWrapper
  188. .eq(BaseStudentAssessmentStudentRelation::getBaseStudentAssessmentInspectionId, id)
  189. .select(BaseStudentAssessmentStudentRelation.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentAssessmentStudentRelationVo.class).contains(x.getProperty()));
  190. List<BaseStudentAssessmentStudentRelation> studentList = baseStudentAssessmentStudentRelationService.list(studentQueryWrapper);
  191. baseStudentAssessmentInspectionVo.setStudentList(BeanUtil.copyToList(studentList, BaseStudentAssessmentStudentRelationVo.class));
  192. baseStudentAssessmentInspectionVo.setStudentCount(studentList.size());
  193. //查询考核项目
  194. BaseStudentAssessmentProject project = baseStudentAssessmentProjectMapper.selectById(baseStudentAssessmentInspection.getBaseStudentAssessmentProjectId());
  195. if (project != null) {
  196. baseStudentAssessmentInspectionVo.setAssessmentProjectName(project.getName());
  197. }
  198. //查询考核类别
  199. BaseStudentAssessmentCategory category = baseStudentAssessmentCategoryMapper.selectById(baseStudentAssessmentInspection.getBaseStudentAssessmentCategoryId());
  200. if (category != null) {
  201. baseStudentAssessmentInspectionVo.setAssessmentCategoryName(category.getName());
  202. }
  203. //登记人
  204. XjrUser createUser = xjrUserMapper.selectById(baseStudentAssessmentInspection.getCreateUserId());
  205. if (createUser != null) {
  206. baseStudentAssessmentInspectionVo.setCreateUserName(createUser.getName());
  207. }
  208. //考核人
  209. XjrUser assessmentUser = xjrUserMapper.selectById(baseStudentAssessmentInspection.getAssessmentUserId());
  210. if (createUser != null) {
  211. baseStudentAssessmentInspectionVo.setAssessmentUserName(assessmentUser.getName());
  212. }
  213. //修改人
  214. XjrUser modifyUser = xjrUserMapper.selectById(baseStudentAssessmentInspection.getModifyUserId());
  215. if (modifyUser != null) {
  216. baseStudentAssessmentInspectionVo.setModifyUserName(modifyUser.getName());
  217. }
  218. return RT.ok(baseStudentAssessmentInspectionVo);
  219. }
  220. @PostMapping
  221. @ApiOperation(value = "新增学生班级巡查考核")
  222. @SaCheckPermission("basestudentassessmentinspection:add")
  223. public RT<Boolean> add(@Valid @RequestBody AddBaseStudentAssessmentInspectionDto dto) {
  224. BaseStudentAssessmentInspection baseStudentAssessmentInspection = BeanUtil.toBean(dto, BaseStudentAssessmentInspection.class);
  225. boolean isSuccess = baseStudentAssessmentInspectionService.save(baseStudentAssessmentInspection);
  226. return RT.ok(isSuccess);
  227. }
  228. @PutMapping
  229. @ApiOperation(value = "修改学生班级巡查考核")
  230. @SaCheckPermission("basestudentassessmentinspection:edit")
  231. public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentAssessmentInspectionDto dto) {
  232. BaseStudentAssessmentInspection baseStudentAssessmentInspection = BeanUtil.toBean(dto, BaseStudentAssessmentInspection.class);
  233. return RT.ok(baseStudentAssessmentInspectionService.updateById(baseStudentAssessmentInspection));
  234. }
  235. @DeleteMapping
  236. @ApiOperation(value = "删除学生班级巡查考核")
  237. @SaCheckPermission("basestudentassessmentinspection:delete")
  238. public RT<Boolean> delete(@Valid @RequestBody List<Long> ids) {
  239. return RT.ok(baseStudentAssessmentInspectionService.removeBatchByIds(ids));
  240. }
  241. }