Browse Source

添加学生住宿信息功能

liu 1 year ago
parent
commit
fa6e9d4f3b

+ 7 - 0
src/main/java/com/template/api/WelcomeBedControllerAPI.java

@@ -90,5 +90,12 @@ public interface WelcomeBedControllerAPI {
     @ApiOperation(value = "床位对调", notes = "床位对调", httpMethod = "POST")
     @ApiOperation(value = "床位对调", notes = "床位对调", httpMethod = "POST")
     CommonResult replaceBed(@RequestBody ReplaceBedVo replaceBedVo);
     CommonResult replaceBed(@RequestBody ReplaceBedVo replaceBedVo);
 
 
+    @GetMapping(value = "/studentAccommodationPage")
+    @ApiOperation(value = "学生住宿分页展示", notes = "学生住宿分页展示", httpMethod = "GET")
+    CommonResult studentAccommodationPage(@RequestParam int currentPage, @RequestParam int pageCount,Integer schoolId,Integer buildId,Integer dormitoryId,Integer collegeId,Integer majorId, Integer classstrId,String name);
+
+    @GetMapping(value = "/studentAccommodationListExport")
+    @ApiOperation(value = "导出学生住宿信息", notes = "导出学生住宿信息", httpMethod = "GET")
+    void studentAccommodationListExport(HttpServletResponse response, Integer schoolId,Integer buildId,Integer dormitoryId,Integer collegeId,Integer majorId, Integer classstrId,String name);
 
 
 }
 }

+ 89 - 3
src/main/java/com/template/controller/WelcomeBedController.java

@@ -846,6 +846,7 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
         changeBed.setName(sourceBed.getName());
         changeBed.setName(sourceBed.getName());
         changeBed.setMajorId(sourceBed.getMajorId());
         changeBed.setMajorId(sourceBed.getMajorId());
         changeBed.setMajor(sourceBed.getMajor());
         changeBed.setMajor(sourceBed.getMajor());
+        changeBed.setInstructor(sourceBed.getInstructor());
         welcomeBeds.add(changeBed);
         welcomeBeds.add(changeBed);
 
 
         sourceBed.setIsCheck(0);
         sourceBed.setIsCheck(0);
@@ -856,6 +857,7 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
         sourceBed.setName(null);
         sourceBed.setName(null);
         sourceBed.setMajorId(null);
         sourceBed.setMajorId(null);
         sourceBed.setMajor(null);
         sourceBed.setMajor(null);
+        sourceBed.setInstructor(null);
         welcomeBeds.add(sourceBed);
         welcomeBeds.add(sourceBed);
 
 
         //        修改寝室信息
         //        修改寝室信息
@@ -911,16 +913,100 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
         if (ObjectUtils.isEmpty(sourceBed) || ObjectUtils.isEmpty(changeBed)) {
         if (ObjectUtils.isEmpty(sourceBed) || ObjectUtils.isEmpty(changeBed)) {
             return CommonResult.fail("床位不存在");
             return CommonResult.fail("床位不存在");
         }
         }
+//        源数据
         String studentCard = sourceBed.getStudentCard();
         String studentCard = sourceBed.getStudentCard();
         String cardNum = sourceBed.getCardNum();
         String cardNum = sourceBed.getCardNum();
         Integer classstrId = sourceBed.getClassstrId();
         Integer classstrId = sourceBed.getClassstrId();
         String classstr = sourceBed.getClassstr();
         String classstr = sourceBed.getClassstr();
         String name = sourceBed.getName();
         String name = sourceBed.getName();
         Integer majorId = sourceBed.getMajorId();
         Integer majorId = sourceBed.getMajorId();
