luodangjia
2024-09-30 d8786c8c3b5084bdad9ef318d056d81579e622f0
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -191,7 +191,7 @@
                        AND o.code LIKE CONCAT('%',#{data.code},'%')
                    </if>
                    <if test="data.phone != null and data.phone != ''">
                        AND o.phone LIKE CONCAT('%',#{data.phone},'%')
                        AND i.phone LIKE CONCAT('%',#{data.phone},'%')
                    </if>
                    <if test="data.type != null">
                        AND o.type = #{data.type}
@@ -211,7 +211,7 @@
                    <if test="data.isRefund == 1">
                        AND o.refund_status is not null
                    </if>
                    <if test="data.isRefund == 1">
                    <if test="data.isRefund == 2">
                        AND o.refund_status is null
                    </if>
@@ -592,25 +592,10 @@
    </select>
    <select id="usersDay" resultType="java.util.Map">
        SELECT
            'today' AS data_type,
            '1' as type,
            DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME,
   count(DISTINCT  app_user_id) AS counts
        FROM
            t_charging_order
        WHERE
            del_flag = 0
          AND recharge_payment_status = 2
          AND ISNULL( refund_status )
          AND DATE ( create_time ) = CURDATE()
        GROUP BY
            TIME
        UNION all
        SELECT
            'today' AS data_type,
            '2' as type,
            DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME,
            DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time,
   count(1) AS counts
        FROM
            charging_pile_account.t_app_user
@@ -618,47 +603,31 @@
            del_flag = 0
          AND DATE ( create_time ) = CURDATE()
        GROUP BY
            TIME
            time
    </select>
    <select id="usersByQuery" resultType="java.util.Map">
    <select id="usersDay1" resultType="java.util.Map">
        SELECT
            'today' AS data_type,
            '1' as type,
            DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME,
   count(DISTINCT  app_user_id) AS counts
            DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time,
        count(DISTINCT  app_user_id) AS counts
        FROM
            t_charging_order
        WHERE
            del_flag = 0
          AND recharge_payment_status = 2
          AND ISNULL( refund_status )
        <if test="statisticsQueryDto.dayType =1 ">
            AND DATE(create_time) = CURDATE()
        </if>
        <if test="statisticsQueryDto.dayType =2 ">
            AND WEEKOFYEAR(create_time) = WEEKOFYEAR(CURDATE())
        </if>
        <if test="statisticsQueryDto.dayType =3 ">
            AND MONTH(create_time) = MONTH(CURDATE())
        </if>
        <if test="statisticsQueryDto.dayType =4">
          AND YEAR(create_time) = YEAR(CURDATE())
        </if>
        <if test="statisticsQueryDto.dayType =5">
        <if test="statisticsQueryDto.startTime != null">
            AND create_time >= #{statisticsQueryDto.startTime}
        </if>
        <if test="statisticsQueryDto.endTime != null">
            AND create_time &lt;= #{statisticsQueryDto.endTime}
        </if>
        </if>
          AND DATE ( create_time ) = CURDATE()
        GROUP BY
            TIME
        UNION all
            time
    </select>
    <select id="usersByQuery" resultType="java.util.Map">
        SELECT
            'today' AS data_type,
            '2' as type,
            DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME,
            DATE_FORMAT( create_time, '%Y-%m-%d' ) AS time,
   count(1) AS counts
        FROM
            charging_pile_account.t_app_user
@@ -685,43 +654,51 @@
            </if>
        </if>
        GROUP BY
            TIME
            time
    </select>
    <select id="getUserTagCount" resultType="java.util.Map">
        SELECT user_tag_id,COUNT(1) as count from (
        SELECT
            tt.`name`,
            COUNT( 1 ) AS count
        FROM
            (
            SELECT
            a.app_user_id,
            a.user_tag_id,
            a.create_time
            FROM
            charging_pile_account.t_app_user_tag a
            JOIN (
            SELECT
            app_user_id,
            MAX(create_time) AS max_create_time
            FROM
            charging_pile_account.t_app_user_tag
            GROUP BY
            app_user_id
            ) b ON a.app_user_id = b.app_user_id AND a.create_time = b.max_create_time
            JOIN ( SELECT app_user_id, MAX( create_time ) AS max_create_time FROM charging_pile_account.t_app_user_tag GROUP BY app_user_id ) b ON a.app_user_id = b.app_user_id
            AND a.create_time = b.max_create_time
            ) o
        GROUP BY o.user_tag_id
            LEFT JOIN `charging_pile_other`.`t_user_tag` tt on o.user_tag_id = tt.id
        GROUP BY
            tt.name
    </select>
    <select id="getVipCount" resultType="java.util.Map">
        SELECT vip_id,count(1) as Counts
        FROM charging_pile_account.t_app_user
        WHERE del_flag = 0
        GROUP BY vip_id
        SELECT
            tv.`name`,
            count(1) AS Counts
        FROM
            charging_pile_account.t_app_user  ta
                LEFT JOIN `charging_pile_other`.`t_vip` tv on ta.vip_id = tv.id
        WHERE
            ta.del_flag = 0
        GROUP BY
            tv.`name`
    </select>
    <select id="unitConsumption" resultType="java.util.Map">
        SELECT
        tc.`name`,
            au.company_id as companyId,
            SUM( co.charging_capacity )  as chargingCapacity
        FROM
            charging_pile_order.t_charging_order co
                LEFT JOIN charging_pile_account.t_app_user au ON co.app_user_id = au.id
        LEFT JOIN `charging_pile_other`.`t_company` tc on au.company_id = tc.id
        <where>
            co.del_flag = 0
            <if test="statisticsQueryDto.dayType == 1">
@@ -746,7 +723,7 @@
            </if>
        </where>
        GROUP BY
            au.company_id
        tc.`name`, au.company_id
    </select>
    <select id="carUserMethod" resultType="java.util.Map">
        SELECT
@@ -777,13 +754,14 @@
            `t_order_evaluate` te
                LEFT JOIN t_charging_order  co on te.order_id = co.id
        WHERE
             1 = 1
        <if test="siteIds != null and siteIds.size() > 0">
            AND co.site_id IN
            <foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
                #{siteId}
            </foreach>
        </if>
            te.del_flag = 0
           AND  te.del_flag = 0
    </select>
    <select id="getLevelEvaluate" resultType="java.util.Map">
@@ -890,7 +868,7 @@
              source_name as source
            from t_charging_order
            where 1=1
        del_flag = 0
        AND  del_flag = 0
        AND recharge_payment_status = 2
            <if test="siteIds != null and siteIds.size() > 0">
                and site_id IN
@@ -923,7 +901,7 @@
                   </if>
                   ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as siteName
                   ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as siteName
        FROM
            `charging_pile_order`.`t_charging_order` co
                LEFT JOIN  `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id
@@ -983,7 +961,7 @@
        </if>
        ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as siteName
        ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as siteName
        FROM
        `charging_pile_order`.`t_charging_order` co
        LEFT JOIN  `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id
@@ -1040,7 +1018,7 @@
            ))
        </if>
                   ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1
                   ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1
        FROM
            `charging_pile_service`.`t_fault_message` co
                LEFT JOIN  `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id
@@ -1097,7 +1075,7 @@
            ))
        </if>
        ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1
        ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1
        FROM
        `charging_pile_service`.`t_fault_message` co
        LEFT JOIN  `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id
@@ -1154,7 +1132,7 @@
            ))
        </if>
        ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1
        ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1
        FROM
        `charging_pile_service`.`t_fault_message` co
        LEFT JOIN  `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id
@@ -1209,7 +1187,7 @@
            ))
        </if>
        ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1
        ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1
        FROM
        `charging_pile_service`.`t_fault_message` co
        LEFT JOIN  `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id
