|
@@ -1,9 +1,6 @@
|
|
|
package com.github.jfcloud.gene.sample.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.date.DatePattern;
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -13,7 +10,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.github.jfcloud.admin.api.sys.dto.message.MessageUserDTO;
|
|
|
import com.github.jfcloud.common.core.util.R;
|
|
|
import com.github.jfcloud.common.data.datascope.DataScope;
|
|
|
import com.github.jfcloud.gene.cache.UserIdNameCache;
|
|
@@ -26,7 +22,6 @@ 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.FlowFileVersionService;
|
|
|
-import com.github.jfcloud.gene.flow.service.NotifyService;
|
|
|
import com.github.jfcloud.gene.flow.vo.SynProjectVo;
|
|
|
import com.github.jfcloud.gene.sample.dto.SampleAuditDto;
|
|
|
import com.github.jfcloud.gene.sample.dto.SampleDetailDto;
|
|
@@ -38,6 +33,7 @@ import com.github.jfcloud.gene.sample.service.SampleEditService;
|
|
|
import com.github.jfcloud.gene.sample.service.SampleInfoService;
|
|
|
import com.github.jfcloud.gene.sample.service.biz.SampleAnimalImagingServiceImpl;
|
|
|
import com.github.jfcloud.gene.sample.service.biz.SampleAnimalServiceImpl;
|
|
|
+import com.github.jfcloud.gene.sample.service.biz.SampleFoodServiceImpl;
|
|
|
import com.github.jfcloud.gene.sample.service.biz.SamplePathologicalServiceImpl;
|
|
|
import com.github.jfcloud.gene.sample.vo.SampleAuditVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SamplePageVo;
|
|
@@ -63,10 +59,10 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
private final SampleAnimalServiceImpl sampleAnimalService;
|
|
|
private final SamplePathologicalServiceImpl samplePathologicalService;
|
|
|
private final SampleAnimalImagingServiceImpl sampleAnimalImagingService;
|
|
|
+ private final SampleFoodServiceImpl sampleFoodService;
|
|
|
private final FlowFileVersionService fileVersionService;
|
|
|
private final UserIdNameCache userIdNameCache;
|
|
|
private final FlowAuditService flowAuditService;
|
|
|
- private final NotifyService notifyService;
|
|
|
private final DBSystemPropertiesService systemPropertiesService;
|
|
|
private final RemoteProjectService remoteProjectService;
|
|
|
private final SubProjectFeign subProjectFeign;
|
|
@@ -85,6 +81,8 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
return sampleAnimalService;
|
|
|
case ANIMAL_IMAGE:
|
|
|
return sampleAnimalImagingService;
|
|
|
+ case ANIMAL_FOOD:
|
|
|
+ return sampleFoodService;
|
|
|
}
|
|
|
|
|
|
log.error("样本检测类型参数错误 type={}", type);
|
|
@@ -167,7 +165,7 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
.setCreateTime(new Date());
|
|
|
}
|
|
|
updateInfo.updateById();
|
|
|
- notify(id);
|
|
|
+ getServiceByType(sampleInfo.getType()).afterAudit(id);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -237,6 +235,9 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
case ANIMAL_IMAGE:
|
|
|
detailDto.setAnimalImage(sampleAnimalImagingService.getDetail(id));
|
|
|
break;
|
|
|
+ case ANIMAL_FOOD:
|
|
|
+ detailDto.setAnimalFood(sampleFoodService.getDetail(id));
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
return detailDto;
|
|
@@ -247,6 +248,7 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
SampleInfo sampleInfo = getById(id);
|
|
|
Assert.notNull(sampleInfo, "样本检测信息不存在");
|
|
|
Assert.isFalse(GeneStatusEnum.SUBMIT_STATUS.contains(sampleInfo.getStatus()), "样本检测流程状态错误");
|
|
|
+ SampleEditService service = getServiceByType(sampleInfo.getType());
|
|
|
|
|
|
String nextStatus = "";
|
|
|
GeneStatusEnum statusEnum = Objects.requireNonNull(GeneStatusEnum.getByStatus(sampleInfo.getStatus()));
|
|
@@ -287,8 +289,7 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
.setStatus(GeneStatusEnum.REJECTED.getStatus())
|
|
|
.updateById();
|
|
|
|
|
|
- generate(id);
|
|
|
- notify(id);
|
|
|
+ service.afterAudit(id);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -311,8 +312,7 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
.setStatus(nextStatus)
|
|
|
.updateById();
|
|
|
|
|
|
- generate(id);
|
|
|
- notify(id);
|
|
|
+ service.afterAudit(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -410,78 +410,6 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
getServiceByType(sampleInfo.getType()).afterExecute(id);
|
|
|
}
|
|
|
|
|
|
- private void notify(Long sampleId) {
|
|
|
- SampleInfo sampleInfo = getById(sampleId);
|
|
|
- if (sampleInfo == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //查询流程前一个状态
|
|
|
- List<FlowAudit> flowAudits = flowAuditService.auditList(sampleId, "sample." + sampleInfo.getType(), false);
|
|
|
- FlowAudit previousAudit = null;
|
|
|
- String previousStatus = "";
|
|
|
- String previousUser = "";
|
|
|
- if (CollUtil.isNotEmpty(flowAudits)) {
|
|
|
- previousAudit = flowAudits.get(0);
|
|
|
- GeneStatusEnum statusEnum = GeneStatusEnum.getByStatus(previousAudit.getFlowStatus());
|
|
|
- previousStatus = statusEnum != null ? statusEnum.getDescription() : "";
|
|
|
- previousUser = userIdNameCache.getNicknameByUserId(previousAudit.getCreateBy());
|
|
|
- }
|
|
|
-
|
|
|
- String projectType = "样本送检/" + Objects.requireNonNull(SampleTypeEnum.resolve(sampleInfo.getType())).getLabel();
|
|
|
- String proNo = StrUtil.emptyToDefault(sampleInfo.getProjectNo(), sampleInfo.getApprovalNo());
|
|
|
- if (StrUtil.isNotBlank(proNo)) {
|
|
|
- projectType += "/" + proNo;
|
|
|
- }
|
|
|
- String projectName = sampleInfo.getProjectName();
|
|
|
- if (StrUtil.isBlank(projectName) && StrUtil.isNotBlank(proNo)) {
|
|
|
- projectName = Objects.requireNonNull(SampleTypeEnum.resolve(sampleInfo.getType())).getLabel() + "-" + proNo;
|
|
|
- }
|
|
|
- if (StrUtil.isNotBlank(projectName)) {
|
|
|
- projectType += "/" + projectName;
|
|
|
- }
|
|
|
-
|
|
|
- String now = DateUtil.format(new Date(), DatePattern.CHINESE_DATE_TIME_PATTERN);
|
|
|
-
|
|
|
- Long userId;
|
|
|
- String dingMsg;
|
|
|
- GeneStatusEnum statusEnum = Objects.requireNonNull(GeneStatusEnum.getByStatus(sampleInfo.getStatus()));
|
|
|
- switch (statusEnum) {
|
|
|
- case REJECTED:
|
|
|
- //驳回通知申请人
|
|
|
- userId = Long.valueOf(sampleInfo.getCreateBy());
|
|
|
- dingMsg = String.format("【%s】【%s/%s】%s不同意,请修正后再提交", projectType, previousStatus, previousUser, now);
|
|
|
- break;
|
|
|
- case DEPART_LEADER:
|
|
|
- userId = sampleInfo.getDepartLeaderId();
|
|
|
- dingMsg = String.format("【%s】【%s】%s提交,请进行审查", projectType, userIdNameCache.getNicknameByUserId(sampleInfo.getCreateBy()), now);
|
|
|
- break;
|
|
|
- case PROJECT_MANAGEMENT:
|
|
|
- userId = sampleInfo.getProjectManageId();
|
|
|
- dingMsg = String.format("【%s】【%s/%s】%s同意,请进行审查", projectType, previousStatus, previousUser, now);
|
|
|
- break;
|
|
|
- case COMPLETED:
|
|
|
- //执行
|
|
|
- userId = Long.valueOf(sampleInfo.getCreateBy());
|
|
|
- dingMsg = String.format("【%s】【%s/%s】%s同意,请执行项目", projectType, previousStatus, previousUser, now);
|
|
|
- break;
|
|
|
- default:
|
|
|
- log.error("流程项目 ({}) 状态异常 {}", projectName, statusEnum.getDescription());
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (sampleInfo.getVersion() > 1) {
|
|
|
- dingMsg += "(第" + sampleInfo.getVersion() + "次申请)";
|
|
|
- }
|
|
|
-
|
|
|
- //查询是否需要钉钉通知
|
|
|
- String key = String.format("sample.%s.dingding.enable", sampleInfo.getStatus());
|
|
|
- if (systemPropertiesService.getBooleanValue(key)) {
|
|
|
- MessageUserDTO messageUserDTO = new MessageUserDTO();
|
|
|
- messageUserDTO.setUserId(userId);
|
|
|
- notifyService.sendDingding("样本送检", dingMsg, Collections.singletonList(messageUserDTO));
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|