|
@@ -22,6 +22,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.business.feignClient.ClientTreePublicCodeClientImpl;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
@@ -36,6 +37,7 @@ import org.springblade.business.service.ITreeContractFirstService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -54,6 +56,64 @@ public class TreeContractFirstController extends BladeController {
|
|
|
|
|
|
private final WbsTreeContractClient wbsTreeContractClient;
|
|
|
|
|
|
+ private final ClientTreePublicCodeClientImpl clientTreePublicCodeClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取合同段划分树中被标记为首件的节点
|
|
|
+ * @param parentId 父节点,为空则查询第一级节点
|
|
|
+ * @param contractId 合同段ID
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @GetMapping("/queryContractWbsTreeFirstByContractIdAndType")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "获取合同段划分树中被标记为首件的节点")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "parentId", value = "父节点,为空则查询第一级节点"),
|
|
|
+ @ApiImplicitParam(name = "contractId", value = "合同段ID", required = true)
|
|
|
+ })
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> queryContractWbsTreeFirstByContractIdAndType(@RequestParam String parentId, @RequestParam String contractId){
|
|
|
+ List<WbsTreeContractTreeVOS> rootTreeNode;
|
|
|
+ if(StringUtils.isEmpty(parentId)){
|
|
|
+ //为空,说明初始化
|
|
|
+ //获取根节点
|
|
|
+ rootTreeNode = this.clientTreePublicCodeClient.queryContractWbsTreeByContractIdAndType(contractId, 1, "0");
|
|
|
+ } else {
|
|
|
+ //不为空,获取其下子节点
|
|
|
+ rootTreeNode = this.wbsTreeContractClient.queryContractWbsTreeByContractIdAndType(contractId, 1, parentId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断这些节点哪些是标记为首件的
|
|
|
+ Iterator<WbsTreeContractTreeVOS> iterator = rootTreeNode.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ WbsTreeContractTreeVOS vos = iterator.next();
|
|
|
+
|
|
|
+ if(vos.getChildren() != null && vos.getChildren().size() != 0){
|
|
|
+ Iterator<WbsTreeContractTreeVOS> iterators = vos.getChildren().iterator();
|
|
|
+ while (iterators.hasNext()){
|
|
|
+ WbsTreeContractTreeVOS vo = iterators.next();
|
|
|
+ TreeContractFirst first = this.treeContractFirstService.getOne(Wrappers.<TreeContractFirst>lambdaQuery().eq(TreeContractFirst::getWbsNodeId, vo.getPrimaryKeyId()).eq(TreeContractFirst::getIsDeleted, 0));
|
|
|
+ if(first == null){
|
|
|
+ //如果当前节点没被标记为首件则不显示当前节点
|
|
|
+ iterators.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if("0".equals(vos.getParentId())){
|
|
|
+ //根节点不删除
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ TreeContractFirst first = this.treeContractFirstService.getOne(Wrappers.<TreeContractFirst>lambdaQuery().eq(TreeContractFirst::getWbsNodeId, vos.getPrimaryKeyId()).eq(TreeContractFirst::getIsDeleted, 0));
|
|
|
+ if(first == null){
|
|
|
+ //如果当前节点没被标记为首件则不显示当前节点
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(rootTreeNode);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增或删除 合同段划分树首件关联表
|
|
|
*/
|
|
@@ -99,11 +159,13 @@ public class TreeContractFirstController extends BladeController {
|
|
|
//新增父节点需要判断当前父节点是否已经被标记为首件
|
|
|
String[] parentIdArray = parentIds.toString().split(",");
|
|
|
for(String parentId : parentIdArray){
|
|
|
- //判断是否被标记为首件
|
|
|
- TreeContractFirst old = this.treeContractFirstService.getOne(Wrappers.<TreeContractFirst>lambdaQuery().eq(TreeContractFirst::getWbsNodeId, parentId).eq(TreeContractFirst::getIsDeleted, 0));
|
|
|
- if(old == null){
|
|
|
- //说明没有被标记,新增
|
|
|
- save.add(new TreeContractFirst(Long.parseLong(nodeData.getProjectId()), Long.parseLong(nodeData.getContractId()), Long.parseLong(parentId), user.getUserId(), user.getDeptId()));
|
|
|
+ if(StringUtils.isNotEmpty(parentId)){
|
|
|
+ //判断是否被标记为首件
|
|
|
+ TreeContractFirst old = this.treeContractFirstService.getOne(Wrappers.<TreeContractFirst>lambdaQuery().eq(TreeContractFirst::getWbsNodeId, parentId).eq(TreeContractFirst::getIsDeleted, 0));
|
|
|
+ if(old == null){
|
|
|
+ //说明没有被标记,新增
|
|
|
+ save.add(new TreeContractFirst(Long.parseLong(nodeData.getProjectId()), Long.parseLong(nodeData.getContractId()), Long.parseLong(parentId), user.getUserId(), user.getDeptId()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|