Jelajahi Sumber

变更令获取

huangtf 7 bulan lalu
induk
melakukan
19d39efa83

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

@@ -60,5 +60,9 @@ public class MeterPeriodInfo implements  DataModel{
     /**证书id*/
     private Long reportId;
 
+    /**起始日期*/
+    private LocalDate startDate;
+    /**结束日期*/
+    private LocalDate endDate;
 
 }

+ 30 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorInit.java

@@ -15,6 +15,7 @@ import java.util.concurrent.CompletableFuture;
 import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * @author yangyj
@@ -33,6 +34,8 @@ public class ExecutorInit extends FormulaExecutor {
     /*private Function<Long, MeterPeriodInfo> interimMeterPeriodFc;*/
     private Function<Long, List<Material>> materialFormFc;
     private Function<Long,List<MeterPeriodInfo>> interimMeterPeriodAllFc;
+
+    private Function<Long,List<ChangeToken>> changeTokenFc;
     public static final String SZ="[ 一二三四五六七八九十]+";
 
 
@@ -79,6 +82,12 @@ public class ExecutorInit extends FormulaExecutor {
             }
         }
         LinkedHashMap<String, FormData> periodMap = FormulaUtils.toFormDataMap(tec.periodInfo);
+
+        //变更令部分
+        List<ChangeToken> changeTokenList = changeTokenFc.apply(tec.getContractId());
+
+        //List<ChangeToken> changeTokenList1 = getFilteredChangeTokens(changeTokenList,tec.periodInfo,0);
+
         /*每页内容都一样*/
         tec.getRepeatKeys().addAll(periodMap.keySet());
         tec.formDataMap.putAll(periodMap);
@@ -102,5 +111,26 @@ public class ExecutorInit extends FormulaExecutor {
     }
 
 
+    public  List<ChangeToken> getFilteredChangeTokens(List<ChangeToken> changeTokenList, MeterPeriodInfo periodInfo, int type) {
+        switch (type) {
+            case 0:
+                return changeTokenList.stream()
+                        .filter(token -> (periodInfo.getStartDate().isBefore(token.getChangeApprovalDate())
+                                && !periodInfo.getEndDate().isBefore(token.getChangeApprovalDate())))
+                        .collect(Collectors.toList());
+            case 1:
+                return changeTokenList.stream()
+                        .filter(token -> token.getChangeApprovalDate().isBefore(periodInfo.getStartDate()))
+                        .collect(Collectors.toList());
+            case 2:
+                return changeTokenList.stream()
+                        .filter(token -> !token.getChangeApprovalDate().isAfter(periodInfo.getStartDate()))
+                        .collect(Collectors.toList());
+            default:
+                throw new IllegalArgumentException("Unsupported type: " + type);
+        }
+    }
+
+
 
 }

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaDaoImpl.java

@@ -121,7 +121,7 @@ public class FormulaDaoImpl implements IFormulaDao {
     @Override
     public Function<Long, List<MeterPeriodInfo>> getInterimMeterPeriodAllFc() {
           return contractId->{
-            String sql="select a.id, a.period_number periodNumber,a.sort ,b.print_date formPrintDate ,b.pay_money curTotal,b.id reportId from  s_contract_meter_period a join s_interim_pay_certificate b on a.id=b.contract_period_id where a.is_deleted=0 and  b.is_deleted=0 and b.contract_id="+contractId+" order by a.sort";
+            String sql="select a.id, a.period_number periodNumber,a.sort ,b.print_date formPrintDate ,b.pay_money curTotal,b.id reportId,b.start_date,b.end_date  from  s_contract_meter_period a join s_interim_pay_certificate b on a.id=b.contract_period_id where a.is_deleted=0 and  b.is_deleted=0 and b.contract_id="+contractId+" order by a.sort";
             return   getEntityList(sql,MeterPeriodInfo.class);
         };
     }
@@ -186,7 +186,7 @@ public class FormulaDaoImpl implements IFormulaDao {
     public Function<Long, List<ChangeToken>> getChangeTokenFc() {
         return  contractId->{
             String sql="SELECT sctf.change_number, sctf.business_date, sctf.change_money as total_change_money, sctf.change_approval_date, scti.id, scti.change_token_id, scti.form_number, scti.change_money FROM s_change_token_form sctf " +
-                    "INNER JOIN s_change_token_inventory scti ON sctf.id = scti.change_token_id WHERE sctf.is_deleted = 0 AND sctf.approve_status = 2 AND scti.is_deleted = 0 AND sctf.contract_id =  "+contractId;
+                    "INNER JOIN s_change_token_inventory scti ON sctf.id = scti.change_token_id WHERE sctf.is_deleted = 0 AND sctf.approve_status = 2 AND scti.is_deleted = 0 AND sctf.contract_id =  "+contractId + " order by scti.change_token_id";
             return getEntityList(sql,ChangeToken.class);
         };
     }