|
|
@@ -0,0 +1,204 @@
|
|
|
+package com.yingpaipay.business.service.impl;
|
|
|
+
|
|
|
+import com.yingpaipay.business.domain.Document;
|
|
|
+import com.yingpaipay.business.domain.DocumentQcTask;
|
|
|
+import com.yingpaipay.business.domain.DocumentQcTaskDetail;
|
|
|
+import com.yingpaipay.business.domain.bo.DocumentQcTaskBo;
|
|
|
+import com.yingpaipay.business.domain.bo.DocumentQcTaskDetailBo;
|
|
|
+import com.yingpaipay.business.domain.vo.DocumentQcTaskDetailVo;
|
|
|
+import com.yingpaipay.business.domain.vo.DocumentQcTaskVo;
|
|
|
+import com.yingpaipay.business.mapper.DocumentQcTaskDetailMapper;
|
|
|
+import org.dromara.common.core.exception.BusinessException;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.system.domain.vo.SysUserVo;
|
|
|
+import org.dromara.system.service.ISysUserService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.yingpaipay.business.mapper.DocumentQcTaskMapper;
|
|
|
+import com.yingpaipay.business.service.IDocumentQcTaskService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 文档质控任务Service业务层处理
|
|
|
+ *
|
|
|
+ * @author Huanyi
|
|
|
+ * @date 2026-01-06
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class DocumentQcTaskServiceImpl implements IDocumentQcTaskService {
|
|
|
+
|
|
|
+ private final DocumentQcTaskMapper baseMapper;
|
|
|
+ private final DocumentQcTaskDetailMapper detailMapper;
|
|
|
+
|
|
|
+ private final CommonProjectService projectService;
|
|
|
+ private final CommonDocumentService documentService;
|
|
|
+ private final ISysUserService userService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询文档质控任务
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 文档质控任务
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public DocumentQcTaskVo queryById(Long id){
|
|
|
+ DocumentQcTaskVo vo = baseMapper.selectVoById(id);
|
|
|
+ List<DocumentQcTaskDetailVo> voList = detailMapper.selectVoList(
|
|
|
+ Wrappers.lambdaQuery(DocumentQcTaskDetail.class)
|
|
|
+ .eq(DocumentQcTaskDetail::getTaskId, vo.getId())
|
|
|
+ );
|
|
|
+ List<Long> documentIds = new ArrayList<>();
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
+ Map<Long, String> documentMap = new HashMap<>();
|
|
|
+ Map<Long, SysUserVo> userMap = new HashMap<>();
|
|
|
+ voList.forEach(e -> {
|
|
|
+ documentIds.add(e.getDocumentId());
|
|
|
+ userIds.add(e.getExecutor());
|
|
|
+ });
|
|
|
+ documentService.getByIds(documentIds).forEach(e -> documentMap.put(e.getId(), e.getName()));
|
|
|
+ userService.selectUserByIds(userIds).forEach(e -> userMap.put(e.getUserId(), e));
|
|
|
+ voList.forEach(e -> {
|
|
|
+ e.setDocumentName(documentMap.get(e.getDocumentId()));
|
|
|
+ SysUserVo executor = userMap.get(e.getExecutor());
|
|
|
+ e.setExecutorName(executor.getNickName());
|
|
|
+ e.setExecutorStatus(e.getStatus());
|
|
|
+ });
|
|
|
+ vo.setDetails(voList);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询文档质控任务列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @param pageQuery 分页参数
|
|
|
+ * @return 文档质控任务分页列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<DocumentQcTaskVo> queryPageList(DocumentQcTaskBo bo, PageQuery pageQuery) {
|
|
|
+ LambdaQueryWrapper<DocumentQcTask> lqw = buildQueryWrapper(bo);
|
|
|
+ Page<DocumentQcTaskVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ buildVo(result.getRecords());
|
|
|
+ return TableDataInfo.build(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void buildVo(List<DocumentQcTaskVo> result) {
|
|
|
+ List<Long> projectIds = new ArrayList<>();
|
|
|
+ result.forEach(e -> projectIds.add(e.getProjectId()));
|
|
|
+ Map<Long, String> projectMap = new HashMap<>();
|
|
|
+ projectService.queryByIds(projectIds).forEach(e -> projectMap.put(e.getId(), e.getName()));
|
|
|
+ result.forEach(e -> e.setProjectName(projectMap.get(e.getProjectId())));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询符合条件的文档质控任务列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @return 文档质控任务列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<DocumentQcTaskVo> queryList(DocumentQcTaskBo bo) {
|
|
|
+ LambdaQueryWrapper<DocumentQcTask> lqw = buildQueryWrapper(bo);
|
|
|
+ List<DocumentQcTaskVo> vos = baseMapper.selectVoList(lqw);
|
|
|
+ buildVo(vos);
|
|
|
+ return vos;
|
|
|
+ }
|
|
|
+
|
|
|
+ private LambdaQueryWrapper<DocumentQcTask> buildQueryWrapper(DocumentQcTaskBo bo) {
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ LambdaQueryWrapper<DocumentQcTask> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.orderByAsc(DocumentQcTask::getId);
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getName()), DocumentQcTask::getName, bo.getName());
|
|
|
+ lqw.eq(bo.getInitiator() != null, DocumentQcTask::getInitiator, bo.getInitiator());
|
|
|
+ lqw.eq(bo.getProjectId() != null, DocumentQcTask::getProjectId, bo.getProjectId());
|
|
|
+ lqw.between(params.get("beginStartDate") != null && params.get("endStartDate") != null,
|
|
|
+ DocumentQcTask::getStartDate ,params.get("beginStartDate"), params.get("endStartDate"));
|
|
|
+ lqw.between(params.get("beginDeadline") != null && params.get("endDeadline") != null,
|
|
|
+ DocumentQcTask::getDeadline ,params.get("beginDeadline"), params.get("endDeadline"));
|
|
|
+ lqw.eq(bo.getStatus() != null, DocumentQcTask::getStatus, bo.getStatus());
|
|
|
+ lqw.eq(bo.getCreateBy() != null, DocumentQcTask::getCreateBy, bo.getCreateBy());
|
|
|
+ lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
|
|
+ DocumentQcTask::getCreateTime ,params.get("beginCreateTime"), params.get("endCreateTime"));
|
|
|
+ lqw.eq(bo.getUpdateBy() != null, DocumentQcTask::getUpdateBy, bo.getUpdateBy());
|
|
|
+ lqw.between(params.get("beginUpdateTime") != null && params.get("endUpdateTime") != null,
|
|
|
+ DocumentQcTask::getUpdateTime ,params.get("beginUpdateTime"), params.get("endUpdateTime"));
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增文档质控任务
|
|
|
+ *
|
|
|
+ * @param bo 文档质控任务
|
|
|
+ * @return 是否新增成功
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBo(DocumentQcTaskBo bo) {
|
|
|
+ DocumentQcTask add = MapstructUtils.convert(bo, DocumentQcTask.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ boolean flag = baseMapper.insert(add) == 0;
|
|
|
+ if (flag) {
|
|
|
+ throw new BusinessException("新增指控任务失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ // FIXME 这里存在着问题 : 并发场景下生成了同一个文档的不同指控任务,暂不考虑
|
|
|
+ List<DocumentQcTaskDetailBo> details = bo.getDetails();
|
|
|
+ List<DocumentQcTaskDetail> list = new ArrayList<>();
|
|
|
+ details.forEach(e -> {
|
|
|
+ e.setTaskId(add.getId());
|
|
|
+ list.add(MapstructUtils.convert(e, DocumentQcTaskDetail.class));
|
|
|
+ });
|
|
|
+ boolean detailFlag = detailMapper.insertBatch(list);
|
|
|
+ if (!detailFlag) {
|
|
|
+ throw new BusinessException("指控细节插入失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改文档质控任务
|
|
|
+ *
|
|
|
+ * @param bo 文档质控任务
|
|
|
+ * @return 是否修改成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean updateByBo(DocumentQcTaskBo bo) {
|
|
|
+ DocumentQcTask update = MapstructUtils.convert(bo, DocumentQcTask.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(DocumentQcTask entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验并批量删除文档质控任务信息
|
|
|
+ *
|
|
|
+ * @param ids 待删除的主键集合
|
|
|
+ * @param isValid 是否进行有效性校验
|
|
|
+ * @return 是否删除成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return baseMapper.deleteByIds(ids) > 0;
|
|
|
+ }
|
|
|
+}
|