From e6283bee1cd5fd77e241e5e86a5999fdb77c0331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Fri, 21 Nov 2025 11:15:40 +0800 Subject: [PATCH] =?UTF-8?q?11-21-=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HseSafetyWeeklyReportServiceImpl.java | 145 +++++++++++++++++- 1 file changed, 144 insertions(+), 1 deletion(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseSafetyWeeklyReportServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseSafetyWeeklyReportServiceImpl.java index ee5c6cdf..90eacf1b 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseSafetyWeeklyReportServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseSafetyWeeklyReportServiceImpl.java @@ -12,7 +12,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.xssf.usermodel.*; import org.dromara.common.core.constant.HttpStatus; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.ObjectUtils; @@ -1484,4 +1484,147 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl30, I1<=60)"); + PatternFormatting fill2 = rule2.createPatternFormatting(); + fill2.setFillBackgroundColor(IndexedColors.ORANGE.getIndex()); + fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND); + + // 规则3: 61-100% - 深红色 + ConditionalFormattingRule rule3 = conditionalFormatting.createConditionalFormattingRule( + "AND(ISNUMBER(I1), I1>60)"); + PatternFormatting fill3 = rule3.createPatternFormatting(); + fill3.setFillBackgroundColor(IndexedColors.RED.getIndex()); + fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND); + + // 应用规则到两个区域 + ConditionalFormattingRule[] rules = new ConditionalFormattingRule[]{rule1, rule2, rule3}; + + // 施工进度统计表 + CellRangeAddress[] progressRanges = new CellRangeAddress[] { + new CellRangeAddress(11, 17, 8, 8) + }; + conditionalFormatting.addConditionalFormatting(progressRanges, rules); + + // 设备材料表格 + CellRangeAddress[] materialRanges = new CellRangeAddress[] { + new CellRangeAddress(19, 22, 8, 8) + }; + conditionalFormatting.addConditionalFormatting(materialRanges, rules); + + } catch (Exception e) { + System.err.println("创建简单条件格式化失败: " + e.getMessage()); + } + } + }