yeg
2026-09-29 b78295e8da96c3e5e76befeef9582ce5273dbb74
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.battery.business.service.report;
 
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.ruoyi.common.exception.ServiceException;
 
/** 拼接详情字段只描述身份、顺序与展示语义,不携带测试或数据值。 */
public record SpliceField(String name, String category, String unit, Long fieldDefinitionId, String displayName)
{
    public SpliceField
    {
        if (name == null || name.isBlank() || name.length() > 100
                || !("battery".equals(category) || "special".equals(category)))
            throw new ServiceException("拼接字段名称或分类无效");
        unit = unit == null ? "" : unit.trim();
        displayName = displayName == null ? name : displayName.trim();
        if (unit.length() > 30 || displayName.isBlank() || displayName.length() > 100
                || (fieldDefinitionId != null && (fieldDefinitionId <= 0 || !"battery".equals(category))))
            throw new ServiceException("拼接字段展示名称、单位或共享身份无效");
    }
 
    /** 拒绝将测量或人工值混入模板字段。 */
    @JsonAnySetter
    public void rejectUnknown(String field, Object value) { throw new ServiceException("拼接字段不允许提交属性:" + field); }
}