|
|
@ -12,10 +12,7 @@ import io.swagger.v3.oas.annotations.Operation; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
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.XSSFWorkbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
@ -23,6 +20,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
@ -93,11 +91,17 @@ public class AuditRecordController { |
|
|
|
} |
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
Sheet sheet = workbook.createSheet("审计记录"); |
|
|
|
CellStyle headerStyle = workbook.createCellStyle(); |
|
|
|
Font font = workbook.createFont(); |
|
|
|
font.setFontName("Arial"); // 使用标准字体 |
|
|
|
font.setBold(true); |
|
|
|
headerStyle.setFont(font); |
|
|
|
Row headerRow = sheet.createRow(0); |
|
|
|
String[] headers = {"ID", "用户名", "溶液名称", "浓度", "通道ID", "体积", "创建时间", "更新时间"}; |
|
|
|
String[] headers = {"ID", "用户名", "溶液名称", "浓度(%)", "通道", "体积(ml)", "创建时间"}; |
|
|
|
for (int i = 0; i < headers.length; i++) { |
|
|
|
Cell cell = headerRow.createCell(i); |
|
|
|
cell.setCellValue(headers[i]); |
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
} |
|
|
|
// 填充数据 |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
@ -107,10 +111,11 @@ public class AuditRecordController { |
|
|
|
row.createCell(1).setCellValue(record.getUserNickname()); |
|
|
|
row.createCell(2).setCellValue(record.getSolutionName()); |
|
|
|
row.createCell(3).setCellValue(record.getConcentration()); |
|
|
|
row.createCell(4).setCellValue(record.getChannelCode()); |
|
|
|
row.createCell(4).setCellValue(record.getChannelCode().substring(record.getChannelCode().length() - 1)); |
|
|
|
row.createCell(5).setCellValue(record.getUsedVolume()); |
|
|
|
row.createCell(6).setCellValue(record.getCreateTime() != null ? record.getCreateTime().toString() : ""); |
|
|
|
row.createCell(7).setCellValue(record.getUpdateTime() != null ? record.getUpdateTime().toString() : ""); |
|
|
|
row.createCell(6).setCellValue(record.getCreateTime() != null |
|
|
|
? DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(record.getCreateTime()) |
|
|
|
: ""); |
|
|
|
} |
|
|
|
// 自动调整列宽 |
|
|
|
for (int i = 0; i < headers.length; i++) { |
|
|
|