|
@@ -1,10 +1,16 @@
|
|
package com.mixsmart.utils;
|
|
package com.mixsmart.utils;
|
|
|
|
|
|
|
|
|
|
|
|
+import org.springblade.manager.dto.Coords;
|
|
|
|
+import org.springblade.manager.dto.ElementData;
|
|
|
|
+import org.springblade.manager.dto.FormData;
|
|
|
|
+import org.springblade.manager.entity.Formula;
|
|
|
|
+
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author yangyj
|
|
* @author yangyj
|
|
@@ -56,6 +62,56 @@ public class FormulaUtils {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static void write(FormData fd, Object data){
|
|
|
|
+ if(data instanceof List){
|
|
|
|
+ List<Object> values = (List<Object>) data;
|
|
|
|
+ if(values.size()>fd.getValues().size()){
|
|
|
|
+ /*当生成的数据超过实际容量的时候,会自动追加页数*/
|
|
|
|
+ if(fd.getCoordsList().size()==1){
|
|
|
|
+ fd.getValues().get(0).setValue(values.stream().map(StringUtils::handleNull).collect(Collectors.joining("、")));
|
|
|
|
+ }else{
|
|
|
|
+ // copy(fd,values);
|
|
|
|
+ for(int n=0;n<fd.getValues().size();n++){
|
|
|
|
+ fd.getValues().get(n).setValue(values.get(n));
|
|
|
|
+ }
|
|
|
|
+ List<Object> overList=values.stream().skip(fd.getValues().size()).collect(Collectors.toList());
|
|
|
|
+ List<Coords> coordsList = fd.getCoordsList();
|
|
|
|
+ int addPage=(int)Math.ceil((double)overList.size()/(double)coordsList.size());
|
|
|
|
+ fd.setAddPages(addPage);
|
|
|
|
+ ElementData last =fd.getValues().get(fd.getValues().size()-1);
|
|
|
|
+ int indexBase=last.getIndex()+1;
|
|
|
|
+ List<ElementData> addList= new ArrayList<>();
|
|
|
|
+ for(int i=0;i<addPage;i++){
|
|
|
|
+ for(int j=0;j<coordsList.size();j++){
|
|
|
|
+ /*超页就尽管写进去,格式化阶段再加表*/
|
|
|
|
+ Coords coords = coordsList.get(j);
|
|
|
|
+ Object v=null;
|
|
|
|
+ int st=i*coordsList.size()+j;
|
|
|
|
+ if(st<overList.size()){
|
|
|
|
+ v= overList.get(st);
|
|
|
|
+ }
|
|
|
|
+ addList.add(new ElementData(indexBase+i,last.getGroupId(),v,coords.getX(),coords.getY()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ fd.getValues().addAll(addList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ for(int n=0;n<values.size();n++){
|
|
|
|
+ fd.getValues().get(n).setValue(values.get(n));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ if(Formula.FULL.equals(fd.getFormula().getOutm())){
|
|
|
|
+ /*填充策略*/
|
|
|
|
+ fd.getValues().forEach(e->e.setValue(data));
|
|
|
|
+ }else{
|
|
|
|
+ fd.getValues().get(0).setValue(data);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|