xyc
4 天以前 520bdcba17d90b07d7d63fdcdb0e98a2a0a87300
traffic-audit-server/src/main/java/com/trafficaudit/holiday/service/HolidayBulletinService.java
@@ -24,6 +24,7 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.file.Files;
import java.time.LocalDate;
import java.util.ArrayList;
@@ -250,7 +251,10 @@
            Element pPr = firstChildElement(templateParagraph, "pPr");
            if (pPr != null) paragraph.appendChild(pPr.cloneNode(true));
        }
        Element templateRun = templateParagraph == null ? null : firstChildElement(templateParagraph, "r");
        Element rPr = templateRun == null ? null : firstChildElement(templateRun, "rPr");
        Element run = createElement("r");
        if (rPr != null) run.appendChild(rPr.cloneNode(true));
        Element t = createElement("t");
        t.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
        t.setTextContent(text == null ? "" : text);
@@ -330,7 +334,12 @@
    private String ratio(BigDecimal current, BigDecimal base) {
        if (current == null || base == null || base.abs().compareTo(EPSILON) < 0) return "—";
        return ratioPhrase(current, base);
        BigDecimal ratio = HolidayNumberUtils.divide(current, base);
        if (ratio == null) return "—";
        BigDecimal percent = HolidayNumberUtils.multiply(ratio.subtract(BigDecimal.ONE), BigDecimal.valueOf(100));
        if (percent == null) return "—";
        BigDecimal rounded = percent.setScale(1, RoundingMode.HALF_UP);
        return rounded.signum() == 0 ? "0%" : rounded.toPlainString() + "%";
    }
    private String number(BigDecimal value) {