带有更多条件的 if 语句

if statement with more conditions

我正在创建一个自动报告生成器,它正在从数据库中获取所有信息。

您可以在 pdf 中看到进度,在该进度中您有一个特定的状态,始终为 0、1、2 或 3。

如果状态为 0-1,则应将图像更改为不完整图像。
如果状态为 2,则应将图像更改为完整图像
如果状态为 3,则应将图像更改为未尝试成像。

我有一个支持前两个的代码:

IF( $F{status} == 2) ? $P{IMG_DIR} + "scorm_completed.png" : $P{IMG_DIR} + "scorm_incomplete.png"

有谁知道我要更改什么吗?

以下是您将如何执行此操作的示例:

<image>
    <reportElement x="0" y="1" width="100" height="37"/>
    <imageExpression>
        <![CDATA[($F{status} == 3) ?
            $P{IMG_DIR} + "not_attempted.png" :
            (($F{status} == 2) ?
            $P{IMG_DIR} + "scorm_completed.png" :
            (($F{status} == 1 || $F{status} == 0) ?
            $P{IMG_DIR} + "scorm_incompleted.png" : null))]]>
    </imageExpression>
</image>

我正在使用 null 占位符来表示状态既不是 0、1、2 或 3 的情况,但您可能想用错误图像替换它。