Kaynağa Gözat

fix(mapper): 修复预约确认订单查询中的警告天数计算逻辑

- 添加了警告日期非空验证条件
- 将原来的CASE语句替换为GREATEST函数计算
- 修正了日期比较逻辑从预约日期减去警告日期改为警告日期减去当前日期
- 统一了两处相同的查询条件修改
xuzhancheng 3 gün önce
ebeveyn
işleme
827339f24f

+ 4 - 2
tz-module-pressure2/tz-module-pressure2-biz/src/main/resources/mapper/appointmentconfirmorder/AppointmentConfirmOrderMapper.xml

@@ -85,7 +85,8 @@
                     AND aco.appointment_date BETWEEN #{reqVO.appointmentDate[0]} AND #{reqVO.appointmentDate[1]}
                 </if>
                 <if test="reqVO.warningDay != null and reqVO.warningDay.length >= 2">
-                    AND (CASE WHEN aco.appointment_date - aco.warning_date > 0 THEN aco.appointment_date - aco.warning_date ELSE 0 END) BETWEEN #{reqVO.warningDay[0]} AND #{reqVO.warningDay[1]}
+                    AND aco.warning_date IS NOT NULL
+                    AND GREATEST(TRUNC(aco.warning_date) - TRUNC(SYSDATE), 0) BETWEEN #{reqVO.warningDay[0]} AND #{reqVO.warningDay[1]}
                 </if>
                 <if test="reqVO.unitContact != null and reqVO.unitContact != ''">AND aco.unit_contact = #{reqVO.unitContact}</if>
                 <if test="reqVO.unitPhone != null and reqVO.unitPhone != ''">AND aco.unit_phone = #{reqVO.unitPhone}</if>
@@ -162,7 +163,8 @@
                     AND aco.appointment_date BETWEEN #{reqVO.appointmentDate[0]} AND #{reqVO.appointmentDate[1]}
                 </if>
                 <if test="reqVO.warningDay != null and reqVO.warningDay.length >= 2">
-                    AND (CASE WHEN aco.appointment_date - aco.warning_date > 0 THEN aco.appointment_date - aco.warning_date ELSE 0 END) BETWEEN #{reqVO.warningDay[0]} AND #{reqVO.warningDay[1]}
+                    AND aco.warning_date IS NOT NULL
+                    AND GREATEST(TRUNC(aco.warning_date) - TRUNC(SYSDATE), 0) BETWEEN #{reqVO.warningDay[0]} AND #{reqVO.warningDay[1]}
                 </if>
                 <if test="reqVO.unitContact != null and reqVO.unitContact != ''">AND aco.unit_contact = #{reqVO.unitContact}</if>
                 <if test="reqVO.unitPhone != null and reqVO.unitPhone != ''">AND aco.unit_phone = #{reqVO.unitPhone}</if>