吸收数字员工管理端审批策略预览
This commit is contained in:
@@ -1148,6 +1148,7 @@ public class DigitalEmployeeSyncApplicationServiceImpl implements DigitalEmploye
|
||||
return switch (view) {
|
||||
case "interventions" -> isInterventionRow(row);
|
||||
case "approval_governance" -> isApprovalGovernanceRow(row);
|
||||
case "approval_policies" -> isApprovalPolicyRow(row);
|
||||
case "service_operations" -> isServiceOperationsRow(row);
|
||||
case "artifact_lifecycle" -> isArtifactLifecycleRow(row);
|
||||
case "notifications" -> isNotificationRow(row);
|
||||
@@ -1191,6 +1192,21 @@ public class DigitalEmployeeSyncApplicationServiceImpl implements DigitalEmploye
|
||||
));
|
||||
}
|
||||
|
||||
private boolean isApprovalPolicyRow(DigitalEmployeeAdminWorkbenchRowDto row) {
|
||||
String category = firstString(row.getCategory());
|
||||
String kind = firstString(row.getKind());
|
||||
return Set.of("approval_policy", "approval_decision_policy", "conflict_policy", "risk_approval_policy").contains(category)
|
||||
|| contains(kind, "approval_policy")
|
||||
|| contains(kind, "approval_decision_policy")
|
||||
|| contains(kind, "conflict_policy")
|
||||
|| contains(kind, "risk_approval_policy")
|
||||
|| StringUtils.isNotBlank(row.getApprovalPolicyId())
|
||||
|| StringUtils.isNotBlank(row.getConflictPolicyId())
|
||||
|| StringUtils.isNotBlank(row.getDecisionGuardStatus())
|
||||
|| row.getBatchAcceptRemoteDisabled() != null
|
||||
|| row.getAutoDecisionDisabled() != null;
|
||||
}
|
||||
|
||||
private boolean isArtifactLifecycleRow(DigitalEmployeeAdminWorkbenchRowDto row) {
|
||||
return StringUtils.equals(row.getEntityType(), "artifact")
|
||||
|| startsWithAny(row.getKind(), "artifact_")
|
||||
|
||||
@@ -361,6 +361,98 @@ class DigitalEmployeeSyncApplicationServiceImplTest {
|
||||
assertThat(result.getRecords().get(3).getApprovalId()).isEqualTo("approval-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryAdminWorkbenchApprovalPoliciesReturnsPolicyRowsOnly() {
|
||||
when(repository.queryBusinessRecords(eq(101L), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), eq(1L), eq(20L)))
|
||||
.thenReturn(page(List.of(
|
||||
record("outbox-approval-policy", "event", "event-approval-policy-1", 101L, new Date(10_000),
|
||||
Map.ofEntries(
|
||||
Map.entry("entity_type", "event"),
|
||||
Map.entry("category", "approval_policy"),
|
||||
Map.entry("kind", "approval_policy_snapshot"),
|
||||
Map.entry("status", "active"),
|
||||
Map.entry("title", "审批策略快照"),
|
||||
Map.entry("approval_policy_id", "approval-policy-1"),
|
||||
Map.entry("decision_guard_status", "protected"),
|
||||
Map.entry("batch_accept_remote_disabled", true),
|
||||
Map.entry("auto_decision_disabled", true),
|
||||
Map.entry("policy_reason", "manual_review_required"),
|
||||
Map.entry("policy_source", "admin"),
|
||||
Map.entry("policy_status", "synced")
|
||||
),
|
||||
Map.of("id", "event-approval-policy-1", "kind", "approval_policy_snapshot")),
|
||||
record("outbox-conflict-policy", "event", "event-conflict-policy-1", 101L, new Date(11_000),
|
||||
Map.of(
|
||||
"entity_type", "event",
|
||||
"category", "conflict_policy",
|
||||
"kind", "approval_conflict_policy_snapshot",
|
||||
"status", "active",
|
||||
"title", "冲突策略快照",
|
||||
"conflict_policy_id", "conflict-policy-1",
|
||||
"decision_guard_status", "manual_only"
|
||||
),
|
||||
Map.of("id", "event-conflict-policy-1", "kind", "approval_conflict_policy_snapshot")),
|
||||
record("outbox-risk-approval-policy", "event", "event-risk-policy-1", 101L, new Date(12_000),
|
||||
Map.of(
|
||||
"entity_type", "event",
|
||||
"category", "risk_approval_policy",
|
||||
"kind", "risk_approval_policy_pulled",
|
||||
"status", "synced",
|
||||
"title", "风险审批策略",
|
||||
"approval_policy_id", "risk-policy-1"
|
||||
),
|
||||
Map.of("id", "event-risk-policy-1", "kind", "risk_approval_policy_pulled")),
|
||||
record("outbox-policy-snapshot", "policy_snapshot", "approval-policy-snapshot", 101L, new Date(13_000),
|
||||
Map.ofEntries(
|
||||
Map.entry("entity_type", "policy_snapshot"),
|
||||
Map.entry("category", "policy_snapshot"),
|
||||
Map.entry("kind", "approval_decision_policy_snapshot"),
|
||||
Map.entry("status", "synced"),
|
||||
Map.entry("title", "裁决策略保护"),
|
||||
Map.entry("approval_policy_id", "approval-policy-2"),
|
||||
Map.entry("conflict_policy_id", "conflict-policy-2"),
|
||||
Map.entry("decision_guard_status", "protected"),
|
||||
Map.entry("batch_accept_remote_disabled", true),
|
||||
Map.entry("auto_decision_disabled", true),
|
||||
Map.entry("policy_reason", "batch_disabled")
|
||||
),
|
||||
Map.of("id", "approval-policy-snapshot", "kind", "approval_decision_policy_snapshot")),
|
||||
record("outbox-approval", "approval", "approval-1", 101L, new Date(14_000),
|
||||
Map.of("entity_type", "approval", "title", "普通审批", "status", "pending"),
|
||||
Map.of("id", "approval-1", "status", "pending")),
|
||||
record("outbox-notification", "notification", "notification-1", 101L, new Date(15_000),
|
||||
Map.of("entity_type", "notification", "title", "普通通知", "status", "unread"),
|
||||
Map.of("id", "notification-1", "status", "unread")),
|
||||
record("outbox-artifact", "artifact", "artifact-1", 101L, new Date(16_000),
|
||||
Map.of("entity_type", "artifact", "title", "普通产物", "status", "active"),
|
||||
Map.of("id", "artifact-1", "status", "active")),
|
||||
record("outbox-route", "event", "event-route-1", 101L, new Date(17_000),
|
||||
Map.of("entity_type", "event", "category", "route_governance", "title", "路由", "status", "blocked"),
|
||||
Map.of("id", "event-route-1", "status", "blocked")),
|
||||
record("outbox-audit", "event", "event-audit-1", 101L, new Date(18_000),
|
||||
Map.of("entity_type", "event", "category", "tool_call_audit", "title", "审计", "status", "warn"),
|
||||
Map.of("id", "event-audit-1", "status", "warn"))
|
||||
)));
|
||||
|
||||
DigitalEmployeeAdminWorkbenchPageDto result = service.queryAdminWorkbench(
|
||||
"approval_policies", null, null, null, null, null, null, null, null, null, null, null, 1L, 20L
|
||||
);
|
||||
|
||||
assertThat(result.getTotal()).isEqualTo(4);
|
||||
assertThat(result.getRecords()).extracting(DigitalEmployeeAdminWorkbenchRowDto::getEntityId)
|
||||
.containsExactly("event-approval-policy-1", "event-conflict-policy-1", "event-risk-policy-1", "approval-policy-snapshot");
|
||||
assertThat(result.getRecords().get(0).getView()).isEqualTo("approval_policies");
|
||||
assertThat(result.getRecords().get(0).getApprovalPolicyId()).isEqualTo("approval-policy-1");
|
||||
assertThat(result.getRecords().get(0).getDecisionGuardStatus()).isEqualTo("protected");
|
||||
assertThat(result.getRecords().get(0).getBatchAcceptRemoteDisabled()).isTrue();
|
||||
assertThat(result.getRecords().get(0).getAutoDecisionDisabled()).isTrue();
|
||||
assertThat(result.getRecords().get(0).getPolicyReason()).isEqualTo("manual_review_required");
|
||||
assertThat(result.getRecords().get(1).getConflictPolicyId()).isEqualTo("conflict-policy-1");
|
||||
assertThat(result.getRecords().get(2).getApprovalPolicyId()).isEqualTo("risk-policy-1");
|
||||
assertThat(result.getRecords().get(3).getConflictPolicyId()).isEqualTo("conflict-policy-2");
|
||||
assertThat(result.getRecords().get(3).getTitle()).isEqualTo("裁决策略保护");
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryAdminWorkbenchMemoryGovernanceReturnsMemoryRowsOnly() {
|
||||
when(repository.queryBusinessRecords(eq(101L), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), eq(1L), eq(20L)))
|
||||
|
||||
Reference in New Issue
Block a user