ACATTTTA 2020-11-25 16:01 采纳率: 60%
浏览 715
已结题

同样的sql语句在数据库中根据条件能查出结果,但是在springboot项目中,却查不出来

<select id="queryVehicleBySelective" parameterType="com.svw.vms.vehicle.dto.VehicleStorageReqDto"
       resultType="com.svw.vms.vehicle.dto.VehicleStorageResultDto">
   SELECT a.hq_vehicle_id hqVehicleId,
          a.vin vin,
          a.offline_date offlineDate,
          a.storage_code storageCode,
          a.storage_status storageStatus,
          a.quality_status qualityStatus,
          (select 1 from tt_sales_lock s where a.commission_no = s.commission_no or a.vin = s.vin) salesLockFlag,
          a.logistics_lock_flag logisticsLockFlag,
          a.identity_code identityCode,
          a.model_code modelCode,
          a.interior_code interiorCode,
          a.color_code colorCode,
          a.pr_list prList,
          a.engine_no engineNo,
          a.cert_no certNo,
          a.purchase_storage_code purchaseStorageCode,
          a.factory_plate_model factoryPlateModel,
          a.bol_no bolNo,
          a.instruction_no instructionNo,
          a.instruction_type instructionType,
          a.bill_type billType,
          b.storage_area_name storageAreaName
     FROM tt_hq_vehicle a
     LEFT JOIN tt_trans_storage_lastest b
     ON a.vin = b.vin AND b.brand_id = #{brandId, jdbcType=BIGINT}
       WHERE a.brand_id = #{brandId, jdbcType=BIGINT}
       <if test="storageCode != null and storageCode !=''">
          AND a.storage_code = #{storageCode, jdbcType=VARCHAR}
   </if>
       <if test="vin != null and vin !=''">
          AND a.vin = #{vin, jdbcType=VARCHAR}
       </if>
       <if test="modelCode != null and modelCode != ''">
          AND a.model_code = #{modelCode, jdbcType=VARCHAR}
       </if>
       <if test="interiorCode != null and interiorCode != ''">
          AND a.interior_code = #{interiorCode, jdbcType=VARCHAR}
       </if>
       <if test="colorCode != null and colorCode != ''">
          AND a.color_code = #{colorCode, jdbcType=VARCHAR}
       </if>
       <if test="identityCode != null and identityCode != ''">
          AND a.identity_code = #{identityCode, jdbcType=VARCHAR}
       </if>
       <if test="offlineDateStart != null and offlineDateStart != ''">
          AND a.offline_date >= TO_DATE(#{offlineDateStart, jdbcType=VARCHAR}, 'YYYY-MM-DD')
       </if>
       <if test="offlineDateEnd != null and offlineDateEnd != ''">
          AND a.offline_date &lt; TO_DATE(#{offlineDateEnd, jdbcType=VARCHAR}, 'YYYY-MM-DD') + 1
       </if>
       <if test="qualityStatus != null and qualityStatus != ''">
          AND a.quality_status = #{qualityStatus, jdbcType=VARCHAR}
       </if>
   <if test="billType != null and billType != ''" >
      AND a.bill_type = #{billType, jdbcType=CHAR}
   </if>
       <if test="vinList != null and vinList.size() > 0">
          AND a.vin IN 
          <foreach collection="vinList" item="item" index="index" open="(" close=")" separator=","> 
               #{item}
          </foreach>
       </if>
       <if test="logisticsLockFlag != null and logisticsLockFlag != ''">
           <choose>
           <when test="logisticsLockFlag == '0'">
           AND a.logistics_lock_flag = 0
           </when>
           <otherwise>
           AND a.logistics_lock_flag > 0
           </otherwise>
           </choose>
       </if>
       ORDER BY a.hq_vehicle_id DESC
   </select>
  • 写回答

5条回答 默认 最新

  • g5zhu5896 2020-11-26 10:14
    关注

    mybatis 在执行时可以在控制台打印sql,以及对于的参数,把sql复制出来参数放上去在数据库执行看看

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 7月27日

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条