|
@ -9,6 +9,7 @@ import org.dom4j.DocumentException; |
|
|
import org.dom4j.Node; |
|
|
import org.dom4j.Node; |
|
|
import org.dom4j.io.SAXReader; |
|
|
import org.dom4j.io.SAXReader; |
|
|
import org.dromara.common.oss.core.OssClient; |
|
|
import org.dromara.common.oss.core.OssClient; |
|
|
|
|
|
import org.dromara.common.oss.entity.UploadResult; |
|
|
import org.dromara.common.oss.factory.OssFactory; |
|
|
import org.dromara.common.oss.factory.OssFactory; |
|
|
import org.dromara.common.sdk.cloudapi.device.DeviceDomainEnum; |
|
|
import org.dromara.common.sdk.cloudapi.device.DeviceDomainEnum; |
|
|
import org.dromara.common.sdk.cloudapi.device.DeviceEnum; |
|
|
import org.dromara.common.sdk.cloudapi.device.DeviceEnum; |
|
@ -108,7 +109,7 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
if (waylineOpt.isEmpty()) { |
|
|
if (waylineOpt.isEmpty()) { |
|
|
throw new SQLException(waylineId + " 不存在。"); |
|
|
throw new SQLException(waylineId + " 不存在。"); |
|
|
} |
|
|
} |
|
|
OssClient storage = OssFactory.instance("wayline_file"); |
|
|
OssClient storage = OssFactory.instance("waylinefile"); |
|
|
return storage.getPrivateUrlURL(waylineOpt.get().getObjectKey(), 3600); |
|
|
return storage.getPrivateUrlURL(waylineOpt.get().getObjectKey(), 3600); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -119,12 +120,12 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
file.setWorkspaceId(workspaceId); |
|
|
file.setWorkspaceId(workspaceId); |
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(file.getSign())) { |
|
|
if (!StringUtils.hasText(file.getSign())) { |
|
|
OssClient storage = OssFactory.instance("wayline_file"); |
|
|
OssClient storage = OssFactory.instance("waylinefile"); |
|
|
String privateUrl = storage.getPrivateUrl(metadata.getObjectKey(), 3600); |
|
|
String privateUrl = storage.getPrivateUrl(metadata.getObjectKey(), 3600); |
|
|
try (InputStream object = storage.getObjectContent(privateUrl)) { |
|
|
try (InputStream object = storage.getObjectContent(privateUrl)) { |
|
|
if (object.available() == 0) { |
|
|
if (object.available() == 0) { |
|
|
throw new RuntimeException("文件 " + metadata.getObjectKey() + |
|
|
throw new RuntimeException("文件 " + metadata.getObjectKey() + |
|
|
" 桶中不存在[ wayline_file ]."); |
|
|
" 桶中不存在[ waylinefile ]."); |
|
|
} |
|
|
} |
|
|
file.setSign(DigestUtils.md5DigestAsHex(object)); |
|
|
file.setSign(DigestUtils.md5DigestAsHex(object)); |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
@ -173,7 +174,7 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
if (!isDel) { |
|
|
if (!isDel) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
OssClient storage = OssFactory.instance("wayline_file"); |
|
|
OssClient storage = OssFactory.instance("waylinefile"); |
|
|
storage.delete(wayline.getObjectKey()); |
|
|
storage.delete(wayline.getObjectKey()); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -187,10 +188,11 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
try { |
|
|
try { |
|
|
WaylineFileDTO waylineFile = waylineFileOpt.get(); |
|
|
WaylineFileDTO waylineFile = waylineFileOpt.get(); |
|
|
waylineFile.setUsername(creator); |
|
|
waylineFile.setUsername(creator); |
|
|
OssClient storage = OssFactory.instance("wayline_file"); |
|
|
OssClient storage = OssFactory.instance("waylinefile"); |
|
|
String originalfileName = file.getOriginalFilename(); |
|
|
String originalfileName = file.getOriginalFilename(); |
|
|
String suffix = org.apache.commons.lang3.StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); |
|
|
String suffix = org.apache.commons.lang3.StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length()); |
|
|
storage.uploadSuffix( file.getBytes(),suffix,file.getContentType()); |
|
|
UploadResult uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType()); |
|
|
|
|
|
waylineFile.setObjectKey(uploadResult.getFilename()); |
|
|
this.saveWaylineFile(workspaceId, waylineFile); |
|
|
this.saveWaylineFile(workspaceId, waylineFile); |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
@ -236,7 +238,7 @@ public class WaylineFileServiceImpl implements IWaylineFileService { |
|
|
DeviceTypeEnum payloadType = DeviceTypeEnum.find(Integer.parseInt(payloadNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_ENUM_VALUE))); |
|
|
DeviceTypeEnum payloadType = DeviceTypeEnum.find(Integer.parseInt(payloadNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_ENUM_VALUE))); |
|
|
DeviceSubTypeEnum payloadSubType = DeviceSubTypeEnum.find(Integer.parseInt(payloadNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_SUB_ENUM_VALUE))); |
|
|
DeviceSubTypeEnum payloadSubType = DeviceSubTypeEnum.find(Integer.parseInt(payloadNode.valueOf(KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_PAYLOAD_SUB_ENUM_VALUE))); |
|
|
String templateType = document.valueOf("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_TEMPLATE_TYPE); |
|
|
String templateType = document.valueOf("//" + KmzFileProperties.TAG_WPML_PREFIX + KmzFileProperties.TAG_TEMPLATE_TYPE); |
|
|
OssClient storage = OssFactory.instance("wayline_file"); |
|
|
OssClient storage = OssFactory.instance("waylinefile"); |
|
|
return Optional.of(WaylineFileDTO.builder() |
|
|
return Optional.of(WaylineFileDTO.builder() |
|
|
.droneModelKey(DeviceEnum.find(DeviceDomainEnum.DRONE, type, subType).getDevice()) |
|
|
.droneModelKey(DeviceEnum.find(DeviceDomainEnum.DRONE, type, subType).getDevice()) |
|
|
.payloadModelKeys(List.of(DeviceEnum.find(DeviceDomainEnum.PAYLOAD, payloadType, payloadSubType).getDevice())) |
|
|
.payloadModelKeys(List.of(DeviceEnum.find(DeviceDomainEnum.PAYLOAD, payloadType, payloadSubType).getDevice())) |
|
|