Browse Source

Merge remote-tracking branch 'origin/master' into master

# Conflicts:
#	blade-service/blade-manager/src/main/java/org/springblade/manager/controller/FormulaController.java
yangyj 2 years ago
parent
commit
3b555170f3
21 changed files with 583 additions and 473 deletions
  1. 1 13
      blade-common/src/main/java/org/springblade/common/utils/BaseUtils.java
  2. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialDetectionDataPageDTO.java
  3. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSelfInspectionRecordPageDTO.java
  4. 1 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/RangeInfo.java
  5. 59 24
      blade-service/blade-business/src/main/java/org/springblade/business/controller/DatumPointController.java
  6. 2 2
      blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java
  7. 3 3
      blade-service/blade-business/src/main/java/org/springblade/business/excel/DatumPointExcel.java
  8. 13 6
      blade-service/blade-business/src/main/java/org/springblade/business/excel/DatumPointxyExcel.java
  9. 5 2
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.java
  10. 19 4
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.xml
  11. 138 206
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/DatumPointService.java
  12. 25 16
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDetectionDataServiceImpl.java
  13. 105 43
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  14. 1 1
      blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java
  15. 19 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ContractInfoController.java
  16. 22 10
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeController.java
  17. 4 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.java
  18. 3 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IContractInfoService.java
  19. 19 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java
  20. 1 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
  21. 137 139
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

+ 1 - 13
blade-common/src/main/java/org/springblade/common/utils/BaseUtils.java

@@ -1,6 +1,5 @@
 package org.springblade.common.utils;
 
-import cn.hutool.core.lang.func.Func;
 import com.alibaba.cloud.commons.lang.StringUtils;
 import org.springblade.common.constant.RegexConstant;
 
@@ -73,17 +72,6 @@ public class BaseUtils {
         return false;
     }
 
-    public static boolean isNumber(Object value) {
-        if((value==null)||value.toString().trim().length()==0){
-            return  false;
-        }
-        if(value instanceof  Number){
-            return true;
-        }
-        String pattern = "^[+-]?\\d+(\\.\\d+)?$";
-        Pattern r = Pattern.compile(pattern);
-        Matcher m = r.matcher(String.valueOf(value));
-        return m.matches();
-    }
+
 
 }

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialDetectionDataPageDTO.java

@@ -22,4 +22,7 @@ public class TrialDetectionDataPageDTO extends TrialDetectionData {
     @ApiModelProperty(value = "是否合格 '0'=不合格 '1'=合格")
     private String queryStatus;
 
+    @ApiModelProperty(value = "质检树的节点pKeyId")
+    private String qualityTestPKeyId;
+
 }

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSelfInspectionRecordPageDTO.java

@@ -22,4 +22,7 @@ public class TrialSelfInspectionRecordPageDTO extends TrialSelfInspectionRecord
     @ApiModelProperty(value = "是否合格 '0'=不合格 '1'=合格")
     private String queryStatus;
 
+    @ApiModelProperty(value = "质检树的节点pKeyId")
+    private String qualityTestPKeyId;
+
 }

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/RangeInfo.java

