吴羡
2026-10-24 3d397976d08f0359b8cfeb4e4f22403ae5d0c04f
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java
@@ -231,8 +231,6 @@
        info.setViewStatus(false);
        info.setJumpPath(MenuJumpPathConstants.REPORT_PREPARATION);
        informationNotificationService.addInformationNotification(info);
        String primaryReportUrl = getPrimaryReportUrl(insReport);
        // 判断是否是原材料  需要替换****成供应商
        IfsInventoryQuantity one = ifsInventoryQuantityMapper.selectOne(new LambdaQueryWrapper<IfsInventoryQuantity>()
                .eq(IfsInventoryQuantity::getId, order.getIfsInventoryId()));
@@ -253,9 +251,7 @@
        }};
        writeMarksToReportFiles(insReport, writeMarks);
        // 修改临时pdf
        String tempUrlPdf = wordToPdfTemp(primaryReportUrl.replace("/word", wordUrl));
        insReport.setTempUrlPdf("/word/" + tempUrlPdf);
        refreshTemporaryPreviews(insReport);
        insReportMapper.updateById(insReport);
@@ -383,16 +379,13 @@
        info.setViewStatus(false);
        info.setJumpPath(MenuJumpPathConstants.REPORT_PREPARATION);
        informationNotificationService.addInformationNotification(info);
        String primaryReportUrl = getPrimaryReportUrl(insReport);
        Map<String, Object> examineMarks = new HashMap<String, Object>() {{
            put("examineUrl", ReportSignaturePictureUtils.create(imgUrl, signatureUrl));
            put("examineDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create());
        }};
        writeMarksToReportFiles(insReport, examineMarks);
        // 修改临时pdf
        String tempUrlPdf = wordToPdfTemp(primaryReportUrl.replace("/word", wordUrl));
        insReport.setTempUrlPdf("/word/" + tempUrlPdf);
        refreshTemporaryPreviews(insReport);
        // 发送企业微信通知(通知批准人审批)
        threadPoolTaskExecutor.execute(() -> {
@@ -728,6 +721,30 @@
                .collect(Collectors.toList());
    }
    private void refreshTemporaryPreviews(InsReport report) {
        String primaryPdf = wordToPdfTemp(getPrimaryReportUrl(report).replace("/word", wordUrl));
        if (StringUtils.isBlank(primaryPdf)) {
            throw new ErrorException("检测报告预览生成失败");
        }
        report.setTempUrlPdf("/word/" + primaryPdf);
        if (StringUtils.isNotBlank(report.getInspectionUrl())) {
            String inspectionPdf = wordToPdfTemp(report.getInspectionUrl().replace("/word", wordUrl));
            if (StringUtils.isBlank(inspectionPdf)) {
                throw new ErrorException("检验报告预览生成失败");
            }
            report.setInspectionTempUrlPdf("/word/" + inspectionPdf);
        }
    }
    @Override
    public String prepareEditedReportPreview(String absoluteDocxPath) {
        String pdfName = wordToPdfTemp(absoluteDocxPath);
        if (StringUtils.isBlank(pdfName)) {
            throw new ErrorException("报告预览生成失败");
        }
        return "/word/" + pdfName;
    }
    private void writeMarksToReportFiles(InsReport report, Map<String, Object> marks) {
        for (String reportUrl : getApprovalReportUrls(report)) {
            wordInsertUrl(marks, reportUrl.replace("/word", wordUrl));
@@ -804,7 +821,12 @@
            throw new ErrorException("报告文件不存在,请联系管理员");
        }
        try {
            String filename = file.getFileName().toString();
            // 物理文件可能是 reviewed/edited UUID;对用户始终使用业务报告编号。
            String reportNumber = StringUtils.isBlank(report.getCode()) ? "报告" : report.getCode();
            reportNumber = reportNumber.replaceAll("[\\\\/:*?\"<>|\\p{Cntrl}]", "-").trim();
            String suffix = StringUtils.isNotBlank(report.getInspectionUrl())
                    ? (Objects.equals(reportType, INSPECTION_REPORT) ? "-检验报告" : "-检测报告") : "";
            String filename = reportNumber + suffix + ".docx";
            String encodedName = URLEncoder.encode(filename, "UTF-8").replace("+", "%20");
            response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
            response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedName);