package com.template.controller; import com.alibaba.druid.sql.visitor.functions.If; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.sun.org.apache.bcel.internal.generic.NEW; import com.template.api.WelcomeBedControllerAPI; import com.template.common.utils.BeanUtil; import com.template.common.utils.ExcelUtils; import com.template.common.utils.paramUtils; import com.template.model.enumModel.eFileType; import com.template.model.pojo.*; import com.template.model.request.InsertWelcomeBedRequest; import com.template.model.request.UpdateWelcomeBedRequest; import com.template.model.result.CommonResult; import com.template.model.result.PageUtils; import com.template.model.vo.*; import com.template.services.*; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; import java.util.*; import java.util.stream.Collectors; /** *

* 前端控制器 *

* * @author ceshi * @since 2025-06-13 */ @RestController public class WelcomeBedController implements WelcomeBedControllerAPI { @Autowired private WelcomeOrgService welcomeOrgService; @Autowired private WelcomeBedService welcomeBedService; @Autowired private WelcomeBuildService welcomeBuildService; @Autowired private WelcomeStudentService welcomeStudentService; @Autowired private WelcomeDormitoryService welcomeDormitoryService; @Autowired private WelcomeSchoolService welcomeSchoolService; @Autowired private WelcomeAccountService welcomeAccountService; @Override public CommonResult insertBedInfo(InsertWelcomeBedRequest iwbr, BindingResult bindingResult) { if (bindingResult.hasErrors()) { String st = paramUtils.getParamError(bindingResult); return CommonResult.fail(st); } WelcomeDormitory byId = welcomeDormitoryService.getById(iwbr.getDormitoryId()); if (ObjectUtils.isEmpty(byId)) { return CommonResult.fail("该宿舍号不存在"); } if (!byId.getSex().equals(iwbr.getSex())) { return CommonResult.fail("请勿跨性别添加床位"); } Integer bedNumber = byId.getBedNumber(); // 查询该寝室下有多少床位 LambdaQueryWrapper wrapper=new LambdaQueryWrapper<>(); wrapper.eq(WelcomeBed::getDormitoryId,iwbr.getDormitoryId()); List list = welcomeBedService.list(wrapper); if (list.size()>=bedNumber) { return CommonResult.fail("该寝室的床位号已满"); } WelcomeBed existData = welcomeBedService.queryBedData(iwbr.getSchool(), iwbr.getBuildId(), iwbr.getDormitoryId(), iwbr.getNumber()); if (existData != null) { return CommonResult.fail("该床位号已存在,请勿重复插入!"); } WelcomeBed wb = new WelcomeBed(); if (StringUtils.hasText(iwbr.getCardNum())) { WelcomeStudent student = welcomeStudentService.queryStudentInfo(iwbr.getCollegeId(), iwbr.getMajorId(), iwbr.getClassstrId(), iwbr.getCardNum()); if (student == null) { return CommonResult.fail("当前学生信息在系统中不存在!"); } wb.setStudentCard(student.getCardId()); wb.setCardNum(iwbr.getCardNum()); wb.setName(iwbr.getName()); } wb.setNumber(iwbr.getNumber()); wb.setSchool(iwbr.getSchool()); wb.setSchoolId(iwbr.getSchoolId()); wb.setBuildId(iwbr.getBuildId()); wb.setBuild(iwbr.getBuild()); wb.setDormitoryId(iwbr.getDormitoryId()); wb.setDormitory(iwbr.getDormitory()); wb.setSex(iwbr.getSex()); wb.setIsCheck(StringUtils.hasText(iwbr.getCardNum()) ? 1 : 0); wb.setRemark(iwbr.getRemark()); wb.setInstructor(iwbr.getInstructor()); wb.setGrade(iwbr.getGrade()); wb.setCollegeId(iwbr.getCollegeId()); wb.setCollege(iwbr.getCollege()); wb.setMajorId(iwbr.getMajorId()); wb.setMajor(iwbr.getMajor()); wb.setClassstrId(iwbr.getClassstrId()); wb.setClassstr(iwbr.getClassstr()); wb.setRetentionState(iwbr.getRetentionState()); int result = welcomeBedService.insertWelcomeBed(wb); return result > 0 ? CommonResult.ok("添加成功!") : CommonResult.fail("添加失败"); } @Override public CommonResult updateBedInfo(UpdateWelcomeBedRequest uwbr, BindingResult bindingResult) throws Exception { if (bindingResult.hasErrors()) { String st = paramUtils.getParamError(bindingResult); return CommonResult.fail(st); } WelcomeBed oldData = welcomeBedService.getBedById(uwbr.getId()); if (oldData == null) { return CommonResult.fail("床位信息已失效,编辑失败"); } WelcomeDormitory byId = welcomeDormitoryService.getById(uwbr.getDormitoryId()); if (ObjectUtils.isEmpty(byId)) { return CommonResult.fail("该宿舍号不存在"); } if (!byId.getSex().equals(uwbr.getSex())) { return CommonResult.fail("请勿跨性别修改床位"); } WelcomeBed existData = welcomeBedService.queryBedData(uwbr.getSchool(), uwbr.getBuildId(), uwbr.getDormitoryId(), uwbr.getNumber()); if (existData != null && existData.getId().intValue() != uwbr.getId().intValue()) { return CommonResult.fail("该床位号已存在,请勿重复插入!"); } if (StringUtils.hasText(uwbr.getCardNum())) { WelcomeStudent student = welcomeStudentService.queryStudentInfo(uwbr.getCollegeId(), uwbr.getMajorId(), uwbr.getClassstrId(), uwbr.getCardNum()); if (student == null) { return CommonResult.fail("当前学生信息在系统中不存在!"); } oldData.setStudentCard(student.getCardId()); oldData.setCollegeId(uwbr.getCollegeId()); oldData.setCollege(uwbr.getCollege()); oldData.setMajorId(uwbr.getMajorId()); oldData.setMajor(uwbr.getMajor()); oldData.setClassstrId(uwbr.getClassstrId()); oldData.setClassstr(uwbr.getClassstr()); oldData.setCardNum(uwbr.getCardNum()); oldData.setName(uwbr.getName()); } oldData.setNumber(uwbr.getNumber()); oldData.setSchool(uwbr.getSchool()); oldData.setSchoolId(uwbr.getSchoolId()); oldData.setBuildId(uwbr.getBuildId()); oldData.setBuild(uwbr.getBuild()); oldData.setDormitoryId(uwbr.getDormitoryId()); oldData.setDormitory(uwbr.getDormitory()); oldData.setSex(uwbr.getSex()); oldData.setCollegeId(uwbr.getCollegeId()); oldData.setCollege(uwbr.getCollege()); oldData.setMajorId(uwbr.getMajorId()); oldData.setMajor(uwbr.getMajor()); oldData.setClassstrId(uwbr.getClassstrId()); oldData.setClassstr(uwbr.getClassstr()); oldData.setIsCheck(uwbr.getIsCheck()); oldData.setCardNum(uwbr.getCardNum()); oldData.setName(uwbr.getName()); oldData.setRemark(uwbr.getRemark()); oldData.setInstructor(uwbr.getInstructor()); oldData.setGrade(uwbr.getGrade()); int result = welcomeBedService.updateWelcomeBed(oldData); return result > 0 ? CommonResult.ok("编辑成功!") : CommonResult.fail("编辑失败"); } @Override public CommonResult queryPageBeds(int currentPage, int pageCount, Integer schoolId, Integer buildId, Integer dormitoryId, String sex, Integer isCheck, Integer collegeId, Integer majorId, Integer classstrId,Integer retentionState,Integer accountId) { // 当学院为空 PageUtils result=null; if (ObjectUtils.isEmpty(collegeId)) { WelcomeAccount account = welcomeAccountService.getById(accountId); if (ObjectUtils.isEmpty(account)) { return CommonResult.fail("当前账号不存在,请重新登入"); } String aClassstrId = account.getCollegeId(); String[] split = aClassstrId.split(","); List collegeIds = new ArrayList<>(); for (String s : split) { collegeIds.add(s); } result = welcomeBedService.queryPageWelcomeBedsC(currentPage, pageCount, schoolId, buildId, dormitoryId, sex, isCheck, collegeIds, majorId, classstrId,retentionState); }else { result = welcomeBedService.queryPageWelcomeBeds(currentPage, pageCount, schoolId, buildId, dormitoryId, sex, isCheck, collegeId, majorId, classstrId,retentionState); } return CommonResult.ok(result); } @Override public CommonResult deleteBedInfo(int id) throws Exception { int result = welcomeBedService.deleteWelcomeBedById(id); return result > 0 ? CommonResult.ok() : CommonResult.fail(); } @Override public CommonResult importBedExcel(MultipartFile file) throws IOException, ParseException { System.out.println("导入床位信息"); if (file.isEmpty() || file.getSize() == 0) { return CommonResult.fail("导入文件不能为空"); } String ContentType = file.getContentType(); InputStream inputStream = file.getInputStream(); List result = new ArrayList<>(); //xls格式文件 if (ContentType.equals(eFileType.Xls.getValue())) { CommonResult> resultData = readXls(inputStream); if (!resultData.isSuccess()) { return resultData; } result = resultData.getData(); } else if (ContentType.equals(eFileType.Xlsx.getValue())) { CommonResult> resultData = readXlsx(inputStream); if (!resultData.isSuccess()) { return resultData; } result = resultData.getData(); } else { return CommonResult.fail("床位信息数据导入只支持Xls或Xlsx格式文件"); } List admissNums = result.stream().map(WelcomeBed::getCardNum).distinct().collect(Collectors.toList()); if (admissNums != null && admissNums.size() > 0) { List students = welcomeStudentService.getDataByAdmissNum(admissNums); if (students != null && students.size() > 0) { for (WelcomeBed r : result) { Optional os = students.stream().filter(e -> e.getAdmissNum().equals(r.getCardNum())).findFirst(); if (os != null && os.isPresent()) { r.setStudentCard(os.get().getCardId()); } } } } boolean resultBool = welcomeBedService.saveOrUpdateBatch(result); System.out.println("导入楼栋1"); return resultBool ? CommonResult.ok("导入成功") : CommonResult.fail("导入失败"); } /** * xls文件读取方法 * * @param inputStream * @return * @throws IOException * @throws ParseException */ private CommonResult> readXls(InputStream inputStream) throws IOException, ParseException { List result = new ArrayList<>(); HSSFWorkbook sheets = new HSSFWorkbook(inputStream); List wb = welcomeBedService.list(null); List wos = welcomeOrgService.list(null); List wbils = welcomeBuildService.list(null); List wds = welcomeDormitoryService.list(null); List ws = welcomeSchoolService.list(null); Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); //读取第一张sheet HSSFSheet sheetAt = sheets.getSheetAt(0); DataFormatter dataFormatter = new DataFormatter(); try { //rowNum = 3 从第三行开始获取值 //sheetAt.getLastRowNum():从0开始统计数量 所以得+1 for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) { HSSFRow row = sheetAt.getRow(rowNum); if (row != null) { //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。 //所以先使用setCellType()方法先将该单元格的类型设置为STRING //然后poi会根据字符串读取它 if (rowNum == 0) { String school = dataFormatter.formatCellValue(row.getCell(0));//校区名称 if (!school.equals("校区名称")) { return CommonResult.fail("导入数据第一列为校区名称"); } String build = dataFormatter.formatCellValue(row.getCell(1));//楼栋名称 if (!build.equals("楼栋名称")) { return CommonResult.fail("导入数据第二列为楼栋名称"); } String dormitory = dataFormatter.formatCellValue(row.getCell(2));//寝室号 if (!dormitory.equals("寝室号")) { return CommonResult.fail("导入数据第三列为寝室号"); } String number = dataFormatter.formatCellValue(row.getCell(3));//床位号 if (!number.equals("床位号")) { return CommonResult.fail("导入数据第四列为床位号"); } String sex = dataFormatter.formatCellValue(row.getCell(4));//床位性别 if (!sex.equals("床位性别")) { return CommonResult.fail("导入数据第五列为床位性别"); } String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院 if (!college.equals("所属学院")) { return CommonResult.fail("导入数据第六列为所属学院"); } String major = dataFormatter.formatCellValue(row.getCell(6));//所属专业 if (!major.equals("所属专业")) { return CommonResult.fail("导入数据第七列为所属专业"); } String classstr = dataFormatter.formatCellValue(row.getCell(7));//所属班级 if (!classstr.equals("所属班级")) { return CommonResult.fail("导入数据第八列为所属班级"); } String instructor = dataFormatter.formatCellValue(row.getCell(8));//辅导员 if (!instructor.equals("辅导员")) { return CommonResult.fail("导入数据第九列为辅导员"); } String remark = dataFormatter.formatCellValue(row.getCell(9));//备注 if (!remark.equals("备注")) { return CommonResult.fail("导入数据第十列为备注"); } } else { WelcomeBed bedData = new WelcomeBed(); String school = dataFormatter.formatCellValue(row.getCell(0));//校区 if (ObjectUtils.isEmpty(school)) { continue; } String build = dataFormatter.formatCellValue(row.getCell(1));//楼栋 String dormitory = dataFormatter.formatCellValue(row.getCell(2));//寝室号 String number = dataFormatter.formatCellValue(row.getCell(3));//床位号 Optional ob = wb.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build) && e.getDormitory().equals(dormitory) && e.getNumber().intValue() == Integer.valueOf(number).intValue()).findFirst(); if (ob != null && ob.isPresent()) { bedData.setId(ob.get().getId()); } String sex = dataFormatter.formatCellValue(row.getCell(4));//床位性别 String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院 String major = dataFormatter.formatCellValue(row.getCell(6));//所属专业 String classstr = dataFormatter.formatCellValue(row.getCell(7));//所属班级 String instructor = dataFormatter.formatCellValue(row.getCell(8));//辅导员 String remark = dataFormatter.formatCellValue(row.getCell(9));//备注 //校区 if (ws != null && ws.size() > 0) { Optional wsl = ws.stream().filter(e -> e.getSchool().equals(school)).findFirst(); if (wsl != null && wsl.isPresent()) { bedData.setSchoolId(wsl.get().getId()); bedData.setSchool(school); } else { int h=rowNum+1; return CommonResult.fail("第" +h+ "行,不存在该校区"); } } //楼栋 if (wbils != null && wbils.size() > 0) { Optional oBuild = wbils.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build)).findFirst(); if (oBuild != null && oBuild.isPresent()) { bedData.setBuild(build); bedData.setBuildId(oBuild.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该楼栋"); } } //寝室 if (wds != null && wds.size() > 0) { Optional oDormitory = wds.stream().filter(e ->e.getSchool().equals(school) && e.getBuild().equals(build) && e.getDormitory().equals(dormitory)).findFirst(); if (oDormitory != null && oDormitory.isPresent()) { if (!oDormitory.get().getSex().equals(sex)) { int h=rowNum+1; return CommonResult.fail("第" + h + "行,床位性别和寝室性别不一致"); } if (!oDormitory.get().getCollege().equals(college)) { int h=rowNum+1; return CommonResult.fail("第" + h + "行,床位院系和寝室院系不一致"); } bedData.setDormitory(dormitory); bedData.setDormitoryId(oDormitory.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该寝室号"); } } bedData.setNumber(Integer.valueOf(number)); bedData.setSex(sex); //region 院系专业 Optional owo = wos.stream().filter(e -> e.getName().equals(college)).findFirst(); if (owo != null && owo.isPresent()) { bedData.setCollege(college); bedData.setCollegeId(owo.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该院系"); } // 专业 Optional omwo = wos.stream().filter(e -> e.getName().equals(major) && e.getParentId().equals(owo.get().getId())).findFirst(); if (omwo != null && omwo.isPresent()) { bedData.setMajor(major); bedData.setMajorId(omwo.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该专业"); } // 班级 Optional ocwo = wos.stream().filter(e -> e.getName().equals(classstr) && e.getParentId().equals(omwo.get().getId())).findFirst(); if (ocwo != null && ocwo.isPresent()) { bedData.setClassstr(classstr); bedData.setClassstrId(ocwo.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该班级"); } //endregion bedData.setIsCheck(0); bedData.setRemark(remark); bedData.setRetentionState(1); bedData.setInstructor(instructor); bedData.setGrade(year); result.add(bedData); } } } } catch (Exception e) { return CommonResult.fail("请按模板格式导入数据"); } return CommonResult.ok(result); } /** * xls文件读取方法 * * @param inputStream * @return * @throws IOException * @throws ParseException */ private CommonResult> readXlsx(InputStream inputStream) throws IOException, ParseException { List result = new ArrayList<>(); XSSFWorkbook sheets = new XSSFWorkbook(inputStream); List wb = welcomeBedService.list(null); List wos = welcomeOrgService.list(null); List wbils = welcomeBuildService.list(null); List wds = welcomeDormitoryService.list(null); List ws = welcomeSchoolService.list(null); //读取第一张sheet XSSFSheet sheetAt = sheets.getSheetAt(0); DataFormatter dataFormatter = new DataFormatter(); Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); try { //rowNum = 3 从第三行开始获取值 //sheetAt.getLastRowNum():从0开始统计数量 所以得+1 for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) { XSSFRow row = sheetAt.getRow(rowNum); if (row != null) { //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。 //所以先使用setCellType()方法先将该单元格的类型设置为STRING //然后poi会根据字符串读取它 if (rowNum == 0) { String school = dataFormatter.formatCellValue(row.getCell(0));//校区名称 if (!school.equals("校区名称")) { return CommonResult.fail("导入数据第一列为校区名称"); } String build = dataFormatter.formatCellValue(row.getCell(1));//楼栋名称 if (!build.equals("楼栋名称")) { return CommonResult.fail("导入数据第二列为楼栋名称"); } String dormitory = dataFormatter.formatCellValue(row.getCell(2));//寝室号 if (!dormitory.equals("寝室号")) { return CommonResult.fail("导入数据第三列为寝室号"); } String number = dataFormatter.formatCellValue(row.getCell(3));//床位号 if (!number.equals("床位号")) { return CommonResult.fail("导入数据第四列为床位号"); } String sex = dataFormatter.formatCellValue(row.getCell(4));//床位性别 if (!sex.equals("床位性别")) { return CommonResult.fail("导入数据第五列为床位性别"); } String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院 if (!college.equals("所属学院")) { return CommonResult.fail("导入数据第六列为所属学院"); } String major = dataFormatter.formatCellValue(row.getCell(6));//所属专业 if (!major.equals("所属专业")) { return CommonResult.fail("导入数据第七列为所属专业"); } String classstr = dataFormatter.formatCellValue(row.getCell(7));//所属班级 if (!classstr.equals("所属班级")) { return CommonResult.fail("导入数据第八列为所属班级"); } String instructor = dataFormatter.formatCellValue(row.getCell(8));//辅导员 if (!instructor.equals("辅导员")) { return CommonResult.fail("导入数据第九列为辅导员"); } String remark = dataFormatter.formatCellValue(row.getCell(9));//备注 if (!remark.equals("备注")) { return CommonResult.fail("导入数据第十列为备注"); } } else { WelcomeBed bedData = new WelcomeBed(); String school = dataFormatter.formatCellValue(row.getCell(0));//校区 if (ObjectUtils.isEmpty(school)) { continue; } String build = dataFormatter.formatCellValue(row.getCell(1));//楼栋 String dormitory = dataFormatter.formatCellValue(row.getCell(2));//寝室号 String number = dataFormatter.formatCellValue(row.getCell(3));//床位号 Optional ob = wb.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build) && e.getDormitory().equals(dormitory) && e.getNumber().intValue() == Integer.valueOf(number).intValue()).findFirst(); if (ob != null && ob.isPresent()) { bedData.setId(ob.get().getId()); } String sex = dataFormatter.formatCellValue(row.getCell(4));//床位性别 String college = dataFormatter.formatCellValue(row.getCell(5));//所属学院 String major = dataFormatter.formatCellValue(row.getCell(6));//所属专业 String classstr = dataFormatter.formatCellValue(row.getCell(7));//所属班级 String instructor = dataFormatter.formatCellValue(row.getCell(8));//辅导员 String remark = dataFormatter.formatCellValue(row.getCell(9));//备注 //校区 if (ws != null && ws.size() > 0) { Optional wsl = ws.stream().filter(e -> e.getSchool().equals(school)).findFirst(); if (wsl != null && wsl.isPresent()) { bedData.setSchoolId(wsl.get().getId()); bedData.setSchool(school); } else { int h=rowNum+1; return CommonResult.fail("第" +h+ "行,不存在该校区"); } } //楼栋 if (wbils != null && wbils.size() > 0) { Optional oBuild = wbils.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build)).findFirst(); if (oBuild != null && oBuild.isPresent()) { bedData.setBuild(build); bedData.setBuildId(oBuild.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该楼栋"); } } //寝室 if (wds != null && wds.size() > 0) { Optional oDormitory = wds.stream().filter(e ->e.getSchool().equals(school) && e.getBuild().equals(build) && e.getDormitory().equals(dormitory)).findFirst(); if (oDormitory != null && oDormitory.isPresent()) { if (!oDormitory.get().getSex().equals(sex)) { int h=rowNum+1; return CommonResult.fail("第" + h + "行,床位性别和寝室性别不一致"); } if (!oDormitory.get().getCollege().equals(college)) { int h=rowNum+1; return CommonResult.fail("第" + h + "行,床位院系和寝室院系不一致"); } bedData.setDormitory(dormitory); bedData.setDormitoryId(oDormitory.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该寝室号"); } } bedData.setNumber(Integer.valueOf(number)); bedData.setSex(sex); //region 院系专业 Optional owo = wos.stream().filter(e -> e.getName().equals(college)).findFirst(); if (owo != null && owo.isPresent()) { bedData.setCollege(college); bedData.setCollegeId(owo.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该院系"); } // 专业 Optional omwo = wos.stream().filter(e -> e.getName().equals(major) && e.getParentId().equals(owo.get().getId())).findFirst(); if (omwo != null && omwo.isPresent()) { bedData.setMajor(major); bedData.setMajorId(omwo.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该专业"); } // 班级 Optional ocwo = wos.stream().filter(e -> e.getName().equals(classstr) && e.getParentId().equals(omwo.get().getId())).findFirst(); if (ocwo != null && ocwo.isPresent()) { bedData.setClassstr(classstr); bedData.setClassstrId(ocwo.get().getId()); }else { int h=rowNum+1; return CommonResult.fail("第" + h + "行,不存在该班级"); } //endregion bedData.setIsCheck(0); bedData.setRemark(remark); bedData.setRetentionState(1); bedData.setInstructor(instructor); bedData.setGrade(year); result.add(bedData); } } } } catch (Exception e) { return CommonResult.fail("请按模板格式导入数据"); } return CommonResult.ok(result); } @Override public CommonResult downloadBedExcel() { return CommonResult.ok("200", "操作成功", "https://chtech.ncjti.edu.cn/welcome/homeimage/床位信息管理.xlsx"); } @Override public void welcomeBedExport(HttpServletResponse response, Integer schoolId, Integer buildId, Integer dormitoryId, String sex, Integer isCheck, Integer collegeId, Integer majorId, Integer classstrId,Integer retentionState,Integer accountId) { // 当学院为空 List result=null; if (ObjectUtils.isEmpty(collegeId)) { WelcomeAccount account = welcomeAccountService.getById(accountId); if (ObjectUtils.isEmpty(account)) { throw new RuntimeException("当前账号不存在,请重新登入"); } String aClassstrId = account.getCollegeId(); String[] split = aClassstrId.split(","); List collegeIds = new ArrayList<>(); for (String s : split) { collegeIds.add(s); } result = welcomeBedService.queryPageWelcomeBedsS(schoolId, buildId, dormitoryId, sex, isCheck, collegeIds, majorId, classstrId,retentionState); }else { result = welcomeBedService.queryPageWelcomeBeds(schoolId, buildId, dormitoryId, sex, isCheck, collegeId, majorId, classstrId,retentionState); } //导出 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("是否入住"); headerRow.createCell(12).setCellValue("录取号"); headerRow.createCell(13).setCellValue("姓名"); headerRow.createCell(14).setCellValue("备注"); headerRow.createCell(15).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.getSchool()); dataRow.createCell(2).setCellValue(bed.getBuild()); dataRow.createCell(3).setCellValue(bed.getDormitory()); dataRow.createCell(4).setCellValue(bed.getNumber()); dataRow.createCell(5).setCellValue(bed.getSex()); if (ObjectUtils.isEmpty(bed.getGrade())) { dataRow.createCell(6).setCellValue(""); }else { dataRow.createCell(6).setCellValue(bed.getGrade()); } dataRow.createCell(7).setCellValue(bed.getCollege()); dataRow.createCell(8).setCellValue(bed.getMajor()); dataRow.createCell(9).setCellValue(bed.getClassstr()); dataRow.createCell(10).setCellValue(bed.getInstructor()); Integer isCheck1 = bed.getIsCheck(); String rz=""; if (isCheck1==1) { rz="是"; }else { rz="否"; } dataRow.createCell(11).setCellValue(rz); dataRow.createCell(12).setCellValue(bed.getCardNum()); dataRow.createCell(13).setCellValue(bed.getName()); dataRow.createCell(14).setCellValue(bed.getRemark()); Integer retentionState1 = bed.getRetentionState(); String bl=""; if (1==retentionState1) { bl="否"; }else { bl="是"; } dataRow.createCell(15).setCellValue(bl); } // 将工作簿写入文件 ExcelUtils.excelDownload(workbook, "床位信息.xlsx", response); } @Override public CommonResult submit(String studentCard,WelcomeBed welcomeBed) { welcomeBed.setStudentCard(studentCard); // 先判断是否已经提交 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(WelcomeBed::getStudentCard, studentCard); WelcomeBed one = welcomeBedService.getOne(wrapper); if (ObjectUtils.isNotEmpty(one)) { return CommonResult.fail("当前用户已选择宿舍,请勿重复提交"); } WelcomeBed wb = welcomeBedService.getBedById(welcomeBed.getId()); if (wb == null) { return CommonResult.fail("床位已失效,选择失败!"); } if (wb.getIsCheck()==1) { return CommonResult.fail("该床位已被其他人入住"); } if (StringUtils.hasText(wb.getStudentCard()) && !wb.getStudentCard().equals(welcomeBed.getStudentCard())) { return CommonResult.fail("该床位已被其他人入住,选择失败!"); } boolean updateBed = welcomeBedService.updateById(welcomeBed); // 修改宿舍信息 WelcomeDormitory welcomeDormitory = welcomeDormitoryService.getById(welcomeBed.getDormitoryId()); if (ObjectUtils.isNotEmpty(welcomeDormitory)) { Integer freeBedNumber = welcomeDormitory.getFreeBedNumber(); freeBedNumber = freeBedNumber - 1; if (freeBedNumber > 0) { welcomeDormitory.setFreeBedNumber(freeBedNumber); welcomeDormitory.setStatus(3); } else if (freeBedNumber == 0) { welcomeDormitory.setFreeBedNumber(freeBedNumber); welcomeDormitory.setStatus(1); } boolean updateResult = welcomeDormitoryService.updateById(welcomeDormitory); if(!updateResult){ return CommonResult.fail("更新失败"); } } if (!updateBed) { return CommonResult.fail("选宿舍失败"); } return CommonResult.ok(); } @Override public CommonResult bedDetails(String studentCard) { List result = new ArrayList<>(); WelcomeStudent student = welcomeStudentService.getDataByIdcard(studentCard); if(student == null){ return CommonResult.fail("558","当前学生信息已失效,查看失败"); } // 获取未入住的床位 List beds = welcomeBedService.queryBedList(studentCard); for (BedInfosVo bed:beds) { BedDetailsVo data = new BedDetailsVo(); if(bed.getStudentCard() != null && bed.getStudentCard().equals(studentCard)){ data.setPicture(student.getPicture()); data.setCardNum(student.getAdmissNum()); data.setAdmissNum(student.getAdmissNum()); data.setName(student.getName()); data.setSex(student.getSex()); data.setNationality(student.getNationality()); data.setCollege(student.getCollege()); data.setMajor(student.getMajor()); data.setClassstr(student.getClassstr()); data.setBatchValue(student.getBatchValue()); data.setExamNum(student.getExamNum()); data.setStudentCard(student.getCardId()); data.setAddress(student.getAddress()); data.setPhone(student.getPhone()); } data.setBuild(bed.getBuild()); data.setDormitory(bed.getDormitory()); data.setNumber(bed.getNumber()); data.setIsCheck(bed.getIsCheck()); result.add(data); } return CommonResult.ok(result); } @Override public CommonResult queryBedDatas(int dormitoryId) { List beds = welcomeBedService.queryDormitorys(dormitoryId); List datas = new ArrayList<>(); for (WelcomeBed bed : beds) { ListVo data = new ListVo(); data.setId(bed.getId()); data.setName(String.valueOf(bed.getNumber())); datas.add(data); } return CommonResult.ok(datas); } @Override public CommonResult isCheck(String studentCard) { WelcomeBedCheckVo vo = welcomeBedService.isCheck(studentCard); if (ObjectUtils.isEmpty(vo)) { vo = new WelcomeBedCheckVo(); vo.setIsCheck(0); } return CommonResult.ok(vo); } @Override public CommonResult batchOperationBed(BatchOperationBedVo batchOperationVo) { List bedIds = batchOperationVo.getBedIds(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(WelcomeBed::getId, bedIds); List list = welcomeBedService.list(wrapper); if (ObjectUtils.isNotEmpty(list)) { for (WelcomeBed welcomeBed : list) { welcomeBed.setRetentionState(batchOperationVo.getRetentionState()); } welcomeBedService.updateBatchById(list); } return CommonResult.ok(); } @Override @Transactional(rollbackFor = Exception.class) public CommonResult checkIn(CheckInVo checkInVo) { List list = welcomeStudentService.getStudent(checkInVo); if (ObjectUtils.isEmpty(list)) { return CommonResult.fail("暂无该学生"); } else if (list.size() > 1) { return CommonResult.fail("该录取号有多个学生,请检查修改后在试"); } WelcomeStudent welcomeStudent = list.get(0); WelcomeBed bed = welcomeBedService.getBedById(checkInVo.getBedId()); if (ObjectUtils.isEmpty(bed)) { return CommonResult.fail("不存在该床铺"); } if (bed.getIsCheck()==1) { return CommonResult.fail("该床位已被其他人入住"); } if (!welcomeStudent.getCollegeId().equals(bed.getCollegeId())) { return CommonResult.fail("请勿跨学院入住"); } if (!welcomeStudent.getSex().equals(bed.getSex())) { return CommonResult.fail("请勿跨性别入住"); } bed.setIsCheck(1); bed.setStudentCard(welcomeStudent.getCardId()); bed.setCardNum(welcomeStudent.getAdmissNum()); bed.setClassstrId(welcomeStudent.getClassstrId()); bed.setClassstr(welcomeStudent.getClassstr()); bed.setName(welcomeStudent.getName()); bed.setMajorId(welcomeStudent.getMajorId()); bed.setMajor(welcomeStudent.getMajor()); welcomeBedService.updateWelcomeBed(bed); // 修改寝室信息 WelcomeDormitory welcomeDormitory = welcomeDormitoryService.getById(bed.getDormitoryId()); if (ObjectUtils.isNotEmpty(welcomeDormitory)) { Integer freeBedNumber = welcomeDormitory.getFreeBedNumber(); freeBedNumber = freeBedNumber - 1; if (freeBedNumber > 0) { welcomeDormitory.setFreeBedNumber(freeBedNumber); welcomeDormitory.setStatus(3); } else if (freeBedNumber == 0) { welcomeDormitory.setFreeBedNumber(freeBedNumber); welcomeDormitory.setStatus(1); } welcomeDormitoryService.updateById(welcomeDormitory); } return CommonResult.ok(); } @Override @Transactional(rollbackFor = Exception.class) public CommonResult checkOutDormitory(Integer bedId) { WelcomeBed bed = welcomeBedService.getBedById(bedId); if (ObjectUtils.isEmpty(bed)) { return CommonResult.fail("无该床铺信息"); } welcomeBedService.updateData(bedId); // 修改寝室信息 WelcomeDormitory welcomeDormitory = welcomeDormitoryService.getById(bed.getDormitoryId()); if (ObjectUtils.isNotEmpty(welcomeDormitory)) { Integer freeBedNumber = welcomeDormitory.getFreeBedNumber(); Integer bedNumber = welcomeDormitory.getBedNumber(); freeBedNumber = freeBedNumber + 1; if (bedNumber.equals(freeBedNumber)) { welcomeDormitory.setFreeBedNumber(freeBedNumber); welcomeDormitory.setStatus(1); } else if (bedNumber > freeBedNumber) { welcomeDormitory.setFreeBedNumber(freeBedNumber); welcomeDormitory.setStatus(3); } welcomeDormitoryService.updateById(welcomeDormitory); } return CommonResult.ok(); } @Override public CommonResult bedGroup(Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId) { return null; } @Override @Transactional(rollbackFor = Exception.class) public CommonResult changeBed(ChangeBedVo changeBedVo) { Integer sourceBedId = changeBedVo.getSourceBedId(); Integer changeBedId = changeBedVo.getChangeBedId(); WelcomeBed sourceBed = welcomeBedService.getBedById(sourceBedId); WelcomeBed changeBed = welcomeBedService.getBedById(changeBedId); if (ObjectUtils.isEmpty(sourceBed) || ObjectUtils.isEmpty(changeBed)) { return CommonResult.fail("床位不存在"); } if (!sourceBed.getCollegeId().equals(changeBed.getCollegeId())) { return CommonResult.fail("请勿跨学院换床位"); } if (!sourceBed.getSex().equals(changeBed.getSex())) { return CommonResult.fail("请勿跨性别换床位"); } changeBed.setIsCheck(1); changeBed.setStudentCard(sourceBed.getStudentCard()); changeBed.setCardNum(sourceBed.getCardNum()); changeBed.setClassstrId(sourceBed.getClassstrId()); changeBed.setClassstr(sourceBed.getClassstr()); changeBed.setName(sourceBed.getName()); changeBed.setMajorId(sourceBed.getMajorId()); changeBed.setMajor(sourceBed.getMajor()); changeBed.setInstructor(sourceBed.getInstructor()); welcomeBedService.updateData(sourceBedId); // 修改寝室信息 WelcomeDormitory welcomeDormitoryC = welcomeDormitoryService.getById(changeBed.getDormitoryId()); if (ObjectUtils.isNotEmpty(welcomeDormitoryC)) { Integer freeBedNumber = welcomeDormitoryC.getFreeBedNumber(); freeBedNumber = freeBedNumber - 1; if (freeBedNumber > 0) { welcomeDormitoryC.setFreeBedNumber(freeBedNumber); welcomeDormitoryC.setStatus(3); } else if (freeBedNumber == 0) { welcomeDormitoryC.setFreeBedNumber(freeBedNumber); welcomeDormitoryC.setStatus(1); } welcomeDormitoryService.updateById(welcomeDormitoryC); } // 修改寝室信息 WelcomeDormitory welcomeDormitory = welcomeDormitoryService.getById(sourceBed.getDormitoryId()); if (ObjectUtils.isNotEmpty(welcomeDormitory)) { Integer freeBedNumber = welcomeDormitory.getFreeBedNumber(); Integer bedNumber = welcomeDormitory.getBedNumber(); freeBedNumber = freeBedNumber + 1; if (bedNumber.equals(freeBedNumber)) { welcomeDormitory.setFreeBedNumber(freeBedNumber); welcomeDormitory.setStatus(1); } else if (bedNumber > freeBedNumber) { welcomeDormitory.setFreeBedNumber(freeBedNumber); welcomeDormitory.setStatus(3); } welcomeDormitoryService.updateById(welcomeDormitory); } welcomeBedService.updateById(changeBed); return CommonResult.ok(); } @Override public CommonResult checkInBedGroup(Integer schoolId, Integer buildId, Integer dormitoryId,Integer bedId,Integer collegeId) { // 获取已入住的床位 List beds = welcomeBedService.checkInBedGroup(schoolId, buildId, dormitoryId,bedId,collegeId); return CommonResult.ok(beds); } @Override public CommonResult replaceBed(ReplaceBedVo replaceBedVo) { Integer sourceBedId = replaceBedVo.getSourceBedId(); Integer changeBedId = replaceBedVo.getChangeBedId(); WelcomeBed sourceBed = welcomeBedService.getBedById(sourceBedId); WelcomeBed changeBed = welcomeBedService.getBedById(changeBedId); if (ObjectUtils.isEmpty(sourceBed) || ObjectUtils.isEmpty(changeBed)) { return CommonResult.fail("床位不存在"); } if (!sourceBed.getCollegeId().equals(changeBed.getCollegeId())) { return CommonResult.fail("请勿跨学院床位对调"); } if (!sourceBed.getSex().equals(changeBed.getSex())) { return CommonResult.fail("请勿跨性别对调床位"); } // 源数据 WelcomeBed welcomeBed = new WelcomeBed(); BeanUtil.copyProperties(sourceBed,welcomeBed); WelcomeBed welcomeBed2 = new WelcomeBed(); BeanUtil.copyProperties(changeBed,welcomeBed2); String studentCard = sourceBed.getStudentCard(); String cardNum = sourceBed.getCardNum(); Integer classstrId = sourceBed.getClassstrId(); String classstr = sourceBed.getClassstr(); String name = sourceBed.getName(); Integer majorId = sourceBed.getMajorId(); 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(); welcomeBed.setStudentCard(studentCard2); welcomeBed.setCardNum(cardNum2); welcomeBed.setClassstrId(classstrId2); welcomeBed.setClassstr(classstr2); welcomeBed.setName(name2); welcomeBed.setMajorId(majorId2); welcomeBed.setMajor(major2); welcomeBed.setInstructor(instructor2); welcomeBed2.setStudentCard(studentCard); welcomeBed2.setCardNum(cardNum); welcomeBed2.setClassstrId(classstrId); welcomeBed2.setClassstr(classstr); welcomeBed2.setName(name); welcomeBed2.setMajorId(majorId); welcomeBed2.setMajor(major); welcomeBed2.setInstructor(instructor); ArrayList welcomeBeds = new ArrayList<>(); welcomeBeds.add(welcomeBed); welcomeBeds.add(welcomeBed2); 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,Integer accountId) { // 当学院为空 PageUtils result=null; if (ObjectUtils.isEmpty(collegeId)) { WelcomeAccount account = welcomeAccountService.getById(accountId); if (ObjectUtils.isEmpty(account)) { return CommonResult.fail("当前账号不存在,请重新登入"); } String aClassstrId = account.getCollegeId(); String[] split = aClassstrId.split(","); List collegeIds = new ArrayList<>(); for (String s : split) { collegeIds.add(s); } result = welcomeBedService.studentAccommodationPageS(currentPage, pageCount, schoolId, buildId, dormitoryId,collegeIds, majorId, classstrId,name); }else { 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,Integer accountId) { // 当学院为空 List result=null; if (ObjectUtils.isEmpty(collegeId)) { WelcomeAccount account = welcomeAccountService.getById(accountId); if (ObjectUtils.isEmpty(account)) { throw new RuntimeException("当前账号不存在,请重新登入"); } String aClassstrId = account.getCollegeId(); String[] split = aClassstrId.split(","); List collegeIds = new ArrayList<>(); for (String s : split) { collegeIds.add(s); } result =welcomeBedService.studentAccommodationListS( schoolId, buildId, dormitoryId,collegeIds, majorId, classstrId,name); }else { 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); } @Override public CommonResult changeBuildGroup(Integer schoolId, Integer collegeId, String sex) { // 获取未入住的楼栋 List beds = welcomeBedService.changeBuildGroup(schoolId,collegeId,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeBuildGroupVo vo = new ChangeBuildGroupVo(); vo.setBuild(bed.getBuild()); vo.setBuildId(bed.getBuildId()); vos.add(vo); } return CommonResult.ok(vos); } @Override public CommonResult changeDormitoryGroup(Integer schoolId, Integer buildId, Integer collegeId, String sex) { // 获取未入住的寝室 List beds = welcomeBedService.changeDormitoryGroup(schoolId,buildId,collegeId,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeDormitoryGroupVo vo = new ChangeDormitoryGroupVo(); vo.setDormitory(bed.getDormitory()); vo.setDormitoryId(bed.getDormitoryId()); vos.add(vo); } return CommonResult.ok(vos); } @Override public CommonResult changeBedGroup(Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId,String sex) { // 获取未入住的床位 List beds = welcomeBedService.changeBedGroup(schoolId, buildId, dormitoryId,collegeId,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeBedGroupVo vo = new ChangeBedGroupVo(); vo.setBedId(bed.getId()); vo.setNumber(bed.getNumber()); vos.add(vo); } return CommonResult.ok(vos); } @Override public CommonResult replaceBuildGroup(Integer schoolId, Integer collegeId, String sex) { // 获取已入住的楼栋 List beds = welcomeBedService.replaceBuildGroup(schoolId,collegeId,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeBuildGroupVo vo = new ChangeBuildGroupVo(); vo.setBuild(bed.getBuild()); vo.setBuildId(bed.getBuildId()); vos.add(vo); } return CommonResult.ok(vos); } @Override public CommonResult replaceDormitoryGroup(Integer schoolId, Integer buildId, Integer collegeId, String sex) { // 获取已入住的寝室 List beds = welcomeBedService.replaceDormitoryGroup(schoolId,buildId,collegeId,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeDormitoryGroupVo vo = new ChangeDormitoryGroupVo(); vo.setDormitory(bed.getDormitory()); vo.setDormitoryId(bed.getDormitoryId()); vos.add(vo); } return CommonResult.ok(vos); } @Override public CommonResult replaceBedGroup(Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId, String sex) { // 获取已入住的床位 List beds = welcomeBedService.replaceBedGroup(schoolId, buildId, dormitoryId,collegeId,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeBedGroupVo vo = new ChangeBedGroupVo(); vo.setBedId(bed.getId()); vo.setNumber(bed.getNumber()); vos.add(vo); } return CommonResult.ok(vos); } @Override public CommonResult hBuildGroup(Integer schoolId, Integer collegeId, Integer majorId, Integer classstrid, String sex) { // 获取未入住的楼栋 List beds = welcomeBedService.hBuildGroup(schoolId,collegeId,majorId,classstrid,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeBuildGroupVo vo = new ChangeBuildGroupVo(); vo.setBuild(bed.getBuild()); vo.setBuildId(bed.getBuildId()); vos.add(vo); } return CommonResult.ok(vos); } @Override public CommonResult hDormitoryGroup(Integer schoolId, Integer buildId, Integer collegeId, Integer majorId, Integer classstrid, String sex) { // 获取未入住的寝室 List beds = welcomeBedService.hDormitoryGroup(schoolId,buildId,collegeId,majorId,classstrid,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeDormitoryGroupVo vo = new ChangeDormitoryGroupVo(); vo.setDormitory(bed.getDormitory()); vo.setDormitoryId(bed.getDormitoryId()); vos.add(vo); } return CommonResult.ok(vos); } @Override public CommonResult hBedGroup(Integer schoolId, Integer buildId, Integer dormitoryId, Integer collegeId, Integer majorId, Integer classstrid, String sex) { // 获取未入住的床位 List beds = welcomeBedService.hBedGroup(schoolId, buildId, dormitoryId,collegeId,majorId,classstrid,sex); ArrayList vos = new ArrayList<>(); for (WelcomeBed bed : beds) { ChangeBedGroupVo vo = new ChangeBedGroupVo(); vo.setBedId(bed.getId()); vo.setNumber(bed.getNumber()); vos.add(vo); } return CommonResult.ok(vos); } }