fix(dingdansu)
This commit is contained in:
+83
-14
@@ -151,27 +151,45 @@ public class OrderFileController {
|
||||
log.warn("参数为空,orderFile: {}", orderFile);
|
||||
return Result.failed(orderFile,"参数为空");
|
||||
}
|
||||
|
||||
// 校验订单是否存在
|
||||
Order order = orderService.getOrderByNumber(orderFile.getOrderNo());
|
||||
if (order == null) {
|
||||
log.warn("订单不存在,订单号: {}", orderFile.getOrderNo());
|
||||
return Result.failed(orderFile,"订单不存在");
|
||||
}
|
||||
orderFile.setOrderNo(order.getOrderNo());
|
||||
orderFile.setUserId(order.getUserId());
|
||||
if (orderFile.getFilePath() != null) {
|
||||
FileInfo fileInfo = fileCenterService.creatFileInfo(orderFile.getFilePath());
|
||||
if (fileInfo == null) {
|
||||
log.warn("文件信息创建失败,filePath: {}", orderFile.getFilePath());
|
||||
return Result.failed(orderFile,"文件信息创建失败");
|
||||
}
|
||||
orderFile.setFileId(fileInfo.getId());
|
||||
orderFile.setFilePath(fileInfo.getPath());
|
||||
orderFile.setFileType(fileInfo.getContentType());
|
||||
orderFile.setTourismId(order.getTourismId());
|
||||
} else {
|
||||
|
||||
// 校验文件路径是否为空
|
||||
if (orderFile.getFilePath() == null || orderFile.getFilePath().trim().isEmpty()) {
|
||||
log.warn("素材路径为空,订单号: {}", orderFile.getOrderNo());
|
||||
return Result.failed(orderFile,"素材路径为空");
|
||||
}
|
||||
|
||||
// 先校验记录是否已经存在
|
||||
OrderFile existingOrderFile = orderFileService.getOrderFileByFilePath(orderFile.getFilePath());
|
||||
if (existingOrderFile != null) {
|
||||
log.info("记录已存在,不再重复创建,订单号: {}, 文件路径: {}", orderFile.getOrderNo(), orderFile.getFilePath());
|
||||
return Result.succeed(existingOrderFile, "记录已存在,无需重复创建");
|
||||
}
|
||||
|
||||
// 设置订单相关信息
|
||||
orderFile.setOrderNo(order.getOrderNo());
|
||||
orderFile.setUserId(order.getUserId());
|
||||
|
||||
// 创建文件信息
|
||||
FileInfo fileInfo = fileCenterService.creatFileInfo(orderFile.getFilePath());
|
||||
if (fileInfo == null) {
|
||||
log.warn("文件信息创建失败,filePath: {}", orderFile.getFilePath());
|
||||
return Result.failed(orderFile,"文件信息创建失败");
|
||||
}
|
||||
|
||||
// 设置文件相关信息
|
||||
orderFile.setFileId(fileInfo.getId());
|
||||
orderFile.setFilePath(fileInfo.getPath());
|
||||
orderFile.setFileType(fileInfo.getContentType());
|
||||
orderFile.setTourismId(order.getTourismId());
|
||||
|
||||
// 保存记录
|
||||
boolean saved = orderFileService.save(orderFile);
|
||||
if (saved) {
|
||||
// 机库上报订单素材,更新订单状态为素材上传中,如果订单为设备执行中则更新,否则说明状态已更新
|
||||
@@ -181,7 +199,7 @@ public class OrderFileController {
|
||||
orderService.updateOrder(order);
|
||||
}
|
||||
log.info("素材记录创建成功,订单号: {}, 文件ID: {}", orderFile.getOrderNo(), orderFile.getFileId());
|
||||
return Result.succeed(orderFile, "更新成功");
|
||||
return Result.succeed(orderFile, "创建成功");
|
||||
} else {
|
||||
log.error("素材记录保存失败,订单号: {}", orderFile.getOrderNo());
|
||||
return Result.failed(orderFile,"素材记录保存失败");
|
||||
@@ -203,4 +221,55 @@ public class OrderFileController {
|
||||
|
||||
}
|
||||
|
||||
@Operation(summary = "根据文件路径查询订单文件记录是否存在")
|
||||
@GetMapping("/path/{filePath}")
|
||||
public Result<OrderFile> getOrderFileByFilePath(@PathVariable("filePath") String filePath) {
|
||||
try {
|
||||
if (filePath == null || filePath.trim().isEmpty()) {
|
||||
return Result.failed("文件路径不能为空");
|
||||
}
|
||||
|
||||
OrderFile orderFile = orderFileService.getOrderFileByFilePath(filePath);
|
||||
if (orderFile == null) {
|
||||
return Result.failed("未找到对应的订单文件记录");
|
||||
}
|
||||
|
||||
// 设置文件查看URL
|
||||
orderFile.setViewUrl(fileCenterService.getViewUrlByPath(orderFile.getFilePath()));
|
||||
|
||||
// 设置压缩文件查看URL
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
fileMap.put("path", orderFile.getFilePath());
|
||||
orderFile.setZipViewUrl(fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
|
||||
return Result.succeed(orderFile, "记录已存在");
|
||||
} catch (Exception e) {
|
||||
log.error("根据文件路径查询订单文件记录失败: filePath={}", filePath, e);
|
||||
return Result.failed("查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "检查文件路径对应的订单文件记录是否存在")
|
||||
@GetMapping("/exists/{filePath}")
|
||||
public Result<Boolean> checkOrderFileExists(@PathVariable("filePath") String filePath) {
|
||||
try {
|
||||
if (filePath == null || filePath.trim().isEmpty()) {
|
||||
return Result.failed("文件路径不能为空");
|
||||
}
|
||||
|
||||
OrderFile orderFile = orderFileService.getOrderFileByFilePath(filePath);
|
||||
boolean exists = orderFile != null;
|
||||
|
||||
if (exists) {
|
||||
return Result.succeed(true, "记录已存在");
|
||||
} else {
|
||||
return Result.succeed(false, "记录不存在");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("检查文件路径对应的订单文件记录是否存在失败: filePath={}", filePath, e);
|
||||
return Result.failed("检查失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -84,5 +84,12 @@ public interface IOrderFileService extends ISuperService<OrderFile> {
|
||||
* 获取订单图片文件
|
||||
*/
|
||||
List<OrderFile> getOrderImageFiles(String orderNo);
|
||||
|
||||
/**
|
||||
* 根据文件路径查询订单文件资源
|
||||
* @param filePath 文件路径
|
||||
* @return 订单文件资源
|
||||
*/
|
||||
OrderFile getOrderFileByFilePath(String filePath);
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -103,4 +103,19 @@ public class OrderFileServiceImpl extends SuperServiceImpl<OrderFileMapper, Orde
|
||||
.orderByAsc("create_time"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderFile getOrderFileByFilePath(String filePath) {
|
||||
try {
|
||||
log.debug("根据文件路径查询订单文件: filePath={}", filePath);
|
||||
return baseMapper.selectOne(
|
||||
new QueryWrapper<OrderFile>()
|
||||
.eq("file_path", filePath)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("根据文件路径查询订单文件失败: filePath={}", filePath, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user