|
@@ -0,0 +1,794 @@
|
|
|
+package com.qunzhixinxi.hnqz.admin.manager;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.dto.SysArchiveDto;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysArchiveEntity;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysArchiveItem;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysCheckChainNodeCheckHistory;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysImplPlanDetails;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysImplPlanDetailsItem;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysImplementPlan;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysPlanPkg;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmPackageContract;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmPackageTaskTypeQty;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmScorePackage;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmScorePackageStatus;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmScoreTaskType;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTask;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskContent;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSupervision;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSupervisionAdvice;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysArchiveItemService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysArchiveService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysCheckChainNodeCheckHistoryService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysImplPlanDetailsItemService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysImplPlanDetailsService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysImplementPlanService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysPlanPkgService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmPackageContractService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmPackageTaskTypeQtyService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmScorePackageStatusService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmScoreTaskTypeService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskContentService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskSupervisionAdviceService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskSupervisionService;
|
|
|
+import com.qunzhixinxi.hnqz.common.core.exception.BizException;
|
|
|
+import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 归档管理器
|
|
|
+ *
|
|
|
+ * @author jimmy
|
|
|
+ * @date 2024-11-22 21:38
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class SysArchiveManager {
|
|
|
+
|
|
|
+ private final SysImplementPlanService implementPlanService;
|
|
|
+ private final SysImplPlanDetailsService implPlanDetailsService;
|
|
|
+ private final SysImplPlanDetailsItemService implPlanDetailsItemService;
|
|
|
+
|
|
|
+ private final SysPlanPkgService planPkgService;
|
|
|
+
|
|
|
+ private final WmScorePackageService packageService;
|
|
|
+ private final WmScorePackageStatusService packageStatusService;
|
|
|
+ private final WmPackageContractService packageContractService;
|
|
|
+ private final WmPackageTaskTypeQtyService packageTaskTypeQtyService;
|
|
|
+ private final WmScoreTaskTypeService packageTaskTypeService;
|
|
|
+
|
|
|
+ private final WmTaskService taskService;
|
|
|
+ private final WmTaskContentService taskContentService;
|
|
|
+
|
|
|
+ private final SysCheckChainNodeCheckHistoryService checkChainNodeCheckHistoryService;
|
|
|
+
|
|
|
+ private final WmTaskSupervisionService taskSupervisionService;
|
|
|
+ private final WmTaskSupervisionAdviceService taskSupervisionAdviceService;
|
|
|
+
|
|
|
+
|
|
|
+ private final SysArchiveService archiveService;
|
|
|
+ private final SysArchiveItemService archiveItemService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 归档计划
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean destroyPlan(SysArchiveDto.OnPlanArchive resource, HnqzUser operator) {
|
|
|
+
|
|
|
+ // 获取当前计划ID的记录
|
|
|
+ SysImplementPlan plan = implementPlanService.getById(resource.getPlanId());
|
|
|
+
|
|
|
+
|
|
|
+ if (plan == null) {
|
|
|
+ log.info("归档所需的根计划不存在");
|
|
|
+ throw new BizException("归档所需的根计划不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 判断是否是跟计划
|
|
|
+ boolean isRootPlan = (plan.getParentId() == 0);
|
|
|
+
|
|
|
+ // 获取要归档的数据
|
|
|
+ // 1.1 获取需要的的归档记录
|
|
|
+ List<SysImplementPlan> planRecords = getPlanRecords(plan);
|
|
|
+
|
|
|
+ // 1.2 获取所需要的归档详情
|
|
|
+ List<SysImplPlanDetails> planDetailsRecords = getPlanDetailsRecords(planRecords);
|
|
|
+
|
|
|
+ // 1.3 获取所有归档的拆机详情
|
|
|
+ List<SysImplPlanDetailsItem> planDetailsItemRecords = getPlanDetailsItemRecords(planDetailsRecords);
|
|
|
+
|
|
|
+ // 1.4 获取计划和执行包的关联关系
|
|
|
+ List<SysPlanPkg> planPkgRecords = getPlanPkgRecords(planRecords);
|
|
|
+
|
|
|
+ // 1.5 获取要归档的执行包
|
|
|
+ List<WmScorePackage> packageRecords = getPackageRecords(planPkgRecords);
|
|
|
+
|
|
|
+ // 1.6 获取要归档的领取记录
|
|
|
+ List<WmScorePackageStatus> packageStatusRecords = getPackageStatusRecords(packageRecords);
|
|
|
+
|
|
|
+ // 1.7 获取积分包的合同记录
|
|
|
+ List<WmPackageContract> packageContractRecords = getPackageContractRecords(packageRecords);
|
|
|
+
|
|
|
+ // 1.8 获取积分包任务类型个数
|
|
|
+ List<WmPackageTaskTypeQty> packageTaskTypeQtyRecords = getPackageTaskTypeQtyRecords(packageRecords);
|
|
|
+
|
|
|
+ // 1.9 获取原始积分包任务类型记录
|
|
|
+ List<WmScoreTaskType> scoreTaskTypeRecords = getScoreTaskTypeRecords(packageRecords);
|
|
|
+
|
|
|
+ // 1.10 获取任务记录
|
|
|
+ List<WmTask> taskRecords = getTaskRecords(packageRecords);
|
|
|
+
|
|
|
+ // 1.11 获取任务内容记录
|
|
|
+ List<WmTaskContent> taskContentRecords = getTaskContentRecords(taskRecords);
|
|
|
+
|
|
|
+ // 1.12 获取任务审核历史
|
|
|
+ List<SysCheckChainNodeCheckHistory> checkChainNodeCheckHistoryRecords = getCheckChainNodeCheckHistoryRecords(taskRecords);
|
|
|
+
|
|
|
+ // 1.13 获取监察记录
|
|
|
+ List<WmTaskSupervision> taskSupervisionRecords = getTaskSupervisionRecords(taskRecords);
|
|
|
+
|
|
|
+ // 1.14 获取监察建议记录
|
|
|
+ List<WmTaskSupervisionAdvice> taskSupervisionAdviceRecords = getTaskSupervisionAdviceRecords(taskSupervisionRecords);
|
|
|
+
|
|
|
+
|
|
|
+ // 保存归档信息
|
|
|
+ // 2.1 构建归档项
|
|
|
+ SysArchiveEntity archiveEntity = new SysArchiveEntity();
|
|
|
+ archiveEntity.setArchiveHead("PLAN");
|
|
|
+ archiveEntity.setOriginInfo(plan.getPlanName());
|
|
|
+ archiveEntity.setArchiveInfo(String.format("%s(%s终止)", plan.getPlanName(), DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN).format(LocalDateTime.now())));
|
|
|
+ archiveEntity.setArchiveReason(resource.getArchiveReason());
|
|
|
+ archiveEntity.setCreateBy(operator.getUsername());
|
|
|
+ archiveEntity.setCreateTime(LocalDateTime.now());
|
|
|
+ archiveService.save(archiveEntity);
|
|
|
+
|
|
|
+ // 2.2 构建归档项记录
|
|
|
+ Integer archiveId = archiveEntity.getArchiveId();
|
|
|
+ List<SysArchiveItem> items = new LinkedList<>();
|
|
|
+
|
|
|
+ // 2.2.1 归档计划
|
|
|
+ if (CollUtil.isNotEmpty(planRecords)) {
|
|
|
+
|
|
|
+ String clzName = SysImplementPlan.class.getSimpleName();
|
|
|
+ String fullClzName = SysImplementPlan.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = planRecords.stream().map(plan1 -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(plan1));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.2 归档计划详情
|
|
|
+ if (CollUtil.isNotEmpty(planDetailsRecords)) {
|
|
|
+
|
|
|
+ String clzName = SysImplPlanDetails.class.getSimpleName();
|
|
|
+ String fullClzName = SysImplPlanDetails.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = planDetailsRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.3 归档详情拆解
|
|
|
+ if (CollUtil.isNotEmpty(planDetailsItemRecords)) {
|
|
|
+ String clzName = SysImplPlanDetailsItem.class.getSimpleName();
|
|
|
+ String fullClzName = SysImplPlanDetailsItem.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = planDetailsItemRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.4 计划执行包关联关系
|
|
|
+ if (CollUtil.isNotEmpty(planPkgRecords)) {
|
|
|
+ String clzName = SysPlanPkg.class.getSimpleName();
|
|
|
+ String fullClzName = SysPlanPkg.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = planPkgRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.5 归档的执行包
|
|
|
+ if (CollUtil.isNotEmpty(packageRecords)) {
|
|
|
+ String clzName = WmScorePackage.class.getSimpleName();
|
|
|
+ String fullClzName = WmScorePackage.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = packageRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.6 归档领取记录
|
|
|
+ if (CollUtil.isNotEmpty(packageStatusRecords)) {
|
|
|
+ String clzName = WmScorePackageStatus.class.getSimpleName();
|
|
|
+ String fullClzName = WmScorePackageStatus.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = packageStatusRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.7 归档包合同
|
|
|
+ if (CollUtil.isNotEmpty(packageContractRecords)) {
|
|
|
+ String clzName = WmPackageContract.class.getSimpleName();
|
|
|
+ String fullClzName = WmPackageContract.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = packageContractRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.8 包任务类型分配数
|
|
|
+ if (CollUtil.isNotEmpty(packageTaskTypeQtyRecords)) {
|
|
|
+ String clzName = WmPackageTaskTypeQty.class.getSimpleName();
|
|
|
+ String fullClzName = WmPackageTaskTypeQty.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = packageTaskTypeQtyRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.9 原始任务类型数
|
|
|
+ if (CollUtil.isNotEmpty(scoreTaskTypeRecords)) {
|
|
|
+ String clzName = WmScoreTaskType.class.getSimpleName();
|
|
|
+ String fullClzName = WmScoreTaskType.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = scoreTaskTypeRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.10 任务记录
|
|
|
+ if (CollUtil.isNotEmpty(taskRecords)) {
|
|
|
+ String clzName = WmTask.class.getSimpleName();
|
|
|
+ String fullClzName = WmTask.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = taskRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.11 任务内容
|
|
|
+ if (CollUtil.isNotEmpty(taskContentRecords)) {
|
|
|
+ String clzName = WmTaskContent.class.getSimpleName();
|
|
|
+ String fullClzName = WmTaskContent.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = taskContentRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.12 审核历史
|
|
|
+ if (CollUtil.isNotEmpty(checkChainNodeCheckHistoryRecords)) {
|
|
|
+ String clzName = SysCheckChainNodeCheckHistory.class.getSimpleName();
|
|
|
+ String fullClzName = SysCheckChainNodeCheckHistory.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = checkChainNodeCheckHistoryRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.13 任务监察
|
|
|
+ if (CollUtil.isNotEmpty(taskSupervisionRecords)) {
|
|
|
+ String clzName = WmTaskSupervision.class.getSimpleName();
|
|
|
+ String fullClzName = WmTaskSupervision.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = taskSupervisionRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.2.14 任务监察建议
|
|
|
+ if (CollUtil.isNotEmpty(taskSupervisionAdviceRecords)) {
|
|
|
+ String clzName = WmTaskSupervisionAdvice.class.getSimpleName();
|
|
|
+ String fullClzName = WmTaskSupervisionAdvice.class.getName();
|
|
|
+
|
|
|
+ List<SysArchiveItem> collect = taskSupervisionAdviceRecords.stream().map(record -> {
|
|
|
+ SysArchiveItem item = new SysArchiveItem();
|
|
|
+ item.setClassName(clzName);
|
|
|
+ item.setFullClassName(fullClzName);
|
|
|
+ item.setItemContent(JSONUtil.toJsonStr(record));
|
|
|
+ item.setArchiveId(archiveId);
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ items.addAll(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ archiveItemService.saveBatch(items);
|
|
|
+
|
|
|
+
|
|
|
+ //~ 删除历史数据==========================
|
|
|
+ // 3.1 删除归档计划
|
|
|
+ if (CollUtil.isNotEmpty(planRecords)) {
|
|
|
+ Set<Integer> collect = planRecords.stream().mapToInt(SysImplementPlan::getPlanId).boxed().collect(Collectors.toSet());
|
|
|
+ implementPlanService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.2 删除归档计划详情
|
|
|
+ if (CollUtil.isNotEmpty(planDetailsRecords)) {
|
|
|
+ Set<Integer> collect = planDetailsRecords.stream().mapToInt(SysImplPlanDetails::getDetailsId).boxed().collect(Collectors.toSet());
|
|
|
+ implPlanDetailsService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.3 删除归档详情拆解
|
|
|
+ if (CollUtil.isNotEmpty(planDetailsItemRecords)) {
|
|
|
+ Set<Integer> collect = planDetailsItemRecords.stream().mapToInt(SysImplPlanDetailsItem::getItemId).boxed().collect(Collectors.toSet());
|
|
|
+ implPlanDetailsItemService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.4 删除计划执行包关联关系
|
|
|
+ if (CollUtil.isNotEmpty(planPkgRecords)) {
|
|
|
+ for (SysPlanPkg planPkg : planPkgRecords) {
|
|
|
+ planPkgService.remove(Wrappers.<SysPlanPkg>lambdaQuery()
|
|
|
+ .eq(SysPlanPkg::getPlanId, planPkg.getPlanId())
|
|
|
+ .eq(SysPlanPkg::getPkgId, planPkg.getPkgId()));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.5 删除归档的执行包
|
|
|
+ if (CollUtil.isNotEmpty(packageRecords)) {
|
|
|
+ Set<String> collect = packageRecords.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
+ packageService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.6 删除归档领取记录
|
|
|
+ if (CollUtil.isNotEmpty(packageStatusRecords)) {
|
|
|
+ Set<Integer> collect = packageStatusRecords.stream().map(WmScorePackageStatus::getId).collect(Collectors.toSet());
|
|
|
+ packageStatusService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.7 删除归档包合同
|
|
|
+ if (CollUtil.isNotEmpty(packageContractRecords)) {
|
|
|
+ Set<Integer> collect = packageContractRecords.stream().mapToInt(WmPackageContract::getContractId).boxed().collect(Collectors.toSet());
|
|
|
+ packageContractService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.8 删除包任务类型分配数
|
|
|
+ if (CollUtil.isNotEmpty(packageTaskTypeQtyRecords)) {
|
|
|
+ Set<Integer> collect = packageTaskTypeQtyRecords.stream().mapToInt(WmPackageTaskTypeQty::getRecordId).boxed().collect(Collectors.toSet());
|
|
|
+ packageTaskTypeQtyService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.9 删除原始任务类型数
|
|
|
+ if (CollUtil.isNotEmpty(scoreTaskTypeRecords)) {
|
|
|
+ Set<Long> collect = scoreTaskTypeRecords.stream().mapToLong(WmScoreTaskType::getId).boxed().collect(Collectors.toSet());
|
|
|
+ packageTaskTypeService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.10 删除任务记录
|
|
|
+ if (CollUtil.isNotEmpty(taskRecords)) {
|
|
|
+ Set<String> collect = taskRecords.stream().map(WmTask::getId).collect(Collectors.toSet());
|
|
|
+ taskService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.11 删除任务内容
|
|
|
+ if (CollUtil.isNotEmpty(taskContentRecords)) {
|
|
|
+ Set<Integer> collect = taskContentRecords.stream().mapToInt(WmTaskContent::getId).boxed().collect(Collectors.toSet());
|
|
|
+ taskContentService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.12 删除审核历史
|
|
|
+ if (CollUtil.isNotEmpty(checkChainNodeCheckHistoryRecords)) {
|
|
|
+ Set<Integer> collect = checkChainNodeCheckHistoryRecords.stream().mapToInt(SysCheckChainNodeCheckHistory::getHistoryId).boxed().collect(Collectors.toSet());
|
|
|
+ checkChainNodeCheckHistoryService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.13 删除任务监察
|
|
|
+ if (CollUtil.isNotEmpty(taskSupervisionRecords)) {
|
|
|
+ Set<Long> collect = taskSupervisionRecords.stream().mapToLong(WmTaskSupervision::getSupervisionId).boxed().collect(Collectors.toSet());
|
|
|
+ taskSupervisionService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.14 删除任务监察建议
|
|
|
+ if (CollUtil.isNotEmpty(taskSupervisionAdviceRecords)) {
|
|
|
+ Set<Long> collect = taskSupervisionAdviceRecords.stream().mapToLong(WmTaskSupervisionAdvice::getAdviceId).boxed().collect(Collectors.toSet());
|
|
|
+ taskSupervisionAdviceService.removeByIds(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ //~ 更新必要数据==========================
|
|
|
+ // 如果不是跟计划,需要父级更新可用分值
|
|
|
+ if (!isRootPlan) {
|
|
|
+
|
|
|
+ SysImplementPlan parentPlan = implementPlanService.getById(plan.getParentId());
|
|
|
+ parentPlan.setAvailScore(parentPlan.getAvailScore() + plan.getPlanScore());
|
|
|
+ parentPlan.setUpdateTime(LocalDateTime.now());
|
|
|
+ parentPlan.setUpdateBy(operator.getUsername());
|
|
|
+ implementPlanService.updateById(parentPlan);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取计划记录
|
|
|
+ *
|
|
|
+ * @param plan 根计划
|
|
|
+ * @return 需要归档的所有计划
|
|
|
+ */
|
|
|
+ private List<SysImplementPlan> getPlanRecords(SysImplementPlan plan) {
|
|
|
+
|
|
|
+ List<SysImplementPlan> archivePlans = new LinkedList<>();
|
|
|
+
|
|
|
+ archivePlans.add(plan);
|
|
|
+
|
|
|
+ List<Integer> queryIds = new LinkedList<>();
|
|
|
+ queryIds.add(plan.getPlanId());
|
|
|
+ while (true) {
|
|
|
+
|
|
|
+ List<SysImplementPlan> plans = implementPlanService.list(Wrappers.<SysImplementPlan>lambdaQuery().in(SysImplementPlan::getParentId, queryIds));
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(plans)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ archivePlans.addAll(plans);
|
|
|
+
|
|
|
+ queryIds = plans.stream().mapToInt(SysImplementPlan::getPlanId).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ return archivePlans;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取计划详情信息
|
|
|
+ *
|
|
|
+ * @param planRecords 计划
|
|
|
+ * @return 计划详情信息
|
|
|
+ */
|
|
|
+ private List<SysImplPlanDetails> getPlanDetailsRecords(Collection<SysImplementPlan> planRecords) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(planRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> planIds = planRecords.stream().mapToInt(SysImplementPlan::getPlanId).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return implPlanDetailsService.list(Wrappers.<SysImplPlanDetails>lambdaQuery().in(SysImplPlanDetails::getPlanId, planIds));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有归档详情拆解信息
|
|
|
+ *
|
|
|
+ * @param planDetailsRecords 计划详情信息
|
|
|
+ * @return 计划详情信息
|
|
|
+ */
|
|
|
+ private List<SysImplPlanDetailsItem> getPlanDetailsItemRecords(Collection<SysImplPlanDetails> planDetailsRecords) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(planDetailsRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> collect = planDetailsRecords.stream().mapToInt(SysImplPlanDetails::getDetailsId).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return implPlanDetailsItemService.list(Wrappers.<SysImplPlanDetailsItem>lambdaQuery().in(SysImplPlanDetailsItem::getDetailsId, collect));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取计划和执行包的关联关系
|
|
|
+ *
|
|
|
+ * @param planRecords 执行计划
|
|
|
+ * @return 关系列表
|
|
|
+ */
|
|
|
+ private List<SysPlanPkg> getPlanPkgRecords(Collection<SysImplementPlan> planRecords) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(planRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<Integer> planIds = planRecords.stream().mapToInt(SysImplementPlan::getPlanId).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return planPkgService.list(Wrappers.<SysPlanPkg>lambdaQuery().in(SysPlanPkg::getPlanId, planIds));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取关联执行包
|
|
|
+ *
|
|
|
+ * @param planPkgs 计划和执行包关联关系
|
|
|
+ * @return 关联的执行包集合
|
|
|
+ */
|
|
|
+ private List<WmScorePackage> getPackageRecords(Collection<SysPlanPkg> planPkgs) {
|
|
|
+ if (CollUtil.isEmpty(planPkgs)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> pkgIds = planPkgs.stream().map(pp -> pp.getPkgId().toString()).distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return packageService.listByIds(pkgIds);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取领取记录
|
|
|
+ *
|
|
|
+ * @param packageRecords 包信息
|
|
|
+ * @return 记录集合
|
|
|
+ */
|
|
|
+ private List<WmScorePackageStatus> getPackageStatusRecords(Collection<WmScorePackage> packageRecords) {
|
|
|
+ if (CollUtil.isEmpty(packageRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> collect = packageRecords.stream().map(WmScorePackage::getId).distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return packageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery().in(WmScorePackageStatus::getPackageId, collect));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取积分包合同
|
|
|
+ *
|
|
|
+ * @param packageRecords 积分包记录
|
|
|
+ * @return 合同集合
|
|
|
+ */
|
|
|
+ private List<WmPackageContract> getPackageContractRecords(Collection<WmScorePackage> packageRecords) {
|
|
|
+
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(packageRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> collect = packageRecords.stream().mapToInt(pkg -> Integer.parseInt(pkg.getId())).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return packageContractService.list(Wrappers.<WmPackageContract>lambdaQuery().in(WmPackageContract::getPackageId, collect));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取积分包任务类型记录数
|
|
|
+ *
|
|
|
+ * @param packageRecords 积分包记录
|
|
|
+ * @return 积分包任务类型数记录
|
|
|
+ */
|
|
|
+ private List<WmPackageTaskTypeQty> getPackageTaskTypeQtyRecords(Collection<WmScorePackage> packageRecords) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(packageRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> collect = packageRecords.stream().mapToInt(pkg -> Integer.parseInt(pkg.getId())).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return packageTaskTypeQtyService.listPkgTaskTypeQtyByPkgIds(collect);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取原始任务积分包任务类型记录
|
|
|
+ *
|
|
|
+ * @param packageRecords 执行包记录
|
|
|
+ * @return 记录集合
|
|
|
+ */
|
|
|
+ private List<WmScoreTaskType> getScoreTaskTypeRecords(Collection<WmScorePackage> packageRecords) {
|
|
|
+ if (CollUtil.isEmpty(packageRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> collect = packageRecords.stream().map(WmScorePackage::getId).distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return packageTaskTypeService.list(Wrappers.<WmScoreTaskType>lambdaQuery().in(WmScoreTaskType::getScoreId, collect));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取任务记录
|
|
|
+ *
|
|
|
+ * @param packageRecords 执行包记录
|
|
|
+ * @return 任务集合
|
|
|
+ */
|
|
|
+ private List<WmTask> getTaskRecords(Collection<WmScorePackage> packageRecords) {
|
|
|
+ if (CollUtil.isEmpty(packageRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> collect = packageRecords.stream().map(WmScorePackage::getId).distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return taskService.list(Wrappers.<WmTask>lambdaQuery().eq(WmTask::getScorePackageId, collect));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取任务内容
|
|
|
+ *
|
|
|
+ * @param taskRecords 任务记录
|
|
|
+ * @return 任务内容集合
|
|
|
+ */
|
|
|
+ private List<WmTaskContent> getTaskContentRecords(Collection<WmTask> taskRecords) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(taskRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> collect = taskRecords.stream().mapToInt(t -> Integer.parseInt(t.getTaskContentId())).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return taskContentService.listByIds(collect);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取任务监察记录
|
|
|
+ *
|
|
|
+ * @param taskRecords 任务记录
|
|
|
+ * @return 监察记录
|
|
|
+ */
|
|
|
+ private List<WmTaskSupervision> getTaskSupervisionRecords(Collection<WmTask> taskRecords) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(taskRecords)) {
|
|
|
+
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> collect = taskRecords.stream().mapToInt(t -> Integer.parseInt(t.getId())).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return taskSupervisionService.list(Wrappers.<WmTaskSupervision>lambdaQuery().in(WmTaskSupervision::getTaskId, collect));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取任务监察建议
|
|
|
+ *
|
|
|
+ * @param taskSupervisionRecords 任务监察记录
|
|
|
+ * @return 监察建议集合
|
|
|
+ */
|
|
|
+ private List<WmTaskSupervisionAdvice> getTaskSupervisionAdviceRecords(Collection<WmTaskSupervision> taskSupervisionRecords) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(taskSupervisionRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<Long> collect = taskSupervisionRecords.stream().mapToLong(WmTaskSupervision::getSupervisionId).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return taskSupervisionAdviceService.list(Wrappers.<WmTaskSupervisionAdvice>lambdaQuery().in(WmTaskSupervisionAdvice::getTaskSupervisionId, collect));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取任务审核历史
|
|
|
+ *
|
|
|
+ * @param taskRecords 任务记录
|
|
|
+ * @return 审核历史
|
|
|
+ */
|
|
|
+ private List<SysCheckChainNodeCheckHistory> getCheckChainNodeCheckHistoryRecords(Collection<WmTask> taskRecords) {
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(taskRecords)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> collect = taskRecords.stream().mapToInt(t -> Integer.parseInt(t.getId())).boxed().distinct().sorted().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return checkChainNodeCheckHistoryService.list(Wrappers.<SysCheckChainNodeCheckHistory>lambdaQuery().in(SysCheckChainNodeCheckHistory::getTargetId, collect));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|