From 29443fbecbe78e553e46b5387f2c97c101d89dca Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 13 Apr 2023 10:36:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=81=E7=BA=A7=E8=81=94=E5=AE=A1=20?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=96=87=E4=BB=B6=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../converter/ApplicationConverter.java | 61 ++++++++++++++++------ .../manage/ReviewByProvincialDeptManage.java | 17 ++---- .../pmapi/provincial/model/dto/FileDTO.java | 23 ++++++++ 3 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/FileDTO.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java index 42ffa7d..4ae8098 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java @@ -1,16 +1,20 @@ package com.ningdatech.pmapi.projectdeclared.converter; import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; +import com.ningdatech.pmapi.provincial.model.dto.FileDTO; import com.ningdatech.pmapi.provincial.model.dto.ProvincialApplicationDTO; import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; +import lombok.extern.slf4j.Slf4j; import org.assertj.core.util.Lists; import java.math.BigDecimal; -import java.util.Collections; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -19,9 +23,11 @@ import java.util.stream.Collectors; * @Date 2023/3/13 17:38 * @Author PoffyZhang */ +@Slf4j public class ApplicationConverter { - public static ProvincialProjectDTO convertProject(Project projectInfo,List applications) { + public static ProvincialProjectDTO convertProject(Project projectInfo, List applications, + FileService fileService) { return ProvincialProjectDTO.builder() .regionCode(projectInfo.getAreaCode()) .regionName(projectInfo.getArea()) @@ -41,7 +47,7 @@ public class ApplicationConverter { .beginTime(projectInfo.getBeginTime()) .endTime(projectInfo.getEndTime()) .buildBasis("立项依据") - .buildBasisFile(projectInfo.getBuildBasis()) + .buildBasisFile(convertFile(projectInfo.getBuildBasis(),fileService)) .projectSummary(projectInfo.getProjectIntroduction()) .responsibleMan(projectInfo.getResponsibleMan()) .responsibleManPhone(projectInfo.getResponsibleManMobile()) @@ -51,16 +57,15 @@ public class ApplicationConverter { .buildUnitCode(projectInfo.getBuildOrgCode()) .superUnit(projectInfo.getSuperOrg()) .superUnitCode(projectInfo.getSuperOrgCode()) - .projectApplyFile(projectInfo.getProjectPdf()) - .projectEstimateFile(projectInfo.getCalculationTotalInvestmentFile()) + .projectEstimateFile(convertFile(projectInfo.getCalculationTotalInvestmentFile(),fileService)) .unitThreePlan(projectInfo.getMainResponsibilitiesApplicantFile()) - .otherFile(projectInfo.getPreliminaryPlanFile()) + .otherFile(convertFile(projectInfo.getPreliminaryPlanFile(),fileService)) .projectRemark(projectInfo.getProjectRemarks()) .includeApplication(projectInfo.getIncludeApplication()) .isEffective(1) - .projectApplyFile(projectInfo.getProjectApplicationForm()) - .researchReport(projectInfo.getPreliminaryPlanFile()) - .applicationInfo(convertApplications(applications)) + .projectApplyFile(convertFile(projectInfo.getProjectApplicationForm(),fileService)) + .researchReport(convertFile(projectInfo.getPreliminaryPlanFile(),fileService)) + .applicationInfo(convertApplications(applications,fileService)) .build(); } @@ -78,7 +83,7 @@ public class ApplicationConverter { if(Objects.nonNull(declareGovSuperiorFinanceAmount) && declareGovSuperiorFinanceAmount.compareTo(BigDecimal.ZERO) > 0){ sb.append("政府投资-上级财政资金,"); } - if(Objects.nonNull(declareGovSuperiorFinanceAmount) && declareGovSuperiorFinanceAmount.compareTo(BigDecimal.ZERO) > 0){ + if(Objects.nonNull(declareBankLendingAmount) && declareBankLendingAmount.compareTo(BigDecimal.ZERO) > 0){ sb.append("银行贷款,"); } if(Objects.nonNull(otherAmount) && otherAmount.compareTo(BigDecimal.ZERO) > 0){ @@ -88,15 +93,16 @@ public class ApplicationConverter { } //放入项目 app - private static List convertApplications(List applications) { + private static List convertApplications(List applications + ,FileService fileService) { if(CollUtil.isEmpty(applications)){ Collections.emptyList(); } - return applications.stream().map(ApplicationConverter::convertApp).collect(Collectors.toList()); + return applications.stream().map(app -> convertApp(app,fileService)).collect(Collectors.toList()); } - private static ProvincialApplicationDTO convertApp(ProjectApplication projectApplication) { + private static ProvincialApplicationDTO convertApp(ProjectApplication projectApplication,FileService fileService) { return ProvincialApplicationDTO.builder() .clouds(convertCloud(projectApplication)) .isFirst(projectApplication.getIsFirst()) @@ -109,7 +115,6 @@ public class ApplicationConverter { .unionBuildKind(projectApplication.getUnionBuildKind()) .applicationSummary(projectApplication.getApplicationSummary()) .applicationRemark(projectApplication.getApplicationRemark()) - .applicationEstimateFile(projectApplication.getApplicationEstimateFile()) .isFiveDomain(projectApplication.getIsDigitalModification()) .fiveDomain(projectApplication.getDigitalModification()) .bizDomain(projectApplication.getBizDomain()) @@ -131,10 +136,32 @@ public class ApplicationConverter { .publishSide(projectApplication.getPublishSide()) .isS2(projectApplication.getIsAccountAppName()) .accountAppName(projectApplication.getAccountAppName()) - .applicationEstimateFile(projectApplication.getApplicationEstimateFile()) + .applicationEstimateFile(convertFile(projectApplication.getApplicationEstimateFile(),fileService)) .build(); } + private static String convertFile(String applicationEstimateFile, FileService fileService) { + try { + JSONArray jsonArrays = JSON.parseArray(applicationEstimateFile); + List files = jsonArrays.stream().map(json -> { + JSONObject fileJson = (JSONObject) JSON.toJSON(json); + Long fileId = fileJson.getLong("id"); + String fileName = fileJson.getString("name"); + Map fileMap = fileService.findUrlById(Arrays.asList(fileId)); + String url = fileMap.get(fileId); + FileDTO file = new FileDTO(); + file.setFileId(String.valueOf(fileId)); + file.setFileName(fileName); + file.setAccessUrl(url); + return file; + }).collect(Collectors.toList()); + return JSON.toJSONString(files); + } catch (Exception e) { + log.info("转换省局上传 文件出错 {}",e.getMessage()); + } + return null; + } + private static List convertCloud(ProjectApplication projectApplication) { return Lists.newArrayList(ProvincialApplicationDTO.Cloud.builder() .cloudType(projectApplication.getCloudsType()) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java index d9ea304..329e434 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java @@ -1,9 +1,8 @@ package com.ningdatech.pmapi.projectdeclared.manage; -import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.function.VUtils; -import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; +import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.projectdeclared.converter.ApplicationConverter; import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; @@ -12,20 +11,14 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; import com.ningdatech.pmapi.projectlib.service.IProjectService; -import com.ningdatech.pmapi.provincial.model.dto.ProvincialApplicationDTO; -import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; import com.wflow.exception.BusinessException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; - -import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; /** * @Classname ReviewByProvincialDeptManage @@ -40,9 +33,7 @@ public class ReviewByProvincialDeptManage { private final IProjectService projectService; - private final StateMachineUtils stateMachineUtils; - - private final DefaultDeclaredProjectManage defaultProjectManage; + private final FileService fileService; private final IJoinReviewProvincialBureauService joinReviewProvincialBureauService; @@ -69,7 +60,7 @@ public class ReviewByProvincialDeptManage { List applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .eq(ProjectApplication::getProjectId, projectInfo.getId())); if(joinReviewProvincialBureauService.pushImportProject( - ApplicationConverter.convertProject(projectInfo,applications))){ + ApplicationConverter.convertProject(projectInfo,applications,fileService))){ return Boolean.TRUE; } @@ -98,7 +89,7 @@ public class ReviewByProvincialDeptManage { List applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .eq(ProjectApplication::getProjectId, projectInfo.getId())); if(!joinReviewProvincialBureauService.pushImportProject( - ApplicationConverter.convertProject(projectInfo,applications))){ + ApplicationConverter.convertProject(projectInfo,applications,fileService))){ throw new BusinessException("提交省级部门联审失败"); } projectInfo.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/FileDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/FileDTO.java new file mode 100644 index 0000000..c25027c --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/FileDTO.java @@ -0,0 +1,23 @@ +package com.ningdatech.pmapi.provincial.model.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Classname FileDTO + * @Description + * @Date 2023/4/13 9:55 + * @Author PoffyZhang + */ +@Data +public class FileDTO { + + @ApiModelProperty("文件id") + private String fileId; + + @ApiModelProperty("文件名") + private String fileName; + + @ApiModelProperty("url") + private String accessUrl; +}