测试处方上传

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

@@ -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) {
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) {
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,28 +196,40 @@ func (r *Runner) executeStep(step, anchorDate string, opts StepRunOptions) (*Ste
var callbacks []xkapi.CallbackItem
success, failed, skipped := 0, 0, 0
for _, item := range items {
var tr *itemTraceCtx
if opts.CollectTrace {
tr = newItemTraceCtx(item)
if item.BizKey == "" && item.Payload != nil {
tr.out.BizKey = hy.BizKey(step, anchorDate, item.Payload)
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(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)
if tr != nil {
tr.finish(cb)
result.Items = append(result.Items, *tr.out)
}
switch cb.PushStatus {
case "success":
success++
case "skipped":
skipped++
default:
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 {

View File

@@ -11,10 +11,14 @@ import (
// UploadTestResult Web 测试上传结果(含本次 FileAuth.java token 分步信息)。
type UploadTestResult struct {
FileID string
Filename string
Scope string
Parts fileauth.UploadTokenParts
FileID string
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

@@ -47,9 +47,11 @@ func New(baseURL, token, callbackPath string) *Client {
// PullResponse 单次拉取响应。
type PullResponse struct {
AnchorDate string `json:"anchor_date"`
BatchID int `json:"batch_id"`
Items []PullItem `json:"items"`
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