|
|
@@ -17,10 +17,7 @@ import com.template.services.WelcomeSchoolService;
|
|
|
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.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
@@ -61,7 +58,7 @@ public class WelcomeBuildController implements WelcomeBuildControllerAPI {
|
|
|
String build = welcomeBuild.getBuild();
|
|
|
LambdaQueryWrapper<WelcomeBuild> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(WelcomeBuild::getBuild, build)
|
|
|
- .eq(WelcomeBuild::getSchool,welcomeBuild.getSchool());
|
|
|
+ .eq(WelcomeBuild::getSchool, welcomeBuild.getSchool());
|
|
|
WelcomeBuild wb = welcomeBuildService.getOne(wrapper);
|
|
|
|
|
|
if (ObjectUtils.isNotEmpty(wb)) {
|
|
|
@@ -87,7 +84,7 @@ public class WelcomeBuildController implements WelcomeBuildControllerAPI {
|
|
|
//先查询是否有当前楼栋信息
|
|
|
LambdaQueryWrapper<WelcomeBuild> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(WelcomeBuild::getBuild, welcomeBuild.getBuild())
|
|
|
- .eq(WelcomeBuild::getSchool,welcomeBuild.getSchool());
|
|
|
+ .eq(WelcomeBuild::getSchool, welcomeBuild.getSchool());
|
|
|
WelcomeBuild one = welcomeBuildService.getOne(wrapper);
|
|
|
|
|
|
if (ObjectUtils.isNotEmpty(one)) {
|
|
|
@@ -103,11 +100,11 @@ public class WelcomeBuildController implements WelcomeBuildControllerAPI {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommonResult listBuild(int currentPage, int pageCount, Integer schoolId,String buildId, String sex) {
|
|
|
+ public CommonResult listBuild(int currentPage, int pageCount, Integer schoolId, String buildId, String sex) {
|
|
|
|
|
|
- PageUtils<WelcomeBuildVo> pageUtils =welcomeBuildService.listBuild(currentPage,pageCount,schoolId,buildId,sex);
|
|
|
+ PageUtils<WelcomeBuildVo> pageUtils = welcomeBuildService.listBuild(currentPage, pageCount, schoolId, buildId, sex);
|
|
|
|
|
|
- return CommonResult.ok(pageUtils);
|
|
|
+ return CommonResult.ok(pageUtils);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -225,7 +222,7 @@ public class WelcomeBuildController implements WelcomeBuildControllerAPI {
|
|
|
String school = dataFormatter.formatCellValue(row.getCell(1));//校区名称
|
|
|
String build = dataFormatter.formatCellValue(row.getCell(2));//楼栋名称
|
|
|
Optional<WelcomeBuild> ob = wb.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build)).findFirst();
|
|
|
- if(ob != null && ob.isPresent()){
|
|
|
+ if (ob != null && ob.isPresent()) {
|
|
|
buildData.setId(ob.get().getId());
|
|
|
}
|
|
|
|
|
|
@@ -316,7 +313,7 @@ public class WelcomeBuildController implements WelcomeBuildControllerAPI {
|
|
|
String school = dataFormatter.formatCellValue(row.getCell(1));//校区名称
|
|
|
String build = dataFormatter.formatCellValue(row.getCell(2));//楼栋名称
|
|
|
Optional<WelcomeBuild> ob = wb.stream().filter(e -> e.getSchool().equals(school) && e.getBuild().equals(build)).findFirst();
|
|
|
- if(ob != null && ob.isPresent()){
|
|
|
+ if (ob != null && ob.isPresent()) {
|
|
|
buildData.setId(ob.get().getId());
|
|
|
}
|
|
|
|
|
|
@@ -349,29 +346,66 @@ public class WelcomeBuildController implements WelcomeBuildControllerAPI {
|
|
|
|
|
|
@Override
|
|
|
public void welcomeBuildExport(HttpServletResponse response, String schoolName, String buildName, String sex) {
|
|
|
- List<WelcomeBuild> result = welcomeBuildService.listBuild(schoolName,buildName,sex);
|
|
|
+ List<WelcomeBuild> result = welcomeBuildService.listBuild(schoolName, buildName, sex);
|
|
|
//导出
|
|
|
Workbook workbook = new XSSFWorkbook();
|
|
|
Sheet sheet = workbook.createSheet("楼栋信息");
|
|
|
+ // 创建样式对象
|
|
|
+ CellStyle style = workbook.createCellStyle();
|
|
|
+ // 设置边框样式
|
|
|
+ style.setBorderBottom(BorderStyle.THIN);
|
|
|
+ style.setBorderTop(BorderStyle.THIN);
|
|
|
+ style.setBorderRight(BorderStyle.THIN);
|
|
|
+ style.setBorderLeft(BorderStyle.THIN);
|
|
|
+ style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
|
|
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("备注");
|
|
|
+ Cell no = headerRow.createCell(0);
|
|
|
+ no.setCellStyle(style);
|
|
|
+ no.setCellValue("序号");
|
|
|
+ Cell school = headerRow.createCell(1);
|
|
|
+ school.setCellStyle(style);
|
|
|
+ school.setCellValue("校区名称");
|
|
|
+ Cell buildStr = headerRow.createCell(2);
|
|
|
+ buildStr.setCellStyle(style);
|
|
|
+ buildStr.setCellValue("楼栋名称");
|
|
|
+ Cell sexStr = headerRow.createCell(3);
|
|
|
+ sexStr.setCellStyle(style);
|
|
|
+ sexStr.setCellValue("楼栋性别");
|
|
|
+ Cell floors = headerRow.createCell(4);
|
|
|
+ floors.setCellStyle(style);
|
|
|
+ floors.setCellValue("楼栋层数");
|
|
|
+ Cell startFloor = headerRow.createCell(5);
|
|
|
+ startFloor.setCellStyle(style);
|
|
|
+ startFloor.setCellValue("起始层数");
|
|
|
+ Cell remark = headerRow.createCell(6);
|
|
|
+ remark.setCellStyle(style);
|
|
|
+ remark.setCellValue("备注");
|
|
|
for (int i = 0; i < result.size(); i++) {
|
|
|
WelcomeBuild build = result.get(i);
|
|
|
Row dataRow = sheet.createRow(i + 1);
|
|
|
- dataRow.createCell(0).setCellValue(i + 1);
|
|
|
- dataRow.createCell(1).setCellValue(build.getSchool());
|
|
|
- dataRow.createCell(2).setCellValue(build.getBuild());
|
|
|
- dataRow.createCell(3).setCellValue(build.getSex());
|
|
|
- dataRow.createCell(4).setCellValue(build.getFloors());
|
|
|
- dataRow.createCell(5).setCellValue(build.getStartFloor());
|
|
|
- dataRow.createCell(6).setCellValue(build.getRemark());
|
|
|
+ Cell nod = dataRow.createCell(0);
|
|
|
+ nod.setCellStyle(style);
|
|
|
+ nod.setCellValue(i + 1);
|
|
|
+ Cell schoold = dataRow.createCell(1);
|
|
|
+ schoold.setCellStyle(style);
|
|
|
+ schoold.setCellValue(build.getSchool());
|
|
|
+ Cell buildStrd = dataRow.createCell(2);
|
|
|
+ buildStrd.setCellStyle(style);
|
|
|
+ buildStrd.setCellValue(build.getBuild());
|
|
|
+ Cell sexd = dataRow.createCell(3);
|
|
|
+ sexd.setCellStyle(style);
|
|
|
+ sexd.setCellValue(build.getSex());
|
|
|
+ Cell floord = dataRow.createCell(4);
|
|
|
+ floord.setCellStyle(style);
|
|
|
+ floord.setCellValue(build.getFloors());
|
|
|
+ Cell startFloord = dataRow.createCell(5);
|
|
|
+ startFloord.setCellStyle(style);
|
|
|
+ startFloord.setCellValue(build.getStartFloor());
|
|
|
+ Cell remarkd = dataRow.createCell(6);
|
|
|
+ remarkd.setCellStyle(style);
|
|
|
+ remarkd.setCellValue(build.getRemark());
|
|
|
}
|
|
|
// 将工作簿写入文件
|
|
|
ExcelUtils.excelDownload(workbook, "楼栋信息.xlsx", response);
|