瀏覽代碼

Merge branch 'master' of http://39.108.216.210:3000/zhuwei/bladex

huangtf 5 月之前
父節點
當前提交
fd1a71f87f
共有 13 個文件被更改,包括 968 次插入181 次删除
  1. 34 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/ParameterDTO.java
  2. 34 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/ParameterElementDTO.java
  3. 56 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/Parameter.java
  4. 63 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ParameterElement.java
  5. 36 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ParameterVO.java
  6. 39 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ParameterElementVO.java
  7. 9 0
      blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java
  8. 204 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ParameterController.java
  9. 201 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ParameterElementController.java
  10. 168 167
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java
  11. 15 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
  12. 6 6
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java
  13. 103 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

+ 34 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/ParameterDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.dto;
+
+import org.springblade.manager.entity.Parameter;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 参数库数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2025-02-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ParameterDTO extends Parameter {
+	private static final long serialVersionUID = 1L;
+
+}

+ 34 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/ParameterElementDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.dto;
+
+import org.springblade.manager.entity.ParameterElement;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 参数库元素表数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2025-02-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ParameterElementDTO extends ParameterElement {
+	private static final long serialVersionUID = 1L;
+
+}

+ 56 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/Parameter.java

@@ -0,0 +1,56 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 参数库实体类
+ *
+ * @author BladeX
+ * @since 2025-02-20
+ */
+@Data
+@TableName("m_parameter")
+@EqualsAndHashCode(callSuper = true)
+public class Parameter extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 参数名称
+	*/
+		private String paramName;
+	/**
+	* 参数类型
+	*/
+		private String paramType;
+	/**
+	* 是否区分项目 1是 2否
+	*/
+		private Integer type;
+	/**
+	* 备注
+	*/
+		private String remarks;
+
+
+}

+ 63 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ParameterElement.java

@@ -0,0 +1,63 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 参数库元素表实体类
+ *
+ * @author BladeX
+ * @since 2025-02-21
+ */
+@Data
+@TableName("m_parameter_element")
+@EqualsAndHashCode(callSuper = true)
+public class ParameterElement extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 参数库ID
+	*/
+		private Long parameterId;
+	/**
+	* 元素名称
+	*/
+		private String elementName;
+	/**
+	* 是否全局参数 1是 2否
+	*/
+		private Integer type;
+
+	/**
+	* 项目id
+	*/
+		private Long projectId;
+
+	/**
+	* 合同段id
+	*/
+		private String contractId;
+
+
+
+}

+ 36 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ParameterVO.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.vo;
+
+import org.springblade.manager.entity.Parameter;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 参数库视图实体类
+ *
+ * @author BladeX
+ * @since 2025-02-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ParameterVO extends Parameter {
+	private static final long serialVersionUID = 1L;
+
+    private String paramTypeName;
+
+}

+ 39 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ParameterElementVO.java

@@ -0,0 +1,39 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.vo;
+
+import org.springblade.manager.entity.ParameterElement;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 参数库元素表视图实体类
+ *
+ * @author BladeX
+ * @since 2025-02-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ParameterElementVO extends ParameterElement {
+	private static final long serialVersionUID = 1L;
+
+    private String name;
+
+    private String projectName;
+
+    private String contractName;
+}

+ 9 - 0
blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java

@@ -2240,6 +2240,15 @@ public class CustomFunction {
             if (g) {
                 return result;
             } else {
+                if(result.get(0).equals("-")){
+                    String pattern = "^-?\\d+(\\.\\d+)?([+\\-*/]-?\\d+(\\.\\d+)?)*$";
+                    Pattern r = Pattern.compile(pattern);
+                    Matcher mm = r.matcher(String.valueOf(value));
+                    boolean b = mm.matches();
+                    if(b){
+                        return result.get(1);
+                    }
+                }
                 return result.get(0);
             }
         }

+ 204 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ParameterController.java

