该错误是由于将字符串"Y"解析为数字引起的。原因是在判断isReturn参数是否等于"Y"时,使用了等于操作符(eq),而MyBatis默认将参数值解析为字符串并尝试将其转换为数字。解决方法是将等于操作符(eq)改为等价的字符串相等操作符(==)。

修改后的代码如下所示:

<select id="queryPages" parameterType="java.lang.String" resultType="org.jeecg.modules.silverReplaceInventoryService.entity.SilverReplaceInventory">
    SELECT
    sri.id,
    sri.material_document,
    sri.material_document_line,
    sri.posting_date,
    sri.material,
    sri.quantity,
    sri.original_quantity,
    sri.unit,
    sri.goods_movement_type,
    sri.plant,
    sri.storage_location,
    sri.manufacturing_order,
    sri.is_return,
    op.productdescription material_name
    FROM
    silver_replace_inventory sri
    LEFT JOIN ods_product op on op.product=sri.material
    where 1=1
    <if test="silverReplaceInventory.material != null and silverReplaceInventory.material != ''">
        AND sri.material = #{silverReplaceInventory.material}
    </if>
    <if test="silverReplaceInventory.manufacturingOrder != null and silverReplaceInventory.manufacturingOrder != ''">
        AND sri.manufacturing_order = #{silverReplaceInventory.manufacturingOrder}
    </if>
    <if test="silverReplaceInventory.isReturn != null and silverReplaceInventory.isReturn != ''">
        <choose>
            <when test="silverReplaceInventory.isReturn == 'Y'">
                AND sri.is_return = 'Y'
            </when>
            <when test="silverReplaceInventory.isReturn == 'N'">
                AND sri.is_return is null
            </when>
        </choose>
    </if>
    <if test="silverReplaceInventory.startDate != null and silverReplaceInventory.startDate != ''">
        AND sri.posting_date >=#{silverReplaceInventory.startDate}
    </if>
    <if test="silverReplaceInventory.endDate != null and silverReplaceInventory.endDate != ''">
        AND sri.posting_date &lt;=#{silverReplaceInventory.endDate}
    </if>
    ORDER BY sri.posting_date
</select>

请注意,将等号(=)修改为等价的字符串相等操作符(==),这样就可以将字符串"Y"正确地与isReturn参数进行比较

select id=queryPages parameterType=javalangString resultType=orgjeecgmodulessilverReplaceInventoryServiceentitySilverReplaceInventory SELECT sriid srimaterial_document srim

原文地址: https://www.cveoy.top/t/topic/iRGS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录