瀏覽代碼

183计量

cr 1 天之前
父節點
當前提交
2d910148cd

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/InterimPaymentCertificate.java

@@ -94,6 +94,6 @@ public class InterimPaymentCertificate implements  DataModel{
             BigDecimal payRatioBd = currentPeriodEndPayBd.multiply(new BigDecimal(100)).divide(BaseUtils.str2BigDecimal(this.contractAmount), 2, RoundingMode.HALF_UP);
             this.payRatio = payRatioBd.toString();
         }
-        this.revisedTotal =BaseUtils.str2BigDecimal(revisedAmount).subtract(BaseUtils.str2BigDecimal(contractAmount)).toString();
+        //this.revisedTotal =BaseUtils.str2BigDecimal(revisedAmount).subtract(BaseUtils.str2BigDecimal(contractAmount)).toString();
     }
 }

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

@@ -1236,6 +1236,7 @@ public class ExecutorMeter extends FormulaExecutor {
             //上期期数ID
             Long prePeriodId = null;
             List<ContractMeterPeriod> contractMeterPeriodList =FormEndPayUtil.selectList(contractId);
+            List<Long> idList=new ArrayList<>();
             if(contractMeterPeriodList.size()>0){
                 OptionalInt index=IntStream.range(0, contractMeterPeriodList.size())
                     .filter(i -> contractMeterPeriodList.get(i).getId().equals(periodId))
@@ -1246,6 +1247,11 @@ public class ExecutorMeter extends FormulaExecutor {
                     if(j>0){
                         prePeriodId=contractMeterPeriodList.get(j-1).getId();
                     }
+                    // 获取从开始到目标索引(包含)的所有元素
+                    idList= IntStream.rangeClosed(0, j)
+                            .mapToObj(contractMeterPeriodList::get)
+                            .map(ContractMeterPeriod::getId)
+                            .collect(Collectors.toList());
                 }
             }
             Long finalPrePeriodId = prePeriodId;
@@ -1342,6 +1348,12 @@ public class ExecutorMeter extends FormulaExecutor {
                         }
                          /*计算其它属性值*/
                          ipc.calculate();
+                         //重新计算 合同价及变更总金额_变更总金额,合同价及变更总金额_变更后总金额
+                         //合同价及变更总金额_变更总金额 = 2-8的值累加
+                         BigDecimal sumChangeMoney =InventoryUCUtil.selectChangeMoney(idList,k);
+                         ipc.setRevisedTotal(sumChangeMoney+"");
+                         //合同价及变更总金额_变更后总金额 =合同价及变更总金额_变更总金额+合同价及变更总金额_合同金额
+                         ipc.setRevisedAmount(sumChangeMoney.add(new BigDecimal(ipc.getContractAmount())).toString());
                          //dataList.add(ipc);
                          paymentCertificateMap.put(ch,ipc);
                      }

+ 19 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/InventoryUCUtil.java

@@ -12,7 +12,11 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 @Component
@@ -120,6 +124,21 @@ public class InventoryUCUtil {
         return jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ChangeInventoryForm.class));
     }
 
+    public static BigDecimal selectChangeMoney(List<Long> idList, String k) {
+        if (idList == null || idList.isEmpty()) {
+            return BigDecimal.ZERO;
+        }
+        String placeholders = String.join(",", Collections.nCopies(idList.size(), "?"));
+        String sql = "select sum(change_money) from s_change_inventory_form where period_id in (" + placeholders + ") and inventory_num=?";
+        List<Object> params = new ArrayList<>();
+        params.addAll(idList);
+        params.add(k);
+        List<BigDecimal> result = jdbcTemplate.query(sql, params.toArray(), (rs, rowNum) -> rs.getBigDecimal(1));
+        BigDecimal sum = result.isEmpty() || result.get(0) == null ? BigDecimal.ZERO : result.get(0);
+        // 四舍五入保留整数
+        return sum.setScale(0, RoundingMode.HALF_UP);
+    }
+
     @Autowired
     public  void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
         InventoryUCUtil.jdbcTemplate = jdbcTemplate;