首页 > 代码库 > 报表制作
报表制作
打印js
$scope.printObserveRecord = function () { if ($scope.printObserveRecordShow) { var erObservationDetailList = []; erObservationDetailList.push($scope.erObservationDetail); $scope.printInfoObject = { type: "report", method: "post", appletParameters: { report_url: "api/jasper-prints/emergency-station/pre-er-observe", printer_name: null, is_direct_print: true, is_display: true }, reportParameter: { reportFileName: "reports/emergency/erObserveRegister.jasper", parameters: { erObservationDetail: erObservationDetailList, hospitalName: getSysParaConfig("Hosp_Name"), reportMaker: getStaffDict().staffName, diagnosis:$scope.erObservationDetail.observationDetail.diagnosis, observationCause:$scope.erObservationDetail.observationDetail.observationCause, observationTime:$filter(‘date‘)($scope.erObservationDetail.observationDetail.observationTime,‘yyyy-MM-dd HH:mm:ss‘), suggestPrepayment:$scope.erObservationDetail.observationDetail.suggestPrepayment } } }; HrUtils.postMessageToBaseFrame($scope.printInfoObject, "*"); } else { hrDialog.dialog(hrDialog.typeEnum.WARN, {message: "请先保存留观记录!"}); } };
HrUtils.postMessageToBaseFrame($SCOPE.PRINTiNFOoBJECT,"*");
postMessageToBaseFrame: function (data, origin) {//origin参数默认为*,可以不填写 if (HrStr.isNull(origin)) { origin = "*"; } window.parent.top.postMessage(data, origin); }
在另一个程序里接收
接收EmergencystationPrintResource.java
package com.heren.his.report.api; import com.heren.his.report.facade.EmergencystationPrintFacade; import com.heren.his.report.vo.JasperPrintParamsVo; import net.sf.jasperreports.engine.JasperPrint; import javax.inject.Inject; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.InputStream; @Path("emergency-station") public class EmergencystationPrintResource { @Inject private EmergencystationPrintFacade emergencystationPrintFacade; //留观登记打印 @POST @Path("pre-er-observe") @Produces({MediaType.APPLICATION_OCTET_STREAM}) @Consumes({MediaType.APPLICATION_JSON}) public JasperPrint getErObserveRegisterPrint(JasperPrintParamsVo parameters) { return emergencystationPrintFacade.fillErObserveRegisterPrint(parameters); } }
接收EmergencystationPrintFacade.java
package com.heren.his.report.facade; import com.heren.his.report.vo.JasperPrintParamsVo; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.data.JRMapCollectionDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.heren.his.report.util.ReportUtils.obtainJasperReportByFileName; public class EmergencystationPrintFacade extends BaseJasperFillFacade { private static final Logger LOGGER = LoggerFactory.getLogger(NursestationFillFacade.class); /** * 留观登记打印 * @param jasperPrintParamsVo * @return */ public JasperPrint fillErObserveRegisterPrint(JasperPrintParamsVo jasperPrintParamsVo){ LOGGER.debug("填充报表[{}];填充时使用参数:[{}]。", jasperPrintParamsVo.getReportFileName(), jasperPrintParamsVo.getParameters()); List<Map<String, ?>> erObservationDetail = (List<Map<String, ?>>) jasperPrintParamsVo.getParameters().get("erObservationDetail"); return hrFillReport(obtainJasperReportByFileName(jasperPrintParamsVo.getReportFileName()), jasperPrintParamsVo.getParameters(), new JRMapCollectionDataSource(erObservationDetail)); } }
报表(我用的是Jaspersoft)制作的报表
1:先新建一个erObserveRegister.jrxml
如图所示$P{hospitalName}是js里面蓝色标注的参数
$F{name}是js里面绿色标注的参数
蓝色参数是单独的参数,也就是一个string字符串而绿色参数是一个对象,所以他们在报表里面的引用形式就不一样一个是$P一个是$F
如图所示Parameters里面对应的是$P,Fields里对应的是$F Parameters里面的命名一定要和传入的参数名字一致,Fields里面的命名要和传入对象里的参数名字一致
2:调整报表内容格式(因为要打印的格式是pdf格式或者是其他格式,所以要调节内容格式)达到如下效果
要出现如上效果,整齐对照,布局清晰,字体样式带有三角感叹号为止
3:修改ing 框体位置大小修改如下
字体大小位置如下
打印字体设置如下 主要是设置图2红框中的内容(PDF)
4:点击如下点击build就可以生成一个.jasper的文件
5:把这两个文件都拷贝到报表项目下,.jrxml文件是为了做以后修改用的,.jasper才是用来打印的报表
报表制作
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。