魏熙美 5 år sedan
förälder
incheckning
3802bda763
1 ändrade filer med 5 tillägg och 5 borttagningar
  1. 5
    5
      src/main/resources/mapper/TaPersonMapper.xml

+ 5
- 5
src/main/resources/mapper/TaPersonMapper.xml Visa fil

418
         FROM
418
         FROM
419
         (
419
         (
420
             SELECT
420
             SELECT
421
-            DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date,
421
+            DATE_FORMAT( DATE_SUB( <if test="endDate != null">#{endDate}</if><if test="endDate == null">now()</if>, INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date,
422
             tempf.from_name as from_name,
422
             tempf.from_name as from_name,
423
             tempf.from_code as from_code
423
             tempf.from_code as from_code
424
             FROM
424
             FROM
438
         (
438
         (
439
             SELECT
439
             SELECT
440
                 ifnull(COUNT(1), 0) as count,
440
                 ifnull(COUNT(1), 0) as count,
441
-                tps.create_date as create_date,
441
+                DATE_FORMAT( tps.create_date, '%Y-%m-%d' ) as create_date,
442
                 tpfs.from_code as from_code,
442
                 tpfs.from_code as from_code,
443
                 tpfs.from_name as from_name
443
                 tpfs.from_name as from_name
444
             FROM ta_person tps
444
             FROM ta_person tps
449
             and tps.person_type IN ('customer','drift','estate agent')
449
             and tps.person_type IN ('customer','drift','estate agent')
450
             AND tps.create_date BETWEEN #{startDate} AND #{endDate}
450
             AND tps.create_date BETWEEN #{startDate} AND #{endDate}
451
 
451
 
452
-            GROUP BY tpfs.from_code
452
+            GROUP BY tpfs.from_code, DATE_FORMAT( tps.create_date, '%Y-%m-%d' )
453
         ) as user_count
453
         ) as user_count
454
         ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') =  temp_date.date and temp_date.from_code = user_count.from_code
454
         ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') =  temp_date.date and temp_date.from_code = user_count.from_code
455
         LEFT JOIN
455
         LEFT JOIN
456
         (
456
         (
457
             SELECT
457
             SELECT
458
                 ifnull(COUNT(1), 0) as count,
458
                 ifnull(COUNT(1), 0) as count,
459
-                tps.create_date as create_date,
459
+                DATE_FORMAT( tps.create_date, '%Y-%m-%d' ) as create_date,
460
                 tpfs.from_code as from_code,
460
                 tpfs.from_code as from_code,
461
                 tpfs.from_name as from_name
461
                 tpfs.from_name as from_name
462
             FROM ta_person tps
462
             FROM ta_person tps
467
                 and tps.person_type IN ('customer','drift','estate agent')
467
                 and tps.person_type IN ('customer','drift','estate agent')
468
                 AND tps.create_date BETWEEN #{startDate} AND #{endDate}
468
                 AND tps.create_date BETWEEN #{startDate} AND #{endDate}
469
                 and tps.phone is not null
469
                 and tps.phone is not null
470
-            GROUP BY tpfs.from_code
470
+            GROUP BY tpfs.from_code,DATE_FORMAT( tps.create_date, '%Y-%m-%d' )
471
         ) as registered_count
471
         ) as registered_count
472
         ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') =  temp_date.date and temp_date.from_code = registered_count.from_code
472
         ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') =  temp_date.date and temp_date.from_code = registered_count.from_code
473
         order by temp_date.date DESC
473
         order by temp_date.date DESC