From f5829a6c2b51f1c0520dbb52e75da10ff47dfb7e Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 13 Apr 2023 11:54:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=81=E7=BA=A7=E8=81=94=E5=AE=A1=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../converter/ApplicationConverter.java | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) 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 4ae8098..3db3167 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 @@ -47,7 +47,7 @@ public class ApplicationConverter { .beginTime(projectInfo.getBeginTime()) .endTime(projectInfo.getEndTime()) .buildBasis("立项依据") - .buildBasisFile(convertFile(projectInfo.getBuildBasis(),fileService)) + .buildBasisFile(convertBasicFile(projectInfo.getBuildBasis(),fileService)) .projectSummary(projectInfo.getProjectIntroduction()) .responsibleMan(projectInfo.getResponsibleMan()) .responsibleManPhone(projectInfo.getResponsibleManMobile()) @@ -146,7 +146,7 @@ public class ApplicationConverter { List files = jsonArrays.stream().map(json -> { JSONObject fileJson = (JSONObject) JSON.toJSON(json); Long fileId = fileJson.getLong("id"); - String fileName = fileJson.getString("name"); + String fileName = fileJson.getString("originalFileName"); Map fileMap = fileService.findUrlById(Arrays.asList(fileId)); String url = fileMap.get(fileId); FileDTO file = new FileDTO(); @@ -162,6 +162,34 @@ public class ApplicationConverter { return null; } + //立项依据的文件格式不一样 + private static String convertBasicFile(String applicationEstimateFile, FileService fileService) { + try { + List files = Lists.newArrayList(); + JSONArray jsonArrays = JSON.parseArray(applicationEstimateFile); + jsonArrays.stream().forEach(json -> { + JSONObject fileJson = (JSONObject) JSON.toJSON(json); + JSONArray fileList = fileJson.getJSONArray("fileList"); + fileList.stream().forEach(f -> { + JSONObject fJson = (JSONObject) JSON.toJSON(f); + Long fileId = fJson.getLong("id"); + String fileName = fJson.getString("originalFileName"); + 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); + files.add(file); + }); + }); + return JSON.toJSONString(files); + } catch (Exception e) { + log.info("转换省局上传 basic文件出错 {}",e.getMessage()); + } + return null; + } + private static List convertCloud(ProjectApplication projectApplication) { return Lists.newArrayList(ProvincialApplicationDTO.Cloud.builder() .cloudType(projectApplication.getCloudsType())