|
@@ -1,6 +1,8 @@
|
|
|
package com.ruoyi.project.sems.controller;
|
|
|
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
@@ -18,6 +20,7 @@ import com.ruoyi.project.system.domain.SysDictData;
|
|
|
import com.ruoyi.project.system.service.ISysDeptService;
|
|
|
import com.ruoyi.project.system.service.ISysDictTypeService;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -358,4 +361,86 @@ public class TSpecdevDzsbController extends BaseController
|
|
|
logger.info("failRow:" +String.valueOf(failRow));
|
|
|
return AjaxResult.success(String.valueOf(successNumber),failRow);
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/exportDevList")
|
|
|
+ public AjaxResult exportbmy(ParamData params) throws IOException {
|
|
|
+ logger.info(JSON.toJSONString(params));
|
|
|
+ String id = params.getIds();
|
|
|
+ String[] ids = id.split(",");
|
|
|
+ List<TSpecdevDzsb> list = new ArrayList<>();
|
|
|
+ for (String i : ids
|
|
|
+ ) {
|
|
|
+ TSpecdevDzsb t = tSpecdevDzsbService.getById(i);
|
|
|
+ list.add(t);
|
|
|
+ }
|
|
|
+ SXSSFWorkbook wb = new SXSSFWorkbook(1000);
|
|
|
+ CellStyle wrapStyle = wb.createCellStyle();
|
|
|
+ wrapStyle.setWrapText(true); //设置自动换行
|
|
|
+ //创建sheet页
|
|
|
+ Sheet sheet = wb.createSheet("sheet1");
|
|
|
+ //设置列的宽度,第一个参数为列的序号,从0开始,第二参数为列宽,单位1/256个字节
|
|
|
+ sheet.setColumnWidth(0, 12*256);
|
|
|
+ sheet.setColumnWidth(1, 26*256);
|
|
|
+ sheet.setColumnWidth(2, 26*256);
|
|
|
+ sheet.setColumnWidth(3, 26*256);
|
|
|
+ sheet.setColumnWidth(4, 26*256);
|
|
|
+ sheet.setColumnWidth(5, 26*256);
|
|
|
+ sheet.setColumnWidth(6, 26*256);
|
|
|
+ sheet.setColumnWidth(7, 26*256);
|
|
|
+ sheet.setColumnWidth(8, 40*256);
|
|
|
+ sheet.setColumnWidth(9, 40*256);
|
|
|
+ //设置开始行和开始列
|
|
|
+
|
|
|
+ Row row0 = sheet.createRow(0);
|
|
|
+ CellStyle style = wb.createCellStyle();
|
|
|
+ style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
|
|
|
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
+// Font headerFont = wb.createFont();
|
|
|
+// headerFont.setFontName("Arial");
|
|
|
+// headerFont.setFontHeightInPoints((short) 12);
|
|
|
+// headerFont.setBold(false);
|
|
|
+// headerFont.setColor(IndexedColors.BLACK.getIndex());
|
|
|
+// style.setFont(headerFont);
|
|
|
+ Cell cell0 = row0.createCell(0);
|
|
|
+ row0.createCell(0).setCellValue("序号");
|
|
|
+ row0.createCell(1).setCellValue("装置");
|
|
|
+ row0.createCell(2).setCellValue("设备位号");
|
|
|
+ row0.createCell(3).setCellValue("档案号");
|
|
|
+ row0.createCell(4).setCellValue("设备名称");
|
|
|
+ row0.createCell(5).setCellValue("检验单位");row0.getCell(5).setCellStyle(style);
|
|
|
+ row0.createCell(6).setCellValue("检验日期");row0.getCell(6).setCellStyle(style);
|
|
|
+ row0.createCell(7).setCellValue("报告编号");row0.getCell(7).setCellStyle(style);
|
|
|
+ row0.createCell(8).setCellValue("下次检验日期");row0.getCell(8).setCellStyle(style);
|
|
|
+ row0.createCell(9).setCellValue("定期检验结论");row0.getCell(9).setCellStyle(style);
|
|
|
+ //填充数据
|
|
|
+ int rowIndex = 1;
|
|
|
+ int columnIndex = 1;
|
|
|
+ for (TSpecdevDzsb t: list
|
|
|
+ ) {
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
+ row.createCell(0).setCellValue(t.getId());
|
|
|
+ row.createCell(1).setCellValue(t.getPlantCode());
|
|
|
+ row.createCell(2).setCellValue(t.getDevno());
|
|
|
+ row.createCell(3).setCellValue(t.getDocno());
|
|
|
+ row.createCell(4).setCellValue(t.getDevname());
|
|
|
+ row.createCell(5).setCellValue(t.getCheckUnit());
|
|
|
+ if (t.getWarnDate()!= null){
|
|
|
+ row.createCell(6).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getWarnDate()));
|
|
|
+ }
|
|
|
+
|
|
|
+ row.createCell(7).setCellValue(t.getReportNo());
|
|
|
+ if (t.getNextWarnDate()!= null){
|
|
|
+ row.createCell(8).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getNextWarnDate()));
|
|
|
+ }
|
|
|
+ row.createCell(9).setCellValue(t.getPerTestConclusion());
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ OutputStream out = null;
|
|
|
+ String filename = ExcelUtil.encodingFilename("起重机械批量更新");
|
|
|
+ out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
|
|
|
+ wb.write(out);
|
|
|
+ wb.close();
|
|
|
+ out.close();
|
|
|
+ return AjaxResult.success(filename);
|
|
|
+ }
|
|
|
}
|