| | |
| | | // 详情按测试电池归属;名称与分类不解释为共享字段身份、单位或设备事实。 |
| | | if (!sources.containsAll(overrides.keySet())) throw new ServiceException("详情调整不属于所选测试电池"); |
| | | for (Object value : overrides.values()) { |
| | | if (!(value instanceof Map<?,?> override) || !Set.of("experimentName", "fieldValues").containsAll(override.keySet())) throw new ServiceException("详情调整无效"); |
| | | if (override.containsKey("experimentName") && (!(override.get("experimentName") instanceof String name) || name.length() > 500)) throw new ServiceException("实验名称无效"); |
| | | if (!override.containsKey("fieldValues")) continue; |
| | | if (!(override.get("fieldValues") instanceof Map<?,?> values)) throw new ServiceException("详情字段格式无效"); |
| | | for (var entry : values.entrySet()) { |
| | | if (!(entry.getKey() instanceof String key) || !key.matches("(?:battery|special)\\|.{1,100}") |
| | | || !(entry.getValue() instanceof String text) || text.length() > 500) throw new ServiceException("详情字段名称或值无效"); |
| | | } |
| | | if (!(value instanceof Map<?,?> override) || !Set.of("batteryFields", "specialFields", "fieldValues").containsAll(override.keySet())) |
| | | throw new ServiceException("详情调整无效"); |
| | | JSON.parseObject(JSON.toJSONString(override), ReportSourceDetail.class).validate(); |
| | | } |
| | | } |
| | | |