|
@@ -2,8 +2,11 @@ package org.springblade.manager.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import com.mixsmart.utils.StringUtils;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.business.vo.SaveLogContractVO;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.cache.utils.CacheUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
@@ -14,18 +17,26 @@ import org.springblade.core.tool.support.Kv;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.manager.dto.WbsTreePrivateDTO2;
|
|
|
import org.springblade.manager.dto.WbsTreePrivateDTO3;
|
|
|
+import org.springblade.manager.entity.ProjectInfo;
|
|
|
+import org.springblade.manager.entity.WbsTree;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
+import org.springblade.manager.service.IProjectInfoService;
|
|
|
import org.springblade.manager.service.IWbsTreePrivateService;
|
|
|
+import org.springblade.manager.service.IWbsTreeService;
|
|
|
import org.springblade.manager.vo.WbsNodeTableVO;
|
|
|
import org.springblade.manager.vo.WbsTreePrivateVO;
|
|
|
import org.springblade.manager.wrapper.WbsTreePrivateWrapper;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
|
@@ -45,6 +56,69 @@ public class WbsTreePrivateController extends BladeController {
|
|
|
private final WbsTreeContractMapper wbsTreeContractMapper;
|
|
|
private final WbsTreePrivateMapper wbsTreePrivateMapper;
|
|
|
|
|
|
+ private final IWbsTreeService wbsTreeService;
|
|
|
+
|
|
|
+ private final IProjectInfoService projectInfoService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存项目日志划分
|
|
|
+ */
|
|
|
+ @PostMapping("/saveContractLogNode")
|
|
|
+ @ApiOperationSupport(order = 12)
|
|
|
+ @ApiOperation(value = "保存项目日志划分")
|
|
|
+ public R<Boolean> saveContractLogNode(@RequestBody SaveLogContractVO vo){
|
|
|
+ if(StringUtils.isNotEmpty(vo.getWbsTreeIds())){
|
|
|
+ //获取当前项目已经划分的日志树
|
|
|
+ List<WbsTreePrivate> oldDataList = this.wbsTreePrivateService.list(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, vo.getProjectId()).eq(WbsTreePrivate::getWbsType, "4").eq(WbsTreePrivate::getWbsId, vo.getWbsId()));
|
|
|
+
|
|
|
+ //需要保存的集合
|
|
|
+ List<WbsTreePrivate> saveTreePrivateList = new ArrayList<>();
|
|
|
+
|
|
|
+ //模板节点
|
|
|
+ List<String> wbsTreeIds = new ArrayList<>(Arrays.asList(vo.getWbsTreeIds().split(",")));
|
|
|
+
|
|
|
+ if(oldDataList != null && oldDataList.size() > 0){
|
|
|
+ //只新增节点
|
|
|
+ //检查哪些节点是重复的,删除
|
|
|
+ Iterator<String> iterator = wbsTreeIds.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ String id = iterator.next();
|
|
|
+ for(WbsTreePrivate oldPrivate : oldDataList){
|
|
|
+ if(oldPrivate.getId().toString().equals(id)){
|
|
|
+ iterator.remove();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(wbsTreeIds.size() > 0){
|
|
|
+ //获取模板
|
|
|
+ List<WbsTree> wbsTreeList = this.wbsTreeService.list(Wrappers.<WbsTree>lambdaQuery().in(WbsTree::getId, wbsTreeIds));
|
|
|
+ //复制数据
|
|
|
+ for(WbsTree tree : wbsTreeList){
|
|
|
+ WbsTreePrivate treePrivate = new WbsTreePrivate();
|
|
|
+ BeanUtils.copyProperties(tree, treePrivate);
|
|
|
+ saveTreePrivateList.add(treePrivate);
|
|
|
+ treePrivate.setWbsType("4");
|
|
|
+ treePrivate.setProjectId(vo.getProjectId());
|
|
|
+ treePrivate.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
+ if(saveTreePrivateList.size() > 0){
|
|
|
+ //修改项目引用
|
|
|
+ this.projectInfoService.update(Wrappers.<ProjectInfo>lambdaUpdate().set(ProjectInfo::getReferenceLogWbsTemplateId, vo.getWbsId()).eq(ProjectInfo::getId, vo.getProjectId()));
|
|
|
+
|
|
|
+ //保存数据
|
|
|
+ return R.data(this.wbsTreePrivateService.saveBatch(saveTreePrivateList));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return R.data(200, true, "不需要新增节点");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.data(300, false, "保存失败");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 私有库节点逻辑删除
|
|
|
*/
|