yeg
5 天以前 691f882740b46c5354fb33404fef6efb370e05dc
battery-business/src/main/java/com/battery/business/service/impl/PushIngestAdapter.java
@@ -389,14 +389,31 @@
        boolean charging = current.signum() >= 0;
        BigDecimal capacity = charging ? row.getChargeCapacityAh() : row.getDischargeCapacityAh();
        BigDecimal energy = charging ? row.getChargeEnergyWh() : row.getDischargeEnergyWh();
        // 实时行同样带上方向(类型与名称):甲方那一列「状态」显示的就是它,实时页的"工步名称"要用。
        StepDirection direction = directionOf(row);
        return new CabinetRealtime(row.getRecordSequence() == null ? 0L : row.getRecordSequence(),
                row.getDeviceTimeUtc() == null ? null : row.getDeviceTimeUtc().toInstant(),
                current.doubleValue(), decimal(row.getVoltageV()), decimal(capacity), decimal(energy),
                row.getCycleNo() == null ? 0 : row.getCycleNo(), row.getStepNo() == null ? 0 : row.getStepNo(),
                null, null, row.getReceivedAtUtc() == null ? null : row.getReceivedAtUtc().toInstant(),
                // 注意参数次序:CabinetRealtime 是 stepName 在前、stepType 在后。
                direction.displayName(), direction.label(),
                row.getReceivedAtUtc() == null ? null : row.getReceivedAtUtc().toInstant(),
                row.getDeviceTimeRaw(), row.getTimezoneId(),
                row.getRelativeTimeSeconds() == null ? null : row.getRelativeTimeSeconds().longValue(),
                "push:" + row.getRecordKey());
    }
    /**
     * 单行的方向:这一类来源没有设备侧工步类型,方向只能由电流符号判定(ADR-0067),
     * 恒正充电、恒负放电、恒为零搁置,电流缺失保持未知。
     */
    private static StepDirection directionOf(TDeviceIngestRecord row)
    {
        BigDecimal current = row.getCurrentA();
        if (current == null) return StepDirection.UNKNOWN;
        if (current.signum() > 0) return StepDirection.CHARGE;
        if (current.signum() < 0) return StepDirection.DISCHARGE;
        return StepDirection.REST;
    }
    // ------------------------------------------------------------------ 工步与循环的推导(ADR-0067)
@@ -422,14 +439,23 @@
     */
    private enum StepDirection
    {
        CHARGE("charge"), DISCHARGE("discharge"), REST("rest"), UNKNOWN(null);
        CHARGE("charge", "充电"), DISCHARGE("discharge", "放电"), REST("rest", "搁置"), UNKNOWN(null, null);
        private final String label;
        private final String displayName;
        StepDirection(String label) { this.label = label; }
        StepDirection(String label, String displayName) { this.label = label; this.displayName = displayName; }
        /** 写进工步记录的类型:来源没给类型时交出的是判定出的方向名称,未知方向留空。 */
        String label() { return label; }
        /**
         * 交出去的工步名称。这类来源的工步方案里只有「步_N」这种标号,没有描述性名称
         * (2026-10-09 现场核对 .pcj:<Step StepLabel="步_1"> + CtrlTypeName=Rest/Current);
         * 而甲方软件那一列「状态」显示的就是充电/放电/搁置——所以用同一套词当工步名称,
         * 值同样来自电流符号判定,**不是设备给的名称**(现场清单与 ADR-0067 都记了这一条)。
         */
        String displayName() { return displayName; }
        /** 该工步自身累计的单项值。搁置段实测两向都不增长,所以它的累计是 0 而不是缺失。 */
        BigDecimal own(BigDecimal charge, BigDecimal discharge)
@@ -503,8 +529,10 @@
        putIfPresent(measurements, "dischargeEnergy", last.getDischargeEnergyWh());
        BigDecimal capacity = direction.own(last.getChargeCapacityAh(), last.getDischargeCapacityAh());
        BigDecimal energy = direction.own(last.getChargeEnergyWh(), last.getDischargeEnergyWh());
        // 工步名称用判定出的方向(充电/放电/搁置):该来源的方案里只有「步_N」标号,没有描述性名称,
        // 而甲方软件自己那一列「状态」显示的就是这三个词。它和方向同源,不是设备给的名称。
        return new StepRecord(sourceRecordId(sourceRef, "step", group.key().cycleNo() + ":" + group.key().stepNo()),
                group.key().cycleNo(), group.key().stepNo(), null, direction.label(), deviceTime(first),
                group.key().cycleNo(), group.key().stepNo(), direction.displayName(), direction.label(), deviceTime(first),
                deviceTime(last), decimal(last.getVoltageV()), decimal(last.getCurrentA()),
                capacity == null ? null : capacity.doubleValue(), energy == null ? null : energy.doubleValue(),
                last.getDeviceTimeRaw(), last.getTimezoneId(), receivedAt(last), measurements);