|
@@ -13,19 +13,23 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.jfcloud.admin.api.sys.dto.message.MessageUserDTO;
|
|
|
import com.github.jfcloud.gene.cache.UserIdNameCache;
|
|
|
import com.github.jfcloud.gene.common.constant.StrConstant;
|
|
|
import com.github.jfcloud.gene.common.constant.WhetherEnum;
|
|
|
import com.github.jfcloud.gene.common.util.CustomIdGenerator;
|
|
|
+import com.github.jfcloud.gene.common.util.UserUtil;
|
|
|
import com.github.jfcloud.gene.constants.GeneStatusEnum;
|
|
|
import com.github.jfcloud.gene.file.entity.FileInfo;
|
|
|
import com.github.jfcloud.gene.file.service.FileInfoService;
|
|
|
import com.github.jfcloud.gene.file.vo.FileVo;
|
|
|
import com.github.jfcloud.gene.flow.entity.FlowAudit;
|
|
|
import com.github.jfcloud.gene.flow.service.FlowAuditService;
|
|
|
+import com.github.jfcloud.gene.flow.service.NotifyService;
|
|
|
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.enums.SampleTypeEnum;
|
|
|
import com.github.jfcloud.gene.sample.mapper.SampleInfoMapper;
|
|
|
import com.github.jfcloud.gene.sample.mapper.SamplePathologicalMapper;
|
|
|
import com.github.jfcloud.gene.sample.service.PathologicalPreExperimentService;
|
|
@@ -34,6 +38,7 @@ import com.github.jfcloud.gene.sample.service.SamplePathologicalService;
|
|
|
import com.github.jfcloud.gene.sample.vo.PreExperimentVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SamplePathologicalVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SampleSubmitVo;
|
|
|
+import com.github.jfcloud.gene.sys.service.DBSystemPropertiesService;
|
|
|
import com.github.jfcloud.gene.util.WordDataService;
|
|
|
import com.github.jfcloud.rich.vo.HtmlParseVo;
|
|
|
import com.github.jfcloud.rich.word.WordNodeFactory;
|
|
@@ -41,9 +46,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -67,6 +70,8 @@ public class SamplePathologicalServiceImpl extends ServiceImpl<SamplePathologica
|
|
|
private final WordDataService wordDataService;
|
|
|
private final UserIdNameCache userIdNameCache;
|
|
|
private final FlowAuditService flowAuditService;
|
|
|
+ private final DBSystemPropertiesService systemPropertiesService;
|
|
|
+ private final NotifyService notifyService;
|
|
|
|
|
|
@Override
|
|
|
public void removeBySampleId(Long sampleId) {
|
|
@@ -94,8 +99,14 @@ public class SamplePathologicalServiceImpl extends ServiceImpl<SamplePathologica
|
|
|
SamplePathological samplePathological = BeanUtil.copyProperties(pathological, SamplePathological.class);
|
|
|
samplePathological.setId(CustomIdGenerator.nextId());
|
|
|
samplePathological.setSampleId(sampleId);
|
|
|
- //清空预实验相关的参数
|
|
|
- if (!pathological.getPreExperiment()) {
|
|
|
+
|
|
|
+ //保存预实验列表
|
|
|
+ if (pathological.getPreExperiment()) {
|
|
|
+ List<PathologicalPreExperiment> preExperiments = BeanUtil.copyToList(pathological.getExperiments(), PathologicalPreExperiment.class);
|
|
|
+ preExperiments.forEach(item -> item.setPathologicalId(samplePathological.getId()));
|
|
|
+ preExperimentService.saveBatch(preExperiments);
|
|
|
+ } else {
|
|
|
+ //清空预实验相关的参数
|
|
|
samplePathological.setPreDate("")
|
|
|
.setPrePeople("")
|
|
|
.setPreSubjectName("")
|
|
@@ -108,13 +119,6 @@ public class SamplePathologicalServiceImpl extends ServiceImpl<SamplePathologica
|
|
|
}
|
|
|
samplePathological.insert();
|
|
|
|
|
|
- //保存预实验列表
|
|
|
- if (pathological.getPreExperiment()) {
|
|
|
- List<PathologicalPreExperiment> preExperiments = BeanUtil.copyToList(pathological.getExperiments(), PathologicalPreExperiment.class);
|
|
|
- preExperiments.forEach(item -> item.setPathologicalId(samplePathological.getId()));
|
|
|
- preExperimentService.saveBatch(preExperiments);
|
|
|
- }
|
|
|
-
|
|
|
//保存附件列表
|
|
|
List<FileInfo> fileInfos = new ArrayList<>();
|
|
|
pathological.getSampleInfoFiles().forEach(f -> {
|
|
@@ -269,7 +273,43 @@ public class SamplePathologicalServiceImpl extends ServiceImpl<SamplePathologica
|
|
|
|
|
|
@Override
|
|
|
public void afterExecute(Long sampleId) {
|
|
|
+ //钉钉消息通知申请人、检测人员
|
|
|
+ if (!systemPropertiesService.getBooleanValue("sample.afterExecute.dingding.enable")) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ SampleInfo sampleInfo = sampleInfoMapper.selectById(sampleId);
|
|
|
+
|
|
|
+ String projectType = "样本送检/" + Objects.requireNonNull(SampleTypeEnum.resolve(sampleInfo.getType())).getLabel();
|
|
|
+ if (StrUtil.isNotBlank(sampleInfo.getProjectNo())) {
|
|
|
+ projectType += "/" + sampleInfo.getProjectNo();
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(sampleInfo.getProjectName())) {
|
|
|
+ projectType += "/" + sampleInfo.getProjectName();
|
|
|
+ }
|
|
|
+ String dingMsg = String.format("【%s】【%s】已执行项目", projectType, UserUtil.getNickName());
|
|
|
+
|
|
|
+ Set<Long> userIds = new HashSet<>();
|
|
|
+ //申请人
|
|
|
+ userIds.add(sampleInfo.getApplicantId());
|
|
|
+ //检测人员
|
|
|
+ if (StrUtil.isNotBlank(sampleInfo.getInspector())) {
|
|
|
+ JSON.parseArray(sampleInfo.getInspector()).forEach(item -> {
|
|
|
+ JSONObject obj = (JSONObject) item;
|
|
|
+ if (obj.containsKey("id")) {
|
|
|
+ userIds.add(obj.getLong("id"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ List<MessageUserDTO> users = userIds.stream()
|
|
|
+ .map(x -> {
|
|
|
+ MessageUserDTO messageUserDTO = new MessageUserDTO();
|
|
|
+ messageUserDTO.setUserId(x);
|
|
|
+ return messageUserDTO;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ notifyService.sendDingding("样本送检", dingMsg, users);
|
|
|
}
|
|
|
|
|
|
@Override
|