|
|
@@ -5,11 +5,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.yingpaipay.business.domain.Document;
|
|
|
-import com.yingpaipay.business.domain.DocumentQcTaskDetail;
|
|
|
+import com.yingpaipay.business.constant.QcTaskStatusConst;
|
|
|
+import com.yingpaipay.business.domain.*;
|
|
|
+import com.yingpaipay.business.domain.bo.DocumentQcAuditBo;
|
|
|
import com.yingpaipay.business.domain.bo.DocumentQcTaskDetailListBo;
|
|
|
+import com.yingpaipay.business.domain.bo.TaskCenterQcListBo;
|
|
|
import com.yingpaipay.business.domain.vo.DocumentQcGenerateVo;
|
|
|
import com.yingpaipay.business.domain.vo.DocumentQcTaskDetailListVo;
|
|
|
+import com.yingpaipay.business.domain.vo.TaskCenterQcListVo;
|
|
|
+import com.yingpaipay.business.enumeration.DocumentQcStatusEnum;
|
|
|
+import com.yingpaipay.business.enumeration.DocumentStatusEnum;
|
|
|
+import com.yingpaipay.business.mapper.DocumentQcTaskLogMapper;
|
|
|
+import com.yingpaipay.business.mapper.DocumentQcTaskMapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.exception.BusinessException;
|
|
|
@@ -17,6 +24,8 @@ import org.dromara.common.core.utils.MessageUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
import org.dromara.system.domain.SysUser;
|
|
|
import org.dromara.system.domain.vo.SysUserVo;
|
|
|
import org.dromara.system.service.ISysUserService;
|
|
|
@@ -39,8 +48,11 @@ import java.util.*;
|
|
|
public class DocumentQcTaskDetailServiceImpl implements IDocumentQcTaskDetailService {
|
|
|
|
|
|
private final DocumentQcTaskDetailMapper baseMapper;
|
|
|
+ private final DocumentQcTaskLogMapper logMapper;
|
|
|
+ private final DocumentQcTaskMapper taskMapper;
|
|
|
|
|
|
private final CommonDocumentService documentService;
|
|
|
+ private final CommonProjectService projectService;
|
|
|
private final ISysUserService userService;
|
|
|
|
|
|
/**
|
|
|
@@ -88,7 +100,6 @@ public class DocumentQcTaskDetailServiceImpl implements IDocumentQcTaskDetailSer
|
|
|
result.add(vo);
|
|
|
}
|
|
|
|
|
|
- // TODO 不能创建空的质控任务
|
|
|
if (result.isEmpty()) {
|
|
|
throw new BusinessException("当前没有文档需要进行质控");
|
|
|
}
|
|
|
@@ -109,11 +120,12 @@ public class DocumentQcTaskDetailServiceImpl implements IDocumentQcTaskDetailSer
|
|
|
return TableDataInfo.build(page.convert(e -> {
|
|
|
DocumentQcTaskDetailListVo vo = new DocumentQcTaskDetailListVo();
|
|
|
vo.setId(e.getId());
|
|
|
- Document document = documentMap.get(e.getDocumentId());
|
|
|
|
|
|
+ Document document = documentMap.get(e.getDocumentId());
|
|
|
vo.setDocument(document.getId());
|
|
|
vo.setDocumentName(document.getName());
|
|
|
vo.setActualDocument(document.getActualDocument());
|
|
|
+
|
|
|
vo.setExecutor(e.getExecutor());
|
|
|
vo.setStatus(e.getStatus());
|
|
|
vo.setNote(e.getNote());
|
|
|
@@ -123,6 +135,121 @@ public class DocumentQcTaskDetailServiceImpl implements IDocumentQcTaskDetailSer
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public boolean audit(DocumentQcAuditBo bo) {
|
|
|
+
|
|
|
+ DocumentQcTaskDetail detail = baseMapper.selectById(bo.getDetailId());
|
|
|
+ Document document = documentService.selectById(detail.getDocumentId());
|
|
|
+ DocumentQcTaskLog log = new DocumentQcTaskLog();
|
|
|
+ log.setTaskId(detail.getTaskId());
|
|
|
+ log.setDetailId(detail.getId());
|
|
|
+ log.setExecutor(LoginHelper.getUserId());
|
|
|
+ log.setExecuteTime(new Date());
|
|
|
+ log.setResult(bo.getResult());
|
|
|
+ log.setQuestionType(bo.getRejectionType());
|
|
|
+ log.setOpinion(bo.getOpinion());
|
|
|
+ log.setDesignatedDealer(bo.getDesignatedDealer());
|
|
|
+ log.setDeadline(bo.getDeadline());
|
|
|
+ log.setTenantId(TenantHelper.getTenantId());
|
|
|
+
|
|
|
+ detail.setStatus(bo.getResult());
|
|
|
+ detail.setExecutionTime(new Date());
|
|
|
+
|
|
|
+ if (DocumentQcStatusEnum.pass(bo.getResult())) {
|
|
|
+ detail.setFinishTime(new Date());
|
|
|
+ document.setStatus(DocumentStatusEnum.QC_PASS.getValue());
|
|
|
+
|
|
|
+ } else {
|
|
|
+ document.setStatus(DocumentStatusEnum.QC_REJECT.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean detailFlag = baseMapper.updateById(detail) == 0;
|
|
|
+ if (detailFlag) {
|
|
|
+ throw new RuntimeException("修改质控细节失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean documentFlag = documentService.updateById(document);
|
|
|
+ if (!documentFlag) {
|
|
|
+ throw new RuntimeException("修改文档状态失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean logFlag = logMapper.insert(log) == 0;
|
|
|
+ if (logFlag) {
|
|
|
+ throw new RuntimeException("新增日志失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ long count = baseMapper.selectCount(Wrappers.lambdaQuery(DocumentQcTaskDetail.class).eq(DocumentQcTaskDetail::getTaskId, detail.getTaskId()).ne(DocumentQcTaskDetail::getStatus, DocumentQcStatusEnum.PASS.getCode()));
|
|
|
+ if (count == 0) {
|
|
|
+ boolean taskFlag = taskMapper.update(Wrappers.lambdaUpdate(DocumentQcTask.class).eq(DocumentQcTask::getId, detail.getTaskId()).set(DocumentQcTask::getStatus, QcTaskStatusConst.FINISHED)) == 0;
|
|
|
+ if (taskFlag) {
|
|
|
+ throw new RuntimeException("更新质控任务状态失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<TaskCenterQcListVo> listOnTaskCenter(TaskCenterQcListBo bo, PageQuery pageQuery) {
|
|
|
+
|
|
|
+ List<Long> taskIds = new ArrayList<>();
|
|
|
+ List<Long> projectIds = new ArrayList<>();
|
|
|
+ Map<Long, DocumentQcTask> taskMap = new HashMap<>();
|
|
|
+ Map<Long, String> projectMap = new HashMap<>();
|
|
|
+ taskMapper.selectList(Wrappers.lambdaQuery(DocumentQcTask.class).like(StringUtils.isNotBlank(bo.getTaskName()), DocumentQcTask::getName, bo.getTaskName()))
|
|
|
+ .forEach(e -> {
|
|
|
+ taskIds.add(e.getId());
|
|
|
+ taskMap.put(e.getId(), e);
|
|
|
+ });
|
|
|
+ projectService.queryListByName(bo.getProjectName())
|
|
|
+ .forEach(e -> {
|
|
|
+ projectIds.add(e.getId());
|
|
|
+ projectMap.put(e.getId(), e.getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ IPage<DocumentQcTaskDetail> page = baseMapper.selectPage(
|
|
|
+ pageQuery.build(),
|
|
|
+ buildListOnTaskCenterWrapper(bo, taskIds, projectIds)
|
|
|
+ );
|
|
|
+
|
|
|
+ return TableDataInfo.build(page.convert(e -> {
|
|
|
+ TaskCenterQcListVo vo = new TaskCenterQcListVo();
|
|
|
+ vo.setId(e.getId());
|
|
|
+ DocumentQcTask task = taskMap.get(e.getTaskId());
|
|
|
+ vo.setName(task.getName());
|
|
|
+ vo.setProjectName(projectMap.get(e.getProjectId()));
|
|
|
+ vo.setStatus(e.getStatus());
|
|
|
+ vo.setInitiator(task.getInitiator());
|
|
|
+ vo.setExecutor(e.getExecutor());
|
|
|
+ vo.setNote(e.getNote());
|
|
|
+ vo.setExecuteTime(e.getExecutionTime());
|
|
|
+ vo.setCreateTime(e.getCreateTime());
|
|
|
+ return vo;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ private LambdaQueryWrapper<DocumentQcTaskDetail> buildListOnTaskCenterWrapper(TaskCenterQcListBo bo, List<Long> taskIds, List<Long> projectIds) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DocumentQcTaskDetail> wrapper = Wrappers.lambdaQuery(DocumentQcTaskDetail.class)
|
|
|
+ .eq(bo.getStatus() != null, DocumentQcTaskDetail::getStatus, bo.getStatus())
|
|
|
+ .orderByDesc(DocumentQcTaskDetail::getId);
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(bo.getTaskName())) {
|
|
|
+ wrapper.in(DocumentQcTaskDetail::getTaskId, taskIds.isEmpty() ? List.of(-1L) : taskIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ wrapper.in(StringUtils.isNotBlank(bo.getProjectName()), DocumentQcTaskDetail::getProjectId, projectIds.isEmpty() ? List.of(-1L) : projectIds);
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(bo.getDocumentName())) {
|
|
|
+ List<Long> documentIds = new ArrayList<>();
|
|
|
+ documentService.selectByName(bo.getDocumentName(), projectIds).forEach(e -> documentIds.add(e.getId()));
|
|
|
+ wrapper.in(DocumentQcTaskDetail::getDocumentId, documentIds.isEmpty() ? List.of(-1L) : documentIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+
|
|
|
private LambdaQueryWrapper<DocumentQcTaskDetail> buildListPageWrapper(DocumentQcTaskDetailListBo bo, List<Long> documentIds) {
|
|
|
|
|
|
return Wrappers.lambdaQuery(DocumentQcTaskDetail.class)
|