fix(inspection): allow PDF downloads before result archiving
This commit is contained in:
parent
066b496ca4
commit
83cb972881
@ -54,8 +54,10 @@ public class LabInspectionController {
|
||||
if(binary&&!security.hasPermission("lab:data:download"))throw new ResponseStatusException(HttpStatus.FORBIDDEN,"没有文件下载权限");
|
||||
if(binary&&job!=null) {
|
||||
String name=path.substring(path.lastIndexOf('/')+1);
|
||||
if(Set.of("report_signed_chromatogram.pdf","report.pdf","platform-result.stl").contains(name)) {
|
||||
if(!"ARCHIVED".equals(job.get("status"))||job.get("delivery_id")==null||job.get("awaiting_revision")!=null)
|
||||
boolean pdf=Set.of("report_signed_chromatogram.pdf","report.pdf").contains(name);
|
||||
boolean archived="ARCHIVED".equals(job.get("status"))&&job.get("delivery_id")!=null&&job.get("awaiting_revision")==null;
|
||||
if(name.equals("platform-result.stl")||pdf&&archived) {
|
||||
if(!archived)
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT,"当前成果尚未完成归档,请等待归档完成或重试成果归档后下载");
|
||||
long tenant=TenantContextHolder.getRequiredTenantId();
|
||||
var delivery=jdbc.queryForMap("SELECT stl_id,pdf_id FROM lab_dimension_delivery WHERE id=? AND tenant_id=? AND deleted=0",job.get("delivery_id"),tenant);
|
||||
@ -63,6 +65,13 @@ public class LabInspectionController {
|
||||
response.setContentType(name.endsWith(".pdf")?"application/pdf":"application/octet-stream");response.setHeader("Cache-Control","private, no-store");response.setHeader("X-Content-Type-Options","nosniff");
|
||||
response.setHeader("Content-Disposition","attachment; filename*=UTF-8''"+URLEncoder.encode(file.get("name").toString(),StandardCharsets.UTF_8));Files.copy((Path)file.get("path"),response.getOutputStream());return null;
|
||||
}
|
||||
if(pdf) {
|
||||
String statePath="/api/tasks/"+engine;
|
||||
Object value=gateway.json(statePath,"GET",gateway.forward(statePath,"GET",new byte[0]));
|
||||
if(!(value instanceof Map<?,?> state)||Boolean.FALSE.equals(state.get("report_ready"))
|
||||
||!Set.of("done","blocked").contains(Objects.toString(state.get("status"),"")))
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT,"报告尚未生成完成,请等待报告生成后下载");
|
||||
}
|
||||
}
|
||||
byte[] body=new byte[0];
|
||||
if(method.equals("POST")) {
|
||||
|
||||
@ -1833,7 +1833,7 @@ async function evaluateDocument(op: FeatureOperation) {
|
||||
async function report() {
|
||||
return runOperation(async (op) => {
|
||||
await op.post('feature-report', { revision: doc.value.revision })
|
||||
ElMessage.success('报告已生成,归档完成后可在成果页下载 PDF')
|
||||
ElMessage.success('报告已生成,可在成果页直接下载 PDF')
|
||||
emit('reported')
|
||||
})
|
||||
}
|
||||
|
||||
@ -458,17 +458,12 @@
|
||||
<el-button type="primary" :loading="busy" @click="previewReport">预览报告</el-button
|
||||
><el-button
|
||||
:loading="busy"
|
||||
:disabled="!archivedReportReady"
|
||||
:disabled="!hasReport"
|
||||
@click="download('report_signed_chromatogram.pdf')"
|
||||
>下载 PDF</el-button
|
||||
><el-button :loading="busy" @click="download('result.zip')">下载结果包</el-button
|
||||
><el-button :loading="busy" @click="download('worker.log')">处理日志</el-button></div
|
||||
><el-alert
|
||||
v-if="hasReport && !archivedReportReady"
|
||||
title="当前报告尚未完成归档,PDF 下载暂不可用;归档失败时可在任务中重试成果归档。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/><el-empty
|
||||
><el-empty
|
||||
v-if="!hasReport"
|
||||
:description="
|
||||
processing ? '正在测量与生成报告,请稍候' : '报告尚未生成,可在计划核对后点击生成报告'
|
||||
@ -560,12 +555,12 @@
|
||||
><iframe
|
||||
v-else-if="reportPdfUrl"
|
||||
:src="reportPdfUrl"
|
||||
title="归档PDF报告预览"
|
||||
title="PDF报告预览"
|
||||
class="inspect-report-frame"
|
||||
></iframe
|
||||
><template #footer
|
||||
><el-button
|
||||
:disabled="!archivedReportReady"
|
||||
:disabled="!hasReport"
|
||||
@click="download('report_signed_chromatogram.pdf')"
|
||||
>下载 PDF</el-button
|
||||
></template
|
||||
@ -744,16 +739,6 @@ const measuredCount = computed(
|
||||
hasReport = computed(
|
||||
() => current.value.report_ready !== false && ['done', 'blocked'].includes(current.value.status)
|
||||
),
|
||||
archivedReportReady = computed(() => {
|
||||
const job = current.value.platform_job
|
||||
return (
|
||||
!!job?.delivery_id &&
|
||||
job.status === 'ARCHIVED' &&
|
||||
!job.awaiting_revision &&
|
||||
String(job.engine_revision) ===
|
||||
String(current.value.report_revision || current.value.revision || '')
|
||||
)
|
||||
}),
|
||||
statusType = computed(() =>
|
||||
ready.value
|
||||
? pendingInspectionCount(current.value) || current.value.measurement_complete === false
|
||||
|
||||
26
deploy/windows11/RELEASE-20261124-pdf-download.md
Normal file
26
deploy/windows11/RELEASE-20261124-pdf-download.md
Normal file
@ -0,0 +1,26 @@
|
||||
# PDF 报告下载不再依赖成果归档
|
||||
|
||||
报告生成后,结果页与报告预览窗口可以直接下载 PDF,无需先生成处理后 STL 或完成成套归档。
|
||||
|
||||
未归档报告由平台检查当前报告已生成后,从计算服务读取 PDF;已归档报告继续读取保存的归档文件。任务访问、租户和文件下载权限校验保留,尚未生成完成的报告不允许下载。成果归档流程与 STL 归档规则保持原有行为。
|
||||
|
||||
## 验证
|
||||
|
||||
- 后端模块及依赖编译通过;8 项下载验证通过,涵盖未归档报告、归档待处理、报告未就绪、计算中、已归档报告及访问权限。
|
||||
- 前端 standalone 完整构建通过,两处 Vue 组件编译通过。
|
||||
- 发布更新脚本语法检查通过,已核对拉取、前后端构建、增量升级、空闲检查、停止/启动和健康检查路径。
|
||||
- 临时测试代码与验证产物已清理;未运行现场设备。
|
||||
|
||||
## 更新
|
||||
|
||||
没有新增依赖、私有配置、菜单、字典或表结构;无需专项迁移。通过原有 `update.ps1` 构建前后端并执行标准增量升级即可。保留现场设备地址、凭据、QUIC、证书及业务文件,不同步开发数据。
|
||||
|
||||
正式环境 AI 收到更新通知后,先核对仓库本地改动和已有未推送提交,不得强制重置或覆盖。确认现场空闲后按原有受控流程执行:
|
||||
|
||||
```powershell
|
||||
pwsh -NoProfile -File deploy/windows11/update.ps1 -CheckOnly
|
||||
pwsh -NoProfile -File deploy/windows11/update.ps1 -ConfirmStopped
|
||||
pwsh -NoProfile -File deploy/windows11/manage.ps1 -Action Status
|
||||
```
|
||||
|
||||
更新后核对 `.local/standalone/deployment.json` 的提交号与 JAR 校验值,并检查前端 5180、后端 48090 和代理健康。打开已有报告已生成、尚未归档的检测记录,确认结果页和预览窗口均可下载有效 PDF;不需要重新扫描或运动设备。
|
||||
Loading…
Reference in New Issue
Block a user