update
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Ant Group
|
||||||
|
* Copyright (c) 2004-2024 All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package org.jeecg.modules.database.constant;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lise
|
||||||
|
* @version Experiment.java, v 0.1 2024年11月08日 17:15 lise
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum ExperimentFileType {
|
||||||
|
//辐照试验委托书
|
||||||
|
// 试验大纲
|
||||||
|
// 沟通记录表
|
||||||
|
// 合同/委托书评审表
|
||||||
|
// 试验大纲评审表
|
||||||
|
// 试验流程检查单
|
||||||
|
// 辐照试验更改申请表
|
||||||
|
// 满意度调查表
|
||||||
|
// 其他文件
|
||||||
|
FZSYWTS("辐照试验委托书"),
|
||||||
|
SYDG("试验大纲"),
|
||||||
|
GTJLB("沟通记录表"),
|
||||||
|
HTPSB("合同/委托书评审表"),
|
||||||
|
SYDGPSB("试验大纲评审表"),
|
||||||
|
SYLCJCD("试验流程检查单"),
|
||||||
|
FZSYGGSQB("辐照试验更改申请表"),
|
||||||
|
MYDDCB("满意度调查表"),
|
||||||
|
QTWJ("其他文件"),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
String type;
|
||||||
|
}
|
||||||
@@ -44,9 +44,6 @@ import java.util.List;
|
|||||||
@RequestMapping("/database/experiment")
|
@RequestMapping("/database/experiment")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ExperimentController extends JeecgController<Experiment, IExperimentService> {
|
public class ExperimentController extends JeecgController<Experiment, IExperimentService> {
|
||||||
|
|
||||||
@Value(value = "${jeecg.uploadType}")
|
|
||||||
private String uploadType;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IExperimentService experimentService;
|
private IExperimentService experimentService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -268,37 +265,5 @@ public class ExperimentController extends JeecgController<Experiment, IExperimen
|
|||||||
return super.importExcel(request, response, Experiment.class);
|
return super.importExcel(request, response, Experiment.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "试验管理-上传试验文件")
|
|
||||||
@PostMapping(value = "/upload")
|
|
||||||
public Result<?> upload(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
||||||
Result<ExperimentFile> result = new Result<>();
|
|
||||||
String fileType = request.getParameter("fileType");
|
|
||||||
if (StringUtils.isBlank(fileType)) {
|
|
||||||
fileType = "其他";
|
|
||||||
}
|
|
||||||
|
|
||||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
||||||
// 获取上传文件对象
|
|
||||||
MultipartFile file = multipartRequest.getFile("file");
|
|
||||||
|
|
||||||
//update-begin-author:taoyan date:20200814 for:文件上传改造
|
|
||||||
String savePath = CommonUtils.upload(file, "experiment_file", uploadType);
|
|
||||||
|
|
||||||
ExperimentFile ossFile = new ExperimentFile();
|
|
||||||
ossFile.setFileName(file.getOriginalFilename());
|
|
||||||
ossFile.setFileUrl(savePath);
|
|
||||||
ossFile.setFileType(fileType);
|
|
||||||
experimentFileService.save(ossFile);
|
|
||||||
result.setResult(ossFile);
|
|
||||||
|
|
||||||
if (oConvertUtils.isNotEmpty(savePath)) {
|
|
||||||
result.setMessage(savePath);
|
|
||||||
result.setSuccess(true);
|
|
||||||
} else {
|
|
||||||
result.setMessage("上传失败!");
|
|
||||||
result.setSuccess(false);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,18 +8,25 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.common.util.CommonUtils;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.jeecg.modules.database.constant.ExperimentFileType;
|
||||||
import org.jeecg.modules.database.entity.ExperimentFile;
|
import org.jeecg.modules.database.entity.ExperimentFile;
|
||||||
import org.jeecg.modules.database.service.IExperimentFileService;
|
import org.jeecg.modules.database.service.IExperimentFileService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 试验文件
|
* @Description: 试验文件
|
||||||
@@ -32,6 +39,10 @@ import java.util.Arrays;
|
|||||||
@RequestMapping("/database/experimentFile")
|
@RequestMapping("/database/experimentFile")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ExperimentFileController extends JeecgController<ExperimentFile, IExperimentFileService> {
|
public class ExperimentFileController extends JeecgController<ExperimentFile, IExperimentFileService> {
|
||||||
|
|
||||||
|
@Value(value = "${jeecg.uploadType}")
|
||||||
|
private String uploadType;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IExperimentFileService experimentFileService;
|
private IExperimentFileService experimentFileService;
|
||||||
|
|
||||||
@@ -159,4 +170,62 @@ public class ExperimentFileController extends JeecgController<ExperimentFile, IE
|
|||||||
return super.importExcel(request, response, ExperimentFile.class);
|
return super.importExcel(request, response, ExperimentFile.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过实验id查询
|
||||||
|
*
|
||||||
|
* @param experimentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "试验评定-通过id查询")
|
||||||
|
@Operation(summary = "试验报告-通过实验ID查询")
|
||||||
|
@GetMapping(value = "/queryByExperimentId")
|
||||||
|
public Result<List<ExperimentFile>> queryByExperimentId(@RequestParam(name = "experimentId", required = true) String experimentId) {
|
||||||
|
List<ExperimentFile> byExperimentId = experimentFileService.getByExperimentId(experimentId);
|
||||||
|
return Result.OK(byExperimentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "试验报告-通过实验ID分类查询")
|
||||||
|
@GetMapping(value = "/queryByType")
|
||||||
|
public Result<?> queryByType(@RequestParam(name = "experimentId", required = true) String experimentId) {
|
||||||
|
Map<String, List<ExperimentFile>> result = new HashMap<>();
|
||||||
|
for (ExperimentFileType value : ExperimentFileType.values()) {
|
||||||
|
List<ExperimentFile> fileList = experimentFileService.getByType(experimentId, value.getType());
|
||||||
|
result.put(value.getType(), fileList);
|
||||||
|
}
|
||||||
|
return Result.OK(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "试验管理-上传试验文件")
|
||||||
|
@PostMapping(value = "/upload")
|
||||||
|
public Result<?> upload(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
Result<ExperimentFile> result = new Result<>();
|
||||||
|
String fileType = request.getParameter("fileType");
|
||||||
|
if (StringUtils.isBlank(fileType)) {
|
||||||
|
fileType = "其他";
|
||||||
|
}
|
||||||
|
|
||||||
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
|
// 获取上传文件对象
|
||||||
|
MultipartFile file = multipartRequest.getFile("file");
|
||||||
|
|
||||||
|
//update-begin-author:taoyan date:20200814 for:文件上传改造
|
||||||
|
String savePath = CommonUtils.upload(file, "experiment_file", uploadType);
|
||||||
|
|
||||||
|
ExperimentFile ossFile = new ExperimentFile();
|
||||||
|
ossFile.setFileName(file.getOriginalFilename());
|
||||||
|
ossFile.setFileUrl(savePath);
|
||||||
|
ossFile.setFileType(fileType);
|
||||||
|
experimentFileService.save(ossFile);
|
||||||
|
result.setResult(ossFile);
|
||||||
|
|
||||||
|
if (oConvertUtils.isNotEmpty(savePath)) {
|
||||||
|
result.setMessage(savePath);
|
||||||
|
result.setSuccess(true);
|
||||||
|
} else {
|
||||||
|
result.setMessage("上传失败!");
|
||||||
|
result.setSuccess(false);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ import java.util.List;
|
|||||||
public interface IExperimentFileService extends IService<ExperimentFile> {
|
public interface IExperimentFileService extends IService<ExperimentFile> {
|
||||||
|
|
||||||
List<ExperimentFile> getByExperimentId(String experimentId);
|
List<ExperimentFile> getByExperimentId(String experimentId);
|
||||||
|
|
||||||
|
List<ExperimentFile> getByType(String experimentId, String type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,10 @@ public class ExperimentFileServiceImpl extends ServiceImpl<ExperimentFileMapper,
|
|||||||
public List<ExperimentFile> getByExperimentId(String experimentId) {
|
public List<ExperimentFile> getByExperimentId(String experimentId) {
|
||||||
return list(new LambdaQueryWrapper<ExperimentFile>().eq(ExperimentFile::getExperimentId, experimentId));
|
return list(new LambdaQueryWrapper<ExperimentFile>().eq(ExperimentFile::getExperimentId, experimentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ExperimentFile> getByType(String experimentId, String type) {
|
||||||
|
return list(new LambdaQueryWrapper<ExperimentFile>().eq(ExperimentFile::getExperimentId, experimentId).eq(
|
||||||
|
ExperimentFile::getFileType, type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user