From 27f28beed7c8069d09713a8a46764d5514bd04d3 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期四, 13 二月 2025 10:13:48 +0800
Subject: [PATCH] 历史导出

---
 src/main/java/com/whyc/service/ExportService.java |   74 +++++++++++++++++++++----------------
 1 files changed, 42 insertions(+), 32 deletions(-)

diff --git a/src/main/java/com/whyc/service/ExportService.java b/src/main/java/com/whyc/service/ExportService.java
index d7a5c4b..f4bb88f 100644
--- a/src/main/java/com/whyc/service/ExportService.java
+++ b/src/main/java/com/whyc/service/ExportService.java
@@ -7,7 +7,7 @@
 import com.whyc.util.ActionUtil;
 import com.whyc.util.SubTablePageInfoUtil;
 import com.whyc.util.ThreadLocalUtil;
-import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -45,59 +45,69 @@
 
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet("閿佺殑鍩虹淇℃伅");
+        // 鍒涘缓涓�涓崟鍏冩牸鏍峰紡锛屽苟璁剧疆瀛椾綋澶у皬涓�5
+        sheet.setDefaultColumnWidth(20);
+        sheet.setDefaultRowHeightInPoints(20);
 
-        XSSFDrawing patriarch = sheet.createDrawingPatriarch();
         int rowNumSheet = 0;
-        sheet.createRow(rowNumSheet);
-        sheet.getRow(rowNumSheet).createCell(0).setCellValue("鎵�灞炲尯鍩燂細"+linf.getAreaName());
-        sheet.getRow(rowNumSheet).createCell(1).setCellValue("閿佺殑鍚嶇О锛�"+linf.getLockName());
-        sheet.getRow(rowNumSheet).createCell(2).setCellValue("閿佺殑绫诲瀷锛氬疄浣撻攣");
+        Row row1 =  sheet.createRow(rowNumSheet);
+        row1.setHeightInPoints(20.0f);
+        row1.createCell(0).setCellValue("鎵�灞炲尯鍩燂細"+linf.getAreaName());
+        row1.createCell(1).setCellValue("閿佺殑鍚嶇О锛�"+linf.getLockName());
+        row1.createCell(2).setCellValue("閿佺殑绫诲瀷锛氬疄浣撻攣");
         rowNumSheet++;
 
-        sheet.createRow(rowNumSheet);
+        Row row2 =  sheet.createRow(rowNumSheet);
+        row2.setHeightInPoints(20.0f);
         switch (linf.getLockState()){
-            case -1:sheet.getRow(rowNumSheet).createCell(0).setCellValue("閿佺殑鐘舵�侊細鏈畨瑁�");break;
-            case 0:sheet.getRow(rowNumSheet).createCell(0).setCellValue("閿佺殑鐘舵�侊細闂攣");break;
-            case 1:sheet.getRow(rowNumSheet).createCell(0).setCellValue("閿佺殑鐘舵�侊細寮�閿�");break;
+            case -1:row2.createCell(0).setCellValue("閿佺殑鐘舵�侊細鏈畨瑁�");break;
+            case 0:row2.createCell(0).setCellValue("閿佺殑鐘舵�侊細闂攣");break;
+            case 1:row2.createCell(0).setCellValue("閿佺殑鐘舵�侊細寮�閿�");break;
         }
         switch (linf.getLockOnline()){
-            case 0:sheet.getRow(rowNumSheet).createCell(1).setCellValue("閿佺殑鐘舵�侊細绂荤嚎");break;
-            case 1:sheet.getRow(rowNumSheet).createCell(1).setCellValue("閿佺殑鐘舵�侊細鍦ㄧ嚎");break;
+            case 0:row2.createCell(1).setCellValue("閿佺殑鐘舵�侊細绂荤嚎");break;
+            case 1:row2.createCell(1).setCellValue("閿佺殑鐘舵�侊細鍦ㄧ嚎");break;
         }
         rowNumSheet++;
-        sheet.createRow(rowNumSheet);
-        sheet.getRow(rowNumSheet).createCell(0).setCellValue("閿佸叿寮�鍚鏁帮細"+linf.getLockOpenCount());
-        sheet.getRow(rowNumSheet).createCell(1).setCellValue("涓婁竴娆″紑閿佹椂闂达細"+ThreadLocalUtil.format(linf.getLastUpdateTime(),1));
+        Row row3 =  sheet.createRow(rowNumSheet);
+        row3.setHeightInPoints(20.0f);
+        row3.createCell(0).setCellValue("閿佸叿寮�鍚鏁帮細"+linf.getLockOpenCount());
+        row3.createCell(1).setCellValue("涓婁竴娆″紑閿佹椂闂达細"+ThreadLocalUtil.format(linf.getLastUpdateTime(),1));
 
         rowNumSheet++;
