| | |
| | | import com.ruoyi.inspect.service.InsOrderService; |
| | | import com.ruoyi.inspect.service.InsReportService; |
| | | import com.ruoyi.inspect.service.RawMaterialOrderService; |
| | | import com.ruoyi.inspect.service.SealUsageLedgerService; |
| | | import com.ruoyi.inspect.util.PreserveReportPicturePlaceholderHandler; |
| | | import com.ruoyi.inspect.util.ReportSealLayoutUtil; |
| | | import com.ruoyi.inspect.util.ReportSignaturePictureUtils; |
| | |
| | | private UserMapper userMapper; |
| | | @Resource |
| | | private InsReportMapper insReportMapper; |
| | | @Resource |
| | | private SealUsageLedgerService sealUsageLedgerService; |
| | | @Resource |
| | | private InsOrderStateMapper insOrderStateMapper; |
| | | @Resource |
| | |
| | | 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())); |
| | |
| | | }}; |
| | | writeMarksToReportFiles(insReport, writeMarks); |
| | | |
| | | // 修改临时pdf |
| | | String tempUrlPdf = wordToPdfTemp(primaryReportUrl.replace("/word", wordUrl)); |
| | | insReport.setTempUrlPdf("/word/" + tempUrlPdf); |
| | | refreshTemporaryPreviews(insReport); |
| | | |
| | | insReportMapper.updateById(insReport); |
| | | |
| | |
| | | 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(() -> { |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int ratifyReport(Integer id, Integer isRatify, String ratifyTell, String sealIds, |
| | | Integer maSealId, Integer reportSealId, Integer seamSealId) { |
| | | InsReport insReport = insReportMapper.selectById(id); |
| | | if (id == null || (isRatify == null || (isRatify != 0 && isRatify != 1))) { |
| | | throw new ErrorException("批准参数不正确"); |
| | | } |
| | | InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getId, id) |
| | | .last("FOR UPDATE")); |
| | | if (insReport == null) { |
| | | throw new ErrorException("报告不存在"); |
| | | } |
| | | if (Objects.equals(insReport.getIsRatify(), 1)) { |
| | | throw new ErrorException("报告已批准,请勿重复操作"); |
| | | } |
| | | if (Objects.equals(insReport.getExamineUserId(), SecurityUtils.getUserId().intValue())) { |
| | | throw new ErrorException("审核人和批准人不能为同一人,请重新选择批准人"); |
| | | } |
| | |
| | | }); |
| | | } |
| | | |
| | | return insReportMapper.updateById(insReport); |
| | | int affected = insReportMapper.updateById(insReport); |
| | | if (affected != 1) { |
| | | throw new ErrorException("报告批准状态保存失败"); |
| | | } |
| | | sealUsageLedgerService.recordApprovedReport(insReport); |
| | | return affected; |
| | | } |
| | | |
| | | /** |
| | |
| | | .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)); |
| | |
| | | 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); |