@@ -31,7 +31,7 @@ public class RangeInfo {
     private String key;
     @ApiModelProperty("表节点的唯一id")
     private Long pkId;
-    @ApiModelProperty("命名有误此字段应为:合格数量,也可以用百分比表示如2%")
+    @ApiModelProperty("合格数量,也可以用百分比表示如2%")
     private String fail;
     @ApiModelProperty("容量")
     private Integer capacity;

+ 59 - 24
blade-service/blade-business/src/main/java/org/springblade/business/controller/DatumPointController.java

@@ -14,11 +14,8 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springblade.business.entity.DatumPoint;
-import org.springblade.business.excel.DatumPointExcel;
-import org.springblade.business.excel.DatumPointxyExcel;
 import org.springblade.business.service.impl.DatumPointService;
 import org.springblade.business.vo.DatumPointVo;
-import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
@@ -38,7 +35,6 @@ import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 
 /**
  * @author yangyj
@@ -132,7 +128,7 @@ public class DatumPointController {
         if(file != null&& type!=null && contractId!=null&&projectId!=null) {
             String fileName = Objects.requireNonNull(file.getOriginalFilename());
             if(Pattern.matches(".+(\\.xls)x?$",fileName.toLowerCase(Locale.ROOT))) {
-                return this.service.importExcel(file,contractId,projectId,type);
+                return this.service.importData(file,contractId,projectId,type);
             } else {
                 R.fail("文件格式不正确,请上传Excel文件");
             }
@@ -152,25 +148,64 @@ public class DatumPointController {
 
         List<DatumPoint> list=this.service.exportExcel(contractId,type,search);
         if(list!=null&&list.size()>0){
-             if(type==0){
-                 List<DatumPointExcel> listA=list.stream().map(e->{
-                     DatumPointExcel dp = new DatumPointExcel();
-                     BeanUtils.copyProperties(e,dp);
-                     dp.setH(Func.toStr(e.getH()));
-                     return dp;
-                 }).collect(Collectors.toList());
-                 ExcelUtil.export(response, "水准点模板", "水准点模板", listA, DatumPointExcel.class);
-             }else{
-                 List<DatumPointxyExcel> listA=list.stream().map(e->{
-                     DatumPointxyExcel dp = new DatumPointxyExcel();
-                     BeanUtils.copyProperties(e,dp);
-                     dp.setH(Func.toStr(e.getH()));
-                     dp.setX(Func.toStr(e.getX()));
-                     dp.setY(Func.toStr(e.getY()));
-                     return dp;
-                 }).collect(Collectors.toList());
-                 ExcelUtil.export(response, "导线点模板", "导线点模板", listA, DatumPointxyExcel.class);
-             }
+            //创建HSSFWorkbook对象(excel的文档对象)
+            HSSFWorkbook wb = new HSSFWorkbook();
+            //创建sheet对象(excel的表单)
+            HSSFSheet sheet=wb.createSheet("测站点数据");
+            //创建第一行,这里即是表头。行的最小值是0,代表每一行,上限没研究过,可参考官方的文档
+            HSSFRow row1=sheet.createRow(0);
+            if(type==1) {
+                row1.createCell(0).setCellValue("测站点名称");
+                row1.createCell(1).setCellValue("x坐标(m)");
+                row1.createCell(2).setCellValue("y坐标(m)");
+                row1.createCell(3).setCellValue("高程(m)");
+                row1.createCell(4).setCellValue("等级");
+                row1.createCell(5).setCellValue("备注");
+                for (int i = 0; i < list.size(); i++) {
+                    HSSFRow row = sheet.createRow(i + 1);
+                    row.createCell(0).setCellValue(list.get(i).getName());
+                    row.createCell(1).setCellValue(list.get(i).getX());
+                    row.createCell(2).setCellValue(list.get(i).getY());
+                    row.createCell(3).setCellValue(list.get(i).getH());
+                    row.createCell(4).setCellValue(list.get(i).getLevel());
+                    row.createCell(5).setCellValue(list.get(i).getRemark());
+
+                }
+            }else if(type==0){
+                row1.createCell(0).setCellValue("测站点名称");
+                row1.createCell(1).setCellValue("高程(m)");
+                row1.createCell(2).setCellValue("等级");
+                row1.createCell(3).setCellValue("备注");
+                for (int i = 0; i < list.size(); i++) {
+                    HSSFRow row = sheet.createRow(i + 1);
+                    row.createCell(0).setCellValue(list.get(i).getName());
+                    row.createCell(1).setCellValue(list.get(i).getH());
+                    row.createCell(2).setCellValue(list.get(i).getLevel());
+                    row.createCell(3).setCellValue(list.get(i).getRemark());
+
+                }
+            }
+            //输出Excel文件
+            OutputStream output=response.getOutputStream();
+            response.reset();
+            Date dt = new Date();
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
+            String fileName = sdf.format(dt);
+            if(0==type){
+                fileName=fileName+"水准点.xls";
+            }else if(1==type){
+                fileName=fileName+"导线点.xls";
+            }
+            response.setContentType("application/x-msdownload");
+            response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
+            wb.write(output);
+            output.close();
+        }else {
+            response.setContentType("application/json;charset=UTF-8");
+            PrintWriter out = response.getWriter();
+            out.println(JSON.toJSONString(R.fail("没有查到到相关数据")));
+            out.flush();
+            out.close();
         }
 
     }

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -1518,8 +1518,8 @@ public class InformationWriteQueryController extends BladeController {
 
         if (queryProcess != null && queryProcess.size() > 0) {
             //检查这些填报节点是否存在已经审批或已经上报的节点,如果存在则不允许删除
-            List<QueryProcessDataVO> approvalList = queryProcess.stream().filter(vo -> new Integer(2).equals(vo.getStatus())).collect(Collectors.toList());
-            List<QueryProcessDataVO> runTaskList = queryProcess.stream().filter(vo -> new Integer(1).equals(vo.getStatus())).collect(Collectors.toList());
+            List<QueryProcessDataVO> approvalList = queryProcess.stream().filter(vo -> new Integer("2").equals(vo.getStatus())).collect(Collectors.toList());
+            List<QueryProcessDataVO> runTaskList = queryProcess.stream().filter(vo -> new Integer("1").equals(vo.getStatus())).collect(Collectors.toList());
             if (approvalList.size() > 0 || runTaskList.size() > 0) {
                 //说明存在已经审批或已经上报的节点,不允许删除
                 return R.data(300, false, "存在已经上报或审批的节点,不允许删除");

+ 3 - 3
blade-service/blade-business/src/main/java/org/springblade/business/excel/DatumPointExcel.java

@@ -18,10 +18,10 @@ import java.io.Serializable;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class DatumPointExcel implements Serializable {
-    @ExcelProperty(value = "测站点名称")
+    @ExcelProperty(value = "名称")
     private String name;
-    @ExcelProperty(value = "高程(m)")
-    private String h;
+    @ExcelProperty(value = "高程")
+    private Double h=0.0;
     @ExcelProperty(value = "等级")
     private String level;
     @ExcelProperty(value = "备注")

+ 13 - 6
blade-service/blade-business/src/main/java/org/springblade/business/excel/DatumPointxyExcel.java

@@ -14,14 +14,21 @@ import java.io.Serializable;
  * @Date 2022/6/9 11:01
  * @description TODO
  */
-@EqualsAndHashCode(callSuper = true)
 @Data
 @ColumnWidth(16)
 @HeadRowHeight(20)
 @ContentRowHeight(18)
-public class DatumPointxyExcel extends DatumPointExcel {
-    @ExcelProperty(value = "x坐标(m)",index=2)
-    private String x ;
-    @ExcelProperty(value = "y坐标(m)",index = 3)
-    private String y;
+public class DatumPointxyExcel implements Serializable {
+    @ExcelProperty(value = "名称")
+    private String name;
+    @ExcelProperty(value = "x坐标")
+    private Double x = 0.0;
+    @ExcelProperty(value = "y坐标")
+    private Double y = 0.0;
+    @ExcelProperty(value = "高程")
+    private Double h = 0.0;
+    @ExcelProperty(value = "等级")
+    private String level;
+    @ExcelProperty(value = "备注")
+    private String remark;
 }

+ 5 - 2
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.java

@@ -3,6 +3,7 @@ package org.springblade.business.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.springblade.business.entity.TrialSelfInspectionRecord;
+import org.springblade.manager.entity.WbsTreeContract;
 
 import java.util.List;
 
@@ -30,12 +31,14 @@ public interface TrialSelfInspectionRecordMapper extends BaseMapper<TrialSelfIns
 
     void updateInformationQuery(String id, String contractId, String classify, String link);
 
-    void deleteSeletedStatusByNodeId(String nodeId, Integer type);
+    void deleteSeletedStatusByNodeId(String nodeId, Integer type, String recordId);
 
     void insertSeletedStatus(Long id, String nodeId, Integer type, String recordId);
 
-    int selectCountSeletedStatus(String nodeId, Integer type);
+    List<String> selectCountSeletedStatus(String nodeId, Integer type);
 
     List<String> selectSelectedStatusList(Long nodeId, String type);
 
+    List<WbsTreeContract> selectWbsTreeContractListByPKeyIds(@Param("idList") List<String> ids);
+
 }

+ 19 - 4
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.xml

@@ -58,6 +58,9 @@
 
     <delete id="deleteSeletedStatusByNodeId">
         delete from u_trial_file_pdf_record where `type` = #{type} and node_id = #{nodeId}
+        <if test="recordId != null and recordId != ''">
+            and record_id = #{recordId}
+        </if>
     </delete>
 
     <select id="selectAll" resultType="org.springblade.business.entity.TrialSelfInspectionRecord">
@@ -84,12 +87,24 @@
         select pdf_url from u_information_query where wbs_id = #{id} and classify = #{classify} and contract_id = #{contractId} and is_deleted = 0
     </select>
 
-    <select id="selectCountSeletedStatus" resultType="java.lang.Integer">
-        select count(1) from u_trial_file_pdf_record where node_id = #{nodeId} and `type` != #{type}
-    </select>
-
     <select id="selectSelectedStatusList" resultType="java.lang.String">
         select record_id from u_trial_file_pdf_record where node_id = #{nodeId} and `type` in ( ${type} )
     </select>
 
+    <select id="selectCountSeletedStatus" resultType="java.lang.String">
+        select record_id from u_trial_file_pdf_record where node_id = #{nodeId} and `type` != #{type}
+    </select>
+
+    <select id="selectWbsTreeContractListByPKeyIds" resultType="org.springblade.manager.entity.WbsTreeContract" parameterType="java.util.List">
+        select node_name from m_wbs_tree_contract
+        <where>
+            <if test="idList.size()>0">
+                p_key_id in
+                <foreach collection="idList" item="id" index="index" open="(" close=")" separator=",">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
 </mapper>

+ 138 - 206
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/DatumPointService.java

@@ -2,30 +2,22 @@ package org.springblade.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import io.reactivex.Single;
 import lombok.AllArgsConstructor;
 import org.apache.poi.ss.usermodel.*;
 import org.springblade.business.entity.DatumPoint;
-import org.springblade.business.excel.DatumPointExcel;
-import org.springblade.business.excel.DatumPointxyExcel;
-import org.springblade.business.excel.MileageExcel;
 import org.springblade.business.mapper.DatumPointMapper;
 import org.springblade.business.utils.ExcelUtil;
-import org.springblade.common.utils.BaseUtils;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringPool;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.manager.feign.FormulaClient;
-import org.springframework.beans.BeanUtils;
-import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.FileNotFoundException;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @author yangyj
@@ -36,7 +28,6 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPoint> {
      private  final FormulaClient formulaClient;
-     private final JdbcTemplate   jdbc;
     public R<Object> site(Long contractId,Long pkId,String key) throws FileNotFoundException {
           Map<String,Object> result = new HashMap<>();
           if(Func.isNotEmpty(contractId)&&Func.isNotEmpty(pkId)&&Func.isNotEmpty(key)) {
@@ -79,214 +70,155 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
           }
           return  R.data(result);
     }
-    public  static  List<String> LEVEL = new ArrayList<>(Arrays.asList("一级","二级","三级","四级"));
-    public R importExcel(MultipartFile file, Long contractId, Long projectId, Integer dataType) {
+
+    public R importData(MultipartFile file, Long contractId, Long projectId, Integer dataType) throws Exception {
+        List<String> level=new ArrayList<>();
+        level.add("一级");
+        level.add("二级");
+        level.add("三级");
+        level.add("四级");
         try {
-            StringBuilder sb = new StringBuilder();
-            List<DatumPointxyExcel> data = org.springblade.core.excel.util.ExcelUtil.read(file,DatumPointxyExcel.class);
-            if(Func.isNotEmpty(data)){
-                List<String> names=data.stream().map(DatumPointxyExcel::getName).filter(Func::isNotBlank).collect(Collectors.toList());
-                List<String> checkNames= new ArrayList<>();
-                if(Func.isNotEmpty(names)){
-                    checkNames= this.jdbc.queryForList("select name from t_om_datum_point where  is_deleted=0 and type="+dataType+" and contract_id ="+contractId+" and name in('"+String.join("','",names)+"')",String.class);
+            Workbook wb = WorkbookFactory.create(file.getInputStream());
+            Sheet sheet = wb.getSheetAt(0);
+            List<DatumPoint> importList = new ArrayList<>();
+            Row row1=sheet.getRow(0);
+            if(dataType==0){
+                String dengji= ExcelUtil.getValue(row1.getCell(2)).toString();
+                String beizhu=ExcelUtil.getValue(row1.getCell(3)).toString();
+                if( !"等级".equals(dengji)||!"备注".equals(beizhu)){
+                    return  R.fail("导入的数据格式有错,请对准导入模板确认!");
+                }
+            }
+            if(dataType==1){
+                String dengji=ExcelUtil.getValue(row1.getCell(4)).toString();
+                String beizhu=ExcelUtil.getValue(row1.getCell(5)).toString();
+                if( !"等级".equals(dengji)||!"备注".equals(beizhu)){
+                    return  R.fail("导入的数据格式有错,请对准导入模板确认!");
+                }
+            }
+
+            for (int i = 1; ; i++) {
+                Row row = sheet.getRow(i);
+                if(row == null) {
+                    break;
                 }
-                List<String> finalCheckNames = checkNames;
-                Map<Boolean,List<DatumPointxyExcel>> map = data.stream().collect(Collectors.partitioningBy(d->Func.isNotBlank(d.getName())&&LEVEL.contains(d.getLevel())&&!finalCheckNames.contains(d.getName())));
-                List<DatumPointxyExcel> checked = map.get(true);
-                List<DatumPointxyExcel> fail=map.get(false);
-                if(Func.isNotEmpty(checked)){
-                    List<DatumPoint> result= checked.stream().map(d->{
-                        DatumPoint dp = new DatumPoint();
-                        BeanUtils.copyProperties(d,dp);
-                        if(BaseUtils.isNumber(d.getH())){
-                            dp.setH(Func.toDouble(d.getH()));
+                if(dataType==0) {
+                    DatumPoint obj = new DatumPoint();
+                    for (int j = 0; j < 4; j++) {
+                        String value = (String) ExcelUtil.getValue(row.getCell(j));
+                        if (StringUtil.isEmpty(value)) {
+                            value = "";
+                        }
+                        String msg="";
+                        //判断测站点名称是否为空
+                        String name=(String)ExcelUtil.getValue(row.getCell(0));
+                        if(StringUtil.isEmpty(name)){
+                            msg="第"+i+"行,测站点名称为空,请输入!";
+                            return  R.fail(msg);
+                        }
+                        //判断,同一合同段下,测站点名称是否重复
+                        if(this.count(Wrappers.<DatumPoint>lambdaQuery().eq(DatumPoint::getName,name).eq(DatumPoint::getContractId,contractId).eq(DatumPoint::getType,dataType))>0){
+                            msg="第"+i+"行,测站点:"+name+"已存在,请修改";
+                            return  R.fail(msg);
                         }
-                        if(dataType==1){
-                            if(BaseUtils.isNumber(d.getX())){
-                                dp.setX(Func.toDouble(d.getX()));
-                            }
-                            if(BaseUtils.isNumber(d.getY())){
-                                dp.setY(Func.toDouble(d.getY()));
-                            }
+                        switch (j) {
+                            case 0:
+                                obj.setName(value);
+                                break;
+                            case 1:
+                                obj.setH(Double.parseDouble(value));
+                                break;
+                            case 2:
+                                //判断等级是否为:一级、二级、三级、四级
+                                if(StringUtil.isNotBlank((String) ExcelUtil.getValue(row.getCell(j)))) {
+                                    if(!level.contains(value)){
+                                        msg="第"+i+"行,等级应该为:一级、二级、三级 或 四级,请修改!";
+                                        return  R.fail(msg);
+                                    }
+                                    obj.setLevel(value);
+                                }
+                                break;
+                            case 3:
+                                obj.setRemark(value);
+                                break;
+                            default:
+                                break;
                         }
-                        dp.setContractId(contractId);
-                        dp.setProjectId(projectId);
-                        dp.setCreateTime(new Date());
-                        dp.setType(dataType);
-                        return dp;
-                    }).collect(Collectors.toList());
-                    this.saveBatch(result);
-                    sb.append(result.size()).append("条记录导入成功");
+
+                    }
+                    obj.setContractId(contractId);
+                    obj.setProjectId(projectId);
+                    obj.setCreateTime(new Date());
+                    obj.setType(dataType);
+                    importList.add(obj);
                 }
-                if(Func.isNotEmpty(fail)){
-                   List<String> error=fail.stream().map(e->{
-                       if(Func.isEmpty(e.getName())){
-                           return "第"+(data.indexOf(e)+1)+"条记录测站点名称为空";
-                       }else if(!LEVEL.contains(e.getLevel())){
-                           return e.getName()+"等级必须为一级、二级、三级、四级";
-                       }else{
-                           return e.getName()+"已存在";
-                       }
-                   }).collect(Collectors.toList());
-                   sb.append(String.join(";",error));
+                if(dataType==1){
+                    DatumPoint obj = new DatumPoint();
+                    for (int j = 0; j < 6; j++) {
+                        String value = (String) ExcelUtil.getValue(row.getCell(j));
+                        if (StringUtil.isEmpty(value)) {
+                            value = "";
+                        }
+                        String msg="";
+                        //判断测站点名称是否为空
+                        String name=(String)ExcelUtil.getValue(row.getCell(0));
+                        if(StringUtil.isEmpty(name)){
+                            msg="第"+i+"行,测站点名称为空,请输入!";
+                            return  R.fail(msg);
+                        }
+                        //判断,同一合同段下,测站点名称是否重复
+                        if(this.count(Wrappers.<DatumPoint>lambdaQuery().eq(DatumPoint::getName,name).eq(DatumPoint::getContractId,contractId).eq(DatumPoint::getType,dataType))>0){
+                            msg="第"+i+"行,测站点:"+name+"已存在,请修改";
+                            return  R.fail(msg);
+                        }
+                        switch (j) {
+                            case 0:
+                                obj.setName(value);
+                                break;
+                            case 1:
+                                obj.setX(Double.parseDouble(value));
+                                break;
+                            case 2:
+                                obj.setY(Double.parseDouble(value));
+                                break;
+                            case 3:
+                                obj.setH(Double.parseDouble(value));
+                                break;
+                            case 4:
+                                //判断等级是否为:一级、二级、三级、四级
+                                if(StringUtil.isNotBlank((String) ExcelUtil.getValue(row.getCell(j)))) {
+                                    if(!level.contains(value)){
+                                        msg="第"+i+"行,等级应该为:一级、二级、三级 或 四级,请修改!";
+                                        return  R.fail(msg);
+                                    }
+                                    obj.setLevel(value);
+                                }
+                                break;
+                            case 5:
+                                obj.setRemark(value);
+                                break;
+                            default:
+                                break;
+                        }
+
+                    }
+                    obj.setContractId(contractId);
+                    obj.setProjectId(projectId);
+                    obj.setCreateTime(new Date());
+                    obj.setType(dataType);
+                    importList.add(obj);
                 }
-                return R.success(sb.toString());
             }
-            return  R.fail("数据无效");
-        }catch (Exception e){
+            //批量保存
+            this.saveBatch(importList);
+            return   R.success("导入成功");
+        } catch (Exception e){
             e.printStackTrace();
         }
-        return  R.fail("导入失败");
+        return  R.fail("执行异常");
     }
 
-//    public R importData_bak(MultipartFile file, Long contractId, Long projectId, Integer dataType) throws Exception {
-//        List<String> level=new ArrayList<>();
-//        level.add("一级");
-//        level.add("二级");
-//        level.add("三级");
-//        level.add("四级");
-//        try {
-//            Workbook wb = WorkbookFactory.create(file.getInputStream());
-//            Sheet sheet = wb.getSheetAt(0);
-//            List<DatumPoint> importList = new ArrayList<>();
-//            Row row1=sheet.getRow(0);
-//            if(dataType==0){
-//                String dengji= ExcelUtil.getValue(row1.getCell(2)).toString();
-//                String beizhu=ExcelUtil.getValue(row1.getCell(3)).toString();
-//                if( !"等级".equals(dengji)||!"备注".equals(beizhu)){
-//                    return  R.fail("导入的数据格式有错,请对准导入模板确认!");
-//                }
-//            }
-//            if(dataType==1){
-//                String dengji=ExcelUtil.getValue(row1.getCell(4)).toString();
-//                String beizhu=ExcelUtil.getValue(row1.getCell(5)).toString();
-//                if( !"等级".equals(dengji)||!"备注".equals(beizhu)){
-//                    return  R.fail("导入的数据格式有错,请对准导入模板确认!");
-//                }
-//            }
-//
-//            for (int i = 1; ; i++) {
-//                Row row = sheet.getRow(i);
-//                if(row == null) {
-//                    break;
-//                }
-//                if(dataType==0) {
-//                    DatumPoint obj = new DatumPoint();
-//                    for (int j = 0; j < 4; j++) {
-//                        String value = (String) ExcelUtil.getValue(row.getCell(j));
-//                        if (StringUtil.isEmpty(value)) {
-//                            value = "";
-//                        }
-//                        String msg="";
-//                        //判断测站点名称是否为空
-//                        String name=(String)ExcelUtil.getValue(row.getCell(0));
-//                        if(StringUtil.isEmpty(name)){
-//                            msg="第"+i+"行,测站点名称为空,请输入!";
-//                            return  R.fail(msg);
-//                        }
-//                        //判断,同一合同段下,测站点名称是否重复
-//                        if(this.count(Wrappers.<DatumPoint>lambdaQuery().eq(DatumPoint::getName,name).eq(DatumPoint::getContractId,contractId).eq(DatumPoint::getType,dataType))>0){
-//                            msg="第"+i+"行,测站点:"+name+"已存在,请修改";
-//                            return  R.fail(msg);
-//                        }
-//                        switch (j) {
-//                            case 0:
-//                                obj.setName(value);
-//                                break;
-//                            case 1:
-//                                obj.setH(Double.parseDouble(value));
-//                                break;
-//                            case 2:
-//                                //判断等级是否为:一级、二级、三级、四级
-//                                if(StringUtil.isNotBlank((String) ExcelUtil.getValue(row.getCell(j)))) {
-//                                    if(!level.contains(value)){
-//                                        msg="第"+i+"行,等级应该为:一级、二级、三级 或 四级,请修改!";
-//                                        return  R.fail(msg);
-//                                    }
-//                                    obj.setLevel(value);
-//                                }
-//                                break;
-//                            case 3:
-//                                obj.setRemark(value);
-//                                break;
-//                            default:
-//                                break;
-//                        }
-//
-//                    }
-//                    obj.setContractId(contractId);
-//                    obj.setProjectId(projectId);
-//                    obj.setCreateTime(new Date());
-//                    obj.setType(dataType);
-//                    importList.add(obj);
-//                }
-//                if(dataType==1){
-//                    DatumPoint obj = new DatumPoint();
-//                    for (int j = 0; j < 6; j++) {
-//                        String value = (String) ExcelUtil.getValue(row.getCell(j));
-//                        if (StringUtil.isEmpty(value)) {
-//                            value = "";
-//                        }
-//                        String msg="";
-//                        //判断测站点名称是否为空
-//                        String name=(String)ExcelUtil.getValue(row.getCell(0));
-//                        if(StringUtil.isEmpty(name)){
-//                            msg="第"+i+"行,测站点名称为空,请输入!";
-//                            return  R.fail(msg);
-//                        }
-//                        //判断,同一合同段下,测站点名称是否重复
-//                        if(this.count(Wrappers.<DatumPoint>lambdaQuery().eq(DatumPoint::getName,name).eq(DatumPoint::getContractId,contractId).eq(DatumPoint::getType,dataType))>0){
-//                            msg="第"+i+"行,测站点:"+name+"已存在,请修改";
-//                            return  R.fail(msg);
-//                        }
-//                        switch (j) {
-//                            case 0:
-//                                obj.setName(value);
-//                                break;
-//                            case 1:
-//                                obj.setX(Double.parseDouble(value));
-//                                break;
-//                            case 2:
-//                                obj.setY(Double.parseDouble(value));
-//                                break;
-//                            case 3:
-//                                obj.setH(Double.parseDouble(value));
-//                                break;
-//                            case 4:
-//                                //判断等级是否为:一级、二级、三级、四级
-//                                if(StringUtil.isNotBlank((String) ExcelUtil.getValue(row.getCell(j)))) {
-//                                    if(!level.contains(value)){
-//                                        msg="第"+i+"行,等级应该为:一级、二级、三级 或 四级,请修改!";
-//                                        return  R.fail(msg);
-//                                    }
-//                                    obj.setLevel(value);
-//                                }
-//                                break;
-//                            case 5:
-//                                obj.setRemark(value);
-//                                break;
-//                            default:
-//                                break;
-//                        }
-//
-//                    }
-//                    obj.setContractId(contractId);
-//                    obj.setProjectId(projectId);
-//                    obj.setCreateTime(new Date());
-//                    obj.setType(dataType);
-//                    importList.add(obj);
-//                }
-//            }
-//            //批量保存
-//            this.saveBatch(importList);
-//            return   R.success("导入成功");
-//        } catch (Exception e){
-//            e.printStackTrace();
-//        }
-//        return  R.fail("执行异常");
-//    }
-
-    /*导出数据*/
+    //导出数据
     public List<DatumPoint>  exportExcel( String contractId , Integer type, String search){
         if(StringUtil.isBlank(search)){
             search="";

+ 25 - 16
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDetectionDataServiceImpl.java

@@ -23,6 +23,7 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @Service
@@ -62,15 +63,16 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
         IPage<TrialDetectionData> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialDetectionData::getCreateTime));
         List<TrialDetectionDataVO> trialDetectionDataVOS = BeanUtil.copyProperties(pages.getRecords(), TrialDetectionDataVO.class);
 
-        List<String> list = inspectionRecordMapper.selectSelectedStatusList(dto.getNodeId(), "2,3");
+        if (ObjectUtil.isNotEmpty(dto.getQualityTestPKeyId())) {
+            List<String> list = inspectionRecordMapper.selectSelectedStatusList(Long.parseLong(dto.getQualityTestPKeyId()), "2,3");
 
-        //是否关联过
-        for (TrialDetectionDataVO trialDetectionDataVO : trialDetectionDataVOS) {
-            for (String recordId : list) {
-                trialDetectionDataVO.setIsSelectedStatus(trialDetectionDataVO.getId().toString().equals(recordId) ? 1 : 0);
-            }
-            if (list.size() == 0) {
-                trialDetectionDataVO.setIsSelectedStatus(0);
+            //是否关联过
+            for (TrialDetectionDataVO trialDetectionDataVO : trialDetectionDataVOS) {
+                for (String recordId : list) {
+                    if (trialDetectionDataVO.getId().toString().equals(recordId)) {
+                        trialDetectionDataVO.setIsSelectedStatus(1);
+                    }
+                }
             }
         }
 
@@ -83,18 +85,25 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
             //批量复制新增保存
             List<Long> longs = Func.toLongList(dto.getIds());
             List<TrialDetectionData> trialDetectionData = baseMapper.selectBatchIds(longs);
+            List<TrialDetectionData> insertData = new ArrayList<>();
             for (TrialDetectionData trialDetectionDatum : trialDetectionData) {
-                trialDetectionDatum.setId(SnowFlakeUtil.getId());
-                trialDetectionDatum.setEntrustNo(String.valueOf(SnowFlakeUtil.getId()));
-                trialDetectionDatum.setReportNo(String.valueOf(SnowFlakeUtil.getId()));
+                TrialDetectionData obj = BeanUtil.copyProperties(trialDetectionDatum, TrialDetectionData.class);
+                assert obj != null;
+                obj.setId(SnowFlakeUtil.getId());
+                obj.setEntrustNo(String.valueOf(SnowFlakeUtil.getId()));
+                obj.setReportNo(String.valueOf(SnowFlakeUtil.getId()));
+                insertData.add(obj);
             }
-            this.saveBatch(trialDetectionData);
+            this.saveBatch(insertData);
+
         } else {
             //单条复制编辑新增保存
-            dto.setId(SnowFlakeUtil.getId());
-            dto.setEntrustNo(String.valueOf(SnowFlakeUtil.getId()));
-            dto.setReportNo(String.valueOf(SnowFlakeUtil.getId()));
-            this.save(dto);
+            TrialDetectionData obj = BeanUtil.copyProperties(dto, TrialDetectionData.class);
+            assert obj != null;
+            obj.setId(SnowFlakeUtil.getId());
+            obj.setEntrustNo(String.valueOf(SnowFlakeUtil.getId()));
+            obj.setReportNo(String.valueOf(SnowFlakeUtil.getId()));
+            this.save(obj);
         }
         return true;
     }

+ 105 - 43
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.spire.xls.*;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.time.DateUtils;
+import org.apache.poi.hssf.record.DVALRecord;
 import org.springblade.business.dto.RawMaterialSubmitRelationDTO;
 import org.springblade.business.dto.TrialFileSubmitDTO;
 import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
@@ -45,6 +46,7 @@ import org.springblade.system.entity.Dict;
 import org.springblade.system.feign.IDictClient;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -102,8 +104,6 @@ public class TrialSelfInspectionRecordServiceImpl
         List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
         List<Dict> trialDetectionCategory = iDictClient.getList("trial_detection_category").getData();
 
-        List<WbsTreeContract> contractTreeList = wbsTreeContractClient.getContractWbsTreeByContractId(dto.getContractId());
-
         for (TrialSelfInspectionRecordVO record : records) {
             for (Dict dict : trialDetectionCategory) {
                 if (dict.getDictKey().equals(String.valueOf(record.getDetectionCategory()))) {
@@ -114,13 +114,10 @@ public class TrialSelfInspectionRecordServiceImpl
             record.setDetectionResultName(record.getDetectionResult().equals(1) ? "合格" : "不合格");
 
             //工程部位及用途名称
-            if (contractTreeList.size() > 0 && ObjectUtil.isNotEmpty(record.getProjectPosition())) {
-                List<String> projectPositionNames = new ArrayList<>();
-                for (WbsTreeContract wbsTreeContract : contractTreeList) {
-                    if ((record.getProjectPosition()).contains(String.valueOf(wbsTreeContract.getPKeyId()))) {
-                        projectPositionNames.add(wbsTreeContract.getNodeName());
-                    }
-                }
+            if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
+                List<String> ids = Func.toStrList(record.getProjectPosition()); //关联的工程部位ids
+                List<WbsTreeContract> result = baseMapper.selectWbsTreeContractListByPKeyIds(ids); //查询工程部位节点名称信息
+                List<String> projectPositionNames = result.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
                 String name = projectPositionNames.stream().findAny().orElse(null);
                 if (projectPositionNames.size() > 1) {
                     record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
@@ -129,6 +126,7 @@ public class TrialSelfInspectionRecordServiceImpl
                 }
             }
         }
+
         return trialSelfInspectionRecordVOIPage.setRecords(records);
     }
 
@@ -673,39 +671,50 @@ public class TrialSelfInspectionRecordServiceImpl
         IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
         List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
 
-        //List<WbsTreeContract> contractTreeList = wbsTreeContractClient.getContractWbsTreeByContractId(dto.getContractId());
-
         //查询是否关联过
-        List<String> selectedIds = baseMapper.selectSelectedStatusList(dto.getNodeId(), "1");
-
-        for (TrialSelfInspectionRecordVO record : records) {
-            record.setDetectionResultName(record.getDetectionResult().equals(1) ? "合格" : "不合格");
+        if (ObjectUtil.isNotEmpty(dto.getQualityTestPKeyId())) {
+            List<String> selectedIds = baseMapper.selectSelectedStatusList(Long.parseLong(dto.getQualityTestPKeyId()), "1");
+            for (TrialSelfInspectionRecordVO record : records) {
+                //是否关联过
+                for (String recordId : selectedIds) {
+                    if (record.getId().toString().equals(recordId)){
+                        record.setIsSelectedStatus(1);
+                    }
+                }
 
-            //是否关联过
-            for (String id : selectedIds) {
-                record.setIsSelectedStatus(record.getId().toString().equals(id) ? 1 : 0);
-            }
-            if (selectedIds.size() == 0) {
-                record.setIsSelectedStatus(0);
+                record.setDetectionResultName(record.getDetectionResult().equals(1) ? "合格" : "不合格");
+                //工程部位及用途名称
+                if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
+                    List<String> ids = Func.toStrList(record.getProjectPosition()); //关联的工程部位ids
+                    List<WbsTreeContract> result = baseMapper.selectWbsTreeContractListByPKeyIds(ids); //查询工程部位节点名称信息
+                    List<String> projectPositionNames = result.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
+                    String name = projectPositionNames.stream().findAny().orElse(null);
+                    if (projectPositionNames.size() > 1) {
+                        record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
+                    } else {
+                        record.setProjectPositionName(name);
+                    }
+                }
             }
 
-            /*//工程部位及用途名称
-            if (contractTreeList.size() > 0 && ObjectUtil.isNotEmpty(record.getProjectPosition())) {
-                List<String> projectPositionNames = new ArrayList<>();
-                for (WbsTreeContract wbsTreeContract : contractTreeList) {
-                    if ((record.getProjectPosition()).contains(String.valueOf(wbsTreeContract.getPKeyId()))) {
-                        projectPositionNames.add(wbsTreeContract.getNodeName());
+        } else {
+            for (TrialSelfInspectionRecordVO record : records) {
+                record.setDetectionResultName(record.getDetectionResult().equals(1) ? "合格" : "不合格");
+                //工程部位及用途名称
+                if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
+                    List<String> ids = Func.toStrList(record.getProjectPosition()); //关联的工程部位ids
+                    List<WbsTreeContract> result = baseMapper.selectWbsTreeContractListByPKeyIds(ids); //查询工程部位节点名称信息
+                    List<String> projectPositionNames = result.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
+                    String name = projectPositionNames.stream().findAny().orElse(null);
+                    if (projectPositionNames.size() > 1) {
+                        record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
+                    } else {
+                        record.setProjectPositionName(name);
                     }
                 }
-                String name = projectPositionNames.stream().findAny().orElse(null);
-                if (projectPositionNames.size() > 1) {
-                    record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
-                } else {
-                    record.setProjectPositionName(name);
-                }
-            }*/
-
+            }
         }
+
         return trialSelfInspectionRecordVOIPage.setRecords(records);
     }
 
@@ -726,7 +735,7 @@ public class TrialSelfInspectionRecordServiceImpl
                 .eq(InformationQuery::getType, 1) //质检
         );
 
-         if (StringUtils.isNotEmpty(dto.getIds())) {
+        if (StringUtils.isNotEmpty(dto.getIds())) {
             if (ObjectUtil.isNotEmpty(informationQuery) && StringUtils.isNotEmpty(informationQuery.getPdfUrl())) {
 
                 List<String> pdfList = new ArrayList<>();
@@ -775,10 +784,10 @@ public class TrialSelfInspectionRecordServiceImpl
                     if (bladeFile != null) {
                         //修改当前节点的pdfTrialURL地址
                         if (informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, bladeFile.getLink()).eq(InformationQuery::getId, informationQuery.getId()))) {
-                            //修改选中状态记录信息(选中为勾选绿色)
-                            baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType()); //先删除该类型的所有记录信息
-
                             for (String recordId : Func.toStrList(dto.getIds())) {
+                                //修改选中状态记录信息(选中为勾选绿色)
+                                baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), recordId); //先删除对应记录
+
                                 baseMapper.insertSeletedStatus(SnowFlakeUtil.getId(), dto.getNodeId(), dto.getType(), recordId); //新增该类型选中的记录信息
                             }
                             return true;
@@ -789,16 +798,69 @@ public class TrialSelfInspectionRecordServiceImpl
                 throw new ServiceException("当前节点还未上报,获取pdf信息失败,请先上报后再进行关联");
             }
 
-        } else { //删除
+        } else {
             //如果没有关联信息ids=null,那么删除当前类型对应的记录
             //删除前判断当前节点下关联的信息是否还有其他类型的,如果有就不修改pdfTrialUrl=null,如果当前记录为null,那就修改pdfTrialUrl=null
-            int row = baseMapper.selectCountSeletedStatus(dto.getNodeId(), dto.getType());
-            if (row == 0) {
+            List<String> pdfList = new ArrayList<>();
+            List<String> recordIds = baseMapper.selectCountSeletedStatus(dto.getNodeId(), dto.getType());
+            if (recordIds.size() > 0) {
+                //其他类型记录ids
+                String ids = org.apache.commons.lang.StringUtils.join(recordIds, ",");
+
+                if (dto.getType().equals(1)) { //自检ids=null,那么就取第三方外委的pdf重新合并
+                    //获取到 第三方、外委记录信息
+                    List<TrialDetectionData> trialDetectionData = trialDetectionDataService.getBaseMapper().selectList(Wrappers.<TrialDetectionData>lambdaQuery().in(TrialDetectionData::getId, ids));
+                    List<String> pdfURLs = new ArrayList<>();
+                    for (TrialDetectionData trialDetectionDatum : trialDetectionData) {
+                        if (StringUtils.isNotEmpty(trialDetectionDatum.getRecordTableUrl())) {
+                            pdfURLs.add(trialDetectionDatum.getRecordTableUrl());
+                        }
+                        if (StringUtils.isNotEmpty(trialDetectionDatum.getReportAttachmentUrl())) {
+                            pdfURLs.add(trialDetectionDatum.getReportAttachmentUrl());
+                        }
+                    }
+                    pdfList.addAll(pdfURLs);
+
+                } else if (dto.getType().equals(2) || dto.getType().equals(3)) { //第三方、外委ids=null,那么就取自检的pdf重新合并
+                    //获取自检的对应的数据pdf
+                    List<TrialSelfInspectionRecord> trialSelfInspectionRecords = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, ids));
+                    List<String> pdfURLs = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+                    pdfList.addAll(pdfURLs);
+
+                }
+
+                if (pdfList.size() > 0) {
+                    //合并pdf把试验自检记录、第三方、外委的pdf追加到当前质检合同段树节点下的pdf后显示
+                    List<String> collect = pdfList.stream().filter(Objects::nonNull).collect(Collectors.toList());
+                    String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                    String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
+                    File tabPDF = ResourceUtil.getFile(listPdf);
+                    if (tabPDF.exists()) {
+                        tabPDF.delete();
+                    }
+                    FileUtils.mergePdfPublicMethods(collect, listPdf);
+                    BladeFile bladeFile = this.newIOSSClient.uploadFile(informationQuery.getId() + ".pdf", listPdf);
+                    if (bladeFile != null) {
+                        //修改当前节点的pdfTrialURL地址
+                        if (informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, bladeFile.getLink()).eq(InformationQuery::getId, informationQuery.getId()))) {
+                            for (String recordId : recordIds) {
+                                //修改选中状态记录信息(选中为勾选绿色)
+                                baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), recordId); //先删除对应记录
+
+                                baseMapper.insertSeletedStatus(SnowFlakeUtil.getId(), dto.getNodeId(), dto.getType(), recordId); //新增该类型选中的记录信息
+                            }
+                            return true;
+                        }
+                    }
+                }
+
+            } else {
                 //修改pdfTrialUrl=null
                 informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, null).eq(InformationQuery::getId, informationQuery.getId()));
             }
             //删除该类型的所有记录信息
