Pārlūkot izejas kodu

定时任务优化

魏超 5 gadus atpakaļ
vecāks
revīzija
6a38a95024

+ 4
- 30
src/main/resources/mapper/HelpActivityMapper.xml Parādīt failu

38
     </select>
38
     </select>
39
 
39
 
40
     <update id="updateUnStartHelpActivity">
40
     <update id="updateUnStartHelpActivity">
41
-        update ta_help_activity
41
+        update ta_help_activity t
42
         set activity_status = 0
42
         set activity_status = 0
43
         where
43
         where
44
-        help_activity_id in (
45
-            select
46
-            help_activity_id
47
-            from
48
-            (
49
-            select
50
-            t.help_activity_id
51
-            from
52
-            ta_help_activity t
53
-            where
54
-            t.activity_status != '2'
55
-            and NOW() > t.start_date
56
-            and NOW() &lt; t.end_date
57
-            ) s
58
-        )
44
+        t.activity_status != '2' and NOW() BETWEEN t.start_date  and t.end_date
59
     </update>
45
     </update>
60
 
46
 
61
     <update id="updateProcessingHelpActivity">
47
     <update id="updateProcessingHelpActivity">
62
-        update ta_help_activity
48
+        update ta_help_activity t
63
         set activity_status = 2
49
         set activity_status = 2
64
         where
50
         where
65
-            help_activity_id in (
66
-                select
67
-                    help_activity_id
68
-                from
69
-                    (
70
-                        select
71
-                            t.help_activity_id
72
-                        from
73
-                            ta_help_activity t
74
-                        where
75
-                            t.activity_status != '2'
51
+             t.activity_status != '2'
76
                         and NOW() > t.end_date
52
                         and NOW() > t.end_date
77
-                    ) s
78
-            )
79
     </update>
53
     </update>
80
 
54
 
81
     <select id="selectWxhelpActivityAndGroup" resultType="com.huiju.estateagents.entity.HelpActivity">
55
     <select id="selectWxhelpActivityAndGroup" resultType="com.huiju.estateagents.entity.HelpActivity">

+ 15
- 11
src/main/resources/mapper/HelpInitiateRecordMapper.xml Parādīt failu

3
 <mapper namespace="com.huiju.estateagents.mapper.HelpInitiateRecordMapper">
3
 <mapper namespace="com.huiju.estateagents.mapper.HelpInitiateRecordMapper">
4
 
4
 
5
     <update id="updateHelpActivityProcessToEnd">
5
     <update id="updateHelpActivityProcessToEnd">
6
-      update ta_help_initiate_record a
7
-        set a.`status` = '2'
8
-        where
9
-            a.help_activity_id in (
10
-                select
11
-                    t.help_activity_id
12
-                from
13
-                    ta_help_activity t
14
-                where (NOW() > t.end_date or t.activity_status = '2')
15
-            )
16
-        and a.`status` = '1'
6
+--       update ta_help_initiate_record a
7
+--         set a.`status` = '2'
8
+--         where
9
+--             a.help_activity_id in (
10
+--                 select
11
+--                     t.help_activity_id
12
+--                 from
13
+--                     ta_help_activity t
14
+--                 where (NOW() > t.end_date or t.activity_status = '2')
15
+--             )
16
+--         and a.`status` = '1'
17
+        update ta_help_initiate_record a
18
+        left join ta_help_activity b on a.help_activity_id = b.help_activity_id
19
+        set a.status = '2'
20
+        where  (NOW() > b.end_date or b.activity_status = '2') and a.`status` = '1' and a.status != '0'
17
     </update>
21
     </update>
18
 
22
 
19
     <select id="selectPageList" resultType="com.huiju.estateagents.entity.HelpInitiateRecord">
23
     <select id="selectPageList" resultType="com.huiju.estateagents.entity.HelpInitiateRecord">

+ 4
- 31
src/main/resources/mapper/TaBuildingDynamicMapper.xml Parādīt failu

96
     </update>
96
     </update>
97
 
97
 
98
     <update id="updateUnStartActivity">
98
     <update id="updateUnStartActivity">
99
-        update ta_building_dynamic
99
+        update ta_building_dynamic t
100
         set activity_status = 0
100
         set activity_status = 0
101
         where
101
         where
102
-        dynamic_id in (
103
-            select
104
-            dynamic_id
105
-            from
106
-            (
107
-            select
108
-            t.dynamic_id
109
-            from
110
-            ta_building_dynamic t
111
-            where
112
-            t.activity_status != '2'
113
-            and NOW() > t.create_date
114
-            and NOW() &lt; t.end_date
115
-            ) s
116
-        )
102
+        t.activity_status = 1 and NOW() between  t.create_date and  t.end_date
117
     </update>
103
     </update>
118
 
104
 
119
     <update id="updateProcessingActivity">
105
     <update id="updateProcessingActivity">
120
-        update ta_building_dynamic
106
+        update ta_building_dynamic t
121
         set activity_status = 2
107
         set activity_status = 2
