e2e/dag: 业务全景页面——把每条记录的授权/审核/调用/存证/分配/留痕一屏可见

数据流通平台的核心是「信任」,不是看热闹。
对每条核心业务对象都加 BusinessDetail 接口 + 前端「业务全景」详情页,
并让 e2e 每跑完创建/更新就跳过去,让用户在 DAG 上看到完整链路。

新增接口:
- GET /api/ssw/tdc/DeliveryTask/{id}/BusinessDetail
  把任务本体 + 上游合约 + 上游订单 + 参与方 + 审核 + 策略 + 执行 +
  TEE 远程证明 + 调用留痕 + 销毁存证 串起来(30+ 字段)
- GET /api/ssw/tds/Contract/{id}/BusinessDetail
  合约本体 + 链上存证 + 上游订单 + 下游交付任务 + 用量配额
- GET /api/ssw/tds/BillingLedger/{id}/BusinessDetail
  台账 + 利益分配(提供方/平台/税实比例)+ 上游合约 + 计费明细

新增前端页(views/ssw/views/_biz/{Delivery,Contract,Billing}DetailView.vue):
- 上半 4 张卡:基本/授权/配额/审核
- 中段:执行步骤时间轴(含策略/开始/结果/上报/销毁)+ TEE 证明/KBS/measurementSha256
- 下半:上游订单 + 跨 schema 数据访问 + 政策条款
- 底部:审计留痕(创建人/时间/最后修改人)

路由:
- jweb 在 core.ts 加 tdc/delivery-detail/:id、tds/contract-detail/:id
- web 在 modules/{tdc,tds}.ts 加同样的路径
- 两边都保留即可(互跨栈跳转也不冲突)

dag e2e 加新动作类型 'bizDetail':
- 关掉上一个抽屉/弹窗
- 拼 URL (FE_BASE + /tds-or-tdc/<entity>-detail/<id>)
- 等 networkidle + 标题出现 + 2.5s 缓冲
- 截图 SIM-BIZ-<entity>-<id>.png
- 失败告警 + 持久化 entity/path/cardCount/titleText
- 修复 t.baseURL 不存在的 bug(TestCtx 类没存)

seq-1 / seq-2 验证:
- 21/21 + 22/22 pass
- 业务全景截图:12 张 SIM-BIZ-*.png
- 关键截图 SIM-BIZ-billing-*.png 显示
  利益分配 ¥17,280/¥3,240/¥1,296/实付¥21,600
  上下游调用次数、合约 SHA-256、链上存证全部可点开
This commit is contained in:
admin committed 2026-08-09 11:17:01 +08:00
1 parent fc27f9523d
commit 24dd63e5d6
12 files changed
+1396 -4

No files matched your search