@@ -0,0 +1,204 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.manager.entity.ParameterElement;
+import org.springblade.manager.service.IParameterElementService;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.SingleColumnRowMapper;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestParam;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.manager.entity.Parameter;
+import org.springblade.manager.vo.ParameterVO;
+import org.springblade.manager.wrapper.ParameterWrapper;
+import org.springblade.manager.service.IParameterService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 参数库 控制器
+ *
+ * @author BladeX
+ * @since 2025-02-20
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/parameter")
+@Api(value = "参数库", tags = "参数库接口")
+public class ParameterController extends BladeController {
+
+	private final IParameterService parameterService;
+    private final IParameterElementService parameterElementService;
+    private final JdbcTemplate jdbcTemplate;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入parameter")
+	public R<ParameterVO> detail(Parameter parameter) {
+		Parameter detail = parameterService.getOne(Condition.getQueryWrapper(parameter));
+		return R.data(ParameterWrapper.build().entityVO(detail));
+	}
+
+	/**
+	 * 分页 参数库
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入parameter")
+	public R<IPage<ParameterVO>> list(Query query) {
+		IPage<Parameter> pages = parameterService.page(Condition.getPage(query));
+        IPage<ParameterVO> list = ParameterWrapper.build().pageVO(pages);
+        if(list.getRecords().size()>0){
+            for (ParameterVO vo : list.getRecords()) {
+                vo.setParamTypeName(getNameRuleV1(vo.getParamType()));
+            }
+        }
+        return R.data(list);
+	}
+
+
+	/**
+	 * 自定义分页 参数库
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入parameter")
+	public R<IPage<ParameterVO>> page(ParameterVO parameter, Query query) {
+		IPage<ParameterVO> pages = parameterService.selectParameterPage(Condition.getPage(query), parameter);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 参数库
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入parameter")
+	public R save(@Valid @RequestBody Parameter parameter) {
+		return R.status(parameterService.save(parameter));
+	}
+
+	/**
+	 * 修改 参数库
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入parameter")
+	public R update(@Valid @RequestBody Parameter parameter) {
+		return R.status(parameterService.updateById(parameter));
+	}
+
+	/**
+	 * 新增或修改 参数库
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入parameter")
+	public R submit(@Valid @RequestBody Parameter parameter) {
+        if(parameter.getParamType()==null){
+            return R.fail("参数识别类型不能为空");
+        }
+        String sql="select param_type from m_parameter where is_deleted=0";
+        List<String> list = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
+        if(list.size()>0){
+            if(list.contains(parameter.getType())){
+                return R.fail("当前识别类型已存在,创建失败");
+            }
+        }
+        parameter.setParamType(sortType(parameter.getParamType()));
+        parameterService.saveOrUpdate(parameter);
+		return R.success("创建成功");
+	}
+
+
+	/**
+	 * 删除 参数库
+	 */
+	@GetMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入id")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
+        List<ParameterElement> list = parameterElementService.getBaseMapper().selectList(new LambdaQueryWrapper<ParameterElement>().eq(ParameterElement::getParameterId, id).eq(ParameterElement::getIsDeleted,0));
+        if(list.size()>0){
+            return R.fail("该参数下存在元素,请先删除参数元素");
+        }
+        parameterService.getBaseMapper().deleteById(id);
+        return R.success("操作成功");
+	}
+
+    /**
+     * 排序
+     * @return
+     */
+    public String sortType(String type){
+        String[] strArray = type.split(",");
+        int[] intArray = new int[strArray.length];
+        for (int i = 0; i < strArray.length; i++) {
+            intArray[i] = Integer.parseInt(strArray[i]);
+        }
+        Arrays.sort(intArray);
+        StringBuilder sortedNumbers = new StringBuilder();
+        for (int i = 0; i < intArray.length; i++) {
+            sortedNumbers.append(intArray[i]);
+            if (i < intArray.length - 1) {
+                sortedNumbers.append(",");
+            }
+        }
+        return sortedNumbers.toString();
+    }
+
+    public String getNameRuleV1(String string){
+        // 定义工程名称到C格式的映射
+        Map<String, String> mapping = new HashMap<>();
+        mapping.put("0", "单位工程");
+        mapping.put("1", "子单位工程");
+        mapping.put("2", "分部工程");
+        mapping.put("3", "子分部工程");
+        mapping.put("4", "分项工程");
+        mapping.put("5", "子分项工程");
+        mapping.put("6", "工序");
+        mapping.put("7", "划分编号(质检)");
+        mapping.put("8", "范围随机数");
+        // 将输入字符串分割成列表
+        List<String> list = Arrays.asList(string.split(","));
+        return list.stream()
+            .map(mapping::get)
+            .collect(Collectors.joining("/"));
+    }
+
+}

+ 201 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ParameterElementController.java

