|
@@ -4,6 +4,7 @@ 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.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
@@ -35,6 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.validation.Valid;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -83,9 +85,32 @@ public class StudentReportRecordController {
|
|
|
@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);
|
|
|
+ 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);
|
|
|
+ Long semesterId = null;
|
|
|
+ if(!semesterList.isEmpty()){
|
|
|
+ semesterId = semesterList.get(0).getId();
|
|
|
+ }
|
|
|
+ StudentReportRecord one = studentReportRecordService.getOne(
|
|
|
+ new QueryWrapper<StudentReportRecord>().lambda()
|
|
|
+ .eq(StudentReportRecord::getUserId, dto.getUserId())
|
|
|
+ .eq(StudentReportRecord::getBaseSemesterId, semesterId)
|
|
|
+ );
|
|
|
+ boolean isSuccess = true;
|
|
|
+ if(one != null){
|
|
|
+ one.setReportTime(new Date());
|
|
|
+ isSuccess = studentReportRecordService.updateById(one);
|
|
|
+ }else{
|
|
|
+ StudentReportRecord studentReportRecord = BeanUtil.toBean(dto, StudentReportRecord.class);
|
|
|
+ studentReportRecord.setBaseSemesterId(semesterId);
|
|
|
+ studentReportRecord.setReportTime(new Date());
|
|
|
+ isSuccess = studentReportRecordService.save(studentReportRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ return RT.ok(isSuccess);
|
|
|
}
|
|
|
|
|
|
@PutMapping
|
|
@@ -121,7 +146,7 @@ public class StudentReportRecordController {
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/class-statistics")
|
|
|
- @ApiOperation(value="班级统计(分页)")
|
|
|
+ @ApiOperation(value="班级统计")
|
|
|
@SaCheckPermission("studentreportrecord:detail")
|
|
|
public RT<StudentReportRecordStatisticsVo> classStatistics(@Valid StudentReportRecordStatisticsDto dto){
|
|
|
if(dto.getTeacherId() == null){
|
|
@@ -148,4 +173,32 @@ public class StudentReportRecordController {
|
|
|
return RT.ok(statisticsVo);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping(value = "/statistics")
|
|
|
+ @ApiOperation(value="领导统计")
|
|
|
+ @SaCheckPermission("studentreportrecord:detail")
|
|
|
+ public RT<StudentReportRecordStatisticsVo> statistics(@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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|