Browse Source

覆盖恢复

yangyj 2 năm trước cách đây
mục cha
commit
02cb3f684c

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

@@ -1,5 +1,6 @@
 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;
 
@@ -72,6 +73,17 @@ 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();
+    }
 
 }

+ 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;

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

@@ -14,8 +14,11 @@ 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;
@@ -35,6 +38,7 @@ import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * @author yangyj
@@ -128,7 +132,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.importData(file,contractId,projectId,type);
+                return this.service.importExcel(file,contractId,projectId,type);
             } else {
                 R.fail("文件格式不正确,请上传Excel文件");
             }
@@ -148,64 +152,25 @@ public class DatumPointController {
 
         List<DatumPoint> list=this.service.exportExcel(contractId,type,search);
         if(list!=null&&list.size()>0){
-            //创建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();
+             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);
+             }
         }
 
     }

+ 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 = "高程")
-    private Double h=0.0;
+    @ExcelProperty(value = "高程(m)")
+    private String h;
     @ExcelProperty(value = "等级")
     private String level;
     @ExcelProperty(value = "备注")

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

@@ -14,21 +14,14 @@ 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 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;
+public class DatumPointxyExcel extends DatumPointExcel {
+    @ExcelProperty(value = "x坐标(m)",index=2)
+    private String x ;
+    @ExcelProperty(value = "y坐标(m)",index = 3)
+    private String y;
 }

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

@@ -2,22 +2,30 @@ 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
@@ -28,6 +36,7 @@ import java.util.*;
 @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)) {
@@ -70,155 +79,214 @@ public class DatumPointService extends BaseServiceImpl<DatumPointMapper, DatumPo
           }
           return  R.data(result);
     }
-
-    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("四级");
+    public  static  List<String> LEVEL = new ArrayList<>(Arrays.asList("一级","二级","三级","四级"));
+    public R importExcel(MultipartFile file, Long contractId, Long projectId, Integer dataType) {
         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;
+            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);
                 }
-                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);
+                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()));
                         }
-                        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;
+                        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()));
+                            }
                         }
-
-                    }
-                    obj.setContractId(contractId);
-                    obj.setProjectId(projectId);
-                    obj.setCreateTime(new Date());
-                    obj.setType(dataType);
-                    importList.add(obj);
+                        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("条记录导入成功");
                 }
-                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);
+                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));
                 }
+                return R.success(sb.toString());
             }
-            //批量保存
-            this.saveBatch(importList);
-            return   R.success("导入成功");
-        } catch (Exception e){
+            return  R.fail("数据无效");
+        }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="";

+ 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(",");
+			String[] s= Func.toStr(range).replaceAll("[\\[\\]]","").split(",\\s+");
 			return dateCp(s[0],s[1],false);
 		}
 		return StringPool.EMPTY;

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

@@ -3,6 +3,7 @@ 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.*;
@@ -81,6 +82,8 @@ 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";
 
 
 
@@ -156,15 +159,12 @@ 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_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);
-         }
+        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);
+        }
         /*检查项目*/
         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,13 +342,15 @@ 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->p.getKey()+":"+p.getValue()).collect(Collectors.joining(";")));
+        this.tec.getLog().append("本节点参数情况:").append(result.entrySet().stream().map(p->logMap.get(p.getKey())+":"+p.getValue()).collect(Collectors.joining(";")));
         /*元素动态绑定*/
         this.formDataMap.values().stream().filter(e->e.getIsCurrentNodeElement()&&e.getFormula()==null).forEach(e->{
             /*执行列表里不存在,且元素的名称和节点参数名称匹配成功*/
@@ -423,9 +425,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);
@@ -466,10 +468,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("不满足执行依赖;");
@@ -512,12 +514,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;
@@ -565,16 +567,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()));
+                }
             }
         }
     }
@@ -604,7 +606,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();
@@ -612,12 +614,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();
     }
 
@@ -636,10 +638,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);
         }
@@ -723,11 +725,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                         while (m.find()) {
                             Object data=null;
                             if(f.contains("quantity(")){
-                                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);
+                                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);
                                 if(Func.isNotEmpty(tableColKeyVal)){
-                                    data = tableColKeyVal.stream().map(map->{RangeInfo rangeInfo=BeanUtil.toBean((Map) map.get("val"), RangeInfo.class);return rangeInfo.getSize();}).collect(Collectors.toList());
+                                    data = tableColKeyVal.stream().map(map-> BeanUtil.toBean(JSON.parseObject(map.get("val").toString()),RangeInfo.class)).map(RangeInfo::getFail).findFirst().orElseGet(String::new);
                                 }else{
                                     /*手动计算*/
                                     System.out.println("");
@@ -739,7 +741,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);
+                                        this.tec.getLog().append(fd.getEName()).append("缺失依赖:").append(k).append(";");
                                         return;
                                     }
                                     E.put(e.getCode(),e.getValues().stream().map(ElementData::getValue).collect(Collectors.toList()));
@@ -792,19 +794,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);