优化了sdk的feign请求超时变量
This commit is contained in:
@ -212,8 +212,7 @@ public class DefaultAttachmentClient implements AttachmentClient {
|
|||||||
public Optional<UploadObject> upload(@NotNull String businessId, @NotNull String filename, @NotNull byte[] array) {
|
public Optional<UploadObject> upload(@NotNull String businessId, @NotNull String filename, @NotNull byte[] array) {
|
||||||
removeDuplicateObject(businessId, filename);
|
removeDuplicateObject(businessId, filename);
|
||||||
|
|
||||||
String res = documentCenterService.upload("ebtp-mall-cloud", businessId,
|
String res = documentCenterService.upload("ebtp-mall-cloud", businessId, fileConvertor.toMultipartFile(filename, array));
|
||||||
fileConvertor.toMultipartFile(filename, array));
|
|
||||||
|
|
||||||
log.info("document center upload result: {}", res);
|
log.info("document center upload result: {}", res);
|
||||||
|
|
||||||
@ -255,7 +254,7 @@ public class DefaultAttachmentClient implements AttachmentClient {
|
|||||||
* @param filename
|
* @param filename
|
||||||
*/
|
*/
|
||||||
private void removeDuplicateObject(String businessId, String filename) {
|
private void removeDuplicateObject(String businessId, String filename) {
|
||||||
log.info("remove duplicate name files {} in business: {}", filename, businessId);
|
log.info("remove files {} in business: {} if exists", filename, businessId);
|
||||||
Optional<AttachmentDetail> op = findByBusinessId(Arrays.asList(businessId));
|
Optional<AttachmentDetail> op = findByBusinessId(Arrays.asList(businessId));
|
||||||
|
|
||||||
op.ifPresent(detail -> {
|
op.ifPresent(detail -> {
|
||||||
|
@ -45,12 +45,14 @@ public class ModelConvertor {
|
|||||||
AttachmentEntity entity = null;
|
AttachmentEntity entity = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SysStorageVO vo = tpDownPO(content);
|
Optional<SysStorageVO> op = tpDownPO(content);
|
||||||
log.debug("convert to model: {}", vo);
|
|
||||||
|
|
||||||
|
if (op.isPresent()) {
|
||||||
|
SysStorageVO vo = op.get();
|
||||||
entity = new AttachmentEntity();
|
entity = new AttachmentEntity();
|
||||||
entity.setId(vo.getFileId()).setFilename(vo.getOriginalName()).setBid(vo.getObjectId())
|
entity.setId(vo.getFileId()).setFilename(vo.getOriginalName()).setBid(vo.getObjectId())
|
||||||
.setKey(vo.getFileName());
|
.setKey(vo.getFileName());
|
||||||
|
}
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
log.error(json);
|
log.error(json);
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
@ -82,7 +84,11 @@ public class ModelConvertor {
|
|||||||
public Optional<byte[]> toByteArray(String json) {
|
public Optional<byte[]> toByteArray(String json) {
|
||||||
return Optional.ofNullable(json).map(content -> {
|
return Optional.ofNullable(json).map(content -> {
|
||||||
try {
|
try {
|
||||||
return tpDownPO(content).getFileStream();
|
Optional<SysStorageVO> op = tpDownPO(content);
|
||||||
|
|
||||||
|
if (op.isPresent()) {
|
||||||
|
return op.get().getFileStream();
|
||||||
|
}
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
log.error(json);
|
log.error(json);
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
@ -99,18 +105,20 @@ public class ModelConvertor {
|
|||||||
return Optional.ofNullable(json).map(content -> {
|
return Optional.ofNullable(json).map(content -> {
|
||||||
DownloadEntity entity = null;
|
DownloadEntity entity = null;
|
||||||
try {
|
try {
|
||||||
SysStorageVO vo = tpDownPO(content);
|
Optional<SysStorageVO> op = tpDownPO(content);
|
||||||
|
|
||||||
|
if (op.isPresent()) {
|
||||||
|
SysStorageVO vo = op.get();
|
||||||
entity = new DownloadEntity();
|
entity = new DownloadEntity();
|
||||||
entity.setFilename(URLEncoder.DEFAULT.encode(vo.getOriginalName(), Charset.forName("UTF-8")))
|
entity.setFilename(URLEncoder.DEFAULT.encode(vo.getOriginalName(), Charset.forName("UTF-8")))
|
||||||
.setStream(vo.getFileStream());
|
.setStream(vo.getFileStream());
|
||||||
|
}
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
log.error(json);
|
log.error(json);
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,10 +146,10 @@ public class ModelConvertor {
|
|||||||
* @throws JsonMappingException
|
* @throws JsonMappingException
|
||||||
* @throws JsonProcessingException
|
* @throws JsonProcessingException
|
||||||
*/
|
*/
|
||||||
private SysStorageVO tpDownPO(String json) throws JsonMappingException, JsonProcessingException {
|
private Optional<SysStorageVO> tpDownPO(String json) throws JsonMappingException, JsonProcessingException {
|
||||||
log.debug("current convertor json is: {}", json);
|
log.debug("current convertor json is: {}", json);
|
||||||
return Optional.ofNullable(objectMapper.readValue(json, DownStream.class)).map(ds -> ds.getData())
|
return Optional.ofNullable(objectMapper.readValue(json, DownStream.class)).map(ds -> ds.getData())
|
||||||
.map(data -> data.getSysStorageVO()).orElseGet(SysStorageVO::new);
|
.map(data -> data.getSysStorageVO());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
ribbon.ReadTimeout=1800000
|
feign.hystrix.enabled=true
|
||||||
ribbon.SocketTimeout=1800000
|
feign.client.config.default.retryer=feign.Retryer.Default
|
||||||
|
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=600000
|
||||||
|
|
||||||
# document center id
|
# document center id
|
||||||
document.center.service.id=core-service-document-center
|
document.center.service.id=core-service-document-center
|
||||||
|
Reference in New Issue
Block a user