【fix】修复文件上传异常
This commit is contained in:
parent
823f810702
commit
7ccfb5ec45
@ -5,7 +5,7 @@
|
|||||||
#dbUsername="root"
|
#dbUsername="root"
|
||||||
#dbPassword="celnet@2025.bln"
|
#dbPassword="celnet@2025.bln"
|
||||||
#携科
|
#携科
|
||||||
dbUrl="jdbc:mysql://127.0.0.1:3306/data-dump-xxl-job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false"
|
dbUrl="jdbc:mysql://127.0.0.1:3306/data-dump-xxl-job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai"
|
||||||
dbUsername="root"
|
dbUsername="root"
|
||||||
dbPassword="Celnet2025.QY"
|
dbPassword="Celnet2025.QY"
|
||||||
#其它
|
#其它
|
||||||
|
@ -1,24 +1,37 @@
|
|||||||
package com.celnet.datadump.controller;
|
package com.celnet.datadump.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.celnet.datadump.entity.DataObject;
|
||||||
import com.celnet.datadump.entity.OrgConfig;
|
import com.celnet.datadump.entity.OrgConfig;
|
||||||
import com.celnet.datadump.global.Result;
|
import com.celnet.datadump.global.Result;
|
||||||
|
import com.celnet.datadump.param.DumpFileParam;
|
||||||
|
import com.celnet.datadump.service.DataObjectService;
|
||||||
import com.celnet.datadump.service.FileManagerService;
|
import com.celnet.datadump.service.FileManagerService;
|
||||||
|
import com.celnet.datadump.service.FileService;
|
||||||
|
import com.celnet.datadump.util.DataUtil;
|
||||||
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
|
import com.xxl.job.core.log.XxlJobLogger;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Api(value = "fileManager", tags = "文件管理")
|
@Api(value = "fileManager", tags = "文件管理")
|
||||||
@RequestMapping("/fileManager")
|
@RequestMapping("/fileManager")
|
||||||
|
@Slf4j
|
||||||
public class FileManagerController {
|
public class FileManagerController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileManagerService fileManagerService;
|
private FileManagerService fileManagerService;
|
||||||
|
@Autowired
|
||||||
|
private FileService fileService;
|
||||||
|
@Autowired
|
||||||
|
private DataObjectService dataObjectService;
|
||||||
|
|
||||||
@GetMapping("/documentPage")
|
@GetMapping("/documentPage")
|
||||||
@ApiOperation("document page")
|
@ApiOperation("document page")
|
||||||
@ -45,4 +58,62 @@ public class FileManagerController {
|
|||||||
public Result uploadImg(@RequestParam("token") String token) {
|
public Result uploadImg(@RequestParam("token") String token) {
|
||||||
return Result.success(fileManagerService.uploadImg(token));
|
return Result.success(fileManagerService.uploadImg(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/dumpFileLocal")
|
||||||
|
@ApiOperation("附件下载")
|
||||||
|
public ReturnT<String> dumpFileLocal(String paramStr) throws Exception {
|
||||||
|
log.info("dumpFileLocal execute start ..................");
|
||||||
|
DumpFileParam param = new DumpFileParam();
|
||||||
|
try {
|
||||||
|
if (StringUtils.isNotBlank(paramStr)) {
|
||||||
|
param = JSON.parseObject(paramStr, DumpFileParam.class);
|
||||||
|
}
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
return new ReturnT<>(500, "参数解析失败!");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(param.getApi())) {
|
||||||
|
return new ReturnT<>(500, "api参数缺失!");
|
||||||
|
}
|
||||||
|
for (String api : DataUtil.toIdList(param.getApi())) {
|
||||||
|
DataObject dataObject = dataObjectService.getById(api);
|
||||||
|
String blobField = dataObject.getBlobField();
|
||||||
|
if (StringUtils.isBlank(blobField)) {
|
||||||
|
log.error("api:{} does not have blob field", api);
|
||||||
|
XxlJobLogger.log("api:{} does not have blob field", api);
|
||||||
|
}
|
||||||
|
fileService.dumpFile(api, blobField, param.getSingleThread());
|
||||||
|
}
|
||||||
|
return ReturnT.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/uploadFileLocal")
|
||||||
|
@ApiOperation("附件上传")
|
||||||
|
public ReturnT<String> uploadFileLocal(String paramStr) throws Exception {
|
||||||
|
log.info("uploadFileJob execute start ..................");
|
||||||
|
DumpFileParam param = new DumpFileParam();
|
||||||
|
try {
|
||||||
|
if (StringUtils.isNotBlank(paramStr)) {
|
||||||
|
param = JSON.parseObject(paramStr, DumpFileParam.class);
|
||||||
|
}
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
return new ReturnT<>(500, "参数解析失败!");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(param.getApi())) {
|
||||||
|
return new ReturnT<>(500, "api参数缺失!");
|
||||||
|
}
|
||||||
|
for (String api : DataUtil.toIdList(param.getApi())) {
|
||||||
|
DataObject dataObject = dataObjectService.getById(api);
|
||||||
|
String blobField = dataObject.getBlobField();
|
||||||
|
if (StringUtils.isBlank(blobField)) {
|
||||||
|
log.error("api:{} does not have blob field", api);
|
||||||
|
XxlJobLogger.log("api:{} does not have blob field", api);
|
||||||
|
}
|
||||||
|
if ("Attachment".equals(api)){
|
||||||
|
fileService.uploadFileToAttachment(api, blobField, param.getSingleThread());
|
||||||
|
}else {
|
||||||
|
fileService.uploadFile(api, blobField, param.getSingleThread());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ReturnT.SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,12 +50,12 @@ public class Const {
|
|||||||
/**
|
/**
|
||||||
* sf 下载文件链接
|
* sf 下载文件链接
|
||||||
*/
|
*/
|
||||||
public static final String SF_FILE_URL = "/services/data/v55.0/sobjects/%s/%s/%s";
|
public static final String SF_FILE_URL = "/services/data/v56.0/sobjects/%s/%s/%s";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sf 上传文件链接
|
* sf 上传文件链接
|
||||||
*/
|
*/
|
||||||
public static final String SF_UPLOAD_FILE_URL = "/services/data/v55.0/sobjects/%s";
|
public static final String SF_UPLOAD_FILE_URL = "/services/data/v56.0/sobjects/%s";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sf 获取富文本图片链接
|
* sf 获取富文本图片链接
|
||||||
|
@ -522,7 +522,7 @@ public class FileServiceImpl implements FileService {
|
|||||||
HttpEntity he = response.getEntity();
|
HttpEntity he = response.getEntity();
|
||||||
if (he != null) {
|
if (he != null) {
|
||||||
respContent = EntityUtils.toString(he, "UTF-8");
|
respContent = EntityUtils.toString(he, "UTF-8");
|
||||||
String newId = String.valueOf(JSONObject.parseObject(respContent).get("Id"));
|
String newId = String.valueOf(JSONObject.parseObject(respContent).get("id"));
|
||||||
if (StringUtils.isBlank(newId)) {
|
if (StringUtils.isBlank(newId)) {
|
||||||
log.error("文件上传错误,返回实体信息:" + respContent);
|
log.error("文件上传错误,返回实体信息:" + respContent);
|
||||||
break;
|
break;
|
||||||
|
@ -3,7 +3,7 @@ spring:
|
|||||||
type: com.zaxxer.hikari.HikariDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
# 携科
|
# 携科
|
||||||
url: jdbc:mysql://127.0.0.1:3306/xieke?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://127.0.0.1:3306/xieke?useUnicode=true&allowPublicKeyRetrieval=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: Celnet2025.QY
|
password: Celnet2025.QY
|
||||||
# cook
|
# cook
|
||||||
@ -22,7 +22,7 @@ spring:
|
|||||||
sf:
|
sf:
|
||||||
# 附件下载url
|
# 附件下载url
|
||||||
file-download-url: https://d2000000079c7eaa.lightning.force.com
|
file-download-url: https://d2000000079c7eaa.lightning.force.com
|
||||||
file-upload-url: https://steco-process.lightning.sfcrmapps.cn
|
file-upload-url: https://steco-process.my.sfcrmproducts.cn
|
||||||
#线程数
|
#线程数
|
||||||
executor-size: 5
|
executor-size: 5
|
||||||
list:
|
list:
|
||||||
|
Loading…
Reference in New Issue
Block a user