ソースを参照

计量报表公式bug处理

yangyj 8 ヶ月 前
コミット
3aeb702ce4

+ 3 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterPeriodInfo.java

@@ -35,6 +35,9 @@ public class MeterPeriodInfo {
     /**本期支付金额*/
     @JSONField(name = "key_6",label="本期支付金额",ordinal = 4)
     private String  curTotal;
+    /**本期末累计支付金额*/
+    @JSONField(name = "key_7",label="本期末累计支付金额",ordinal = 4)
+    private String  total;
     /**请款理由*/
     @JSONField(name = "key_5",label="请款理由",ordinal = 5)
     private String  cause;

+ 14 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorFormat.java

@@ -8,6 +8,8 @@ import org.springblade.manager.dto.ElementData;
 import org.springblade.manager.dto.FormData;
 import org.springblade.manager.entity.Formula;
 
+import java.util.Set;
+
 /**
  * @author yangyj
  * @Date 2023/12/18 14:24
@@ -22,14 +24,22 @@ public class ExecutorFormat extends FormulaExecutor {
 
     @Override
     public void handle() {
+         Set<String> repeatKeys = tec.getRepeatKeys();
         /*数据格式化*/
         for(FormData fd:tec.formDataList){
             if(fd.verify()){
-                /*保留小数位*/
-                if(fd.getFormula()!=null&&!fd.empty()&&fd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNumber)){
-                    Formula f = fd.getFormula();
-                    fd.setValues(FormulaUtils.setScale(f.getScale(),fd.getValues()));
+                Formula f = fd.getFormula();
+                if(f!=null){
+                    if(!fd.empty()&&fd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNumber)) {
+                        /*保留小数位*/
+                        fd.setValues(FormulaUtils.setScale(f.getScale(), fd.getValues()));
+                    }
+                    if(StringUtils.isNotEmpty(f.getRely())&&f.getRelyList().size()==1&&repeatKeys.contains(f.getRely())){
+                        /*设置为repeat元素*/
+                        fd.setRepeat(true);
+                    }
                 }
+
             }
         }
 

+ 7 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorInit.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.springblade.common.utils.BaseUtils;
 import org.springblade.core.tool.utils.RegexUtil;
+import org.springblade.manager.dto.FormData;
 import org.springblade.manager.dto.TreeNode;
 import org.springblade.manager.vo.*;
 
@@ -39,7 +40,9 @@ public class ExecutorInit extends FormulaExecutor {
         BaseInfo baseInfo = baseInfoFc.apply(tec.getContractId());
         baseInfo.setTotalAmount(baseInfo.getContractAmount());
         tec.getConstantMap().put(BaseInfo.TBN,baseInfo);
-        tec.formDataMap.putAll(FormulaUtils.toFormDataMap(baseInfo));
+        LinkedHashMap<String, FormData> baseMap =FormulaUtils.toFormDataMap(baseInfo);
+        tec.getRepeatKeys().addAll(baseMap.keySet());
+        tec.formDataMap.putAll(baseMap);
         if(MeterType.MATERIAL.equals(tec.getMeterType())||MeterType.START.equals(tec.getMeterType())){
             /*加载计量期信息*/
             tec.periodInfo=meterPeriodFc.apply(tec.getReportId());
@@ -61,7 +64,9 @@ public class ExecutorInit extends FormulaExecutor {
                 tec.periodInfo.setPeriodNumber(periodNumber);
             }
         }
-        tec.formDataMap.putAll(FormulaUtils.toFormDataMap(tec.periodInfo));
+        LinkedHashMap<String, FormData> periodMap=  FormulaUtils.toFormDataMap(tec.periodInfo);
+        tec.getRepeatKeys().addAll(periodMap.keySet());
+        tec.formDataMap.putAll(periodMap);
 
     }
 

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -943,7 +943,7 @@ public class ExecutorMeter extends FormulaExecutor {
             if(pageFd!=null) {
                 int total = totalPage();
                 /*页面不重复*/
-                tec.getFormDataMap().values().stream().filter(e->e.executable()&& pageFd.getCode().equals(e.getFormula().getRely())).forEach(e->e.setRepeat(false));
+                /*tec.getFormDataMap().values().stream().filter(e->e.executable()&& pageFd.getCode().equals(e.getFormula().getRely())).forEach(e->e.setRepeat(false));*/
                 String pageTmp = "第$1页 共" + total + "页";
                 pageFd.setValues(IntStream.rangeClosed(1, total).boxed().map(i -> new ElementData(pageTmp.replace("$1", i.toString()))).collect(Collectors.toList()));
             }

+ 6 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/TableElementConverter.java

@@ -120,10 +120,11 @@ public class TableElementConverter implements ITableElementConverter {
     private MeterType meterType;
     /**计量单元树*/
     public CompletableFuture<Map<Long, TreeNode<MeterTree>>> meterTreeMap;
-    /*存放计量计算结果*/
-    public List<ReportResult> reportResults ;
-
-    /*取小数*/
+    /**存放计量计算结果*/
+    private List<ReportResult> reportResults ;
+    /**repeat 公共元素标记:有部分元素是每种表每页都相同的内容*/
+    private Set<String> repeatKeys=new HashSet<>();
+    /**取小数*/
     public Integer scale = 0;
 
     public Integer payRadicScale = 2;
@@ -377,7 +378,7 @@ public class TableElementConverter implements ITableElementConverter {
                          if(Func.isNotBlank(coords)){
                              fd.flushCoords(coords);
                              /*设置是否是每页公共数据*/
-                             fd.setRepeat(fd.getCoordsList().size()<2);
+                             /*fd.setRepeat(fd.getCoordsList().size()<2);*/
                          }
                      }
               }