-        sheet.createRow(rowNumSheet);
-        sheet.getRow(rowNumSheet).createCell(0).setCellValue("灞忔煖绫诲瀷锛�"+linf.getScreenBoxType());
-        sheet.getRow(rowNumSheet).createCell(1).setCellValue("灞忔煖鍝佺墝锛�"+linf.getScreenBoxProduct());
+        Row row4 =  sheet.createRow(rowNumSheet);
+        row4.setHeightInPoints(20.0f);
+        row4.createCell(0).setCellValue("灞忔煖绫诲瀷锛�"+linf.getScreenBoxType());
+        row4.createCell(1).setCellValue("灞忔煖鍝佺墝锛�"+linf.getScreenBoxProduct());
 
         rowNumSheet++;
-        sheet.createRow(rowNumSheet);
-        sheet.getRow(rowNumSheet).createCell(0).setCellValue("寮�濮嬫椂闂�:"+startTime);
-        sheet.getRow(rowNumSheet).createCell(1).setCellValue("缁撴潫鏃堕棿:"+endTime);
+        Row row5 =  sheet.createRow(rowNumSheet);
+        row5.setHeightInPoints(20.0f);
+        row5.createCell(0).setCellValue("寮�濮嬫椂闂�:"+startTime);
+        row5.createCell(1).setCellValue("缁撴潫鏃堕棿:"+endTime);
 
         XSSFSheet sheet1 = wb.createSheet("鍘嗗彶鏁版嵁");
+        sheet1.setDefaultColumnWidth(20);
+        sheet1.setDefaultRowHeightInPoints(20);
         //鎶ご
         int rowNum = 0;
-        XSSFRow row = sheet1.createRow(rowNum);
-        row.createCell(0).setCellValue("璁板綍鏃堕棿(yyyy-MM-dd HH:mm:ss)");
-        row.createCell(1).setCellValue("閿佸叿鐘舵��");
-        row.createCell(2).setCellValue("寮�閿佹柟寮�");
+        Row row6 = sheet1.createRow(rowNum);
+        row6.setHeightInPoints(20.0f);
+        row6.createCell(0).setCellValue("璁板綍鏃堕棿(yyyy-MM-dd HH:mm:ss)");
+        row6.createCell(1).setCellValue("閿佸叿鐘舵��");
+        row6.createCell(2).setCellValue("寮�閿佹柟寮�");
         rowNum++;
         //鏁版嵁鏍�
         for (int i = 0; i < list.size(); i++) {
-            sheet1.createRow(rowNum);  //鍒涘缓琛�
+            Row row=sheet1.createRow(rowNum);  //鍒涘缓琛�
             LockHis lock=list.get(i);
-            sheet1.getRow(rowNum).createCell(0).setCellValue(ThreadLocalUtil.format(lock.getRecordTime(),1));
-            sheet1.getRow(rowNum).createCell(1).setCellValue(lock.getLockState()==0?"闂攣":lock.getLockState()==1?"寮�閿�":"鏈煡");
+            row.createCell(0).setCellValue(ThreadLocalUtil.format(lock.getRecordTime(),1));
+            row.createCell(1).setCellValue(lock.getLockState()==0?"闂攣":lock.getLockState()==1?"寮�閿�":"鏈煡");
             switch (lock.getUnlockType()){
-                case 0:sheet1.getRow(rowNum).createCell(2).setCellValue("485寮�閿�");break;
-                case 1:sheet1.getRow(rowNum).createCell(2).setCellValue("鍒峰崱寮�閿�");break;
-                case 2:sheet1.getRow(rowNum).createCell(2).setCellValue("钃濈墮寮�閿�");break;
-                case 3:sheet1.getRow(rowNum).createCell(2).setCellValue("DI寮�閿�");break;
+                case 0:row.createCell(2).setCellValue("485寮�閿�");break;
+                case 1:row.createCell(2).setCellValue("鍒峰崱寮�閿�");break;
+                case 2:row.createCell(2).setCellValue("钃濈墮寮�閿�");break;
+                case 3:row.createCell(2).setCellValue("DI寮�閿�");break;
             }
             rowNum++;
         }

--
Gitblit v1.9.1