yangyj 1 년 전
부모
커밋
de650bc447

+ 15 - 0
blade-common/src/main/java/org/springblade/common/utils/BaseUtils.java

@@ -126,6 +126,21 @@ public class BaseUtils {
       return Pattern.matches(NUM_REG,stringValue);
     }
 
+
+    static final String ZERO_REG = "^(0(\\.0*)?|0[eE]-\\d+)$";
+    public static boolean isZero(Object value) {
+        if ((value == null) ) {
+            return false;
+        }
+        String stringValue = value.toString().trim();
+        if (stringValue.isEmpty()) {
+            return false;
+        }
+        return Pattern.matches(ZERO_REG,stringValue);
+    }
+
+
+
     public static  boolean isNotNumber(Object value){
         return !isNumber(value);
     }

+ 7 - 9
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterInfo.java

@@ -1,17 +1,15 @@
 package org.springblade.manager.vo;
 
 import cn.hutool.log.StaticLog;
-import com.aliyuncs.utils.MapUtils;
 import lombok.Data;
 import org.springblade.common.utils.BaseUtils;
-import org.springblade.manager.dto.ElementData;
 import org.springblade.manager.dto.TreeNode;
 import org.springblade.meter.entity.InterimPayCertificateItem;
 
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.function.ToIntFunction;
+
+import java.util.function.ToLongFunction;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
@@ -75,16 +73,16 @@ public class MeterInfo {
 
 
     /*章节排序*/
-    private ToIntFunction<InventoryForm> paymentSortIndexFc= itf -> {
-        int sort=9999999;
+    private ToLongFunction<InventoryForm> paymentSortIndexFc= itf -> {
+        long sort=Long.MAX_VALUE;
         String number = itf.getFormNumber();
         if(number!=null&&!number.isEmpty()){
             if(!number.contains("-")&&!BaseUtils.isNumber(number)) {
+                return sort;
+            }else {
                 String[] arr = number.split("[^\\d.]+");
                 /*  102-5-3-1的sort=102X10^6+5x10^4+3X10^2+1  */
                 sort = IntStream.range(0, arr.length).boxed().mapToInt(i -> (int) (BaseUtils.obj2IntegerZero(arr[i]) * Math.pow(10, (6 - 2 * i)))).sum();
-            }else {
-                return 2000;
             }
         }
         return sort;
@@ -92,7 +90,7 @@ public class MeterInfo {
     public List<InventoryForm> getInventoryForms()  {
         try {
             if(inventoryFormList==null) {
-                return inventoryForms.get().stream().sorted(Comparator.comparingInt(paymentSortIndexFc)).collect(Collectors.toList());
+                return inventoryForms.get().stream().sorted(Comparator.comparingLong(paymentSortIndexFc)).collect(Collectors.toList());
             }
             return inventoryFormList;
         }catch (Exception e){

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

@@ -2228,6 +2228,9 @@ public class CustomFunction {
         return null;
     }
 
+/*   public static void main(String[] args) {
+        System.out.println(xN(0.0,0.0001));
+    }*/
     /**
      * @return java.lang.Object
      * @Description 放大缩小

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

@@ -4,11 +4,13 @@ import com.mixsmart.utils.FormulaUtils;
 import com.mixsmart.utils.StringUtils;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import org.springblade.common.utils.BaseUtils;
 import org.springblade.core.tool.utils.StringPool;
 import org.springblade.manager.dto.ElementData;
 import org.springblade.manager.dto.FormData;
 import org.springblade.manager.entity.Formula;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
@@ -44,7 +46,7 @@ public class ExecutorFormat extends FormulaExecutor {
                 }
                 /*0不显示*/
                fd.getValues().forEach(ed->{
-                   if(StringUtils.isEquals("0",ed.getValue())){
+                   if(BaseUtils.isZero(ed.getValue())){
                        ed.setValue(StringPool.EMPTY);
                    }
                });

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

@@ -1483,163 +1483,7 @@ public class ExecutorMeter extends FormulaExecutor {
 
     }
 
-    @Data
-    @EqualsAndHashCode(callSuper = true)
-    public  class ConSchChapter2 extends   BaseSpecial<ConstructionSchedule> implements Special{
-
-        @Override
-        public boolean ready() {
-            return MeterInfo.MB_ZJ.equals(tec.getMeterInfo().getTemplate());
-        }
-
-        @Override
-        public void parse() {
-            builderFormDatas(ConstructionSchedule.class);
-
-            List<ChapterSchedule> chapterSchedules=chapterScheduleFc.apply(tec.getContractId().toString());
-            /*支付信息根据章节、月份分组*/
-            List<InventoryForm> inventoryForms = tec.meterInfo.getInventoryForms();
-            List<InventoryForm> chapters = tec.meterInfo.getChapter();
-            /*合同金额*/
-            Map<String, BigDecimal[]> contractMoney = contractMoneySum.apply(inventoryForms);
-            LinkedHashMap<String, InventoryForm> dictMap = chapters.stream().collect(Collectors.toMap(e->chapterPreFixFc.apply(e),e -> e, (v1, v2) -> v1,LinkedHashMap::new));
-            LinkedHashMap<Integer,List<Payment>>paymentListMap = tec.meterInfo.getPaymentListMap();
-            /*之前的计量期数据*/
-            previous = paymentListMap.get(MeterInfo.PRE);
-            /*当前计量期数据*/
-            current =paymentListMap.get(MeterInfo.CUR);
-            /*累计到本期末*/
-            paymentsPeriodEnd=paymentListMap.get(MeterInfo.END);
-            /*往期每章节的实际花费*/
-            Map<String,BigDecimal> previousMoney= moneySum.apply(previous);
-            /*当前计量期每章节的实际花费*/
-            Map<String,BigDecimal> currentMoney= moneySum.apply(current);
-            /*本期末每章节的实际花费*/
-            Map<String,BigDecimal> endMoney= moneySum.apply(paymentsPeriodEnd);
 
-            LinkedHashMap<Integer,BigDecimal> monthMoney = paymentsPeriodEnd.stream().sorted(Comparator.comparing(Payment::getBusinessDate)).collect(Collectors.groupingBy(
-                    payment -> payment.getBusinessDate().getMonthValue(),
-                    LinkedHashMap::new,
-                    Collectors.reducing(BigDecimal.ZERO, Payment::getMoneyAsBigDecimal, BigDecimal::add)
-            ));
-
-            BaseInfo baseInfo = tec.meterInfo.getBaseInfo();
-            dictMap.forEach((k,v)-> {
-                ConstructionSchedule cs = new ConstructionSchedule(v.getFormName());
-                BigDecimal[] sum = contractMoney.get(k);
-                cs.setChapterNumber(k);
-                cs.setContractMoney(sum[0].toPlainString());
-                cs.setChangeMoney(sum[1].toPlainString());
-                cs.setCurrentPeriodPay(StringUtils.handleNull(currentMoney.get(k)));
-                cs.setCurrentPeriodEndPay(StringUtils.handleNull(endMoney.get(k)));
-                cs.setItemPercent(ratioFc.apply(cs.getChangeMoney(), baseInfo.getContractAmount().toString()));
-                cs.setItemProgress(ratioFc.apply(cs.getCurrentPeriodEndPay(), cs.getChangeMoney()));
-                cs.setCurrentPayPercent(ratioFc.apply(cs.getCurrentPeriodPay(),cs.getChangeMoney()));
-                /* 本期末累计支付金额占合同比*/
-                cs.setPayPercent(ratioFc.apply(cs.getCurrentPeriodEndPay(),cs.getChangeMoney()));
-                /*本期末占合合同金额 */
-                cs.setPrePayPercent(ratioFc.apply(cs.getCurrentPeriodEndPay(),cs.getContractMoney()));
-                /*变更金额*/
-                cs.setChangeMoneyAll(subtractFc.apply(cs.getChangeMoney(),cs.getContractMoney()));
-                dataList.add(cs);
-            });
-            /*每月合计进度*/
-            try {
-                String totalAmount=dataList.stream().map(ConstructionSchedule::getContractMoney).map(BaseUtils::str2BigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toPlainString();
-                int max = monthMoney.keySet().stream().max(Comparator.comparingInt(i->i)).orElse(12);
-                /*没月累计*/
-                List<String> monthlySum= IntStream.rangeClosed(1,max).boxed().map(month->{
-                    BigDecimal tmp=  monthMoney.entrySet().stream().filter(e->e.getKey()<=month).map(Map.Entry::getValue).reduce(BigDecimal.ZERO,BigDecimal::add);
-                    return  ratioFc.apply(tmp.toPlainString(),totalAmount);
-                }).collect(Collectors.toList());
-                FormulaUtils.elementFindByCode(fdm,ConstructionSchedule.TBN+":key_22").ifPresent(t->{
-                    elementWriter.write(t,monthlySum);
-                });
-                /*本月*/
-                List<String> monthlyCount= IntStream.rangeClosed(1,max).boxed().map(month->{
-                    BigDecimal tmp=  monthMoney.entrySet().stream().filter(e-> e.getKey().equals(month)).map(Map.Entry::getValue).reduce(BigDecimal.ZERO,BigDecimal::add);
-                    return  ratioFc.apply(tmp.toPlainString(),totalAmount);
-                }).collect(Collectors.toList());
-                FormulaUtils.elementFindByCode(fdm,ConstructionSchedule.TBN+":key_23").ifPresent(t->{
-                    elementWriter.write(t,monthlyCount);
-                });
-                List<String> planMonthSum=new ArrayList<>();
-                if(chapterSchedules!=null&&chapterSchedules.size()>0) {
-                    String totalAmountPlan=totalAmount;
-                            /*chapterSchedules.stream().map(ChapterSchedule::getEight).map(BaseUtils::str2BigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toPlainString();*/
-                    chapterSchedules.forEach(ChapterSchedule::updateArray);
-                    List<BigDecimal> planMonth = IntStream.range(0,12).boxed().map(i->chapterSchedules.stream().map(e->e.getArr()[i]).reduce(BigDecimal.ZERO,BigDecimal::add)).collect(Collectors.toList());
-                    /*计划本月*/
-                    FormulaUtils.elementFindByCode(fdm, ConstructionSchedule.TBN + ":key_28").ifPresent(t -> {
-                        List<String> value=planMonth.stream().map(BigDecimal::toPlainString).map(s-> ratioFc.apply(s,totalAmountPlan)).collect(Collectors.toList());
-                        elementWriter.write(t, value);
-                    });
-                    /*计划累计*/
-                    planMonthSum = IntStream.range(0,12).boxed().map(i-> {
-                                String tmp=  planMonth.stream().filter(e -> planMonth.indexOf(e) <= i).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
-                                return ratioFc.apply(tmp,totalAmountPlan);
-                            }
-                    ).collect(Collectors.toList());
-                    List<String> finalPlanMonthSum = planMonthSum;
-                    FormulaUtils.elementFindByCode(fdm, ConstructionSchedule.TBN + ":key_27").ifPresent(t -> {
-                        elementWriter.write(t, finalPlanMonthSum);
-                    });
-                }
-                /*上传图标*/
-                if(planMonthSum.size()>0&&monthlySum.size()>0){
-                    try {
-                        double[] actual = monthlySum.stream().mapToDouble(BaseUtils::obj2DoubleZero).toArray();
-                        double[] planned =planMonthSum.stream().limit(monthlySum.size()).mapToDouble(BaseUtils::obj2DoubleZero).toArray();;
-                       /* byte[]  chartBytes = FormulaUtils.chapterScheduleChart(actual,planned);
-                        FileOutputStream fos = new FileOutputStream("C:/Users/yangyj/Desktop/Swap_space/poi_statistics2.png");
-                        fos.write(chartBytes);
-                        BladeFile chartFile= tec.getNewIOSSClient().updateFile(chartBytes, ConstructionSchedule.TBN+SnowFlakeUtil.getId()+".png");*/
-                        String path=FormulaUtils.chapterScheduleChartUrl(null,null,2023,2024);
-                        BladeFile chartFile= tec.getNewIOSSClient().uploadFile( ConstructionSchedule.TBN+ SnowFlakeUtil.getId() + ".png",path);
-                        /*施工进度图*/
-                        FormulaUtils.elementFindByCode(fdm, ConstructionSchedule.TBN + ":key_29").ifPresent(t -> {
-                            elementWriter.write(t, chartFile.getLink());
-                        });
-                    }catch (Exception e){
-                        e.printStackTrace();
-                    }
-                }
-            }catch (Exception e){
-                StaticLog.error(e.getMessage());
-            }
-
-            /* 合同概要*/
-            FormulaUtils.elementFindByCode(fdm,ConstructionSchedule.TBN+":key_24").ifPresent(t->{
-                /*合同时长*/
-                String contractDay=CustomFunction.join(CustomFunction.daysPassed(baseInfo.getStartDatePlan(),baseInfo.getEndDatePlan()),"").toString();
-                /*总时长*/
-                String totalDay=CustomFunction.join(CustomFunction.daysPassed(baseInfo.getStartDate(),baseInfo.getEndDate()),"").toString();
-                /*延长时间*/
-                int extended=BaseUtils.obj2IntegerZero(contractDay)-BaseUtils.obj2IntegerZero(totalDay);
-                /*已过去*/
-                String passDay=CustomFunction.join(CustomFunction.daysPassed(baseInfo.getStartDate(), LocalDate.now()),"").toString();
-
-                BigDecimal provisionalSum=tec.meterInfo.getInventoryForms().stream().filter(e->"D".equals(e.getFormNumber())).map(e->BaseUtils.str2BigDecimal(e.getBidPrice())).reduce(BigDecimal.ZERO,BigDecimal::add);
-                BigDecimal BOQAmount=tec.meterInfo.getInventoryForms().stream().filter(e->!"D".equals(e.getFormNumber())).map(e->BaseUtils.str2BigDecimal(e.getBidPrice())).reduce(BigDecimal.ZERO,BigDecimal::add);
-                baseInfo.setProvisionalSum(provisionalSum.toPlainString());
-                baseInfo.setBOQAmount(BOQAmount.toPlainString());
-                BigDecimal changeTokenTotal=tec.meterInfo.getChangeTokenListMap().values().stream().flatMap(Collection::stream).map(ChangeToken::getTotalChangeMoney).reduce(BigDecimal.ZERO,BigDecimal::add);
-                double totalMoney = BaseUtils.obj2DoubleZero(baseInfo.getContractAmount())+BaseUtils.obj2DoubleZero(baseInfo.getProvisionalSum())+BaseUtils.obj2DoubleZero(baseInfo.getBOQAmount())+BaseUtils.obj2DoubleZero(changeTokenTotal);
-                String brief="开工日期:"+baseInfo.getStartDatePlan()+" 始算工期日:"+baseInfo.getStartDate()
-                        +" 合同完成日期:"+baseInfo.getEndDatePlan()+" 合同期限"+contractDay+"天 时间延长"+extended+"天 修改后合同期限"+ totalDay
-                        +"天(即至"+baseInfo.getEndDate()+")"
-                        + "\n 合同总价"+CustomFunction.xN(baseInfo.getContractAmount(),0.0001)+"万元、暂定金"
-                        +CustomFunction.xN(baseInfo.getProvisionalSum(),0.0001)+"万元、工程量清单金额"
-                        +CustomFunction.xN(baseInfo.getBOQAmount(),0.0001)+"万元、工程量变更("+CustomFunction.xN(changeTokenTotal,0.0001)+")万元、估计最终金额"+CustomFunction.xN(totalMoney,0.0001)+"万元,时间已过"
-                        +passDay+"天,占合同工期"+StringUtils.number2String(ratioFc.apply(passDay,totalDay),2)+"%";
-                elementWriter.write(t,brief);
-            });
-
-            /*内容输出*/
-            putOut(ConstructionSchedule.class);
-
-        }
-    }
     @Data
     @EqualsAndHashCode(callSuper = true)
     public  class ConSchChapter extends   BaseSpecial<ConstructionSchedule> implements Special{
@@ -1715,8 +1559,8 @@ public class ExecutorMeter extends FormulaExecutor {
                 int max = monthMoney.keySet().stream().max(Comparator.comparingInt(i->i)).orElse(BaseUtils.dateInt(planEndDate.getYear(),12));
                 int min= monthMoney.keySet().stream().min(Comparator.comparingInt(i->i)).orElse(BaseUtils.dateInt(planStartDate.getYear(),1));
                 List<Integer> tickUnit =BaseUtils.getTickUnit(min,max);
-                /*起始月相对于一月份的偏移量*/
-                int offset= min%100-1;
+                /*起始月相对于起始年一月份的偏移量*/
+                int offset= (min/100-planStartDate.getYear())*12+min%100-1;
                 /*每月累计*/
                 LinkedHashMap<Integer,Double> actualMap  = new LinkedHashMap<>();
                 List<String> monthlySum=  tickUnit.stream().map(month->{
@@ -1800,7 +1644,7 @@ public class ExecutorMeter extends FormulaExecutor {
                 /*总时长*/
                 String totalDay=CustomFunction.join(CustomFunction.daysPassed(baseInfo.getStartDate(),baseInfo.getEndDate()),"").toString();
                 /*延长时间*/
-                int extended=BaseUtils.obj2IntegerZero(contractDay)-BaseUtils.obj2IntegerZero(totalDay);
+                int extended=BaseUtils.obj2IntegerZero(totalDay)-BaseUtils.obj2IntegerZero(contractDay);
                 /*已过去*/
                 String passDay=CustomFunction.join(CustomFunction.daysPassed(baseInfo.getStartDate(), LocalDate.now()),"").toString();