@@ -1249,13 +1227,14 @@
        SELECT
            FORMAT((SUM(co.current) / SUM(co.need_elec)), 2) AS percent,
            co.charging_gun_id,
            tc.name,
            cp.name AS gun_name
            tc.name as name,
            cp.name AS siteName
        FROM
            `charging_pile_order`.`t_charging_order` co
                LEFT JOIN `charging_pile_service`.`t_charging_gun` tc ON co.charging_gun_id = tc.id
                LEFT JOIN `charging_pile_service`.`t_charging_pile` cp ON tc.charging_pile_id = cp.id
        <where>
            cp.type = 1
            <if test="siteIds != null and siteIds.size() > 0">
                and co.site_id IN
                <foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
@@ -1439,4 +1418,48 @@
    </select>
    <select id="needElec1" resultType="java.util.Map">
        SELECT
        FORMAT((SUM(co.current) / SUM(co.need_elec)), 2) AS percent,
        co.charging_gun_id,
        tc.name as name,
        cp.name AS siteName
        FROM
        `charging_pile_order`.`t_charging_order` co
        LEFT JOIN `charging_pile_service`.`t_charging_gun` tc ON co.charging_gun_id = tc.id
        LEFT JOIN `charging_pile_service`.`t_charging_pile` cp ON tc.charging_pile_id = cp.id
        <where>
            cp.type = 2
            <if test="siteIds != null and siteIds.size() > 0">
                and co.site_id IN
                <foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
                    #{siteId}
                </foreach>
            </if>
            <if test="statisticsQueryDto.dayType == 1">
                AND DATE( co.create_time ) = CURDATE()
            </if>
            <if test="statisticsQueryDto.dayType == 2">
                AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() )
            </if>
            <if test="statisticsQueryDto.dayType == 3">
                AND MONTH( co.create_time ) = MONTH(CURDATE())
            </if>
            <if test="statisticsQueryDto.dayType == 4">
                AND YEAR( co.create_time ) = YEAR(CURDATE() )
            </if>
            <if test="statisticsQueryDto.dayType == 5">
                <if test="statisticsQueryDto.startTime != null">
                    AND co.create_time >= #{statisticsQueryDto.startTime}
                </if>
                <if test="statisticsQueryDto.endTime != null">
                    AND co.create_time &lt;= #{statisticsQueryDto.endTime}
                </if>
            </if>
        </where>
        GROUP BY
        tc.name,
        cp.name,
        co.charging_gun_id;
    </select>
</mapper>