From 7eca258d44ae0f20606898a47442f1521825fef2 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 23 Nov 2023 17:18:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0OSSPDF=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/manage/DashboardProjectManage.java | 2 ++ .../gov/manage/GovProjectCollectionManage.java | 32 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java index 6398e2f..dbcbf21 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java @@ -396,6 +396,7 @@ public class DashboardProjectManage { } projectInfo.setProjectIntroduction(apply.getBaseProjIntro()); projectInfo.setBuildCycle(apply.getBaseProjDuration()); + projectInfo.setApprovalAmount(apply.getBaseProjTotalAmount()); } projectInfo.setProjectCode(projectCode); projectInfo.setProjectName(baseInfo.getBaseProjName()); @@ -416,6 +417,7 @@ public class DashboardProjectManage { } projectInfo.setProjectIntroduction(apply.getBaseProjIntro()); projectInfo.setBuildCycle(apply.getBaseProjDuration()); + projectInfo.setApprovalAmount(apply.getBaseProjTotalAmount()); } projectInfo.setProjectCode(projectCode); projectInfo.setProjectName(operationBase.getBaseProjName()); 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 9087b28..2236e8a 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 @@ -15,6 +15,7 @@ import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.StrPool; +import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.constant.RegionConst; import com.ningdatech.pmapi.common.helper.RegionCacheHelper; @@ -58,6 +59,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.util.IOUtils; import org.flowable.engine.HistoryService; import org.flowable.engine.RuntimeService; import org.springframework.beans.factory.annotation.Autowired; @@ -70,10 +72,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.RestTemplate; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; + +import java.io.*; import java.lang.reflect.Field; import java.time.LocalDate; import java.time.LocalDateTime; @@ -121,6 +121,8 @@ public class GovProjectCollectionManage { private final ThreadPoolTaskScheduler threadPoolTaskScheduler; + private final FileService fileService; + @Value("${project.push-url}") private String pushUrl; @@ -1695,7 +1697,9 @@ public class GovProjectCollectionManage { StringJoiner sj = convertAndUpload(procure.getBiddingFile()); saveProcure.setBiddingFilePdf(sj.toString()); } - if(checkFieldNotPdf(procure.getPurchaseContract(),o,"purchaseContract")){ + Boolean purchaseContract = checkFieldNotPdf(procure.getPurchaseContract(), o, "purchaseContract"); + log.info("是否转换 采购合同 purchaseContract:{}",purchaseContract); + if(purchaseContract){ StringJoiner sj = convertAndUpload(procure.getPurchaseContract()); saveProcure.setPurchaseContractPdf(sj.toString()); } @@ -1710,9 +1714,25 @@ public class GovProjectCollectionManage { JSONArray fileArray = JSON.parseArray(bpb); fileArray.forEach(j -> { JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); - byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); String suffix = jsonObject.getString("suffix"); + //如果已经是PDF 就不用转换了 + byte[] btyes = null; String originalFileName = jsonObject.getString("originalFileName"); + if(StringUtils.isNotBlank(suffix) && suffix.equals("pdf")){ + com.ningdatech.file.entity.File file = fileService.getById(jsonObject.getLong("id")); + if(Objects.isNull(file)){ + throw new RuntimeException("转换PDF文件失败:" + originalFileName); + } + InputStream inputStream = fileService.getFileInputStream(file); + try { + btyes = IOUtils.toByteArray(inputStream); + } catch (IOException e) { + throw new RuntimeException("转换PDF文件失败:" + originalFileName,e); + } + }else{ + btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); + } + if(!BizConst.DEV.equals(active)){ originalFileName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); }