From 64a1cc897adf662573b552ceeab86737098fd8c0 Mon Sep 17 00:00:00 2001 From: jacky6024 Date: Fri, 1 Dec 2017 16:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E5=8F=8A=E6=9D=A1=E7=A0=81=E5=9C=A8=E8=AE=BE=E7=BD=AE=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E6=97=B6=E6=98=BE=E7=A4=BA=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../build/compute/ZxingValueCompute.java | 55 +++++++++++++------ .../ureport/export/html/HtmlProducer.java | 5 +- .../expr/CurrentCellValueExpression.java | 2 +- 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/ureport2-core/src/main/java/com/bstek/ureport/build/compute/ZxingValueCompute.java b/ureport2-core/src/main/java/com/bstek/ureport/build/compute/ZxingValueCompute.java index 1dead82f..35cb8b62 100644 --- a/ureport2-core/src/main/java/com/bstek/ureport/build/compute/ZxingValueCompute.java +++ b/ureport2-core/src/main/java/com/bstek/ureport/build/compute/ZxingValueCompute.java @@ -35,7 +35,10 @@ import com.bstek.ureport.definition.value.ZxingValue; import com.bstek.ureport.exception.ReportComputeException; import com.bstek.ureport.expression.model.Expression; +import com.bstek.ureport.expression.model.data.BindDataListExpressionData; import com.bstek.ureport.expression.model.data.ExpressionData; +import com.bstek.ureport.expression.model.data.ObjectExpressionData; +import com.bstek.ureport.expression.model.data.ObjectListExpressionData; import com.bstek.ureport.model.Cell; import com.bstek.ureport.model.Image; import com.google.zxing.BarcodeFormat; @@ -70,26 +73,44 @@ public List compute(Cell cell, Context context) { }else{ Expression expression=value.getExpression(); ExpressionData data=expression.execute(cell,cell, context); - Object obj=data.getData(); - if(obj instanceof List){ - List listData=(List)obj; - for(Object o:listData){ - if(o!=null){ - Image image=buildImage(barcodeForamt,o.toString(),w,h); - list.add(new BindData(image)); - } + if(data instanceof BindDataListExpressionData){ + BindDataListExpressionData listData=(BindDataListExpressionData)data; + List bindDataList=listData.getData(); + for(BindData bindData:bindDataList){ + Object obj=bindData.getValue(); + if(obj==null)obj=""; + Image image=buildImage(barcodeForamt,obj.toString(),w,h); + list.add(new BindData(image)); } - }else if(obj instanceof String){ - String text=obj.toString(); - if(text.startsWith("\"") && text.endsWith("\"")){ - text=text.substring(1,text.length()-1); + }else if(data instanceof ObjectExpressionData){ + ObjectExpressionData exprData=(ObjectExpressionData)data; + Object obj=exprData.getData(); + if(obj==null){ + obj=""; + }else if(obj instanceof String){ + String text=obj.toString(); + if(text.startsWith("\"") && text.endsWith("\"")){ + text=text.substring(1,text.length()-1); + } + obj=text; } - Image image=buildImage(barcodeForamt,text,w,h); - list.add(new BindData(image)); - }else{ - if(obj!=null){ + Image image=buildImage(barcodeForamt,obj.toString(),w,h); + list.add(new BindData(image)); + }else if(data instanceof ObjectListExpressionData){ + ObjectListExpressionData listExprData=(ObjectListExpressionData)data; + List listData=listExprData.getData(); + for(Object obj:listData){ + if(obj==null){ + obj=""; + }else if(obj instanceof String){ + String text=obj.toString(); + if(text.startsWith("\"") && text.endsWith("\"")){ + text=text.substring(1,text.length()-1); + } + obj=text; + } Image image=buildImage(barcodeForamt,obj.toString(),w,h); - list.add(new BindData(image)); + list.add(new BindData(image)); } } } diff --git a/ureport2-core/src/main/java/com/bstek/ureport/export/html/HtmlProducer.java b/ureport2-core/src/main/java/com/bstek/ureport/export/html/HtmlProducer.java index cfc16469..49a80a1f 100644 --- a/ureport2-core/src/main/java/com/bstek/ureport/export/html/HtmlProducer.java +++ b/ureport2-core/src/main/java/com/bstek/ureport/export/html/HtmlProducer.java @@ -193,7 +193,7 @@ private StringBuilder buildTable(Context context,List rows, List co if(StringUtils.isBlank(target))target="_self"; sb.append(""); } - Object obj=(cell.getFormatData()== null) ? " " : cell.getFormatData(); + Object obj=(cell.getFormatData()== null) ? "" : cell.getFormatData(); if(obj instanceof Image){ Image img=(Image)obj; String path=img.getPath(); @@ -229,6 +229,9 @@ private StringBuilder buildTable(Context context,List rows, List co text=text.replaceAll("\r\n", "
"); text=text.replaceAll("\n", "
"); text=text.replaceAll(" ", " "); + if(text.equals("")){ + text=" "; + } sb.append(text); } if(hasLink){ diff --git a/ureport2-core/src/main/java/com/bstek/ureport/expression/model/expr/CurrentCellValueExpression.java b/ureport2-core/src/main/java/com/bstek/ureport/expression/model/expr/CurrentCellValueExpression.java index 25a75b21..d0659819 100644 --- a/ureport2-core/src/main/java/com/bstek/ureport/expression/model/expr/CurrentCellValueExpression.java +++ b/ureport2-core/src/main/java/com/bstek/ureport/expression/model/expr/CurrentCellValueExpression.java @@ -29,6 +29,6 @@ public class CurrentCellValueExpression extends BaseExpression { @Override protected ExpressionData compute(Cell cell, Cell currentCell,Context context) { - return new ObjectExpressionData(cell.getFormatData()); + return new ObjectExpressionData(cell.getData()); } }