傅行帆 3 anni fa
parent
commit
ad29bd0b8d

+ 3
- 1
src/main/java/com/yunzhi/marketing/service/impl/TaPersonFromRecordServiceImpl.java Vedi File

74
     public void personFromStatistic() {
74
     public void personFromStatistic() {
75
         List<TsPersonFromStatistic> list =  taPersonFromRecordMapper.getNowDataList();
75
         List<TsPersonFromStatistic> list =  taPersonFromRecordMapper.getNowDataList();
76
         tsPersonFromStatisticMapper.deleteByData();
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 Vedi File

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