|
@@ -2,16 +2,28 @@ package com.github.jfcloud.gene.sample.service.biz;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
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 com.github.jfcloud.gene.cache.UserIdNameCache;
|
|
|
import com.github.jfcloud.gene.common.constant.WhetherEnum;
|
|
import com.github.jfcloud.gene.common.constant.WhetherEnum;
|
|
|
import com.github.jfcloud.gene.common.util.CustomIdGenerator;
|
|
import com.github.jfcloud.gene.common.util.CustomIdGenerator;
|
|
|
import com.github.jfcloud.gene.file.entity.FileInfo;
|
|
import com.github.jfcloud.gene.file.entity.FileInfo;
|
|
|
import com.github.jfcloud.gene.file.service.FileInfoService;
|
|
import com.github.jfcloud.gene.file.service.FileInfoService;
|
|
|
import com.github.jfcloud.gene.file.vo.FileVo;
|
|
import com.github.jfcloud.gene.file.vo.FileVo;
|
|
|
|
|
+import com.github.jfcloud.gene.flow.service.FlowAuditService;
|
|
|
import com.github.jfcloud.gene.sample.entity.PathologicalPreExperiment;
|
|
import com.github.jfcloud.gene.sample.entity.PathologicalPreExperiment;
|
|
|
|
|
+import com.github.jfcloud.gene.sample.entity.SampleInfo;
|
|
|
import com.github.jfcloud.gene.sample.entity.SamplePathological;
|
|
import com.github.jfcloud.gene.sample.entity.SamplePathological;
|
|
|
|
|
+import com.github.jfcloud.gene.sample.mapper.SampleInfoMapper;
|
|
|
import com.github.jfcloud.gene.sample.mapper.SamplePathologicalMapper;
|
|
import com.github.jfcloud.gene.sample.mapper.SamplePathologicalMapper;
|
|
|
import com.github.jfcloud.gene.sample.service.PathologicalPreExperimentService;
|
|
import com.github.jfcloud.gene.sample.service.PathologicalPreExperimentService;
|
|
|
import com.github.jfcloud.gene.sample.service.SampleEditService;
|
|
import com.github.jfcloud.gene.sample.service.SampleEditService;
|
|
@@ -19,6 +31,10 @@ import com.github.jfcloud.gene.sample.service.SamplePathologicalService;
|
|
|
import com.github.jfcloud.gene.sample.vo.PreExperimentVo;
|
|
import com.github.jfcloud.gene.sample.vo.PreExperimentVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SamplePathologicalVo;
|
|
import com.github.jfcloud.gene.sample.vo.SamplePathologicalVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SampleSubmitVo;
|
|
import com.github.jfcloud.gene.sample.vo.SampleSubmitVo;
|
|
|
|
|
+import com.github.jfcloud.gene.util.LocalWord;
|
|
|
|
|
+import com.github.jfcloud.gene.util.WordDataService;
|
|
|
|
|
+import com.github.jfcloud.rich.vo.HtmlParseVo;
|
|
|
|
|
+import com.github.jfcloud.rich.word.WordNodeFactory;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -26,6 +42,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -41,8 +58,13 @@ public class SamplePathologicalServiceImpl extends ServiceImpl<SamplePathologica
|
|
|
* 病理样本-抗体信息附件类型
|
|
* 病理样本-抗体信息附件类型
|
|
|
*/
|
|
*/
|
|
|
public static final String PATHOLOGICAL_ANTIBODY_INFO = "pathological.antibodyInfo";
|
|
public static final String PATHOLOGICAL_ANTIBODY_INFO = "pathological.antibodyInfo";
|
|
|
|
|
+
|
|
|
|
|
+ private final SampleInfoMapper sampleInfoMapper;
|
|
|
private final PathologicalPreExperimentService preExperimentService;
|
|
private final PathologicalPreExperimentService preExperimentService;
|
|
|
private final FileInfoService fileInfoService;
|
|
private final FileInfoService fileInfoService;
|
|
|
|
|
+ private final WordDataService wordDataService;
|
|
|
|
|
+ private final UserIdNameCache userIdNameCache;
|
|
|
|
|
+ private final FlowAuditService flowAuditService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void removeBySampleId(Long sampleId) {
|
|
public void removeBySampleId(Long sampleId) {
|
|
@@ -119,7 +141,67 @@ public class SamplePathologicalServiceImpl extends ServiceImpl<SamplePathologica
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void generate(Long sampleId) {
|
|
public void generate(Long sampleId) {
|
|
|
|
|
+ SampleInfo sampleInfo = sampleInfoMapper.selectById(sampleId);
|
|
|
|
|
+ SamplePathologicalVo pathologicalVo = getDetail(sampleId);
|
|
|
|
|
+
|
|
|
|
|
+ //文件名称:课题名称-申请人-申请日期-随机四位.docx
|
|
|
|
|
+ String applyDate = DateUtil.format(sampleInfo.getApplyTime(), DatePattern.CHINESE_DATE_PATTERN);
|
|
|
|
|
+ String fileName = String.format("病理实验计划表-%s-%s-%s-%s.docx",
|
|
|
|
|
+ pathologicalVo.getSubjectName(), sampleInfo.getApplicantName(), applyDate,
|
|
|
|
|
+ RandomUtil.randomString(RandomUtil.BASE_CHAR_NUMBER_LOWER, 4));
|
|
|
|
|
+ log.info("生成word 课题名称:{} 文件名称:{}", pathologicalVo.getSubjectName(), fileName);
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject dataMap = new JSONObject();
|
|
|
|
|
+ wordDataService.fillDocCreator(dataMap);
|
|
|
|
|
+
|
|
|
|
|
+ //富文本图片
|
|
|
|
|
+ JSONArray images = new JSONArray();
|
|
|
|
|
+ dataMap.put("images", images);
|
|
|
|
|
+
|
|
|
|
|
+ //实验名称
|
|
|
|
|
+ List<PreExperimentVo> experiments = pathologicalVo.getExperiments();
|
|
|
|
|
+ AtomicInteger experimentIndex = new AtomicInteger(0);
|
|
|
|
|
+ experiments.forEach(item -> {
|
|
|
|
|
+ item.setTitle("实验" + Convert.numberToChinese(experimentIndex.incrementAndGet(), false));
|
|
|
|
|
+ if (StrUtil.isNotBlank(item.getFblx())) {
|
|
|
|
|
+ item.setFblx(item.getFblx().replace("未封闭", "未封"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(item.getXftj())) {
|
|
|
|
|
+ item.setXftj(item.getXftj().replace("高温高压", "温压"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(item.getSyjg())) {
|
|
|
|
|
+ HtmlParseVo parseVo = WordNodeFactory.html2xml(item.getSyjg());
|
|
|
|
|
+ item.setSyjg(parseVo.getContent());
|
|
|
|
|
+ images.addAll(parseVo.getImageCache());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject sampleInfoObj = JSON.parseObject(JSON.toJSONStringWithDateFormat(sampleInfo, DatePattern.NORM_DATETIME_PATTERN));
|
|
|
|
|
+ dataMap.put("sampleInfo", sampleInfoObj);
|
|
|
|
|
+ JSONObject pathologicalObj = JSON.parseObject(JSON.toJSONStringWithDateFormat(pathologicalVo, DatePattern.NORM_DATETIME_PATTERN));
|
|
|
|
|
+ dataMap.put("pathological", pathologicalObj);
|
|
|
|
|
+
|
|
|
|
|
+ //申请时间
|
|
|
|
|
+ String applyDateStr = DateUtil.format(sampleInfo.getApplyTime(), DatePattern.NORM_DATE_PATTERN);
|
|
|
|
|
+ sampleInfoObj.put("applyDate", applyDateStr);
|
|
|
|
|
+
|
|
|
|
|
+ //实验人员
|
|
|
|
|
+ if (StrUtil.isNotEmpty(pathologicalVo.getPrePeople())) {
|
|
|
|
|
+ String joinName = JSON.parseArray(pathologicalVo.getPrePeople())
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(item -> {
|
|
|
|
|
+ JSONObject obj = (JSONObject) item;
|
|
|
|
|
+ return obj.getString("nickname");
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect(Collectors.joining("、"));
|
|
|
|
|
+ pathologicalObj.put("prePeopleName", joinName);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ String modelName = "animalPathological.ftl";
|
|
|
|
|
+ if (LocalWord.exportWord(modelName, dataMap, fileName)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ fileInfoService.uploadFileWithFileName(modelName, fileName, sampleInfo.getId(), sampleInfo.getStatus(), dataMap);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|