| | |
| | | import com.fasterxml.jackson.annotation.JsonAnySetter; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | |
| | | /** 化成字段结构不携带数据;循环测量单位固定,未知公式仅允许人工项。 */ |
| | | /** 化成字段结构不携带数据;实际测量与已确认计算结果不可伪装成人工项。 */ |
| | | public record FormationField(String key, String scope, String kind, String displayName, String unit, Long fieldDefinitionId) |
| | | { |
| | | public static final Map<String, String> METRIC_UNITS = Map.of("chargeCapacity", "mAh", "dischargeCapacity", "mAh", |
| | |
| | | { |
| | | if (key == null || key.isBlank() || key.length() > 100 || key.contains("|") |
| | | || !("detail".equals(scope) || "cycle".equals(scope)) |
| | | || !("battery".equals(kind) || "metric".equals(kind) || "manual".equals(kind))) |
| | | || !("battery".equals(kind) || "metric".equals(kind) || "manual".equals(kind) || "calculated".equals(kind))) |
| | | throw new ServiceException("化成字段身份或分类无效"); |
| | | displayName = displayName == null ? key : displayName.trim(); |
| | | unit = unit == null ? "" : unit.trim(); |
| | |
| | | throw new ServiceException("化成字段展示名称、单位或共享身份无效"); |
| | | if ((METRIC_UNITS.containsKey(key) && !"metric".equals(kind)) |
| | | || (java.util.Set.of("Z", "H", "F", "A", "B").contains(key) && !"battery".equals(kind)) |
| | | || (java.util.Set.of("FN", "C", "method2", "manual", "chargePerGram", "chargePerGramTotal", "capacity1v", "capacity1vf", |
| | | "dischargeInflection", "dischargeInflectionTotal").contains(key) && !"manual".equals(kind))) |
| | | || (java.util.Set.of("method", "method2", "manual").contains(key) && !"manual".equals(kind)) |
| | | || (FormationReportCalculations.RESULTS.contains(key) && !"calculated".equals(kind)) |
| | | || ("calculated".equals(kind) && (!FormationReportCalculations.RESULTS.contains(key) |
| | | || !(java.util.Set.of("FN", "C").contains(key) ? "detail" : "cycle").equals(scope)))) |
| | | throw new ServiceException("固定字段不能改变来源分类"); |
| | | } |
| | | |