-            baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType());
+            baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), null);
+
             return true;
         }
 

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

@@ -429,7 +429,7 @@ public class CustomFunction {
 
 	public static Object dateMax(Object range){
 		if(StringUtils.isNotEmpty(range)){
-			String[] s= Func.toStr(range).replaceAll("[\\[\\]]","").split(",\\s+");
+			String[] s= Func.toStr(range).replaceAll("[\\[\\]]","").split(",");
 			return dateCp(s[0],s[1],false);
 		}
 		return StringPool.EMPTY;

+ 19 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ContractInfoController.java

@@ -435,6 +435,25 @@ public class ContractInfoController extends BladeController {
         return R.fail(200, "未查询到信息");
     }
 
+    /**
+     * 查询合同段私有Wbs节点树形结构 --- 试验关联工程节点树
+     */
+    @GetMapping("/trial/relation/tree")
+    @ApiOperationSupport(order = 18)
+    @ApiOperation(value = "查询合同段私有Wbs节点树形结构", notes = "传入wbsId,项目id,合同段id")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "wbsId", value = "wbsId", required = true),
+            @ApiImplicitParam(name = "项目id", value = "projectId", required = true),
+            @ApiImplicitParam(name = "合同段id", value = "contractId", required = true)
+    })
+    public R trialRelationTree(String wbsId, String projectId, String contractId) {
+        Map<String,Object> tree = contractInfoService.trialRelationTree(wbsId, projectId, contractId);
+        if (tree != null && tree.size() > 0) {
+            return R.data(tree);
+        }
+        return R.fail(200, "未查询到信息");
+    }
+
     /**
      * 客户端填报-划分变更手动关联树
      */

