jasper-reports - 如何让jasper报表上显示不同的图片?
问题描述
我有一个问题,在这种情况下,当尝试从“工作卡”中显示三个单独的图像时,会显示相同的图片。
但实际上数据库上有三个不同的图像
这是我的 SQL:
select distinct job_card.job_card_name,
job_card.job_number,
job_card.job_type,
job_card.job_card_name,
client_account.account_name,
job_card.punchlist_comments,
"user".name,
job_card.customer_name,
job_card.created_at,
job_card.customer_signature_blob,
job_card.technician_signature_blob,
photograph.photo_blob
from $P!{schemaName}.job_card
left join $P!{schemaName}.photograph on $P!{schemaName}.job_card."_id_" = $P!{schemaName}.photograph.job_cards_fk
left join $P!{schemaName}."user" on $P!{schemaName}."user"."_id_" = $P!{schemaName}.job_card.technicians_fk
left join $P!{schemaName}.asset on $P!{schemaName}.asset."_id_" = $P!{schemaName}.job_card.assets_fk
left join $P!{schemaName}.client_account on $P!{schemaName}.client_account."_id_" = $P!{schemaName}.asset.clientaccounts_fk
where job_card._id_ = $P{job_cardUUID}::uuid
“photograph.photo_blob”是变量
这是碧玉元素:
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[ Installation pictures ]]></text>
</staticText>
<image>
<reportElement x="0" y="180" width="200" height="124" uuid="8bf21ae9-eec4-4c39-b4c1-4c174ec59aab"/>
<box>
<pen lineWidth="0.25"/>
</box>
<imageExpression><![CDATA[$F{photo_blob}]]></imageExpression>
</image>
<image>
<reportElement x="200" y="180" width="200" height="124" uuid="aa9d55fb-184f-4098-95f8-9de17530c99b"/>
<box>
<pen lineWidth="0.25"/>
</box>
<imageExpression><![CDATA[$F{photo_blob}]]></imageExpression>
</image>
<image>
<reportElement x="400" y="180" width="150" height="124" uuid="64df2d59-4154-4b26-a3d1-3f54f1b54eca"/>
<box>
<pen lineWidth="0.25"/>
</box>
<imageExpression><![CDATA[$F{photo_blob}]]></imageExpression>
</image>
我尝试将此框放在详细信息带中,但页面只是乘以图片数量
解决方案
您有三张重复的图片,因为您同时使用同一波段中的三个图像元素,共享相同的表达式,即$F{photo_blob}
。
如果每个人都有树或更多不同的图片,则job_card._id_
必须创建一个组,例如job_card
,并在您放置的组标题中
<text><![CDATA[ Installation pictures ]]></text>
在你放的细节带中
<image>
<reportElement x="0" y="180" width="200" height="124" uuid="8bf21ae9-eec4-4c39-b4c1-4c174ec59aab"/>
<box>
<pen lineWidth="0.25"/>
</box>
<imageExpression><![CDATA[$F{photo_blob}]]></imageExpression>
</image>
推荐阅读
- sql - SQL:为每个 id 增加列值(循环?)
- python - 如何使用线程防止程序“冻结”
- bash - 使用 awk 在文件末尾添加常量值作为列
- html - HTML - HREF 在图像下创建一个新的蓝线
- python-3.x - 使用 BeautifulSoup,Python 3.6 获取完整的项目列表
- kotlin - 为什么'await'阻塞了kotlin中的线程?
- javascript - 如何使用 Angular 材料从后端获取标签作为名称属性?
- sql - 内连接:内连接不同表中的值之和,两边都没有命中时为0
- sql - SQL SERVER 为 2 Colmuns 两个不同的表添加检查约束
- python - 将迭代的值存储到张量 - Python、Numpy、pytorch