This commit is contained in:
linfso 2025-01-03 21:54:44 +08:00
parent 2e8353b20b
commit ff37de99fc

View File

@ -1850,133 +1850,78 @@
count(1) as totalNum,
sum(a.parcel_qty) as totalParcelQty,
round(sum(bill_weight),2) as totalBillWeight,
round(sum(total_volume),5) as totalVolume,
round(sum(volume_weight),2) as totalVolumeWeight,
round(sum(settlement_weight),2) as totalSettlementWeight,
round(sum(freight),2) as totalFreight
round(sum(total_volume),4) as totalVolume
from emis_waybill a
<where>
a.del_flag='0' and a.order_status !='0' and a.order_status!='2'
and ( a.problem_type is null or (a.problem_type is not null and (a.problem_type != 173 and a.problem_type != 170 and a.problem_type != 151) ) )
<if test="salesmen != null and salesmen != '' " >
<if test="params.queryDateType != null and params.queryDateType == 1 ">
and to_days(a.send_date) = to_days(now())
</if>
<if test="params.queryDateType != null and params.queryDateType == 2 ">
and DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[ <= ]]> a.send_date
</if>
<if test="params.queryDateType != null and params.queryDateType == 3 ">
and QUARTER(a.send_date)=QUARTER(now()) and YEAR(a.send_date)=YEAR(NOW())
</if>
<if test="params.queryDateType != null and params.queryDateType == 4 ">
and YEAR(a.send_date)=YEAR(NOW())
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and a.salesmen=#{salesmen}
</if>
<if test="params.beginDate != null and params.beginDate != ''">
and a.send_date <![CDATA[ >= ]]> #{params.beginDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and a.send_date <![CDATA[ <= ]]> #{params.endDate}
</if>
<if test="salesmen == null and params.privSiteCode != null and params.privSiteCode != '88888'">
and (
a.send_site_code in (
SELECT t1.site_code FROM (
SELECT * FROM emis_site WHERE parent_site_code IS NOT NULL ) t1,( SELECT @pid :=
#{params.privSiteCode} ) pd
WHERE FIND_IN_SET( parent_site_code, @pid ) > 0 AND @pid := concat(@pid,',',site_code)
UNION
SELECT #{params.privSiteCode} FROM dual
)
or
a.dispatch_site_code in (
SELECT t1.site_code FROM (
SELECT * FROM emis_site WHERE parent_site_code IS NOT NULL ) t1,( SELECT @pid :=
#{params.privSiteCode} ) pd
WHERE FIND_IN_SET( parent_site_code, @pid ) > 0 AND @pid := concat(@pid,',',site_code)
UNION
SELECT #{params.privSiteCode} FROM dual
)
<if test="params.isQueryPrintOrder != null and params.isQueryPrintOrder == 1">
or EXISTS (select 1 from emis_tms_scan_record etsr where a.bill_code=etsr.main_bill_code and etsr.scan_site_code=#{params.privSiteCode})
</if>
<if test="custNo != null and custNo != ''">
or EXISTS (
select 1 from emis_customer_user ecu where a.cust_no=ecu.monthly_pay_code and ecu.owner_site=#{params.privSiteCode}
)
</if>
or a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.operate_employee_code=#{params.privEmpCode}
or a.take_piece_employee_code=#{params.privEmpCode}
)
</if>
</where>
</select>
<select id="getMyBizStatListByCountry" parameterType="EmisWaybill" resultType="map">
select
a.receive_country as receiveCountry,
b.name as receiveCountryName,
count(1) as totalNum,
sum(a.parcel_qty) as totalParcelQty,
round(sum(a.bill_weight),2) as totalBillWeight,
round(sum(a.total_volume),5) as totalVolume,
round(sum(a.volume_weight),2) as totalVolumeWeight,
round(sum(a.settlement_weight),2) as totalSettlementWeight,
round(sum(a.freight),2) as totalFreight
from emis_waybill a,emis_country b
b.CODE AS countryCode,
b.NAME AS countryName,
sum(if(c.trans_type=1,1,0) ) as kdTotalNum,
round(sum(if(c.trans_type=1,a.bill_weight,0) ),2) as kdTotalBillWeight,
sum(if(c.trans_type=2,1,0) ) as kyTotalNum,
round(sum(if(c.trans_type=2,a.bill_weight,0) ),2) as kyTotalBillWeight,
sum(if( ( c.trans_type=3 or c.trans_type=4 or c.trans_type=5 ),1,0) ) as wlTotalNum,
round(sum(if( ( c.trans_type=3 or c.trans_type=4 or c.trans_type=5 ) ,a.bill_weight,0) ),2) as wlTotalBillWeight,
count( 1 ) AS totalNum,
round( sum( a.bill_weight ), 2 ) AS totalBillWeight
from emis_waybill a, emis_country b,emis_trans_line c
<where>
a.del_flag='0' and a.order_status !='0' and a.order_status!='2'
and a.receive_country=b.code
and b.del_flag='0' and c.del_flag='0'
and a.receive_country=b.code and a.trans_line_type=c.line_code
and ( a.problem_type is null or (a.problem_type is not null and (a.problem_type != 173 and a.problem_type != 170 and a.problem_type != 151) ) )
<if test="salesmen != null and salesmen != '' " >
<if test="params.queryDateType != null and params.queryDateType == 1 ">
and to_days(a.send_date) = to_days(now())
</if>
<if test="params.queryDateType != null and params.queryDateType == 2 ">
and DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[ <= ]]> a.send_date
</if>
<if test="params.queryDateType != null and params.queryDateType == 3 ">
and QUARTER(a.send_date)=QUARTER(now()) and YEAR(a.send_date)=YEAR(NOW())
</if>
<if test="params.queryDateType != null and params.queryDateType == 4 ">
and YEAR(a.send_date)=YEAR(NOW())
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and a.salesmen=#{salesmen}
</if>
<if test="params.beginDate != null and params.beginDate != ''">
and a.send_date <![CDATA[ >= ]]> #{params.beginDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and a.send_date <![CDATA[ <= ]]> #{params.endDate}
</if>
<if test="salesmen == null and params.privSiteCode != null and params.privSiteCode != '88888'">
and (
a.send_site_code in (
SELECT t1.site_code FROM (
SELECT * FROM emis_site WHERE parent_site_code IS NOT NULL ) t1,( SELECT @pid :=
#{params.privSiteCode} ) pd
WHERE FIND_IN_SET( parent_site_code, @pid ) > 0 AND @pid := concat(@pid,',',site_code)
UNION
SELECT #{params.privSiteCode} FROM dual
)
or
a.dispatch_site_code in (
SELECT t1.site_code FROM (
SELECT * FROM emis_site WHERE parent_site_code IS NOT NULL ) t1,( SELECT @pid :=
#{params.privSiteCode} ) pd
WHERE FIND_IN_SET( parent_site_code, @pid ) > 0 AND @pid := concat(@pid,',',site_code)
UNION
SELECT #{params.privSiteCode} FROM dual
)
<if test="params.isQueryPrintOrder != null and params.isQueryPrintOrder == 1">
or EXISTS (select 1 from emis_tms_scan_record etsr where a.bill_code=etsr.main_bill_code and etsr.scan_site_code=#{params.privSiteCode})
</if>
<if test="custNo != null and custNo != ''">
or EXISTS (
select 1 from emis_customer_user ecu where a.cust_no=ecu.monthly_pay_code and ecu.owner_site=#{params.privSiteCode}
)
</if>
or a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.operate_employee_code=#{params.privEmpCode}
or a.take_piece_employee_code=#{params.privEmpCode}
)
</if>
</where>
group by a.receive_country
group by b.code
</select>