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, List<@NotNull Integer>> manualChargeSteps,
|
Map<String, @Valid StepSelection> curveStepSelections,
|
List<@NotNull String> hiddenSeriesKeys, Integer activeCycle)
|
{
|
/** 旧版缺少显隐设置时显示五类指标,不补造测量快照。 */
|
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 StepSelection(@NotNull List<@NotNull Integer> charge, @NotNull List<@NotNull Integer> discharge) { }
|
|
/** 编辑保持后端冻结来源范围,不接收替代来源或测量。 */
|
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); }
|
}
|