+ 22 - 10
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeController.java

@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springblade.manager.service.IWbsTreeService;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springframework.web.multipart.MultipartFile;
+
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
@@ -169,10 +170,10 @@ public class WbsTreeController extends BladeController {
     @ApiImplicitParam(name = "id", value = "表单id", required = true)
     public R removeTableById(@RequestParam("id") String id) {
         if (StringUtils.isNotEmpty(id)) {
-            List<WbsFormElementVO> wbsFormElements = wbsTreeService.selectFormElements(id,null); //此处nodeId为后续其他开发加的,不知道有什么用,所以传null
+            /*List<WbsFormElementVO> wbsFormElements = wbsTreeService.selectFormElements(id,null); //此处nodeId为后续其他开发加的,不知道有什么用,所以传null
             if (wbsFormElements.size() > 0) {
                 throw new ServiceException("该表单中存在元素,删除失败");
-            }
+            }*/
             Long wbsTreePrivates = wbsTreePrivateMapper.selectCount(Wrappers.<WbsTreePrivate>query().lambda()
                     .eq(WbsTreePrivate::getStatus, 1)
                     .eq(WbsTreePrivate::getId, id));
@@ -180,6 +181,17 @@ public class WbsTreeController extends BladeController {
                 throw new ServiceException("该表单已被项目引用,删除失败");
             }
             if (wbsTreeService.removeTableById(id)) {
+                //如果当前节点没有表单,那么修改is_exist_form = 0
+                WbsTree wbsTreeZi = wbsTreeService.getBaseMapper().selectOne(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getId, id));
+                if (wbsTreeZi != null) {
+                    WbsTree wbsTreeFu = wbsTreeService.getBaseMapper().selectOne(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getId, wbsTreeZi.getParentId()));
+                    if (wbsTreeFu != null) {
+                        List<WbsTree> nodes = wbsTreeService.getBaseMapper().selectList(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getParentId, wbsTreeFu.getId()));
+                        if (nodes.size() == 0) {
+                            wbsTreeService.update(Wrappers.<WbsTree>lambdaUpdate().set(WbsTree::getIsExistForm, 0).eq(WbsTree::getId, wbsTreeFu.getId()));
+                        }
+                    }
+                }
                 return R.success("删除成功");
             }
         }
