Report Creation 2 (incoming a SQL primary key with subreport)

Source: Internet
Author: User
Tags sql primary key

Transferred from: http://www.cnblogs.com/ms-grf/p/6756243.html

Report JS

$scope. Printcptempletmasterdetail = function (cpId) {        var parameters = {            Reportfilename: "reports/ Doctorstation/cptempletmasterdetail.jasper ",            parameters: {                ' cpId ': CpId            }        };        var printinfoobject = {            type: ' Report ',            appletparameters: {                is_direct_print:true,                is_display:false ,                Printer_name:null,                report_url: "Api/jasper-prints/doctor-station/cp-order-detail"            },            Reportparameter:parameters        };        Hrutils.postmessagetobaseframe (Printinfoobject, "*");    };

Report Doctorstationprintresource.java

Package Com.heren.his.report.api;import Com.heren.his.report.facade.doctorstationprintfacade;import Com.heren.his.report.vo.jasperprintparamsvo;import Net.sf.jasperreports.engine.jasperprint;import javax.ws.rs.*; Import Javax.ws.rs.core.MediaType; @Path ("Doctor-station") public class Doctorstationprintresource {    @ Javax.inject.Inject    private Doctorstationprintfacade doctorstationprintfacade;    /**     * Print path details     * @param parameters     * @return */    @GET    @Path ("Cp-order-detail")    @Produces ( {Mediatype.application_octet_stream})    Public Jasperprint Fillcptempletmasterdetailreport (@QueryParam ("parameter") JASPERPRINTPARAMSVO parameters) {        return Doctorstationprintfacade.fillcptempletmasterdetailreport (parameters);}    }

Report Doctorstationprintfacade.java

Package Com.heren.his.report.facade;import Com.google.common.base.strings;import Com.heren.his.report.common.hrresultset;import Com.heren.his.report.vo.jasperprintparamsvo;import Com.heren.his.report.vo.doctorstation.eroutpblooddetail;import Com.heren.his.report.vo.doctorstation.eroutpbloodvo;import Com.heren.his.report.vo.doctorstation.medicalrecordinfovo;import Net.sf.jasperreports.engine.jasperprint;import Net.sf.jasperreports.engine.data.jrbeancollectiondatasource;import Net.sf.jasperreports.engine.data.jrmapcollectiondatasource;import Org.slf4j.logger;import Org.slf4j.loggerfactory;import Javax.inject.inject;import Java.util.arraylist;import Java.util.List;import Java.util.map;import static Com.heren.his.report.util.reportutils.obtainjasperreportbyfilename;public class Doctorstationprintfacade extends Basejasperfillfacade {private static final Logger Logger = Loggerfactory.getlogger (do    Ctorstationprintfacade.class); @Inject Private Medicalinfodatafacade MEDICALINFODATAFACAde /** * Print Path Advice Details * * @param JASPERPRINTPARAMSVO * @return */public Jasperprint Fillcptempletmasterde Tailreport (Jasperprintparamsvo jasperprintparamsvo) {logger.debug ("populate report [{}]; use parameters when populating: [{}].")        ", Jasperprintparamsvo.getreportfilename (), jasperprintparamsvo.getparameters ()); Map ReportParam = Jasperprintparamsvo.getparameters ();//js inside Cpid reportparam.put ("Subreport_dir", "reports/doctors        Tation/"); Return Hrfillreportwithconnection (Obtainjasperreportbyfilename (Jasperprintparamsvo.getreportfilename ()),    ReportParam); }}

Report

1: Create the main report Master.jrxml

The first new two parameters in Master.jrxml, the name is the red label in the code above

Cpid is the primary key used to write SQL, and Subreport_dir is the address used to connect the subreport

Start writing Master.jrxml SQL statements such as

After writing the SQL click on the read fields, you can put the parameters used in the Master.jrxml in fields.

Perfect Master.jrxml

2: Create subreport Nurse.jrxml

The following stage_id is a parameter that is passed from the parent report to the subreport (because the subreport also needs to write the SQL and need to query the criteria)

Sub-report Creation complete

The main point of the configuration subreport is as follows

Then set the Subreport_dir variable of the connection subreport as follows

Generate the. jasper file as follows

Do the test as follows

Report 2 (pass in a SQL primary key with subreports)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.