Browse Source

省级联审 转换文件格式

tags/24080901
PoffyZhang 1 year ago
parent
commit
29443fbecb
3 changed files with 71 additions and 30 deletions
  1. +44
    -17
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java
  2. +4
    -13
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java
  3. +23
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/FileDTO.java

+ 44
- 17
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java View File

@@ -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())


+ 4
- 13
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ReviewByProvincialDeptManage.java View File

@@ -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<ProjectApplication> 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<ProjectApplication> 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());


+ 23
- 0
pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/FileDTO.java View File

@@ -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;
}

Loading…
Cancel
Save