This commit is contained in:
ls
2024-11-07 20:51:02 +08:00
parent 26616f3335
commit 9a79354054
7 changed files with 2426 additions and 8 deletions

View File

@@ -227,7 +227,7 @@ jeecg:
#webapp文件路径
webapp: /opt/webapp
shiro:
excludeUrls: /sys/common/upload,/sys/user/**,/test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
excludeUrls: /database/experimentDoc/**,/sys/common/upload,/sys/user/**,/test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
#阿里云oss存储和大鱼短信秘钥配置
oss:
accessKey: ??

View File

@@ -1,25 +1,35 @@
package org.jeecg.modules.database.controller;
import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.database.entity.ExperimentDoc;
import org.jeecg.modules.database.entity.ExperimentReport;
import org.jeecg.modules.database.service.IExperimentDocService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.Arrays;
import java.io.*;
import java.net.URLDecoder;
import java.util.*;
/**
* @Description: 试验文档
@@ -134,6 +144,74 @@ public class ExperimentDocController extends JeecgController<ExperimentDoc, IExp
return Result.OK(experimentDoc);
}
/**
* 通过实验id查询
*
* @param experimentalId
* @return
*/
//@AutoLog(value = "试验评定-通过id查询")
@Operation(summary = "试验报告-通过实验ID查询")
@GetMapping(value = "/queryByExperimentId")
public Result<List<ExperimentDoc>> queryByExperimentalId(@RequestParam(name = "experimentId", required = true) String experimentalId) {
LambdaQueryWrapper<ExperimentDoc> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ExperimentDoc::getExperimentId, experimentalId);
List<ExperimentDoc> experimentReview = experimentDocService.list(queryWrapper);
if (experimentReview == null) {
return Result.error("未找到对应数据");
}
return Result.OK(experimentReview);
}
/**
* 试验文档下载
*
* @param experimentId
* @return
*/
//@AutoLog(value = "试验评定-通过id查询")
@Operation(summary = "试验文档下载", parameters = {
@Parameter(name = "experimentId", description = "实验id", required = true),
@Parameter(name = "type", description = "文档类型(辐照试验计划表,试验报告评审表,设备使用记录表,试验报告,辐照试验总结单)",
required = true),
})
@GetMapping(value = "/download")
public Result<ExperimentDoc> download(@RequestParam(name = "experimentId", required = true) String experimentId,
@RequestParam(name = "type", required = true) String type, HttpServletResponse response) {
LambdaQueryWrapper<ExperimentDoc> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ExperimentDoc::getExperimentId, experimentId);
queryWrapper.eq(ExperimentDoc::getDocType, type);
ExperimentDoc doc = experimentDocService.getOne(queryWrapper);
if (Objects.isNull(doc)) {
doc = experimentDocService.generate(experimentId, type);
}
if (Objects.isNull(doc)) {
return Result.error("试验文档生成失败");
}
return Result.OK(doc);
}
/**
* 重新生成试验文档
*
* @param experimentId
* @param type
* @return
*/
@Operation(summary = "重新生成试验文档", parameters = {
@Parameter(name = "experimentId", description = "实验id", required = true),
@Parameter(name = "type", description = "文档类型", required = true),
})
@GetMapping(value = "/generate")
public Result<ExperimentDoc> generate(@RequestParam(name = "experimentId", required = true) String experimentId,
@RequestParam(name = "type", required = true) String type) {
ExperimentDoc experimentReview = experimentDocService.generate(experimentId, type);
if (Objects.isNull(experimentReview)) {
return Result.error("试验文档生成失败");
}
return Result.OK(experimentReview);
}
/**
* 导出excel
*

View File

@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.Arrays;
import java.util.List;
/**
* @Description: 试验报告
@@ -161,15 +162,16 @@ public class ExperimentReportController extends JeecgController<ExperimentReport
//@AutoLog(value = "试验评定-通过id查询")
@Operation(summary = "试验报告-通过实验ID查询")
@GetMapping(value = "/queryByExperimentId")
public Result<ExperimentReport> queryByExperimentalId(@RequestParam(name = "experimentId", required = true) String experimentalId) {
public Result<List<ExperimentReport>> queryByExperimentalId(@RequestParam(name = "experimentId", required = true) String experimentalId) {
LambdaQueryWrapper<ExperimentReport> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ExperimentReport::getExperimentId, experimentalId);
ExperimentReport experimentReview = experimentReportService.getOne(queryWrapper);
List<ExperimentReport> experimentReview = experimentReportService.list(queryWrapper);
if (experimentReview == null) {
return Result.error("未找到对应数据");
}
return Result.OK(experimentReview);
}
/**
* 导出excel
*

View File

@@ -73,7 +73,7 @@ public class ExperimentDoc implements Serializable {
* 文档类型
*/
@Excel(name = "文档类型", width = 15)
@Schema(description = "文档类型")
@Schema(description = "文档类型", allowableValues = "辐照试验计划表,试验报告评审表,设备使用记录表,试验报告,辐照试验总结单")
private String docType;
/**
* 文件地址

View File

@@ -11,4 +11,6 @@ import org.jeecg.modules.database.entity.ExperimentDoc;
*/
public interface IExperimentDocService extends IService<ExperimentDoc> {
ExperimentDoc generate(String experimentId, String type);
}

View File

@@ -4,6 +4,8 @@ import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.util.MinioUtil;
import org.jeecg.modules.database.entity.ExperimentDoc;
import org.jeecg.modules.database.mapper.ExperimentDocMapper;
import org.jeecg.modules.database.service.IExperimentDocService;
@@ -43,7 +45,7 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
generateExperimentDoc("20241028号实验", "辐照试验计划表", maps);
}
public static void generateExperimentDoc(String experimentId, String fileName, Map<String, Object> params) {
public static String generateExperimentDoc(String experimentId, String fileName, Map<String, Object> params) {
URL resourceUrl = ExperimentDocServiceImpl.class.getClassLoader().getResource("templates/doc/" + docTempalteMap.get(fileName));
if (Objects.isNull(resourceUrl)) {
throw new RuntimeException("模板文件不存在!");
@@ -60,8 +62,26 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
log.info("output file path: " + outputFile);
XWPFTemplate.compile(absolutePath).render(params).writeToFile(outputFile);
} catch (IOException e) {
throw new RuntimeException(e);
String path = MinioUtil.upload(FileUtil.getInputStream(outputFile),
"experiment_doc/" + experimentId + "/" + fileName + ".docx");
return path;
} catch (Exception e) {
log.error(e.getMessage());
return null;
}
}
@Override
public ExperimentDoc generate(String experimentalId, String type) {
String filePath = generateExperimentDoc(experimentalId, type, new HashMap<>());
if (StringUtils.isNotBlank(filePath)) {
ExperimentDoc experimentDoc = new ExperimentDoc();
experimentDoc.setExperimentId(experimentalId);
experimentDoc.setDocType(type);
experimentDoc.setFilePath(filePath);
this.save(experimentDoc);
return experimentDoc;
}
return null;
}
}

2316
scripts/nasa_data_record.sql Normal file

File diff suppressed because it is too large Load Diff