@@ -193,13 +205,13 @@ public class WbsTreeController extends BladeController {
     @ApiOperationSupport(order = 8)
     @ApiOperation(value = "根据表单id查询所有元素", notes = "传入表单id")
     @ApiImplicitParam(name = "id", value = "表单id", required = true)
-    public R<List<WbsFormElementVO>> selectFormElements(@RequestParam("id") String id,Long nodeId,String search) {
+    public R<List<WbsFormElementVO>> selectFormElements(@RequestParam("id") String id, Long nodeId, String search) {
         List<WbsFormElementVO> wbsFormElements = null;
         if (StringUtils.isNotEmpty(id)) {
-            wbsFormElements = wbsTreeService.selectFormElements(id,nodeId);
+            wbsFormElements = wbsTreeService.selectFormElements(id, nodeId);
             if (wbsFormElements.size() > 0) {
-                if(StringUtils.isNotEmpty(search)){
-                    wbsFormElements=wbsFormElements.stream().filter(e->e.getEName().contains(search)).collect(Collectors.toList());
+                if (StringUtils.isNotEmpty(search)) {
+                    wbsFormElements = wbsFormElements.stream().filter(e -> e.getEName().contains(search)).collect(Collectors.toList());
                 }
                 return R.data(wbsFormElements);
             }
@@ -212,13 +224,13 @@ public class WbsTreeController extends BladeController {
     @ApiOperationSupport(order = 8)
     @ApiOperation(value = "根据表单id查询所有元素", notes = "传入表单id")
     @ApiImplicitParam(name = "id", value = "表单id", required = true)
-    public R<List<WbsFormElementVO>> selectFormElements4Formula(@RequestParam("id") String id,String search) {
+    public R<List<WbsFormElementVO>> selectFormElements4Formula(@RequestParam("id") String id, String search) {
         List<WbsFormElementVO> wbsFormElements = null;
         if (StringUtils.isNotEmpty(id)) {
             wbsFormElements = wbsTreeService.selectFormElements4Formula(id);
             if (wbsFormElements.size() > 0) {
-                if(StringUtils.isNotEmpty(search)){
-                    wbsFormElements=wbsFormElements.stream().filter(e->e.getEName().contains(search)).collect(Collectors.toList());
+                if (StringUtils.isNotEmpty(search)) {
+                    wbsFormElements = wbsFormElements.stream().filter(e -> e.getEName().contains(search)).collect(Collectors.toList());
                 }
                 return R.data(wbsFormElements);
             }
@@ -226,6 +238,7 @@ public class WbsTreeController extends BladeController {
 
         return R.data(wbsFormElements, "未查询到元素");
     }
+
     /**
      * 新增表单与元素
      */
@@ -347,7 +360,6 @@ public class WbsTreeController extends BladeController {
     }
 
 
-
     /**
      * 查询公有wbs节点元素表与节点参数
      */

+ 4 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.java

@@ -1,6 +1,7 @@
 package org.springblade.manager.mapper;
 
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.springblade.manager.dto.FindAllUserByConditionDTO;
 import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.entity.ContractRelationJlyz;
@@ -80,4 +81,7 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
 
     List<UserContractInfoVO> userListByIds(@Param("ids") List<String> ids);
 
+    @Select("select quality_node_id from u_trial_self_quality_project")
+    List<String> queryList();
+
 }

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IContractInfoService.java

@@ -13,6 +13,7 @@ import org.springblade.system.user.vo.UserVO2;
 
 
 import java.util.List;
+import java.util.Map;
 
 public interface IContractInfoService extends BaseService<ContractInfo> {
 
@@ -62,4 +63,6 @@ public interface IContractInfoService extends BaseService<ContractInfo> {
 
     List<UserContractInfoVO> getContractUserInfo(String contractId);
 
+    Map<String, Object> trialRelationTree(String wbsId, String projectId, String contractId);
+
 }

+ 19 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -21,9 +21,10 @@ import org.springblade.manager.mapper.ContractInfoMapper;
 import org.springblade.manager.service.IContractInfoService;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.system.user.entity.User;
-import org.springblade.system.user.feign.IUserClient;
 import org.springblade.system.user.vo.UserContractInfoVO;
 import org.springblade.system.user.vo.UserVO2;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
@@ -36,7 +37,6 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper, ContractInfo> implements IContractInfoService {
 
-    private final IUserClient iUserClient;
     private final ContractInfoMapper contractInfoMapper;
     private final ProjectContractAreaMapper projectContractAreaMapper;
     private final SaveUserInfoByProjectMapper saveUserInfoByProjectMapper;
@@ -120,7 +120,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
 
     @Override
     public List<WbsTreeContractVO> tree(String wbsId, String projectId, String contractId) {
-        List<WbsTreeContractVO> wbsTreeContractVOS = baseMapper.tree2(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId), null, null,null);
+        List<WbsTreeContractVO> wbsTreeContractVOS = baseMapper.tree2(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId), null, null, null);
         return buildWbsTreeByStream(wbsTreeContractVOS);
     }
 
@@ -302,4 +302,20 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
         return buildWbsTreeByStream(wbsTreeContractVOS);
     }
 
+    @Override
+    public Map<String, Object> trialRelationTree(String wbsId, String projectId, String contractId) {
+        Map<String,Object> maps = new HashMap<>();
+
+        //合同段树
+        List<WbsTreeContractVO> wbsTreeContractVOS = baseMapper.tree2(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId), null, null, null);
+        List<WbsTreeContractVO> wbsTreeContractVOList = buildWbsTreeByStream(wbsTreeContractVOS);
+
+        //是否勾选-试验关联工程部位信息
+        List<String> list = baseMapper.queryList();
+
+        maps.put("treeContractAll",wbsTreeContractVOList);
+        maps.put("isSelectedStatus",list);
+        return maps;
+    }
+
 }

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1338,6 +1338,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             throw new ServiceException("操作失败!");
         }
 
+        @SuppressWarnings("unchecked") //忽略警告
         Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfoTrial(pkeyId);
 
         // 获取excel流 和 html流

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

@@ -3,7 +3,6 @@ package org.springblade.manager.service.impl;
 
 import cn.hutool.core.util.HashUtil;
 import cn.hutool.log.StaticLog;
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.jfireel.expression.Expression;
 import com.mixsmart.utils.*;
@@ -82,8 +81,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     public static final Pattern POLY = Pattern.compile(POLY_REG);
     public final static String CTI="ContractInfo";
     public final static String PJI="ProjectInfo";
-    /**表单信息*/
-    public final static String TEXT_INFO_MAP="textInfoMap";
 
 
 
@@ -159,12 +156,15 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             this.tec.getLog().append("无法识别的依赖:").append(missingList.stream().map(e->e.replaceAll("'","")).collect(Collectors.joining(",")));
         }
         /*实测值参数*/
-        List<Map<String,Object>>  textInfoMap= this.jdbcTemplate.queryForList("SELECT b.tab_id pkId,b.col_name val ,CONCAT(a.init_table_name,':',b.col_key)code from m_wbs_tree_contract a inner join m_textdict_info b on a.p_key_id=b.tab_id   " +
-                "where a.p_key_id in("+this.tec.getTableAll().stream().map(AppWbsTreeContractVO::getPKeyId).map(Func::toStr).collect(Collectors.joining(","))+") and b.type=8 ");
-        if(Func.isNotEmpty(textInfoMap)){
-            Map<String,List<Map<String,Object>>> tmap = textInfoMap.stream().collect(Collectors.groupingBy(m->m.get("code").toString()));
-            this.constantMap.put(TEXT_INFO_MAP,tmap);
-        }
+        List<Map<String,Object>>  textInfoMap= this.jdbcTemplate.queryForList("SELECT b.tab_id pkId, b.col_key ekey,b.col_name val ,c.init_table_name tableName " +
+                "from m_wbs_tree_contract a " +
+                "inner join m_textdict_info b on a.p_key_id=b.tab_id  " +
+                "INNER JOIN m_wbs_tree c on (a.id=c.id or a.old_id=c.id) " +
+                "where a.p_key_id in("+ this.tec.getTableAll().stream().map(AppWbsTreeContractVO::getPKeyId).map(Func::toStr).collect(Collectors.joining(","))+") and b.type=8");
+         if(Func.isNotEmpty(textInfoMap)){
+             Map<String,List<Map<String,Object>>> tmap = textInfoMap.stream().collect(Collectors.groupingBy(m->m.get("tableName")+StringPool.COLON+m.get("ekey")));
+             this.constantMap.put("tmap",tmap);
+         }
         /*检查项目*/
         return this;
     }
@@ -202,89 +202,89 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             }
         }
     }
