Bladeren bron

解决页面横向输出时边距处理错误的BUG,添加数据行倍数、添加条件属性分页、添加标题行类型和总结行类型功能

master
jacky6024 7 jaren geleden
bovenliggende
commit
a749721af4
  1. 92
      ureport2-console/src/main/resources/asserts/js/designer.bundle.js
  2. 26
      ureport2-console/src/main/resources/asserts/js/preview.bundle.js
  3. 9
      ureport2-core/src/main/java/com/bstek/ureport/build/Context.java
  4. 3
      ureport2-core/src/main/java/com/bstek/ureport/build/DataCompute.java
  5. 207
      ureport2-core/src/main/java/com/bstek/ureport/build/ReportBuilder.java
  6. 37
      ureport2-core/src/main/java/com/bstek/ureport/build/Splash.java
  7. 9
      ureport2-core/src/main/java/com/bstek/ureport/build/assertor/EqualsAssertor.java
  8. 2
      ureport2-core/src/main/java/com/bstek/ureport/build/cell/CellBuilder.java
  9. 3
      ureport2-core/src/main/java/com/bstek/ureport/build/cell/NoneExpandBuilder.java
  10. 8
      ureport2-core/src/main/java/com/bstek/ureport/build/cell/down/DownExpandBuilder.java
  11. 7
      ureport2-core/src/main/java/com/bstek/ureport/build/cell/right/RightExpandBuilder.java
  12. 30
      ureport2-core/src/main/java/com/bstek/ureport/build/paging/BasePagination.java
  13. 63
      ureport2-core/src/main/java/com/bstek/ureport/build/paging/FitPagePagination.java
  14. 51
      ureport2-core/src/main/java/com/bstek/ureport/build/paging/FixRowsPagination.java
  15. 5
      ureport2-core/src/main/java/com/bstek/ureport/build/paging/Page.java
  16. 2
      ureport2-core/src/main/java/com/bstek/ureport/definition/Band.java
  17. 24
      ureport2-core/src/main/java/com/bstek/ureport/definition/CellDefinition.java
  18. 41
      ureport2-core/src/main/java/com/bstek/ureport/definition/ConditionPaging.java
  19. 10
      ureport2-core/src/main/java/com/bstek/ureport/definition/ConditionPropertyItem.java
  20. 24
      ureport2-core/src/main/java/com/bstek/ureport/definition/PagingPosition.java
  21. 21
      ureport2-core/src/main/java/com/bstek/ureport/definition/ReportDefinition.java
  22. 1
      ureport2-core/src/main/java/com/bstek/ureport/definition/RowDefinition.java
  23. 1
      ureport2-core/src/main/java/com/bstek/ureport/expression/model/Op.java
  24. 13
      ureport2-core/src/main/java/com/bstek/ureport/expression/model/expr/CellPositionExpression.java
  25. 48
      ureport2-core/src/main/java/com/bstek/ureport/model/Cell.java
  26. 41
      ureport2-core/src/main/java/com/bstek/ureport/model/Report.java
  27. 24
      ureport2-core/src/main/java/com/bstek/ureport/model/Row.java
  28. 8
      ureport2-core/src/main/java/com/bstek/ureport/parser/impl/CellParser.java
  29. 23
      ureport2-core/src/main/java/com/bstek/ureport/parser/impl/ConditionPagingParser.java
  30. 4
      ureport2-core/src/main/java/com/bstek/ureport/parser/impl/ConditionParameterItemParser.java
  31. 8
      ureport2-core/src/main/java/com/bstek/ureport/utils/DataUtils.java
  32. 16
      ureport2-core/src/main/resources/ureport2.xsd
  33. 28
      ureport2-js/src/table/ContextMenu.js
  34. 4
      ureport2-js/src/table/HeaderUtils.js

92
ureport2-console/src/main/resources/asserts/js/designer.bundle.js

File diff suppressed because one or more lines are too long

26
ureport2-console/src/main/resources/asserts/js/preview.bundle.js

File diff suppressed because one or more lines are too long

9
ureport2-core/src/main/java/com/bstek/ureport/build/Context.java

