From 2e6ec65cd2a4f4e1a9881de897582ecc93a6cb77 Mon Sep 17 00:00:00 2001 From: Kris <2893855659@qq.com> Date: Fri, 7 Nov 2025 10:00:46 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90feat=E3=80=91=20=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E5=9B=BE=E7=89=87=E6=9B=BF=E6=8D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- file/BlukV1_750e2000004GIDCAA4.csv | 1 - .../celnet/datadump/entity/RichTextLog.java | 4 +- .../impl/DataImportNewServiceImpl.java | 237 ++++++++++++------ .../service/impl/FileServiceImpl.java | 91 +++++-- 4 files changed, 237 insertions(+), 96 deletions(-) delete mode 100644 file/BlukV1_750e2000004GIDCAA4.csv diff --git a/file/BlukV1_750e2000004GIDCAA4.csv b/file/BlukV1_750e2000004GIDCAA4.csv deleted file mode 100644 index 3eec75d..0000000 --- a/file/BlukV1_750e2000004GIDCAA4.csv +++ /dev/null @@ -1 +0,0 @@ -752e2000002qkjy \ No newline at end of file diff --git a/src/main/java/com/celnet/datadump/entity/RichTextLog.java b/src/main/java/com/celnet/datadump/entity/RichTextLog.java index b32346a..c45654b 100644 --- a/src/main/java/com/celnet/datadump/entity/RichTextLog.java +++ b/src/main/java/com/celnet/datadump/entity/RichTextLog.java @@ -62,7 +62,7 @@ public class RichTextLog implements Serializable { private String newFileId; @ApiModelProperty("创建时间") - @TableField(value = "created_time", fill = FieldFill.INSERT) - private Date createdTime; + @TableField(value = "createdDate", fill = FieldFill.INSERT) + private Date createdDate; } \ No newline at end of file diff --git a/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java b/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java index 6dae859..f8a3d72 100644 --- a/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java +++ b/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java @@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j; import okhttp3.Response; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.Get; +import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.lang.time.DateUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -47,6 +48,7 @@ import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; import java.io.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -58,8 +60,6 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import java.util.Base64; - @Service @Slf4j public class DataImportNewServiceImpl implements DataImportNewService { @@ -102,6 +102,23 @@ public class DataImportNewServiceImpl implements DataImportNewService { private static final String TEMP_FILE_PATH = "verify/"; + private static String FILE_UPLOAD_URL = ""; + + private static String FILE_DOWNLOAD_URL = ""; + + @PostConstruct + public void init() { + List> poll = customMapper.list("code,value","org_config",null); + for (Map map1 : poll) { + if ("FILE_UPLOAD_URL".equals(map1.get("code"))) { + FILE_UPLOAD_URL = (String) map1.get("value"); + } + if ("FILE_DOWNLOAD_URL".equals(map1.get("code"))) { + FILE_DOWNLOAD_URL = (String) map1.get("value"); + } + } + } + static { // 检测路径是否存在 不存在则创建 File excel = new File(TEMP_FILE_PATH); @@ -110,9 +127,6 @@ public class DataImportNewServiceImpl implements DataImportNewService { } } - @Autowired - private EmailUtil emailUtil; - /** * Get返写个人客户联系人入口 */ @@ -1414,12 +1428,23 @@ public class DataImportNewServiceImpl implements DataImportNewService { } if (Const.FILE_TYPE == FileType.SERVER) { + Date defaultBeginDate = DataUtil.DEFAULT_BEGIN_DATE; + Calendar calendar = Calendar.getInstance(); + int currentYear = calendar.get(Calendar.YEAR); + calendar.setTime(defaultBeginDate); + int beginYear = calendar.get(Calendar.YEAR); + // 检测路径是否存在 不存在则创建 - File excel = new File(Const.SERVER_FILE_PATH + "/" + api); - if (!excel.exists()) { - boolean mkdir = excel.mkdir(); - if (!mkdir) { - log.info("创建文件存储目录失败!"); + File baseDir = new File(Const.SERVER_FILE_PATH + "/" + api); + if (!baseDir.exists()) { + baseDir.mkdirs(); + } + + // 创建从开始年份到当前年份的子目录 + for (int year = beginYear; year <= currentYear; year++) { + File yearDir = new File(Const.SERVER_FILE_PATH + "/" + api + "—" + year); + if (!yearDir.exists()) { + yearDir.mkdir(); } } } @@ -1502,7 +1527,7 @@ public class DataImportNewServiceImpl implements DataImportNewService { log.info("api:{} 批次:{};-开始时间:{};-结束时间:{};",api, i, beginDateStr, endDateStr); // 获取未存储的附件id - List> list = customMapper.list("Id, " + name, api, " is_dump = 0 and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr +"'"+ extraSql + "limit 200"); + List> list = customMapper.list("Id,CreatedDate, " + name, api, " is_dump = 0 and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr +"'"+ extraSql + "limit 200"); for (Map map : list) { int failCount = 0; @@ -1517,9 +1542,11 @@ public class DataImportNewServiceImpl implements DataImportNewService { }else { fileName = (String) map.get("Name"); } + String year = map.get("CreatedDate").toString().substring(0, 4); + // 判断路径是否为空 if (StringUtils.isNotBlank(fileName)) { - String filePath = api + "/" + id + "_" + fileName; + String filePath = api + "-" + year + "/" + id + "_" + fileName; // 拼接url String url = downloadUrl + String.format(Const.SF_FILE_URL, api, id, field); @@ -2675,6 +2702,16 @@ public class DataImportNewServiceImpl implements DataImportNewService { endDateStr = DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss"); } } + // 检测路径是否存在 不存在则创建 + File excel = new File(Const.SERVER_FILE_PATH + "/richTextImages" ); + if (!excel.exists()) { + log.info("创建API目录: {}", excel.getAbsolutePath()); + boolean mkdir = excel.mkdir(); + if (!mkdir) { + log.info("创建文件存储目录失败!"); + } + } + // 获取连接 PartnerConnection sourceConnection = salesforceConnect.createConnect(); PartnerConnection targetConnection = salesforceTargetConnect.createConnect(); @@ -2740,6 +2777,10 @@ public class DataImportNewServiceImpl implements DataImportNewService { // 处理富文本中的图片 String updatedContent = processRichTextImages(richTextContent, sourceId, api, field, sourceConnection, targetConnection); + if (updatedContent == null){ + return ReturnT.FAIL; + } + // 如果内容有变化,则更新目标组织中的记录 if (!richTextContent.equals(updatedContent)) { @@ -2748,6 +2789,7 @@ public class DataImportNewServiceImpl implements DataImportNewService { sObject.setType(api); sObject.setId(targetId); sObject.setField(field, updatedContent); + sObject.setField("Id", targetId); accounts[index] = sObject; index ++; @@ -2817,8 +2859,7 @@ public class DataImportNewServiceImpl implements DataImportNewService { private String processRichTextImages(String richTextContent, String sourceRecordId, String api, String field, PartnerConnection sourceConnection, PartnerConnection targetConnection) throws Exception { // 匹配富文本中包含refid的img标签 - Pattern imgPattern = Pattern.compile("]*refid=\"([^\"]+)\"[^>]*/?>", Pattern.CASE_INSENSITIVE); - Matcher matcher = imgPattern.matcher(richTextContent); + Pattern imgPattern = Pattern.compile("]*src\\s*=\\s*\"[^\"]*refid=([^\"]+)(?:"|&|&|\\\"|\"|')?[^>]*/?>", Pattern.CASE_INSENSITIVE); Matcher matcher = imgPattern.matcher(richTextContent); StringBuffer updatedContent = new StringBuffer(); Map imageIdMap = new ConcurrentHashMap<>(); @@ -2837,57 +2878,58 @@ public class DataImportNewServiceImpl implements DataImportNewService { } try { - // 查询源组织中的ContentDocumentLink记录 - String cdlQuery = "SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '" + sourceRecordId + "' AND ContentDocumentId = '" + refId + "'"; - QueryResult cdlResult = sourceConnection.query(cdlQuery); - - if (cdlResult.getRecords() != null && cdlResult.getRecords().length > 0) { - // 构建源图片下载URL (参考Python脚本中的imageUrl构建方式) - String downloadUrl = sourceConnection.getConfig().getServiceEndpoint() + - String.format("/services/data/v55.0/sobjects/%s/%s/richTextImageFields/%s/%s", - api, sourceRecordId, field, refId); + // 构建源图片下载URL (参考Python脚本中的imageUrl构建方式) + String downloadUrl = FILE_DOWNLOAD_URL + + String.format("/services/data/v55.0/sobjects/%s/%s/richTextImageFields/%s/%s", + api, sourceRecordId, field, refId); + // 获取图片的alt属性作为标题 + String title = "image"; + Pattern altPattern = Pattern.compile("alt=\"([^\"]*)\"", Pattern.CASE_INSENSITIVE); + Matcher altMatcher = altPattern.matcher(imgTag); + if (altMatcher.find()) { + title = altMatcher.group(1); + } // 下载源图片文件 - InputStream inputStream = downloadImageFile(sourceConnection, downloadUrl); - if (inputStream != null) { - // 获取图片的alt属性作为标题 - String title = "image"; - Pattern altPattern = Pattern.compile("alt=\"([^\"]*)\"", Pattern.CASE_INSENSITIVE); - Matcher altMatcher = altPattern.matcher(imgTag); - if (altMatcher.find()) { - title = altMatcher.group(1); - } + String downloadImageFile = downloadImageFile(sourceConnection, downloadUrl, title); - // 上传图片到目标组织 - String newContentVersionId = uploadImageFile(targetConnection, inputStream, title); - if (newContentVersionId != null) { - // 获取新的ContentDocumentId - String newContentDocumentId = getDocumentId(targetConnection, newContentVersionId); - if (newContentDocumentId != null) { - imageIdMap.put(refId, newContentDocumentId); + if (downloadImageFile != null) { - // 构建新的img标签 (参考Python脚本中的richTextUrl构建方式) - String newImageUrl = targetConnection.getConfig().getServiceEndpoint() + - "/sfc/servlet.shepherd/version/download/" + newContentVersionId; - String updatedImgTag = ""; + // 上传图片到目标组织 + String newContentVersionId = uploadImageFile(targetConnection, downloadImageFile, title); - matcher.appendReplacement(updatedContent, Matcher.quoteReplacement(updatedImgTag)); + if (newContentVersionId != null) { + // 获取新的ContentDocumentId + Map documentId = getDocumentId(targetConnection, newContentVersionId); + String newContentDocumentId = documentId.get("ContentDocumentId"); + String newOwnId = documentId.get("OwnerId"); - // 记录替换日志 - richTextLogService.logRichTextImageReplace( - api, - field, - newContentDocumentId, - null, // recordOwnerId 可以从记录中获取,但此处简化处理 - richTextContent, - refId, // 原图片链接 - newImageUrl, // 新图片链接 - newContentDocumentId // 新文件ID - ); - continue; - } + if (newContentDocumentId != null) { + imageIdMap.put(refId, newContentDocumentId); + + // 构建新的img标签 (参考Python脚本中的richTextUrl构建方式) + String newImageUrl = + "/sfc/servlet.shepherd/version/download/" + newContentVersionId; + String updatedImgTag = ""; + + matcher.appendReplacement(updatedContent, Matcher.quoteReplacement(updatedImgTag)); + + // 记录替换日志 + richTextLogService.logRichTextImageReplace( + api, + field, + newContentDocumentId, + newOwnId, // recordOwnerId 可以从记录中获取,但此处简化处理 + richTextContent, + refId, // 原图片链接 + newImageUrl, // 新图片链接 + newContentDocumentId // 新文件ID + ); + continue; } } + }else { + return null; } // 如果找不到对应关系,保留原始标签 @@ -2909,8 +2951,8 @@ public class DataImportNewServiceImpl implements DataImportNewService { * @return 图片文件数据 * @throws Exception 异常 */ - private InputStream downloadImageFile(PartnerConnection connection, String downloadUrl) throws Exception { - InputStream inputStream = null; + private String downloadImageFile(PartnerConnection connection, String downloadUrl,String title) throws Exception { + String imageServer = null; try { String token = connection.getSessionHeader().getSessionId(); @@ -2919,47 +2961,84 @@ public class DataImportNewServiceImpl implements DataImportNewService { headers.put("connection", "keep-alive"); Response response = HttpUtil.doGet(downloadUrl, null, headers); - assert response.body() != null; - inputStream = response.body().byteStream(); + + if (response.body() != null && response.code() == 200){ + InputStream inputStream = response.body().byteStream(); + imageServer = dumpToRichTextImageServer(title, response, inputStream); + }else { + throw new RuntimeException("下载图片文件时发生错误,URL: " + downloadUrl + ";错误信息:" + response.message()); + } } catch (Exception e) { log.error("下载图片文件时发生错误,URL: {}", downloadUrl, e); return null; } - return inputStream; + return imageServer; + } + + /** + * 保存富文本图片到本地服务器 + * @param response + * @param inputStream + * @throws IOException + */ + private String dumpToRichTextImageServer(String name, Response response, InputStream inputStream) throws IOException { + String path = Const.SERVER_FILE_PATH + "/richTextImages/" + name; + long offset = 0L; + RandomAccessFile accessFile = new RandomAccessFile(path, "rw"); + while (true) { + try { + // 保存到本地 + byte[] buf = new byte[8192]; + int len = 0; + if (offset > 0) { + inputStream.skip(offset); + accessFile.seek(offset); + } + while ((len = inputStream.read(buf)) != -1) { + accessFile.write(buf, 0, len); + offset += len; + } + break; + } catch (Exception e) { + if (offset <= 0) { + throw e; + } + response.close(); + } + } + accessFile.close(); + return path; } /** * 上传图片文件到目标组织 * @param connection 目标组织连接 - * @param inputStream 文件数据 - * @param title 文件标题 += * @param title 文件标题 * @return 新的ContentVersion ID * @throws Exception 异常 */ - private String uploadImageFile(PartnerConnection connection, InputStream inputStream, String title) throws Exception { + private String uploadImageFile(PartnerConnection connection, String filePath, String title) throws Exception { String newId = null; try { int failCount = 0; String token = connection.getSessionHeader().getSessionId(); - String uploadUrl = connection.getConfig().getServiceEndpoint() + + String uploadUrl = FILE_UPLOAD_URL + "/services/data/v55.0/sobjects/ContentVersion"; HttpPost httpPost = new HttpPost(uploadUrl); - Map headers = Maps.newHashMap(); - headers.put("Authorization", "Bearer " + token); - headers.put("connection", "keep-alive"); - + httpPost.setHeader("Authorization", "Bearer " + token); + httpPost.setHeader("connection", "keep-alive"); com.alibaba.fastjson.JSONObject credentialsJsonParam = new com.alibaba.fastjson.JSONObject(); credentialsJsonParam.put("title", title); - credentialsJsonParam.put("pathOnClient", title + ".jpg"); + credentialsJsonParam.put("pathOnClient", title); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("entity_content", credentialsJsonParam.toJSONString(), ContentType.APPLICATION_JSON); - builder.addBinaryBody("VersionData", inputStream, ContentType.APPLICATION_OCTET_STREAM, title + ".jpg"); + builder.addBinaryBody("VersionData", new FileInputStream(filePath), ContentType.APPLICATION_OCTET_STREAM, title + ".jpg"); HttpEntity entity = builder.build(); httpPost.setEntity(entity); @@ -3019,18 +3098,22 @@ public class DataImportNewServiceImpl implements DataImportNewService { } /** - * 获取ContentDocumentId + * 获取ContentDocumentId和OwnerId * @param connection 连接 * @param contentVersionId ContentVersion ID - * @return ContentDocumentId + * @return 包含ContentDocumentId和OwnerId的Map * @throws Exception 异常 */ - private String getDocumentId(PartnerConnection connection, String contentVersionId) throws Exception { - String soql = "SELECT ContentDocumentId FROM ContentVersion WHERE Id = '" + contentVersionId + "'"; + private Map getDocumentId(PartnerConnection connection, String contentVersionId) throws Exception { + String soql = "SELECT ContentDocumentId,OwnerId FROM ContentVersion WHERE Id = '" + contentVersionId + "'"; QueryResult queryResult = connection.query(soql); + Map result = new HashMap<>(); + if (queryResult.getRecords() != null && queryResult.getRecords().length > 0) { SObject record = queryResult.getRecords()[0]; - return (String) record.getField("ContentDocumentId"); + result.put("ContentDocumentId", (String) record.getField("ContentDocumentId")); + result.put("OwnerId", (String) record.getField("OwnerId")); + return result; } return null; } diff --git a/src/main/java/com/celnet/datadump/service/impl/FileServiceImpl.java b/src/main/java/com/celnet/datadump/service/impl/FileServiceImpl.java index 8960f6b..7965a9f 100644 --- a/src/main/java/com/celnet/datadump/service/impl/FileServiceImpl.java +++ b/src/main/java/com/celnet/datadump/service/impl/FileServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.celnet.datadump.config.SalesforceConnect; import com.celnet.datadump.config.SalesforceExecutor; import com.celnet.datadump.config.SalesforceTargetConnect; +import com.celnet.datadump.entity.DataField; import com.celnet.datadump.entity.DataObject; import com.celnet.datadump.enums.FileType; import com.celnet.datadump.global.Const; @@ -16,6 +17,7 @@ import com.celnet.datadump.param.FileTransformParam; import com.celnet.datadump.global.SystemConfigCode; import com.celnet.datadump.mapper.CustomMapper; import com.celnet.datadump.service.*; +import com.celnet.datadump.util.DataUtil; import com.celnet.datadump.util.EmailUtil; import com.celnet.datadump.util.HttpUtil; import com.celnet.datadump.util.OssUtil; @@ -45,10 +47,8 @@ import org.springframework.stereotype.Service; import java.io.*; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.time.LocalDateTime; +import java.util.*; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -154,10 +154,24 @@ public class FileServiceImpl implements FileService { extraSql += "AND IsDeleted = false "; } if (Const.FILE_TYPE == FileType.SERVER) { + Date defaultBeginDate = DataUtil.DEFAULT_BEGIN_DATE; + Calendar calendar = Calendar.getInstance(); + int currentYear = calendar.get(Calendar.YEAR); + calendar.setTime(defaultBeginDate); + int beginYear = calendar.get(Calendar.YEAR); + // 检测路径是否存在 不存在则创建 - File excel = new File(Const.SERVER_FILE_PATH + "/" + api); - if (!excel.exists()) { - boolean mkdir = excel.mkdir(); + File baseDir = new File(Const.SERVER_FILE_PATH + "/" + api); + if (!baseDir.exists()) { + baseDir.mkdirs(); + } + + // 创建从开始年份到当前年份的子目录 + for (int year = beginYear; year <= currentYear; year++) { + File yearDir = new File(Const.SERVER_FILE_PATH + "/" + api + "—" + year); + if (!yearDir.exists()) { + yearDir.mkdir(); + } } } try { @@ -171,7 +185,7 @@ public class FileServiceImpl implements FileService { long num = 0; while (true) { // 获取未存储的附件id - List> list = customMapper.list("Id, " + name, api, extraSql + " AND is_dump = 0 limit 1000"); + List> list = customMapper.list("Id,CreatedDate," + name, api, extraSql + " AND is_dump = 0 limit 1000"); if (CollectionUtils.isEmpty(list)) { log.info("无需要下载文件数据!!!"); break; @@ -194,9 +208,12 @@ public class FileServiceImpl implements FileService { fileName = (String) map.get("Name"); } log.info("------------文件名:"+id + "_" + fileName); + Object createdDateObj = map.get("CreatedDate"); + String year = createdDateObj.toString().substring(0, 4); + // 判断路径是否为空 if (StringUtils.isNotBlank(fileName)) { - String filePath = api + "/" + id + "_" + fileName; + String filePath = api + "-" + year + "/" + id + "_" + fileName; // 拼接url String url = finalDownloadUrl + String.format(Const.SF_FILE_URL, api, id, field); Response response = HttpUtil.doGet(url, null, headers); @@ -468,20 +485,36 @@ public class FileServiceImpl implements FileService { throw new RuntimeException("找不到文件路径"); } } + String selectField = "Id, url, PathOnClient, Title, ContentDocumentId, VersionNumber"; + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("api", api); + wrapper.eq("is_createable",1); + List dataFields = dataFieldService.list(wrapper); + + ArrayList addFieldList = new ArrayList<>(); + for (DataField dataField : dataFields) { + if (!selectField.contains(dataField.getField())){ + selectField += "," + dataField.getField(); + addFieldList.add(dataField.getField()); + } + } + try { List> documentList = customMapper.list("Id", "ContentDocument", "new_id is null"); for (Map documentMap : documentList) { boolean index = false; String documentId = (String) documentMap.get("Id"); + // 获取未存储的附件id - List> list = customMapper.list("Id, url, PathOnClient, Title, ContentDocumentId, VersionNumber", api, "ContentDocumentId = '" + documentId + "' and new_id is null ORDER BY VersionNumber ASC"); + List> list = customMapper.list(selectField, api, "ContentDocumentId = '" + documentId + "' and new_id is null ORDER BY VersionNumber ASC"); if (CollectionUtils.isEmpty(list)) { continue; } String finalUploadUrl = uploadUrl; Future future = salesforceExecutor.execute(() -> { - String newDocumentId = null; - for (Map map : list) { + String newDocumentId = null; + for (Map map : list) { String id = null; // 上传完毕 更新附件信息 List> maps = Lists.newArrayList(); @@ -520,6 +553,11 @@ public class FileServiceImpl implements FileService { if (newDocumentId != null) { credentialsJsonParam.put("ContentDocumentId", newDocumentId); } + if (!addFieldList.isEmpty()){ + for (String s : addFieldList) { + credentialsJsonParam.put(s, map.get(s)); + } + } MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("entity_content", credentialsJsonParam.toJSONString(), ContentType.APPLICATION_JSON); builder.addBinaryBody("VersionData", new FileInputStream(file), ContentType.APPLICATION_OCTET_STREAM, fileName); @@ -655,9 +693,25 @@ public class FileServiceImpl implements FileService { throw new RuntimeException("找不到文件路径"); } } + + String selectField = "Id,url,ParentId,Parent_Type,OwnerId,Description,CreatedById,Name"; + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("api", api); + wrapper.eq("is_createable",1); + List dataFields = dataFieldService.list(wrapper); + + ArrayList addFieldList = new ArrayList<>(); + for (DataField dataField : dataFields) { + if (!selectField.contains(dataField.getField())){ + selectField += "," + dataField.getField(); + addFieldList.add(dataField.getField()); + } + } + try { // 获取未存储的附件id - List> list = customMapper.list("*", api, "is_upload = 0"); + List> list = customMapper.list(selectField, api, "is_upload = 0"); for (Map map : list) { String finalUploadUrl = uploadUrl; Future future = salesforceExecutor.execute(() -> { @@ -678,8 +732,7 @@ public class FileServiceImpl implements FileService { String description = (String) map.get("Description"); String createdById = (String) map.get("CreatedById"); String fileName = (String) map.get("Name"); - log.info("id: {}, url_fileName: {}, parentId: {}, parentType: {}, ownerId: {}, description: {}, createdById: {}", - id, url_fileName, parentId, parentType, ownerId, description, createdById); + // 判断路径是否为空 if (StringUtils.isNotBlank(url_fileName)) { String filePath = Const.SERVER_FILE_PATH + "/" + url_fileName; @@ -771,6 +824,12 @@ public class FileServiceImpl implements FileService { // credentialsJsonParam.put("CreatedDate", map.get("CreatedDate")); credentialsJsonParam.put("CreatedById", cMap.get("new_id")); + if (!addFieldList.isEmpty()){ + for (String s : addFieldList) { + credentialsJsonParam.put(s, map.get(s)); + } + } + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("data", credentialsJsonParam.toJSONString(), ContentType.APPLICATION_JSON); builder.addBinaryBody("Body", new FileInputStream(file), ContentType.APPLICATION_OCTET_STREAM, fileName); @@ -827,7 +886,7 @@ public class FileServiceImpl implements FileService { try { response.close(); } catch (IOException e) { - log.error("exception message", e); + log.error("exception message", e); } } try {