@@ -0,0 +1,201 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.manager.dto.*;
+import org.springblade.manager.entity.ContractInfo;
+import org.springblade.manager.entity.ProjectInfo;
+import org.springblade.manager.vo.ParameterElementVo1;
+import org.springblade.manager.vo.ProjectInfoVO1;
+import org.springframework.beans.BeanUtils;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.SingleColumnRowMapper;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestParam;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.manager.entity.ParameterElement;
+import org.springblade.manager.vo.ParameterElementVO;
+import org.springblade.manager.wrapper.ParameterElementWrapper;
+import org.springblade.manager.service.IParameterElementService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * 参数库元素表 控制器
+ *
+ * @author BladeX
+ * @since 2025-02-21
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/parameterelement")
+@Api(value = "参数库元素", tags = "参数库元素接口")
+public class ParameterElementController extends BladeController {
+
+	private final IParameterElementService parameterElementService;
+    private final JdbcTemplate jdbcTemplate;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入parameterElement")
+	public R<ParameterElementVO> detail(ParameterElement parameterElement) {
+		ParameterElement detail = parameterElementService.getOne(Condition.getQueryWrapper(parameterElement));
+		return R.data(ParameterElementWrapper.build().entityVO(detail));
+	}
+
+	/**
+	 * 分页 参数库元素表
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入parameterElement")
+	public R<IPage<ParameterElementVO>> list(ParameterElement parameterElement, Query query) {
+		IPage<ParameterElement> pages = parameterElementService.page(Condition.getPage(query), Condition.getQueryWrapper(parameterElement));
+		return R.data(ParameterElementWrapper.build().pageVO(pages));
+	}
+
+
+	/**
+	 * 自定义分页 参数库元素表
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入parameterElement")
+	public R<IPage<ParameterElementVO>> page(ParameterElementVO parameterElement, Query query) {
+		IPage<ParameterElementVO> pages = parameterElementService.selectParameterElementPage(Condition.getPage(query), parameterElement);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 参数库元素表
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入parameterElement")
+	public R save(@Valid @RequestBody ParameterElement parameterElement) {
+		return R.status(parameterElementService.save(parameterElement));
+	}
+
+	/**
+	 * 修改 参数库元素表
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入parameterElement")
+	public R update(@Valid @RequestBody ParameterElement parameterElement) {
+		return R.status(parameterElementService.updateById(parameterElement));
+	}
+
+	/**
+	 * 新增或修改 参数库元素表
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入parameterElement")
+	public R submit(@Valid @RequestBody List<ParameterElementDTO1> dtos) {
+        for (ParameterElementDTO1 dto : dtos) {
+            ParameterElement p = new ParameterElement();
+            String sql="Select a.id,a.element_name,a.parameter_id,b.param_name from m_parameter_element a left join m_parameter b on a.parameter_id=b.id where a.is_deleted=0";
+            List<ParameterElementVo1> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ParameterElementVo1.class));
+            if(query.size()>0){
+                for (ParameterElementVo1 element : query) {
+                    if (element.getElementName().equals(dto.getElementName())&& !Objects.equals(element.getId(), dto.getId())) {
+                        return R.fail(element.getElementName()+"元素已被'"+element.getParameterName()+"'引用");
+                    }
+                }
+            }
+            if(dto.getId()!=null){
+                p.setId(dto.getId());
+            }
+            p.setParameterId(dto.getParameterId());
+            p.setElementName(dto.getElementName());
+            p.setType(dto.getType());
+            if(dto.getProjectList()!=null&&dto.getProjectList().size()>0){
+                for (ContractInfoDto3 dto3 : dto.getProjectList()) {
+                    ParameterElement element = new ParameterElement();
+                    BeanUtils.copyProperties(p,element);
+                    element.setProjectId(dto3.getProjectId());
+                    element.setContractId(dto3.getContractId());
+                    parameterElementService.saveOrUpdate(element);
+                }
+            }else {
+                parameterElementService.saveOrUpdate(p);
+            }
+        }
+        return R.success("操作成功");
+	}
+
+
+	/**
+	 * 删除 参数库元素表
+	 */
+	@GetMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String id) {
+		return R.status(parameterElementService.deleteLogic(Func.toLongList(id)));
+	}
+
+    @PostMapping("/getParameterElementList")
+    @ApiOperationSupport(order = 8)
+    @ApiOperation("根据参数库id,和查询条件查询参数元素")
+    /**
+     * 根据参数库id,和查询条件查询参数元素
+     * @param dto
+     * @return
+     */
+    public R<List<ParameterElementVO>> getParameterElementList(@RequestBody ParameterElementDTO dto) {
+        List<ParameterElementVO> list=parameterElementService.getParameterElementList(dto);
+        return R.data(list);
+    }
+
+    /**
+     * 根据参数id获取项目合同信息
+     * @param parameterId
+     * @return
+     */
+    @GetMapping("/getProjectContract")
+    @ApiOperationSupport(order = 9)
+    @ApiOperation("根据参数id获取项目合同信息")
+    public R<List<ProjectInfoVO1>> getProjectContract(@RequestParam Long parameterId){
+        String sql="select a.project_id,b.project_name from m_parameter_element a left join m_project_info b on a.project_id=b.id where a.parameter_id="+parameterId+" and a.is_deleted=0";
+        List<ProjectInfoVO1> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ProjectInfoVO1.class));
+        return R.data(list);
+    }
+
+}

+ 168 - 167
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java

@@ -22,6 +22,7 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.StringUtil;
 
+import org.springblade.manager.dto.NameRuleDto;
 import org.springblade.manager.dto.WbsTreePrivateDTO2;
 import org.springblade.manager.dto.WbsTreePrivateDTO3;
 import org.springblade.manager.entity.*;
@@ -829,172 +830,172 @@ public class WbsTreePrivateController extends BladeController {
         return wbsTreePrivateService.getExcelHtmlEntrust(nodeId,contractId);
     }
 