-    public void missingFill(List<String> missingList){
-        /*数据池里面没有任何元素匹配和当前依赖匹配*/
-        if(Func.isNotEmpty(missingList)){
-            StaticLog.info("缺失元素{}", String.join(";", missingList));
-            /*1从当前节点其它表格中查找匹配的元素*/
-            List<String> removeList=new ArrayList<>();
-            for(String r:missingList){
-                String tn = r.substring(0,r.indexOf(StringPool.COLON));
-                String key =r.substring(r.indexOf(StringPool.COLON)+1);
-                List<AppWbsTreeContractVO> nodeList = this.tec.getTableAll().stream().filter(e->e.getInitTableName().equals(tn)).collect(Collectors.toList());
-                if(Func.isNotEmpty(nodeList)){
-                    String tableName = nodeList.get(0).getInitTableName();
-                    try {
-                        if(!this.tec.getCoordinateMap().containsKey(tableName)){
-                            this.tec.getCoordinateMap().put(tableName, getTableCols(nodeList.get(0), null));
-                        }
-                    } catch (FileNotFoundException e) {
-                        e.printStackTrace();
-                    }
-                    List<Map<String,Object>> tableDatas= this.jdbcTemplate.queryForList("select * from "+tableName+" where p_key_id in("+nodeList.stream().map(AppWbsTreeContractVO::getPKeyId).map(StringUtils::handleNull).collect(Collectors.joining(","))+")");
-                    fill(tableDatas,removeList,tn,key);
-                }
-            }
-            if(Func.isNotEmpty(removeList)){
-                /*移除已经找到的元素数据*/
-                missingList.removeIf(removeList::contains);
-            }
-            if(Func.isNotEmpty(missingList)){
-                /*2从当前节点的兄弟节点中查找匹配的元素*/
-                CurrentNode currentNode = this.tec.getCurrentNode();
-                List<Map<String,Object>> tableNamePkIdsMaps= this.jdbcTemplate.queryForList("select c.init_table_name tableName,c.p_key_id pkId from (select b.id from (select * from m_wbs_tree_contract  where p_key_id="+currentNode.getPkId()+") a join  m_wbs_tree_contract b on b.parent_id=a.parent_id where  b.contract_id="+this.tec.getContractId()+" and b.is_deleted=0) k join m_wbs_tree_contract c on c.parent_id = k.id where  c.contract_id="+this.tec.getContractId()+" and c.is_deleted=0 ");
-                if(Func.isNotEmpty(tableNamePkIdsMaps)){
-                    removeList.clear();
-                    missingList.forEach(miss->{
-                        String tn = miss.substring(0,miss.indexOf(StringPool.COLON));
-                        String key =miss.substring(miss.indexOf(StringPool.COLON)+1);
-                        String targetIds=tableNamePkIdsMaps.stream().filter(m->StringUtils.isEquals(m.get("tableName"),tn)).map(m->m.get("pkId")).map(StringUtils::handleNull).collect(Collectors.joining(","));
-                        if(Func.isNotEmpty(targetIds)){
-                            List<Map<String,Object>> tableDatas= this.jdbcTemplate.queryForList("select * from "+tn+" where p_key_id in ("+targetIds+")");
-                            fill(tableDatas,removeList,tn,key);
-                        }
-                    });
-                }
-            }
-            if(Func.isNotEmpty(removeList)){
-                /*移除已经找到的元素数据*/
-                missingList.removeIf(removeList::contains);
-            }
-        }
-    }
-
-    public void fill(List<Map<String,Object>> tableDatas,List<String> removeList,String tn,String key){
-        if(Func.isNotEmpty(tableDatas)){
-            Map<String,Object> map = new HashMap<>();
-            tableDatas.forEach(m->{
-                for(Map.Entry<String,Object> entry:m.entrySet()){
-                    if(entry.getValue()!=null){
-                        map.merge(entry.getKey(), entry.getValue(), (v1, v2) -> v1 + ";" + v2);
-                    }
-                }
-            });
-            this.tableDataMaps.put(tn,map);
-            String values= StringUtils.handleNull(map.get(key));
-            String r= tn+StringPool.COLON+key;
-            if(StringUtils.isNotEmpty(values)){
-                FormData tmp=createFormDataFast(r,values);
-                if(tmp!=null){
-                    removeList.add(r);
-                    this.formDataMap.put(r,tmp);
-                }
-            }
-        }
-    }
-    public FormData createFormDataFast(String code,String values){
+   public void missingFill(List<String> missingList){
+       /*数据池里面没有任何元素匹配和当前依赖匹配*/
+         if(Func.isNotEmpty(missingList)){
+             StaticLog.info("缺失元素{}", String.join(";", missingList));
+             /*1从当前节点其它表格中查找匹配的元素*/
+             List<String> removeList=new ArrayList<>();
+             for(String r:missingList){
+                 String tn = r.substring(0,r.indexOf(StringPool.COLON));
+                 String key =r.substring(r.indexOf(StringPool.COLON)+1);
+                 List<AppWbsTreeContractVO> nodeList = this.tec.getTableAll().stream().filter(e->e.getInitTableName().equals(tn)).collect(Collectors.toList());
+                 if(Func.isNotEmpty(nodeList)){
+                     String tableName = nodeList.get(0).getInitTableName();
+                     try {
+                         if(!this.tec.getCoordinateMap().containsKey(tableName)){
+                             this.tec.getCoordinateMap().put(tableName, getTableCols(nodeList.get(0), null));
+                         }
+                     } catch (FileNotFoundException e) {
+                         e.printStackTrace();
+                     }
+                     List<Map<String,Object>> tableDatas= this.jdbcTemplate.queryForList("select * from "+tableName+" where p_key_id in("+nodeList.stream().map(AppWbsTreeContractVO::getPKeyId).map(StringUtils::handleNull).collect(Collectors.joining(","))+")");
+                     fill(tableDatas,removeList,tn,key);
+                 }
+             }
+             if(Func.isNotEmpty(removeList)){
+                 /*移除已经找到的元素数据*/
+                 missingList.removeIf(removeList::contains);
+             }
+             if(Func.isNotEmpty(missingList)){
+                 /*2从当前节点的兄弟节点中查找匹配的元素*/
+                 CurrentNode currentNode = this.tec.getCurrentNode();
+                 List<Map<String,Object>> tableNamePkIdsMaps= this.jdbcTemplate.queryForList("select c.init_table_name tableName,c.p_key_id pkId from (select b.id from (select * from m_wbs_tree_contract  where p_key_id="+currentNode.getPkId()+") a join  m_wbs_tree_contract b on b.parent_id=a.parent_id where  b.contract_id="+this.tec.getContractId()+" and b.is_deleted=0) k join m_wbs_tree_contract c on c.parent_id = k.id where  c.contract_id="+this.tec.getContractId()+" and c.is_deleted=0 ");
+                 if(Func.isNotEmpty(tableNamePkIdsMaps)){
+                     removeList.clear();
+                     missingList.forEach(miss->{
+                         String tn = miss.substring(0,miss.indexOf(StringPool.COLON));
+                         String key =miss.substring(miss.indexOf(StringPool.COLON)+1);
+                         String targetIds=tableNamePkIdsMaps.stream().filter(m->StringUtils.isEquals(m.get("tableName"),tn)).map(m->m.get("pkId")).map(StringUtils::handleNull).collect(Collectors.joining(","));
+                       if(Func.isNotEmpty(targetIds)){
+                           List<Map<String,Object>> tableDatas= this.jdbcTemplate.queryForList("select * from "+tn+" where p_key_id in ("+targetIds+")");
+                           fill(tableDatas,removeList,tn,key);
+                       }
+                     });
+                 }
+             }
+             if(Func.isNotEmpty(removeList)){
+                 /*移除已经找到的元素数据*/
+                 missingList.removeIf(removeList::contains);
+             }
+         }
+   }
+
+   public void fill(List<Map<String,Object>> tableDatas,List<String> removeList,String tn,String key){
+       if(Func.isNotEmpty(tableDatas)){
+           Map<String,Object> map = new HashMap<>();
+           tableDatas.forEach(m->{
+               for(Map.Entry<String,Object> entry:m.entrySet()){
+                   if(entry.getValue()!=null){
+                       map.merge(entry.getKey(), entry.getValue(), (v1, v2) -> v1 + ";" + v2);
+                   }
+               }
+           });
+           this.tableDataMaps.put(tn,map);
+           String values= StringUtils.handleNull(map.get(key));
+           String r= tn+StringPool.COLON+key;
+           if(StringUtils.isNotEmpty(values)){
+               FormData tmp=createFormDataFast(r,values);
+               if(tmp!=null){
+                   removeList.add(r);
+                   this.formDataMap.put(r,tmp);
+               }
+           }
+       }
+   }
+   public FormData createFormDataFast(String code,String values){
         if(StringUtils.isNotEmpty(code,values)){
-            return    new FormData(code, Arrays.stream(values.split("☆")).map(s->{
+         return    new FormData(code, Arrays.stream(values.split("☆")).map(s->{
                 String[] t = s.split("_\\^_");
                 String[] c =t[1].split("_");
                 return  new ElementData(0,0,t[0],Func.toInt(c[1]),Func.toInt(c[0]));
             }).collect(Collectors.toList()), null,StringPool.EMPTY);
         }
         return null;
-    }
+   }
 
     public Map<String, String> getTableCols(AppWbsTreeContractVO wbsTreeContract, String colkey) throws FileNotFoundException {
         Map<String, String> dataMap = new HashMap<>();
@@ -320,9 +320,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
 
     /**引入关键字*/
     public void keyWord(Map<String,Object> constantMap){
-        CustomFunction.KEYWORD_SET.forEach(e->{
-            constantMap.put(e,e);
-        });
+           CustomFunction.KEYWORD_SET.forEach(e->{
+               constantMap.put(e,e);
+           });
     }
 
     /**
@@ -342,15 +342,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         if(Func.isNotEmpty(wpsPrivate)){
             total.addAll(wpsPrivate);
         }
-        Map<String,String> logMap =new HashMap<>();
         if(CollectionUtil.isNotEmpty(total)){
             /*同名参数私有覆盖公用*/
             for(WbsParam p:total){
                 result.put(p.getK(),p.getV());
-                logMap.put(p.getK(),p.getName());
             }
         }
-        this.tec.getLog().append("本节点参数情况:").append(result.entrySet().stream().map(p->logMap.get(p.getKey())+":"+p.getValue()).collect(Collectors.joining(";")));
+        this.tec.getLog().append("本节点参数情况:").append(result.entrySet().stream().map(p->p.getKey()+":"+p.getValue()).collect(Collectors.joining(";")));
         /*元素动态绑定*/
         this.formDataMap.values().stream().filter(e->e.getIsCurrentNodeElement()&&e.getFormula()==null).forEach(e->{
             /*执行列表里不存在,且元素的名称和节点参数名称匹配成功*/
@@ -425,9 +423,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                     }
                 }
                 if(CHECK_ITEMS.equals(tmp)){
-                    /*获取type=1的检验单或者type=4的监表*/
-                    List<WbsTreeContract> tableList= (List<WbsTreeContract>) this.constantMap.get(TABLE_LIST);
-                    Optional<WbsTreeContract> wop=tableList.stream().filter(e->e.getTableType()==1||e.getTableType()==4).findAny();
+                   /*获取type=1的检验单或者type=4的监表*/
+                   List<WbsTreeContract> tableList= (List<WbsTreeContract>) this.constantMap.get(TABLE_LIST);
+                   Optional<WbsTreeContract> wop=tableList.stream().filter(e->e.getTableType()==1||e.getTableType()==4).findAny();
                     wop.ifPresent(wbsTreeContract -> this.jdbcTemplate.queryForList("select c.e_name name ,c.init_table_name tableName,c.e_key ekey from m_wbs_tree_contract a INNER JOIN m_wbs_tree b on (a.id=b.id or a.old_id=b.id) INNER join m_wbs_form_element c on b.init_table_id=c.f_id where a.id=" + wbsTreeContract.getPKeyId()));
                 }
                 fd.getFormula().setFormula(tmp);
@@ -468,10 +466,10 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                         if(CollectionUtil.isNotEmpty(relyList)){
                             List<FormData>  ele = new ArrayList<>();
                             relyList.forEach(rely->{
-                                FormData formData=  this.tec.getFormDataMap().get(rely);
-                                if(formData!=null&&formData.getValues().stream().anyMatch(Func::isNotEmpty)){
-                                    ele.add(formData);
-                                }
+                               FormData formData=  this.tec.getFormDataMap().get(rely);
+                               if(formData!=null&&formData.getValues().stream().anyMatch(Func::isNotEmpty)){
+                                   ele.add(formData);
+                               }
                             });
                             if(ele.size()<relyList.size()){
                                 this.tec.getLog().append(fd.getEName()).append(fd.getFormula().getFormula().replaceAll("'", "")).append("不满足执行依赖;");
@@ -514,12 +512,12 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                             write(fd,data);
                         }
                     }catch (Exception e){
-                        tec.getLog().append(fd.getEName()).append("计算错误; ");
+                       tec.getLog().append(fd.getEName()).append("计算错误; ");
                     }
 
                 }
-                /*数量不相等*/
-                fd.setUpdate(1);
+                     /*数量不相等*/
+                    fd.setUpdate(1);
             }
         }
         return this;
