<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.njzscloud.supervisory.sys.stationletter.mapper.StationLetterMapper">

    <resultMap id="StationLetterResultMap" type="com.njzscloud.supervisory.sys.stationletter.pojo.StationLetterEntity">
        <id property="id" column="id"/>
        <result property="warnCategoryName" column="warn_category_name"/>
        <result property="warnCategory" column="warn_category"/>
        <result property="licensePlate" column="license_plate"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <select id="selectPendingWarnList" resultMap="StationLetterResultMap">
        SELECT 
            bw.id,
            bw.warn_category,
            bt.license_plate,
            bw.create_time
        FROM biz_warn bw
        LEFT JOIN order_info oi ON bw.order_id = oi.id AND oi.deleted = 0
        LEFT JOIN biz_truck bt ON oi.truck_id = bt.id AND bt.deleted = 0
        WHERE bw.process_status = 'PENDING'
          AND bw.deleted = 0
        ORDER BY bw.create_time DESC
    </select>

    <!-- 查询待审核的公司数量 -->
    <select id="selectPendingCompanyCount" resultType="int">
        SELECT COUNT(*)
        FROM biz_company
        WHERE deleted = 0 AND audit_status = 'DaiShenHe'
    </select>

    <!-- 查询待审核的车辆数量 -->
    <select id="selectPendingTruckCount" resultType="int">
        SELECT COUNT(*)
        FROM biz_truck
        WHERE deleted = 0 AND audit_status = 'DaiShenHe'
    </select>

    <!-- 查询待审核的项目数量 -->
    <select id="selectPendingProjectCount" resultType="int">
        SELECT COUNT(*)
        FROM biz_project
        WHERE deleted = 0 AND audit_status = 'DaiShenHe'
    </select>

    <!-- 查询待审核的司机数量 -->
    <select id="selectPendingDriverCount" resultType="int">
        SELECT COUNT(*)
        FROM biz_driver
        WHERE deleted = 0 AND audit_status = 'DaiShenHe'
    </select>

    <!-- 查询待审核的订单数量 -->
    <select id="selectPendingOrderCount" resultType="int">
        SELECT COUNT(*)
        FROM order_info
        WHERE deleted = 0 AND audit_status = 'DaiShenHe'
    </select>

</mapper>
