dzx 9 mesi fa
parent
commit
f3cc4221bc

+ 51 - 1
src/main/java/com/xjrsoft/module/student/controller/StudentTryReadingReportController.java

@@ -2,22 +2,27 @@ 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.dto.ChangeClassDto;
 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.StudentReportRecord;
 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;
@@ -25,6 +30,8 @@ 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;
 
@@ -100,4 +107,47 @@ public class StudentTryReadingReportController {
         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);
+    }
+
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/student/service/IStudentReportRecordService.java

@@ -47,8 +47,12 @@ public interface IStudentReportRecordService extends MPJBaseService<StudentRepor
 
     Boolean updateStduyStatus(StudentReportSignDto dto);
 
+    Boolean updateStduyStatusByTryReading(StudentReportSignDto dto);
+
     Page<StudentReportRecordPlanPageVo> getTryReadingPage(Page<StudentReportRecordPlanPageVo> page, StudentReportRecordPageDto dto);
 
+    List<StudentReportRecordPlanPageVo> getTryReadingList(StudentReportRecordPageDto dto);
+
     Boolean tryReadingSign(StudentReportSignDto dto);
 
     Boolean changeClass(StudentReportSignDto dto);

+ 8 - 0
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentSchoolRollServiceImpl.java

@@ -42,6 +42,7 @@ import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -285,6 +286,8 @@ public class BaseStudentSchoolRollServiceImpl extends MPJBaseServiceImpl<BaseStu
         User user = userMapper.selectById(userId);
         user.setDeleteMark(DeleteMark.NODELETE.getCode());
         user.setEnabledMark(EnabledMark.ENABLED.getCode());
+        user.setModifyUserId(StpUtil.getLoginIdAsLong());
+        user.setModifyDate(LocalDateTime.now());
         userMapper.updateById(user);
 
         //将学籍信息改为在读
@@ -295,6 +298,8 @@ public class BaseStudentSchoolRollServiceImpl extends MPJBaseServiceImpl<BaseStu
         schoolRoll.setDeleteMark(DeleteMark.NODELETE.getCode());
         schoolRoll.setEnabledMark(EnabledMark.ENABLED.getCode());
         schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
+        schoolRoll.setModifyUserId(StpUtil.getLoginIdAsLong());
+        schoolRoll.setModifyDate(LocalDateTime.now());
         this.updateById(schoolRoll);
 
         //将学生基本信息中状态改为正常
@@ -303,7 +308,10 @@ public class BaseStudentSchoolRollServiceImpl extends MPJBaseServiceImpl<BaseStu
                         .eq(BaseStudent::getUserId, userId)
         );
         baseStudent.setIsNormal(1);
+        baseStudent.setModifyUserId(StpUtil.getLoginIdAsLong());
+        baseStudent.setModifyDate(LocalDateTime.now());
         baseStudentMapper.updateById(baseStudent);
+
         return true;
     }
 }

+ 48 - 7
src/main/java/com/xjrsoft/module/student/service/impl/StudentReportRecordServiceImpl.java

@@ -249,11 +249,58 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         return true;
     }
 
+    /**
+     * 试读报到,把新生和学生基本信息中的数据都进行修改
+     * 不用记录异动信息
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean updateStduyStatusByTryReading(StudentReportSignDto dto) {
+        LocalDate now = LocalDate.now();
+        StudentReportRecord record = this.getById(dto.getId());
+        StudentReportPlan reportPlan = planMapper.selectById(record.getStudentReportPlanId());
+        if(!LocalDateUtil.isDateInRange(now, reportPlan.getUpdateStartTime(), reportPlan.getUpdateEndTime())){
+            throw new MyException("不在修改时间内,无法修改");
+        }
+        BaseNewStudent student = newStudentMapper.selectById(record.getUserId());
+
+        if(StudyStatusEnum.InResidence.getCode().equals(student.getStduyStatus())){
+            student.setStduyStatus(StudyStatusEnum.AttendDaySchool.getCode());
+        }else if(StudyStatusEnum.AttendDaySchool.getCode().equals(student.getStduyStatus())){
+            student.setStduyStatus(StudyStatusEnum.InResidence.getCode());
+        }
+        newStudentMapper.updateById(student);
+
+        User user = userService.getUserByParam(new GetUserByParamDto() {{
+            setCredentialNumber(student.getCredentialNumber());
+        }});
+
+        if(record.getReportTime() != null){
+
+            BaseStudentSchoolRoll roll = rollService.getOne(
+                    new QueryWrapper<BaseStudentSchoolRoll>().lambda()
+                            .eq(BaseStudentSchoolRoll::getUserId, user.getId())
+                            .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
+            );
+            roll.setStduyStatus(student.getStduyStatus());
+            roll.setModifyDate(LocalDateTime.now());
+            roll.setModifyUserId(StpUtil.getLoginIdAsLong());
+
+            rollService.updateById(roll);
+        }
+        return true;
+    }
+
     @Override
     public Page<StudentReportRecordPlanPageVo> getTryReadingPage(Page<StudentReportRecordPlanPageVo> page, StudentReportRecordPageDto dto) {
         return this.baseMapper.getTryReadingPage(page, dto);
     }
 
+    @Override
+    public List<StudentReportRecordPlanPageVo> getTryReadingList(StudentReportRecordPageDto dto) {
+        return this.baseMapper.getTryReadingList(dto);
+    }
+
     /**
      * 试读报到
      * @param dto
@@ -293,13 +340,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         if(user != null){
             //学生已存在,则修改班级信息
             rollService.updateStudentClass(baseClass.getId(), user.getId());
-            Integer deleteMark = user.getDeleteMark();
-            if(deleteMark != null && deleteMark == 1){
-                userService.recoveryStudentInfo(user.getId());
-                user.setDeleteMark(DeleteMark.NODELETE.getCode());
-            }
-            BeanUtil.copyProperties(student, user);
-            userService.updateById(user);
+            rollService.activateStudent(user.getId());
         }else{
             LocalDate birthDate = getBirthDate(student.getCredentialNumber());
             LocalDateTime now = LocalDateTime.now();

+ 1 - 1
src/main/resources/mapper/student/StudentReportRecordMapper.xml

@@ -337,6 +337,6 @@
         <if test="dto.reportTimeStart != null and dto.reportTimeEnd != null">
             and t1.report_time between #{dto.reportTimeStart} and #{dto.reportTimeEnd}
         </if>
-        ORDER BY t1.report_time IS NULL DESC, t1.report_time DESC,t5.name
+        ORDER BY t1.report_time IS NULL DESC, t1.report_time DESC,t5.name is null desc,t5.name
     </select>
 </mapper>