@ -47,6 +47,7 @@ public class Context {
private Map<String,Object> parameters;
private Map<String,List<Cell>> unprocessedCellsMap = new HashMap<String,List<Cell>>();
private Map<Row,Map<Column,Cell>> blankCellsMap=new HashMap<Row,Map<Column,Cell>>();
private Map<Row,Integer> fillBlankRowsMap=new HashMap<Row,Integer>();
public Context(ReportBuilder reportBuilder,Report report,Map<String,Dataset> datasetMap,ApplicationContext applicationContext,Map<String,Object> parameters) {
this.reportBuilder=reportBuilder;
@ -68,6 +69,14 @@ public class Context {
this.rootCell.setName("ROOT");
}
public void addFillBlankRow(Row row,int value){
fillBlankRowsMap.put(row, value);
}
public Map<Row, Integer> getFillBlankRowsMap() {
return fillBlankRowsMap;
}
public ReportBuilder getReportBuilder() {
return reportBuilder;
}

3
ureport2-core/src/main/java/com/bstek/ureport/build/DataCompute.java

@ -60,7 +60,8 @@ public class DataCompute {
Value value = cell.getValue();
ValueCompute valueCompute=valueComputesMap.get(value.getType().name());
if(valueCompute!=null){
return valueCompute.compute(cell, context);
List<BindData> list= valueCompute.compute(cell, context);
return list;
}
throw new ReportException("Unsupport value: "+value);
}

207
ureport2-core/src/main/java/com/bstek/ureport/build/ReportBuilder.java

@ -34,6 +34,8 @@ import com.bstek.ureport.build.cell.down.DownExpandBuilder;
import com.bstek.ureport.build.cell.right.RightExpandBuilder;
import com.bstek.ureport.build.paging.BasePagination;
import com.bstek.ureport.build.paging.Page;
import com.bstek.ureport.definition.Band;
import com.bstek.ureport.definition.CellStyle;
import com.bstek.ureport.definition.Expand;
import com.bstek.ureport.definition.Orientation;
import com.bstek.ureport.definition.PagingMode;
@ -78,6 +80,7 @@ public class ReportBuilder extends BasePagination implements ApplicationContextA
buildCell(context,cells);
cells = context.nextUnprocessedCells();
} while (cells != null);
doFillBlankRows(report,context);
recomputeCells(report,context);
long end=System.currentTimeMillis();
log.info("Report compute completed:"+(end-start)+"ms");
@ -95,11 +98,19 @@ public class ReportBuilder extends BasePagination implements ApplicationContextA
List<BindData> dataList=context.buildCellData(cell);
cell.setProcessed(true);
int size=dataList.size();
Cell lastCell=cell;
if(size==1){
noneExpandBuilder.buildCell(dataList, cell, context);
lastCell=noneExpandBuilder.buildCell(dataList, cell, context);
}else if(size>1){
CellBuilder cellBuilder=cellBuildersMap.get(cell.getExpand());
cellBuilder.buildCell(dataList,cell, context);
lastCell=cellBuilder.buildCell(dataList,cell, context);
}
if(lastCell.isFillBlankRows() && lastCell.getMultiple()>0){
int result=size % lastCell.getMultiple();
if(result>0){
int value=lastCell.getMultiple()-result;
context.addFillBlankRow(lastCell.getRow(), value);
}
}
}
}
@ -159,6 +170,69 @@ public class ReportBuilder extends BasePagination implements ApplicationContextA
return datasetMap;
}
private void doFillBlankRows(Report report,Context context){
List<Column> columns=report.getColumns();
Map<Row, Map<Column, Cell>> rowMap=report.getRowColCellMap();
Map<Row, Integer> map=context.getFillBlankRowsMap();
List<Row> newRowList=new ArrayList<Row>();
for(Row row:map.keySet()){
Map<Column,Cell> cellMap=rowMap.get(row);
int size=map.get(row);
for(int i=0;i<size;i++){
Row newRow=row.newRow();
newRow.setBand(null);
newRowList.add(newRow);
Map<Column,Cell> newCellMap=new HashMap<Column,Cell>();
rowMap.put(newRow, newCellMap);
for(Column col:columns){
Cell newCell=newBlankCell(cellMap, col,report);
newCell.setRow(newRow);
newRow.getCells().add(newCell);
newCellMap.put(col, newCell);
}
}
if(newRowList.size()>0){
int rowNumber=row.getRowNumber();
report.insertRows(rowNumber+1, newRowList);
newRowList.clear();
}
}
}
private Cell newBlankCell(Map<Column,Cell> cellMap,Column column,Report report){
if(cellMap!=null){
Cell cell=cellMap.get(column);
if(cell!=null){
Cell newCell=new Cell();
newCell.setData("");
newCell.setConditionPropertyItems(cell.getConditionPropertyItems());
report.addLazyCell(newCell);
newCell.setCellStyle(cell.getCellStyle());
newCell.setName(cell.getName());
newCell.setColumn(column);
column.getCells().add(newCell);
Cell leftParent=cell.getLeftParentCell();
if(leftParent!=null){
newCell.setLeftParentCell(leftParent);
leftParent.addRowChild(newCell);
}
Cell topParent=cell.getTopParentCell();
if(topParent!=null){
newCell.setTopParentCell(topParent);
topParent.addColumnChild(newCell);
}
return newCell;
}
}
Cell newCell=new Cell();
newCell.setData("");
newCell.setCellStyle(new CellStyle());
newCell.setName("");
newCell.setColumn(column);
column.getCells().add(newCell);
return newCell;
}
private void recomputeCells(Report report,Context context){
List<Cell> lazyCells=report.getLazyComputeCells();
for(Cell cell:lazyCells){
@ -171,26 +245,52 @@ public class ReportBuilder extends BasePagination implements ApplicationContextA
PagingMode pagingMode=paper.getPagingMode();
List<Row> headerRows=report.getHeaderRepeatRows();
List<Row> footerRows=report.getFooterRepeatRows();
List<Row> titleRows=report.getTitleRows();
List<Row> summaryRows=report.getSummaryRows();
List<Page> pages=new ArrayList<Page>();
List<Row> pageRows=new ArrayList<Row>();
int pageIndex=1;
List<Row> pageRepeatHeaders=new ArrayList<Row>();
List<Row> pageRepeatFooters=new ArrayList<Row>();
pageRepeatHeaders.addAll(headerRows);
pageRepeatFooters.addAll(footerRows);
if(pagingMode.equals(PagingMode.fitpage)){
int height=paper.getHeight()-paper.getBottomMargin()-paper.getTopMargin();
if(paper.getOrientation().equals(Orientation.landscape)){
height=paper.getWidth()-paper.getLeftMargin()-paper.getRightMargin();
}
int repeatRowHeight=0;
for(Row row:headerRows){
repeatRowHeight+=row.getRealHeight();
height=paper.getWidth()-paper.getBottomMargin()-paper.getTopMargin();
}
for(Row row:footerRows){
repeatRowHeight+=row.getRealHeight();
}
int rowHeight=repeatRowHeight;
int repeatHeaderRowHeight=report.getRepeatHeaderRowHeight(),repeatFooterRowHeight=report.getRepeatFooterRowHeight();
int rowHeight=repeatHeaderRowHeight+repeatFooterRowHeight;
for(int i=0;i<rowSize;i++){
Row row=rows.get(i);
int rowRealHeight=row.getRealHeight();
if(rowRealHeight>1 && row.getBand()==null){
Band band=row.getBand();
if(band!=null && rowRealHeight>0){
String rowKey=row.getRowKey();
int index=-1;
if(band.equals(Band.headerrepeat)){
for(int j=0;j<pageRepeatHeaders.size();j++){
Row headerRow=pageRepeatHeaders.get(j);
if(headerRow.getRowKey().equals(rowKey)){
index=j;
break;
}
}
pageRepeatHeaders.remove(index);
pageRepeatHeaders.add(index,row);
}else if(band.equals(Band.footerrepeat)){
for(int j=0;j<pageRepeatFooters.size();j++){
Row footerRow=pageRepeatFooters.get(j);
if(footerRow.getRowKey().equals(rowKey)){
index=j;
break;
}
}
pageRepeatFooters.remove(index);
pageRepeatFooters.add(index,row);
}
}
if(rowRealHeight>1 && band==null){
rowHeight+=rowRealHeight;
pageRows.add(row);
boolean overflow=false;
@ -200,47 +300,82 @@ public class ReportBuilder extends BasePagination implements ApplicationContextA
overflow=true;
}
}
if(!overflow && row.isPageBreak()){
overflow=true;
}
if(overflow){
Page newPage=buildPage(pageRows,headerRows,footerRows,pageIndex,report);
Page newPage=buildPage(pageRows,pageRepeatHeaders,pageRepeatFooters,titleRows,pageIndex,report);
pageIndex++;
pages.add(newPage);
rowHeight=repeatRowHeight;
rowHeight=repeatHeaderRowHeight+repeatFooterRowHeight;
pageRows=new ArrayList<Row>();
}
}
processRowColumn(report, i, row);
}
if(rowHeight>0){
Page newPage=buildPage(pageRows,headerRows,footerRows,pageIndex,report);
if(pageRows.size()>0){
Page newPage=buildPage(pageRows,pageRepeatHeaders,pageRepeatFooters,titleRows,pageIndex,report);
pages.add(newPage);
}
buildPageHeaderFooter(pages, report);
}else{
int fixRows=paper.getFixRows();
int fixRows=paper.getFixRows()-headerRows.size()-footerRows.size();
if(fixRows<0){
fixRows=1;
}
for(int i=0;i<rowSize;i++){
Row row=rows.get(i);
processRowColumn(report, i, row);
int height=row.getRealHeight();
if(height<1){
Band band=row.getBand();
if(band!=null && height>0){
String rowKey=row.getRowKey();
int index=-1;
if(band.equals(Band.headerrepeat)){
for(int j=0;j<pageRepeatHeaders.size();j++){
Row headerRow=pageRepeatHeaders.get(j);
if(headerRow.getRowKey().equals(rowKey)){
index=j;
break;
}
}
pageRepeatHeaders.remove(index);
pageRepeatHeaders.add(index,row);
}else if(band.equals(Band.footerrepeat)){
for(int j=0;j<pageRepeatFooters.size();j++){
Row footerRow=pageRepeatFooters.get(j);
if(footerRow.getRowKey().equals(rowKey)){
index=j;
break;
}
}
pageRepeatFooters.remove(index);
pageRepeatFooters.add(index,row);
}
if(index==-1){
throw new ReportComputeException("Invalid row["+band+"] with key "+rowKey+".");
}
}
if(height<1 || band!=null){
continue;
}
pageRows.add(row);
if((pageRows.size()+footerRows.size()) >= fixRows){
pageRows.addAll(footerRows);
Page newPage=buildPage(pageRows,headerRows,footerRows,pageIndex,report);
Page newPage=buildPage(pageRows,pageRepeatHeaders,pageRepeatFooters,titleRows,pageIndex,report);
pageIndex++;
pages.add(newPage);
pageRows=new ArrayList<Row>();
}
}
if(pageRows.size()>headerRows.size()){
if(pageRows.size()>0){
pageRows.addAll(footerRows);
Page newPage=buildPage(pageRows,headerRows,footerRows,pageIndex,report);
Page newPage=buildPage(pageRows,pageRepeatHeaders,pageRepeatFooters,titleRows,pageIndex,report);
pages.add(newPage);
}
buildPageHeaderFooter(pages, report);
}
buildSummaryRows(summaryRows, pages);
report.setPages(pages);
}
private void processRowColumn(Report report, int i, Row row) {
@ -326,32 +461,6 @@ public class ReportBuilder extends BasePagination implements ApplicationContextA
for(DatasourceProvider dp: datasourceProviders){
datasourceProviderMap.put(dp.getName(), dp);
}
StringBuilder sb=new StringBuilder();
sb.append("\n");
sb.append("`7MMF' `7MF'`7MM\"\"\"Mq. `7MM\"\"\"YMM `7MM\"\"\"Mq. .g8\"\"8q. `7MM\"\"\"Mq. MMP\"\"MM\"\"YMM ");
sb.append("\n");
sb.append(" MM M MM `MM. MM `7 MM `MM..dP' `YM. MM `MM. P' MM `7 ");
sb.append("\n");
sb.append(" MM M MM ,M9 MM d MM ,M9 dM' `MM MM ,M9 MM pd*\"*b. ");
sb.append("\n");
sb.append(" MM M MMmmdM9 MMmmMM MMmmdM9 MM MM MMmmdM9 MM (O) j8 ");
sb.append("\n");
sb.append(" MM M MM YM. MM Y , MM MM. ,MP MM YM. MM ,;j9 ");
sb.append("\n");
sb.append(" YM. ,M MM `Mb. MM ,M MM `Mb. ,dP' MM `Mb. MM ,-=' ");
sb.append("\n");
sb.append(" `bmmmmd\"' .JMML. .JMM..JMMmmmmMMM .JMML. `\"bmmd\"' .JMML. .JMM. .JMML. Ammmmmmm ");
sb.append("\n");
sb.append(".....................................................................................................");
sb.append("\n");
sb.append(". uReport, is a Chinese style report engine");
sb.append(" licensed under the Apache License 2.0, .");
sb.append("\n");
sb.append(". which is opensource, free of charge, easy to use,");
sb.append("high-performance, with browser-based-designer. .");
sb.append("\n");
sb.append(".....................................................................................................");
sb.append("\n");
System.out.println(sb.toString());
new Splash().doPrint();
}
}

37
ureport2-core/src/main/java/com/bstek/ureport/build/Splash.java

@ -0,0 +1,37 @@
package com.bstek.ureport.build;
/**
* @author Jacky.gao
* @since 2017年6月19日
*/
public class Splash {
public void doPrint(){
StringBuilder sb=new StringBuilder();
sb.append("\n");
sb.append("`7MMF' `7MF'`7MM\"\"\"Mq. `7MM\"\"\"YMM `7MM\"\"\"Mq. .g8\"\"8q. `7MM\"\"\"Mq. MMP\"\"MM\"\"YMM ");
sb.append("\n");
sb.append(" MM M MM `MM. MM `7 MM `MM..dP' `YM. MM `MM. P' MM `7 ");
sb.append("\n");
sb.append(" MM M MM ,M9 MM d MM ,M9 dM' `MM MM ,M9 MM pd*\"*b. ");
sb.append("\n");
sb.append(" MM M MMmmdM9 MMmmMM MMmmdM9 MM MM MMmmdM9 MM (O) j8 ");
sb.append("\n");
sb.append(" MM M MM YM. MM Y , MM MM. ,MP MM YM. MM ,;j9 ");
sb.append("\n");
sb.append(" YM. ,M MM `Mb. MM ,M MM `Mb. ,dP' MM `Mb. MM ,-=' ");
sb.append("\n");
sb.append(" `bmmmmd\"' .JMML. .JMM..JMMmmmmMMM .JMML. `\"bmmd\"' .JMML. .JMM. .JMML. Ammmmmmm ");
sb.append("\n");
sb.append(".....................................................................................................");
sb.append("\n");
sb.append(". uReport, is a Chinese style report engine");
sb.append(" licensed under the Apache License 2.0, .");
sb.append("\n");
sb.append(". which is opensource, free of charge, easy to use,");
sb.append("high-performance, with browser-based-designer. .");
sb.append("\n");
sb.append(".....................................................................................................");
sb.append("\n");
System.out.println(sb.toString());
}
}

9
ureport2-core/src/main/java/com/bstek/ureport/build/assertor/EqualsAssertor.java

@ -15,6 +15,8 @@
******************************************************************************/
package com.bstek.ureport.build.assertor;
import java.util.List;
/**
* @author Jacky.gao
@ -35,6 +37,13 @@ public class EqualsAssertor implements Assertor {
Number r=(Number)right;
return l.doubleValue()==r.doubleValue();
}
if(right instanceof List){
List<?> rightList=(List<?>)right;
if(rightList.size()==1){
Object rightObj=rightList.get(0);
return left.equals(rightObj);
}
}
return left.equals(right);
}
}

2
ureport2-core/src/main/java/com/bstek/ureport/build/cell/CellBuilder.java

@ -26,5 +26,5 @@ import com.bstek.ureport.model.Cell;
* @since 2016年11月1日
*/
public interface CellBuilder {
void buildCell(List<BindData> dataList, Cell cell, Context context);
Cell buildCell(List<BindData> dataList, Cell cell, Context context);
}

3
ureport2-core/src/main/java/com/bstek/ureport/build/cell/NoneExpandBuilder.java

@ -29,7 +29,7 @@ import com.bstek.ureport.model.Cell;
public class NoneExpandBuilder implements CellBuilder {
@Override
public void buildCell(List<BindData> dataList, Cell cell, Context context) {
public Cell buildCell(List<BindData> dataList, Cell cell, Context context) {
Object obj=null;
List<Object> bindData=null;
for(BindData data:dataList){
@ -49,5 +49,6 @@ public class NoneExpandBuilder implements CellBuilder {
cell.doFormat();
cell.doDataWrapCompute(context);
}
return cell;
}
}

8
ureport2-core/src/main/java/com/bstek/ureport/build/cell/down/DownExpandBuilder.java

@ -34,7 +34,7 @@ import com.bstek.ureport.model.Row;
*/
public class DownExpandBuilder extends ExpandBuilder {
@Override
public void buildCell(List<BindData> dataList, Cell cell, Context context) {
public Cell buildCell(List<BindData> dataList, Cell cell, Context context) {
Range duplicateRange=cell.getDuplicateRange();
int mainCellRowNumber=cell.getRow().getRowNumber();
Range rowRange = buildRowRange(mainCellRowNumber,duplicateRange);
@ -44,7 +44,7 @@ public class DownExpandBuilder extends ExpandBuilder {
int rowSize=rowRange.getEnd()-rowRange.getStart()+1;
DownBlankCellApply downBlankCellApply=new DownBlankCellApply(rowSize,cell,context,downDuplocatorWrapper);
CellDownDuplicateUnit unit=new CellDownDuplicateUnit(context,downDuplocatorWrapper,cell,mainCellRowNumber,rowSize);
Cell lastCell=cell;
int dataSize=dataList.size();
for (int i = 0; i < dataSize; i++) {
BindData bindData = dataList.get(i);
@ -76,9 +76,11 @@ public class DownExpandBuilder extends ExpandBuilder {
if(topParentCell!=null){
topParentCell.addColumnChild(newCell);
}
unit.duplicate(newCell,i);
unit.duplicate(newCell,i);
lastCell=newCell;
}
unit.complete();
return lastCell;
}
private Range buildRowRange(int mainCellRowNumber,Range range){

7
ureport2-core/src/main/java/com/bstek/ureport/build/cell/right/RightExpandBuilder.java

@ -34,7 +34,7 @@ import com.bstek.ureport.model.Column;
*/
public class RightExpandBuilder extends ExpandBuilder {
@Override
public void buildCell(List<BindData> dataList, Cell cell, Context context) {
public Cell buildCell(List<BindData> dataList, Cell cell, Context context) {
Range duplicateRange=cell.getDuplicateRange();
int mainCellColNumber=cell.getColumn().getColumnNumber();
Range colRange = buildColRange(cell,duplicateRange,mainCellColNumber);
@ -42,6 +42,7 @@ public class RightExpandBuilder extends ExpandBuilder {
int colSize=colRange.getEnd()-colRange.getStart()+1;
RightBlankCellApply rightBlankCellApply=new RightBlankCellApply(colSize,cell,context,rightDuplocatorWrapper);
CellRightDuplicateUnit unit=new CellRightDuplicateUnit(context,rightDuplocatorWrapper,cell,mainCellColNumber,colSize);
Cell lastCell=cell;
for (int i = 0; i < dataList.size(); i++) {
BindData bindData = dataList.get(i);
if (i == 0) {
@ -72,9 +73,11 @@ public class RightExpandBuilder extends ExpandBuilder {
if(leftParentCell!=null){
leftParentCell.addRowChild(newCell);
}
unit.duplicate(newCell,i);
unit.duplicate(newCell,i);
lastCell=newCell;
}
unit.complete();
return lastCell;
}
private Range buildColRange(Cell cell,Range range,int mainCellColNumber){

30
ureport2-core/src/main/java/com/bstek/ureport/build/paging/BasePagination.java

@ -33,8 +33,16 @@ import com.bstek.ureport.model.Row;
* @since 2017年1月17日
*/
public abstract class BasePagination {
protected Page buildPage(List<Row> rows,List<Row> headerRows,List<Row> footerRows,int pageIndex,Report report){
protected void buildSummaryRows(List<Row> summaryRows,List<Page> pages){
Page lastPage=pages.get(pages.size()-1);
List<Row> lastPageRows=lastPage.getRows();
int summaryRowSize=summaryRows.size()-1;
for(int i=summaryRowSize;i>-1;i--){
Row row=summaryRows.get(i);
lastPageRows.add(row);
}
}
protected Page buildPage(List<Row> rows,List<Row> headerRows,List<Row> footerRows,List<Row> titleRows,int pageIndex,Report report){
int rowSize=rows.size();
Row lastRow=rows.get(rowSize-1);
int lastRowNumber=lastRow.getRowNumber();
@ -117,6 +125,24 @@ public abstract class BasePagination {
buildExistPageFunctionCell(context, cell);
}
}
if(pageIndex==1){
int titleRowSize=titleRows.size()-1;
for(int i=titleRowSize;i>-1;i--){
Row row=titleRows.get(i);
rows.add(0,row);
Map<Column,Cell> colMap=rowColCellsMap.get(row);
if(colMap==null){
continue;
}
for(Column col:columns){
Cell cell=colMap.get(col);
if(cell==null){
continue;
}
buildExistPageFunctionCell(context, cell);
}
}
}
for(Row row:footerRows){
Row newRow=duplicateRepeateRow(row, context);
rows.add(newRow);

63
ureport2-core/src/main/java/com/bstek/ureport/build/paging/FitPagePagination.java

@ -18,8 +18,10 @@ package com.bstek.ureport.build.paging;
import java.util.ArrayList;
import java.util.List;
import com.bstek.ureport.definition.Band;
import com.bstek.ureport.definition.Orientation;
import com.bstek.ureport.definition.Paper;
import com.bstek.ureport.exception.ReportComputeException;
import com.bstek.ureport.model.Report;
import com.bstek.ureport.model.Row;
@ -33,28 +35,57 @@ public class FitPagePagination extends BasePagination implements Pagination {
Paper paper=report.getPaper();
int height=paper.getHeight()-paper.getBottomMargin()-paper.getTopMargin();
if(paper.getOrientation().equals(Orientation.landscape)){
height=paper.getWidth()-paper.getLeftMargin()-paper.getRightMargin();
height=paper.getWidth()-paper.getBottomMargin()-paper.getTopMargin();
}
List<Row> rows=report.getRows();
List<Row> headerRows=report.getHeaderRepeatRows();
List<Row> footerRows=report.getFooterRepeatRows();
int repeatRowHeight=0;
for(Row row:headerRows){
repeatRowHeight+=row.getRealHeight();
}
for(Row row:footerRows){
repeatRowHeight+=row.getRealHeight();
}
int rowHeight=repeatRowHeight;
List<Row> titleRows=report.getTitleRows();
List<Row> summaryRows=report.getSummaryRows();
int repeatHeaderRowHeight=report.getRepeatHeaderRowHeight(),repeatFooterRowHeight=report.getRepeatFooterRowHeight();
int rowHeight=repeatHeaderRowHeight+repeatFooterRowHeight;
List<Page> pages=new ArrayList<Page>();
List<Row> pageRows=new ArrayList<Row>();
List<Row> pageRepeatHeaders=new ArrayList<Row>();
List<Row> pageRepeatFooters=new ArrayList<Row>();
pageRepeatHeaders.addAll(headerRows);
pageRepeatFooters.addAll(footerRows);
int i=0;
int rowSize=rows.size();
Row row=rows.get(i);
int pageIndex=1;
while(row!=null){
int rowRealHeight=row.getRealHeight();
if(rowRealHeight>1 && row.getBand()==null){
Band band=row.getBand();
if(band!=null && rowRealHeight>0){
String rowKey=row.getRowKey();
int index=-1;
if(band.equals(Band.headerrepeat)){
for(int j=0;j<pageRepeatHeaders.size();j++){
Row headerRow=pageRepeatHeaders.get(j);
if(headerRow.getRowKey().equals(rowKey)){
index=j;
break;
}
}
pageRepeatHeaders.remove(index);
pageRepeatHeaders.add(index,row);
}else if(band.equals(Band.footerrepeat)){
for(int j=0;j<pageRepeatFooters.size();j++){
Row footerRow=pageRepeatFooters.get(j);
if(footerRow.getRowKey().equals(rowKey)){
index=j;
break;
}
}
pageRepeatFooters.remove(index);
pageRepeatFooters.add(index,row);
}
if(index==-1){
throw new ReportComputeException("Invalid row["+band+"] with key "+rowKey+".");
}
}
if(rowRealHeight>1 && band==null){
rowHeight+=rowRealHeight;
pageRows.add(row);
boolean overflow=false;
@ -64,11 +95,14 @@ public class FitPagePagination extends BasePagination implements Pagination {
overflow=true;
}
}
if(!overflow && row.isPageBreak()){
overflow=true;
}
if(overflow){
Page newPage=buildPage(pageRows,headerRows,footerRows,pageIndex,report);
Page newPage=buildPage(pageRows,pageRepeatHeaders,pageRepeatFooters,titleRows,pageIndex,report);
pageIndex++;
pages.add(newPage);
rowHeight=repeatRowHeight;
rowHeight=repeatHeaderRowHeight+repeatFooterRowHeight;
pageRows=new ArrayList<Row>();
}
}
@ -79,11 +113,12 @@ public class FitPagePagination extends BasePagination implements Pagination {
row=null;
}
}
if(rowHeight>0){
Page newPage=buildPage(pageRows,headerRows,footerRows,pageIndex,report);
if(pageRows.size()>0){
Page newPage=buildPage(pageRows,pageRepeatHeaders,pageRepeatFooters,titleRows,pageIndex,report);
pages.add(newPage);
}
buildPageHeaderFooter(pages, report);
buildSummaryRows(summaryRows, pages);
return pages;
}
}

51
ureport2-core/src/main/java/com/bstek/ureport/build/paging/FixRowsPagination.java

@ -18,7 +18,9 @@ package com.bstek.ureport.build.paging;
import java.util.ArrayList;
import java.util.List;
import com.bstek.ureport.definition.Band;
import com.bstek.ureport.definition.Paper;
import com.bstek.ureport.exception.ReportComputeException;
import com.bstek.ureport.model.Report;
import com.bstek.ureport.model.Row;
@ -30,34 +32,73 @@ public class FixRowsPagination extends BasePagination implements Pagination {
@Override
public List<Page> doPaging(Report report) {
Paper paper=report.getPaper();
int fixRows=paper.getFixRows();
List<Row> rows=report.getRows();
List<Row> headerRows=report.getHeaderRepeatRows();
List<Row> footerRows=report.getFooterRepeatRows();
List<Row> titleRows=report.getTitleRows();
List<Row> summaryRows=report.getSummaryRows();
int fixRows=paper.getFixRows()-headerRows.size()-footerRows.size();
if(fixRows<0){
fixRows=1;
}
List<Row> pageRepeatHeaders=new ArrayList<Row>();
List<Row> pageRepeatFooters=new ArrayList<Row>();
pageRepeatHeaders.addAll(headerRows);
pageRepeatFooters.addAll(footerRows);
List<Page> pages=new ArrayList<Page>();
List<Row> pageRows=new ArrayList<Row>();
int pageIndex=1;
for(Row row:rows){
int height=row.getRealHeight();
if(height<1){
Band band=row.getBand();
if(band!=null && height>0){
String rowKey=row.getRowKey();
int index=-1;
if(band.equals(Band.headerrepeat)){
for(int j=0;j<pageRepeatHeaders.size();j++){
Row headerRow=pageRepeatHeaders.get(j);
if(headerRow.getRowKey().equals(rowKey)){
index=j;
break;
}
}
pageRepeatHeaders.remove(index);
pageRepeatHeaders.add(index,row);
}else if(band.equals(Band.footerrepeat)){
for(int j=0;j<pageRepeatFooters.size();j++){
Row footerRow=pageRepeatFooters.get(j);
if(footerRow.getRowKey().equals(rowKey)){
index=j;
break;
}
}
pageRepeatFooters.remove(index);
pageRepeatFooters.add(index,row);
}
if(index==-1){
throw new ReportComputeException("Invalid row["+band+"] with key "+rowKey+".");
}
}
if(height<1 && row.getBand()!=null){
continue;
}
pageRows.add(row);
if((pageRows.size()+footerRows.size()) >= fixRows){
pageRows.addAll(footerRows);
Page newPage=buildPage(pageRows,headerRows,footerRows,pageIndex,report);
Page newPage=buildPage(pageRows,pageRepeatHeaders,pageRepeatFooters,titleRows,pageIndex,report);
pageIndex++;
pages.add(newPage);
pageRows=new ArrayList<Row>();
}
}
if(pageRows.size()>headerRows.size()){
if(pageRows.size()>0){
pageRows.addAll(footerRows);
Page newPage=buildPage(pageRows,headerRows,footerRows,pageIndex,report);
Page newPage=buildPage(pageRows,pageRepeatHeaders,pageRepeatFooters,titleRows,pageIndex,report);
pageIndex++;
pages.add(newPage);
}
buildPageHeaderFooter(pages, report);
buildSummaryRows(summaryRows, pages);
return pages;
}
}

5
ureport2-core/src/main/java/com/bstek/ureport/build/paging/Page.java

@ -25,20 +25,15 @@ import com.bstek.ureport.model.Row;
* @since 2017年1月17日
*/
public class Page {
// private Map<Row,Map<Column,Cell>> rowColCellMap;
private List<Row> rows;
private List<Column> columns;
private HeaderFooter header;
private HeaderFooter footer;
public Page(List<Row> rows,List<Column> columns) {
// this.rowColCellMap = rowColCellMap;
this.rows = rows;
this.columns=columns;
}
/*public Map<Row, Map<Column, Cell>> getRowColCellMap() {
return rowColCellMap;
}*/
public List<Row> getRows() {
return rows;
}

2
ureport2-core/src/main/java/com/bstek/ureport/definition/Band.java

@ -20,5 +20,5 @@ package com.bstek.ureport.definition;
* @since 2017年1月16日
*/
public enum Band {
headerrepeat,footerrepeat
headerrepeat,footerrepeat,title,summary
}

24
ureport2-core/src/main/java/com/bstek/ureport/definition/CellDefinition.java

@ -44,6 +44,12 @@ public class CellDefinition {
private String linkTargetWindow;
private List<LinkParameter> linkParameters;
private boolean fillBlankRows;
/**
* 允许填充空白行时fillBlankRows=true要求当前数据行数必须是multiple定义的行数的倍数否则就补充空白行
*/
private int multiple;
private Expand expand=Expand.None;
@JsonIgnore
@ -102,6 +108,8 @@ public class CellDefinition {
cell.setLinkTargetWindow(linkTargetWindow);
cell.setLinkUrl(linkUrl);
cell.setConditionPropertyItems(conditionPropertyItems);
cell.setFillBlankRows(fillBlankRows);
cell.setMultiple(multiple);
return cell;
}
@ -197,6 +205,22 @@ public class CellDefinition {
return cellStyle;
}
public boolean isFillBlankRows() {
return fillBlankRows;
}
public void setFillBlankRows(boolean fillBlankRows) {
this.fillBlankRows = fillBlankRows;
}
public int getMultiple() {
return multiple;
}
public void setMultiple(int multiple) {
this.multiple = multiple;
}
public Range getDuplicateRange() {
return duplicateRange;
}

41
ureport2-core/src/main/java/com/bstek/ureport/definition/ConditionPaging.java

@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright 2017 Bstek
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
package com.bstek.ureport.definition;
/**
* @author Jacky.gao
* @since 2017年6月19日
*/
public class ConditionPaging {
private PagingPosition position;
/**
* 当position为after时line用来指定当前行后多少行进行分页
*/
private int line;
public PagingPosition getPosition() {
return position;
}
public void setPosition(PagingPosition position) {
this.position = position;
}
public int getLine() {
return line;
}
public void setLine(int line) {
this.line = line;
}
}

10
ureport2-core/src/main/java/com/bstek/ureport/definition/ConditionPropertyItem.java

@ -46,6 +46,8 @@ public class ConditionPropertyItem {
private ConditionCellStyle cellStyle;
private ConditionPaging paging;
@JsonIgnore
private Expression expression;
@ -146,4 +148,12 @@ public class ConditionPropertyItem {
public void setColWidth(int colWidth) {
this.colWidth = colWidth;
}
public ConditionPaging getPaging() {
return paging;
}
public void setPaging(ConditionPaging paging) {
this.paging = paging;
}
}

24
ureport2-core/src/main/java/com/bstek/ureport/definition/PagingPosition.java

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright 2017 Bstek
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/
package com.bstek.ureport.definition;
/**
* @author Jacky.gao
* @since 2017年6月19日
*/
public enum PagingPosition {
before,after;
}

21
ureport2-core/src/main/java/com/bstek/ureport/definition/ReportDefinition.java

@ -57,11 +57,32 @@ public class ReportDefinition {
report.setRows(reportRows);
report.setColumns(reportColumns);
Map<Integer,Row> rowMap=new HashMap<Integer,Row>();
int headerRowsHeight=0,footerRowsHeight=0,titleRowsHeight=0,summaryRowsHeight=0;
for (RowDefinition rowDef : rows) {
Row newRow=rowDef.newRow(reportRows);
report.insertRow(newRow, rowDef.getRowNumber());
rowMap.put(rowDef.getRowNumber(), newRow);
Band band=rowDef.getBand();
if(band!=null){
if(band.equals(Band.headerrepeat)){
report.getHeaderRepeatRows().add(newRow);
headerRowsHeight+=newRow.getRealHeight();
}else if(band.equals(Band.footerrepeat)){
report.getFooterRepeatRows().add(newRow);
footerRowsHeight+=newRow.getRealHeight();
}else if(band.equals(Band.title)){
report.getTitleRows().add(newRow);
titleRowsHeight+=newRow.getRealHeight();
}else if(band.equals(Band.summary)){
report.getSummaryRows().add(newRow);
summaryRowsHeight+=newRow.getRealHeight();
}
}
}
report.setRepeatHeaderRowHeight(headerRowsHeight);
report.setRepeatFooterRowHeight(footerRowsHeight);
report.setTitleRowsHeight(titleRowsHeight);
report.setSummaryRowsHeight(summaryRowsHeight);
Map<Integer,Column> columnMap=new HashMap<Integer,Column>();
for (ColumnDefinition columnDef : columns) {
Column newColumn=columnDef.newColumn(reportColumns);

1
ureport2-core/src/main/java/com/bstek/ureport/definition/RowDefinition.java

@ -31,6 +31,7 @@ public class RowDefinition implements Comparable<RowDefinition>{
Row row=new Row(rows);
row.setHeight(height);
row.setBand(band);
row.setRowKey("r"+rowNumber);
return row;
}

1
ureport2-core/src/main/java/com/bstek/ureport/expression/model/Op.java

@ -24,6 +24,7 @@ import com.bstek.ureport.exception.ReportParseException;
public enum Op {
GreatThen,EqualsGreatThen,LessThen,EqualsLessThen,Equals,NotEquals,In,NotIn,Like;
public static Op parse(String op){
op=op.trim();
if(op.equals(">")){
return GreatThen;
}else if(op.equals(">=")){

13
ureport2-core/src/main/java/com/bstek/ureport/expression/model/expr/CellPositionExpression.java

@ -54,7 +54,7 @@ public class CellPositionExpression extends CellExpression {
int rowNumber=cell.getRow().getRowNumber(),colNumber=cell.getColumn().getColumnNumber();
for(int i=0;i<targetCells.size();i++){
Cell target=targetCells.get(i);
if(target.getRow()==cell.getRow() || target.getColumn()==cell.getColumn()){
if(target.getRow()==cell.getRow()){
index=i;
break;
}
@ -67,6 +67,17 @@ public class CellPositionExpression extends CellExpression {
break;
}
}
}
if(index>-1){
index++;
return new ObjectExpressionData(index);
}
for(int i=0;i<targetCells.size();i++){
Cell target=targetCells.get(i);
if(target.getColumn()==cell.getColumn()){
index=i;
break;
}
int colSpan=target.getColSpan();
if(colSpan>0){
int targetColStart=target.getColumn().getColumnNumber();

48
ureport2-core/src/main/java/com/bstek/ureport/model/Cell.java

@ -41,9 +41,11 @@ import com.bstek.ureport.definition.BlankCellInfo;
import com.bstek.ureport.definition.Border;
import com.bstek.ureport.definition.CellStyle;
import com.bstek.ureport.definition.ConditionCellStyle;
import com.bstek.ureport.definition.ConditionPaging;
import com.bstek.ureport.definition.ConditionPropertyItem;
import com.bstek.ureport.definition.Expand;
import com.bstek.ureport.definition.LinkParameter;
import com.bstek.ureport.definition.PagingPosition;
import com.bstek.ureport.definition.Scope;
import com.bstek.ureport.definition.value.SimpleValue;
import com.bstek.ureport.definition.value.Value;
@ -95,6 +97,12 @@ public class Cell implements ReportCell {
private List<ConditionPropertyItem> conditionPropertyItems;
private boolean fillBlankRows;
/**
* 允许填充空白行时fillBlankRows=true要求当前数据行数必须是multiple定义的行数的倍数否则就补充空白行
*/
private int multiple;
/**
* 当前单元格左父格
*/
@ -180,6 +188,8 @@ public class Cell implements ReportCell {
cell.setLinkUrl(linkUrl);
cell.setPageRowSpan(pageRowSpan);
cell.setConditionPropertyItems(conditionPropertyItems);
cell.setFillBlankRows(fillBlankRows);
cell.setMultiple(multiple);
return cell;
}
@ -269,6 +279,28 @@ public class Cell implements ReportCell {
if(!condition.filter(this, this, obj, context)){
continue;
}
ConditionPaging paging=item.getPaging();
if(paging!=null){
PagingPosition position=paging.getPosition();
if(position!=null){
if(position.equals(PagingPosition.after)){
int line=paging.getLine();
if(line==0){
row.setPageBreak(true);
}else{
int rowNumber=row.getRowNumber()+line;
Row targetRow=context.getRow(rowNumber);
targetRow.setPageBreak(true);
}
}else{
int rowNumber=row.getRowNumber()-1;
Row targetRow=context.getRow(rowNumber);
targetRow.setPageBreak(true);
}
}
}
int rowHeight=item.getRowHeight();
if(rowHeight>-1){
row.setRealHeight(rowHeight);
@ -846,6 +878,22 @@ public class Cell implements ReportCell {
}
return sb.toString();
}
public boolean isFillBlankRows() {
return fillBlankRows;
}
public void setFillBlankRows(boolean fillBlankRows) {
this.fillBlankRows = fillBlankRows;
}
public int getMultiple() {
return multiple;
}
public void setMultiple(int multiple) {
this.multiple = multiple;
}
private String buildExpression(Context context, String name, Expression expr) {
ExpressionData<?> exprData=expr.execute(this,this,context);

41
ureport2-core/src/main/java/com/bstek/ureport/model/Report.java

@ -41,6 +41,9 @@ public class Report {
private List<Row> rows;
private List<Row> headerRepeatRows=new ArrayList<Row>();
private List<Row> footerRepeatRows=new ArrayList<Row>();
private List<Row> titleRows=new ArrayList<Row>();
private List<Row> summaryRows=new ArrayList<Row>();
private int repeatHeaderRowHeight=0,repeatFooterRowHeight=0,titleRowsHeight=0,summaryRowsHeight=0;
private List<Column> columns;
private List<Page> pages;
private String reportFullName;
@ -54,11 +57,6 @@ public class Report {
if(band==null){
return;
}
if(band.equals(Band.headerrepeat)){
headerRepeatRows.add(row);
}else if(band.equals(Band.footerrepeat)){
footerRepeatRows.add(row);
}
}
public void insertRows(int firstRowIndex,List<Row> insertRows){
int pos=firstRowIndex-1;
@ -117,7 +115,7 @@ public class Report {
return addLazyCell(cell);
}
private boolean addLazyCell(Cell cell){
public boolean addLazyCell(Cell cell){
List<ConditionPropertyItem> conditionPropertyItems=cell.getConditionPropertyItems();
if(conditionPropertyItems!=null && conditionPropertyItems.size()>0){
lazyComputeCells.add(cell);
@ -198,6 +196,37 @@ public class Report {
public void setFooterRepeatRows(List<Row> footerRepeatRows) {
this.footerRepeatRows = footerRepeatRows;
}
public List<Row> getTitleRows() {
return titleRows;
}
public List<Row> getSummaryRows() {
return summaryRows;
}
public int getRepeatHeaderRowHeight() {
return repeatHeaderRowHeight;
}
public void setRepeatHeaderRowHeight(int repeatHeaderRowHeight) {
this.repeatHeaderRowHeight = repeatHeaderRowHeight;
}
public int getRepeatFooterRowHeight() {
return repeatFooterRowHeight;
}
public void setRepeatFooterRowHeight(int repeatFooterRowHeight) {
this.repeatFooterRowHeight = repeatFooterRowHeight;
}
public int getTitleRowsHeight() {
return titleRowsHeight;
}
public void setTitleRowsHeight(int titleRowsHeight) {
this.titleRowsHeight = titleRowsHeight;
}
public int getSummaryRowsHeight() {
return summaryRowsHeight;
}
public void setSummaryRowsHeight(int summaryRowsHeight) {
this.summaryRowsHeight = summaryRowsHeight;
}
public HeaderFooterDefinition getHeader() {
return header;
}

24
ureport2-core/src/main/java/com/bstek/ureport/model/Row.java

@ -27,13 +27,15 @@ import com.bstek.ureport.definition.Band;
public class Row extends Line{
private int height;
private int realHeight=-1;
private String rowKey;
/**
* 一个用来临时存放当前行号的属性只在构建报表时创建新行时使用
*/
private int tempRowNumber;
private Band band;
private boolean forPaging;
private boolean pageBreak;
private List<Row> rows;
public Row(List<Row> rows) {
@ -44,9 +46,19 @@ public class Row extends Line{
Row row=new Row(rows);
row.setHeight(height);
row.setRealHeight(realHeight);
row.setBand(band);
row.setRowKey(rowKey);
return row;
}
public String getRowKey() {
return rowKey;
}
public void setRowKey(String rowKey) {
this.rowKey = rowKey;
}
public int getRowNumber() {
return rows.indexOf(this)+1;
}
@ -71,6 +83,14 @@ public class Row extends Line{
this.forPaging = forPaging;
}
public boolean isPageBreak() {
return pageBreak;
}
public void setPageBreak(boolean pageBreak) {
this.pageBreak = pageBreak;
}
public int getTempRowNumber() {
return tempRowNumber;
}

8
ureport2-core/src/main/java/com/bstek/ureport/parser/impl/CellParser.java

@ -76,6 +76,14 @@ public class CellParser implements Parser<CellDefinition>{
if(StringUtils.isNotBlank(expand)){
cell.setExpand(Expand.valueOf(expand));
}
String fillBlankRows=element.attributeValue("fill-blank-rows");
if(StringUtils.isNotBlank(fillBlankRows)){
cell.setFillBlankRows(Boolean.valueOf(fillBlankRows));
String multiple=element.attributeValue("multiple");
if(StringUtils.isNotBlank(multiple)){
cell.setMultiple(Integer.valueOf(multiple));
}
}
cell.setLinkTargetWindow(element.attributeValue("link-target-window"));
cell.setLinkUrl(element.attributeValue("link-url"));
List<LinkParameter> linkParameters=null;

23
ureport2-core/src/main/java/com/bstek/ureport/parser/impl/ConditionPagingParser.java

@ -0,0 +1,23 @@
package com.bstek.ureport.parser.impl;
import org.dom4j.Element;
import com.bstek.ureport.definition.ConditionPaging;
import com.bstek.ureport.definition.PagingPosition;
import com.bstek.ureport.parser.Parser;
/**
* @author Jacky.gao
* @since 2017年6月21日
*/
public class ConditionPagingParser implements Parser<ConditionPaging> {
@Override
public ConditionPaging parse(Element element) {
ConditionPaging paging=new ConditionPaging();
String position=element.attributeValue("position");
paging.setPosition(PagingPosition.valueOf(position));
String line=element.attributeValue("line");
paging.setLine(Integer.valueOf(line));
return paging;
}
}

4
ureport2-core/src/main/java/com/bstek/ureport/parser/impl/ConditionParameterItemParser.java

@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
import org.dom4j.Element;
import com.bstek.ureport.definition.ConditionCellStyle;
import com.bstek.ureport.definition.ConditionPaging;
import com.bstek.ureport.definition.ConditionPropertyItem;
import com.bstek.ureport.definition.LinkParameter;
import com.bstek.ureport.expression.ExpressionUtils;
@ -45,6 +46,7 @@ public class ConditionParameterItemParser implements Parser<ConditionPropertyIte
public ConditionParameterItemParser() {
parsers.put("cell-style",new CellStyleParser());
parsers.put("link-parameter",new LinkParameterParser());
parsers.put("paging",new ConditionPagingParser());
}
@Override
public ConditionPropertyItem parse(Element element) {
@ -93,6 +95,8 @@ public class ConditionParameterItemParser implements Parser<ConditionPropertyIte
parameters=new ArrayList<LinkParameter>();
}
parameters.add((LinkParameter)data);
}else if(data instanceof ConditionPaging){
item.setPaging((ConditionPaging)data);
}
}
item.setCondition(topCondition);

8
ureport2-core/src/main/java/com/bstek/ureport/utils/DataUtils.java

@ -69,7 +69,7 @@ public class DataUtils {
}else{
list=leftList;
data=topCell.getData();
Value value=leftCell.getValue();
Value value=topCell.getValue();
DatasetExpression de=fetchDatasetExpression(value);
if(de==null){
throw new ReportComputeException("Unsupport value : "+value);
@ -79,7 +79,11 @@ public class DataUtils {
List<Object> result=new ArrayList<Object>();
for(Object obj:list){
Object o=Utils.getProperty(obj, prop);
if(o==data){
if((o==null && data==null)){
result.add(obj);
}else if(o!=null && o.equals(data)){
result.add(obj);
}else if(data!=null && data.equals(o)){
result.add(obj);
}
}

16
ureport2-core/src/main/resources/ureport2.xsd

@ -144,6 +144,9 @@
</simpleType>
</attribute>
<attribute name="fill-blank-rows" type="boolean" use="optional"></attribute>
<attribute name="multiple" type="int" use="optional"></attribute>
<attribute name="link-url" type="string" use="optional"></attribute>
<attribute name="link-target-window" use="optional">
<simpleType>
@ -161,6 +164,7 @@
<element name="link-parameter" type="tns:link-parameter" maxOccurs="unbounded" minOccurs="0"></element>
<element name="cell-style" type="tns:cell-style" maxOccurs="1" minOccurs="0"></element>
<element name="expr" type="tns:text" minOccurs="0" maxOccurs="1"></element>
<element name="paging" type="tns:condition-paging" maxOccurs="1" minOccurs="0"></element>
</sequence>
<attribute name="name" type="string" use="required"></attribute>
<attribute name="row-height" type="int" use="optional"></attribute>
@ -185,6 +189,18 @@
</attribute>
</complexType>
<complexType name="condition-paging">
<attribute name="line" type="int"></attribute>
<attribute name="position">
<simpleType>
<restriction base="string">
<enumeration value="beofore"></enumeration>
<enumeration value="after"></enumeration>
</restriction>
</simpleType>
</attribute>
</complexType>
<complexType name="cell-style">
<sequence>
<element name="left-border" type="tns:border" minOccurs="0" maxOccurs="1"></element>

28
ureport2-js/src/table/ContextMenu.js

@ -70,6 +70,15 @@ export const contextMenuConfigure={
}
renderRowHeader(this,context);
setDirty();
}else if(key==='title_row'){
const selected=this.getSelected();
const startRow=selected[0],endRow=selected[2];
const context=this.context;
for(let rowNumber=startRow;rowNumber<=endRow;rowNumber++){
context.addRowHeader(rowNumber,'title');
}
renderRowHeader(this,context);
setDirty();
}else if(key==='repeat_row_footer'){
const selected=this.getSelected();
const startRow=selected[0],endRow=selected[2];
@ -79,6 +88,15 @@ export const contextMenuConfigure={
}
renderRowHeader(this,context);
setDirty();
}else if(key==='summary_row'){
const selected=this.getSelected();
const startRow=selected[0],endRow=selected[2];
const context=this.context;
for(let rowNumber=startRow;rowNumber<=endRow;rowNumber++){
context.addRowHeader(rowNumber,'summary');
}
renderRowHeader(this,context);
setDirty();
}else if(key==='repeat_cancel'){
const selected=this.getSelected();
const startRow=selected[0],endRow=selected[2];
@ -147,6 +165,10 @@ export const contextMenuConfigure={
name: '<i class="ureport ureport-width" style="color: #d30a16;font-size: 13px;font-weight:bold"></i> 设置列宽',
disabled:checkColDeleteOperationDisabled
},
"title_row": {
name: '<i class="ureport ureport-title" style="color: #9C27B0;font-size: 13px"></i> 标题行',
disabled:checkRowDeleteOperationDisabled
},
"repeat_row_header": {
name: '<i class="ureport ureport-header-repeat" style="color: #9C27B0;font-size: 13px"></i> 重复表头',
disabled:checkRowDeleteOperationDisabled
@ -155,8 +177,12 @@ export const contextMenuConfigure={
name: '<i class="ureport ureport-footer-repeat" style="color: #9C27B0;font-size: 13px"></i> 重复表尾',
disabled:checkRowDeleteOperationDisabled
},
"summary_row": {
name: '<i class="ureport ureport-summary" style="color: #9C27B0;font-size: 13px"></i> 总结行',
disabled:checkRowDeleteOperationDisabled
},
"repeat_cancel": {
name: '<i class="glyphicon glyphicon-remove-circle" style="color: #d30e00;font-size: 13px"></i> 取消重复',
name: '<i class="glyphicon glyphicon-remove-circle" style="color: #d30e00;font-size: 13px"></i> 取消行类型',
disabled:checkRowDeleteOperationDisabled
},
"clean_content": {

4
ureport2-js/src/table/HeaderUtils.js

@ -14,6 +14,10 @@ export function renderRowHeader(hot,context){
type=`<span style='color:blue;font-size: 10px' title='分页时每页头部重复显示'>HR</span>`;
}else if(header.band==='footerrepeat'){
type=`<span style='color:#d30a16;font-size: 10px' title='分页时每页尾部重复显示'>FR</span>`;
}else if(header.band==='title'){
type=`<span style='color:#d30a16;font-size: 10px' title='分页时每页尾部重复显示'>T</span>`;
}else if(header.band==='summary'){
type=`<span style='color:#d30a16;font-size: 10px' title='分页时每页尾部重复显示'>S</span>`;
}
break;
}

Laden…
Annuleren
Opslaan