update
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 试验管理
|
* @Description: 试验管理
|
||||||
@@ -116,6 +117,18 @@ public class ExperimentController extends JeecgController<Experiment, IExperimen
|
|||||||
if (!StringUtils.startsWith(experimentNo, "KC")) {
|
if (!StringUtils.startsWith(experimentNo, "KC")) {
|
||||||
return Result.error("实验编号格式不正确!");
|
return Result.error("实验编号格式不正确!");
|
||||||
}
|
}
|
||||||
|
List<ExperimentSampleInfo> sampleInfoList = experiment.getSampleInfoList();
|
||||||
|
List<ExperimentIrradiationBoard> irradiationBoardList = experiment.getIrradiationBoardList();
|
||||||
|
List<ExperimentDeviationCondition> deviationConditionList = experiment.getDeviationConditionList();
|
||||||
|
Set<String> sampleList = sampleInfoList.stream().map(v -> v.getSampleModel()).collect(Collectors.toUnmodifiableSet());
|
||||||
|
Set<String> boardList = irradiationBoardList.stream().map(v -> v.getSampleModel()).collect(Collectors.toUnmodifiableSet());
|
||||||
|
Set<String> conditionList = deviationConditionList.stream().map(v -> v.getSampleModel()).collect(Collectors.toUnmodifiableSet());
|
||||||
|
if (!sampleList.equals(boardList)) {
|
||||||
|
return Result.error("辐照板信息不匹配!");
|
||||||
|
}
|
||||||
|
if (!sampleList.equals(conditionList)) {
|
||||||
|
return Result.error("偏置条件信息不匹配!");
|
||||||
|
}
|
||||||
experiment.setStatus(ExperimentStatus.PRE_TEST);
|
experiment.setStatus(ExperimentStatus.PRE_TEST);
|
||||||
experimentService.saveWithDetail(experiment);
|
experimentService.saveWithDetail(experiment);
|
||||||
|
|
||||||
@@ -181,6 +194,19 @@ public class ExperimentController extends JeecgController<Experiment, IExperimen
|
|||||||
} else {
|
} else {
|
||||||
experiment.setStatus(dbExp.getStatus());
|
experiment.setStatus(dbExp.getStatus());
|
||||||
}
|
}
|
||||||
|
List<ExperimentSampleInfo> sampleInfoList = experiment.getSampleInfoList();
|
||||||
|
List<ExperimentIrradiationBoard> irradiationBoardList = experiment.getIrradiationBoardList();
|
||||||
|
List<ExperimentDeviationCondition> deviationConditionList = experiment.getDeviationConditionList();
|
||||||
|
Set<String> sampleList = sampleInfoList.stream().map(v -> v.getSampleModel()).collect(Collectors.toUnmodifiableSet());
|
||||||
|
Set<String> boardList = irradiationBoardList.stream().map(v -> v.getSampleModel()).collect(Collectors.toUnmodifiableSet());
|
||||||
|
Set<String> conditionList = deviationConditionList.stream().map(v -> v.getSampleModel()).collect(Collectors.toUnmodifiableSet());
|
||||||
|
if (!sampleList.equals(boardList)) {
|
||||||
|
return Result.error("辐照板信息不匹配!");
|
||||||
|
}
|
||||||
|
if (!sampleList.equals(conditionList)) {
|
||||||
|
return Result.error("偏置条件信息不匹配!");
|
||||||
|
}
|
||||||
|
|
||||||
experimentService.saveWithDetail(experiment);
|
experimentService.saveWithDetail(experiment);
|
||||||
ExperimentLog experimentLog = new ExperimentLog();
|
ExperimentLog experimentLog = new ExperimentLog();
|
||||||
experimentLog.setExperimentId(experiment.getId());
|
experimentLog.setExperimentId(experiment.getId());
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ public class ExperimentSampleInfoController extends JeecgController<ExperimentSa
|
|||||||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||||
// 自定义 sampleModel 字段的查询规则为:RIGHT_LIKE
|
// 自定义 sampleModel 字段的查询规则为:RIGHT_LIKE
|
||||||
customeRuleMap.put("sampleModel", QueryRuleEnum.RIGHT_LIKE);
|
customeRuleMap.put("sampleModel", QueryRuleEnum.RIGHT_LIKE);
|
||||||
|
customeRuleMap.put("sampleType", QueryRuleEnum.RIGHT_LIKE);
|
||||||
|
customeRuleMap.put("sampleName", QueryRuleEnum.RIGHT_LIKE);
|
||||||
QueryWrapper<ExperimentSampleInfo> queryWrapper = QueryGenerator.initQueryWrapper(experimentSampleInfo, req.getParameterMap(),
|
QueryWrapper<ExperimentSampleInfo> queryWrapper = QueryGenerator.initQueryWrapper(experimentSampleInfo, req.getParameterMap(),
|
||||||
customeRuleMap);
|
customeRuleMap);
|
||||||
List<ExperimentSampleInfo> pageList = experimentSampleInfoService.list(queryWrapper);
|
List<ExperimentSampleInfo> pageList = experimentSampleInfoService.list(queryWrapper);
|
||||||
@@ -153,7 +155,7 @@ public class ExperimentSampleInfoController extends JeecgController<ExperimentSa
|
|||||||
* @param request
|
* @param request
|
||||||
* @param experimentSampleInfo
|
* @param experimentSampleInfo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RequestMapping(value = "/exportXls")
|
@RequestMapping(value = "/exportXls")
|
||||||
public ModelAndView exportXls(HttpServletRequest request, ExperimentSampleInfo experimentSampleInfo) {
|
public ModelAndView exportXls(HttpServletRequest request, ExperimentSampleInfo experimentSampleInfo) {
|
||||||
return super.exportXls(request, experimentSampleInfo, ExperimentSampleInfo.class, "试验样品信息");
|
return super.exportXls(request, experimentSampleInfo, ExperimentSampleInfo.class, "试验样品信息");
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ public class ExperimentDeviationCondition implements Serializable {
|
|||||||
@Excel(name = "样品型号", width = 15)
|
@Excel(name = "样品型号", width = 15)
|
||||||
@Schema(description = "样品型号")
|
@Schema(description = "样品型号")
|
||||||
private java.lang.String sampleModel;
|
private java.lang.String sampleModel;
|
||||||
|
/**
|
||||||
|
* 批次
|
||||||
|
*/
|
||||||
|
@Excel(name = "批次", width = 15)
|
||||||
|
@Schema(description = "批次")
|
||||||
|
private java.lang.String sampleBatch;
|
||||||
/**
|
/**
|
||||||
* 样品编号
|
* 样品编号
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ public class ExperimentDeviationEquipment implements Serializable {
|
|||||||
@Excel(name = "样品型号", width = 15)
|
@Excel(name = "样品型号", width = 15)
|
||||||
@Schema(description = "样品型号")
|
@Schema(description = "样品型号")
|
||||||
private java.lang.String sampleModel;
|
private java.lang.String sampleModel;
|
||||||
|
/**
|
||||||
|
* 批次
|
||||||
|
*/
|
||||||
|
@Excel(name = "批次", width = 15)
|
||||||
|
@Schema(description = "批次")
|
||||||
|
private java.lang.String sampleBatch;
|
||||||
/**
|
/**
|
||||||
* 设备型号
|
* 设备型号
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,93 +1,117 @@
|
|||||||
package org.jeecg.modules.database.entity;
|
package org.jeecg.modules.database.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import lombok.Data;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
|
||||||
import org.jeecg.common.aspect.annotation.Dict;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 试验辐照板信息
|
* @Description: 试验辐照板信息
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2024-12-05
|
* @Date: 2024-12-05
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("experiment_irradiation_board")
|
@TableName("experiment_irradiation_board")
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@Schema(description="试验辐照板信息")
|
@Schema(description = "试验辐照板信息")
|
||||||
public class ExperimentIrradiationBoard implements Serializable {
|
public class ExperimentIrradiationBoard implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**主键*/
|
/**
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
@Schema(description = "主键")
|
@Schema(description = "主键")
|
||||||
private java.lang.String id;
|
private java.lang.String id;
|
||||||
/**创建人*/
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
@Schema(description = "创建人")
|
@Schema(description = "创建人")
|
||||||
private java.lang.String createBy;
|
private java.lang.String createBy;
|
||||||
/**创建日期*/
|
/**
|
||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
* 创建日期
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@Schema(description = "创建日期")
|
@Schema(description = "创建日期")
|
||||||
private java.util.Date createTime;
|
private java.util.Date createTime;
|
||||||
/**更新人*/
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
@Schema(description = "更新人")
|
@Schema(description = "更新人")
|
||||||
private java.lang.String updateBy;
|
private java.lang.String updateBy;
|
||||||
/**更新日期*/
|
/**
|
||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
* 更新日期
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@Schema(description = "更新日期")
|
@Schema(description = "更新日期")
|
||||||
private java.util.Date updateTime;
|
private java.util.Date updateTime;
|
||||||
/**所属部门*/
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
@Schema(description = "所属部门")
|
@Schema(description = "所属部门")
|
||||||
private java.lang.String sysOrgCode;
|
private java.lang.String sysOrgCode;
|
||||||
/**试验ID*/
|
/**
|
||||||
@Excel(name = "试验ID", width = 15)
|
* 试验ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "试验ID", width = 15)
|
||||||
@Schema(description = "试验ID")
|
@Schema(description = "试验ID")
|
||||||
private java.lang.String experimentId;
|
private java.lang.String experimentId;
|
||||||
/**样品类型*/
|
/**
|
||||||
@Excel(name = "样品类型", width = 15)
|
* 样品类型
|
||||||
|
*/
|
||||||
|
@Excel(name = "样品类型", width = 15)
|
||||||
@Schema(description = "样品类型")
|
@Schema(description = "样品类型")
|
||||||
private java.lang.String sampleType;
|
private java.lang.String sampleType;
|
||||||
/**样品型号*/
|
/**
|
||||||
@Excel(name = "样品型号", width = 15)
|
* 样品型号
|
||||||
|
*/
|
||||||
|
@Excel(name = "样品型号", width = 15)
|
||||||
@Schema(description = "样品型号")
|
@Schema(description = "样品型号")
|
||||||
private java.lang.String sampleModel;
|
private java.lang.String sampleModel;
|
||||||
/**辐照板数量*/
|
/**
|
||||||
@Excel(name = "辐照板数量", width = 15)
|
* 批次
|
||||||
@Schema(description = "辐照板数量")
|
*/
|
||||||
private java.lang.String irradiationBoardNumber;
|
|
||||||
/**辐照板编号*/
|
|
||||||
@Excel(name = "辐照板编号", width = 15)
|
|
||||||
@Schema(description = "辐照板编号")
|
|
||||||
private java.lang.String irradiationBoardCode;
|
|
||||||
/**计量有效期*/
|
|
||||||
@Excel(name = "计量有效期", width = 15)
|
|
||||||
@Schema(description = "计量有效期")
|
|
||||||
private java.lang.String measurementValidity;
|
|
||||||
/**占源面积*/
|
|
||||||
@Excel(name = "占源面积", width = 15)
|
|
||||||
@Schema(description = "占源面积")
|
|
||||||
private java.lang.String sourceArea;
|
|
||||||
/**图片*/
|
|
||||||
@Excel(name = "图片", width = 15)
|
|
||||||
@Schema(description = "图片")
|
|
||||||
private java.lang.String sampleImage;
|
|
||||||
/**批次*/
|
|
||||||
@Excel(name = "批次", width = 15)
|
@Excel(name = "批次", width = 15)
|
||||||
@Schema(description = "批次")
|
@Schema(description = "批次")
|
||||||
private java.lang.String batch;
|
private java.lang.String sampleBatch;
|
||||||
|
/**
|
||||||
|
* 辐照板数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "辐照板数量", width = 15)
|
||||||
|
@Schema(description = "辐照板数量")
|
||||||
|
private java.lang.String irradiationBoardNumber;
|
||||||
|
/**
|
||||||
|
* 辐照板编号
|
||||||
|
*/
|
||||||
|
@Excel(name = "辐照板编号", width = 15)
|
||||||
|
@Schema(description = "辐照板编号")
|
||||||
|
private java.lang.String irradiationBoardCode;
|
||||||
|
/**
|
||||||
|
* 计量有效期
|
||||||
|
*/
|
||||||
|
@Excel(name = "计量有效期", width = 15)
|
||||||
|
@Schema(description = "计量有效期")
|
||||||
|
private java.lang.String measurementValidity;
|
||||||
|
/**
|
||||||
|
* 占源面积
|
||||||
|
*/
|
||||||
|
@Excel(name = "占源面积", width = 15)
|
||||||
|
@Schema(description = "占源面积")
|
||||||
|
private java.lang.String sourceArea;
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
|
@Excel(name = "图片", width = 15)
|
||||||
|
@Schema(description = "图片")
|
||||||
|
private java.lang.String sampleImage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,30 @@
|
|||||||
package org.jeecg.modules.database.service.impl;
|
package org.jeecg.modules.database.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.io.file.PathUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
import org.jeecg.common.util.MinioUtil;
|
import org.jeecg.common.util.DateUtils;
|
||||||
import org.jeecg.modules.database.entity.*;
|
import org.jeecg.modules.database.entity.*;
|
||||||
import org.jeecg.modules.database.mapper.ExperimentDocMapper;
|
import org.jeecg.modules.database.mapper.ExperimentDocMapper;
|
||||||
import org.jeecg.modules.database.service.*;
|
import org.jeecg.modules.database.service.*;
|
||||||
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
|
import org.jeecg.modules.system.service.ISysUserService;
|
||||||
import org.jeecgframework.poi.word.WordExportUtil;
|
import org.jeecgframework.poi.word.WordExportUtil;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +43,18 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
|||||||
private IExperimentService experimentService;
|
private IExperimentService experimentService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IExperimentReportService experimentReportService;
|
private IExperimentReportService experimentReportService;
|
||||||
static Map<String, String> docTempalteMap = new HashMap<>();
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IClientService clientService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IExperimentTestProcessService experimentTestProcessService;
|
||||||
|
@Autowired
|
||||||
|
private ITestStandardsService testStandardsService;
|
||||||
|
|
||||||
|
static Map<String, String> docTempalteMap = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
//辐照试验计划表
|
//辐照试验计划表
|
||||||
@@ -49,8 +67,11 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
|||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
//The core API uses a minimalist design, only one line of code is required
|
//The core API uses a minimalist design, only one line of code is required
|
||||||
Map<String, Object> maps = new HashMap<>();
|
TestStandards testStandards = new TestStandards();
|
||||||
maps.put("title", "辐照试验计划表");
|
testStandards.setAttachment("");
|
||||||
|
Path lastPathEle = PathUtil.getLastPathEle(Path.of(Optional.ofNullable(testStandards).map(TestStandards::getAttachment).orElse(""))
|
||||||
|
.getFileName());
|
||||||
|
System.out.println(lastPathEle.toString());
|
||||||
//generateExperimentDoc("20241028号实验", "辐照试验计划表", maps);
|
//generateExperimentDoc("20241028号实验", "辐照试验计划表", maps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,19 +93,79 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
|||||||
}
|
}
|
||||||
log.info("output file path: " + outputFile);
|
log.info("output file path: " + outputFile);
|
||||||
Map<String, Object> params = assembleParams(experimentId, fileName);
|
Map<String, Object> params = assembleParams(experimentId, fileName);
|
||||||
XWPFDocument doc = WordExportUtil.exportWord07(absolutePath, params);
|
XWPFDocument document = WordExportUtil.exportWord07(absolutePath, params);
|
||||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
|
||||||
doc.write(fos);
|
List<XWPFHeader> headers = document.getHeaderList();
|
||||||
fos.close();
|
|
||||||
String path = MinioUtil.upload(FileUtil.getInputStream(outputFile),
|
// 遍历所有节,确保每个节的页眉都添加了页码
|
||||||
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + fileName + ".docx");
|
for (XWPFHeader h : headers) {
|
||||||
return path;
|
// 添加页码到每个节的页眉
|
||||||
|
addPageNumberToHeader("报告编号:" + experiment.getExperimentNo(), h);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (FileOutputStream out = new FileOutputStream("/Users/lise/" + fileName + ".docx")) {
|
||||||
|
document.write(out);
|
||||||
|
}
|
||||||
|
document.close();
|
||||||
|
//String path = MinioUtil.upload(FileUtil.getInputStream(outputFile),
|
||||||
|
// "experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + fileName + ".docx");
|
||||||
|
return "path";
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addPageNumberToHeader(String left, XWPFHeader header) {
|
||||||
|
|
||||||
|
// 创建一个新的段落用于页码
|
||||||
|
XWPFParagraph paragraph = header.createParagraph();
|
||||||
|
|
||||||
|
// 设置段落右对齐
|
||||||
|
CTPPr pPr = paragraph.getCTP().addNewPPr();
|
||||||
|
pPr.addNewJc().setVal(STJc.BOTH);
|
||||||
|
|
||||||
|
// 添加页码文本
|
||||||
|
// 添加文本“第”
|
||||||
|
XWPFRun run = paragraph.createRun();
|
||||||
|
run.setText(left);
|
||||||
|
// 添加制表符(用于分隔左侧固定字符串和右侧页码)
|
||||||
|
run.addTab();
|
||||||
|
|
||||||
|
run = paragraph.createRun();
|
||||||
|
run.setText("第 ");
|
||||||
|
|
||||||
|
// 插入当前页码字段
|
||||||
|
run = paragraph.createRun();
|
||||||
|
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.BEGIN);
|
||||||
|
run.getCTR().addNewInstrText().setStringValue("PAGE");
|
||||||
|
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.SEPARATE);
|
||||||
|
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.END);
|
||||||
|
|
||||||
|
// 添加文本“页,共”
|
||||||
|
run = paragraph.createRun();
|
||||||
|
run.setText(" 页,共 ");
|
||||||
|
|
||||||
|
// 插入总页数字段
|
||||||
|
run = paragraph.createRun();
|
||||||
|
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.BEGIN);
|
||||||
|
run.getCTR().addNewInstrText().setStringValue("NUMPAGES");
|
||||||
|
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.SEPARATE);
|
||||||
|
run.getCTR().addNewFldChar().setFldCharType(org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType.END);
|
||||||
|
|
||||||
|
// 添加文本“页(含封面)”
|
||||||
|
run = paragraph.createRun();
|
||||||
|
run.setText(" 页(含封面)");
|
||||||
|
|
||||||
|
// 设置制表符的对齐方式为右对齐
|
||||||
|
CTTabs tabs = pPr.addNewTabs();
|
||||||
|
CTTabStop tabStop = tabs.addNewTab();
|
||||||
|
tabStop.setVal(STTabJc.RIGHT); // 右对齐
|
||||||
|
tabStop.setPos(BigInteger.valueOf(8000)); // 设置制表符位置(单位:twips,1 cm = 567 twips)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, Object> assembleParams(String experimentId, String type) {
|
private Map<String, Object> assembleParams(String experimentId, String type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "辐照试验计划表":
|
case "辐照试验计划表":
|
||||||
@@ -107,20 +188,37 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
|
|||||||
|
|
||||||
private Map<String, Object> assembleSybg(String experimentId) {
|
private Map<String, Object> assembleSybg(String experimentId) {
|
||||||
Experiment experiment = experimentService.getById(experimentId);
|
Experiment experiment = experimentService.getById(experimentId);
|
||||||
|
experimentService.fetchExperimentDetail(experiment);
|
||||||
|
if (Objects.isNull(experiment)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
ExperimentReport latestReport = experimentReportService.getLatestReport(experimentId);
|
ExperimentReport latestReport = experimentReportService.getLatestReport(experimentId);
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
if (Objects.nonNull(latestReport)) {
|
||||||
|
params.put("审核人员姓名", Optional.ofNullable(sysUserService.getById(latestReport.getAuditor())).map(SysUser::getRealname)
|
||||||
|
.orElse(""));
|
||||||
|
params.put("校对人员姓名", Optional.ofNullable(sysUserService.getById(latestReport.getProofreader())).map(SysUser::getRealname)
|
||||||
|
.orElse(""));
|
||||||
|
params.put("批准人员姓名", Optional.ofNullable(sysUserService.getById(latestReport.getConfirmer())).map(SysUser::getRealname)
|
||||||
|
.orElse(""));
|
||||||
|
}
|
||||||
params.put("试验报告名称", experiment.getName());
|
params.put("试验报告名称", experiment.getName());
|
||||||
params.put("试验编号", experiment.getExperimentNo());
|
params.put("试验编号", experiment.getExperimentNo());
|
||||||
params.put("编制人员姓名", experiment.getExperimentNo());
|
params.put("编制人员姓名", Optional.ofNullable(sysUserService.getUserByName(experiment.getCreateBy())).map(SysUser::getRealname)
|
||||||
params.put("校对人员姓名", experiment.getExperimentNo());
|
.orElse(""));
|
||||||
params.put("审核人员姓名", experiment.getExperimentNo());
|
params.put("最后批准完成的日期", DateUtils.formatDate(latestReport.getUpdateTime(), "yyyy年MM月dd日"));
|
||||||
params.put("批准人员姓名", experiment.getExperimentNo());
|
Client client = clientService.getOne(new LambdaQueryWrapper<Client>().eq(Client::getName, experiment.getClientName()), false);
|
||||||
params.put("最后批准完成的日期", experiment.getExperimentNo());
|
params.put("委托方单位名称", Optional.ofNullable(client).map(Client::getName).orElse(""));
|
||||||
params.put("委托方单位名称", experiment.getExperimentNo());
|
params.put("委托方单位地址", Optional.ofNullable(client).map(Client::getAddress).orElse(""));
|
||||||
params.put("委托方单位地址", experiment.getExperimentNo());
|
List<ExperimentTestProcess> experimentTestProcesses = experimentTestProcessService.getByExperimentId(experiment.getId());
|
||||||
params.put("标准代号", experiment.getExperimentNo());
|
if (CollUtil.isNotEmpty(experimentTestProcesses)) {
|
||||||
params.put("标准名称", experiment.getExperimentNo());
|
String testStandardsId = experimentTestProcesses.get(0).getTestStandardsId();
|
||||||
params.put("依据的文件名称", experiment.getExperimentNo());
|
Optional<TestStandards> testStandards = Optional.ofNullable(testStandardsService.getById(testStandardsId));
|
||||||
|
params.put("标准代号", testStandards.map(TestStandards::getCode).orElse(""));
|
||||||
|
params.put("标准名称", testStandards.map(TestStandards::getName).orElse(""));
|
||||||
|
Path lastPathEle = PathUtil.getLastPathEle(Path.of(testStandards.map(TestStandards::getAttachment).orElse("")).getFileName());
|
||||||
|
params.put("依据的文件名称", lastPathEle.toString());
|
||||||
|
}
|
||||||
params.put("样品名称", experiment.getExperimentNo());
|
params.put("样品名称", experiment.getExperimentNo());
|
||||||
params.put("样品型号", experiment.getExperimentNo());
|
params.put("样品型号", experiment.getExperimentNo());
|
||||||
params.put("批次", experiment.getExperimentNo());
|
params.put("批次", experiment.getExperimentNo());
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user