傅行帆 3 年前
父节点
当前提交
ad29bd0b8d

+ 3
- 1
src/main/java/com/yunzhi/marketing/service/impl/TaPersonFromRecordServiceImpl.java 查看文件

@@ -74,6 +74,8 @@ public class TaPersonFromRecordServiceImpl extends ServiceImpl<TaPersonFromRecor
74 74
     public void personFromStatistic() {
75 75
         List<TsPersonFromStatistic> list =  taPersonFromRecordMapper.getNowDataList();
76 76
         tsPersonFromStatisticMapper.deleteByData();
77
-        tsPersonFromStatisticMapper.insertStatisticList(list);
77
+        if (list.size() > 0){
78
+            tsPersonFromStatisticMapper.insertStatisticList(list);
79
+        }
78 80
     }
79 81
 }

+ 17
- 21
src/main/resources/mapper/TsConsultantKpiMapper.xml 查看文件

@@ -6,8 +6,8 @@
6 6
     <select id="stsKPIDaily" resultType="com.yunzhi.marketing.entity.TsConsultantKpi">
7 7
         SELECT * FROM (
8 8
             SELECT
9
-                1 AS serial_no,
10
-                '2020' AS statis_date,
9
+                t.serial_no,
10
+                SUBSTR(t.statis_date,1,4),
11 11
                 t.org_id,
12 12
                 t.building_id,
13 13
                 t.building_name,
@@ -27,15 +27,13 @@
27 27
                  where s.org_id = t.org_id and (s.realty_consultant = t.user_id or s.realty_consultant = m.person_id)
28 28
                  and (s.building_id = t.building_id or IFNULL(t.building_id, '') = '')
29 29
                  and s.status > 0
30
-<!--                 AND s.create_date BETWEEN STR_TO_DATE( #{startDate}, '%Y%m%d' )-->
31
-<!--                 AND  STR_TO_DATE(concat(#{endDate}, '235959'), '%Y%m%d%H%i%s')-->
32 30
                 ) as total_persons
33 31
             FROM
34 32
                 ts_consultant_kpi t
35 33
             LEFT JOIN ta_person m on m.org_id = #{orgId} and m.user_id = t.user_id
36 34
             WHERE
37 35
                 t.org_id = #{orgId}
38
-                AND t.statis_date BETWEEN #{startDate} AND #{endDate}
36
+                AND t.statis_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
39 37
             <if test="buildingIds != null">
40 38
                 AND t.building_id in
41 39
                 <foreach item="buildingId" index="index" collection="buildingIds"
@@ -59,8 +57,8 @@
59 57
     <!-- 按照小程序分组统计, 注意查询与分组条件, 必须与之前的汇总,导出一致 -->
60 58
     <select id="stsKPITotalByOrg" resultType="com.yunzhi.marketing.entity.TsConsultantKpi">
61 59
         SELECT
62
-            1 AS serial_no,
63
-            '2020' AS statis_date,
60
+            t.serial_no,
61
+            SUBSTR(t.statis_date,1,4),
64 62
             t.org_id,
65 63
             '' as building_id,
66 64
             '-' as building_name,
@@ -82,7 +80,7 @@
82 80
             ts_consultant_kpi t
83 81
         WHERE
84 82
             t.org_id = #{orgId}
85
-            AND t.statis_date BETWEEN #{startDate} AND #{endDate}
83
+            AND t.statis_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
86 84
         <if test="buildingIds != null">
87 85
             AND t.building_id in
88 86
             <foreach item="buildingId" index="index" collection="buildingIds"
@@ -95,8 +93,8 @@
95 93
     <!-- 导出 -->
96 94
     <select id="stsKPIDailyExport" resultType="com.yunzhi.marketing.excel.ConsultantKPIExport">
97 95
         SELECT
98
-            1 AS serial_no,
99
-            '2020' AS statis_date,
96
+            t.serial_no,
97
+            SUBSTR(t.statis_date,1,4),
100 98
             t.org_id,
101 99
             t.building_id,
102 100
             t.building_name,
@@ -119,7 +117,7 @@
119 117
         LEFT JOIN ta_person m on m.org_id = #{orgId} and m.user_id = t.user_id
120 118
         WHERE
121 119
             t.org_id = #{orgId}
122
-        AND t.statis_date BETWEEN #{startDate} AND #{endDate}
120
+        AND t.statis_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
123 121
     <if test="buildingIds != null">
124 122
         AND t.building_id in
125 123
         <foreach item="buildingId" index="index" collection="buildingIds"
@@ -146,8 +144,6 @@
146 144
         WHERE
147 145
             p.org_id = #{orgId}
148 146
             AND p.`status` > 0
149
-<!--            AND p.create_date BETWEEN STR_TO_DATE( #{startDate}, '%Y%m%d')-->
150
-<!--            AND  STR_TO_DATE(concat(#{endDate}, '235959'), '%Y%m%d%H%i%s')-->
151 147
         <if test="buildingIds != null">
152 148
             AND t.building_id in
153 149
             <foreach item="buildingId" index="index" collection="buildingIds"
@@ -169,7 +165,7 @@
169 165
             AND e.building_id = #{buildingId}
170 166
         </if>
171 167
         AND e.target_type is not null
172
-        AND e.create_date BETWEEN #{startDate} and #{endDate}
168
+        AND e.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
173 169
         AND e.is_project_first = 1
174 170
         AND s.user_id = #{userId}
175 171
 
@@ -197,7 +193,7 @@
197 193
             AND f.building_id = #{buildingId}
198 194
         </if>
199 195
             AND f.event_type = 'card'
200
-            AND f.visit_time BETWEEN #{startDate} and #{endDate}
196
+            AND f.visit_time BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
201 197
             AND s.user_id = #{userId}
202 198
 
203 199
 <!--        为了与存储过程一致 -->
@@ -222,7 +218,7 @@
222 218
             AND f.building_id = #{buildingId}
223 219
         </if>
224 220
             AND f.event_type = 'card'
225
-            AND f.visit_time BETWEEN #{startDate} and #{endDate}
221
+            AND f.visit_time BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
226 222
             AND s.user_id = #{userId}
227 223
 
228 224
 <!--        为了与存储过程一致 -->
@@ -245,7 +241,7 @@
245 241
 
246 242
 <!--        为了与存储过程一致 -->
247 243
 <!--            AND t.`status` = 1-->
248
-            AND h.create_date BETWEEN #{startDate} and #{endDate}
244
+            AND h.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
249 245
             AND s.user_id = #{userId}
250 246
 
251 247
 <!--        为了与存储过程一致 -->
@@ -269,7 +265,7 @@
269 265
 <!--        为了与存储过程一致 -->
270 266
 <!--            AND t.`status` = 1-->
271 267
             AND i.tagert_type = 'consultant'
272
-            AND i.create_date BETWEEN #{startDate} and #{endDate}
268
+            AND i.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
273 269
             AND s.user_id = #{userId}
274 270
 
275 271
 <!--        为了与存储过程一致 -->
@@ -306,7 +302,7 @@
306 302
             AND t.tagert_type like concat(#{targetType}, '%')
307 303
         </if>
308 304
 
309
-            AND t.create_date BETWEEN #{startDate} and #{endDate}
305
+            AND t.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
310 306
         <if test="targetName != null and targetName !=''">
311 307
             AND t.target_name LIKE concat('%', #{targetName}, '%')
312 308
         </if>
@@ -326,7 +322,7 @@
326 322
         INNER JOIN ta_person t ON t.person_id = e.person_id
327 323
         WHERE e.org_id = #{orgId}
328 324
             AND e.share_person = #{userId}
329
-            AND e.create_date BETWEEN #{startDate} and #{endDate}
325
+            AND e.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
330 326
             AND (
331 327
                 e.target_type IN ( 'card_share', 'building_share', 'dynamic_share', 'group_share', 'h5_share', 'help_share', 'house_share', 'live_share', 'news_share', 'poster' )
332 328
                 OR ( e.target_type = 'share' AND e.target_id = 'index' )
@@ -371,7 +367,7 @@
371 367
             AND e.target_name like concat('%', #{targetName} ,'%')
372 368
         </if>
373 369
 
374
-            AND e.create_date BETWEEN #{startDate} and #{endDate}
370
+            AND e.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y%m%d' )  AND DATE_FORMAT(#{endDate}, '%Y%m%d' )
375 371
 
376 372
         <if test="buildingId != null and buildingId !=''">
377 373
             AND e.building_id = #{buildingId}