@@ -567,16 +565,16 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         /*数据格式化*/
         for(FormData fd:this.formDataList){
             if(fd.verify()){
-                /*保留小数位*/
-                if(!fd.empty()&&fd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isDouble)){
-                    Formula f = fd.getFormula();
-                    Integer scale =f.getScale();
-                    if(scale==null){
-                        scale=2;
-                    }
-                    Integer finalScale = scale;
-                    fd.setValues(fd.getValues().stream().peek(e->{if(StringUtils.isDouble(e.getValue())){e.setValue(StringUtils.number2String(e.getValue(),finalScale));}}).collect(Collectors.toList()));
-                }
+                    /*保留小数位*/
+                   if(!fd.empty()&&fd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isDouble)){
+                       Formula f = fd.getFormula();
+                       Integer scale =f.getScale();
+                       if(scale==null){
+                           scale=2;
+                       }
+                       Integer finalScale = scale;
+                       fd.setValues(fd.getValues().stream().peek(e->{if(StringUtils.isDouble(e.getValue())){e.setValue(StringUtils.number2String(e.getValue(),finalScale));}}).collect(Collectors.toList()));
+                   }
             }
         }
     }
@@ -606,7 +604,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                 entry.getValue().stream().max(Comparator.comparing(KeyMapper::getScope)).ifPresent(set::add);
             }
             if(set.size()>0){
-                return new ArrayList<>(set);
+               return new ArrayList<>(set);
             }
         }
         return Collections.emptyList();
