yangyj 3 hafta önce
ebeveyn
işleme
29020b0d08

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

@@ -1684,22 +1684,38 @@ public class ExecutorMeter extends FormulaExecutor {
                 sis.setContractMoney(itf.getContractMoney());
                 sis.setChangeMoney(itf.getChangeMoney());
                 sis.setPrice(itf.getBidPrice());
-                if(cur!=null&&cur.getContractMoney()!=null) {
-                    FormulaUtils.getScale(cur.getUnit()).ifPresent(scale->{
-                        cur.setCompleted(BaseUtils.str2BigDecimal(cur.getCompleted()).setScale(scale,RoundingMode.HALF_UP));
-                        cur.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(cur.getPrice(),cur.getCompleted().toString())).setScale(0,RoundingMode.HALF_UP));
-                        if (pre != null) {
-                            pre.setCompleted(BaseUtils.str2BigDecimal(pre.getCompleted()).setScale(scale,RoundingMode.HALF_UP));
-                            pre.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(pre.getPrice(),pre.getCompleted().toString())).setScale(0,RoundingMode.HALF_UP));
-                            end.setCompleted(BaseUtils.str2BigDecimal(addFc.apply(cur.getCompleted().toString(),pre.getCompleted().toString())).setScale(scale,RoundingMode.HALF_UP));
-                            end.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(end.getPrice(),end.getCompleted().toString())).setScale(0,RoundingMode.HALF_UP));
-                        }else {
-                            end.setCompleted(cur.getCompleted());
-                            end.setMoney(cur.getMoney());
-                        }
-                    });
-                    sis.setCurrentPeriodPay(cur.getMoney().toPlainString());
-                    sis.setCurrentPeriodCompleted(cur.getCompleted().toPlainString());
+                /*只要存在累计就显示*/
+                if(end!=null&&end.getContractMoney()!=null) {
+                    if(cur!=null) {
+                        /*根据单位保留小数位,同时对总金额进行取整*/
+                        FormulaUtils.getScale(cur.getUnit()).ifPresent(scale -> {
+                            cur.setCompleted(BaseUtils.str2BigDecimal(cur.getCompleted()).setScale(scale, RoundingMode.HALF_UP));
+                            cur.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(cur.getPrice(), cur.getCompleted().toString())).setScale(0, RoundingMode.HALF_UP));
+                            if (pre != null) {
+                                pre.setCompleted(BaseUtils.str2BigDecimal(pre.getCompleted()).setScale(scale, RoundingMode.HALF_UP));
+                                pre.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(pre.getPrice(), pre.getCompleted().toString())).setScale(0, RoundingMode.HALF_UP));
+                                end.setCompleted(BaseUtils.str2BigDecimal(addFc.apply(cur.getCompleted().toString(), pre.getCompleted().toString())).setScale(scale, RoundingMode.HALF_UP));
+                                end.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(end.getPrice(), end.getCompleted().toString())).setScale(0, RoundingMode.HALF_UP));
+                            } else {
+                                end.setCompleted(cur.getCompleted());
+                                end.setMoney(cur.getMoney());
+                            }
+                        });
+
+                    }else{
+                        /*根据单位保留小数位,同时对总金额进行取整*/
+                        FormulaUtils.getScale(pre.getUnit()).ifPresent(scale -> {
+                            pre.setCompleted(BaseUtils.str2BigDecimal(pre.getCompleted()).setScale(scale, RoundingMode.HALF_UP));
+                            pre.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(pre.getPrice(), pre.getCompleted().toString())).setScale(0, RoundingMode.HALF_UP));
+                            end.setCompleted(pre.getCompleted());
+                            end.setMoney(pre.getMoney());
+                        });
+
+                    }
+                    if(cur!=null) {
+                        sis.setCurrentPeriodPay(cur.getMoney().toPlainString());
+                        sis.setCurrentPeriodCompleted(cur.getCompleted().toPlainString());
+                    }
                     if (pre != null) {
                         sis.setPreviousPeriodPay(pre.getMoney().toPlainString());
                         sis.setPreviousPeriodCompleted(pre.getCompleted().toPlainString());