|
@@ -2,6 +2,7 @@ package org.springblade.manager.formula.impl;
|
|
|
|
|
|
import com.mixsmart.utils.FormulaUtils;
|
|
|
import com.mixsmart.utils.StringUtils;
|
|
|
+import kotlin.ranges.IntRange;
|
|
|
import lombok.Data;
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
import org.springblade.common.utils.BaseUtils;
|
|
@@ -14,10 +15,13 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.function.BiFunction;
|
|
|
import java.util.function.Function;
|
|
|
+import java.util.function.Predicate;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.IntStream;
|
|
|
|
|
|
/**
|
|
|
* @author yangyj
|
|
@@ -40,6 +44,8 @@ public class ExecutorInit extends FormulaExecutor {
|
|
|
private Function<Long,List<ChangeToken>> changeTokenFc;
|
|
|
private Function<Long, List<Payment>> paymentListFc;
|
|
|
private Function<Long, List<InventoryForm>> inventoryFormFc;
|
|
|
+ private Function<Long, List<MaterialAdjust>> materialAdjustFc;
|
|
|
+
|
|
|
|
|
|
public static final String SZ="[ 一二三四五六七八九十]+";
|
|
|
|
|
@@ -83,6 +89,8 @@ public class ExecutorInit extends FormulaExecutor {
|
|
|
startInfo();
|
|
|
//变更令部分
|
|
|
changeToken();
|
|
|
+ /*材料调差*/
|
|
|
+ materialAdjust();
|
|
|
tec.meterInfo.setPaymentList(paymentListFc.apply(tec.getContractId()));
|
|
|
/*合同工程清单*/
|
|
|
tec.meterInfo.setInventoryForms(CompletableFuture.supplyAsync(() -> inventoryFormFc.apply(tec.getContractId())));
|
|
@@ -148,10 +156,35 @@ public class ExecutorInit extends FormulaExecutor {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ BiFunction<List<ChangeToken>,Predicate<ChangeToken>,List<ChangeToken>>
|
|
|
+ changeTokenPick = (a,b)-> a.stream().filter(b).collect(Collectors.toList());
|
|
|
+
|
|
|
private void changeToken(){
|
|
|
List<ChangeToken> changeTokenList = changeTokenFc.apply(tec.getContractId());
|
|
|
if(changeTokenList.size()>0){
|
|
|
- tec.meterInfo.setChangeTokenListMap(changeTokenList.stream().collect(Collectors.groupingBy(changeTokenPick,LinkedHashMap::new,Collectors.toList())));
|
|
|
+ MeterPeriodInfo periodInfo =tec.periodInfo;
|
|
|
+ LinkedHashMap<Integer,List<ChangeToken>>changeTokenListMap = new LinkedHashMap<>();
|
|
|
+ changeTokenListMap.put(MeterInfo.PRE,changeTokenPick.apply(changeTokenList,token -> token.getChangeApprovalDate().isBefore(periodInfo.getStartDate())));
|
|
|
+ changeTokenListMap.put(MeterInfo.CUR,changeTokenPick.apply(changeTokenList,token -> (periodInfo.getStartDate().isBefore(token.getChangeApprovalDate())
|
|
|
+ && !periodInfo.getEndDate().isBefore(token.getChangeApprovalDate()))));
|
|
|
+ changeTokenListMap.put(MeterInfo.END,changeTokenPick.apply(changeTokenList,token -> token.getChangeApprovalDate().isBefore(periodInfo.getEndDate())));
|
|
|
+ tec.meterInfo.setChangeTokenListMap(changeTokenListMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BiFunction< LinkedHashMap<Integer,List<MaterialAdjust>>, Predicate<Map.Entry<Integer,List<MaterialAdjust>>>, List<MaterialAdjust>>
|
|
|
+ materialAdjustPick = (a,b)-> a.entrySet().stream().filter(b).flatMap(kv->kv.getValue().stream()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ private void materialAdjust(){
|
|
|
+ List<MaterialAdjust> materialAdjustList = materialAdjustFc.apply(tec.getContractId());
|
|
|
+ if(materialAdjustList.size()>0){
|
|
|
+ LinkedHashMap<Integer,List<MaterialAdjust>> tmp = materialAdjustList.stream().collect(Collectors.groupingBy(MaterialAdjust::getSort,LinkedHashMap::new,Collectors.toList()));
|
|
|
+ int sort = tec.periodInfo.getSort();
|
|
|
+ LinkedHashMap<Integer,List<MaterialAdjust>>materialAdjustListMap = new LinkedHashMap<>();
|
|
|
+ materialAdjustListMap.put(MeterInfo.PRE,materialAdjustPick.apply(tmp,kv->kv.getKey()<sort));
|
|
|
+ materialAdjustListMap.put(MeterInfo.CUR,materialAdjustPick.apply(tmp,kv->kv.getKey()==sort));
|
|
|
+ materialAdjustListMap.put(MeterInfo.END,materialAdjustPick.apply(tmp,kv->kv.getKey()<=sort));
|
|
|
+ tec.meterInfo.setMaterialAdjustListMap(materialAdjustListMap);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -178,27 +211,15 @@ public class ExecutorInit extends FormulaExecutor {
|
|
|
.collect(Collectors.toList());
|
|
|
case 2:
|
|
|
return changeTokenList.stream()
|
|
|
- .filter(token -> !token.getChangeApprovalDate().isAfter(periodInfo.getEndDate()))
|
|
|
+ .filter(token -> token.getChangeApprovalDate().isBefore(periodInfo.getEndDate()))
|
|
|
.collect(Collectors.toList());
|
|
|
default:
|
|
|
throw new IllegalArgumentException("Unsupported type: " + type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**根据日期对变更令分类*/
|
|
|
- Function<ChangeToken,Integer> changeTokenPick=token->{
|
|
|
- int result =-1;
|
|
|
- if(token.getChangeApprovalDate().isBefore(tec.periodInfo.getStartDate())){
|
|
|
- /*上期末*/
|
|
|
- result=MeterInfo.PRE;
|
|
|
- }else if(tec.periodInfo.getStartDate().isBefore(token.getChangeApprovalDate()) && !tec.periodInfo.getEndDate().isBefore(token.getChangeApprovalDate())){
|
|
|
- /*本期*/
|
|
|
- result=MeterInfo.CUR;
|
|
|
- }else if(!token.getChangeApprovalDate().isAfter(tec.periodInfo.getEndDate())){
|
|
|
- /*本期末*/
|
|
|
- result= MeterInfo.END;
|
|
|
- }
|
|
|
- return result;
|
|
|
- };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|