@@ -614,12 +612,12 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
 
     @Override
     public List<Formula> getFormulaList(List<KeyMapper> keyMapperList) {
-        if(Func.isNotEmpty(keyMapperList)){
-            List<Formula> result = this.listByIds(keyMapperList.stream().map(KeyMapper::getFormulaId).collect(Collectors.toList()));
-            if(Func.isNotEmpty(result)){
-                return result;
-            }
-        }
+       if(Func.isNotEmpty(keyMapperList)){
+             List<Formula> result = this.listByIds(keyMapperList.stream().map(KeyMapper::getFormulaId).collect(Collectors.toList()));
+             if(Func.isNotEmpty(result)){
+                 return result;
+             }
+       }
         return Collections.emptyList();
     }
 
@@ -638,10 +636,10 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         int min =0;
         List<Object> result = new ArrayList<>();
         try {
-            List<Object>  r= local.stream().map(e-> Expression.parse(e.getFormula()).calculate(e.getCurrentMap())).collect(Collectors.toList());
-            if(CollectionUtil.isNotEmpty(r)&&r.stream().anyMatch(StringUtils::isNotEmpty)){
-                result.addAll(r);
-            }
+                List<Object>  r= local.stream().map(e-> Expression.parse(e.getFormula()).calculate(e.getCurrentMap())).collect(Collectors.toList());
+                if(CollectionUtil.isNotEmpty(r)&&r.stream().anyMatch(StringUtils::isNotEmpty)){
+                    result.addAll(r);
+                }
         }catch (Exception e){
             StaticLog.error("公式:{},执行出错",formula);
         }
@@ -725,11 +723,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                         while (m.find()) {
                             Object data=null;
                             if(f.contains("quantity(")){
-                                String s = m.group(2).split(",")[0].replaceAll("[E\\[\\]']","");
-                                Map<String,List<Map<String,Object>>> textInfoMap= (Map<String, List<Map<String, Object>>>) this.constantMap.getOrDefault(TEXT_INFO_MAP,new HashMap<>());
-                                List<Map<String,Object>> tableColKeyVal= textInfoMap.get(s);
+                                String s = m.group(1).replace("'","");
+                                Map<String,List<Map<String,Object>>> tmap= (Map<String, List<Map<String, Object>>>) this.constantMap.getOrDefault("tmap",new HashMap<>());
+                                List<Map<String,Object>> tableColKeyVal= tmap.get(s);
                                 if(Func.isNotEmpty(tableColKeyVal)){
-                                    data = tableColKeyVal.stream().map(map-> BeanUtil.toBean(JSON.parseObject(map.get("val").toString()),RangeInfo.class)).map(RangeInfo::getFail).findFirst().orElseGet(String::new);
+                                    data = tableColKeyVal.stream().map(map->{RangeInfo rangeInfo=BeanUtil.toBean((Map) map.get("val"), RangeInfo.class);return rangeInfo.getSize();}).collect(Collectors.toList());
                                 }else{
                                     /*手动计算*/
                                     System.out.println("");
@@ -741,7 +739,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                                 for(String k:relyList){
                                     FormData e=this.formDataMap.get(k);
                                     if(e==null){
-                                        this.tec.getLog().append(fd.getEName()).append("缺失依赖:").append(k).append(";");
+                                        this.tec.getLog().append(fd.getEName()).append("缺失依赖:").append(k);
                                         return;
                                     }
                                     E.put(e.getCode(),e.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()));
@@ -794,19 +792,19 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                             //Map<String, Object> currentMap = new HashMap<>(this.constantMap);
                             Matcher fm=P.matcher(rep);
                             while (fm.find()){
-                                FormData kf=  this.formDataMap.get(fm.group().replaceAll("'",""));
-                                if(kf!=null&&!kf.empty()){
-                                    ElementData ed= kf.getValues().get(0);
-                                    if(ed!=null&&Func.isNotEmpty(ed.getValue())){
-                                        rep= rep.replace("E["+fm.group()+"]",ed.getValue().toString());
-                                        rep="'"+rep+"'";
-                                        f=f.replace(im.group(),rep);
-                                    }else{
-                                        f="";
-                                    }
-                                }else{
+                               FormData kf=  this.formDataMap.get(fm.group().replaceAll("'",""));
+                               if(kf!=null&&!kf.empty()){
+                                ElementData ed= kf.getValues().get(0);
+                                 if(ed!=null&&Func.isNotEmpty(ed.getValue())){
+                                     rep= rep.replace("E["+fm.group()+"]",ed.getValue().toString());
+                                     rep="'"+rep+"'";
+                                     f=f.replace(im.group(),rep);
+                                 }else{
                                     f="";
-                                }
+                                 }
+                               }else{
+                                    f="";
+                               }
                             }
                         }
                         formula.setFormula(f);