|
|
@@ -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<ProjectApplication> applications) { |
|
|
|
public static ProvincialProjectDTO convertProject(Project projectInfo, List<ProjectApplication> 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<ProvincialApplicationDTO> convertApplications(List<ProjectApplication> applications) { |
|
|
|
private static List<ProvincialApplicationDTO> convertApplications(List<ProjectApplication> 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<FileDTO> files = jsonArrays.stream().map(json -> { |
|
|
|
JSONObject fileJson = (JSONObject) JSON.toJSON(json); |
|
|
|
Long fileId = fileJson.getLong("id"); |
|
|
|
String fileName = fileJson.getString("name"); |
|
|
|
Map<Long, String> 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<ProvincialApplicationDTO.Cloud> convertCloud(ProjectApplication projectApplication) { |
|
|
|
return Lists.newArrayList(ProvincialApplicationDTO.Cloud.builder() |
|
|
|
.cloudType(projectApplication.getCloudsType()) |
|
|
|