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()); + } + } + }