hjg
2024-03-18 8d48c59d5d3bcc4148ef97dc6f98e3a8cf9ca436
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?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.BusinessMapper">
    <select id="getbslist" parameterType="java.util.Map" resultType="java.util.Map"  >
        <choose>
            <when test="pagesize &gt; 0 ">
                select top ${pagesize} *
            </when>
            <otherwise>
                select * 
            </otherwise>
        </choose>
        from ( select row_number()
        <choose>
            <when test="sort!=null and sort!='' ">
                over (order by min(${sort}) )
            </when>
            <otherwise>
                over (order by min(a.ctime) desc )
            </otherwise> 
        </choose>
        as rownumber,MIN(a.id) id,min(a.bsNo) bsNo,min(a.companyName) companyName,min(a.companyNo) companyNo
        ,min(a.createid) createid,min(a.createName) createName,min(a.ctime) ctime,min(a.driver) driver
        ,min(a.fdsheetNo) fdsheetNo,min(a.invitecode) invitecode,min(a.phone) phone,min(a.sdepartNo) sdepartNo
        ,min('') sendmsg,min(a.shdw) shdw,min(a.status) status,min(a.vehicleId) vehicleId,min(a.bsNo) bussinessNo
        ,min(a.status) sstatus,min('产品销售') name,min('') dcompany,min(a.shdw) rcompany
        ,min('businesstype00002') businesstypeNo,min('') instanceID,min('') canedit,min(0) fdnum,min(0) fdweight
        ,min(0) fdCnum,min(0) fdCweight, ('false') hasCard,max(vq.xspdindx) xspdindx
         from fd_bsheet a left join fd_company_vehicle v on a.vehicleId=v.vehicleId and a.sdepartNo=v.sdepartNo
        left join vehicle_queuing vq on vq.numberplates=a.vehicleId and (a.sdepartNo=vq.sdepartNo or vq.sdepartNO is null)
        <where>
             a.status='在办' 
             <if test="cqV !=null and cqV !='' ">
                     and a.sdepartNo=#{cqV}
                 </if>
            <if test="companyNo !=null and companyNo !='' ">
                and v.companyNo=#{companyNo} and v.vehicleId !='' and v.vehicleId is not null 
            </if>
            <if test="vehicleId !=null and vehicleId !='' ">
                and v.vehicleId like '%'+#{vehicleId}+'%'
            </if>
        </where>
         GROUP BY a.bsNo  
        ) as a where rownumber > #{pagesize}*#{page}
    </select>
    
    <select id="getbspages" parameterType="java.util.Map" resultType="int" >
        select count(DISTINCT(a.bsNo)) 
        from fd_bsheet a left join  fd_company_vehicle v on a.vehicleId=v.vehicleId  and a.sdepartNo=v.sdepartNo 
        <!-- <choose>
             <when test=" companyNo !=null and companyNo !='' ">
                 left join fd_company_vehicle v on a.vehicleId=v.vehicleId 
                 <if test="cqV !=null and cqV !='' " >    
                    <choose>
                        <when test="cqV=='03' || cqV=='05' ">
                            and v.sdepartNo=#{cqV}
                        </when>
                        <otherwise>
                            and v.sdepartNo !='03' and v.sdepartNo !='05'
                        </otherwise>
                    </choose>
                </if>
             </when>
             <otherwise>
                 left join  fd_company_vehicle v on a.vehicleId=v.vehicleId  and a.sdepartNo=v.sdepartNo 
                     <if test="cqV !=null and cqV !='' " >    
                    <choose>
                        <when test="cqV=='03' || cqV=='05' ">
                            and v.sdepartNo=#{cqV}
                        </when>
                        <otherwise>
                            and v.sdepartNo !='03' and v.sdepartNo !='05'
                        </otherwise>
                    </choose>
                </if>
             </otherwise>
         </choose> -->
        <where>
            a.status='在办' 
            <if test="cqV !=null and cqV !='' ">
                     and a.sdepartNo=#{cqV}
             </if>
            <!-- <if test='cqV &gt;= 0'>    
                <choose>
                    <when test="cqV==0">
                        and a.sdepartNo!='03'
                    </when>
                    <otherwise>
                        and a.sdepartNo='03'
                    </otherwise>
                </choose>
            </if> -->
            <if test="companyNo !=null and companyNo !='' ">
                and v.companyNo=#{companyNo} and v.vehicleId !='' and v.vehicleId is not null 
            </if>
            <if test="vehicleId !=null and vehicleId !='' ">
                and v.vehicleId= #{vehicleId}
            </if>
        </where>
    </select>
</mapper>