yeg
2026-09-08 cee1a4e3bcd2eefea83d242fcfa89ba4fc6d5409
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.battery.business.report;
 
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.ruoyi.common.exception.ServiceException;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.Size;
 
/** 新建化成报表仅提交来源身份和展示内容,事实在保存时由后端读取。 */
public record FormationReportRequest(@NotBlank @Size(max = 100) String name, @Size(max = 2000) String description,
        @NotNull @Size(min = 1) List<@NotNull @Valid Selection> selections, @NotNull @Valid Settings settings)
{
    public record Selection(@NotNull @Positive Long testId, @NotNull @Positive Long testBatteryId) { }
 
    /** 值按测试、电池、循环、字段归属,只属于报表展示,不反写测量快照。 */
    public record Settings(@NotNull @Size(min = 1, max = 100) List<@NotNull @Valid FormationField> fields,
            @NotNull Map<String, @NotNull String> values,
            @NotNull Map<String, @NotNull Integer> chargeStepSelections,
            List<@NotNull String> metrics, Map<String, @NotNull String> seriesColors,
            Map<String, @Valid DetailOverride> sourceDetailOverrides)
    {
        /** 旧版缺少显隐设置时显示五类指标,不补造测量快照。 */
        public List<String> metrics() { return metrics == null ? List.of("voltage", "current", "positiveVoltage", "negativeVoltage", "temperature") : metrics; }
 
        /** 未自定义颜色时由页面使用默认色板。 */
        public Map<String, String> seriesColors() { return seriesColors == null ? Map.of() : seriesColors; }
        /** 展示设置拒绝来源和测量快照。 */
        @JsonAnySetter
        public void rejectUnknown(String field, Object value) { throw new ServiceException("化成设置不允许提交属性:" + field); }
    }
 
    /** 人工详情覆盖与来源快照分开保存,空字符串是明确填写值。 */
    public record DetailOverride(@Size(max = 500) String experimentName, Map<String, @NotNull @Size(max = 500) String> fieldValues)
    {
        @JsonAnySetter
        public void rejectUnknown(String field, Object value) { throw new ServiceException("详情调整不允许提交属性:" + field); }
    }
 
    /** 编辑保持后端冻结来源范围,不接收替代来源或测量。 */
    public record Edit(@Positive int baseVersionNo, @NotBlank @Size(max = 100) String name,
            @Size(max = 2000) String description, @NotNull @Valid Settings settings,
            @NotBlank @Size(max = 500) String changeSummary)
    {
        /** 拒绝借普通编辑替换冻结来源或测量。 */
        @JsonAnySetter
        public void rejectUnknown(String field, Object value) { throw new ServiceException("化成编辑不允许提交属性:" + field); }
    }
 
    /** 新建只接收定义的展示内容与真实来源身份。 */
    @JsonAnySetter
    public void rejectUnknown(String field, Object value) { throw new ServiceException("化成报表不允许提交属性:" + field); }
}