-//    @GetMapping("/getNameRule")
-//    @ApiOperationSupport(order = 33)
-//    @ApiOperation(value = "获取题名规则",notes = "获取题名规则")
-//    public R<List<NameRuleVo>> getNameRule(@RequestParam Long projectId){
-//        List<WbsParamVo2> list = iWbsParamService.selectNameRule(projectId);
-//        if(list.size()>0){
-//            Map<Long, List<WbsParamVo2>> map = list.stream()
-//                .collect(Collectors.groupingBy(WbsParamVo2::getNameId));
-//            List<NameRuleVo> vos=new ArrayList<>();
-//            for (Map.Entry<Long, List<WbsParamVo2>> entry : map.entrySet()) {
-//                NameRuleVo vo = new NameRuleVo();
-//                vo.setNameId(entry.getKey());
-//                vo.setNameVaule(entry.getValue().get(0).getV());
-//                vo.setNameRule(getNameRuleV1(entry.getValue().get(0).getV()));
-//                vo.setType(entry.getValue().get(0).getNameType());
-//                List<NameRuleVo1>vo1s=new ArrayList<>();
-//                for (WbsParamVo2 param : entry.getValue()) {
-//                    vo1s.add(new NameRuleVo1(param.getNodeId(),param.getNodeName()));
-//                }
-//                vo.setList(vo1s);
-//                vos.add(vo);
-//            }
-//            return R.data(vos);
-//        }
-//        return R.success("暂无题名规则");
-//    }
-//
-//    @GetMapping("/getTitleRange")
-//    @ApiOperationSupport(order = 33)
-//    @ApiOperation(value = "获取题名范围",notes = "获取题名范围")
-//    public R<List<TitleRangeVo>> getTitleRange(@RequestParam String projectId){
-//        List<WbsTreePrivate>list=wbsTreeService.getTitleRange(projectId);
-//        List<WbsParam> list1 = iWbsParamService.getBaseMapper().selectList(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getK, "FILE_TITLE").eq(WbsParam::getProjectId, projectId));
-//        if(list1.size()>0){
-//            List<Long> longs = list1.stream().map(l -> l.getNodeId()).collect(Collectors.toList());
-//            //判断是否已经被选中
-//            for (WbsTreePrivate wbsTreePrivate : list) {
-//                if(longs.contains(wbsTreePrivate.getId())){
-//                    wbsTreePrivate.setStatus(11);
-//                }
-//            }
-//        }
-//        return R.data(list.stream()
-//            .map(wbsTreePrivate -> {
-//                TitleRangeVo titleRangeVo = new TitleRangeVo();
-//                titleRangeVo.setId(wbsTreePrivate.getId());
-//                titleRangeVo.setNodeName(wbsTreePrivate.getNodeName());
-//                titleRangeVo.setStatus(wbsTreePrivate.getStatus());
-//                return titleRangeVo;
-//            })
-//            .collect(Collectors.toList()));
-//    }
-//
-//    @PostMapping("/saveOrUpdateNameRule")
-//    @ApiOperationSupport(order = 34)
-//    @ApiOperation(value = "新增或修改文件题名规则",notes = "新增或修改题名规则")
-//    public R saveOrUpdateNameRule(@RequestBody List<NameRuleDto> nameRuleDtos){
-//        if(nameRuleDtos!=null){
-//            for (NameRuleDto dto : nameRuleDtos) {
-//                WbsParam param = new WbsParam();
-//                param.setName("文件题名");
-//                param.setK("FILE_TITLE");
-//                param.setV(sortNameRule(dto.getNameRule()));
-//                param.setType(11);
-//                param.setProjectId(dto.getProjectId());
-//                param.setNameId(SnowFlakeUtil.getId());
-//                param.setNameType(dto.getType());
-//                //如果nameID不为空,先删除在保存
-//                if(dto.getNameId()!=null){
-//                    iWbsParamService.getBaseMapper().delete(new QueryWrapper<WbsParam>().eq("name_id",dto.getNameId()));
-//                }
-//                if(dto.getType()==1){
-//                    List<WbsTreePrivate>list=wbsTreeService.getTitleRange(dto.getProjectId()+"");
-//                    if(list.size()>0){
-//                        dto.setNodeId(list.stream()
-//                            .map(item -> String.valueOf(item.getId()))
-//                            .collect(Collectors.joining(",")));
-//                    }
-//                }
-//                String[] nodeIds = dto.getNodeId().split(",");
-//                if(nodeIds.length>0){
-//                    for (String nodeId : nodeIds) {
-//                        WbsParam p=new WbsParam();
-//                        BeanUtils.copyProperties(param,p);
-//                        p.setNodeId(Long.parseLong(nodeId));
-//                        iWbsParamService.getBaseMapper().insert(p);
-//                    }
-//                }else {
-//                    return R.fail("操作失败");
-//                }
-//            }
-//            return R.success("操作成功");
-//        }
-//        return R.fail("操作失败");
-//    }
-//
-//
-//
-//    /**
-//     * 删除文件题名规则
-//     * @return
-//     */
-//    @GetMapping("/deletedNameRule")
-//    @ApiOperationSupport(order = 35)
-//    @ApiOperation(value = "删除文件题名规则",notes = "删除文件题名规则")
-//    public R deletedNameRule(@RequestParam Long nameId){
-//        if(nameId!=null){
-//            int result = iWbsParamService.getBaseMapper().delete(new QueryWrapper<WbsParam>().eq("name_id", nameId));
-//            if(result>=1){
-//                return R.success("操作成功");
-//            }
-//        }
-//        return R.fail("操作失败");
-//    }
-//
-//    /**
-//     * 对文件题名规则排序
-//     * @return
-//     */
-//    public String sortNameRule(String rule){
-//        String[] codes = rule.split("-");
-//        Arrays.sort(codes, Comparator.comparingInt(s -> Integer.parseInt(s.substring(1))));
-//        return String.join("-", codes);
-//    }
-//    /**
-//     * 根据文件题名规则转换成C0-C6形式
-//     * @param string
-//     * @return
-//     */
-//    public String getNameRuleV(String string){
-//        // 定义工程名称到C格式的映射
-//        Map<String, String> mapping = new HashMap<>();
-//        mapping.put("单位工程", "C0");
-//        mapping.put("子单位工程", "C1");
-//        mapping.put("分部工程", "C2");
-//        mapping.put("子分部工程", "C3");
-//        mapping.put("分项工程", "C4");
-//        mapping.put("子分项工程", "C5");
-//        mapping.put("工序", "C6");
-//        // 将输入字符串分割成列表
-//        List<String> list = Arrays.asList(string.split(","));
-//        return list.stream()
-//            .map(mapping::get)
-//            .collect(Collectors.joining("-"));
-//    }
-//
-//    /**
-//     * 根据C0-C6转换成文件题名
-//     * @param string
-//     * @return
-//     */
-//    public String getNameRuleV1(String string){
-//        // 定义工程名称到C格式的映射
-//        Map<String, String> mapping = new HashMap<>();
-//        mapping.put("C0", "单位工程");
-//        mapping.put("C1", "子单位工程");
-//        mapping.put("C2", "分部工程");
-//        mapping.put("C3", "子分部工程");
-//        mapping.put("C4", "分项工程");
-//        mapping.put("C5", "子分项工程");
-//        mapping.put("C6", "工序");
-//        // 将输入字符串分割成列表
-//        List<String> list = Arrays.asList(string.split("-"));
-//        return list.stream()
-//            .map(mapping::get)
-//            .collect(Collectors.joining(","));
-//    }
+    @GetMapping("/getNameRule")
+    @ApiOperationSupport(order = 33)
+    @ApiOperation(value = "获取题名规则",notes = "获取题名规则")
+    public R<List<NameRuleVo>> getNameRule(@RequestParam Long projectId){
+        List<WbsParamVo2> list = iWbsParamService.selectNameRule(projectId);
+        if(list.size()>0){
+            Map<Long, List<WbsParamVo2>> map = list.stream()
+                .collect(Collectors.groupingBy(WbsParamVo2::getNameId));
+            List<NameRuleVo> vos=new ArrayList<>();
+            for (Map.Entry<Long, List<WbsParamVo2>> entry : map.entrySet()) {
+                NameRuleVo vo = new NameRuleVo();
+                vo.setNameId(entry.getKey());
+                vo.setNameVaule(entry.getValue().get(0).getV());
+                vo.setNameRule(getNameRuleV1(entry.getValue().get(0).getV()));
+                vo.setType(entry.getValue().get(0).getNameType());
+                List<NameRuleVo1>vo1s=new ArrayList<>();
+                for (WbsParamVo2 param : entry.getValue()) {
+                    vo1s.add(new NameRuleVo1(param.getNodeId(),param.getNodeName()));
+                }
+                vo.setList(vo1s);
+                vos.add(vo);
+            }
+            return R.data(vos);
+        }
+        return R.success("暂无题名规则");
+    }
+
+    @GetMapping("/getTitleRange")
+    @ApiOperationSupport(order = 33)
+    @ApiOperation(value = "获取题名范围",notes = "获取题名范围")
+    public R<List<TitleRangeVo>> getTitleRange(@RequestParam String projectId){
+        List<WbsTreePrivate>list=wbsTreeService.getTitleRange(projectId);
+        List<WbsParam> list1 = iWbsParamService.getBaseMapper().selectList(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getK, "FILE_TITLE").eq(WbsParam::getProjectId, projectId));
+        if(list1.size()>0){
+            List<Long> longs = list1.stream().map(l -> l.getNodeId()).collect(Collectors.toList());
+            //判断是否已经被选中
+            for (WbsTreePrivate wbsTreePrivate : list) {
+                if(longs.contains(wbsTreePrivate.getId())){
+                    wbsTreePrivate.setStatus(11);
+                }
+            }
+        }
+        return R.data(list.stream()
+            .map(wbsTreePrivate -> {
+                TitleRangeVo titleRangeVo = new TitleRangeVo();
+                titleRangeVo.setId(wbsTreePrivate.getId());
+                titleRangeVo.setNodeName(wbsTreePrivate.getNodeName());
+                titleRangeVo.setStatus(wbsTreePrivate.getStatus());
+                return titleRangeVo;
+            })
+            .collect(Collectors.toList()));
+    }
+
+    @PostMapping("/saveOrUpdateNameRule")
+    @ApiOperationSupport(order = 34)
+    @ApiOperation(value = "新增或修改文件题名规则",notes = "新增或修改题名规则")
+    public R saveOrUpdateNameRule(@RequestBody List<NameRuleDto> nameRuleDtos){
+        if(nameRuleDtos!=null){
+            for (NameRuleDto dto : nameRuleDtos) {
+                WbsParam param = new WbsParam();
+                param.setName("文件题名");
+                param.setK("FILE_TITLE");
+                param.setV(sortNameRule(dto.getNameRule()));
+                param.setType(11);
+                param.setProjectId(dto.getProjectId());
+                param.setNameId(SnowFlakeUtil.getId());
+                param.setNameType(dto.getType());
+                //如果nameID不为空,先删除在保存
+                if(dto.getNameId()!=null){
+                    iWbsParamService.getBaseMapper().delete(new QueryWrapper<WbsParam>().eq("name_id",dto.getNameId()));
+                }
+                if(dto.getType()==1){
+                    List<WbsTreePrivate>list=wbsTreeService.getTitleRange(dto.getProjectId()+"");
+                    if(list.size()>0){
+                        dto.setNodeId(list.stream()
+                            .map(item -> String.valueOf(item.getId()))
+                            .collect(Collectors.joining(",")));
+                    }
+                }
+                String[] nodeIds = dto.getNodeId().split(",");
+                if(nodeIds.length>0){
+                    for (String nodeId : nodeIds) {
+                        WbsParam p=new WbsParam();
+                        BeanUtils.copyProperties(param,p);
+                        p.setNodeId(Long.parseLong(nodeId));
+                        iWbsParamService.getBaseMapper().insert(p);
+                    }
+                }else {
+                    return R.fail("操作失败");
+                }
+            }
+            return R.success("操作成功");
+        }
+        return R.fail("操作失败");
+    }
+
+
+
+    /**
+     * 删除文件题名规则
+     * @return
+     */
+    @GetMapping("/deletedNameRule")
+    @ApiOperationSupport(order = 35)
+    @ApiOperation(value = "删除文件题名规则",notes = "删除文件题名规则")
+    public R deletedNameRule(@RequestParam Long nameId){
+        if(nameId!=null){
+            int result = iWbsParamService.getBaseMapper().delete(new QueryWrapper<WbsParam>().eq("name_id", nameId));
+            if(result>=1){
+                return R.success("操作成功");
+            }
+        }
+        return R.fail("操作失败");
+    }
+
+    /**
+     * 对文件题名规则排序
+     * @return
+     */
+    public String sortNameRule(String rule){
+        String[] codes = rule.split("-");
+        Arrays.sort(codes, Comparator.comparingInt(s -> Integer.parseInt(s.substring(1))));
+        return String.join("-", codes);
+    }
+    /**
+     * 根据文件题名规则转换成C0-C6形式
+     * @param string
+     * @return
+     */
+    public String getNameRuleV(String string){
+        // 定义工程名称到C格式的映射
+        Map<String, String> mapping = new HashMap<>();
+        mapping.put("单位工程", "C0");
+        mapping.put("子单位工程", "C1");
+        mapping.put("分部工程", "C2");
+        mapping.put("子分部工程", "C3");
+        mapping.put("分项工程", "C4");
+        mapping.put("子分项工程", "C5");
+        mapping.put("工序", "C6");
+        // 将输入字符串分割成列表
+        List<String> list = Arrays.asList(string.split(","));
+        return list.stream()
+            .map(mapping::get)
+            .collect(Collectors.joining("-"));
+    }
+
+    /**
+     * 根据C0-C6转换成文件题名
+     * @param string
+     * @return
+     */
+    public String getNameRuleV1(String string){
+        // 定义工程名称到C格式的映射
+        Map<String, String> mapping = new HashMap<>();
+        mapping.put("C0", "单位工程");
+        mapping.put("C1", "子单位工程");
+        mapping.put("C2", "分部工程");
+        mapping.put("C3", "子分部工程");
+        mapping.put("C4", "分项工程");
+        mapping.put("C5", "子分项工程");
+        mapping.put("C6", "工序");
+        // 将输入字符串分割成列表
+        List<String> list = Arrays.asList(string.split("-"));
+        return list.stream()
+            .map(mapping::get)
+            .collect(Collectors.joining(","));
+    }
 
 }

