| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- 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.alibaba.excel.EasyExcel;
- import com.alibaba.excel.support.ExcelTypeEnum;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.xjrsoft.common.annotation.XjrLog;
- import com.xjrsoft.common.enums.RoleCodeEnum;
- import com.xjrsoft.common.model.result.RT;
- import com.xjrsoft.common.page.ConventPage;
- import com.xjrsoft.common.page.PageOutput;
- import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
- import com.xjrsoft.module.student.dto.ChangeBandingStatusDto;
- import com.xjrsoft.module.student.dto.StudentReportRecordPageDto;
- import com.xjrsoft.module.student.dto.StudentReportSignDto;
- import com.xjrsoft.module.student.entity.StudentReportPlan;
- import com.xjrsoft.module.student.entity.StudentReportRecord;
- import com.xjrsoft.module.student.service.IStudentReportPlanService;
- import com.xjrsoft.module.student.service.IStudentReportRecordService;
- import com.xjrsoft.module.student.vo.StudentReportRecordExcelVo;
- import com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.AllArgsConstructor;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import javax.validation.Valid;
- import java.io.ByteArrayOutputStream;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * @title: 新生维护信息
- * @Author dzx
- * @Date: 2024-06-27
- * @Version 1.0
- */
- @RestController
- @RequestMapping("/student" + "/tryReadingReport")
- @Api(value = "/student" + "/tryReadingReport",tags = "试读报到模块代码")
- @AllArgsConstructor
- public class StudentTryReadingReportController {
- private final IStudentReportRecordService recordService;
- private final IBandingTaskClassStudentService classStudentService;
- private final IStudentReportPlanService reportPlanService;
- @GetMapping(value = "/page")
- @ApiOperation(value="试读报到(分页)")
- @SaCheckPermission("tryreadingreport:detail")
- @XjrLog(value="试读报到(分页)")
- public RT<PageOutput<StudentReportRecordPlanPageVo>> page(@Valid StudentReportRecordPageDto dto){
- List<String> roleList = StpUtil.getRoleList();
- if(roleList.contains("CLASSTE") && roleList.contains("TEACHER")){
- dto.setTeacherId(StpUtil.getLoginIdAsLong());
- }
- Page<StudentReportRecordPlanPageVo> page = recordService.getTryReadingPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
- PageOutput<StudentReportRecordPlanPageVo> pageOutput = ConventPage.getPageOutput(page, StudentReportRecordPlanPageVo.class);
- return RT.ok(pageOutput);
- }
- @PostMapping("/clear-class")
- @ApiOperation(value = "非本班学生")
- @SaCheckPermission("tryreadingreport:add")
- @XjrLog(value="非本班学生")
- public RT<Boolean> clearClass(@Valid @RequestBody ChangeBandingStatusDto dto){
- StudentReportRecord record = recordService.getById(dto.getId());
- StudentReportPlan reportPlan = reportPlanService.getById(record.getStudentReportPlanId());
- List<Long> list = new ArrayList<>();
- list.add(record.getUserId());
- classStudentService.removeStudent(list, reportPlan.getBandingTaskId());
- return RT.ok(true);
- }
- @PostMapping(value = "/sign")
- @ApiOperation(value="试读报到")
- @SaCheckPermission("tryreadingreport:detail")
- @XjrLog(value="试读报到")
- public RT<Boolean> sign(@Valid @RequestBody StudentReportSignDto dto){
- return RT.ok(recordService.tryReadingSign(dto));
- }
- @PostMapping(value = "/all-sign")
- @ApiOperation(value="变更为已报到")
- @SaCheckPermission("tryreadingreport:detail")
- @XjrLog(value="试读报到")
- public RT<Boolean> sign(@Valid @RequestBody List<Long> ids){
- for (Long id : ids) {
- recordService.tryReadingSign(new StudentReportSignDto(){{
- setId(id);
- }});
- }
- return RT.ok(true);
- }
- @PostMapping("/change-class")
- @ApiOperation(value = "调整班级")
- @SaCheckPermission("tryreadingreport:change-class")
- @XjrLog(value = "调整班级")
- public RT<Boolean> changeClass(@Valid @RequestBody StudentReportSignDto dto){
- boolean isSuccess = recordService.changeClass(dto);
- return RT.ok(isSuccess);
- }
- @PostMapping(value = "/update-stduyStatus")
- @ApiOperation(value="切换就读方式")
- @SaCheckPermission("tryreadingreport:update-stduyStatus")
- @XjrLog(value = "切换就读方式")
- public RT<Boolean> updateStduyStatus(@Valid @RequestBody StudentReportSignDto dto){
- boolean isSuccess = recordService.updateStduyStatusByTryReading(dto);
- return RT.ok(isSuccess);
- }
- @PostMapping(value = "/export-query")
- @ApiOperation(value="导出")
- @SaCheckPermission("studentreportrecord:detail")
- public ResponseEntity<byte[]> exportQuerty(@Valid @RequestBody StudentReportRecordPageDto dto){
- List<StudentReportRecordExcelVo> dataList = new ArrayList<>();
- List<String> roleList = StpUtil.getRoleList();
- if(roleList.contains(RoleCodeEnum.TEACHER.getCode()) && roleList.contains(RoleCodeEnum.CLASSTE.getCode())){
- if(dto.getClassId() == null){
- dto.setTeacherId(StpUtil.getLoginIdAsLong());
- }
- }
- List<StudentReportRecordPlanPageVo> planPageList = recordService.getTryReadingList(dto);
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- for (StudentReportRecordPlanPageVo pageVo : planPageList) {
- StudentReportRecordExcelVo excelVo = BeanUtil.toBean(pageVo, StudentReportRecordExcelVo.class);
- if(pageVo.getReportTime() != null){
- excelVo.setReportTime(sdf.format(pageVo.getReportTime()));
- }
- excelVo.setIsReport("否");
- if(pageVo.getIsReport() != null && pageVo.getIsReport() == 1){
- excelVo.setIsReport("是");
- }
- dataList.add(excelVo);
- }
- ByteArrayOutputStream bot = new ByteArrayOutputStream();
- EasyExcel.write(bot, StudentReportRecordExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList);
- String fileName = "exportQuerty" + ExcelTypeEnum.XLSX.getValue();
- return RT.fileStream(bot.toByteArray(), fileName);
- }
- }
|