+每个模块排序

This commit is contained in:
wuyu 2023-12-01 16:32:53 +08:00
parent 4d1c712bc9
commit 618c685b17

View File

@ -8,6 +8,7 @@
FROM
(
<if test="isNowDay">
SELECT (@i:=@i+1) mi,aa.* FROM
(SELECT
old_undo.*,1 AS flag
FROM
@ -20,10 +21,11 @@
AND is_delete = 0
AND executor_person_id = #{personId}
AND template_code IN <foreach collection="pendingCalendarCodeDTO.constructionCodes" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
ORDER BY create_at ASC) old_undo)
ORDER BY create_at ASC) old_undo) aa,(SELECT (@i:=0))tt
UNION
ALL
</if>
SELECT (@i:=@i+1) mi,aa.* FROM
(SELECT
new_todo.*,2 AS flag
FROM
@ -36,9 +38,10 @@
AND is_delete = 0
AND executor_person_id = #{personId}
AND template_code IN <foreach collection="pendingCalendarCodeDTO.constructionCodes" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
ORDER BY create_at DESC) new_todo)
ORDER BY create_at DESC) new_todo) aa,(SELECT (@i:=0))tt
UNION
ALL
SELECT (@i:=@i+1) mi,aa.* FROM
(SELECT
new_todo_3.*,3 AS flag
FROM
@ -51,9 +54,10 @@
AND is_delete = 0
AND executor_person_id = #{personId}
AND template_code IN <foreach collection="pendingCalendarCodeDTO.punchInCodes" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
ORDER BY create_at DESC) new_todo_3)
ORDER BY create_at DESC) new_todo_3) aa,(SELECT (@i:=0))tt
UNION
ALL
SELECT (@i:=@i+1) mi,aa.* FROM
(SELECT
new_todo_4.*,4 AS flag
FROM
@ -66,9 +70,10 @@
AND is_delete = 0
AND executor_person_id = #{personId}
AND template_code IN <foreach collection="pendingCalendarCodeDTO.clockInCodes" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
ORDER BY create_at DESC) new_todo_4)
ORDER BY create_at DESC) new_todo_4) aa,(SELECT (@i:=0))tt
UNION
ALL
SELECT (@i:=@i+1) mi,aa.* FROM
(SELECT
all_new_do.*,5 AS flag
FROM
@ -81,10 +86,11 @@
AND is_delete = 0
AND executor_person_id = #{personId}
AND template_code IN <foreach collection="pendingCalendarCodeDTO.allCodes" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
ORDER BY create_at DESC) all_new_do)
ORDER BY create_at DESC) all_new_do) aa,(SELECT (@i:=0))tt
<if test="isNowDay">
UNION
ALL
SELECT (@i:=@i+1) mi,aa.* FROM
(SELECT
old_do.*,6 AS flag
FROM
@ -97,8 +103,8 @@
AND is_delete = 0
AND executor_person_id = #{personId}
AND template_code IN <foreach collection="pendingCalendarCodeDTO.constructionCodes" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
ORDER BY create_at DESC) old_do)
ORDER BY create_at DESC) old_do) aa,(SELECT (@i:=0))tt
</if>
) ccc ORDER BY flag ASC
) ccc ORDER BY flag ASC,mi asc
</select>
</mapper>