-        sourceBed.getMajor();
-//        welcomeBeds.add(changeBed);
+        String major = sourceBed.getMajor();
+        String instructor = sourceBed.getInstructor();
+
+//        交换床位数据
+        String studentCard2 = changeBed.getStudentCard();
+        String cardNum2 = changeBed.getCardNum();
+        Integer classstrId2 = changeBed.getClassstrId();
+        String classstr2 = changeBed.getClassstr();
+        String name2 = changeBed.getName();
+        Integer majorId2 = changeBed.getMajorId();
+        String major2 = changeBed.getMajor();
+        String instructor2 = changeBed.getInstructor();
+
+
+        sourceBed.setStudentCard(studentCard2);
+        sourceBed.setCardNum(cardNum2);
+        sourceBed.setClassstrId(classstrId2);
+        sourceBed.setClassstr(classstr2);
+        sourceBed.setName(name2);
+        sourceBed.setMajorId(majorId2);
+        sourceBed.setMajor(major2);
+        sourceBed.setInstructor(instructor2);
+
+        changeBed.setStudentCard(studentCard);
+        changeBed.setCardNum(cardNum);
+        changeBed.setClassstrId(classstrId);
+        changeBed.setClassstr(classstr);
+        changeBed.setName(name);
+        changeBed.setMajorId(majorId);
+        changeBed.setMajor(major);
+        changeBed.setInstructor(instructor);
+
+        ArrayList<WelcomeBed> welcomeBeds = new ArrayList<>();
+        welcomeBeds.add(sourceBed);
+        welcomeBeds.add(changeBed);
+
+        welcomeBedService.updateBatchById(welcomeBeds);
+        return CommonResult.ok();
+    }
+
+    @Override
+    public CommonResult studentAccommodationPage(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId, Integer majorId, Integer classstrId, String name) {
+        PageUtils<WelcomeBed> result = welcomeBedService.studentAccommodationPage(currentPage, pageCount, schoolId, buildId, dormitoryId,collegeId, majorId, classstrId,name);
+        return CommonResult.ok(result);
+    }
+
+    @Override
+    public void studentAccommodationListExport(HttpServletResponse response, Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId, Integer majorId, Integer classstrId, String name) {
+        List<WelcomeBed> result=welcomeBedService.studentAccommodationList( schoolId, buildId, dormitoryId,collegeId, majorId, classstrId,name);
+
+        //导出
+        Workbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("床位信息");
+
+        Row headerRow = sheet.createRow(0);
+        headerRow.createCell(0).setCellValue("序号");
+        headerRow.createCell(1).setCellValue("录取号");
+        headerRow.createCell(2).setCellValue("学生姓名");
+        headerRow.createCell(3).setCellValue("校区名称");
+        headerRow.createCell(4).setCellValue("学院");
+        headerRow.createCell(5).setCellValue("专业");
+        headerRow.createCell(6).setCellValue("班级");
+        headerRow.createCell(7).setCellValue("性别");
+        headerRow.createCell(8).setCellValue("楼栋名称");
+        headerRow.createCell(9).setCellValue("寝室号");
+        headerRow.createCell(10).setCellValue("床位号");
+        headerRow.createCell(11).setCellValue("辅导员");
+
+        for (int i = 0; i < result.size(); i++) {
+            WelcomeBed bed = result.get(i);
+            Row dataRow = sheet.createRow(i + 1);
+            dataRow.createCell(0).setCellValue(i + 1);
+            dataRow.createCell(1).setCellValue(bed.getCardNum());
+            dataRow.createCell(2).setCellValue(bed.getName());
+            dataRow.createCell(3).setCellValue(bed.getSchool());
+            dataRow.createCell(4).setCellValue(bed.getCollege());
+            dataRow.createCell(5).setCellValue(bed.getMajor());
+            dataRow.createCell(6).setCellValue(bed.getClassstr());
+            dataRow.createCell(7).setCellValue(bed.getSex());
+            dataRow.createCell(8).setCellValue(bed.getBuild());
+            dataRow.createCell(9).setCellValue(bed.getDormitory());
+            dataRow.createCell(10).setCellValue(bed.getNumber());
+            dataRow.createCell(11).setCellValue(bed.getInstructor());
+        }
+        // 将工作簿写入文件
+        ExcelUtils.excelDownload(workbook, "学生住宿信息.xlsx", response);
 
 
-        return null;
     }
     }
 }
 }
 
 

+ 4 - 0
src/main/java/com/template/services/WelcomeBedService.java

@@ -47,4 +47,8 @@ public interface WelcomeBedService extends IService<WelcomeBed> {
     WelcomeBedCheckVo isCheck(String studentCard);
     WelcomeBedCheckVo isCheck(String studentCard);
 
 
     List<WelcomeBed> checkInBedGroup(Integer schoolId, Integer buildId, Integer dormitoryId);
     List<WelcomeBed> checkInBedGroup(Integer schoolId, Integer buildId, Integer dormitoryId);
+
+    PageUtils<WelcomeBed> studentAccommodationPage(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId, Integer majorId, Integer classstrId, String name);
+
+    List<WelcomeBed> studentAccommodationList(Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId, Integer majorId, Integer classstrId, String name);
 }
 }

+ 33 - 0
src/main/java/com/template/services/impl/WelcomeBedServiceImpl.java

@@ -175,4 +175,37 @@ public class WelcomeBedServiceImpl extends ServiceImpl<WelcomeBedMapper, Welcome
         return result;
         return result;
     }
     }
 
 
+    @Override
+    public PageUtils<WelcomeBed> studentAccommodationPage(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId, Integer majorId, Integer classstrId, String name) {
+        Page<WelcomeBed> page = new Page<>(currentPage, pageCount);
+        QueryWrapper<WelcomeBed> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq(schoolId != null, "school_id", schoolId);
+        queryWrapper.eq(buildId != null, "build_id", buildId);
+        queryWrapper.eq(dormitoryId != null, "dormitory_id", dormitoryId);
+        queryWrapper.eq(collegeId != null, "college_id", collegeId);
+        queryWrapper.eq(majorId != null, "major_id", majorId);
+        queryWrapper.eq(classstrId != null, "classstr_id", classstrId);
+        queryWrapper.like(name != null, "name", name);
+        queryWrapper.eq( "is_check", 1);
+        queryWrapper.orderByDesc("update_time");
+        IPage<WelcomeBed> result = welcomeBedMapper.selectPage(page, queryWrapper);
+        return new PageUtils<>(result);
+    }
+
+    @Override
+    public List<WelcomeBed> studentAccommodationList(Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId, Integer majorId, Integer classstrId, String name) {
+        QueryWrapper<WelcomeBed> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq(schoolId != null, "school_id", schoolId);
+        queryWrapper.eq(buildId != null, "build_id", buildId);
+        queryWrapper.eq(dormitoryId != null, "dormitory_id", dormitoryId);
+        queryWrapper.eq(collegeId != null, "college_id", collegeId);
+        queryWrapper.eq(majorId != null, "major_id", majorId);
+        queryWrapper.eq(classstrId != null, "classstr_id", classstrId);
+        queryWrapper.like(name != null, "name", name);
+        queryWrapper.eq( "is_check", 1);
+        queryWrapper.orderByDesc("update_time");
+        List<WelcomeBed> result = welcomeBedMapper.selectList(queryWrapper);
+        return result;
+    }
+
 }
 }