feat(lastleg): manage three delivery document categories

This commit is contained in:
2026-09-09 11:22:47 +08:00
parent f37e9ce555
commit 465d9dfc10
26 changed files with 967 additions and 4 deletions
@@ -0,0 +1,9 @@
package com.baiyue.lastleg.delivery.model;
public enum DeliveryDocumentCategory {
LOADING_PHOTO("DELIVERY_LOADING_PHOTO"), BOL("DELIVERY_BOL"), RECEIPT("DELIVERY_RECEIPT");
private final String businessType;
DeliveryDocumentCategory(String businessType) { this.businessType = businessType; }
public String businessType() { return businessType; }
}
@@ -0,0 +1,24 @@
package com.baiyue.lastleg.delivery.model;
import com.baiyue.lastleg.delivery.dto.DeliveryDocumentDtos.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.*;
/** Saved metadata only; listing never calls File and never counts pending uploads. */
public final class DeliveryDocumentSnapshot {
private static final ObjectMapper JSON = new ObjectMapper().findAndRegisterModules();
private DeliveryDocumentSnapshot() { }
public static List<Category> categories(String json) {
if (json == null || json.isBlank()) return Arrays.stream(DeliveryDocumentCategory.values())
.map(category -> new Category(category, "MISSING", 0, List.of())).toList();
try { return JSON.readValue(json, new TypeReference<List<Category>>() { }); }
catch (JsonProcessingException e) { throw new IllegalStateException("派送资料快照损坏", e); }
}
public static Summary summary(String json) {
List<Category> categories = categories(json);
return new Summary((int) categories.stream().filter(c -> !c.files().isEmpty()).count(), 3,
categories.stream().map(c -> new CategorySummary(c.category(), c.status(), c.fileCount())).toList());
}
}