测试处方上传

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 | | `/config` | 查看云端 / 本地 / 生效互医配置;对比云端预生成 token 与 Runner 本地 FileAuth token |
| `/upload` | 测试 PDF 上传(失败时展示完整 upstream 错误Toast 提示 | | `/upload` | 测试 PDF 上传(`httpStatus`/`rawBody` 政务云文件服务响应 |
| `/supervise-step` | 处方/核销单步联调(含 `push.response_body` 业务上报响应) |
| `/runs` | 同步流水;失败记录可「整条重试」 | | `/runs` | 同步流水;失败记录可「整条重试」 |
改 xk-api `.env` 后:`php artisan config:clear` + 重启 PHP/Laravel-S再在 transit `/config` 点重新拉取。 改 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 { if res != nil {
out["filename"] = res.Filename out["filename"] = res.Filename
out["scope"] = res.Scope 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 != "" { if fileID != "" {
out["fileId"] = 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)); lines.push('\n[推送头 push_headers]\n' + JSON.stringify(it.push_headers, null, 2));
} }
if (it.push) { if (it.push) {
lines.push('\n[政务云上报]\n' + JSON.stringify(it.push, null, 2)); 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) { if (it.callback) {
lines.push('\n[云端回调 CallbackItem]\n' + JSON.stringify(it.callback, null, 2)); 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++ 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 { if result != nil {
result.PullSummary = PullSummary{ result.PullSummary = PullSummary{
Total: len(pull.Items), Total: len(pull.Items),
@@ -192,28 +196,40 @@ func (r *Runner) executeStep(step, anchorDate string, opts StepRunOptions) (*Ste
var callbacks []xkapi.CallbackItem var callbacks []xkapi.CallbackItem
success, failed, skipped := 0, 0, 0 success, failed, skipped := 0, 0, 0
for _, item := range items { appendProcessed := func(processStep, processMethod string, batchItems []xkapi.PullItem) {
var tr *itemTraceCtx for _, item := range batchItems {
if opts.CollectTrace { var tr *itemTraceCtx
tr = newItemTraceCtx(item) if opts.CollectTrace {
if item.BizKey == "" && item.Payload != nil { tr = newItemTraceCtx(item)
tr.out.BizKey = hy.BizKey(step, anchorDate, item.Payload) if item.BizKey == "" && item.Payload != nil {
tr.out.BizKey = hy.BizKey(processStep, anchorDate, item.Payload)
}
}
cb := r.processItem(processStep, anchorDate, processMethod, batchID, item, tr)
callbacks = append(callbacks, cb)
if tr != nil {
tr.finish(cb)
result.Items = append(result.Items, *tr.out)
}
switch cb.PushStatus {
case "success":
success++
case "skipped":
skipped++
default:
failed++
} }
} }
cb := r.processItem(step, anchorDate, method, batchID, item, tr) }
callbacks = append(callbacks, cb) appendProcessed(step, method, items)
if tr != nil {
tr.finish(cb) if step == "verification" && len(pull.FollowUpRecipeItems) > 0 {
result.Items = append(result.Items, *tr.out) followUpMethod, ok := hy.StepMethods["recipe"]
} if !ok {
switch cb.PushStatus { return result, fmt.Errorf("unknown follow-up step: recipe")
case "success":
success++
case "skipped":
skipped++
default:
failed++
} }
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 { if err := r.xk.BatchCallback(batchID, callbacks); err != nil {

View File

@@ -11,10 +11,14 @@ import (
// UploadTestResult Web 测试上传结果(含本次 FileAuth.java token 分步信息)。 // UploadTestResult Web 测试上传结果(含本次 FileAuth.java token 分步信息)。
type UploadTestResult struct { type UploadTestResult struct {
FileID string FileID string
Filename string Filename string
Scope string Scope string
Parts fileauth.UploadTokenParts Parts fileauth.UploadTokenParts
HTTPStatus int
RawBody string
Success bool
Message string
} }
// uploadTokenPartsForUpload 生成 FileAuth.java upload profile tokenscope=仅 bucket // uploadTokenPartsForUpload 生成 FileAuth.java upload profile tokenscope=仅 bucket
@@ -53,11 +57,17 @@ func (r *Runner) UploadTestPDF(pdf []byte, filename string) (*UploadTestResult,
Scope: bucket, Scope: bucket,
Parts: parts, 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 { if err != nil {
return res, err return res, err
} }
res.FileID = fileID
return res, nil return res, nil
} }

View File

@@ -47,9 +47,11 @@ func New(baseURL, token, callbackPath string) *Client {
// PullResponse 单次拉取响应。 // PullResponse 单次拉取响应。
type PullResponse struct { type PullResponse struct {
AnchorDate string `json:"anchor_date"` AnchorDate string `json:"anchor_date"`
BatchID int `json:"batch_id"` BatchID int `json:"batch_id"`
Items []PullItem `json:"items"` Items []PullItem `json:"items"`
FollowUpRecipeItems []PullItem `json:"follow_up_recipe_items"`
PrescriptionIDs []int `json:"prescription_ids"`
} }
// PullItem 单条组包记录(含云端 record_id // PullItem 单条组包记录(含云端 record_id