From bc676e1342a26c822b835955a1f24512f050143e Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 8 Sep 2023 10:04:57 +0800 Subject: [PATCH] =?UTF-8?q?PDF=E8=BD=AC=E6=8D=A2=20=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/gov/contants/BizProjectContant.java | 1 + .../controller/GovProjectCollectionController.java | 7 + .../gov/manage/GovProjectCollectionManage.java | 76 +++---- .../scheduler/task/SynProjectCollectionTask.java | 249 +++++++++++++++++++++ .../pmapi/wps/manage/WpsConvertManage.java | 7 +- 5 files changed, 301 insertions(+), 39 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java index ef45497..90b1b25 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/contants/BizProjectContant.java @@ -23,6 +23,7 @@ public interface BizProjectContant { public static final String OP_INSERT = "insert"; public static final String OP_UPDATE = "update"; public static final String OP_DELETE = "delete"; + public static final String PDF_SUFFIX = ".pdf"; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java index f1bf99c..eb0a8ba 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java @@ -104,4 +104,11 @@ public class GovProjectCollectionController { public void pushTask() throws UnknownHostException { collectionTask.doTask(); } + + @PostMapping("/staging-convert-pdf") + @ApiOperation("把库存的项目归集的文件 都转换成PDF文件存入字段") + @WebLog("主动转换库存的文件都为PDF文件") + public void stagingConvertPdf() { + collectionTask.stagingConvertPdf(); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 4505ef1..2078498 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -818,23 +818,23 @@ public class GovProjectCollectionManage { */ private void uploadFileToProvincialOssApply(GovBizProjectApplyDTO apply, GovBizProjectApply oldApply,GovBizProjectApply saveApply) { - if(checkFieldHas(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ + if(checkFieldNotPdf(apply.getBaseProjBasisFile(),oldApply,"baseProjBasisFile")){ StringJoiner sj = convertAndUpload(apply.getBaseProjBasisFile()); saveApply.setBaseProjBasisFilePdf(sj.toString()); } - if(checkFieldHas(apply.getBaseProjApplyFile(),oldApply,"baseProjApplyFile")){ + if(checkFieldNotPdf(apply.getBaseProjApplyFile(),oldApply,"baseProjApplyFile")){ StringJoiner sj = convertAndUpload(apply.getBaseProjApplyFile()); saveApply.setBaseProjApplyFilePdf(sj.toString()); } - if(checkFieldHas(apply.getBaseOperatMaintenFile(),oldApply,"baseOperatMaintenFile")){ + if(checkFieldNotPdf(apply.getBaseOperatMaintenFile(),oldApply,"baseOperatMaintenFile")){ StringJoiner sj = convertAndUpload(apply.getBaseOperatMaintenFile()); saveApply.setBaseOperatMaintenFilePdf(sj.toString()); } - if(checkFieldHas(apply.getBaseResearchReportFile(),oldApply,"baseResearchReportFile")){ + if(checkFieldNotPdf(apply.getBaseResearchReportFile(),oldApply,"baseResearchReportFile")){ StringJoiner sj = convertAndUpload(apply.getBaseResearchReportFile()); saveApply.setBaseResearchReportFilePdf(sj.toString()); } - if(checkFieldHas(apply.getBaseProjOtherFile(),oldApply,"baseProjOtherFile")){ + if(checkFieldNotPdf(apply.getBaseProjOtherFile(),oldApply,"baseProjOtherFile")){ StringJoiner sj = convertAndUpload(apply.getBaseProjOtherFile()); saveApply.setBaseProjOtherFilePdf(sj.toString()); } @@ -842,15 +842,15 @@ public class GovProjectCollectionManage { } private void uploadFileToProvincialOssApprove(GovBizProjectApproveDTO approve, GovBizProjectApprove oldApprove, GovBizProjectApprove saveApprove) { - if(checkFieldHas(approve.getApprovalFile(),oldApprove,"approvalFile")){ + if(checkFieldNotPdf(approve.getApprovalFile(),oldApprove,"approvalFile")){ StringJoiner sj = convertAndUpload(approve.getApprovalFile()); saveApprove.setApprovalFilePdf(sj.toString()); } - if(checkFieldHas(approve.getBaseReviewCommentsFile(),oldApprove,"baseReviewCommentsFile")){ + if(checkFieldNotPdf(approve.getBaseReviewCommentsFile(),oldApprove,"baseReviewCommentsFile")){ StringJoiner sj = convertAndUpload(approve.getBaseReviewCommentsFile()); saveApprove.setBaseReviewCommentsFilePdf(sj.toString()); } - if(checkFieldHas(approve.getPreliminaryDesignFile(),oldApprove,"preliminaryDesignFile")){ + if(checkFieldNotPdf(approve.getPreliminaryDesignFile(),oldApprove,"preliminaryDesignFile")){ StringJoiner sj = convertAndUpload(approve.getPreliminaryDesignFile()); saveApprove.setPreliminaryDesignFilePdf(sj.toString()); } @@ -859,63 +859,63 @@ public class GovProjectCollectionManage { private void uploadFileToProvincialOssCimplement(GovBizProjectCimplementDTO cimplement, GovBizProjectCimplement oldCimplement, GovBizProjectCimplement saveCimplement) { - if(checkFieldHas(cimplement.getBaseChanFile(),oldCimplement,"baseChanFile")){ + if(checkFieldNotPdf(cimplement.getBaseChanFile(),oldCimplement,"baseChanFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseChanFile()); saveCimplement.setBaseChanFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseCheckFile(),oldCimplement,"baseCheckFile")){ + if(checkFieldNotPdf(cimplement.getBaseCheckFile(),oldCimplement,"baseCheckFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseCheckFile()); saveCimplement.setBaseCheckFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseInforLevelFile(),oldCimplement,"baseInforLevelFile")){ + if(checkFieldNotPdf(cimplement.getBaseInforLevelFile(),oldCimplement,"baseInforLevelFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseInforLevelFile()); saveCimplement.setBaseInforLevelFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseChangeFormFile(),oldCimplement,"baseChangeFormFile")){ + if(checkFieldNotPdf(cimplement.getBaseChangeFormFile(),oldCimplement,"baseChangeFormFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseChangeFormFile()); saveCimplement.setBaseChangeFormFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseEstaSummFile(),oldCimplement,"baseEstaSummFile")){ + if(checkFieldNotPdf(cimplement.getBaseEstaSummFile(),oldCimplement,"baseEstaSummFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseEstaSummFile()); saveCimplement.setBaseEstaSummFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ + if(checkFieldNotPdf(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseEngineerPostpoFile()); saveCimplement.setBaseEngineerPostpoFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseFinalExpertOpinionFile(),oldCimplement,"baseFinalExpertOpinionFile")){ + if(checkFieldNotPdf(cimplement.getBaseFinalExpertOpinionFile(),oldCimplement,"baseFinalExpertOpinionFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseFinalExpertOpinionFile()); saveCimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseThirdAcceptFile(),oldCimplement,"baseThirdAcceptFile")){ + if(checkFieldNotPdf(cimplement.getBaseThirdAcceptFile(),oldCimplement,"baseThirdAcceptFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseThirdAcceptFile()); saveCimplement.setBaseThirdAcceptFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseUserConsFile(),oldCimplement,"baseUserConsFile")){ + if(checkFieldNotPdf(cimplement.getBaseUserConsFile(),oldCimplement,"baseUserConsFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseUserConsFile()); saveCimplement.setBaseUserConsFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseFinanlAuditFile(),oldCimplement,"baseFinanlAuditFile")){ + if(checkFieldNotPdf(cimplement.getBaseFinanlAuditFile(),oldCimplement,"baseFinanlAuditFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseFinanlAuditFile()); saveCimplement.setBaseFinanlAuditFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ + if(checkFieldNotPdf(cimplement.getBaseEngineerPostpoFile(),oldCimplement,"baseEngineerPostpoFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseEngineerPostpoFile()); saveCimplement.setBaseEngineerPostpoFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseInitialOpinionFile(),oldCimplement,"baseInitialOpinionFile")){ + if(checkFieldNotPdf(cimplement.getBaseInitialOpinionFile(),oldCimplement,"baseInitialOpinionFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseInitialOpinionFile()); saveCimplement.setBaseInitialOpinionFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBasePasswAssessFile(),oldCimplement,"basePasswAssessFile")){ + if(checkFieldNotPdf(cimplement.getBasePasswAssessFile(),oldCimplement,"basePasswAssessFile")){ StringJoiner sj = convertAndUpload(cimplement.getBasePasswAssessFile()); saveCimplement.setBasePasswAssessFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseSummReportFile(),oldCimplement,"baseSummReportFile")){ + if(checkFieldNotPdf(cimplement.getBaseSummReportFile(),oldCimplement,"baseSummReportFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseSummReportFile()); saveCimplement.setBaseSummReportFilePdf(sj.toString()); } - if(checkFieldHas(cimplement.getBaseIrsTestRunFile(),oldCimplement,"baseIrsTestRunFile")){ + if(checkFieldNotPdf(cimplement.getBaseIrsTestRunFile(),oldCimplement,"baseIrsTestRunFile")){ StringJoiner sj = convertAndUpload(cimplement.getBaseIrsTestRunFile()); saveCimplement.setBaseIrsTestRunFilePdf(sj.toString()); } @@ -923,43 +923,43 @@ public class GovProjectCollectionManage { } private void uploadFileToProvincialOssMimplement(GovBizProjectMimplementDTO mimplement, GovBizProjectMimplement oldMimplement, GovBizProjectMimplement saveMimplement) { - if(checkFieldHas(mimplement.getBaseChanFile(),oldMimplement,"baseChanFile")){ + if(checkFieldNotPdf(mimplement.getBaseChanFile(),oldMimplement,"baseChanFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseChanFile()); saveMimplement.setBaseChanFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseInforLevelFile(),oldMimplement,"baseInforLevelFile")){ + if(checkFieldNotPdf(mimplement.getBaseInforLevelFile(),oldMimplement,"baseInforLevelFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseInforLevelFile()); saveMimplement.setBaseInforLevelFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBasePasswAssessFile(),oldMimplement,"basePasswAssessFile")){ + if(checkFieldNotPdf(mimplement.getBasePasswAssessFile(),oldMimplement,"basePasswAssessFile")){ StringJoiner sj = convertAndUpload(mimplement.getBasePasswAssessFile()); saveMimplement.setBasePasswAssessFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseThirdAcceptFile(),oldMimplement,"baseThirdAcceptFile")){ + if(checkFieldNotPdf(mimplement.getBaseThirdAcceptFile(),oldMimplement,"baseThirdAcceptFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseThirdAcceptFile()); saveMimplement.setBaseThirdAcceptFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseEstaSummFile(),oldMimplement,"baseEstaSummFile")){ + if(checkFieldNotPdf(mimplement.getBaseEstaSummFile(),oldMimplement,"baseEstaSummFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseEstaSummFile()); saveMimplement.setBaseEstaSummFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseUserConsFile(),oldMimplement,"baseUserConsFile")){ + if(checkFieldNotPdf(mimplement.getBaseUserConsFile(),oldMimplement,"baseUserConsFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseUserConsFile()); saveMimplement.setBaseUserConsFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseOperatMaintenSummFile(),oldMimplement,"baseOperatMaintenSummFile")){ + if(checkFieldNotPdf(mimplement.getBaseOperatMaintenSummFile(),oldMimplement,"baseOperatMaintenSummFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseOperatMaintenSummFile()); saveMimplement.setBaseOperatMaintenSummFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseFinalExpertOpinionFile(),oldMimplement,"baseFinalExpertOpinionFile")){ + if(checkFieldNotPdf(mimplement.getBaseFinalExpertOpinionFile(),oldMimplement,"baseFinalExpertOpinionFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseFinalExpertOpinionFile()); saveMimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseEngineerPostpoFile(),oldMimplement,"baseEngineerPostpoFile")){ + if(checkFieldNotPdf(mimplement.getBaseEngineerPostpoFile(),oldMimplement,"baseEngineerPostpoFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseEngineerPostpoFile()); saveMimplement.setBaseEngineerPostpoFilePdf(sj.toString()); } - if(checkFieldHas(mimplement.getBaseEngineerAlterFile(),oldMimplement,"baseEngineerAlterFile")){ + if(checkFieldNotPdf(mimplement.getBaseEngineerAlterFile(),oldMimplement,"baseEngineerAlterFile")){ StringJoiner sj = convertAndUpload(mimplement.getBaseEngineerAlterFile()); saveMimplement.setBaseEngineerAlterFilePdf(sj.toString()); } @@ -973,22 +973,22 @@ public class GovProjectCollectionManage { * @param saveProcure */ private void uploadFileToProvincialOssProcure(GovBizProjectProcureDTO procure, Object o, GovBizProjectProcure saveProcure) { - if(checkFieldHas(procure.getPurchaseFile(),o,"purchaseFile")){ + if(checkFieldNotPdf(procure.getPurchaseFile(),o,"purchaseFile")){ StringJoiner sj = convertAndUpload(procure.getPurchaseFile()); saveProcure.setPurchaseFilePdf(sj.toString()); } - if(checkFieldHas(procure.getBiddingFile(),o,"biddingFile")){ + if(checkFieldNotPdf(procure.getBiddingFile(),o,"biddingFile")){ StringJoiner sj = convertAndUpload(procure.getBiddingFile()); saveProcure.setBiddingFilePdf(sj.toString()); } - if(checkFieldHas(procure.getPurchaseContract(),o,"purchaseContract")){ + if(checkFieldNotPdf(procure.getPurchaseContract(),o,"purchaseContract")){ StringJoiner sj = convertAndUpload(procure.getPurchaseContract()); saveProcure.setPurchaseContractPdf(sj.toString()); } procureService.updateById(saveProcure); } - private StringJoiner convertAndUpload(String baseProjBasisFile) { + public StringJoiner convertAndUpload(String baseProjBasisFile) { String[] baseProjBasisFileArr = baseProjBasisFile.split(";"); StringJoiner sj = new StringJoiner(";"); for(String bpb : baseProjBasisFileArr){ @@ -1009,7 +1009,7 @@ public class GovProjectCollectionManage { return sj; } - private Boolean checkFieldHas(String field, Object record, String fieldName){ + private Boolean checkFieldNotPdf(String field, Object record, String fieldName){ if(StringUtils.isBlank(field)){ return Boolean.FALSE; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java index 4c672ad..4af974e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java @@ -1,20 +1,29 @@ package com.ningdatech.pmapi.scheduler.task; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.StopWatch; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.model.PageVo; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.gov.manage.GovProjectCollectionManage; +import com.ningdatech.pmapi.gov.model.entity.*; import com.ningdatech.pmapi.gov.model.vo.GovBizProjectDetailVO; import com.ningdatech.pmapi.gov.model.vo.GovBizProjectListVO; +import com.ningdatech.pmapi.gov.service.*; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; /** * @author ZPF @@ -34,6 +43,20 @@ public class SynProjectCollectionTask { @Autowired private GovProjectCollectionManage collectionManage; + @Autowired + private IGovBizProjectApplyService applyService; + @Autowired + private IGovBizProjectApproveService approveService; + + @Autowired + private IGovBizProjectCimplementService cimplementService; + + @Autowired + private IGovBizProjectMimplementService mimplementService; + + @Autowired + private IGovBizProjectProcureService procureService; + private final Integer PAGE_NUMBER = 1; /** @@ -78,4 +101,230 @@ public class SynProjectCollectionTask { stopWatch.stop(); log.info("数据同步任务结束====={}s",stopWatch.getTotalTimeSeconds()); } + + /** + * 把库存的项目归集里 没有转换PDF文件的 都转换一遍 存入数据库 + */ + public void stagingConvertPdf() { + log.info("项目归集库存转换PDF任务开始====="); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + ProjectListReq req = new ProjectListReq(); + req.setPageNumber(1); + req.setPageSize(BizConst.MAX_EXPORT_COUNT); + PageVo pageRes = collectionManage.list(req); + + if(CollUtil.isEmpty(pageRes.getRecords())){ + log.info("没有项目归集 任务终止"); + return; + } + + Collection records = pageRes.getRecords(); + for(GovBizProjectListVO project : records){ + //开始转换PDF + convertPdfVo(project.getBaseProjId()); + } + + stopWatch.stop(); + log.info("项目归集库存转换PDF任务结束====={}s",stopWatch.getTotalTimeSeconds()); + } + + //开始转换PDF + private void convertPdfVo(String baseProjId) { + convertPdfApply(baseProjId); + convertPdfApprove(baseProjId); + convertPdfCimplement(baseProjId); + convertPdfMimplement(baseProjId); + convertPdfAProcure(baseProjId); + } + + private void convertPdfApply(String baseProjId) { + GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) + .eq(GovBizProjectApply::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(apply)){ + return; + } + if(StringUtils.isBlank(apply.getBaseProjApplyFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjApplyFile())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjApplyFile()); + apply.setBaseProjApplyFilePdf(sj.toString()); + } + if(StringUtils.isBlank(apply.getBaseProjBasisFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjBasisFile())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjBasisFile()); + apply.setBaseProjBasisFilePdf(sj.toString()); + } + if(StringUtils.isBlank(apply.getBaseProjOtherFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjOtherFile())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjOtherFile()); + apply.setBaseProjOtherFilePdf(sj.toString()); + } + if(StringUtils.isBlank(apply.getBaseResearchReportFilePdf()) && StringUtils.isNotBlank(apply.getBaseResearchReportFile())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseResearchReportFile()); + apply.setBaseResearchReportFilePdf(sj.toString()); + } + if(StringUtils.isBlank(apply.getBaseOperatMaintenFilePdf()) && StringUtils.isNotBlank(apply.getBaseOperatMaintenFilePdf())){ + StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseOperatMaintenFile()); + apply.setBaseOperatMaintenFilePdf(sj.toString()); + } + applyService.updateById(apply); + } + + private void convertPdfApprove(String baseProjId) { + GovBizProjectApprove approve = approveService.getOne(Wrappers.lambdaQuery(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(approve)){ + return; + } + if(StringUtils.isBlank(approve.getApprovalFilePdf()) && StringUtils.isNotBlank(approve.getApprovalFile())){ + StringJoiner sj = collectionManage.convertAndUpload(approve.getApprovalFile()); + approve.setApprovalFile(sj.toString()); + } + if(StringUtils.isBlank(approve.getPreliminaryDesignFilePdf()) && StringUtils.isNotBlank(approve.getPreliminaryDesignFile())){ + StringJoiner sj = collectionManage.convertAndUpload(approve.getPreliminaryDesignFile()); + approve.setPreliminaryDesignFilePdf(sj.toString()); + } + if(StringUtils.isBlank(approve.getBaseReviewCommentsFilePdf()) && StringUtils.isNotBlank(approve.getBaseReviewCommentsFile())){ + StringJoiner sj = collectionManage.convertAndUpload(approve.getBaseReviewCommentsFile()); + approve.setBaseReviewCommentsFilePdf(sj.toString()); + } + approveService.updateById(approve); + } + + private void convertPdfCimplement(String baseProjId) { + GovBizProjectCimplement cimplement = cimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectCimplement.class) + .eq(GovBizProjectCimplement::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(cimplement)){ + return; + } + if(StringUtils.isBlank(cimplement.getBaseCheckFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseCheckFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseCheckFile()); + cimplement.setBaseCheckFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseChanFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseChanFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseChanFile()); + cimplement.setBaseChanFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseChangeFormFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseChangeFormFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseChangeFormFile()); + cimplement.setBaseChangeFormFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseUserConsFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseUserConsFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseUserConsFile()); + cimplement.setBaseUserConsFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseEstaSummFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseEstaSummFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseEstaSummFile()); + cimplement.setBaseEstaSummFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseEngineerPostpoFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseEngineerPostpoFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseEngineerPostpoFile()); + cimplement.setBaseEngineerPostpoFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBasePasswAssessFilePdf()) && StringUtils.isNotBlank(cimplement.getBasePasswAssessFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBasePasswAssessFile()); + cimplement.setBasePasswAssessFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseThirdAcceptFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseThirdAcceptFile()); + cimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseFinanlAuditFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseFinanlAuditFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseFinanlAuditFile()); + cimplement.setBaseFinanlAuditFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseInitialOpinionFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseInitialOpinionFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseInitialOpinionFile()); + cimplement.setBaseInitialOpinionFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseThirdAcceptFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseThirdAcceptFile()); + cimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseSummReportFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseSummReportFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseSummReportFile()); + cimplement.setBaseSummReportFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseFinalExpertOpinionFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseFinalExpertOpinionFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseFinalExpertOpinionFile()); + cimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); + } + if(StringUtils.isBlank(cimplement.getBaseIrsTestRunFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseIrsTestRunFile())){ + StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseIrsTestRunFile()); + cimplement.setBaseIrsTestRunFilePdf(sj.toString()); + } + cimplementService.updateById(cimplement); + } + + private void convertPdfMimplement(String baseProjId) { + GovBizProjectMimplement mimplement = mimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectMimplement.class) + .eq(GovBizProjectMimplement::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(mimplement)){ + return; + } + if(StringUtils.isBlank(mimplement.getBaseChanFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseChanFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseChanFile()); + mimplement.setBaseChanFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseUserConsFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseUserConsFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseUserConsFile()); + mimplement.setBaseUserConsFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseEstaSummFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEstaSummFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEstaSummFile()); + mimplement.setBaseEstaSummFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseEngineerPostpoFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEngineerPostpoFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEngineerPostpoFile()); + mimplement.setBaseEngineerPostpoFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBasePasswAssessFilePdf()) && StringUtils.isNotBlank(mimplement.getBasePasswAssessFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBasePasswAssessFile()); + mimplement.setBasePasswAssessFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseThirdAcceptFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseThirdAcceptFile()); + mimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseThirdAcceptFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseThirdAcceptFile()); + mimplement.setBaseThirdAcceptFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseFinalExpertOpinionFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseFinalExpertOpinionFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseFinalExpertOpinionFile()); + mimplement.setBaseFinalExpertOpinionFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseEngineerAlterFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEngineerAlterFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEngineerAlterFile()); + mimplement.setBaseEngineerAlterFilePdf(sj.toString()); + } + if(StringUtils.isBlank(mimplement.getBaseOperatMaintenSummFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseOperatMaintenSummFile())){ + StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseOperatMaintenSummFile()); + mimplement.setBaseOperatMaintenSummFilePdf(sj.toString()); + } + mimplementService.updateById(mimplement); + } + + private void convertPdfAProcure(String baseProjId) { + List procures = procureService.list(Wrappers.lambdaQuery(GovBizProjectProcure.class) + .eq(GovBizProjectProcure::getBaseProjId, baseProjId)); + for(GovBizProjectProcure procure : procures){ + if(StringUtils.isBlank(procure.getPurchaseContractPdf()) && StringUtils.isNotBlank(procure.getPurchaseContract())){ + StringJoiner sj = collectionManage.convertAndUpload(procure.getPurchaseContract()); + procure.setPurchaseContractPdf(sj.toString()); + } + if(StringUtils.isBlank(procure.getPurchaseFilePdf()) && StringUtils.isNotBlank(procure.getPurchaseFile())){ + StringJoiner sj = collectionManage.convertAndUpload(procure.getPurchaseContract()); + procure.setPurchaseContractPdf(sj.toString()); + } + if(StringUtils.isBlank(procure.getBiddingFilePdf()) && StringUtils.isNotBlank(procure.getBiddingFile())){ + StringJoiner sj = collectionManage.convertAndUpload(procure.getBiddingFile()); + procure.setBiddingFilePdf(sj.toString()); + } + procureService.updateById(procure); + } + } + + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java index 2c399db..c5de710 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java @@ -8,6 +8,7 @@ import com.aliyun.oss.model.ObjectMetadata; import com.ningdatech.file.properties.FileServerProperties; import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.gov.contants.BizProjectContant; import com.ningdatech.pmapi.wps.contants.WpsContant; import com.suwell.ofd.custom.agent.AtomAgent; import lombok.RequiredArgsConstructor; @@ -91,7 +92,9 @@ public class WpsConvertManage { byte[] bytes = new byte[4096]; int read; //测试环境 转不了PDF 请求不了 WPS转换服务器 - if(BizConst.DEV.equals(active)){ + // 或者 已经是PDF文件 也不用转PDF + if(BizConst.DEV.equals(active) || + file.getOriginalFileName().endsWith(BizProjectContant.ProjectCollection.PDF_SUFFIX)){ ObjectMetadata metadata = ossObject.getObjectMetadata(); response.setContentType(metadata.getContentType()); fileName = URLEncoder.encode(file.getOriginalFileName(), CharsetUtil.UTF_8); @@ -125,6 +128,8 @@ public class WpsConvertManage { //用完就删 f.deleteOnExit(); } + }else{ + log.info("都不满足条件 并且 没有转换文件!"); } outputStream.flush(); }catch (Exception e){