使用RMF报表设计器进行报表设计

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u014629817/article/details/52883301

由于项目中需要将报表数据打印出来,所以就去研究了下RMF报表设计器,最终也实现了相关功能;在此记录一下,作为备忘。

1、使用RMF报表设计器将要打印的报表模板设计好,然后在JAVA中通过代码去调用并赋值;下面是主要代码类:

2、代码后面的是打印预览效果截图:

package com.parking.print;


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * @author CQling
 * @date 2016年10月19日
 * @todo TODO
**/
public class ParkCarInfoPrintSource implements IPtnSource{


private ParkCarInfo car;


IParkingDataManageServer parkingDataManageServer = new ParkingDataManageServerImpl();


public ParkCarInfoPrintSource(ParkCarInfo carInfo) {
this.car = carInfo;
}


@Override
public Map<String, String> getParamMap() {
Map<String, String>  map = new HashMap<>();
if (car!=null) {
MemFeeRule mFeeRule = new MemFeeRule();
mFeeRule.setFeeTypeCode(car.getFeeTypeCode());
List<MemFeeStandard> feeStandandList = parkingDataManageServer.findMFeeStandardsbyMemPayRule(mFeeRule);
MemFeeStandard mStandard = new MemFeeStandard();
if (feeStandandList != null && feeStandandList.size() > 0) {
for (int i = 0; i < feeStandandList.size(); i++) {
if (TimeUtils.now().after(feeStandandList.get(i).getExecuteTime())) {
mStandard = feeStandandList.get(i);
break;
} else {
mStandard = null;
}
}
} else {
mStandard = null;
}


map.put("carno", car.getCarno());
map.put("drivelicenseno", car.getDrivelicenseno()==null?"":car.getDrivelicenseno());
map.put("cartype", DictionaryUtil.getDictText("cartype",
car.getCartype()));
map.put("cartypeno", car.getMemberTypeName()==null?"":car.getMemberTypeName());
map.put("owner", car.getCarowner()==null?"":car.getCarowner());
map.put("feestandard",mStandard == null ? "当前无收费标准" : mStandard.getFeeStandard() + "");
map.put("telno", car.getTelno()==null?"":car.getTelno());
map.put("createdtime", car.getCreatedTime().toLocaleString());
map.put("remark", car.getRemark()==null?"":car.getRemark());
}
// TODO Auto-generated method stub
return map;
}


@Override
public PrintMainObj getMain() {
PrintMainObj pmo = new PrintMainObj("VIP审批单", PrintFileConfig.getReportPath() //$NON-NLS-1$
+ "dkz_membercar.rmf", "1", "0", "0", "1"); //$NON-NLS-1$
return pmo;
}


@Override
public String getFileName() {
UUID uid = UUID.randomUUID();
return uid.toString() + ".xml"; //$NON-NLS-1$
}


@Override
public List<PrintDataObj> getData() {
return null;
}


}

展开阅读全文

没有更多推荐了,返回首页