# Report and Document Printing

This system supports report and document printing template development based on Jasper Report

# Target Audience

The target audience of this document is: developers and implementers of this system

The report and document printing template development of this system is based on Jasper Report technology. Relevant technical documents can be referenced:

# Interface Interaction

The interface interaction method for document printing and reports is similar to running dynamic actions, while providing targeted optimizations for printing and reporting.

# Report Definition

The report definition in the system is a DynamicReport object, with the following key fields explained:

Field Description Type
name Report name, required, cannot be modified after creation java.lang.String
label Report display name in the interface, required java.lang.String
template Report template file, required, in jrxml format report definition file. tech.muyan.storage.StorageFieldValue
action Action associated with the report, required tech.muyan.dynamic.action.DynamicAction
domainClass Domain object associated with the report, required tech.muyan.DomainClass
parameters Report parameters, optional, for user input of query parameters. List<tech.muyan.dynamic.field.DynamicFieldInstance>
enableRoles Roles available for the report, comma-separated role names java.lang.String
active Whether the report is activated, inactive reports will not display in the UI java.lang.Boolean

# Default Action Definitions for Running Reports

Reports are executed through actions defined in the system. The system has already defined some default report actions that can be used directly. If these do not meet the requirements, custom report actions can also be defined and associated with reports.

The default report actions defined in the system are as follows:

Action Name Action Type Action Description
ClassLevelPrintDocumentAction CLASS_LEVEL Used for Class Level document printing execution
SinglePrintDocumentAction OBJECT_SINGLE Used for document printing execution after selecting a single object
SingleAndMultiplePrintDocumentAction OBJECT_SINGLE_MULTIPLE Used for document printing execution after selecting one or more objects
MultiplePrintDocumentAction OBJECT_MULTIPLE Used for document printing execution after selecting multiple objects
ClassLevelRunReportDocumentAction CLASS_LEVEL Used for Class Level report execution
SingleRunReportDocumentAction OBJECT_SINGLE Used for report execution after selecting a single object
SingleAndMultipleRunReportDocumentAction OBJECT_SINGLE_MULTIPLE Used for report execution after selecting one or more objects
MultipleRunReportDocumentAction OBJECT_MULTIPLE Used for report execution after selecting multiple objects

TIP

Difference between document printing and reports

In business terms, document printing generally does not require user input of query parameters, while reports may require user input of query parameters.

For print-type actions, the interaction method is NO_POPUP_NO_CONFIRM. When users click, it directly generates a print PDF file without requiring user input of query parameters.

For report-type actions, the interaction method is NO_CONFIRM. When users click, it may pop up a parameter input interface for users to input query parameters.

# Report Design

  1. Our company's developers can use their Github accounts to log in to the Online Report Design System (opens new window) for report design. After design, the report template file can be downloaded locally.

  2. You can also directly download the Eclipse-based, full-featured Jasper Report Studio (opens new window), design reports locally, and then export the jrxml report design file after design.

# Default Report Template Download

You can download the default report template from the running system. This template is stored in the DynamicConfig configuration with the key report.template

Download Report Template

# Default Injected Parameters

The system will automatically inject the following query parameters into the report template:

Parameter Name Parameter Type Description Corresponding Database Path
objectIds java.util.Collection<java.lang.Long> List of selected object ids <domain table>.id
objectIdsStr java.util.Collection<java.lang.String> List of selected object ids, converted to String <domain table>.id
firstObjectId java.lang.Long ID of the first selected object <domain table>.id
firstObjectIdStr java.lang.String ID of the first selected object, converted to String <domain table>.id
objectTypeId java.lang.Long Type ID of the selected object, data stored in the domain_class table domain_class.id
objectTypeShortName java.lang.String ShortName of the selected object type, corresponding to Java class name without package domain_class.short_name
objectTypeFullName java.lang.String FullName of the selected object type, corresponding to Java class name with package domain_class.full_name
userId java.lang.Long User's ID application_user.id
username java.lang.String User's login name application_user.username
userDisplayName java.lang.String User's name application_user.name
rootOrganizationId java.lang.Long ID of the top-level organization the user belongs to organization.id
rootOrganizationName java.lang.String Name of the top-level organization the user belongs to organization.name
userOrganizationId java.lang.Long ID of the organization the user belongs to organization.id
userOrganizationName java.lang.String Name of the organization the user belongs to organization.name
logo java.io.InputStream Logo defined in the currently active DynamicTheme in the system dynamic_theme.logo

# FAQ

  1. How to use injected parameters in the report?

    In the report template, you can use $P{<parameter name>} to reference injected parameters, for example: $P{userId}

  2. How to use java.util.Collection as a query condition?

    Jasper report provides syntax support, you can use $X{IN, <database field name>, <parameter name>}. In the following SQL, $X{IN, al.persisted_object_id, objectIdsStr} is used to query data from the audit_log table using the objectIdsStr parameter as a query condition.

     SELECT
        al.id,
        al.persisted_object_id,
        al.property_name,
        al.date_created,
        al.old_value,
        al.new_value,
        COALESCE(au.username, 'System') AS actor
     FROM audit_log al
     LEFT JOIN application_user au ON al.actor = au.id::varchar
     WHERE
       $X{IN, al.persisted_object_id, objectIdsStr}
       AND al.class_name = $P{objectTypeFullName}
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
  3. Why is each queried row repeatedly printed?

    Please check the Detail area design in the report template. By default, Jasper Report repeats printing the Detail area for each row of data returned by the SQL.

  4. How to display the logo

    Simply add an image component in the report template and set its expression to $P{logo}. The system will automatically inject the logo's image stream.

Last Updated: 12/4/2024, 1:00:56 PM