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