122
         where
108
         where
123
-            dynamic_id in (
124
-                select
125
-                    dynamic_id
126
-                from
127
-                    (
128
-                        select
129
-                            t.dynamic_id
130
-                        from
131
-                            ta_building_dynamic t
132
-                        where
133
-                            t.activity_status != '2'
134
-                        and NOW() > t.end_date
135
-                    ) s
136
-            );
109
+        t.activity_status =0 and NOW() > t.end_date
137
     </update>
110
     </update>
138
 
111
 
139
     <select id="updateTaBuildingDynamic">
112
     <select id="updateTaBuildingDynamic">

+ 3
- 17
src/main/resources/mapper/TaShareActivityMapper.xml Parādīt failu

16
     </select>
16
     </select>
17
 
17
 
18
     <update id="updateUnStartGroupActivity">
18
     <update id="updateUnStartGroupActivity">
19
-        update ta_share_activity
19
+        update ta_share_activity t
20
         set activity_status = 0
20
         set activity_status = 0
21
-        where
22
-        group_activity_id in (
23
-            select
24
-            group_activity_id
25
-            from
26
-            (
27
-            select
28
-            t.group_activity_id
29
-            from
30
-            ta_share_activity t
31
-            where
32
-            t.activity_status != '2'
33
-            and NOW() > t.start_time
34
-            and NOW() &lt; t.end_time
35
-            ) s
36
-        )
21
+        where t.activity_status != '2'
22
+            and NOW() BETWEEN t.start_time and t.end_time
37
     </update>
23
     </update>
38
 
24
 
39
     <update id="updateProcessGroupActivity">
25
     <update id="updateProcessGroupActivity">

+ 11
- 7
src/main/resources/mapper/TaShareChildRecordMapper.xml Parādīt failu

3
 <mapper namespace="com.huiju.estateagents.mapper.TaShareChildRecordMapper">
3
 <mapper namespace="com.huiju.estateagents.mapper.TaShareChildRecordMapper">
4
 
4
 
5
     <update id="updateEndGroupActivity">
5
     <update id="updateEndGroupActivity">
6
+--         update ta_share_child_record a
7
+--         set a.`status` = '2'
8
+--         where a.group_activity_id in (
9
+--             select
10
+--                     t.group_activity_id
11
+--                 from
12
+--                     ta_share_activity t
13
+--                 where (NOW() > t.end_time or t.activity_status = '2')
14
+--         ) and a.`status` = '1';
6
         update ta_share_child_record a
15
         update ta_share_child_record a
16
+        LEFT JOIN ta_share_activity b on a.group_activity_id = b.group_activity_id
7
         set a.`status` = '2'
17
         set a.`status` = '2'
8
-        where a.group_activity_id in (
9
-            select
10
-                    t.group_activity_id
11
-                from
12
-                    ta_share_activity t
13
-                where (NOW() > t.end_time or t.activity_status = '2')
14
-        ) and a.`status` = '1';
18
+        where (NOW() > b.end_time or b.activity_status = '2') and a.`status` = '1' and a.status != '0'
15
     </update>
19
     </update>
16
 
20
 
17
     <select id="getList" resultType="com.huiju.estateagents.entity.TaShareChildRecord">
21
     <select id="getList" resultType="com.huiju.estateagents.entity.TaShareChildRecord">

+ 13
- 9
src/main/resources/mapper/TaShareRecordMapper.xml Parādīt failu

3
 <mapper namespace="com.huiju.estateagents.mapper.TaShareRecordMapper">
3
 <mapper namespace="com.huiju.estateagents.mapper.TaShareRecordMapper">
4
 
4
 
5
     <update id="updateEndGroupActivity">
5
     <update id="updateEndGroupActivity">
6
+--         update ta_share_record a
7
+--         set a.`status` = '2'
8
+--         where
9
+--             a.group_activity_id in (
10
+--                 select
11
+--                     t.group_activity_id
12
+--                 from
13
+--                     ta_share_activity t
14
+--                 where (NOW() > t.end_time or t.activity_status = '2')
15
+--             )
16
+--         and a.`status` = '1';
6
         update ta_share_record a
17
         update ta_share_record a
18
+        LEFT JOIN ta_share_activity b on a.group_activity_id = b.group_activity_id
7
         set a.`status` = '2'
19
         set a.`status` = '2'
8
-        where
9
-            a.group_activity_id in (
10
-                select
11
-                    t.group_activity_id
12
-                from
13
-                    ta_share_activity t
14
-                where (NOW() > t.end_time or t.activity_status = '2')
15
-            )
16
-        and a.`status` = '1';
20
+        where (NOW() > b.end_time or b.activity_status = '2') and a.`status` = '1' and a.status != '0'
17
     </update>
21
     </update>
18
 
22
 
19
     <select id="recordSuccessList" resultType="com.huiju.estateagents.entity.TaShareRecord">
23
     <select id="recordSuccessList" resultType="com.huiju.estateagents.entity.TaShareRecord">