puzhibing
2 天以前 ea7595c4c75926f85388574b261b8ba90cf60e0d
ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/WarnMapper.xml
@@ -30,6 +30,9 @@
         <if test="null != item.warnType and '' != item.warnType">
            and a.warn_type = #{item.warnType}
         </if>
         <if test="null != item.carType and '' != item.carType">
            and b.operate_type = #{item.carType}
         </if>
         <if test="null != item.vehicleNumber and '' != item.vehicleNumber">
            and b.vehicle_number like CONCAT('%', #{item.vehicleNumber}, '%')
         </if>
@@ -51,7 +54,43 @@
      </where>
      order by a.create_time desc
   </select>
   <select id="getAllCarWarnList" resultType="com.ruoyi.system.api.model.Warn">
      select
      a.*
      from t_warn a
      left join t_car b on (a.car_id = b.id)
      left join t_driver c on (a.driver_id = c.id)
      left join t_enterprise d on (a.enterprise_id = d.id)
      <where>
         <if test="null != item.warnType and '' != item.warnType">
            and a.warn_type = #{item.warnType}
         </if>
         <if test="null != item.carType and '' != item.carType">
            and b.operate_type = #{item.carType}
         </if>
         <if test="null != item.vehicleNumber and '' != item.vehicleNumber">
            and b.vehicle_number like CONCAT('%', #{item.vehicleNumber}, '%')
         </if>
         <if test="null != item.driverName and '' != item.driverName">
            and c.`name` like CONCAT('%', #{item.driverName}, '%')
         </if>
         <if test="null != item.enterpriseName and '' != item.enterpriseName">
            and d.`name` like CONCAT('%', #{item.enterpriseName}, '%')
         </if>
         <if test="null != item.startTime and '' != item.startTime">
            and a.start_time >= #{item.startTime}
         </if>
         <if test="null != item.endTime and '' != item.endTime">
            and a.end_time &lt;= #{item.endTime}
         </if>
         <if test="null != item.treatmentState and '' != item.treatmentState">
            and a.treatment_state = #{item.treatmentState}
         </if>
      </where>
   </select>
   
   <select id="getWarnGroup10Count" resultType="map">
      select aa.warn_type as warnType, aa.num
@@ -72,8 +111,43 @@
      select *
      from (select COUNT(1) as num, b.`name`
            from t_warn a
                    left join t_enterprise b on (a.enterprise_id = b.id)
            group by a.enterprise_id) as aa
           left join t_enterprise b on (a.enterprise_id = b.id)
            group by a.enterprise_id) as aa where aa.num > 0
      order by aa.num desc limit 10
   </select>
   <select id="getAllWarnGroupVehicleType" resultType="map">
      select
      ct.name,
      ifnull(aa.total, 0) as total,
      ifnull(bb.total, 0) as processed,
      ifnull(cc.total, 0) as unprocessed
      from t_car_type as ct
      left join (
         select
         b.operate_type,
         count(1) as total
         from t_warn a
         left join t_car b on (a.car_id = b.id)
         where a.car_id is not null group by b.operate_type
      ) aa on (ct.name = aa.operate_type)
      left join (
         select
         b.operate_type,
         count(1) as total
         from t_warn a
         left join t_car b on (a.car_id = b.id)
         where a.car_id is not null and a.treatment_state = '已处理' group by b.operate_type
      ) as bb on (ct.name = bb.operate_type)
      left join (
         select
         b.operate_type,
         count(1) as total
         from t_warn a
         left join t_car b on (a.car_id = b.id)
         where a.car_id is not null and a.treatment_state = '处理中' group by b.operate_type
      ) as cc on (ct.name = cc.operate_type)
   </select>
</mapper>