|
@@ -4,16 +4,22 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.jfcloud.common.data.datascope.DataScope;
|
|
|
+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.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.sample.dto.SampleAuditDto;
|
|
|
import com.github.jfcloud.gene.sample.dto.SampleDetailDto;
|
|
|
import com.github.jfcloud.gene.sample.dto.SamplePageDto;
|
|
|
import com.github.jfcloud.gene.sample.entity.SampleInfo;
|
|
@@ -22,6 +28,7 @@ import com.github.jfcloud.gene.sample.mapper.SampleInfoMapper;
|
|
|
import com.github.jfcloud.gene.sample.service.SampleEditService;
|
|
|
import com.github.jfcloud.gene.sample.service.SampleInfoService;
|
|
|
import com.github.jfcloud.gene.sample.vo.SampleAnimalVo;
|
|
|
+import com.github.jfcloud.gene.sample.vo.SampleAuditVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SamplePageVo;
|
|
|
import com.github.jfcloud.gene.sample.vo.SampleSubmitVo;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -30,9 +37,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -41,6 +46,8 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
|
|
|
private final SampleAnimalServiceImpl sampleAnimalService;
|
|
|
private final FlowFileVersionService fileVersionService;
|
|
|
+ private final UserIdNameCache userIdNameCache;
|
|
|
+ private final FlowAuditService flowAuditService;
|
|
|
|
|
|
/**
|
|
|
* 根据样本检测类型获取对应的Service
|
|
@@ -147,7 +154,8 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
.like(StrUtil.isNotBlank(vo.getProject()), SampleInfo::getProjectName, vo.getProject())
|
|
|
.eq(StrUtil.isNotBlank(vo.getType()), SampleInfo::getType, vo.getType())
|
|
|
.eq(StrUtil.isNotBlank(vo.getStatus()), SampleInfo::getStatus, vo.getStatus())
|
|
|
- .eq(Objects.nonNull(vo.getApplicantId()), SampleInfo::getApplicantId, vo.getApplicantId());
|
|
|
+ .eq(Objects.nonNull(vo.getApplicantId()), SampleInfo::getApplicantId, vo.getApplicantId())
|
|
|
+ .orderByDesc(SampleInfo::getCreateTime);
|
|
|
Page<SampleInfo> page = baseMapper.selectPageByScope(pageQuery, wrapper, DataScope.of());
|
|
|
|
|
|
Page<SamplePageDto> pageResult = new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
|
|
@@ -182,6 +190,109 @@ public class SampleInfoServiceImpl extends ServiceImpl<SampleInfoMapper, SampleI
|
|
|
}
|
|
|
return detailDto;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void audit(Long id, SampleAuditVo vo) {
|
|
|
+ SampleInfo sampleInfo = getById(id);
|
|
|
+ Assert.notNull(sampleInfo, "样本检测信息不存在");
|
|
|
+ Assert.isFalse(GeneStatusEnum.SUBMIT_STATUS.contains(sampleInfo.getStatus()), "样本检测流程状态错误");
|
|
|
+
|
|
|
+ String nextStatus = "";
|
|
|
+ GeneStatusEnum statusEnum = Objects.requireNonNull(GeneStatusEnum.getByStatus(sampleInfo.getStatus()));
|
|
|
+ switch (statusEnum) {
|
|
|
+ case DEPART_LEADER:
|
|
|
+ Assert.isTrue(UserUtil.getUserId().equals(sampleInfo.getDepartLeaderId()), "抱歉,您不能审核本条记录");
|
|
|
+ nextStatus = GeneStatusEnum.PROJECT_MANAGEMENT.getStatus();
|
|
|
+ break;
|
|
|
+ case PROJECT_MANAGEMENT:
|
|
|
+ Assert.isTrue(UserUtil.getUserId().equals(sampleInfo.getProjectManageId()), "抱歉,您不能审核本条记录");
|
|
|
+ nextStatus = GeneStatusEnum.COMPLETED.getStatus();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ log.info("流程项目 ({}) 状态为{}", sampleInfo.getProjectName(), statusEnum.getDescription());
|
|
|
+ throw new IllegalArgumentException("流程状态错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存审批节点
|
|
|
+ FlowAudit flowAudit = new FlowAudit()
|
|
|
+ .setFlowId(id)
|
|
|
+ .setFlowType("sample." + sampleInfo.getType())
|
|
|
+ .setFlowStatus(sampleInfo.getStatus())
|
|
|
+ .setAuditResult(vo.getAuditResult())
|
|
|
+ .setRemarks(vo.getRemarks())
|
|
|
+ .setCreateSign(userIdNameCache.getSignPic(UserUtil.getUserId()));
|
|
|
+ if (StrUtil.isNotBlank(vo.getProcessMethod())) {
|
|
|
+ JSONObject dataObj = new JSONObject().fluentPut("processMethod", vo.getProcessMethod());
|
|
|
+ flowAudit.setAdditionalData(dataObj.toJSONString()).insert();
|
|
|
+ }
|
|
|
+ flowAudit.insert();
|
|
|
+
|
|
|
+ //审核不通过
|
|
|
+ if (StrConstant.NO.equals(vo.getAuditResult())) {
|
|
|
+ log.info("流程项目 ({}) 审核不通过", sampleInfo.getProjectName());
|
|
|
+
|
|
|
+ new SampleInfo()
|
|
|
+ .setId(id)
|
|
|
+ .setStatus(GeneStatusEnum.REJECTED.getStatus())
|
|
|
+ .updateById();
|
|
|
+
|
|
|
+// geneWord(id);
|
|
|
+//
|
|
|
+// notifyService.notify(id);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Assert.isTrue(StrConstant.YES.equals(vo.getAuditResult()), "审核结果错误");
|
|
|
+// if (GeneStatusEnum.PROJECT_MANAGEMENT.getStatus().equals(sampleInfo.getStatus())) {
|
|
|
+// Assert.isTrue(StrUtil.isNotBlank(vo.getApprovalNo()), "项目批准编号必填");
|
|
|
+// //检查批准编号的唯一性
|
|
|
+// long count = count(new LambdaQueryWrapper<>(SampleInfo.class)
|
|
|
+// .eq(SampleInfo::getApprovalNo, vo.getApprovalNo())
|
|
|
+// .eq(SampleInfo::getDeleted, WhetherEnum.NO.getCode()));
|
|
|
+// Assert.isTrue(count < 1, "项目批准编号已存在");
|
|
|
+// }
|
|
|
+
|
|
|
+ //审核通过
|
|
|
+ log.info("流程项目 ({}) 审核通过", sampleInfo.getProjectName());
|
|
|
+
|
|
|
+ sampleInfo = new SampleInfo();
|
|
|
+ //更新项目批准编号、修订号等
|
|
|
+ BeanUtil.copyProperties(vo, sampleInfo);
|
|
|
+ sampleInfo.setId(id)
|
|
|
+ .setStatus(nextStatus)
|
|
|
+ .updateById();
|
|
|
+
|
|
|
+// geneWord(id);
|
|
|
+// notifyService.notify(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SampleAuditDto> getAuditRecords(Long id) {
|
|
|
+ SampleInfo sampleInfo = getById(id);
|
|
|
+ Assert.notNull(sampleInfo, "样本检测信息不存在");
|
|
|
+
|
|
|
+ List<FlowAudit> auditList = flowAuditService.list(new LambdaQueryWrapper<>(FlowAudit.class)
|
|
|
+ .eq(FlowAudit::getFlowId, id)
|
|
|
+ .eq(FlowAudit::getFlowType, "sample." + sampleInfo.getType())
|
|
|
+ .eq(FlowAudit::getDeleted, WhetherEnum.NO.getCode())
|
|
|
+ .orderByAsc(FlowAudit::getCreateTime));
|
|
|
+ if (auditList.isEmpty()) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SampleAuditDto> auditDtos = new ArrayList<>();
|
|
|
+ for (FlowAudit audit : auditList) {
|
|
|
+ SampleAuditDto auditDto = BeanUtil.copyProperties(audit, SampleAuditDto.class);
|
|
|
+ auditDto.setCreateName(userIdNameCache.getNicknameByUserId(audit.getCreateBy()));
|
|
|
+ auditDto.setFlowStatusLabel(Objects.requireNonNull(GeneStatusEnum.getByStatus(audit.getFlowStatus())).getDescription());
|
|
|
+ if (StrUtil.isNotBlank(audit.getAdditionalData())) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(audit.getAdditionalData());
|
|
|
+ auditDto.setProcessMethod(jsonObject.getString("processMethod"));
|
|
|
+ }
|
|
|
+ auditDtos.add(auditDto);
|
|
|
+ }
|
|
|
+ return auditDtos;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|