feat: 检验任务 重检修改,图片上传修改
This commit is contained in:
parent
95a67fe999
commit
ae64d11d9f
@ -5,11 +5,15 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class QmsInspecAttachmentDTO extends QmsInspecAttachment {
|
||||
|
||||
private MultipartFile file;
|
||||
private MultipartFile[] files;
|
||||
|
||||
private byte[] bytes;
|
||||
private List<MultipartFile> uploadList;
|
||||
}
|
||||
|
||||
@ -5,12 +5,15 @@ import com.foreverwin.iep.qms.entity.QmsInspecAttachment;
|
||||
import com.foreverwin.iep.qms.service.QmsInspecAttachmentService;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.common.security.annotation.Inner;
|
||||
import com.google.gson.Gson;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
/**
|
||||
* 检验单单身-附件
|
||||
@ -53,8 +56,27 @@ public class QmsInspecAttachmentController {
|
||||
@ApiOperation(value = "上传图片", notes = "上传图片")
|
||||
@PostMapping("/uploadMinio")
|
||||
@Inner(value = false)
|
||||
public R uploadMinio(QmsInspecAttachmentDTO dto, MultipartFile files) {
|
||||
qmsInspecAttachmentService.saveMinio(dto,files);
|
||||
public R uploadMinio(@RequestParam("files") MultipartFile[] files,@RequestParam("uploadData") String uploadData) {
|
||||
// 创建Gson对象
|
||||
Gson gson = new Gson();
|
||||
QmsInspecAttachmentDTO dto = gson.fromJson(uploadData, QmsInspecAttachmentDTO.class);
|
||||
|
||||
for (MultipartFile file : files) {
|
||||
qmsInspecAttachmentService.saveMinio(dto,file);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片删除
|
||||
*/
|
||||
@ApiOperation(value = "图片删除", notes = "图片删除")
|
||||
@PostMapping("/minioDelete")
|
||||
public R upload(@RequestParam("files") MultipartFile[] files,@RequestParam("uploadData") String uploadData) {
|
||||
// 创建Gson对象
|
||||
Gson gson = new Gson();
|
||||
QmsInspecAttachmentDTO dto = gson.fromJson(uploadData, QmsInspecAttachmentDTO.class);
|
||||
//qmsInspecAttachmentService.minioDelete(dto,file);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -360,8 +360,7 @@ public class QmsInspecJobController {
|
||||
@ApiOperation(value = "重检",notes = "重检")
|
||||
@PostMapping("/reInspection")
|
||||
public R reInspection(@RequestBody QmsInspecJob inspecJob){
|
||||
qmsInspecJobService.reInspection(inspecJob);
|
||||
return R.ok();
|
||||
return R.ok(qmsInspecJobService.reInspection(inspecJob));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "檢驗任務創建并收集检验数据源数据", notes = "檢驗任務創建并收集检验数据源数据")
|
||||
|
||||
@ -57,4 +57,14 @@ public interface QmsInspecAttachmentService extends IService<QmsInspecAttachment
|
||||
*/
|
||||
List<QmsInspecAttachment> getMinio(QmsInspecAttachment inspecDetailBo);
|
||||
|
||||
/**
|
||||
* minio文件删除
|
||||
*/
|
||||
void minioDelete(QmsInspecAttachmentDTO dto,MultipartFile files);
|
||||
|
||||
/**
|
||||
* 上传minio
|
||||
*/
|
||||
void uploadMinio(String img);
|
||||
|
||||
}
|
||||
@ -173,7 +173,7 @@ public interface QmsInspecJobService extends IService<QmsInspecJob> {
|
||||
void submit(QmsInspecJobDTO dto);
|
||||
|
||||
void closeInspec(QmsInspecJob inspecJob);
|
||||
void reInspection(QmsInspecJob inspecJob);
|
||||
QmsInspecJob reInspection(QmsInspecJob inspecJob);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -141,19 +141,19 @@ public class QmsInspecAttachmentServiceImpl extends ServiceImpl<QmsInspecAttachm
|
||||
// 获取上传的文件
|
||||
MultipartFile multipartFile = dto.getFile();
|
||||
// 如果文件为空,则返回null
|
||||
if (multipartFile == null) {
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理文件名的编码转换,确保兼容性
|
||||
String fileName = new String(Objects.requireNonNull(multipartFile.getOriginalFilename())
|
||||
String fileName = new String(Objects.requireNonNull(files.getOriginalFilename())
|
||||
.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
|
||||
// 上传文件并获取返回的文件URL
|
||||
String url = uploadFile(multipartFile);
|
||||
String url = uploadFile(files);
|
||||
dto.setSid(UUID.randomUUID().toString());
|
||||
dto.setFileName(url);
|
||||
dto.setType(multipartFile.getContentType());
|
||||
dto.setType(files.getContentType());
|
||||
dto.setCreator(dto.getCreator());
|
||||
dto.setDateCreate(LocalDateTime.now());
|
||||
super.save(dto);
|
||||
@ -171,6 +171,25 @@ public class QmsInspecAttachmentServiceImpl extends ServiceImpl<QmsInspecAttachm
|
||||
return inspecAttachmentList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void minioDelete(QmsInspecAttachmentDTO dto, MultipartFile files) {
|
||||
List<QmsInspecAttachment> attachmentList = getMinio(dto);
|
||||
for (QmsInspecAttachment attachment : attachmentList) {
|
||||
if (StrUtil.isNotEmpty(attachment.getUrl())) {
|
||||
try {
|
||||
fileTemplate.removeObject(properties.getBucketName(), attachment.getUrl());
|
||||
} catch (Exception e) {
|
||||
throw new BaseException("删除文件失败:" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadMinio(String img) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String sid) {
|
||||
Map<String, String> config = ConfigUtils.getFileServerConfig();
|
||||
|
||||
@ -1788,7 +1788,7 @@ public class QmsInspecJobServiceImpl extends ServiceImpl<QmsInspecJobMapper, Qms
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void reInspection(QmsInspecJob inspecJob) {
|
||||
public QmsInspecJob reInspection(QmsInspecJob inspecJob) {
|
||||
QmsInspecJob qmsInspecJob = super.getOne(Wrappers.lambdaUpdate(QmsInspecJob.class)
|
||||
.eq(QmsInspecJob::getHandle, inspecJob.getHandle()));
|
||||
InspecJob job = new InspecJob();
|
||||
@ -1798,7 +1798,8 @@ public class QmsInspecJobServiceImpl extends ServiceImpl<QmsInspecJobMapper, Qms
|
||||
job.setOperation(qmsInspecJob.getOperationBo().split(",")[1]);
|
||||
job.setResrce(qmsInspecJob.getResourceBo().split(",")[1]);
|
||||
job.setQcSubCategories(qmsInspecJob.getQcSubCategories());
|
||||
create(job);
|
||||
job.setOriginalJobNo(qmsInspecJob.getJobNo());
|
||||
QmsInspecJob newInspecJob = create(job);
|
||||
qmsInspecJob.setStatus("4");
|
||||
qmsInspecJob.setCompleteUser(SecurityUtils.getUserName());
|
||||
qmsInspecJob.setCompleteDateTime(LocalDateTime.now());
|
||||
@ -1808,6 +1809,7 @@ public class QmsInspecJobServiceImpl extends ServiceImpl<QmsInspecJobMapper, Qms
|
||||
qmsInspecJob.setUpdater(SecurityUtils.getUserName());
|
||||
qmsInspecJob.setDateUpdate(LocalDateTime.now());
|
||||
super.updateById(qmsInspecJob);
|
||||
return newInspecJob;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user