<?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.mandi.fendan.mapper.Fd_VehicleMapper">
|
<select id="getList1" parameterType="java.util.Map" resultType="java.util.Map">
|
<choose>
|
<when test="pagesize > 0 ">
|
select top ${pagesize} *
|
</when>
|
<otherwise>
|
select *
|
</otherwise>
|
</choose> from ( select row_number()
|
<choose>
|
<when test="sort!=null and sort!='' ">
|
over (order by ${sort} )
|
</when>
|
<otherwise>
|
over (order by a.id desc )
|
</otherwise>
|
</choose>
|
as rownumber,a.*,b.name as companyName from fd_vehicle a left join fd_company b on a.companyNo=b.companyNo
|
<where>
|
<if test="type !=null ">
|
and a.type=#{type}
|
</if>
|
<if test="status !=null ">
|
and a.status=#{status}
|
</if>
|
<if test="state !=null ">
|
and a.state=#{state}
|
</if>
|
<if test="companyNo !=null and companyNo !='' ">
|
and a.companyNo =#{companyNo}
|
</if>
|
<if test="vehicleId !=null and vehicleId !='' ">
|
and a.vehicleId like '%'+#{vehicleId}+'%'
|
</if>
|
</where>
|
) as a where rownumber > #{pagesize}*#{page}
|
</select>
|
<select id="getList2" parameterType="java.util.Map" resultType="java.util.Map">
|
<choose>
|
<when test="pagesize > 0 ">
|
select top ${pagesize} *
|
</when>
|
<otherwise>
|
select *
|
</otherwise>
|
</choose>
|
from ( select row_number()
|
<choose>
|
<when test="sort!=null and sort!='' ">
|
over (order by ${sort} )
|
</when>
|
<otherwise>
|
over (order by a.id desc )
|
</otherwise>
|
</choose>
|
as rownumber,a.*,b.name as companyName from fd_vehicle a left join fd_company b on a.companyNo=b.companyNo
|
<where>
|
<if test="type !=null ">
|
and a.type=#{type}
|
</if>
|
<if test="status !=null ">
|
and a.status=#{status}
|
</if>
|
<if test="companyNo !=null and companyNo !='' ">
|
and a.companyNo =#{companyNo}
|
</if>
|
<if test="vehicleId !=null and vehicleId !='' ">
|
and a.vehicleId like '%'+#{vehicleId}+'%'
|
</if>
|
</where>
|
) as a where rownumber > #{pagesize}*#{page}
|
|
</select>
|
|
<select id="getPages" parameterType="Map" resultType="int">
|
select count(1) from fd_vehicle a left join fd_company b on a.companyNo=b.companyNo
|
<where>
|
<if test="type !=null ">
|
and a.type=#{type}
|
</if>
|
<if test="status !=null ">
|
and a.status=#{status}
|
</if>
|
<if test="companyNo !=null and companyNo !='' ">
|
and a.companyNo =#{companyNo}
|
</if>
|
<if test="vehicleId !=null and vehicleId !='' ">
|
and a.vehicleId like '%'+#{vehicleId}+'%'
|
</if>
|
</where>
|
</select>
|
|
<select id="getCompanyVehicle" parameterType="map" resultType="map">
|
SELECT top 5 a.*,0 fdCnum,0 fdCweight,0 fdnum,0 fdweight from fd_vehicle a
|
<where>
|
a.type='公司车'
|
<choose>
|
<when test="companyNo !=null and companyNo !='' ">
|
and a.companyNo =#{companyNo}
|
</when>
|
<otherwise>
|
and ( a.companyNo is null or a.companyNo='')
|
</otherwise>
|
</choose>
|
<if test="vehicleId!=null and vehicleId!=''">
|
and a.vehicleId like '%'+#{vehicleId}+'%'
|
</if>
|
</where>
|
UNION ALL
|
SELECT top 5 a.*,0 fdCnum,0 fdCweight,0 fdnum,0 fdweight from fd_vehicle a LEFT JOIN fd_company_vehicle b on a.vehicleId=b.vehicleId
|
<where>
|
a.type='临时车'
|
<choose>
|
<when test="companyNo !=null and companyNo !='' ">
|
and b.companyNo =#{companyNo}
|
</when>
|
<otherwise>
|
and ( a.companyNo is null or a.companyNo='')
|
</otherwise>
|
</choose>
|
<if test="vehicleId!=null and vehicleId!=''">
|
and a.vehicleId like '%'+#{vehicleId}+'%'
|
</if>
|
</where>
|
</select>
|
</mapper>
|