+ 15 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -4744,12 +4744,17 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             if( (elementValue.contains("时间") || elementValue.contains("日期")) && textareaElement == null){//特殊处理日期 没有id属性获取keyName
                 textareaElement = select.first();
                 String keyName = textareaElement.attr("keyName");
-                reData.put(keyName, value);
+                if(ObjectUtil.isNotEmpty(value)){
+                    reData.put(keyName, value);
+                }
+
                 return;
             }
             if(textareaElement != null){//正常情况
                 String id = textareaElement.attr("id");
-                reData.put(id, value);
+                if(ObjectUtil.isNotEmpty(value)){
+                    reData.put(id, value);
+                }
             }
 
         } else {// 没有找到 可能格式不同 换一种方式找
@@ -4762,7 +4767,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         List<Node> nodes = textareaElement.childNodes();
                         Node node = nodes.get(1);
                         String id = node.attributes().get("id");
-                        reData.put(id, value);
+                        if(ObjectUtil.isNotEmpty(value)){
+                            reData.put(id, value);
+                        }
+
                     }
                 }else {
                     System.out.println("没有找到[" + elementValue + "]的元素");
@@ -4772,7 +4780,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 Element textareaElement = select2.first();
                 if(textareaElement != null){//正常情况
                     String id = textareaElement.attr("id");
-                    reData.put(id, value);
+                    if(ObjectUtil.isNotEmpty(value)){
+                        reData.put(id, value);
+                    }
+
                 }
             }
         }

