测试处方上传

This commit is contained in:
李琦
2026-07-15 08:47:41 +08:00
parent bf816536be
commit 60102aead6
6 changed files with 77 additions and 31 deletions

View File

@@ -219,7 +219,8 @@ xk-hy-transit-go\log\transit\
| 路径 | 说明 |
|------|------|
| `/config` | 查看云端 / 本地 / 生效互医配置;对比云端预生成 token 与 Runner 本地 FileAuth token |
| `/upload` | 测试 PDF 上传(失败时展示完整 upstream 错误Toast 提示 |
| `/upload` | 测试 PDF 上传(`httpStatus`/`rawBody` 政务云文件服务响应 |
| `/supervise-step` | 处方/核销单步联调(含 `push.response_body` 业务上报响应) |
| `/runs` | 同步流水;失败记录可「整条重试」 |
改 xk-api `.env` 后:`php artisan config:clear` + 重启 PHP/Laravel-S再在 transit `/config` 点重新拉取。

View File

@@ -42,6 +42,16 @@ func uploadTestPayload(res *syncer.UploadTestResult, uploadURL string, ok bool,
if res != nil {
out["filename"] = res.Filename
out["scope"] = res.Scope
if res.HTTPStatus != 0 {
out["httpStatus"] = res.HTTPStatus
}
if res.RawBody != "" {
out["rawBody"] = res.RawBody
}
if res.Message != "" {
out["message"] = res.Message
}
out["success"] = res.Success
}
if fileID != "" {
out["fileId"] = fileID

View File

@@ -87,7 +87,14 @@ function renderStepResult(data) {
lines.push('\n[推送头 push_headers]\n' + JSON.stringify(it.push_headers, null, 2));
}
if (it.push) {
const hasResp = it.push.response_body || it.push.http_code || it.push.msg;
if (hasResp) {
lines.push('\n[政务云上报]\n' + JSON.stringify(it.push, null, 2));
} else if (it.validation_errors && it.validation_errors.length) {
lines.push('\n[政务云上报] 未执行(组包校验失败,记录已 skipped');
} else {
lines.push('\n[政务云上报] 未执行(未到达 PostForward请检查拉取条数或前置步骤');
}
}
if (it.callback) {
lines.push('\n[云端回调 CallbackItem]\n' + JSON.stringify(it.callback, null, 2));

View File

@@ -174,7 +174,11 @@ func (r *Runner) executeStep(step, anchorDate string, opts StepRunOptions) (*Ste
validationCount++
}
}
applog.Pullf("pull done step=%s batch_id=%d items=%d validation_failed=%d", step, batchID, len(pull.Items), validationCount)
followUpCount := 0
if step == "verification" {
followUpCount = len(pull.FollowUpRecipeItems)
}
applog.Pullf("pull done step=%s batch_id=%d items=%d validation_failed=%d follow_up_recipe=%d", step, batchID, len(pull.Items), validationCount, followUpCount)
if result != nil {
result.PullSummary = PullSummary{
Total: len(pull.Items),
@@ -192,15 +196,16 @@ func (r *Runner) executeStep(step, anchorDate string, opts StepRunOptions) (*Ste
var callbacks []xkapi.CallbackItem
success, failed, skipped := 0, 0, 0
for _, item := range items {
appendProcessed := func(processStep, processMethod string, batchItems []xkapi.PullItem) {
for _, item := range batchItems {
var tr *itemTraceCtx
if opts.CollectTrace {
tr = newItemTraceCtx(item)
if item.BizKey == "" && item.Payload != nil {
tr.out.BizKey = hy.BizKey(step, anchorDate, item.Payload)
tr.out.BizKey = hy.BizKey(processStep, anchorDate, item.Payload)
}
}
cb := r.processItem(step, anchorDate, method, batchID, item, tr)
cb := r.processItem(processStep, anchorDate, processMethod, batchID, item, tr)
callbacks = append(callbacks, cb)
if tr != nil {
tr.finish(cb)
@@ -215,6 +220,17 @@ func (r *Runner) executeStep(step, anchorDate string, opts StepRunOptions) (*Ste
failed++
}
}
}
appendProcessed(step, method, items)
if step == "verification" && len(pull.FollowUpRecipeItems) > 0 {
followUpMethod, ok := hy.StepMethods["recipe"]
if !ok {
return result, fmt.Errorf("unknown follow-up step: recipe")
}
applog.Pullf("verification follow-up recipe items=%d", len(pull.FollowUpRecipeItems))
appendProcessed("recipe", followUpMethod, pull.FollowUpRecipeItems)
}
if err := r.xk.BatchCallback(batchID, callbacks); err != nil {
applog.Appf("batch callback failed step=%s batch_id=%d err=%v", step, batchID, err)

View File

@@ -15,6 +15,10 @@ type UploadTestResult struct {
Filename string
Scope string
Parts fileauth.UploadTokenParts
HTTPStatus int
RawBody string
Success bool
Message string
}
// uploadTokenPartsForUpload 生成 FileAuth.java upload profile tokenscope=仅 bucket
@@ -53,11 +57,17 @@ func (r *Runner) UploadTestPDF(pdf []byte, filename string) (*UploadTestResult,
Scope: bucket,
Parts: parts,
}
fileID, err := hyfile.UploadPDF(pdf, filename, url, parts.UploadToken, r.cfg.ForwardSharedSecret)
upRes, err := hyfile.UploadPDFDetail(pdf, filename, url, parts.UploadToken, r.cfg.ForwardSharedSecret)
if upRes != nil {
res.HTTPStatus = upRes.HTTPStatus
res.RawBody = upRes.RawBody
res.Success = upRes.Success
res.Message = upRes.Message
res.FileID = upRes.FileID
}
if err != nil {
return res, err
}
res.FileID = fileID
return res, nil
}

View File

@@ -50,6 +50,8 @@ type PullResponse struct {
AnchorDate string `json:"anchor_date"`
BatchID int `json:"batch_id"`
Items []PullItem `json:"items"`
FollowUpRecipeItems []PullItem `json:"follow_up_recipe_items"`
PrescriptionIDs []int `json:"prescription_ids"`
}
// PullItem 单条组包记录(含云端 record_id