|
|
@ -64,6 +64,49 @@ |
|
|
|
GROUP BY |
|
|
|
sbv.order_code |
|
|
|
</select> |
|
|
|
<select id="selectAllByPage" resultType="org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup"> |
|
|
|
WITH RankedVehicles AS ( |
|
|
|
SELECT |
|
|
|
vg.*, |
|
|
|
ROW_NUMBER() OVER (PARTITION BY vg.vehicle_code ORDER BY vg.due_date) AS rn |
|
|
|
FROM |
|
|
|
sch_base_vehiclematerialgroup vg |
|
|
|
<where> |
|
|
|
<if test="query.vehicle_code != null"> |
|
|
|
AND vg.vehicle_code LIKE CONCAT('%', #{query.vehicle_code}, '%') |
|
|
|
</if> |
|
|
|
<if test="query.workshop_code != null"> |
|
|
|
AND vg.workshop_code = #{query.workshop_code} |
|
|
|
</if> |
|
|
|
<if test="query.job_name != null"> |
|
|
|
AND vg.job_name LIKE CONCAT('%', #{query.job_name}, '%') |
|
|
|
</if> |
|
|
|
<if test="query.region_code != null"> |
|
|
|
<choose> |
|
|
|
<when test="query.region_code.equals('111-100')"> |
|
|
|
AND vg.region_code IS NULL |
|
|
|
</when> |
|
|
|
<otherwise> |
|
|
|
AND vg.region_code = #{query.region_code} |
|
|
|
</otherwise> |
|
|
|
</choose> |
|
|
|
</if> |
|
|
|
<if test="query.order_code != null"> |
|
|
|
AND vg.order_code LIKE CONCAT('%', #{query.order_code}, '%') |
|
|
|
</if> |
|
|
|
<if test="query.material_id != null"> |
|
|
|
AND vg.material_id LIKE CONCAT('%', #{query.material_id}, '%') |
|
|
|
</if> |
|
|
|
<if test="query.daybetween != null"> |
|
|
|
AND DATEDIFF(NOW(), vg.create_time) > #{query.daybetween} |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
ORDER BY vg.create_time DESC |
|
|
|
) |
|
|
|
SELECT * |
|
|
|
FROM RankedVehicles |
|
|
|
WHERE rn = 1 |
|
|
|
</select> |
|
|
|
<select id="selectAllByPage" resultType="org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup"> |
|
|
|
WITH RankedVehicles AS ( |
|
|
|
SELECT |
|
|
@ -97,6 +140,9 @@ |
|
|
|
<if test="query.material_id != null"> |
|
|
|
AND vg.material_id like CONCAT('%', #{query.material_id}, '%') |
|
|
|
</if> |
|
|
|
<if test="query.daybetween != null"> |
|
|
|
WHERE DATEDIFF(NOW(), create_time) >= #{query.daybetween} |
|
|
|
</if> |
|
|
|
order by vg.create_time desc |
|
|
|
) |
|
|
|
SELECT * |
|
|
|