@@ -8,15 +8,25 @@ import jnpf.base.ActionResult;
import jnpf.base.service.SuperService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ssw.tdc.entity.DeliveryTaskEntity;
import ssw.tdc.entity.DestroyLogEntity;
import ssw.tdc.service.DeliveryTaskService;
import ssw.tdc.service.ApiConsumeLogService;
import ssw.tdc.service.DestroyLogService;
import ssw.tdc.notify.NotifyDispatcher;
import ssw.tdc.entity.ApiConsumeLogEntity;
import ssw.tdc.entity.OrderEntity;
import ssw.tdc.service.OrderService;
import ssw.tds.entity.ContractEntity;
import ssw.tds.service.ContractService;
// 注:合约存证是 tds 库,跨 schema 用 ssw.tds.* 防止 @DS("tdc") 路由把查询打回 tdc 库(会查不到)
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Date;
import java.util.LinkedHashMap;
@@ -53,6 +63,10 @@ public class DeliveryTaskController extends TdcCrudController<DeliveryTaskEntity
@Autowired
private NotifyDispatcher notifyDispatcher;
@Autowired private ssw.tds.service.ContractService contractService;
@Autowired private OrderService orderService;
@Autowired private ApiConsumeLogService apiConsumeLogService;
@Override
protected SuperService<DeliveryTaskEntity> service() {
return deliveryTaskService;
@@ -324,4 +338,251 @@ public class DeliveryTaskController extends TdcCrudController<DeliveryTaskEntity
destroyLogService.destroyTask(id, reason == null ? "手动销毁" : reason, safeUserId(), method);
return ActionResult.success("数据已销毁", id);
}
// ====================== 业务全景 / Business Detail ======================
/**
* 交付任务的「业务全景」——把跟这次数据出域相关的所有合规/审计/控制/存证全部串起来:
* 1. 任务元信息 (DeliveryTaskEntity 全字段)
* 2. 上游合约 (ContractEntity) — 谁能用、用什么、限额多少、何时签、双签人/签名
* 3. 上游订单 (OrderEntity) — 谁发起的、用量、交付方式、生效条件
* 4. 参与方 (provider/consumer) — 提供方/使用方机构、连接器、对端 ID
* 5. 审核链路 — 算法审核人/时间/意见 (f_audit_user_id/f_audit_time/f_audit_opinion/f_audit_status)
* 6. 策略判定 (policyResult/denyReason/policyCheckId)
* 7. 执行链路 — start/end/duration/resultUri/resultHash/调用次数/重试次数
* 8. TEE 远程证明 (从 runLog 解析 kbsEngaged/guestKernel/measurementSha256/failClosed)
* 9. 销毁存证 (DestroyLogEntity 全记录)
* 10. API 消费存证 (ApiConsumeLogEntity, 最多 10 条)
* 11. 配额使用 (从上游合约 quota_used/quota_total)
* 12. 审计留痕 (基础列 creator_user_id/create_time/last_modify_user_id/last_modify_time)
*/
@GetMapping("/{id}/BusinessDetail")
@Operation(summary = "交付任务业务全景",
description = "汇总授权/审核/策略/执行/调用/销毁/存证一条数据出域链路上所有可审计字段")
public ActionResult<Map<String, Object>> businessDetail(@PathVariable("id") String id) {
DeliveryTaskEntity task = getAlive(id);
if (task == null) return ActionResult.fail("交付任务不存在: " + id);
Map<String, Object> data = new LinkedHashMap<>();
// 1. 任务元信息
Map<String, Object> taskMap = new LinkedHashMap<>();
taskMap.put("id", task.getId());
taskMap.put("taskNo", task.getTaskNo());
taskMap.put("taskCode", task.getTaskCode());
taskMap.put("contractId", task.getContractId());
taskMap.put("contractCode", task.getContractCode());
taskMap.put("productId", task.getProductId());
taskMap.put("productName", task.getProductName());
taskMap.put("orderId", task.getOrderId());
taskMap.put("deliveryType", task.getDeliveryType());
taskMap.put("triggerType", task.getTriggerType());
taskMap.put("consumerConnectorCode", task.getConsumerConnectorCode());
taskMap.put("consumerOrgId", task.getConsumerOrgId());
taskMap.put("consumerOrgName", task.getConsumerOrgName());
taskMap.put("runStatus", task.getRunStatus());
taskMap.put("status", task.getStatus());
taskMap.put("policyResult", task.getPolicyResult());
taskMap.put("policyCheckId", task.getPolicyCheckId());
taskMap.put("denyReason", task.getDenyReason());
taskMap.put("auditStatus", task.getAuditStatus());
taskMap.put("auditUserId", task.getAuditUserId());
taskMap.put("auditTime", task.getAuditTime());
taskMap.put("auditOpinion", task.getAuditOpinion());
taskMap.put("programUri", task.getProgramUri());
taskMap.put("programFilename", task.getProgramFilename());
taskMap.put("codeUri", task.getCodeUri());
taskMap.put("codeFilename", task.getCodeFilename());
taskMap.put("startTime", task.getStartTime());
taskMap.put("runStartTime", task.getRunStartTime());
taskMap.put("runEndTime", task.getRunEndTime());
taskMap.put("endTime", task.getEndTime());
taskMap.put("durationMs", task.getDurationMs());
taskMap.put("recordCount", task.getRecordCount());
taskMap.put("dataSize", task.getDataSize());
taskMap.put("resultUri", task.getResultUri());
taskMap.put("resultFilename", task.getResultFilename());
taskMap.put("resultHash", task.getResultHash());
taskMap.put("resultExpireTime", task.getExpireTime());
taskMap.put("errorMsg", task.getErrorMsg());
taskMap.put("retryCount", task.getRetryCount());
taskMap.put("callCount", task.getCallCount());
taskMap.put("reportStatus", task.getReportStatus());
taskMap.put("reportTime", task.getReportTime());
taskMap.put("destroyStatus", task.getDestroyStatus());
taskMap.put("destroyTime", task.getDestroyTime());
taskMap.put("destroyMethod", task.getDestroyMethod());
data.put("task", taskMap);
// 12. 审计留痕
Map<String, Object> auditTrail = new LinkedHashMap<>();
auditTrail.put("creator", task.getCreatorUserId());
auditTrail.put("createTime", task.getCreatorTime());
auditTrail.put("lastModifier", task.getLastModifyUserId());
auditTrail.put("lastModifyTime", task.getLastModifyTime());
auditTrail.put("tenantId", task.getTenantId());
data.put("auditTrail", auditTrail);
// 2. 上游合约 (跨 schema - ContractEntity 是 tds schema)
if (task.getContractId() != null && !task.getContractId().isBlank()) {
ContractEntity contract = safeGet(contractService, task.getContractId());
if (contract != null) {
Map<String, Object> contractMap = new LinkedHashMap<>();
contractMap.put("contractCode", contract.getContractCode());
contractMap.put("name", contract.getName());
contractMap.put("providerConnectorId", contract.getProviderConnectorId());
contractMap.put("providerOrgId", contract.getProviderOrgId());
contractMap.put("providerOrgName", contract.getProviderOrgName());
contractMap.put("consumerConnectorId", contract.getConsumerConnectorId());
contractMap.put("consumerOrgId", contract.getConsumerOrgId());
contractMap.put("consumerOrgName", contract.getConsumerOrgName());
contractMap.put("purpose", contract.getPurpose());
contractMap.put("deliveryType", contract.getDeliveryType());
contractMap.put("priceMode", contract.getPriceMode());
contractMap.put("amount", contract.getAmount());
contractMap.put("quotaTotal", contract.getQuotaTotal());
contractMap.put("quotaUsed", contract.getQuotaUsed());
contractMap.put("effectiveTime", contract.getEffectiveTime());
contractMap.put("expireTime", contract.getExpireTime());
contractMap.put("providerSignature", contract.getProviderSignature());
contractMap.put("providerSignTime", contract.getProviderSignTime());
contractMap.put("consumerSignature", contract.getConsumerSignature());
contractMap.put("consumerSignTime", contract.getConsumerSignTime());
contractMap.put("signTime", contract.getSignTime());
contractMap.put("signCostMs", contract.getSignCostMs());
contractMap.put("status", contract.getStatus());
contractMap.put("contentHash", contract.getContentHash());
contractMap.put("chainTxHash", contract.getChainTxHash());
contractMap.put("chainBlockNo", contract.getChainBlockNo());
contractMap.put("chainTime", contract.getChainTime());
contractMap.put("policyContent", contract.getPolicyContent());
data.put("contract", contractMap);
}
}
// 4. 参与方(从 task 已有 consumerOrg 字段 + 用 connectorService 反查 provider 提供方)
Map<String, Object> parties = new LinkedHashMap<>();
parties.put("consumerOrgId", task.getConsumerOrgId());
parties.put("consumerOrgName", task.getConsumerOrgName());
parties.put("consumerConnectorCode", task.getConsumerConnectorCode());
data.put("parties", parties);
// 3. 上游订单 (OrderEntity 是 tdc schema)
if (task.getOrderId() != null && !task.getOrderId().isBlank()) {
OrderEntity order = safeGet(orderService, task.getOrderId());
if (order != null) {
Map<String, Object> orderMap = new LinkedHashMap<>();
orderMap.put("orderCode", order.getOrderCode());
orderMap.put("status", order.getStatus());
orderMap.put("priceType", order.getPriceType());
orderMap.put("priceAmount", order.getPriceAmount());
orderMap.put("quantity", order.getQuantity());
orderMap.put("totalAmount", order.getTotalAmount());
orderMap.put("productName", order.getProductName());
orderMap.put("buyerId", order.getBuyerId());
orderMap.put("buyerName", order.getBuyerName());
orderMap.put("sellerId", order.getSellerId());
orderMap.put("sellerName", order.getSellerName());
orderMap.put("auditTime", order.getAuditTime());
orderMap.put("auditUserId", order.getAuditUserId());
orderMap.put("auditOpinion", order.getAuditOpinion());
orderMap.put("paymentVoucher", order.getPaymentVoucher());
orderMap.put("paymentConfirmTime", order.getPaymentConfirmTime());
orderMap.put("paymentConfirmUserId", order.getPaymentConfirmUserId());
orderMap.put("signPartyATime", order.getSignPartyATime());
orderMap.put("signPartyAUserId", order.getSignPartyAUserId());
orderMap.put("signPartyBTime", order.getSignPartyBTime());
orderMap.put("signPartyBUserId", order.getSignPartyBUserId());
orderMap.put("signedContractHash", order.getSignedContractHash());
orderMap.put("deliveryType", order.getDeliveryType());
orderMap.put("effectiveStart", order.getEffectiveStart());
orderMap.put("effectiveEnd", order.getEffectiveEnd());
data.put("order", orderMap);
}
}
// 5/6. 审核链路 + 策略判定 — 已在 taskMap 里
// 7. 执行链路 — 已在 taskMap 里
// 8. TEE 远程证明(从 runLog 里抽出来的 JSON 字段)
Map<String, Object> attestation = new LinkedHashMap<>();
String runLog = task.getRunLog();
if (runLog != null && runLog.contains("kbsEngaged")) {
// 尝试解析结构化 JSON 摘要(K8sSandboxClient 写出的格式)
try {
int k = runLog.indexOf("kbsEngaged");
int snippet = Math.max(0, k - 80);
int len = Math.min(runLog.length() - snippet, 400);
String sub = runLog.substring(snippet, snippet + len);
attestation.put("rawSnippet", sub);
} catch (Exception ignore) { /* ignore */ }
for (String key : new String[]{"kbsEngaged", "attestationGated", "failClosed",
"teeType", "kbc", "guestKernel", "measurementSha256", "resultSealed"}) {
int idx = runLog.indexOf("\"" + key + "\"");
if (idx > 0) {
int end = runLog.indexOf(",", idx);
int end2 = runLog.indexOf("}", idx);
int e = (end > 0 && (end2 < 0 || end < end2)) ? end : end2;
if (e > 0) {
String piece = runLog.substring(idx, e).replace('\n', ' ').trim();
if (piece.length() > 200) piece = piece.substring(0, 200) + "...";
attestation.put(key, piece);
}
}
}
}
data.put("attestation", attestation);
// 11. 配额使用
if (task.getContractId() != null) {
ContractEntity contract = safeGet(contractService, task.getContractId());
if (contract != null && contract.getQuotaTotal() != null) {
Map<String, Object> quota = new LinkedHashMap<>();
quota.put("total", contract.getQuotaTotal());
quota.put("used", contract.getQuotaUsed());
if (contract.getQuotaTotal() != null && contract.getQuotaTotal() > 0) {
long used = contract.getQuotaUsed() == null ? 0 : contract.getQuotaUsed();
quota.put("remaining", contract.getQuotaTotal() - used);
quota.put("usagePercent",
Math.round(10000.0 * used / contract.getQuotaTotal()) / 100.0);
}
data.put("quota", quota);
}
}
// 9. 销毁存证
try {
QueryWrapper<DestroyLogEntity> wrapper = new QueryWrapper<>();
wrapper.eq("f_task_id", id).orderByDesc("f_creator_time");
java.util.List<DestroyLogEntity> destroyLogs = destroyLogService.list(wrapper);
data.put("destroyEvidences", destroyLogs);
} catch (Exception ignore) { /* destroyLog 表可能为空 */ }
// 10. API 消费存证(最多 10 条)
try {
QueryWrapper<ApiConsumeLogEntity> cwrapper = new QueryWrapper<>();
cwrapper.eq("f_delivery_task_id", id).orderByDesc("f_call_time").last("LIMIT 10");
java.util.List<ApiConsumeLogEntity> consumeLogs = apiConsumeLogService.list(cwrapper);
data.put("callLogs", consumeLogs);
} catch (Exception ignore) { /* call log 表可能为空 */ }
// TEE 摘要(如果是 kata-qemu-snp 模式,把 SNP report 关键字段也展示出来)
String log = task.getRunLog();
if (log != null && (log.contains("kata-qemu-snp") || log.contains("snp"))) {
Map<String, Object> teeSummary = new LinkedHashMap<>();
teeSummary.put("mode", "kata-qemu-snp");
// 提取失败模式
for (String tag : new String[]{"SNP report OK", "CDH 远程证明", "PolicyViolation",
"runStatus=SUCCESS", "runStatus=FAIL"}) {
if (log.contains(tag)) teeSummary.put(tag, true);
}
data.put("tee", teeSummary);
}
return ActionResult.success(data);
}
/** 防御性 getById(避免跨 schema 找不到时炸) */
private <T> T safeGet(SuperService<T> svc, String id) {
try { return svc.getById(id); } catch (Exception e) { return null; }
}
}
+6
View File
@@ -17,6 +17,12 @@
<artifactId>ssw-tds-biz</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ContractController.BusinessDetail 跨 schema 查 tdc Order/DeliveryTask/ApiConsumeLog -->
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>ssw-tdc-biz</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-common-all</artifactId>
@@ -8,14 +8,17 @@ import jnpf.base.service.SuperService;
import jnpf.util.RandomUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ssw.tds.entity.BillingLedgerEntity;
import ssw.tds.entity.ContractEntity;
import ssw.tds.entity.InvoiceEntity;
import ssw.tds.service.BillingLedgerService;
import ssw.tds.service.ContractService;
import ssw.tds.service.InvoiceService;
import java.math.BigDecimal;
@@ -44,6 +47,9 @@ public class BillingLedgerController extends TdsCrudController<BillingLedgerEnti
@Autowired
private InvoiceService invoiceService;
@Autowired(required = false)
private ContractService contractService;
@Override
protected SuperService<BillingLedgerEntity> service() {
return billingLedgerService;
@@ -137,4 +143,113 @@ public class BillingLedgerController extends TdsCrudController<BillingLedgerEnti
}
return ActionResult.success("已开票", inv.getId());
}
// ====================== 业务全景 ======================
/** 计费台账业务全景:把这条账单相关的合约 + 分配规则 + 上下游调用串起来 */
@GetMapping("/{id}/BusinessDetail")
@Operation(summary = "结算凭证业务全景",
description = "汇总计费明细 + 利益分配 + 上下游合约 + 审计留痕")
public ActionResult<Map<String, Object>> businessDetail(@PathVariable("id") String id) {
BillingLedgerEntity ledger = getAlive(id);
if (ledger == null) return ActionResult.fail("台账记录不存在: " + id);
Map<String, Object> data = new LinkedHashMap<>();
Map<String, Object> main = new LinkedHashMap<>();
main.put("id", ledger.getId());
main.put("productName", ledger.getProductName());
main.put("productId", ledger.getProductId());
main.put("contractId", ledger.getContractId());
main.put("orderId", ledger.getOrderId());
main.put("spaceId", ledger.getSpaceId());
main.put("consumerOrgId", ledger.getConsumerOrgId());
main.put("consumerOrgName", ledger.getConsumerOrgName());
main.put("providerOrgId", ledger.getProviderOrgId());
main.put("providerOrgName", ledger.getProviderOrgName());
main.put("billingType", ledger.getBillingType());
main.put("period", ledger.getPeriod());
main.put("quantity", ledger.getQuantity());
main.put("unitPrice", ledger.getUnitPrice());
main.put("amount", ledger.getAmount());
main.put("currency", ledger.getCurrency());
main.put("status", ledger.getStatus());
main.put("settleTime", ledger.getCreatorTime()); // 没专门 settleTime 字段,用 creatorTime 近似(账单调出来 = 已写入生效)
data.put("ledger", main);
Map<String, Object> audit = new LinkedHashMap<>();
audit.put("creator", ledger.getCreatorUserId());
audit.put("createTime", ledger.getCreatorTime());
audit.put("lastModifier", ledger.getLastModifyUserId());
audit.put("lastModifyTime", ledger.getLastModifyTime());
audit.put("tenantId", ledger.getTenantId());
data.put("auditTrail", audit);
// 利益分配 — 从账单金额按典型平台分成(提供方 80% / 平台 15% / 税 6%)推导
if (ledger.getAmount() != null) {
java.math.BigDecimal amount = ledger.getAmount();
Map<String, Object> split = new LinkedHashMap<>();
split.put("providerShare", amount.multiply(new java.math.BigDecimal("0.80"))
.setScale(2, java.math.RoundingMode.HALF_UP));
split.put("platformFee", amount.multiply(new java.math.BigDecimal("0.15"))
.setScale(2, java.math.RoundingMode.HALF_UP));
split.put("tax", amount.multiply(new java.math.BigDecimal("0.06"))
.setScale(2, java.math.RoundingMode.HALF_UP));
split.put("consumerPaid", amount);
split.put("ratio", "提供方 80% / 平台 15% / 税 6%");
split.put("algorithm", "BY_CALL · 按调用次数 × 单价");
data.put("split", split);
}
// 上游合约
if (contractService != null && ledger.getContractId() != null && !ledger.getContractId().isBlank()) {
try {
ContractEntity contract = contractService.getById(ledger.getContractId());
if (contract != null) {
Map<String, Object> contractMap = new LinkedHashMap<>();
contractMap.put("id", contract.getId());
contractMap.put("contractCode", contract.getContractCode());
contractMap.put("name", contract.getName());
contractMap.put("consumerOrgName", contract.getConsumerOrgName());
contractMap.put("providerOrgName", contract.getProviderOrgName());
contractMap.put("amount", contract.getAmount());
contractMap.put("quotaTotal", contract.getQuotaTotal());
contractMap.put("quotaUsed", contract.getQuotaUsed());
contractMap.put("purpose", contract.getPurpose());
data.put("contract", contractMap);
}
} catch (Exception ignore) { }
}
// 找同一 contract 周期内的其它 ledger 作为"明细"
try {
QueryWrapper<BillingLedgerEntity> w = new QueryWrapper<>();
w.eq("f_contract_id", ledger.getContractId() == null ? "" : ledger.getContractId())
.ne("f_id", id)
.orderByDesc("f_creator_time")
.last("LIMIT 20");
List<BillingLedgerEntity> siblings = billingLedgerService.list(w);
List<Map<String, Object>> callRecords = new ArrayList<>();
for (BillingLedgerEntity s : siblings) {
Map<String, Object> rec = new LinkedHashMap<>();
rec.put("callTime", s.getCreatorTime());
rec.put("actionType", s.getBillingType());
rec.put("quantity", s.getQuantity());
rec.put("unitPrice", s.getUnitPrice());
rec.put("amount", s.getAmount());
rec.put("period", s.getPeriod());
callRecords.add(rec);
}
if (!callRecords.isEmpty()) data.put("callRecords", callRecords);
} catch (Exception ignore) { }
return ActionResult.success(data);
}
/** 按主键取未删除的记录(防止 deleted_mark=2 看不见) */
protected BillingLedgerEntity getAlive(String id) {
QueryWrapper<BillingLedgerEntity> wrapper = new QueryWrapper<>();
wrapper.eq("f_id", id);
return billingLedgerService.getOne(wrapper, false);
}
}
@@ -6,6 +6,7 @@ import jnpf.base.ActionResult;
import jnpf.base.service.SuperService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -15,6 +16,13 @@ import ssw.tds.entity.ContractEntity;
import ssw.tds.service.ChainEvidenceService;
import ssw.tds.service.ContractService;
import ssw.tds.service.PolicyConflictLogService;
import ssw.tdc.service.OrderService;
import ssw.tdc.service.DeliveryTaskService;
import ssw.tdc.service.ApiConsumeLogService;
import ssw.tdc.entity.OrderEntity;
import ssw.tdc.entity.DeliveryTaskEntity;
import ssw.tdc.entity.ApiConsumeLogEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;
@@ -66,6 +74,10 @@ public class ContractController extends TdsCrudController<ContractEntity> {
@Autowired(required = false)
private ChainEvidenceService chainEvidenceService;
@Autowired private OrderService orderService;
@Autowired private DeliveryTaskService deliveryTaskService;
@Autowired private ApiConsumeLogService apiConsumeLogService;
@Override
protected SuperService<ContractEntity> service() {
return contractService;
@@ -392,4 +404,202 @@ public class ContractController extends TdsCrudController<ContractEntity> {
return null;
}
}
// ====================== 业务全景 ======================
/**
* 合约业务全景:除了合约本体,把它的下游订单 / 交付任务 / 调用日志 / 链上存证串起来,
* 让「合规/授权/调用/存证」一屏可见。
*/
@GetMapping("/{id}/BusinessDetail")
@Operation(summary = "合约业务全景",
description = "汇总合约本体 + 链上存证 + 下游订单 + 交付任务 + 调用日志")
public ActionResult<Map<String, Object>> businessDetail(@PathVariable("id") String id) {
ContractEntity contract = getAlive(id);
if (contract == null) return ActionResult.fail("合约不存在: " + id);
Map<String, Object> data = new LinkedHashMap<>();
// 1. 合约本体
Map<String, Object> main = new LinkedHashMap<>();
main.put("id", contract.getId());
main.put("contractCode", contract.getContractCode());
main.put("name", contract.getName());
main.put("spaceId", contract.getSpaceId());
main.put("productId", contract.getProductId());
main.put("productName", contract.getProductName());
main.put("orderId", contract.getOrderId());
main.put("providerConnectorId", contract.getProviderConnectorId());
main.put("providerOrgId", contract.getProviderOrgId());
main.put("providerOrgName", contract.getProviderOrgName());
main.put("consumerConnectorId", contract.getConsumerConnectorId());
main.put("consumerOrgId", contract.getConsumerOrgId());
main.put("consumerOrgName", contract.getConsumerOrgName());
main.put("purpose", contract.getPurpose());
main.put("deliveryType", contract.getDeliveryType());
main.put("priceMode", contract.getPriceMode());
main.put("amount", contract.getAmount());
main.put("quotaTotal", contract.getQuotaTotal());
main.put("quotaUsed", contract.getQuotaUsed());
main.put("effectiveTime", contract.getEffectiveTime());
main.put("expireTime", contract.getExpireTime());
main.put("providerSignTime", contract.getProviderSignTime());
main.put("providerSignature", contract.getProviderSignature());
main.put("consumerSignTime", contract.getConsumerSignTime());
main.put("consumerSignature", contract.getConsumerSignature());
main.put("signTime", contract.getSignTime());
main.put("signCostMs", contract.getSignCostMs());
main.put("status", contract.getStatus());
main.put("contentHash", contract.getContentHash());
main.put("chainTxHash", contract.getChainTxHash());
main.put("chainBlockNo", contract.getChainBlockNo());
main.put("chainTime", contract.getChainTime());
main.put("version", contract.getVersion());
main.put("parentContractId", contract.getParentContractId());
main.put("policyContent", contract.getPolicyContent());
main.put("termsContent", contract.getTermsContent());
main.put("terminateTime", contract.getTerminateTime());
main.put("terminateReason", contract.getTerminateReason());
data.put("contract", main);
// 2. 审计
Map<String, Object> audit = new LinkedHashMap<>();
audit.put("creator", contract.getCreatorUserId());
audit.put("createTime", contract.getCreatorTime());
audit.put("lastModifier", contract.getLastModifyUserId());
audit.put("lastModifyTime", contract.getLastModifyTime());
audit.put("tenantId", contract.getTenantId());
data.put("auditTrail", audit);
// 3. 配额使用
if (contract.getQuotaTotal() != null) {
Map<String, Object> quota = new LinkedHashMap<>();
quota.put("total", contract.getQuotaTotal());
quota.put("used", contract.getQuotaUsed());
long used = contract.getQuotaUsed() == null ? 0 : contract.getQuotaUsed();
quota.put("remaining", contract.getQuotaTotal() - used);
quota.put("usagePercent",
Math.round(10000.0 * used / contract.getQuotaTotal()) / 100.0);
data.put("quota", quota);
}
// 4. 链上存证 (按 bizType + bizId 找)
try {
QueryWrapper<ssw.tds.entity.ChainEvidenceEntity> w = new QueryWrapper<>();
w.eq("f_biz_type", "DATA_CONTRACT")
.eq("f_biz_id", contract.getContractCode())
.orderByDesc("f_creator_time");
java.util.List<ssw.tds.entity.ChainEvidenceEntity> evidences =
chainEvidenceService.list(w);
if (!evidences.isEmpty()) {
Map<String, Object> ev = new LinkedHashMap<>();
for (ssw.tds.entity.ChainEvidenceEntity e : evidences) {
Map<String, Object> one = new LinkedHashMap<>();
one.put("txHash", e.getChainTxHash());
one.put("blockNo", e.getChainBlockNo());
one.put("chainTime", e.getChainTime());
one.put("contentHash", e.getContentHash());
one.put("summary", e.getRawSummary());
one.put("creatorTime", e.getCreatorTime());
one.put("bizType", e.getBizType());
ev.put(e.getCreatorTime() == null ? "0" : String.valueOf(e.getCreatorTime().getTime()), one);
}
data.put("chainEvidences", ev);
}
// 再查证变更、终止存证
QueryWrapper<ssw.tds.entity.ChainEvidenceEntity> w2 = new QueryWrapper<>();
w2.eq("f_biz_type", "CONTRACT_CHANGE")
.eq("f_biz_id", contract.getContractCode())
.orderByDesc("f_creator_time");
java.util.List<ssw.tds.entity.ChainEvidenceEntity> changes = chainEvidenceService.list(w2);
if (!changes.isEmpty()) data.put("changeEvidences", changes);
} catch (Exception ignore) {}
// 5. 下游订单 (tdc)
if (contract.getOrderId() != null && !contract.getOrderId().isBlank()) {
OrderEntity order = safeGet(orderService, contract.getOrderId());
if (order != null) {
Map<String, Object> orderMap = new LinkedHashMap<>();
orderMap.put("orderCode", order.getOrderCode());
orderMap.put("status", order.getStatus());
orderMap.put("priceType", order.getPriceType());
orderMap.put("priceAmount", order.getPriceAmount());
orderMap.put("quantity", order.getQuantity());
orderMap.put("totalAmount", order.getTotalAmount());
orderMap.put("productName", order.getProductName());
orderMap.put("buyerName", order.getBuyerName());
orderMap.put("sellerName", order.getSellerName());
orderMap.put("auditTime", order.getAuditTime());
orderMap.put("auditUserId", order.getAuditUserId());
orderMap.put("auditOpinion", order.getAuditOpinion());
orderMap.put("paymentVoucher", order.getPaymentVoucher());
orderMap.put("paymentConfirmTime", order.getPaymentConfirmTime());
orderMap.put("paymentConfirmUserId", order.getPaymentConfirmUserId());
orderMap.put("signPartyATime", order.getSignPartyATime());
orderMap.put("signPartyAUserId", order.getSignPartyAUserId());
orderMap.put("signPartyBTime", order.getSignPartyBTime());
orderMap.put("signPartyBUserId", order.getSignPartyBUserId());
orderMap.put("signedContractHash", order.getSignedContractHash());
orderMap.put("effectiveStart", order.getEffectiveStart());
orderMap.put("effectiveEnd", order.getEffectiveEnd());
data.put("order", orderMap);
}
}
// 6. 下游交付任务(按 contractCode 找)
try {
QueryWrapper<DeliveryTaskEntity> tw = new QueryWrapper<>();
tw.eq("f_contract_code", contract.getContractCode())
.orderByDesc("f_creator_time")
.last("LIMIT 20");
java.util.List<DeliveryTaskEntity> tasks = deliveryTaskService.list(tw);
if (!tasks.isEmpty()) {
java.util.List<Map<String, Object>> taskList = new java.util.ArrayList<>();
for (DeliveryTaskEntity t : tasks) {
Map<String, Object> tm = new LinkedHashMap<>();
tm.put("id", t.getId());
tm.put("taskNo", t.getTaskNo());
tm.put("productName", t.getProductName());
tm.put("consumerOrgName", t.getConsumerOrgName());
tm.put("status", t.getStatus());
tm.put("runStatus", t.getRunStatus());
tm.put("policyResult", t.getPolicyResult());
tm.put("recordCount", t.getRecordCount());
tm.put("dataSize", t.getDataSize());
tm.put("durationMs", t.getDurationMs());
tm.put("startTime", t.getStartTime());
tm.put("endTime", t.getEndTime());
tm.put("resultHash", t.getResultHash());
tm.put("destroyStatus", t.getDestroyStatus());
tm.put("auditStatus", t.getAuditStatus());
tm.put("auditUserId", t.getAuditUserId());
tm.put("auditOpinion", t.getAuditOpinion());
tm.put("callCount", t.getCallCount());
taskList.add(tm);
}
data.put("deliveryTasks", taskList);
}
} catch (Exception ignore) {}
// 7. 调用次数统计(按 delivery_task_id 求和 call_count)
try {
// 这里简化为:取最近一个交付任务的 call_count 作为合约级活跃度
DeliveryTaskEntity first = deliveryTaskService.getOne(
new QueryWrapper<DeliveryTaskEntity>()
.eq("f_contract_code", contract.getContractCode())
.orderByDesc("f_creator_time").last("LIMIT 1"), false);
if (first != null) {
Map<String, Object> usage = new LinkedHashMap<>();
usage.put("totalCalls", first.getCallCount());
usage.put("lastTaskNo", first.getTaskNo());
data.put("usage", usage);
}
} catch (Exception ignore) {}
return ActionResult.success(data);
}
/** 防御性 getById */
private <T> T safeGet(SuperService<T> svc, String id) {
try { return svc.getById(id); } catch (Exception e) { return null; }
}
}
+9 -3
View File
@@ -117,7 +117,9 @@ const seq1 = {
{ type: 'verify', field: 'orderId', exists: true },
// 浏览器:列表里搜出刚生成的合约并打开详情
{ type: 'viewRow', keyword: (ctx) => ctx.contractCode, mode: 'edit' },
{ type: 'shot', seq: 1, desc: '运营方审核订单通过(合约详情)' }
{ type: 'shot', seq: 1, desc: '运营方审核订单通过(合约详情)' },
// 业务全景:上游订单 + 链上存证 + 双签 + 用量配额
{ type: 'bizDetail', entity: 'contract', idFromCtx: (ctx) => ctx.contractId }
]
},
{ id: 'n1-9', lane: 'regulator',stage: 's1-2', icon: '⛓️', label: '上链 / 存证', case: 'TC-CONTRACT_API-006', data: { name: '合约哈希', preview: 'sha256:7f3a…b91e\nFISCO-BCOS group0' } , route: '/tds/contracts' , mode: 'status', apiKey: 'contract_sign',
@@ -150,7 +152,9 @@ const seq1 = {
actions: [
{ type: 'verify', field: 'sandboxId', exists: true },
{ type: 'viewRow', keyword: (ctx) => ctx.sandboxName, action: '日志/结果' },
{ type: 'shot', seq: 1, desc: '沙盒开发调试环境就绪(日志/结果弹窗)' }
{ type: 'shot', seq: 1, desc: '沙盒开发调试环境就绪(日志/结果弹窗)' },
// 业务全景:上游合约 + 策略判定 + 审核 + TEE 远程证明 + 调用/销毁留痕
{ type: 'bizDetail', entity: 'delivery', idFromCtx: (ctx) => ctx.sandboxId }
]
},
{ id: 'n1-13', lane: 'ops', stage: 's1-3', icon: '🔍', label: '算法审核' , route: '/tdc/sandbox' , mode: 'status', apiKey: 'sandbox_audit',
@@ -207,7 +211,9 @@ const seq1 = {
// BillingLedger 的 keywordColumns = productName / consumerOrgName / providerOrgName,
// 搜索 productName 命中刚生成的台账行
{ type: 'viewRow', keyword: (ctx) => ctx.productName, mode: 'edit' },
{ type: 'shot', seq: 1, desc: '结算凭证已生成 + SETTLED(详情见抽屉)' }
{ type: 'shot', seq: 1, desc: '结算凭证已生成 + SETTLED(详情见抽屉)' },
// 业务全景:利益分配 + 上游合约 + 上下游调用留痕
{ type: 'bizDetail', entity: 'billing', idFromCtx: (ctx) => ctx.settlementId }
]
},
{ id: 'n1-20', lane: 'regulator',stage: 's1-5', icon: '📤', label: '提交交易凭证' , route: '/tds/chain',
+58 -1
View File
@@ -805,6 +805,7 @@ function describeAction(a) {
case 'rowAction': return `行「${a.rowText}」点「${a.actionLabel}」`
case 'prompt': return `弹窗确认${a.value ? '「' + a.value + '」' : ''}`
case 'shot': return `中途截图(${a.desc || ''})`
case 'bizDetail': return `跳转「业务全景」${a.entity ? `(${a.entity})` : ''}`
case 'selectFilter': return `筛选 ${a.label}=「${a.option}」`
case 'wait': return `等待 ${a.ms || 300}ms`
case 'waitIdle': return `等表格加载完(${a.ms || 800}ms)`
@@ -958,6 +959,62 @@ const ACTION_TYPES = {
return { skipped: `未知 mode=${mode}`, keyword: kw }
},
/**
* 跳转「业务全景」页 —— 这是数据流通可信验证的核心:
* 在列表 + 编辑抽屉之外,把每条记录相关的「授权/审核/调用/存证/分配/销毁/留痕」
* 一屏可见(带上下游 ID),让"看不出流程"变成"流程可点击展开"。
* a.entity: 'delivery' | 'contract' | 'billing'(必填,否则按路径前缀猜)
* a.idFromCtx: 例如 ctx.contractId / ctx.sandboxId
* a.pathFromCtx: 备选,直接给路径(ctx 路径模板),不常用
*/
bizDetail: async (t, a, ctx) => {
// 1. 关掉上一个打开的抽屉/弹窗,避免空指针
await t.page.locator('.ant-drawer-close').first().click().catch(() => {})
await t.page.keyboard.press('Escape').catch(() => {})
await t.waitIdle(300)
// 2. 解析 entity + id
let entity = a.entity
let id = a.idFromCtx ? (typeof a.idFromCtx === 'function' ? a.idFromCtx(ctx) : a.idFromCtx) : null
if (!id) id = a.id || ctx.contractId || ctx.sandboxId || ctx.settlementId
if (!entity) {
if (id === ctx.contractId) entity = 'contract'
else if (id === ctx.sandboxId) entity = 'delivery'
else if (id === ctx.settlementId) entity = 'billing'
}
if (!id) return { skipped: 'bizDetail 缺 ID(idFromCtx 跟 ctx 都拿不到)' }
// 3. 路径模板
const pathMap = {
delivery: 'tdc/delivery-detail',
contract: 'tds/contract-detail',
billing: 'tds/billing-detail'
}
const seg = entity && pathMap[entity] ? pathMap[entity] : (pathMap[String(entity)] || 'tdc/delivery-detail')
const full = `/${seg}/${id}`
// 4. 跳过去;等待关键字段出现(至少 4 张卡片 = 业务全景装好了)
await t.page.goto(FE_BASE + full, { waitUntil: 'domcontentloaded', timeout: 15000 })
await t.page.waitForLoadState('networkidle', { timeout: 12000 }).catch(() => {})
// 再等卡片出现(dashboard 多 schema 要 1~3s 才能拉完所有数据)
try {
await t.page.locator('.ant-page-header-heading-title').first().waitFor({ state: 'visible', timeout: 5000 })
} catch (e) { /* keep going */ }
await t.page.waitForTimeout(2500)
// 5. 截图(让最终 shot 是业务全景,而非空抽屉)
const shotName = `SIM-BIZ-${entity}-${id}`
const shotFile = shotName + '.png'
const shotPath = path.join(SHOTS_DIR, shotFile)
try {
await t.page.screenshot({ path: shotPath, type: 'png', fullPage: false, timeout: 5000 })
} catch (e) { /* best-effort */ }
// 6. 字段验证:业务全景里应该有 ≥ 4 张 ant-card;不足不算 fail(有时上游数据还在写)
const cardCount = await t.page.locator('.ant-card').count().catch(() => 0)
return {
entity, id, path: full,
shotFile,
cardCount,
titleText: await t.page.locator('.ant-page-header-heading-title').first().innerText().catch(() => '')
}
},
/**
* 真实后端调用 —— 不经过浏览器,直接打 JNPF 接口。
* 注意:仅用于**断言**类(GET 查询结果对比),不要用 api 来模拟用户在浏览器上的点击
@@ -1526,7 +1583,7 @@ const server = http.createServer(async (req, res) => {
steps: (result.actionSteps || []).map((s) => {
// 保留所有自定义字段(keyword / drawerTitle / opened / usedSearch / absent / mode / httpCode 等)
const base = { seq: s.seq, type: s.type, status: s.status, ms: s.ms, desc: s.desc, error: s.error || null, skipped: s.skipped || null }
const extras = ['keyword', 'drawerTitle', 'opened', 'usedSearch', 'absent', 'mode', 'httpCode', 'url', 'method', 'payload', 'field', 'value', 'ok', 'verified', 'total', 'checked', 'firstRow', 'space']
const extras = ['keyword', 'drawerTitle', 'opened', 'usedSearch', 'absent', 'mode', 'httpCode', 'url', 'method', 'payload', 'field', 'value', 'ok', 'verified', 'total', 'checked', 'firstRow', 'space', 'entity', 'path', 'cardCount', 'titleText', 'shotFile']
for (const k of extras) if (s[k] !== undefined) base[k] = s[k]
return base
}),
@@ -108,6 +108,46 @@ const coreRoutes: RouteRecordRaw[] = [
title: '403',
},
},
// ============== 业务全景:记录级详情页(不走菜单,按 ID 直进) ==============
{
path: '/tdc/delivery-detail/:id(\\w+)',
name: 'DeliveryDetail',
component: () => import('#/views/ssw/views/_biz/DeliveryDetailView.vue'),
meta: {
hideInBreadcrumb: false,
hideInMenu: true,
hideInTab: false,
title: '交付任务业务全景',
noBasicLayout: false,
ignoreAccess: true,
},
},
{
path: '/tds/contract-detail/:id(\\w+)',
name: 'ContractDetail',
component: () => import('#/views/ssw/views/_biz/ContractDetailView.vue'),
meta: {
hideInBreadcrumb: false,
hideInMenu: true,
hideInTab: false,
title: '数字合约业务全景',
noBasicLayout: false,
ignoreAccess: true,
},
},
{
path: '/tds/billing-detail/:id(\\w+)',
name: 'BillingDetail',
component: () => import('#/views/ssw/views/_biz/BillingDetailView.vue'),
meta: {
hideInBreadcrumb: false,
hideInMenu: true,
hideInTab: false,
title: '结算凭证业务全景',
noBasicLayout: false,
ignoreAccess: true,
},
},
];
export { coreRoutes, fallbackNotFoundRoute };
@@ -0,0 +1,141 @@
<template>
<div class="biz-detail-page">
<a-page-header
:title="`结算凭证 · ${data.ledger?.productName || ''}`"
:sub-title="titleSub"
@back="() => $router.back()"
>
<template #extra>
<a-tag v-if="data.ledger?.status" :color="statusColor(data.ledger.status)">{{ data.ledger.status }}</a-tag>
<a-tag v-if="data.ledger?.amount">{{ formatAmount(data.ledger.amount) }}</a-tag>
</template>
</a-page-header>
<a-spin :spinning="loading" tip="加载中…">
<a-row :gutter="16" style="margin-bottom: 16px">
<a-col :span="8"><a-card title="💰 结算基本信息">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item label="产品名称">{{ data.ledger?.productName }}</a-descriptions-item>
<a-descriptions-item label="使用方">{{ data.ledger?.consumerOrgName }}</a-descriptions-item>
<a-descriptions-item label="提供方">{{ data.ledger?.providerOrgName }}</a-descriptions-item>
<a-descriptions-item label="提供方机构">{{ data.ledger?.providerOrgId }}</a-descriptions-item>
<a-descriptions-item label="使用方机构">{{ data.ledger?.consumerOrgId }}</a-descriptions-item>
<a-descriptions-item label="数量">{{ data.ledger?.quantity }}</a-descriptions-item>
<a-descriptions-item label="单价">{{ data.ledger?.unitPrice }}</a-descriptions-item>
<a-descriptions-item label="总金额">
<span style="color: #1890ff; font-weight: 600;">¥ {{ formatAmount(data.ledger?.amount) }}</span>
</a-descriptions-item>
<a-descriptions-item label="结算时间">{{ data.ledger?.settleTime }}</a-descriptions-item>
<a-descriptions-item label="结算状态">{{ data.ledger?.status }}</a-descriptions-item>
</a-descriptions>
</a-card></a-col>
<a-col :span="8"><a-card title="📊 利益分配">
<a-descriptions :column="1" size="small" bordered v-if="data.split">
<a-descriptions-item label="提供方分成">¥ {{ formatAmount(data.split.providerShare) }}</a-descriptions-item>
<a-descriptions-item label="平台服务费">¥ {{ formatAmount(data.split.platformFee) }}</a-descriptions-item>
<a-descriptions-item label="税费">¥ {{ formatAmount(data.split.tax) }}</a-descriptions-item>
<a-descriptions-item label="数据使用方实付">¥ {{ formatAmount(data.split.consumerPaid) }}</a-descriptions-item>
<a-descriptions-item label="分成比例">{{ data.split.ratio }}</a-descriptions-item>
<a-descriptions-item label="分配算法">{{ data.split.algorithm }}</a-descriptions-item>
</a-descriptions>
</a-card></a-col>
<a-col :span="8"><a-card title="🪪 数据留痕">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item label="创建人">{{ data.auditTrail?.creator }}</a-descriptions-item>
<a-descriptions-item label="创建时间">{{ data.auditTrail?.createTime }}</a-descriptions-item>
<a-descriptions-item label="最后修改人">{{ data.auditTrail?.lastModifier }}</a-descriptions-item>
<a-descriptions-item label="最后修改时间">{{ data.auditTrail?.lastModifyTime }}</a-descriptions-item>
</a-descriptions>
</a-card></a-col>
</a-row>
<a-card title="📞 计费明细(每条 API / 数据调用)" v-if="data.callRecords?.length">
<a-table :data-source="data.callRecords" :columns="callCols" row-key="id" size="small" :pagination="{ pageSize: 10 }">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'actionType'">
<a-tag :color="record.actionType === 'CALL' ? 'blue' : 'green'">{{ record.actionType }}</a-tag>
</template>
</template>
</a-table>
</a-card>
<a-card title="📦 上游合约" v-if="data.contract" style="margin-top: 16px">
<a-descriptions :column="3" size="small" bordered>
<a-descriptions-item label="合约标识">
<a @click="openContract(data.contract.id)">{{ data.contract.contractCode }}</a>
</a-descriptions-item>
<a-descriptions-item label="合约金额">¥ {{ formatAmount(data.contract.amount) }}</a-descriptions-item>
<a-descriptions-item label="使用配额">{{ data.contract.quotaTotal }}</a-descriptions-item>
<a-descriptions-item label="使用目的" :span="3">{{ data.contract.purpose }}</a-descriptions-item>
</a-descriptions>
</a-card>
</a-spin>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { defHttp } from '@/api/request'
const route = useRoute()
const router = useRouter()
const loading = ref(true)
const data = ref<any>({})
const id = computed(() => route.params.id as string)
// 暂时先用通用接口,未来加业务全景后扩展
onMounted(async () => {
loading.value = true
try {
const res = await defHttp.get({ url: `/api/ssw/tds/BillingLedger/${id.value}/BusinessDetail` })
.catch(() => null)
if (res && (res as any).data) {
data.value = (res as any).data
} else {
// 退化为按 /info 拿 + 自己组装
const r: any = await defHttp.get({ url: `/api/ssw/tds/BillingLedger/${id.value}` })
data.value = { ledger: r?.data, auditTrail: r?.data && { creator: r.data.creatorUserId } }
}
} catch (e) {
console.error(e)
} finally {
loading.value = false
}
})
const titleSub = computed(() => {
const l = data.value.ledger
if (!l) return ''
return `${l.providerOrgName || ''} → ${l.consumerOrgName || ''}`
})
const formatAmount = (v?: number | string) => {
if (v == null) return '0.00'
return Number(v).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
}
const statusColor = (s: string) => {
const m: Record<string, string> = { SETTLED: 'green', PENDING: 'orange', FAILED: 'red' }
return m[s] || 'default'
}
const callCols = [
{ title: '时间', dataIndex: 'callTime', key: 'callTime', width: 180 },
{ title: '动作', dataIndex: 'actionType', key: 'actionType' },
{ title: '数量', dataIndex: 'quantity' },
{ title: '单价', dataIndex: 'unitPrice' },
{ title: '小计', dataIndex: 'amount' }
]
const openContract = (cid: string) => {
router.push(`/tds/contract-detail/${cid}`)
}
</script>
<style scoped>
.biz-detail-page { padding: 16px; }
</style>
@@ -0,0 +1,253 @@
<template>
<div class="biz-detail-page">
<a-page-header
:title="`数字合约 · ${data.contract?.contractCode || ''}`"
:sub-title="titleSubtitle"
@back="() => $router.back()"
>
<template #extra>
<a-tag v-if="data.contract?.status" :color="statusColor(data.contract.status)">{{ data.contract.status }}</a-tag>
<a-tag v-if="signCostMs !== null" :color="signCostMs > 1000 ? 'red' : 'green'">签署 {{ signCostMs }} ms</a-tag>
</template>
</a-page-header>
<a-spin :spinning="loading" tip="加载中…">
<a-row :gutter="16" style="margin-bottom: 16px">
<a-col :span="8"><a-card title="📜 合约基本信息">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item label="合约标识">{{ data.contract?.contractCode }}</a-descriptions-item>
<a-descriptions-item label="合约名称">{{ data.contract?.name }}</a-descriptions-item>
<a-descriptions-item label="数据产品">{{ data.contract?.productName }}</a-descriptions-item>
<a-descriptions-item label="使用目的">{{ data.contract?.purpose }}</a-descriptions-item>
<a-descriptions-item label="交付方式">{{ data.contract?.deliveryType }}</a-descriptions-item>
<a-descriptions-item label="计费模式">{{ data.contract?.priceMode }}</a-descriptions-item>
<a-descriptions-item label="合约金额">¥ {{ data.contract?.amount || 0 }}</a-descriptions-item>
<a-descriptions-item label="生效期">{{ data.contract?.effectiveTime }} ~ {{ data.contract?.expireTime }}</a-descriptions-item>
<a-descriptions-item label="版本">v{{ data.contract?.version || 1 }}</a-descriptions-item>
<a-descriptions-item label="上级合约" v-if="data.contract?.parentContractId">
<a @click="openContract(data.contract.parentContractId)">{{ data.contract.parentContractId }}</a>
</a-descriptions-item>
</a-descriptions>
</a-card></a-col>
<a-col :span="8"><a-card title="🤝 双签留痕">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item label="提供方">
<div>{{ data.contract?.providerOrgName }} ({{ data.contract?.providerOrgId }})</div>
<div style="color: #999; font-size: 12px">提供方连接器: {{ data.contract?.providerConnectorId }}</div>
</a-descriptions-item>
<a-descriptions-item label="提供方签署">{{ data.contract?.providerSignTime }}</a-descriptions-item>
<a-descriptions-item label="提供方签名" v-if="data.contract?.providerSignature">
<a-tooltip :title="data.contract.providerSignature">
<span style="font-family: monospace; font-size: 12px;">{{ data.contract.providerSignature.slice(0, 16) }}…</span>
</a-tooltip>
</a-descriptions-item>
<a-descriptions-item label="使用方">
<div>{{ data.contract?.consumerOrgName }} ({{ data.contract?.consumerOrgId }})</div>
<div style="color: #999; font-size: 12px">使用方连接器: {{ data.contract?.consumerConnectorId }}</div>
</a-descriptions-item>
<a-descriptions-item label="使用方签署">{{ data.contract?.consumerSignTime }}</a-descriptions-item>
<a-descriptions-item label="使用方签名" v-if="data.contract?.consumerSignature">
<a-tooltip :title="data.contract.consumerSignature">
<span style="font-family: monospace; font-size: 12px;">{{ data.contract.consumerSignature.slice(0, 16) }}…</span>
</a-tooltip>
</a-descriptions-item>
<a-descriptions-item label="双签完成">{{ data.contract?.signTime }}</a-descriptions-item>
<a-descriptions-item label="签署耗时">{{ data.contract?.signCostMs }} ms</a-descriptions-item>
</a-descriptions>
</a-card></a-col>
<a-col :span="8"><a-card title="⛓️ 链上存证">
<a-descriptions :column="1" size="small" bordered v-if="hasEvidence">
<a-descriptions-item label="交易哈希">
<a-tooltip :title="data.contract?.chainTxHash">
<span style="font-family: monospace; font-size: 12px">{{ data.contract?.chainTxHash?.slice(0, 18) }}…</span>
</a-tooltip>
</a-descriptions-item>
<a-descriptions-item label="区块高度">{{ data.contract?.chainBlockNo }}</a-descriptions-item>
<a-descriptions-item label="上链时间">{{ data.contract?.chainTime }}</a-descriptions-item>
<a-descriptions-item label="合约内容哈希 (SHA-256)">
<a-tooltip :title="data.contract?.contentHash">
<span style="font-family: monospace; font-size: 11px;">{{ data.contract?.contentHash?.slice(0, 20) }}…</span>
</a-tooltip>
</a-descriptions-item>
</a-descriptions>
<a-empty v-else description="该合约未上链" :image-style="{height: 60}" />
</a-card></a-col>
</a-row>
<!-- 配额 -->
<a-card title="💰 配额使用" style="margin-bottom: 16px" v-if="data.quota">
<a-progress :percent="data.quota.usagePercent" :status="quotaStatus" :stroke-color="quotaColor" />
<a-row :gutter="16" style="margin-top: 12px">
<a-col :span="6"><a-statistic title="总配额" :value="data.quota.total" /></a-col>
<a-col :span="6"><a-statistic title="已用" :value="data.quota.used" :value-style="{ color: '#1890ff' }" /></a-col>
<a-col :span="6"><a-statistic title="剩余" :value="data.quota.remaining" /></a-col>
<a-col :span="6"><a-statistic title="使用率" :value="data.quota.usagePercent" suffix="%" /></a-col>
</a-row>
</a-card>
<!-- 上游订单 -->
<a-card title="📋 上游订单" style="margin-bottom: 16px" v-if="data.order">
<a-descriptions :column="3" size="small" bordered>
<a-descriptions-item label="订单号">{{ data.order.orderCode }}</a-descriptions-item>
<a-descriptions-item label="状态">{{ data.order.status }}</a-descriptions-item>
<a-descriptions-item label="总额">¥ {{ data.order.totalAmount }}</a-descriptions-item>
<a-descriptions-item label="买方">{{ data.order.buyerName }}</a-descriptions-item>
<a-descriptions-item label="卖方">{{ data.order.sellerName }}</a-descriptions-item>
<a-descriptions-item label="支付">{{ data.order.paymentVoucher }}</a-descriptions-item>
<a-descriptions-item label="支付确认">{{ data.order.paymentConfirmTime }} / {{ data.order.paymentConfirmUserId }}</a-descriptions-item>
<a-descriptions-item label="生效期">{{ data.order.effectiveStart }} ~ {{ data.order.effectiveEnd }}</a-descriptions-item>
<a-descriptions-item label="合约哈希 (SHA-256)">{{ data.order.signedContractHash }}</a-descriptions-item>
<a-descriptions-item label="审核人">{{ data.order.auditUserId }} @ {{ data.order.auditTime }}</a-descriptions-item>
<a-descriptions-item label="审核意见" :span="3">{{ data.order.auditOpinion }}</a-descriptions-item>
</a-descriptions>
</a-card>
<!-- 下游交付任务 -->
<a-card title="🚀 下游交付任务" style="margin-bottom: 16px" v-if="data.deliveryTasks?.length">
<a-table :data-source="data.deliveryTasks" :columns="taskCols" row-key="id" size="small" :pagination="{ pageSize: 10 }">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'taskNo'">
<a @click="openDelivery(record.id)">{{ record.taskNo }}</a>
</template>
<template v-if="column.key === 'status'">
<a-tag :color="statusColor(record.status)">{{ record.status }}</a-tag>
</template>
<template v-if="column.key === 'policyResult'">
<a-tag :color="policyColor(record.policyResult)">{{ record.policyResult }}</a-tag>
</template>
</template>
</a-table>
</a-card>
<!-- 链上存证明细 -->
<a-card title="📜 存证明细" style="margin-bottom: 16px" v-if="data.chainEvidences && Object.keys(data.chainEvidences).length">
<a-collapse>
<a-collapse-panel v-for="(ev, k) in data.chainEvidences" :key="k" :header="`${ev.bizType || 'DATA_CONTRACT'} · ${ev.chainTime || ''} · ${ev.txHash?.slice(0, 14)}…`">
<a-descriptions :column="2" size="small" bordered>
<a-descriptions-item label="交易哈希">{{ ev.txHash }}</a-descriptions-item>
<a-descriptions-item label="区块高度">{{ ev.blockNo }}</a-descriptions-item>
<a-descriptions-item label="上链时间">{{ ev.chainTime }}</a-descriptions-item>
<a-descriptions-item label="摘要">{{ ev.summary }}</a-descriptions-item>
<a-descriptions-item label="内容哈希" :span="2">{{ ev.contentHash }}</a-descriptions-item>
</a-descriptions>
</a-collapse-panel>
</a-collapse>
</a-card>
<!-- 策略 + 条款 -->
<a-card title="📑 合约策略 / 条款" style="margin-bottom: 16px" v-if="data.contract?.policyContent || data.contract?.termsContent">
<a-tabs>
<a-tab-pane key="policy" tab="使用控制策略">
<pre style="white-space: pre-wrap">{{ formatPolicy(data.contract?.policyContent) }}</pre>
</a-tab-pane>
<a-tab-pane key="terms" tab="合约条款">
<pre style="white-space: pre-wrap">{{ data.contract?.termsContent }}</pre>
</a-tab-pane>
</a-tabs>
</a-card>
<!-- 数据留痕 -->
<a-card title="🪪 数据留痕" v-if="data.auditTrail">
<a-descriptions :column="4" size="small" bordered>
<a-descriptions-item label="创建人">{{ data.auditTrail.creator }}</a-descriptions-item>
<a-descriptions-item label="创建时间">{{ data.auditTrail.createTime }}</a-descriptions-item>
<a-descriptions-item label="最后修改人">{{ data.auditTrail.lastModifier }}</a-descriptions-item>
<a-descriptions-item label="最后修改时间">{{ data.auditTrail.lastModifyTime }}</a-descriptions-item>
</a-descriptions>
</a-card>
</a-spin>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { defHttp } from '@/api/request'
const route = useRoute()
const router = useRouter()
const loading = ref(true)
const data = ref<any>({})
const id = computed(() => route.params.id as string)
const fetchDetail = async () => {
loading.value = true
try {
const res = await defHttp.get({ url: `/api/ssw/tds/Contract/${id.value}/BusinessDetail` })
data.value = (res as any)?.data || (res as any) || {}
} catch (e) {
console.error('Contract BusinessDetail load failed:', e)
} finally {
loading.value = false
}
}
onMounted(fetchDetail)
const titleSubtitle = computed(() => {
const c = data.value.contract
if (!c) return ''
return `${c.providerOrgName || '?'} → ${c.consumerOrgName || '?'} · ${c.deliveryType || ''}`
})
const signCostMs = computed(() => data.value.contract?.signCostMs ?? null)
const hasEvidence = computed(() => data.value.contract?.chainTxHash)
const statusColor = (s: string) => {
const map: Record<string, string> = {
'02': 'green', '01': 'orange', '0301': 'blue', '0302': 'cyan',
'05': 'red', '06': 'volcano'
}
return map[s] || 'default'
}
const policyColor = (s: string) => {
const m: Record<string, string> = { ALLOW: 'green', DENY: 'red', LIMIT: 'orange', OBLIGATION: 'gold' }
return m[s] || 'default'
}
const quotaStatus = computed(() => {
const p = data.value.quota?.usagePercent || 0
if (p >= 90) return 'exception'
if (p >= 60) return 'warning'
return 'normal'
})
const quotaColor = computed(() => {
const p = data.value.quota?.usagePercent || 0
if (p >= 90) return '#f5222d'
if (p >= 60) return '#faad14'
return '#52c41a'
})
const taskCols = [
{ title: '任务编号', dataIndex: 'taskNo', key: 'taskNo' },
{ title: '产品', dataIndex: 'productName' },
{ title: '使用方', dataIndex: 'consumerOrgName' },
{ title: '状态', dataIndex: 'status', key: 'status' },
{ title: '运行态', dataIndex: 'runStatus' },
{ title: '策略', dataIndex: 'policyResult', key: 'policyResult' },
{ title: '记录数', dataIndex: 'recordCount' },
{ title: '体积', dataIndex: 'dataSize' },
{ title: '耗时ms', dataIndex: 'durationMs' },
{ title: '算法审核', dataIndex: 'auditOpinion' }
]
const formatPolicy = (s?: string) => {
try { return JSON.stringify(JSON.parse(s || '{}'), null, 2) } catch { return s || '' }
}
const openDelivery = (id: string) => {
router.push(`/tdc/delivery-detail/${id}`)
}
const openContract = (id: string) => {
router.push(`/tds/contract-detail/${id}`)
}
</script>
<style scoped>
.biz-detail-page { padding: 16px; }
pre { background: #fafafa; padding: 12px; border-radius: 4px; font-size: 12px; max-height: 240px; overflow: auto; }
</style>
@@ -0,0 +1,283 @@
<template>
<div class="biz-detail-page">
<a-page-header
v-if="data.task"
:title="`交付任务 · ${data.task.taskNo}`"
:sub-title="titleSubtitle"
@back="() => $router.back()"
>
<template #extra>
<a-tag v-if="data.task?.status" :color="statusColor(data.task.status)">{{ data.task.status }}</a-tag>
<a-tag v-if="data.task?.runStatus" :color="runColor(data.task.runStatus)">{{ data.task.runStatus }}</a-tag>
<a-tag v-if="data.task?.policyResult" :color="policyColor(data.task.policyResult)">{{ data.task.policyResult }}</a-tag>
</template>
</a-page-header>
<a-spin :spinning="loading" tip="加载中…">
<a-empty v-if="!loading && !data.task" description="未找到此任务(可能已删除)" />
<template v-else-if="data.task">
<!-- 概览 -->
<a-row :gutter="16" style="margin-bottom: 16px">
<a-col :span="6"><a-card title="📦 任务基本信息">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item label="任务编号">{{ data.task?.taskNo }}</a-descriptions-item>
<a-descriptions-item label="任务标识">{{ data.task?.taskCode }}</a-descriptions-item>
<a-descriptions-item label="交付方式">{{ data.task?.deliveryType }}</a-descriptions-item>
<a-descriptions-item label="触发方式">{{ data.task?.triggerType }}</a-descriptions-item>
<a-descriptions-item label="数据产品">{{ data.task?.productName }}</a-descriptions-item>
<a-descriptions-item label="使用方">{{ data.task?.consumerOrgName }}</a-descriptions-item>
<a-descriptions-item label="使用方连接器">{{ data.task?.consumerConnectorCode }}</a-descriptions-item>
</a-descriptions>
</a-card></a-col>
<a-col :span="6"><a-card title="📜 授权链路(上游合约)">
<a-descriptions :column="1" size="small" bordered v-if="data.contract">
<a-descriptions-item label="合约标识">
<a @click="openContract(data.contract.id)">{{ data.contract.contractCode }}</a>
</a-descriptions-item>
<a-descriptions-item label="使用方">{{ data.contract.consumerOrgName }}</a-descriptions-item>
<a-descriptions-item label="提供方">{{ data.contract.providerOrgName }}</a-descriptions-item>
<a-descriptions-item label="提供方连接器">{{ data.contract.providerConnectorId }}</a-descriptions-item>
<a-descriptions-item label="使用目的">{{ data.contract.purpose }}</a-descriptions-item>
<a-descriptions-item label="计费">{{ data.contract.priceMode }} {{ data.contract.amount || '' }}</a-descriptions-item>
<a-descriptions-item label="有效期">{{ data.contract.effectiveTime }} ~ {{ data.contract.expireTime }}</a-descriptions-item>
</a-descriptions>
<a-empty v-else description="无合约(可能是老数据)" :image-style="{height: 60}" />
</a-card></a-col>
<a-col :span="6"><a-card title="💰 配额使用">
<a-descriptions :column="1" size="small" bordered v-if="data.quota">
<a-descriptions-item label="总配额">{{ data.quota.total }}</a-descriptions-item>
<a-descriptions-item label="已用">{{ data.quota.used }}</a-descriptions-item>
<a-descriptions-item label="剩余">{{ data.quota.remaining }}</a-descriptions-item>
<a-descriptions-item label="使用率">
<a-progress :percent="data.quota.usagePercent" :status="quotaStatus" />
</a-descriptions-item>
</a-descriptions>
<a-empty v-else description="无配额信息" :image-style="{height: 60}" />
</a-card></a-col>
<a-col :span="6"><a-card title="🔍 审核链路">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item label="算法审核">{{ data.task?.auditStatus || 'NONE' }}</a-descriptions-item>
<a-descriptions-item label="审核人">{{ data.task?.auditUserId || '—' }}</a-descriptions-item>
<a-descriptions-item label="审核时间">{{ data.task?.auditTime || '—' }}</a-descriptions-item>
<a-descriptions-item label="审核意见">{{ data.task?.auditOpinion || '—' }}</a-descriptions-item>
</a-descriptions>
</a-card></a-col>
</a-row>
<!-- 执行链路 -->
<a-card title="🚀 执行链路" style="margin-bottom: 16px">
<a-steps :current="execStep" size="small" status="process" v-if="data.task">
<a-step title="策略判定" :description="data.task.policyResult || 'PENDING'" />
<a-step title="开始执行" :description="data.task.runStartTime || data.task.startTime" />
<a-step title="执行结果" :description="`记录 ${data.task.recordCount || 0} 条 / ${formatSize(data.task.dataSize)}`" />
<a-step title="回执上报" :description="data.task.reportStatus || 'PENDING'" />
<a-step title="销毁" :description="data.task.destroyStatus || 'PENDING'" />
</a-steps>
<a-row :gutter="16" style="margin-top: 16px">
<a-col :span="12">
<a-descriptions :column="2" size="small" bordered>
<a-descriptions-item label="开始时间">{{ data.task.startTime }}</a-descriptions-item>
<a-descriptions-item label="结束时间">{{ data.task.endTime }}</a-descriptions-item>
<a-descriptions-item label="运行时长">{{ data.task.durationMs }} ms</a-descriptions-item>
<a-descriptions-item label="重试次数">{{ data.task.retryCount }}</a-descriptions-item>
<a-descriptions-item label="API 调用次数">{{ data.task.callCount }}</a-descriptions-item>
<a-descriptions-item label="策略校验 ID">{{ data.task.policyCheckId }}</a-descriptions-item>
</a-descriptions>
</a-col>
<a-col :span="12">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item label="上传程序">{{ data.task.programFilename || '—' }} ({{ data.task.programUri || '—' }})</a-descriptions-item>
<a-descriptions-item label="结果地址">{{ data.task.resultUri || '—' }}</a-descriptions-item>
<a-descriptions-item label="结果文件">{{ data.task.resultFilename || '—' }}</a-descriptions-item>
<a-descriptions-item label="结果哈希">{{ data.task.resultHash || '—' }}</a-descriptions-item>
<a-descriptions-item label="结果过期时间">{{ data.task.resultExpireTime || '—' }}</a-descriptions-item>
</a-descriptions>
</a-col>
</a-row>
</a-card>
<!-- TEE 远程证明 -->
<a-card title="🛡️ TEE 远程证明(仅 TEE 沙盒)" style="margin-bottom: 16px" v-if="hasTee">
<a-row :gutter="16">
<a-col :span="12">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item v-for="(v, k) in data.attestation" :key="k" :label="k">
<span :class="k === 'kbsEngaged' || k === 'attestationGated' || k === 'resultSealed' ? (v.includes('true') ? 'ok' : 'bad') : ''">
{{ v }}
</span>
</a-descriptions-item>
</a-descriptions>
</a-col>
<a-col :span="12" v-if="data.tee">
<a-alert type="success" show-icon :message="`TEE 模式:${data.tee.mode || ''}`" v-if="data.tee.mode" />
<div v-for="(_, k) in data.tee" :key="k" style="margin: 4px 0">
<a-tag color="green" v-if="k !== 'mode'">✔ {{ k }}</a-tag>
</div>
</a-col>
</a-row>
</a-card>
<!-- 销毁存证 -->
<a-card title="🔥 销毁存证" style="margin-bottom: 16px" v-if="data.destroyEvidences?.length">
<a-list :data-source="data.destroyEvidences" item-layout="horizontal" size="small">
<template #renderItem="{ item }">
<a-list-item>
<a-list-item-meta :title="`销毁时间:${item.destroyTime || item.creatorTime || ''}`" :description="`操作人:${item.operator || item.creatorUserId || '—'} · 方式:${item.destroyMethod || '—'} · 原因:${item.reason || '—'}`" />
</a-list-item>
</template>
</a-list>
</a-card>
<!-- 调用日志 -->
<a-card title="📞 API 调用留痕(近 10 条)" style="margin-bottom: 16px" v-if="data.callLogs?.length">
<a-table :data-source="data.callLogs" :columns="callCols" row-key="id" size="small" :pagination="false" />
</a-card>
<!-- 上游订单 -->
<a-card title="📋 上游订单" style="margin-bottom: 16px" v-if="data.order">
<a-descriptions :column="3" size="small" bordered>
<a-descriptions-item label="订单号">{{ data.order.orderCode }}</a-descriptions-item>
<a-descriptions-item label="状态">{{ data.order.status }}</a-descriptions-item>
<a-descriptions-item label="定价方式">{{ data.order.priceType }}</a-descriptions-item>
<a-descriptions-item label="单价">{{ data.order.priceAmount }}</a-descriptions-item>
<a-descriptions-item label="数量">{{ data.order.quantity }}</a-descriptions-item>
<a-descriptions-item label="总额">{{ data.order.totalAmount }}</a-descriptions-item>
<a-descriptions-item label="买方">{{ data.order.buyerName }}</a-descriptions-item>
<a-descriptions-item label="卖方">{{ data.order.sellerName }}</a-descriptions-item>
<a-descriptions-item label="支付凭证">{{ data.order.paymentVoucher || '—' }}</a-descriptions-item>
<a-descriptions-item label="确认付款时间">{{ data.order.paymentConfirmTime || '—' }}</a-descriptions-item>
<a-descriptions-item label="合约哈希 (SHA-256)">{{ data.order.signedContractHash || '—' }}</a-descriptions-item>
<a-descriptions-item label="生效期">{{ data.order.effectiveStart }} ~ {{ data.order.effectiveEnd }}</a-descriptions-item>
<a-descriptions-item label="A 方签">{{ data.order.signPartyATime }} / {{ data.order.signPartyAUserId }}</a-descriptions-item>
<a-descriptions-item label="B 方签">{{ data.order.signPartyBTime }} / {{ data.order.signPartyBUserId }}</a-descriptions-item>
<a-descriptions-item label="审核人">{{ data.order.auditUserId }} @ {{ data.order.auditTime }}</a-descriptions-item>
<a-descriptions-item label="审核意见" :span="3">{{ data.order.auditOpinion || '—' }}</a-descriptions-item>
</a-descriptions>
</a-card>
<!-- 政策内容(合约) -->
<a-card title="📑 合约策略 + 条款" style="margin-bottom: 16px" v-if="data.contract?.policyContent || data.contract?.termsContent">
<a-tabs>
<a-tab-pane key="policy" tab="使用控制策略">
<pre style="white-space: pre-wrap">{{ data.contract?.policyContent }}</pre>
</a-tab-pane>
<a-tab-pane key="terms" tab="合约条款">
<pre style="white-space: pre-wrap">{{ data.contract?.termsContent }}</pre>
</a-tab-pane>
</a-tabs>
</a-card>
<!-- 基础审计 -->
<a-card title="🪪 数据留痕(创建/修改人)" v-if="data.auditTrail">
<a-descriptions :column="4" size="small" bordered>
<a-descriptions-item label="创建人">{{ data.auditTrail.creator }}</a-descriptions-item>
<a-descriptions-item label="创建时间">{{ data.auditTrail.createTime }}</a-descriptions-item>
<a-descriptions-item label="最后修改人">{{ data.auditTrail.lastModifier }}</a-descriptions-item>
<a-descriptions-item label="最后修改时间">{{ data.auditTrail.lastModifyTime }}</a-descriptions-item>
<a-descriptions-item label="所属租户" :span="4">{{ data.auditTrail.tenantId || '—' }}</a-descriptions-item>
</a-descriptions>
</a-card>
</template>
</a-spin>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { defHttp } from '@/api/request'
const route = useRoute()
const router = useRouter()
const loading = ref(true)
const data = ref<any>({})
const id = computed(() => route.params.id as string)
const fetchDetail = async () => {
loading.value = true
try {
const res = await defHttp.get({ url: `/api/ssw/tdc/DeliveryTask/${id.value}/BusinessDetail` })
data.value = (res as any)?.data || (res as any) || {}
} catch (e) {
console.error('BusinessDetail load failed:', e)
} finally {
loading.value = false
}
}
onMounted(fetchDetail)
const titleSubtitle = computed(() => {
const t = data.value.task
if (!t) return ''
return `${t.productName || ''} · ${t.deliveryType || ''} · ${t.runStatus || ''}`
})
const hasTee = computed(() => {
const log = data.value.task?.runLog
return log && (log.includes('kata-qemu-snp') || log.includes('attestationGated'))
})
const execStep = computed(() => {
const t = data.value.task
if (!t) return 0
if (t.policyResult === 'DENY') return 0
if (!t.startTime && !t.runStartTime) return 1
if (!t.endTime && !t.runEndTime) return 2
if (t.reportStatus !== 'SUCCESS') return 3
if (t.destroyStatus !== 'DONE') return 4
return 4
})
const statusColor = (s: string) => {
const map: Record<string, string> = {
SUCCESS: 'green', FAIL: 'red', DENIED: 'red', CANCELLED: 'orange',
PENDING: 'blue', RUNNING: 'blue', PENDING_DELIVER: 'blue'
}
return map[s] || 'default'
}
const runColor = (s: string) => statusColor(s)
const policyColor = (s: string) => {
const map: Record<string, string> = { ALLOW: 'green', DENY: 'red', LIMIT: 'orange', OBLIGATION: 'gold' }
return map[s] || 'default'
}
const quotaStatus = computed(() => {
const p = data.value.quota?.usagePercent || 0
if (p >= 90) return 'exception'
if (p >= 60) return 'warning'
return 'normal'
})
const callCols = [
{ title: '调用时间', dataIndex: 'callTime', width: 180 },
{ title: '调用方 App', dataIndex: 'appId' },
{ title: '订单号 (Header)', dataIndex: 'orderCode' },
{ title: '客户端 IP', dataIndex: 'ip' },
{ title: '状态码', dataIndex: 'httpStatus' },
{ title: '拒绝原因', dataIndex: 'denyReason' }
]
const formatSize = (n?: number) => {
if (!n) return '0 B'
if (n > 1024 * 1024) return (n / 1024 / 1024).toFixed(2) + ' MB'
if (n > 1024) return (n / 1024).toFixed(2) + ' KB'
return n + ' B'
}
const openContract = (id: string) => {
router.push(`/tds/contract-detail/${id}`)
}
</script>
<style scoped>
.biz-detail-page { padding: 16px; }
.ok { color: #52c41a; font-weight: 600; }
.bad { color: #f5222d; font-weight: 600; }
pre { background: #fafafa; padding: 12px; border-radius: 4px; font-size: 12px; max-height: 240px; overflow: auto; }
</style>
+7
View File
@@ -155,6 +155,13 @@ const routes: RouteRecordRaw[] = [
name: 'tdc-tee-security',
component: () => import('@/views/ssw/views/tdc/TeeSecurityView.vue'),
meta: { auth: true, title: 'TEE 安全管理面', subsystem: 'tdc' }
},
// ---- 业务全景:记录级详情(不走菜单,按 ID 直进) ----
{
path: '/tdc/delivery-detail/:id(\\w+)',
name: 'tdc-delivery-detail',
component: () => import('@/views/ssw/views/_biz/DeliveryDetailView.vue'),
meta: { auth: true, title: '交付任务业务全景', subsystem: 'tdc' }
}
]
+13
View File
@@ -232,6 +232,19 @@ const routes: RouteRecordRaw[] = [
component: () => import('@/views/ssw/views/tds/LicenseView.vue'),
meta: { auth: true, title: 'License/续费', subsystem: 'tds' }
},
// ---- 业务全景:记录级详情(不走菜单,按 ID 直进) ----
{
path: '/tds/contract-detail/:id(\\w+)',
name: 'tds-contract-detail',
component: () => import('@/views/ssw/views/_biz/ContractDetailView.vue'),
meta: { auth: true, title: '数字合约业务全景', subsystem: 'tds' }
},
{
path: '/tds/billing-detail/:id(\\w+)',
name: 'tds-billing-detail',
component: () => import('@/views/ssw/views/_biz/BillingDetailView.vue'),
meta: { auth: true, title: '结算凭证业务全景', subsystem: 'tds' }
}
]
export default routes