+ 6 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -1174,7 +1174,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             checkTable = op.get().getInitTableName();
         }
         for (FormData fd : tec.formDataList) {
-            if(fd.getCode().equals("m_20220929151226_1575382979125968896:key_17")){
+            if(fd.getCode().equals("m_20220928163111_1575040410223378432:key_14")){
                 System.out.println(111);
             }
             if (fd.verify()) {
@@ -5944,7 +5944,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             if (ObjectUtil.isEmpty(wbsTreeContract1)) {
                 return R.fail("表单不存在");
             }
-            if (wbsTreeContract1.getIsCopeTab().equals(Integer.valueOf(2))) {
+            if (wbsTreeContract1.getIsCopeTab()!=null&&wbsTreeContract1.getIsCopeTab().equals(Integer.valueOf(2))) {
                 return R.fail("该表不能评定汇总");
             }
             try {
@@ -6017,7 +6017,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                 String unitName = findUnitName(treeContract.getUnitName());
                 //如果包含单元名称就在原来的数量上加1,同时判断如果是自定义的节点就加自定义节点的单元数量
                 if (maps.containsKey(unitName)) {
-                    if (treeContract.getNodeClass() == 2) {
+                    if (treeContract.getNodeClass()!=null&&treeContract.getNodeClass() == 2) {
                         if (ObjectUtil.isNotEmpty(treeContract.getUnitNum())) {
                             maps.put(unitName, maps.get(unitName) + treeContract.getUnitNum());
                         }
@@ -6027,7 +6027,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                     }
                 } else {
                     //不包含就放进map 同时判断是否是自定义的节点
-                    if (treeContract.getNodeClass() == 2) {
+                    if (treeContract.getNodeClass()!=null&&treeContract.getNodeClass() == 2) {
                         if (ObjectUtil.isNotEmpty(treeContract.getUnitNum())) {
                             maps.put(unitName, treeContract.getUnitNum());
                         }
@@ -6040,7 +6040,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             //筛选出自定义数字化节点包含单元评定的节点
             List<WbsTreeContract> list1 = new ArrayList<>();
             for (WbsTreeContract childrenNode : list) {
-                if (childrenNode.getStatus() == 1) {
+                if (childrenNode.getStatus()!=null&&childrenNode.getStatus() == 1) {
                     if (ObjectUtil.isNotEmpty(childrenNode.getNodeClass())) {
                         if (childrenNode.getNodeClass() == 2) {
                             if (ObjectUtil.isNotEmpty(childrenNode.getIsClassifition())) {
@@ -6067,7 +6067,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             //水利工程 拿到除了自定义数字化上传节点以外的其他所有节点的表单
             List<WbsTreeContract> list2 = new ArrayList<>();
             for (WbsTreeContract childrenNode : list) {
-                if (childrenNode.getNodeClass() != 2) {
+                if (childrenNode.getNodeClass()!=null&&childrenNode.getNodeClass() != 2) {
                     String sql = "SELECT * from m_wbs_tree_contract where parent_id=" + childrenNode.getId() + " and is_deleted=0 and project_id=" + childrenNode.getProjectId() + " and contract_id=" + childrenNode.getContractId();
                     List<WbsTreeContract> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
                     if (query.size() > 0) {

+ 103 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -61,6 +61,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.jdbc.BadSqlGrammarException;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.SingleColumnRowMapper;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.LinkedCaseInsensitiveMap;
@@ -2206,26 +2207,124 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         WbsTreeContract wbsTreeContractRoot = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, pkeyId));
         //获取当前节点下所有子节点
         List<WbsTreeContractVO> wbsTreeContractVOS = contractInfoMapper.tree4(wbsTreeContractRoot.getContractId(), String.valueOf(wbsTreeContractRoot.getId()));
+        // 定义 nodeType 的优先级顺序 18是子单位工程,后期加上去的,不敢动原本的顺序
+        List<Integer> priorityOrder = Arrays.asList(1, 18, 2, 3, 4, 5);
+        // 自定义 Comparator
+        Comparator<WbsTreeContractVO> comparator = (vo1, vo2) -> {
+            int index1 = priorityOrder.indexOf(vo1.getNodeType());
+            int index2 = priorityOrder.indexOf(vo2.getNodeType());
+            return Integer.compare(index1, index2);
+        };
+        // 对集合进行排序
+        wbsTreeContractVOS.sort(comparator);
         if (wbsTreeContractVOS.size() <= 0) {
             throw new ServiceException("未查询到当前合同段的wbs树,请先分配该合同的合同段wsb树");
         }
         //本次新增的节点
-        List<String>insertList=new ArrayList<>();
+        List<WbsTreeContract>insertList=new ArrayList<>();
         //本次修改的节点
         List<String> updateList=new ArrayList<>();
 
-        //新增和修改
+        //导入节点与现有节点进行比较。进行修改编号
         for (ImportTreeDto dto : list) {
             for (WbsTreeContractVO vo : wbsTreeContractVOS) {
-                //wbs节点的名称和单位工程的名称类型能对应上,并且编号不一,就修改编号
+                //wbs节点和单位工程的名称类型能对应上,并且编号不一,就修改编号
                 if(vo.getNodeName().equals(dto.getUnitName())&&vo.getNodeType()==1){
-                    baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getUnitCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
+                    if(vo.getPartitionCode().equals(dto.getUnitCode())){
+                        baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getUnitCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
+                        updateList.add(vo.getNodeName());
+                    }
+                    dto.setIsUnit(true);
+                    continue;
+                }
+                //wbs节点和子单位工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
+                if(vo.getNodeName().equals(dto.getSubUnitName())&&vo.getNodeType()==18){
+                    if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName()),vo)){
+                        if(!vo.getPartitionCode().equals(dto.getSubUnitCode())){
+                            baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubUnitCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
+                            updateList.add(vo.getNodeName());
+                        }
+                        dto.setIsSubUnit(true);
+                    }
+                    continue;
+                }
+                //wbs节点和分部工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
+                if(vo.getNodeName().equals(dto.getDivisionName())&&vo.getNodeType()==2&&!vo.getPartitionCode().equals(dto.getDivisionName())){
+                    if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName()),vo)){
+                        baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getDivisionCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
+                        updateList.add(vo.getNodeName());
+                    }
+                    dto.setIsDivision(true);
                     continue;
                 }
+                //wbs节点和子分部工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
+                if(vo.getNodeName().equals(dto.getSubDivisionName())&&vo.getNodeType()==3&&!vo.getPartitionCode().equals(dto.getSubDivisionName())){
+                    if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName()),vo)){
+                        baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubDivisionCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
+                        updateList.add(vo.getNodeName());
+                    }
+                    dto.setIsSubDivision(true);
+                    continue;
+                }
+                //wbs节点和分项工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
+                if(vo.getNodeName().equals(dto.getItemName())&&vo.getNodeType()==4&&!vo.getPartitionCode().equals(dto.getItemName())){
+                    if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName(),dto.getItemName()),vo)){
+                        baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getItemCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
+                        updateList.add(vo.getNodeName());
+                    }
+                    dto.setIsItem(true);
+                    continue;
+                }
+                //wbs节点和子分项工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
+                if(vo.getNodeName().equals(dto.getSubItemName())&&vo.getNodeType()==5&&!vo.getPartitionCode().equals(dto.getSubItemName())){
+                    if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName(),dto.getItemName(),dto.getSubItemName()),vo)){
+                        baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubItemCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
+                        updateList.add(vo.getNodeName());
+                    }
+                    dto.setIsSubItem(true);
+                    break;
+                }
+            }
+        }
 
+        //新增
+        for (ImportTreeDto dto : list) {
+            //单位工程:如果没有被处理过,说明需要新增
+            if (!dto.getIsUnit()){
+                WbsTreeContract contract = new WbsTreeContract();
+                BeanUtil.copy(wbsTreeContractRoot,contract);
+                contract.setPKeyId(SnowFlakeUtil.getId());
+                contract.setId(SnowFlakeUtil.getId());
+                contract.setParentId(wbsTreeContractRoot.getId());
+                contract.setAncestors(wbsTreeContractRoot.getAncestors()+","+contract.getId());
+                contract.setIsCustom(1);
+                contract.setIsTypePrivatePid(null);
+                baseMapper.insert(contract);
+            }
+            //子单位工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。单位工程不会有相同的,所以直接根据名称查找
+            if(!dto.getIsSubUnit()){
+                WbsTreeContract fatherNode = baseMapper.selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, dto.getUnitName()).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
+                    .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
             }
         }
 
+
+    }
+
+    //判断名称是否都在wbs的祖级节点里面
+    private Boolean isTrueNode(List<String> list, WbsTreeContractVO vo){
+        String sql="select node_name from m_wbs_tree_contract where id in ("+String.join("','", vo.getAncestors().split(","))+")";
+        List<String> ancestorNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
+        list.removeIf(Objects::isNull);
+        if(!ancestorNames.isEmpty()){
+            if(ancestorNames.containsAll(list)){
+                return true;
+            }else {
+                return false;
+            }
+        }else {
+            return true;
+        }
     }
 
     /**