From 1666f5f6bb967b9629a384cadf1c773ce22aa160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Sat, 2 Aug 2025 11:43:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AF=BC=E5=87=BA=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=92=8Cu=E7=9B=98=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handacid/app/common/utils/UsbDriverUtil.java | 2 +- .../app/controller/AuditRecordController.java | 21 +++++++++++++-------- .../app/controller/ReceiveRecordController.java | 22 ++++++++++++++-------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/iflytop/handacid/app/common/utils/UsbDriverUtil.java b/src/main/java/com/iflytop/handacid/app/common/utils/UsbDriverUtil.java index 7ad6389..7bd8ca2 100644 --- a/src/main/java/com/iflytop/handacid/app/common/utils/UsbDriverUtil.java +++ b/src/main/java/com/iflytop/handacid/app/common/utils/UsbDriverUtil.java @@ -31,7 +31,7 @@ public class UsbDriverUtil { */ public static String findLinuxPath() { // Linux/Mac系统查找/media或/run/media下的可移动设备 - String[] mediaPaths = {"/media", "/run/media"}; + String[] mediaPaths = {"/media/usb"}; for (String mediaPath : mediaPaths) { File mediaDir = new File(mediaPath); if (mediaDir.exists() && mediaDir.isDirectory()) { diff --git a/src/main/java/com/iflytop/handacid/app/controller/AuditRecordController.java b/src/main/java/com/iflytop/handacid/app/controller/AuditRecordController.java index 6cb8b21..f63f652 100644 --- a/src/main/java/com/iflytop/handacid/app/controller/AuditRecordController.java +++ b/src/main/java/com/iflytop/handacid/app/controller/AuditRecordController.java @@ -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++) { diff --git a/src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java b/src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java index ee03a52..37cefa2 100644 --- a/src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java +++ b/src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java @@ -13,16 +13,15 @@ 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.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; 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; @@ -92,11 +91,17 @@ public class ReceiveRecordController { } 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", "发放人", "领取人", "酸液名称", "酸液浓度", "通道", "领取量", "创建时间", "更新时间"}; + 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 +112,11 @@ public class ReceiveRecordController { row.createCell(2).setCellValue(record.getReceiverNickname()); row.createCell(3).setCellValue(record.getSolutionName()); row.createCell(4).setCellValue(record.getConcentration()); - row.createCell(5).setCellValue(record.getChannelCode().toString()); + row.createCell(5).setCellValue(StringUtils.substring(record.getChannelCode().name(), record.getChannelCode().name().length() - 1)); row.createCell(6).setCellValue(record.getReceivedVolume()); - row.createCell(7).setCellValue(record.getCreateTime() != null ? record.getCreateTime().toString() : ""); - row.createCell(8).setCellValue(record.getUpdateTime() != null ? record.getUpdateTime().toString() : ""); + row.createCell(7).setCellValue(record.getCreateTime() != null + ? DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(record.getCreateTime()) + : ""); } // 自动调整列宽 for (int i = 0; i < headers.length; i++) {