|
@@ -1,17 +1,23 @@
|
|
|
package org.springblade.manager.formula.impl;
|
|
|
|
|
|
+import com.mixsmart.utils.FormulaUtils;
|
|
|
import com.mixsmart.utils.StringUtils;
|
|
|
import lombok.Data;
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.manager.dto.Coords;
|
|
|
+import org.springblade.manager.dto.ElementData;
|
|
|
import org.springblade.manager.dto.FormData;
|
|
|
import org.springblade.manager.formula.FormulaExecutor;
|
|
|
import org.springblade.manager.vo.BaseInfo;
|
|
|
import org.springblade.manager.vo.Material;
|
|
|
-import org.springblade.manager.vo.MeterPeriodInfo;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.IntStream;
|
|
|
|
|
|
/**
|
|
|
* @author yangyj
|
|
@@ -25,15 +31,16 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
public ExecutorSpecial(TableElementConverter tec) {
|
|
|
super(tec);
|
|
|
}
|
|
|
+ private List<Special> specialList = new ArrayList<>();
|
|
|
|
|
|
@Override
|
|
|
public void handle() {
|
|
|
- for(FormData fd:tec.getFormDataList()){
|
|
|
-
|
|
|
- }
|
|
|
+ MaterialCalc materialCalc = new MaterialCalc(tec.getFormDataList());
|
|
|
+ this.specialList.add(materialCalc);
|
|
|
+ this.specialList.forEach(Special::parse);
|
|
|
}
|
|
|
@Data
|
|
|
- public class MaterialCalc {
|
|
|
+ public class MaterialCalc implements Special{
|
|
|
private FormData index;
|
|
|
private FormData materialName;
|
|
|
private FormData unit;
|
|
@@ -52,53 +59,107 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
private String total;
|
|
|
/**预付款合计*/
|
|
|
private String totalAdvance;
|
|
|
+ private List<FormData> fds=new ArrayList<>();
|
|
|
public MaterialCalc(List<FormData> list) {
|
|
|
for(FormData fd:list){
|
|
|
if(fd.getEName().contains("序号")){
|
|
|
this.index=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("材料名称")){
|
|
|
this.materialName=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("单位")){
|
|
|
this.unit=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("数量")){
|
|
|
this.meterAmount=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("单价")){
|
|
|
this.price=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("材料合计价")){
|
|
|
this.sum=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("预付比例")){
|
|
|
this.ratio=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("材料预付款")){
|
|
|
this.advancePayment=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("材料来源")){
|
|
|
this.source=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("是否符合要求")){
|
|
|
this.materialConform=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("备料对方地点")){
|
|
|
this.storagePlace=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("存储情况")){
|
|
|
this.storageStatus=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("存储方法是否符合要求")){
|
|
|
this.storageConform=fd;
|
|
|
+ fds.add(fd);
|
|
|
}else if(fd.getEName().contains("备注")){
|
|
|
this.remark=fd;
|
|
|
+ fds.add(fd);
|
|
|
+ }
|
|
|
+ if(fds.size()>=14){
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- public void handle(){
|
|
|
+ public void parse(){
|
|
|
/*加载合同材料、材料清单*/
|
|
|
/* b.material_name name,b.unit,b.price,a.meter_amount amount,a.material_source source
|
|
|
,material_conform materialConform,a.storage_place storagePlace,a.storage_status storageStatus,a.storage_conform storageConform,a.remark*/
|
|
|
List<Material> materials = materialListFc.apply(tec.getPeriodId());
|
|
|
if(Func.isNotEmpty(materials)){
|
|
|
BaseInfo baseInfo= (BaseInfo) tec.getConstantMap().get(BaseInfo.TBN);
|
|
|
+ int n=1;
|
|
|
for(Material m:materials){
|
|
|
+ m.setIndex(n++);
|
|
|
m.setRatio(baseInfo.getDeductRatio()*100+"%");
|
|
|
m.setAdvancePayment(StringUtils.number2StringZero(Double.parseDouble(m.getSum())*baseInfo.getDeductRatio(),1));
|
|
|
}
|
|
|
this.total=StringUtils.number2StringZero(materials.stream().mapToDouble(m->Double.parseDouble(m.getSum())).sum(),1);
|
|
|
this.totalAdvance=StringUtils.number2StringZero(materials.stream().mapToDouble(m->Double.parseDouble(m.getAdvancePayment())).sum(),1);
|
|
|
+ List<Object> dataList= materials.stream().flatMap(m->m.getData().stream()).collect(Collectors.toList());
|
|
|
+ if(dataList.size()>0){
|
|
|
+ Map<Integer,List<Object>> groupData= IntStream.range(0, dataList.size())
|
|
|
+ .boxed()
|
|
|
+ .collect(Collectors.groupingBy(index -> index % 14,
|
|
|
+ Collectors.mapping(dataList::get, Collectors.toList())));
|
|
|
+ for(int i=0;i<this.fds.size();i++){
|
|
|
+ List<Object> dl= groupData.get(i);
|
|
|
+ FormData fd= fds.get(i);
|
|
|
+ FormulaUtils.write(fd,dl);
|
|
|
+ }
|
|
|
+ /*追加合计*/
|
|
|
+ append(this.sum,this.total);
|
|
|
+ append(this.advancePayment,this.advancePayment);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ public void append(FormData fd,Object value){
|
|
|
+ if(fd!=null&&value!=null&&fd.getCoordsList().size()>0){
|
|
|
+ if(fd.empty()){
|
|
|
+ fd.getValues().get(0).setValue(value);
|
|
|
+ }else{
|
|
|
+ for(int n=0;n<fd.getValues().size();n++){
|
|
|
+ ElementData ed = fd.getValues().get(n);
|
|
|
+ if(ed.isEmpty()){
|
|
|
+ ed.setValue(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public interface Special{
|
|
|
+ void parse();
|
|
|
}
|
|
|
}
|