fix:修复本地上传文件源文件名称获取错误;优化订单详情任务新增接口;

This commit is contained in:
chenxiky 2025-07-20 11:11:20 +08:00
parent 140d628768
commit b96e45024d
6 changed files with 46 additions and 24 deletions

View File

@ -21,6 +21,7 @@ import com.aircraft.modules.order.service.IOrderOperatorService;
import com.aircraft.modules.system.domain.AttachmentMaterial;
import com.aircraft.modules.system.domain.EmEmployees;
import com.aircraft.modules.system.domain.EmScenic;
import com.aircraft.modules.system.domain.dto.LocalAttachmentMaterialDTO;
import com.aircraft.modules.system.domain.enums.AttachmentMaterialBusinessTypeEnum;
import com.aircraft.modules.system.service.EmScenicService;
import com.aircraft.modules.system.service.IAttachmentMaterialService;
@ -91,9 +92,9 @@ public class OrderBiz {
public void addOrder(AddOrderDTO addOrderDTO) {
// 获取当前登录用户飞行端用户
EmEmployees emEmployees = JSON.parseObject(SecurityUtils.getCurrentEmployee(), EmEmployees.class);
EmEmployees employees = JSON.parseObject(SecurityUtils.getCurrentEmployee(), EmEmployees.class);
// 发起人ID
Long orderInitiatorId = emEmployees.getId();
Long orderInitiatorId = employees.getId();
// 新增订单
OrderMain orderMain = orderMainService.addOrder(buildOrderParam(addOrderDTO, orderInitiatorId));
// 构建保存操作人信息
@ -152,22 +153,28 @@ public class OrderBiz {
@Transactional(rollbackFor = Exception.class)
public void addOrderTask(AddOrderTaskDTO orderTaskDTO) {
// TODO 获取当前登录用户
Long orderInitiatorId = SecurityUtils.getCurrentUserId();
// 获取当前登录用户
EmEmployees employees = JSON.parseObject(SecurityUtils.getCurrentEmployee(), EmEmployees.class);
Long orderInitiatorId = employees.getId();
// 构建任务参数
OrderDetail orderTask = buildOrderTaskParam(orderTaskDTO, orderInitiatorId);
// 批量新增
orderDetailService.addOrderDetail(orderTask);
// 判断是否存在材料
if (CollectionUtil.isEmpty(orderTaskDTO.getAttachmentMaterialList())) {
return;
}
// 保存材料
AttachmentMaterial attachmentMaterialList = buildAttachmentMaterialParam(orderTaskDTO);
attachmentMaterialService.addAttachmentMaterial(attachmentMaterialList);
List<AttachmentMaterial> attachmentMaterialList = buildAttachmentMaterialParam(orderTaskDTO);
attachmentMaterialService.batchAddAttachmentMaterial(attachmentMaterialList);
}
/**
* 构建任务参数
* 构建订单任务参数
*
* @param orderTaskDTO {@link AddOrderTaskDTO}
* @param orderInitiatorId
* @param orderInitiatorId 当前飞行员ID
* @return {@link OrderDetail}
*/
private OrderDetail buildOrderTaskParam(AddOrderTaskDTO orderTaskDTO, Long orderInitiatorId) {
@ -187,12 +194,20 @@ public class OrderBiz {
* @param orderTaskDTO {@link AddOrderTaskDTO}
* @return {@link AttachmentMaterial}
*/
private AttachmentMaterial buildAttachmentMaterialParam(AddOrderTaskDTO orderTaskDTO) {
private List<AttachmentMaterial> buildAttachmentMaterialParam(AddOrderTaskDTO orderTaskDTO) {
List<AttachmentMaterial> materialList = new ArrayList<>();
for (LocalAttachmentMaterialDTO materialDTO : orderTaskDTO.getAttachmentMaterialList()) {
AttachmentMaterial attachmentMaterial = new AttachmentMaterial();
attachmentMaterial.setBusinessId(orderTaskDTO.getOrderId());
attachmentMaterial.setBusinessType(AttachmentMaterialBusinessTypeEnum.ORDER_TASK_MATERIAL.getCode());
attachmentMaterial.setFileFullPath(orderTaskDTO.getPicUrl());
return attachmentMaterial;
attachmentMaterial.setFileType(materialDTO.getFileType());
attachmentMaterial.setSourceFileName(materialDTO.getSourceFileName());
attachmentMaterial.setNewFileName(materialDTO.getNewFileName());
attachmentMaterial.setFileSize(materialDTO.getFileSize());
attachmentMaterial.setFileFullPath(materialDTO.getFileFullPath());
materialList.add(attachmentMaterial);
}
return materialList;
}
/**

View File

@ -53,7 +53,7 @@ public class OrderMainController {
@ApiOperation("新增订单任务")
@PostMapping("/addOrderTask")
public ResponseEntity<Object> addOrderTask(AddOrderTaskDTO orderTaskDTO) {
public ResponseEntity<Object> addOrderTask(@RequestBody @Validated AddOrderTaskDTO orderTaskDTO) {
orderBiz.addOrderTask(orderTaskDTO);
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@ -1,10 +1,12 @@
package com.aircraft.modules.order.domain.dto;
import com.aircraft.modules.system.domain.dto.LocalAttachmentMaterialDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
/**
*
@ -46,8 +48,8 @@ public class AddOrderTaskDTO {
private BigDecimal cargoWeight;
/**
* 任务上传的图片全路径URL
* 图片材料List
*/
@ApiModelProperty(value = "任务上传的图片全路径URL")
private String picUrl;
@ApiModelProperty(value = "图片材料List集合")
private List<LocalAttachmentMaterialDTO> attachmentMaterialList;
}

View File

@ -3,6 +3,8 @@ package com.aircraft.modules.system.service;
import com.aircraft.modules.system.domain.AttachmentMaterial;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
@ -14,8 +16,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
public interface IAttachmentMaterialService extends IService<AttachmentMaterial> {
/**
* 新增材料
* @param attachmentMaterial
* 批量新增材料
*
* @param attachmentMaterialList {@link List<AttachmentMaterial>}
*/
void addAttachmentMaterial(AttachmentMaterial attachmentMaterial);
void batchAddAttachmentMaterial(List<AttachmentMaterial> attachmentMaterialList);
}

View File

@ -6,6 +6,8 @@ import com.aircraft.modules.system.service.IAttachmentMaterialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
@ -18,7 +20,7 @@ import org.springframework.stereotype.Service;
public class AttachmentMaterialServiceImpl extends ServiceImpl<AttachmentMaterialMapper, AttachmentMaterial> implements IAttachmentMaterialService {
@Override
public void addAttachmentMaterial(AttachmentMaterial attachmentMaterial) {
this.save(attachmentMaterial);
public void batchAddAttachmentMaterial(List<AttachmentMaterial> attachmentMaterialList) {
this.saveBatch(attachmentMaterialList);
}
}

View File

@ -65,7 +65,7 @@ public class LocalStorageController {
@PostMapping
@ApiOperation("上传文件")
public ResponseEntity<Object> createFile(@RequestPart("file") MultipartFile file){
LocalStorage localStorage = localStorageService.create(file.getName(), file);
LocalStorage localStorage = localStorageService.create(file.getOriginalFilename(), file);
LocalAttachmentMaterialDTO localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO();
localAttachmentMaterialDTO.setFileType(localStorage.getSuffix());
localAttachmentMaterialDTO.setFileSize(file.getSize());