fix:修复本地上传文件源文件名称获取错误;优化订单详情任务新增接口;
This commit is contained in:
parent
140d628768
commit
b96e45024d
@ -21,6 +21,7 @@ import com.aircraft.modules.order.service.IOrderOperatorService;
|
|||||||
import com.aircraft.modules.system.domain.AttachmentMaterial;
|
import com.aircraft.modules.system.domain.AttachmentMaterial;
|
||||||
import com.aircraft.modules.system.domain.EmEmployees;
|
import com.aircraft.modules.system.domain.EmEmployees;
|
||||||
import com.aircraft.modules.system.domain.EmScenic;
|
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.domain.enums.AttachmentMaterialBusinessTypeEnum;
|
||||||
import com.aircraft.modules.system.service.EmScenicService;
|
import com.aircraft.modules.system.service.EmScenicService;
|
||||||
import com.aircraft.modules.system.service.IAttachmentMaterialService;
|
import com.aircraft.modules.system.service.IAttachmentMaterialService;
|
||||||
@ -91,9 +92,9 @@ public class OrderBiz {
|
|||||||
public void addOrder(AddOrderDTO addOrderDTO) {
|
public void addOrder(AddOrderDTO addOrderDTO) {
|
||||||
|
|
||||||
// 获取当前登录用户(飞行端用户)
|
// 获取当前登录用户(飞行端用户)
|
||||||
EmEmployees emEmployees = JSON.parseObject(SecurityUtils.getCurrentEmployee(), EmEmployees.class);
|
EmEmployees employees = JSON.parseObject(SecurityUtils.getCurrentEmployee(), EmEmployees.class);
|
||||||
// 发起人ID
|
// 发起人ID
|
||||||
Long orderInitiatorId = emEmployees.getId();
|
Long orderInitiatorId = employees.getId();
|
||||||
// 新增订单
|
// 新增订单
|
||||||
OrderMain orderMain = orderMainService.addOrder(buildOrderParam(addOrderDTO, orderInitiatorId));
|
OrderMain orderMain = orderMainService.addOrder(buildOrderParam(addOrderDTO, orderInitiatorId));
|
||||||
// 构建保存操作人信息
|
// 构建保存操作人信息
|
||||||
@ -152,22 +153,28 @@ public class OrderBiz {
|
|||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void addOrderTask(AddOrderTaskDTO orderTaskDTO) {
|
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);
|
OrderDetail orderTask = buildOrderTaskParam(orderTaskDTO, orderInitiatorId);
|
||||||
// 批量新增
|
// 批量新增
|
||||||
orderDetailService.addOrderDetail(orderTask);
|
orderDetailService.addOrderDetail(orderTask);
|
||||||
|
|
||||||
|
// 判断是否存在材料
|
||||||
|
if (CollectionUtil.isEmpty(orderTaskDTO.getAttachmentMaterialList())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 保存材料
|
// 保存材料
|
||||||
AttachmentMaterial attachmentMaterialList = buildAttachmentMaterialParam(orderTaskDTO);
|
List<AttachmentMaterial> attachmentMaterialList = buildAttachmentMaterialParam(orderTaskDTO);
|
||||||
attachmentMaterialService.addAttachmentMaterial(attachmentMaterialList);
|
attachmentMaterialService.batchAddAttachmentMaterial(attachmentMaterialList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建任务参数
|
* 构建订单任务参数
|
||||||
*
|
*
|
||||||
* @param orderTaskDTO {@link AddOrderTaskDTO}
|
* @param orderTaskDTO {@link AddOrderTaskDTO}
|
||||||
* @param orderInitiatorId
|
* @param orderInitiatorId 当前飞行员ID
|
||||||
* @return {@link OrderDetail}
|
* @return {@link OrderDetail}
|
||||||
*/
|
*/
|
||||||
private OrderDetail buildOrderTaskParam(AddOrderTaskDTO orderTaskDTO, Long orderInitiatorId) {
|
private OrderDetail buildOrderTaskParam(AddOrderTaskDTO orderTaskDTO, Long orderInitiatorId) {
|
||||||
@ -187,12 +194,20 @@ public class OrderBiz {
|
|||||||
* @param orderTaskDTO {@link AddOrderTaskDTO}
|
* @param orderTaskDTO {@link AddOrderTaskDTO}
|
||||||
* @return {@link AttachmentMaterial}
|
* @return {@link AttachmentMaterial}
|
||||||
*/
|
*/
|
||||||
private AttachmentMaterial buildAttachmentMaterialParam(AddOrderTaskDTO orderTaskDTO) {
|
private List<AttachmentMaterial> buildAttachmentMaterialParam(AddOrderTaskDTO orderTaskDTO) {
|
||||||
AttachmentMaterial attachmentMaterial = new AttachmentMaterial();
|
List<AttachmentMaterial> materialList = new ArrayList<>();
|
||||||
attachmentMaterial.setBusinessId(orderTaskDTO.getOrderId());
|
for (LocalAttachmentMaterialDTO materialDTO : orderTaskDTO.getAttachmentMaterialList()) {
|
||||||
attachmentMaterial.setBusinessType(AttachmentMaterialBusinessTypeEnum.ORDER_TASK_MATERIAL.getCode());
|
AttachmentMaterial attachmentMaterial = new AttachmentMaterial();
|
||||||
attachmentMaterial.setFileFullPath(orderTaskDTO.getPicUrl());
|
attachmentMaterial.setBusinessId(orderTaskDTO.getOrderId());
|
||||||
return attachmentMaterial;
|
attachmentMaterial.setBusinessType(AttachmentMaterialBusinessTypeEnum.ORDER_TASK_MATERIAL.getCode());
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ public class OrderMainController {
|
|||||||
|
|
||||||
@ApiOperation("新增订单任务")
|
@ApiOperation("新增订单任务")
|
||||||
@PostMapping("/addOrderTask")
|
@PostMapping("/addOrderTask")
|
||||||
public ResponseEntity<Object> addOrderTask(AddOrderTaskDTO orderTaskDTO) {
|
public ResponseEntity<Object> addOrderTask(@RequestBody @Validated AddOrderTaskDTO orderTaskDTO) {
|
||||||
orderBiz.addOrderTask(orderTaskDTO);
|
orderBiz.addOrderTask(orderTaskDTO);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.aircraft.modules.order.domain.dto;
|
package com.aircraft.modules.order.domain.dto;
|
||||||
|
|
||||||
|
import com.aircraft.modules.system.domain.dto.LocalAttachmentMaterialDTO;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -46,8 +48,8 @@ public class AddOrderTaskDTO {
|
|||||||
private BigDecimal cargoWeight;
|
private BigDecimal cargoWeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务上传的图片全路径URL
|
* 图片材料List
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "任务上传的图片全路径URL")
|
@ApiModelProperty(value = "图片材料List集合")
|
||||||
private String picUrl;
|
private List<LocalAttachmentMaterialDTO> attachmentMaterialList;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package com.aircraft.modules.system.service;
|
|||||||
import com.aircraft.modules.system.domain.AttachmentMaterial;
|
import com.aircraft.modules.system.domain.AttachmentMaterial;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务类
|
* 服务类
|
||||||
@ -14,8 +16,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
public interface IAttachmentMaterialService extends IService<AttachmentMaterial> {
|
public interface IAttachmentMaterialService extends IService<AttachmentMaterial> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增材料
|
* 批量新增材料
|
||||||
* @param attachmentMaterial
|
*
|
||||||
|
* @param attachmentMaterialList {@link List<AttachmentMaterial>}
|
||||||
*/
|
*/
|
||||||
void addAttachmentMaterial(AttachmentMaterial attachmentMaterial);
|
void batchAddAttachmentMaterial(List<AttachmentMaterial> attachmentMaterialList);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import com.aircraft.modules.system.service.IAttachmentMaterialService;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
@ -18,7 +20,7 @@ import org.springframework.stereotype.Service;
|
|||||||
public class AttachmentMaterialServiceImpl extends ServiceImpl<AttachmentMaterialMapper, AttachmentMaterial> implements IAttachmentMaterialService {
|
public class AttachmentMaterialServiceImpl extends ServiceImpl<AttachmentMaterialMapper, AttachmentMaterial> implements IAttachmentMaterialService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAttachmentMaterial(AttachmentMaterial attachmentMaterial) {
|
public void batchAddAttachmentMaterial(List<AttachmentMaterial> attachmentMaterialList) {
|
||||||
this.save(attachmentMaterial);
|
this.saveBatch(attachmentMaterialList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class LocalStorageController {
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("上传文件")
|
@ApiOperation("上传文件")
|
||||||
public ResponseEntity<Object> createFile(@RequestPart("file") MultipartFile file){
|
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 localAttachmentMaterialDTO = new LocalAttachmentMaterialDTO();
|
||||||
localAttachmentMaterialDTO.setFileType(localStorage.getSuffix());
|
localAttachmentMaterialDTO.setFileType(localStorage.getSuffix());
|
||||||
localAttachmentMaterialDTO.setFileSize(file.getSize());
|
localAttachmentMaterialDTO.setFileSize(file.getSize());
|
||||||
|
Loading…
Reference in New Issue
Block a user