feat: sync vehicle monitoring and accumulated platform updates
Add monitoring metrics, numeric sorting, report-time display, vehicle number labels, and map layout fixes. Include accumulated mileage, hydrogen, OneOS authentication, open platform, ingestion, deployment, and UI updates. Exclude temporary files, generated reports, and credentials. Validate frontend 632 tests and production build, API packages, vehicle-map tests, and release installer tests. Gateway suite has one pre-existing date-sensitive identity throttling test failure reproduced on the parent commit.
This commit is contained in:
@@ -25,6 +25,9 @@ func (s *Service) reconciliationStore() (ReconciliationStore, error) {
|
||||
}
|
||||
|
||||
func (s *Service) ReconciliationSummary(ctx context.Context, days int) (ReconciliationSummary, error) {
|
||||
if p, ok := PrincipalFromContext(ctx); ok && p.HasVehicleScope() {
|
||||
return s.scopedReconciliationSummary(ctx)
|
||||
}
|
||||
store, err := s.reconciliationStore()
|
||||
if err != nil {
|
||||
return ReconciliationSummary{}, err
|
||||
@@ -36,6 +39,7 @@ func (s *Service) ReconciliationSummary(ctx context.Context, days int) (Reconcil
|
||||
}
|
||||
|
||||
func (s *Service) ReconciliationIssues(ctx context.Context, query ReconciliationQuery) (Page[ReconciliationIssue], error) {
|
||||
query.AllowedVINs = principalVehicleVINScope(ctx)
|
||||
store, err := s.reconciliationStore()
|
||||
if err != nil {
|
||||
return Page[ReconciliationIssue]{}, err
|
||||
@@ -222,6 +226,11 @@ func (s *Service) SetReconciliationIssueArchived(ctx context.Context, id string,
|
||||
if err != nil {
|
||||
return ReconciliationIssue{}, err
|
||||
}
|
||||
if p, ok := PrincipalFromContext(ctx); ok && p.HasVehicleScope() {
|
||||
if _, err := s.ReconciliationIssue(ctx, id); err != nil {
|
||||
return ReconciliationIssue{}, err
|
||||
}
|
||||
}
|
||||
return store.SetReconciliationIssueArchived(ctx, id, archived, normalized)
|
||||
}
|
||||
|
||||
@@ -276,6 +285,11 @@ func (s *Service) AssignReconciliationIssue(ctx context.Context, id string, requ
|
||||
if err != nil {
|
||||
return ReconciliationIssue{}, err
|
||||
}
|
||||
if p, ok := PrincipalFromContext(ctx); ok && p.HasVehicleScope() {
|
||||
if _, err := s.ReconciliationIssue(ctx, id); err != nil {
|
||||
return ReconciliationIssue{}, err
|
||||
}
|
||||
}
|
||||
return store.AssignReconciliationIssue(ctx, id, request)
|
||||
}
|
||||
|
||||
@@ -319,7 +333,14 @@ func (s *Service) ReconciliationIssue(ctx context.Context, id string) (Reconcili
|
||||
if err != nil {
|
||||
return ReconciliationIssue{}, err
|
||||
}
|
||||
return store.ReconciliationIssue(ctx, id)
|
||||
item, err := store.ReconciliationIssue(ctx, id)
|
||||
if err != nil {
|
||||
return item, err
|
||||
}
|
||||
if err = authorizeVehicleVIN(ctx, item.VIN); err != nil {
|
||||
return ReconciliationIssue{}, err
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
func (s *Service) UpdateReconciliationIssue(ctx context.Context, id string, request ReconciliationActionRequest) (ReconciliationIssue, error) {
|
||||
@@ -332,6 +353,11 @@ func (s *Service) UpdateReconciliationIssue(ctx context.Context, id string, requ
|
||||
if err != nil {
|
||||
return ReconciliationIssue{}, err
|
||||
}
|
||||
if p, ok := PrincipalFromContext(ctx); ok && p.HasVehicleScope() {
|
||||
if _, err := s.ReconciliationIssue(ctx, id); err != nil {
|
||||
return ReconciliationIssue{}, err
|
||||
}
|
||||
}
|
||||
return store.UpdateReconciliationIssue(ctx, id, request)
|
||||
}
|
||||
|
||||
@@ -397,3 +423,62 @@ func (s *Service) EvaluateReconciliation(ctx context.Context) (ReconciliationEva
|
||||
}
|
||||
return store.EvaluateReconciliation(ctx)
|
||||
}
|
||||
|
||||
// Historical run totals have no VIN dimension. Scoped users receive current
|
||||
// issue totals only, rather than another user's fleet-wide trend.
|
||||
func (s *Service) scopedReconciliationSummary(ctx context.Context) (ReconciliationSummary, error) {
|
||||
if store, ok := s.store.(interface {
|
||||
ScopedReconciliationSummary(context.Context) (ReconciliationSummary, error)
|
||||
}); ok {
|
||||
return store.ScopedReconciliationSummary(ctx)
|
||||
}
|
||||
out := ReconciliationSummary{ByRule: []ReconciliationBucket{}, BySeverity: []ReconciliationBucket{}, Trend: []ReconciliationTrendPoint{}, AsOf: time.Now().Format(time.RFC3339)}
|
||||
rules, severities := map[string]int{}, map[string]int{}
|
||||
for _, scope := range []string{"current", "archived"} {
|
||||
for offset := 0; ; offset += 200 {
|
||||
page, err := s.ReconciliationIssues(ctx, ReconciliationQuery{Scope: scope, Limit: 200, Offset: offset})
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
if page.Total > reconciliationFindingLimit {
|
||||
return out, clientError{Code: "SCOPE_TOO_LARGE", Message: "授权范围内差异过多,请缩小查询范围"}
|
||||
}
|
||||
for _, item := range page.Items {
|
||||
if scope == "archived" {
|
||||
out.Archived++
|
||||
continue
|
||||
}
|
||||
out.Current++
|
||||
active := item.Status == "pending" || item.Status == "confirmed_source_a" || item.Status == "confirmed_source_b"
|
||||
switch item.Status {
|
||||
case "pending":
|
||||
out.Pending++
|
||||
case "confirmed_source_a", "confirmed_source_b":
|
||||
out.Confirmed++
|
||||
case "recovered":
|
||||
out.Recovered++
|
||||
}
|
||||
if active {
|
||||
out.Active++
|
||||
rules[item.RuleCode]++
|
||||
severities[item.Severity]++
|
||||
if due, ok := parseTrackRequestTime(item.DueAt); ok && due.Before(time.Now()) {
|
||||
out.OverSLA++
|
||||
}
|
||||
}
|
||||
}
|
||||
if offset+len(page.Items) >= page.Total || len(page.Items) == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
for name, count := range rules {
|
||||
out.ByRule = append(out.ByRule, ReconciliationBucket{Name: name, Count: count})
|
||||
}
|
||||
for name, count := range severities {
|
||||
out.BySeverity = append(out.BySeverity, ReconciliationBucket{Name: name, Count: count})
|
||||
}
|
||||
sort.Slice(out.ByRule, func(i, j int) bool { return out.ByRule[i].Name < out.ByRule[j].Name })
|
||||
sort.Slice(out.BySeverity, func(i, j int) bool { return out.BySeverity[i].Name < out.BySeverity[j].Name })
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user