|
|
@@ -0,0 +1,151 @@
|
|
|
+package com.xjrsoft.module.student.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
+import com.xjrsoft.common.page.PageOutput;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
+import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
+import com.xjrsoft.module.student.dto.AddStudentReportRecordDto;
|
|
|
+import com.xjrsoft.module.student.dto.StudentReportRecordPageDto;
|
|
|
+import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
|
|
|
+import com.xjrsoft.module.student.dto.UpdateStudentReportRecordDto;
|
|
|
+import com.xjrsoft.module.student.entity.StudentReportRecord;
|
|
|
+import com.xjrsoft.module.student.service.IStudentReportRecordService;
|
|
|
+import com.xjrsoft.module.student.vo.StudentReportRecordPageVo;
|
|
|
+import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
|
|
|
+import com.xjrsoft.module.student.vo.StudentReportRecordVo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 学生报到记录表
|
|
|
+* @Author dzx
|
|
|
+* @Date: 2024-08-28
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/student" + "/studentReportRecord")
|
|
|
+@Api(value = "/student" + "/studentReportRecord",tags = "学生报到记录表代码")
|
|
|
+@AllArgsConstructor
|
|
|
+public class StudentReportRecordController {
|
|
|
+
|
|
|
+
|
|
|
+ private final IStudentReportRecordService studentReportRecordService;
|
|
|
+ private final IBaseSemesterService semesterService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/page")
|
|
|
+ @ApiOperation(value="学生报到记录表列表(分页)")
|
|
|
+ @SaCheckPermission("studentreportrecord:detail")
|
|
|
+ public RT<PageOutput<StudentReportRecordPageVo>> page(@Valid StudentReportRecordPageDto dto){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<StudentReportRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .orderByDesc(StudentReportRecord::getId)
|
|
|
+ .select(StudentReportRecord.class,x -> VoToColumnUtil.fieldsToColumns(StudentReportRecordPageVo.class).contains(x.getProperty()));
|
|
|
+ IPage<StudentReportRecord> page = studentReportRecordService.page(ConventPage.getPage(dto), queryWrapper);
|
|
|
+ PageOutput<StudentReportRecordPageVo> pageOutput = ConventPage.getPageOutput(page, StudentReportRecordPageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/info")
|
|
|
+ @ApiOperation(value="根据id查询学生报到记录表信息")
|
|
|
+ @SaCheckPermission("studentreportrecord:detail")
|
|
|
+ public RT<StudentReportRecordVo> info(@RequestParam Long id){
|
|
|
+ StudentReportRecord studentReportRecord = studentReportRecordService.getById(id);
|
|
|
+ if (studentReportRecord == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
+ }
|
|
|
+ return RT.ok(BeanUtil.toBean(studentReportRecord, StudentReportRecordVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "新增学生报到记录表")
|
|
|
+ @SaCheckPermission("studentreportrecord:add")
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddStudentReportRecordDto dto){
|
|
|
+ StudentReportRecord studentReportRecord = BeanUtil.toBean(dto, StudentReportRecord.class);
|
|
|
+ boolean isSuccess = studentReportRecordService.save(studentReportRecord);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation(value = "修改学生报到记录表")
|
|
|
+ @SaCheckPermission("studentreportrecord:edit")
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateStudentReportRecordDto dto){
|
|
|
+
|
|
|
+ StudentReportRecord studentReportRecord = BeanUtil.toBean(dto, StudentReportRecord.class);
|
|
|
+ return RT.ok(studentReportRecordService.updateById(studentReportRecord));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping
|
|
|
+ @ApiOperation(value = "删除学生报到记录表")
|
|
|
+ @SaCheckPermission("studentreportrecord:delete")
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
+ return RT.ok(studentReportRecordService.removeBatchByIds(ids));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/mobile-page")
|
|
|
+ @ApiOperation(value="班主任查询(分页)")
|
|
|
+ @SaCheckPermission("studentreportrecord:detail")
|
|
|
+ public RT<PageOutput<StudentReportRecordPageVo>> mobilePage(@Valid StudentReportRecordPageDto dto){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<StudentReportRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .orderByDesc(StudentReportRecord::getId)
|
|
|
+ .select(StudentReportRecord.class,x -> VoToColumnUtil.fieldsToColumns(StudentReportRecordPageVo.class).contains(x.getProperty()));
|
|
|
+ IPage<StudentReportRecord> page = studentReportRecordService.page(ConventPage.getPage(dto), queryWrapper);
|
|
|
+ PageOutput<StudentReportRecordPageVo> pageOutput = ConventPage.getPageOutput(page, StudentReportRecordPageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/class-statistics")
|
|
|
+ @ApiOperation(value="班级统计(分页)")
|
|
|
+ @SaCheckPermission("studentreportrecord:detail")
|
|
|
+ public RT<StudentReportRecordStatisticsVo> classStatistics(@Valid StudentReportRecordStatisticsDto dto){
|
|
|
+ if(dto.getTeacherId() == null){
|
|
|
+ dto.setTeacherId(StpUtil.getLoginIdAsLong());
|
|
|
+ }
|
|
|
+ if(dto.getBaseSemesterId() == null){
|
|
|
+ LambdaQueryWrapper<BaseSemester> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .orderByDesc(BaseSemester::getStartDate)
|
|
|
+ .select(BaseSemester.class,x -> VoToColumnUtil.fieldsToColumns(BaseSemester.class).contains(x.getProperty()));
|
|
|
+ List<BaseSemester> semesterList = semesterService.list(queryWrapper);
|
|
|
+ if(!semesterList.isEmpty()){
|
|
|
+ dto.setBaseSemesterId(semesterList.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ StudentReportRecordStatisticsVo statisticsVo = studentReportRecordService.getClassStatistics(dto);
|
|
|
+ long notArrivedCount = statisticsVo.getAllCount() - statisticsVo.getArrivedCount();
|
|
|
+ statisticsVo.setNotArrivedCount(notArrivedCount);
|
|
|
+ BigDecimal divide = BigDecimal.ZERO;
|
|
|
+ if( statisticsVo.getAllCount() != 0){
|
|
|
+ divide = BigDecimal.valueOf(statisticsVo.getArrivedCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ statisticsVo.setReportRate(divide.doubleValue());
|
|
|
+ return RT.ok(statisticsVo);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|