| | |
| | | Map<String, Map<String, BigDecimal>> metrics, List<CurrentBatteryField> businessFields, |
| | | Map<Integer, List<ChargeStep>> chargeSteps, Map<Integer, Curve> curves, Map<Integer, Map<Integer, Curve>> stepCurves) { } |
| | | public record Matrix(List<Item> items, List<Integer> cycleNos) { } |
| | | public record Summary(long id, String name, String creator, long createdAt, String testName, String batteryGroup) { } |
| | | public record Summary(long id, String name, String creator, long createdAt, String testName, String batteryGroup, int versionNo) { } |
| | | |
| | | /** 列表来源名称取自已保存版本,测试删除后仍保留筛选与识别信息。 */ |
| | | public List<Summary> list() |
| | | { |
| | | return reports.list().stream().map(summary -> { |
| | | var sources = items(JSON.parseObject(reports.get(summary.id()).snapshotJson())); |
| | | var version = reports.get(summary.id()); |
| | | var sources = items(JSON.parseObject(version.snapshotJson())); |
| | | return new Summary(summary.id(), summary.name(), summary.creator(), summary.createdAt(), |
| | | String.join("、", sources.stream().map(item -> item.source().name()).distinct().toList()), |
| | | String.join("、", sources.stream().map(item -> item.source().batteryGroup()).distinct().toList())); |
| | | String.join("、", sources.stream().map(item -> item.source().batteryGroup()).distinct().toList()), version.versionNo()); |
| | | }).toList(); |
| | | } |
| | | |
| | |
| | | Map<Integer, ChargeStep> found = new java.util.TreeMap<>(); |
| | | // 实时记录只补充实际范围身份,不代替缺失的工步终止电压。 |
| | | for (var row : realtime) if (cycleNo(row) == cycle && number(row.get("stepNo")) > 0) { |
| | | String type = String.valueOf(row.getOrDefault("stepType", "")); |
| | | found.putIfAbsent(number(row.get("stepNo")), new ChargeStep(number(row.get("stepNo")), String.valueOf(row.getOrDefault("stepName", "")), type, null, directions.resolve(type), null)); |
| | | String type = Objects.toString(row.get("stepType"), ""); |
| | | String name = Objects.toString(row.get("stepName"), ""); |
| | | found.putIfAbsent(number(row.get("stepNo")), new ChargeStep(number(row.get("stepNo")), name, type, null, stepDirection(type, name), null)); |
| | | } |
| | | if (rows != null) for (var row : rows) if (Objects.equals(battery.getBatteryNo(), row.get("batteryNo")) && cycleNo(row) == cycle && number(row.get("stepNo")) > 0) { |
| | | String type = String.valueOf(row.getOrDefault("stepType", "")); |
| | | found.put(number(row.get("stepNo")), new ChargeStep(number(row.get("stepNo")), String.valueOf(row.getOrDefault("stepName", "")), type, decimal(row.get("endVoltage")), directions.resolve(type), decimal(row.get("capacity")))); |
| | | String type = Objects.toString(row.get("stepType"), ""); |
| | | String name = Objects.toString(row.get("stepName"), ""); |
| | | found.put(number(row.get("stepNo")), new ChargeStep(number(row.get("stepNo")), name, type, decimal(row.get("endVoltage")), stepDirection(type, name), decimal(row.get("capacity")))); |
| | | } |
| | | result.put(cycle, new ArrayList<>(found.values())); |
| | | } |
| | | return result; |
| | | } |
| | | private int number(Object value) { return value instanceof Number n ? n.intValue() : 0; } |
| | | |
| | | private Direction stepDirection(String type, String name) |
| | | { |
| | | // 甲方 Excel 只提供工步名称;有协议类型时禁止用名称覆盖未知/混合类型。 |
| | | if (!type.isBlank()) return directions.resolve(type); |
| | | return switch (name.trim()) { |
| | | case "恒流充电" -> Direction.CHARGE; |
| | | case "恒流放电" -> Direction.DISCHARGE; |
| | | case "搁置", "静置" -> Direction.REST; |
| | | default -> Direction.UNKNOWN; |
| | | }; |
| | | } |
| | | private BigDecimal decimal(Object value) { return value instanceof Number n ? new BigDecimal(n.toString()) : null; } |
| | | |
| | | private Set<String> valueKeys(List<FormationField> fields, List<Item> items) |