BaseStudentAssessmentInspectionController.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package com.xjrsoft.module.student.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import cn.hutool.core.bean.BeanUtil;
  4. import cn.hutool.core.util.ObjectUtil;
  5. import cn.hutool.core.util.StrUtil;
  6. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  7. import com.baomidou.mybatisplus.core.metadata.IPage;
  8. import com.github.yulichang.toolkit.MPJWrappers;
  9. import com.xjrsoft.common.model.result.RT;
  10. import com.xjrsoft.common.page.ConventPage;
  11. import com.xjrsoft.common.page.PageOutput;
  12. import com.xjrsoft.common.utils.VoToColumnUtil;
  13. import com.xjrsoft.module.base.entity.BaseClass;
  14. import com.xjrsoft.module.student.dto.AddBaseStudentAssessmentInspectionDto;
  15. import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionPageDto;
  16. import com.xjrsoft.module.student.dto.UpdateBaseStudentAssessmentInspectionDto;
  17. import com.xjrsoft.module.student.entity.BaseStudentAssessmentCategory;
  18. import com.xjrsoft.module.student.entity.BaseStudentAssessmentClassRelation;
  19. import com.xjrsoft.module.student.entity.BaseStudentAssessmentInspection;
  20. import com.xjrsoft.module.student.entity.BaseStudentAssessmentProject;
  21. import com.xjrsoft.module.student.entity.BaseStudentAssessmentStudentRelation;
  22. import com.xjrsoft.module.student.service.IBaseStudentAssessmentClassRelationService;
  23. import com.xjrsoft.module.student.service.IBaseStudentAssessmentInspectionService;
  24. import com.xjrsoft.module.student.vo.BaseStudentAssessmentClassRelationListVo;
  25. import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionPageVo;
  26. import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionVo;
  27. import com.xjrsoft.module.student.vo.BaseStudentAssessmentStudentRelationVo;
  28. import com.xjrsoft.module.teacher.entity.XjrUser;
  29. import io.swagger.annotations.Api;
  30. import io.swagger.annotations.ApiOperation;
  31. import lombok.AllArgsConstructor;
  32. import org.springframework.web.bind.annotation.DeleteMapping;
  33. import org.springframework.web.bind.annotation.GetMapping;
  34. import org.springframework.web.bind.annotation.PostMapping;
  35. import org.springframework.web.bind.annotation.PutMapping;
  36. import org.springframework.web.bind.annotation.RequestBody;
  37. import org.springframework.web.bind.annotation.RequestMapping;
  38. import org.springframework.web.bind.annotation.RequestParam;
  39. import org.springframework.web.bind.annotation.RestController;
  40. import javax.validation.Valid;
  41. import java.util.List;
  42. /**
  43. * @title: 学生班级巡查考核
  44. * @Author dzx
  45. * @Date: 2023-11-16
  46. * @Version 1.0
  47. */
  48. @RestController
  49. @RequestMapping("/student" + "/basestudentassessmentinspection")
  50. @Api(value = "/student" + "/basestudentassessmentinspection",tags = "学生班级巡查考核代码")
  51. @AllArgsConstructor
  52. public class BaseStudentAssessmentInspectionController {
  53. private final IBaseStudentAssessmentInspectionService baseStudentAssessmentInspectionService;
  54. private final IBaseStudentAssessmentClassRelationService baseStudentAssessmentClassRelationService;
  55. private final com.xjrsoft.module.student.service.IBaseStudentAssessmentStudentRelationService baseStudentAssessmentStudentRelationService;
  56. @GetMapping(value = "/page")
  57. @ApiOperation(value="学生班级巡查考核列表(分页)")
  58. @SaCheckPermission("basestudentassessmentinspection:detail")
  59. public RT<PageOutput<BaseStudentAssessmentInspectionPageVo>> page(@Valid BaseStudentAssessmentInspectionPageDto dto){
  60. //未传流程状态不返回数据
  61. if(ObjectUtil.isNull(dto) || ObjectUtil.isNull(dto.getStatus())){
  62. PageOutput<BaseStudentAssessmentInspectionPageVo> result = ConventPage.getPageOutputNull(BaseStudentAssessmentInspectionPageVo.class);
  63. return RT.ok(result);
  64. }
  65. IPage<BaseStudentAssessmentInspectionPageVo> page = baseStudentAssessmentInspectionService.selectJoinListPage(ConventPage.getPage(dto), BaseStudentAssessmentInspectionPageVo.class,
  66. MPJWrappers.<BaseStudentAssessmentInspection>lambdaJoin()
  67. .like(StrUtil.isNotEmpty(dto.getCreateUserName()), XjrUser::getName, dto.getCreateUserName())
  68. .like(StrUtil.isNotEmpty(dto.getModifyUserName()), XjrUser::getName, dto.getModifyUserName())
  69. .eq(BaseStudentAssessmentInspection::getStatus, dto.getStatus())
  70. .eq(StrUtil.isNotEmpty(dto.getEnrollType()), BaseClass::getEnrollType, dto.getEnrollType())
  71. .eq(ObjectUtil.isNotNull(dto.getGradeId()), BaseClass::getGradeId, dto.getGradeId())
  72. .in(ObjectUtil.isNotNull(dto.getBaseStudentAssessmentProjectIds()), BaseStudentAssessmentInspection::getBaseStudentAssessmentProjectId, dto.getBaseStudentAssessmentProjectIds())
  73. .between(ObjectUtil.isNotNull(dto.getStartDate()) && ObjectUtil.isNotNull(dto.getEndDate()), BaseStudentAssessmentInspection::getCreateDate,dto.getStartDate(),dto.getEndDate())
  74. .in(ObjectUtil.isNotNull(dto.getBaseStudentAssessmentProjectIds()), BaseStudentAssessmentInspection::getBaseStudentAssessmentProjectId, dto.getBaseStudentAssessmentProjectIds())
  75. .select("c.name as class_name")
  76. .select("u.name as class_teacher")
  77. .select("d.name as dept_name")
  78. .select("(SELECT COUNT(*) FROM base_student_assessment_student_relation WHERE base_student_assessment_inspection_id = t.id) as student_count")
  79. .select("(SELECT name FROM xjr_user WHERE id = t.assessment_user_id) as assessment_user_name")
  80. .select(BaseStudentAssessmentInspection::getScore)
  81. .select(BaseStudentAssessmentInspection::getSortCode)
  82. .select(BaseStudentAssessmentInspection::getReason)
  83. .select(BaseStudentAssessmentInspection::getId)
  84. .select(BaseStudentAssessmentInspection::getFileId)
  85. .selectAs(BaseStudentAssessmentCategory::getName, BaseStudentAssessmentInspectionPageVo::getAssessmentCategoryName)
  86. .selectAs(BaseStudentAssessmentProject::getName, BaseStudentAssessmentInspectionPageVo::getAssessmentProjectName)
  87. .innerJoin(BaseStudentAssessmentCategory.class, BaseStudentAssessmentCategory::getId, BaseStudentAssessmentInspection::getBaseStudentAssessmentCategoryId)
  88. .innerJoin(BaseStudentAssessmentProject.class, BaseStudentAssessmentProject::getId, BaseStudentAssessmentInspection::getBaseStudentAssessmentProjectId)
  89. .leftJoin(XjrUser.class, XjrUser::getId, BaseStudentAssessmentInspection::getAssessmentUserId)
  90. .innerJoin("base_class c ON t.class_ids LIKE CONCAT('%', c.id, '%')")
  91. .innerJoin("xjr_user u on c.teacher_id = u.id")
  92. .innerJoin("xjr_department d on c.org_id = d.id")
  93. .leftJoin(BaseStudentAssessmentClassRelation.class, BaseStudentAssessmentClassRelation::getBaseStudentAssessmentInspectionId, BaseStudentAssessmentInspection::getId)
  94. );
  95. PageOutput<BaseStudentAssessmentInspectionPageVo> pageOutput = ConventPage.getPageOutput(page, BaseStudentAssessmentInspectionPageVo.class);
  96. return RT.ok(pageOutput);
  97. }
  98. @GetMapping(value = "/info")
  99. @ApiOperation(value="根据id查询学生班级巡查考核信息")
  100. @SaCheckPermission("basestudentassessmentinspection:detail")
  101. public RT<BaseStudentAssessmentInspectionVo> info(@RequestParam Long id){
  102. BaseStudentAssessmentInspection baseStudentAssessmentInspection = baseStudentAssessmentInspectionService.getById(id);
  103. if (baseStudentAssessmentInspection == null) {
  104. return RT.error("找不到此数据!");
  105. }
  106. BaseStudentAssessmentInspectionVo baseStudentAssessmentInspectionVo = BeanUtil.toBean(baseStudentAssessmentInspection, BaseStudentAssessmentInspectionVo.class);
  107. //查询班级
  108. LambdaQueryWrapper<BaseStudentAssessmentClassRelation> classQueryWrapper = new LambdaQueryWrapper<>();
  109. classQueryWrapper
  110. .eq(BaseStudentAssessmentClassRelation::getBaseStudentAssessmentInspectionId, id)
  111. .select(BaseStudentAssessmentClassRelation.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentAssessmentClassRelationListVo.class).contains(x.getProperty()));
  112. List<BaseStudentAssessmentClassRelation> classList = baseStudentAssessmentClassRelationService.list(classQueryWrapper);
  113. baseStudentAssessmentInspectionVo.setClassList(BeanUtil.copyToList(classList, BaseStudentAssessmentClassRelationListVo.class));
  114. //查询学生
  115. LambdaQueryWrapper<BaseStudentAssessmentStudentRelation> studentQueryWrapper = new LambdaQueryWrapper<>();
  116. studentQueryWrapper
  117. .eq(BaseStudentAssessmentStudentRelation::getBaseStudentAssessmentInspectionId, id)
  118. .select(BaseStudentAssessmentStudentRelation.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentAssessmentStudentRelationVo.class).contains(x.getProperty()));
  119. List<BaseStudentAssessmentStudentRelation> studentList = baseStudentAssessmentStudentRelationService.list(studentQueryWrapper);
  120. baseStudentAssessmentInspectionVo.setStudentList(BeanUtil.copyToList(studentList, BaseStudentAssessmentStudentRelationVo.class));
  121. return RT.ok(baseStudentAssessmentInspectionVo);
  122. }
  123. @PostMapping
  124. @ApiOperation(value = "新增学生班级巡查考核")
  125. @SaCheckPermission("basestudentassessmentinspection:add")
  126. public RT<Boolean> add(@Valid @RequestBody AddBaseStudentAssessmentInspectionDto dto){
  127. BaseStudentAssessmentInspection baseStudentAssessmentInspection = BeanUtil.toBean(dto, BaseStudentAssessmentInspection.class);
  128. boolean isSuccess = baseStudentAssessmentInspectionService.save(baseStudentAssessmentInspection);
  129. return RT.ok(isSuccess);
  130. }
  131. @PutMapping
  132. @ApiOperation(value = "修改学生班级巡查考核")
  133. @SaCheckPermission("basestudentassessmentinspection:edit")
  134. public RT<Boolean> update(@Valid @RequestBody UpdateBaseStudentAssessmentInspectionDto dto){
  135. BaseStudentAssessmentInspection baseStudentAssessmentInspection = BeanUtil.toBean(dto, BaseStudentAssessmentInspection.class);
  136. return RT.ok(baseStudentAssessmentInspectionService.updateById(baseStudentAssessmentInspection));
  137. }
  138. @DeleteMapping
  139. @ApiOperation(value = "删除学生班级巡查考核")
  140. @SaCheckPermission("basestudentassessmentinspection:delete")
  141. public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
  142. return RT.ok(baseStudentAssessmentInspectionService.removeBatchByIds(ids));
  143. }
  144. }