|
@@ -562,9 +562,173 @@
|
562
|
562
|
<if test="buildingId != null and buildingId != '' ">
|
563
|
563
|
AND t.building_id = #{buildingId}
|
564
|
564
|
</if>
|
565
|
|
-<!-- <if test="sortField != null and sortField != ''">-->
|
566
|
|
-<!-- ORDER BY ${sortField} ${orderType}-->
|
567
|
|
-<!-- </if>-->
|
|
565
|
+ </select>
|
|
566
|
+ <select id="getStatsTimeBarList" resultType="com.huiju.estateagents.excel.StatsTimeBuilding">
|
|
567
|
+ SELECT
|
|
568
|
+ t.date as create_date,
|
|
569
|
+ IFNULL( s.sk_num, 0 ) AS sk_num,
|
|
570
|
+ IFNULL( g.gk_num, 0 ) AS gk_num,
|
|
571
|
+ IFNULL( u.uv_num, 0 ) AS uv_num,
|
|
572
|
+ IFNULL( s.sk_num, 0 ) + IFNULL( g.gk_num, 0 ) AS kh_num
|
|
573
|
+ FROM
|
|
574
|
+ (
|
|
575
|
+ SELECT
|
|
576
|
+ DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
|
|
577
|
+ FROM
|
|
578
|
+ sequence a
|
|
579
|
+ WHERE
|
|
580
|
+ a.rownum <= datediff( #{endDate}, #{startDate} )
|
|
581
|
+ ) t
|
|
582
|
+ LEFT JOIN (
|
|
583
|
+ SELECT
|
|
584
|
+ count( * ) AS sk_num,
|
|
585
|
+ a.building_id,
|
|
586
|
+ DATE_FORMAT( a.create_date, '%Y-%m-%d' ) AS create_date
|
|
587
|
+ FROM
|
|
588
|
+ ta_recommend_customer a
|
|
589
|
+ WHERE
|
|
590
|
+ a.STATUS > 0
|
|
591
|
+ AND a.verify_status = 1
|
|
592
|
+ AND a.realty_consultant IS NOT NULL
|
|
593
|
+ AND a.realty_consultant != ''
|
|
594
|
+ AND a.org_id = #{orgId}
|
|
595
|
+ AND a.building_id = #{buildingId}
|
|
596
|
+ <if test="startDate != null">
|
|
597
|
+ and TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
|
|
598
|
+ </if>
|
|
599
|
+ <if test="endDate != null">
|
|
600
|
+ and TO_DAYS(a.create_date) <= TO_DAYS(#{endDate})
|
|
601
|
+ </if>
|
|
602
|
+ GROUP BY
|
|
603
|
+ DATE_FORMAT( a.create_date, '%Y-%m-%d' )
|
|
604
|
+ ) s ON t.date = s.create_date
|
|
605
|
+ LEFT JOIN (
|
|
606
|
+ SELECT
|
|
607
|
+ count( * ) AS gk_num,
|
|
608
|
+ b.building_id,
|
|
609
|
+ DATE_FORMAT( b.create_date, '%Y-%m-%d' ) AS create_date
|
|
610
|
+ FROM
|
|
611
|
+ ta_person b
|
|
612
|
+ WHERE
|
|
613
|
+ b.STATUS > 0
|
|
614
|
+ AND b.org_id = #{orgId}
|
|
615
|
+ AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
|
|
616
|
+ AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = 84 AND person_id IS NOT NULL AND person_id != '' )
|
|
617
|
+ AND b.building_id = #{buildingId}
|
|
618
|
+ <if test="startDate != null">
|
|
619
|
+ and TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
|
|
620
|
+ </if>
|
|
621
|
+ <if test="endDate != null">
|
|
622
|
+ and TO_DAYS(b.create_date) <= TO_DAYS(#{endDate})
|
|
623
|
+ </if>
|
|
624
|
+ GROUP BY
|
|
625
|
+ b.person_id,
|
|
626
|
+ DATE_FORMAT( b.create_date, '%Y-%m-%d' )
|
|
627
|
+ ) g ON t.date = g.create_date
|
|
628
|
+ LEFT JOIN (
|
|
629
|
+ SELECT
|
|
630
|
+ count( * ) AS uv_num,
|
|
631
|
+ be_uv AS building_id,
|
|
632
|
+ DATE_FORMAT( create_date, '%Y-%m-%d' ) AS create_date
|
|
633
|
+ FROM
|
|
634
|
+ ta_uv
|
|
635
|
+ WHERE
|
|
636
|
+ tagert_type = 'project'
|
|
637
|
+ AND be_uv = #{buildingId}
|
|
638
|
+ <if test="startDate != null">
|
|
639
|
+ and TO_DAYS(create_date) >= TO_DAYS(#{startDate})
|
|
640
|
+ </if>
|
|
641
|
+ <if test="endDate != null">
|
|
642
|
+ and TO_DAYS(create_date) <= TO_DAYS(#{endDate})
|
|
643
|
+ </if>
|
|
644
|
+ GROUP BY
|
|
645
|
+ DATE_FORMAT( create_date, '%Y-%m-%d' )
|
|
646
|
+ ) u ON t.date = u.create_date
|
|
647
|
+ </select>
|
|
648
|
+ <select id="getStatsTimeTableList" resultType="com.huiju.estateagents.excel.StatsTimeBuilding">
|
|
649
|
+ SELECT
|
|
650
|
+ t.date as create_date,
|
|
651
|
+ IFNULL( s.sk_num, 0 ) AS sk_num,
|
|
652
|
+ IFNULL( g.gk_num, 0 ) AS gk_num,
|
|
653
|
+ IFNULL( u.uv_num, 0 ) AS uv_num,
|
|
654
|
+ IFNULL( s.sk_num, 0 ) + IFNULL( g.gk_num, 0 ) AS kh_num
|
|
655
|
+ FROM
|
|
656
|
+ (
|
|
657
|
+ SELECT
|
|
658
|
+ DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
|
|
659
|
+ FROM
|
|
660
|
+ sequence a
|
|
661
|
+ WHERE
|
|
662
|
+ a.rownum <= datediff( #{endDate}, #{startDate} )
|
|
663
|
+ ) t
|
|
664
|
+ LEFT JOIN (
|
|
665
|
+ SELECT
|
|
666
|
+ count( * ) AS sk_num,
|
|
667
|
+ a.building_id,
|
|
668
|
+ DATE_FORMAT( a.create_date, '%Y-%m-%d' ) AS create_date
|
|
669
|
+ FROM
|
|
670
|
+ ta_recommend_customer a
|
|
671
|
+ WHERE
|
|
672
|
+ a.STATUS > 0
|
|
673
|
+ AND a.verify_status = 1
|
|
674
|
+ AND a.realty_consultant IS NOT NULL
|
|
675
|
+ AND a.realty_consultant != ''
|
|
676
|
+ AND a.org_id = #{orgId}
|
|
677
|
+ AND a.building_id = #{buildingId}
|
|
678
|
+ <if test="startDate != null">
|
|
679
|
+ and TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
|
|
680
|
+ </if>
|
|
681
|
+ <if test="endDate != null">
|
|
682
|
+ and TO_DAYS(a.create_date) <= TO_DAYS(#{endDate})
|
|
683
|
+ </if>
|
|
684
|
+ GROUP BY
|
|
685
|
+ DATE_FORMAT( a.create_date, '%Y-%m-%d' )
|
|
686
|
+ ) s ON t.date = s.create_date
|
|
687
|
+ LEFT JOIN (
|
|
688
|
+ SELECT
|
|
689
|
+ count( * ) AS gk_num,
|
|
690
|
+ b.building_id,
|
|
691
|
+ DATE_FORMAT( b.create_date, '%Y-%m-%d' ) AS create_date
|
|
692
|
+ FROM
|
|
693
|
+ ta_person b
|
|
694
|
+ WHERE
|
|
695
|
+ b.STATUS > 0
|
|
696
|
+ AND b.org_id = #{orgId}
|
|
697
|
+ AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
|
|
698
|
+ AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = 84 AND person_id IS NOT NULL AND person_id != '' )
|
|
699
|
+ AND b.building_id = #{buildingId}
|
|
700
|
+ <if test="startDate != null">
|
|
701
|
+ and TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
|
|
702
|
+ </if>
|
|
703
|
+ <if test="endDate != null">
|
|
704
|
+ and TO_DAYS(b.create_date) <= TO_DAYS(#{endDate})
|
|
705
|
+ </if>
|
|
706
|
+ GROUP BY
|
|
707
|
+ b.person_id,
|
|
708
|
+ DATE_FORMAT( b.create_date, '%Y-%m-%d' )
|
|
709
|
+ ) g ON t.date = g.create_date
|
|
710
|
+ LEFT JOIN (
|
|
711
|
+ SELECT
|
|
712
|
+ count( * ) AS uv_num,
|
|
713
|
+ be_uv AS building_id,
|
|
714
|
+ DATE_FORMAT( create_date, '%Y-%m-%d' ) AS create_date
|
|
715
|
+ FROM
|
|
716
|
+ ta_uv
|
|
717
|
+ WHERE
|
|
718
|
+ tagert_type = 'project'
|
|
719
|
+ AND be_uv = #{buildingId}
|
|
720
|
+ <if test="startDate != null">
|
|
721
|
+ and TO_DAYS(create_date) >= TO_DAYS(#{startDate})
|
|
722
|
+ </if>
|
|
723
|
+ <if test="endDate != null">
|
|
724
|
+ and TO_DAYS(create_date) <= TO_DAYS(#{endDate})
|
|
725
|
+ </if>
|
|
726
|
+ GROUP BY
|
|
727
|
+ DATE_FORMAT( create_date, '%Y-%m-%d' )
|
|
728
|
+ ) u ON t.date = u.create_date
|
|
729
|
+ <if test="sortField != null and sortField != ''">
|
|
730
|
+ ORDER BY ${sortField} ${orderType}
|
|
731
|
+ </if>
|
568
|
732
|
</select>
|
569
|
733
|
|
570
|
734
|
</mapper>
|