提交 | 用户 | 时间
|
58d006
|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
A |
2 |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
3 |
<mapper namespace="com.mandi.fendan.mapper.Fd_XSTDMapper"> |
|
4 |
<sql id="column"> |
867641
|
5 |
a.td_bmbh,a.td_bmmc,a.td_bz,a.td_djrq,a.td_fpbh, a.td_jylx, a.td_khbh,a.td_cqNo,a.committime, |
58d006
|
6 |
CASE WHEN a.td_fpbh IS NULL THEN b.name WHEN a.td_fpbh= '' THEN b.name |
A |
7 |
WHEN a.td_ywdybh= '101' THEN '河南报关' WHEN a.td_ywdybh= '102' THEN '郑州报关' WHEN a.td_ywdybh= '111' THEN '明晟报关' WHEN a.td_ywdybh= '114' THEN '义瑞报关' ELSE '科技报关' |
|
8 |
END td_khmc, |
|
9 |
a.td_shddbh, |
|
10 |
c.name as td_shdd, |
|
11 |
a.td_tdbh, |
|
12 |
a.td_tdls, |
|
13 |
a.td_wfdsl, |
|
14 |
a.td_wfdzl, |
|
15 |
a.td_zcwcbz, |
|
16 |
a.td_zdrmc td_zdr, |
|
17 |
a.td_zdr as td_zdrbh, |
|
18 |
CASE a.td_ztbz WHEN '1' THEN '含运费送货' WHEN '3' THEN '不含运费送货' ELSE '自提' END td_ztbz, |
|
19 |
a.td_shsj td_shsj, |
|
20 |
a.td_ywdybh, |
|
21 |
d.name as td_ywdyName, |
|
22 |
e.name as dq_name |
|
23 |
</sql> |
|
24 |
<!--查询地区的厂区 --> |
|
25 |
<sql id="sqlDq"> |
|
26 |
ISNULL((select STUFF((select distinct ','+b.name from fd_wlgs_fhdq f left join fd_company b on f.wlgsNo=b.companyNo where f.fhdqNo=a.td_shddbh |
|
27 |
and f.ywdyNo=(case when a.td_ywdybh in ('102','111','114') then a.td_ywdybh else '103' end) |
|
28 |
and EXISTS (SELECT 1 from fd_company_ywdy c where b.companyNo=c.companyNo and c.ywdyNo=a.td_ywdybh ) |
|
29 |
for xml path('') |
|
30 |
),1,1,'' ) ),'') |
|
31 |
</sql> |
|
32 |
<!--查询物流公司的厂区 --> |
|
33 |
<sql id="mxWlgsDq"> |
|
34 |
ISNULL(( select STUFF( ( |
|
35 |
select ','+name from fd_company fdc where EXISTS ( |
|
36 |
select * from fd_mx_wlgs where wlgs_no = fdc.companyNo and td_tdls=a.td_tdls |
|
37 |
) for xml path('') |
|
38 |
),1,1,'' ) ),'') |
|
39 |
</sql> |
|
40 |
|
|
41 |
<!-- 根据地区来决定是否显示 --> |
|
42 |
<sql id="changqu"> |
|
43 |
<if test=" cqV !=null and cqV !='' "> |
|
44 |
<if test="companyNo!=null and companyNo!=''"> <!--要确保是管理员或者是fdAdmin的时候companyNo是空--> |
|
45 |
and ( (a.td_ztbz not in (1,3) and EXISTS ( select * from fd_company_ywdy cy left join fd_company fc on |
|
46 |
cy.companyNo = fc.companyNo where hasSPR=1 and cy.companyNo=#{companyNo} ) ) <!-- 拥有自提权限的只能看到厂区范围的 --> |
|
47 |
or |
|
48 |
(a.td_ztbz in (1,3) and EXISTS (SELECT 1 from fd_wlgs_fhdq b LEFT JOIN nc_dq c on b.fhdqNo=c.code <!-- 拥有非自提权限的只能看到区域范围的 --> |
|
49 |
where c.code=a.td_shddbh and b.wlgsNo=#{companyNo} |
|
50 |
<if test=" cqV !=null and cqV !='' "> |
|
51 |
<choose> |
|
52 |
<when test="cqV=='102' || cqV=='111' || cqV=='114' "> |
|
53 |
and b.ywdyNo=#{cqV} |
|
54 |
</when> |
|
55 |
<otherwise> |
|
56 |
and b.ywdyNo!='102' and b.ywdyNo!='111' and b.ywdyNo!='114' |
|
57 |
</otherwise> |
|
58 |
</choose> |
|
59 |
</if> |
|
60 |
) ) |
|
61 |
) |
|
62 |
</if> |
|
63 |
<choose> |
|
64 |
<when test="cqV=='102' || cqV=='111' || cqV=='114'"> |
|
65 |
and a.td_cqNo=#{cqV} |
|
66 |
</when> |
|
67 |
<otherwise> |
|
68 |
and a.td_cqNo !='102' and a.td_cqNo !='111' and a.td_cqNo !='114' |
|
69 |
</otherwise> |
|
70 |
</choose> |
|
71 |
</if> |
|
72 |
</sql> |
|
73 |
<sql id="condition"> |
|
74 |
<if test="companyNo !=null and companyNo !='' "> |
|
75 |
<choose> |
|
76 |
<when test="ztbz==0"> |
|
77 |
AND a.td_ztbz in (1,3) <!--非自提--> |
|
78 |
</when> |
|
79 |
<otherwise> |
|
80 |
and a.td_ztbz not in (1,3) <!-- 自提 --> |
|
81 |
</otherwise> |
|
82 |
</choose> |
|
83 |
</if> |
|
84 |
<if test="sdate !=null and sdate !='' "> |
|
85 |
and a.td_djrq >= #{sdate}+' 00:00:00' |
|
86 |
</if> |
|
87 |
<if test="edate !=null and edate !='' "> |
|
88 |
and a.td_djrq <= #{edate}+' 23:59:59' |
|
89 |
</if> |
|
90 |
<if test="fdAdmin == null || fdAdmin == '' "> |
|
91 |
<choose> |
|
92 |
<when test="wcSign==0"> |
|
93 |
and a.td_wfdsl > 0 |
|
94 |
</when> |
|
95 |
<otherwise> |
|
96 |
and a.td_wfdsl <= 0 |
|
97 |
</otherwise> |
|
98 |
</choose> |
|
99 |
</if> |
|
100 |
<if test="fdAdmin != null and fdAdmin != '' "> <!-- 在车辆分单页面时 --> |
|
101 |
and ( |
a966b5
|
102 |
(a.td_wfdsl=0 and exists |
H |
103 |
( |
|
104 |
select 1 from fd_xstdmx tdmx where tdmx.tdmx_tdls = a.td_tdls and tdmx.tdmx_gbbz=0 and exists |
|
105 |
(select 1 from bussinesssheet bs where bussinessNo=tdmx.tdmx_fdywbh and cardno is not null and cardno!='' and sstatus='在办') |
|
106 |
) |
58d006
|
107 |
) <!-- 全部分单,则车辆有未发卡显示 --> |
A |
108 |
or a.td_wfdsl > 0 <!-- 有未分单显示 --> |
|
109 |
) |
|
110 |
</if> |
|
111 |
<if test="tdbh !=null and tdbh !='' "> |
|
112 |
and a.td_tdbh like '%'+#{tdbh}+'%' |
|
113 |
</if> |
|
114 |
<if test="shdd !=null and shdd !='' "> |
|
115 |
and c.name = #{shdd} |
|
116 |
</if> |
|
117 |
<if test="zdbm !=null and zdbm !='' "> |
|
118 |
and ( a.td_bmmc like '%'+#{zdbm}+'%') |
|
119 |
</if> |
|
120 |
<if test="fpbh !=null and fpbh !='' "> |
|
121 |
and ( a.td_fpbh like '%'+#{fpbh}+'%') |
|
122 |
</if> |
|
123 |
<if test="zdr !=null and zdr !='' "> |
|
124 |
and ( a.td_zdr like '%'+#{zdr}+'%') |
|
125 |
</if> |
|
126 |
<!-- 关联流水号中的可见物流公司(全部为空,显示地区;不全部为空,显示地区+可见;全部不为空,显示可见物流公司) --> |
|
127 |
<if test=" cqV !=null and cqV !='' "> |
|
128 |
and case when not exists (select * from fd_mx_wlgs where td_tdls=a.td_tdls) |
|
129 |
<include refid="changqu"/> <!-- 厂区可见 --> |
|
130 |
then 1 |
|
131 |
<if test="companyNo!=null and companyNo!=''"> <!--全部不为空,即提单中的每一项都手动分了--> |
|
132 |
when exists (select * from fd_xstdmx mx where exists ( |
|
133 |
select * from fd_mx_wlgs where tdmx_tdfl=mx.tdmx_Tdfl) and tdmx_tdls=a.td_tdls |
|
134 |
) then (case when exists (select * from fd_mx_wlgs where td_tdls=a.td_tdls and wlgs_no=#{companyNo} ) then 1 else 0 end) <!--如果分配给了当前公司可见,否则不可见--> |
|
135 |
when (1=1<include refid="changqu"/>) <!-- 区域物流公司 + 手动分配的物流公司 可见 --> |
|
136 |
or exists(select * from fd_mx_wlgs where td_tdls=a.td_tdls and wlgs_no=#{companyNo}) then 1 |
|
137 |
</if> |
|
138 |
else 0 end > 0 |
|
139 |
</if> |
|
140 |
</sql> |
|
141 |
|
|
142 |
|
|
143 |
<select id="getList" parameterType="java.util.Map" resultType="com.mandi.fendan.util.persist.WaitXSTD"> |
|
144 |
<choose> |
|
145 |
<when test="pagesize > 0 "> |
|
146 |
select top ${pagesize} * |
|
147 |
</when> |
|
148 |
<otherwise> |
|
149 |
select * |
|
150 |
</otherwise> |
|
151 |
</choose> |
|
152 |
from ( select row_number() |
|
153 |
<choose> |
|
154 |
<when test="sort!=null and sort!='' "> |
|
155 |
over (order by ${sort} ) |
|
156 |
</when> |
|
157 |
<otherwise> |
|
158 |
over (order by td_djrq desc ) |
|
159 |
</otherwise> |
|
160 |
</choose> |
|
161 |
as rownumber, a.* from |
|
162 |
(select case when a.td_ztbz not in (1,3) then '' <!-- 自提不显示物流公司 --> |
|
163 |
when not exists (select * from fd_mx_wlgs where td_tdls=a.td_tdls) |
|
164 |
then <include refid="sqlDq"/> <!-- 未人为分配,显示区域物流公司 --> |
|
165 |
when exists (select * from fd_xstdmx mx where exists ( |
|
166 |
select * from fd_mx_wlgs where tdmx_tdfl=mx.tdmx_Tdfl) and tdmx_tdls=a.td_tdls |
|
167 |
) then <include refid="mxWlgsDq"/> <!-- 全部分配,显示分配的物流公司 --> |
|
168 |
else <include refid="sqlDq"/> + ' ' + <include refid="mxWlgsDq"/> <!-- 其他即“未全部人为分配”,则显示合集 --> |
|
169 |
end as companyName, |
|
170 |
DATEDIFF (mi,a.td_djrq,getdate()) timeMinus, |
|
171 |
<include refid="column"/> from fd_xstd a |
|
172 |
LEFT JOIN dbo.company b ON a.td_khbh= b.companyNo |
|
173 |
LEFT JOIN dbo.nc_dq c ON a.td_shddbh= c.code |
|
174 |
LEFT JOIN dbo.nc_ywdy d ON a.td_ywdybh= d.code |
|
175 |
left join dbo.nc_dq e on a.td_shddbh = e.code |
|
176 |
<where> |
|
177 |
NOT EXISTS ( SELECT 1 FROM dbo.fd_gbxstd g WHERE a.td_tdbh= g.xstdNo ) |
|
178 |
<include refid="condition"/> |
|
179 |
</where> |
|
180 |
) a |
|
181 |
<where> |
|
182 |
<if test="khmc !=null and khmc !='' "> |
|
183 |
and ( a.td_khmc like '%'+#{khmc}+'%') |
|
184 |
</if> |
|
185 |
</where> |
|
186 |
) as a where rownumber > #{pagesize}*#{page} |
|
187 |
|
|
188 |
</select> |
|
189 |
|
|
190 |
<select id="countPage" parameterType="Map" resultType="int"> |
|
191 |
select count(*) from fd_xstd a |
|
192 |
LEFT JOIN dbo.company b ON a.td_khbh= b.companyNo |
|
193 |
LEFT JOIN dbo.nc_dq c ON a.td_shddbh= c.code |
|
194 |
LEFT JOIN dbo.nc_ywdy d ON a.td_ywdybh= d.code |
|
195 |
left join dbo.nc_dq e on a.td_shddbh = e.code |
|
196 |
<where> |
|
197 |
NOT EXISTS ( SELECT 1 FROM dbo.fd_gbxstd g WHERE a.td_tdbh= g.xstdNo ) |
|
198 |
<include refid="condition"/> |
|
199 |
</where> |
|
200 |
</select> |
|
201 |
</mapper> |