demand: tms-统计报表-月结客户出货统计-查询返回月结客户首次签约时间 tms-统计报表-月结客户出货统计-未出货的月结客户也支持查询

committer: heyu
This commit is contained in:
aike 2025-11-14 10:54:24 +08:00
parent 9429fbf687
commit b4eef7489e
2 changed files with 56 additions and 49 deletions

View File

@ -113,5 +113,8 @@ public class MonthlyCustomerShipmentStatVO implements Serializable {
private Integer thailandTickets;
/* 泰国实际重量 */
private BigDecimal thailandWeight;
/* 首次签约日期 */
private String firstSigningDay;
}

View File

@ -3995,12 +3995,13 @@
<!-- 查询月结客户出货统计 -->
<select id="selectMonthlyCustomerShipmentStat" parameterType="EmisWaybill" resultType="map">
SELECT
a.customer_code AS customerCode,
a.cust_name AS customerName,
a.cust_no AS custNo,
cu.customer_code AS customerCode,
cu.customer_name AS customerName,
cu.monthly_pay_code AS custNo,
cu.salesmen AS salesmen,
cu.first_signing_day AS firstSigningDay,
COUNT(DISTINCT a.bill_code) AS totalTickets,
IFNULL(SUM(a.bill_weight), 0) AS totalWeight,
GROUP_CONCAT(DISTINCT cu.salesmen ORDER BY a.order_date SEPARATOR '/') AS salesmen,
SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '1' THEN 1 ELSE 0 END) AS expressTickets,
IFNULL(SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '1' THEN a.bill_weight ELSE 0 END), 0) AS expressWeight,
SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '2' THEN 1 ELSE 0 END) AS airTickets,
@ -4013,13 +4014,11 @@
IFNULL(SUM(CASE WHEN a.receive_country = '0086' THEN a.bill_weight ELSE 0 END), 0) AS importWeight,
SUM(CASE WHEN a.receive_country != '0086' AND NOT (a.send_country = '0086' AND tl.trans_type IN ('1','2','3','4','5')) THEN 1 ELSE 0 END) AS otherTickets,
IFNULL(SUM(CASE WHEN a.receive_country != '0086' AND NOT (a.send_country = '0086' AND tl.trans_type IN ('1','2','3','4','5')) THEN a.bill_weight ELSE 0 END), 0) AS otherWeight
FROM emis_waybill a
LEFT JOIN emis_trans_line tl ON a.trans_line_type = tl.line_code AND tl.del_flag = '0'
LEFT JOIN emis_customer_user cu ON a.cust_no = cu.monthly_pay_code AND cu.del_flag = '0'
<where>
a.del_flag = '0'
AND a.order_status !='0'
AND a.order_status!='2'
FROM emis_customer_user cu
LEFT JOIN emis_waybill a ON cu.monthly_pay_code = a.cust_no
AND a.del_flag = '0'
AND a.order_status != '0'
AND a.order_status != '2'
AND a.cust_no IS NOT NULL
AND a.cust_no != ''
<!-- 剔除问题件类型为面单删除、出口虚拟单、返货虚拟单的运单 -->
@ -4036,16 +4035,6 @@
<if test="params.endSendDate != null and params.endSendDate != ''">
AND a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
<!-- 客户名称 -->
<if test="customerName != null and customerName != ''">
AND a.cust_name LIKE CONCAT('%', #{custName}, '%')
</if>
<if test="customerCode != null and customerCode != ''">
AND a.customer_code = #{customerCode}
</if>
<if test="custNo != null and custNo != ''">
AND a.cust_no = #{custNo}
</if>
<!-- 寄件国家 -->
<if test="sendCountry != null and sendCountry != ''">
AND a.send_country = #{sendCountry}
@ -4061,6 +4050,20 @@
</otherwise>
</choose>
</if>
LEFT JOIN emis_trans_line tl ON a.trans_line_type = tl.line_code AND tl.del_flag = '0'
<where>
cu.del_flag = '0'
AND cu.customer_type = '2'
<!-- 客户名称 -->
<if test="customerName != null and customerName != ''">
AND (cu.customer_name LIKE CONCAT('%', #{custName}, '%') OR a.cust_name LIKE CONCAT('%', #{custName}, '%'))
</if>
<if test="customerCode != null and customerCode != ''">
AND (cu.customer_code = #{customerCode} OR a.customer_code = #{customerCode})
</if>
<if test="custNo != null and custNo != ''">
AND cu.monthly_pay_code = #{custNo}
</if>
<!-- 销售主管 -->
<if test="salesExecutive != null and salesExecutive != ''">
AND cu.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%')
@ -4090,19 +4093,20 @@
)
</if>
</where>
GROUP BY a.cust_no
ORDER BY a.cust_name
GROUP BY cu.monthly_pay_code
ORDER BY totalWeight desc,totalTickets desc
</select>
<!-- 按目的国家查询月结客户出货统计 -->
<select id="selectMonthlyCustomerShipmentStatByCountry" parameterType="EmisWaybill" resultType="map">
SELECT
a.customer_code AS customerCode,
a.cust_name AS customerName,
a.cust_no AS custNo,
COUNT(DISTINCT a.bill_code) AS totalTickets,
cu.customer_code AS customerCode,
cu.customer_name AS customerName,
cu.monthly_pay_code AS custNo,
cu.salesmen AS salesmen,
cu.first_signing_day AS firstSigningDay,
COUNT(DISTINCT a.bill_code) AS totalTickets,
IFNULL(SUM(a.bill_weight), 0) AS totalWeight,
GROUP_CONCAT(DISTINCT cu.salesmen ORDER BY a.order_date SEPARATOR '/') AS salesmen,
SUM(CASE WHEN a.receive_country = '0086' THEN 1 ELSE 0 END) AS chinaTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0086' THEN a.bill_weight ELSE 0 END), 0) AS chinaWeight,
SUM(CASE WHEN a.receive_country = '0084' THEN 1 ELSE 0 END) AS vietnamTickets,
@ -4118,15 +4122,12 @@
SUM(CASE WHEN a.receive_country = '0066' THEN 1 ELSE 0 END) AS thailandTickets,
IFNULL(SUM(CASE WHEN a.receive_country = '0066' THEN a.bill_weight ELSE 0 END), 0) AS thailandWeight,
SUM(CASE WHEN a.receive_country NOT IN ('0086','0084','0855','0095','0880','0856','0066') THEN 1 ELSE 0 END) AS otherTickets,
IFNULL(SUM(CASE WHEN a.receive_country NOT IN ('0086','0084','0855','0095','0880','0856','0066') THEN a.bill_weight ELSE 0 END), 0) AS otherWeight,
0 AS importTickets,
0 AS importWeight
FROM emis_waybill a
LEFT JOIN emis_customer_user cu ON a.cust_no = cu.monthly_pay_code AND cu.del_flag = '0'
<where>
a.del_flag = '0'
AND a.order_status !='0'
AND a.order_status!='2'
IFNULL(SUM(CASE WHEN a.receive_country NOT IN ('0086','0084','0855','0095','0880','0856','0066') THEN a.bill_weight ELSE 0 END), 0) AS otherWeight
FROM emis_customer_user cu
LEFT JOIN emis_waybill a ON cu.monthly_pay_code = a.cust_no
AND a.del_flag = '0'
AND a.order_status != '0'
AND a.order_status != '2'
AND a.cust_no IS NOT NULL
AND a.cust_no != ''
<!-- 剔除问题件类型为面单删除、出口虚拟单、返货虚拟单的运单 -->
@ -4143,16 +4144,6 @@
<if test="params.endSendDate != null and params.endSendDate != ''">
AND a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
<!-- 客户名称 -->
<if test="customerName != null and customerName != ''">
AND a.cust_name LIKE CONCAT('%', #{custName}, '%')
</if>
<if test="customerCode != null and customerCode != ''">
AND a.customer_code = #{customerCode}
</if>
<if test="custNo != null and custNo != ''">
AND a.cust_no = #{custNo}
</if>
<!-- 寄件国家 -->
<if test="sendCountry != null and sendCountry != ''">
AND a.send_country = #{sendCountry}
@ -4168,6 +4159,19 @@
</otherwise>
</choose>
</if>
<where>
cu.del_flag = '0'
AND cu.customer_type = '2'
<!-- 客户名称 -->
<if test="customerName != null and customerName != ''">
AND (cu.customer_name LIKE CONCAT('%', #{custName}, '%') OR a.cust_name LIKE CONCAT('%', #{custName}, '%'))
</if>
<if test="customerCode != null and customerCode != ''">
AND (cu.customer_code = #{customerCode} OR a.customer_code = #{customerCode})
</if>
<if test="custNo != null and custNo != ''">
AND cu.monthly_pay_code = #{custNo}
</if>
<!-- 销售主管 -->
<if test="salesExecutive != null and salesExecutive != ''">
AND cu.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%')
@ -4197,8 +4201,8 @@
)
</if>
</where>
GROUP BY a.cust_no
ORDER BY a.cust_name
GROUP BY cu.monthly_pay_code
ORDER BY totalWeight desc,totalTickets desc
</select>
<!-- 查询月结客户出货明细 -->