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 Integer thailandTickets;
/* 泰国实际重量 */ /* 泰国实际重量 */
private BigDecimal thailandWeight; private BigDecimal thailandWeight;
/* 首次签约日期 */
private String firstSigningDay;
} }

View File

@ -3995,12 +3995,13 @@
<!-- 查询月结客户出货统计 --> <!-- 查询月结客户出货统计 -->
<select id="selectMonthlyCustomerShipmentStat" parameterType="EmisWaybill" resultType="map"> <select id="selectMonthlyCustomerShipmentStat" parameterType="EmisWaybill" resultType="map">
SELECT SELECT
a.customer_code AS customerCode, cu.customer_code AS customerCode,
a.cust_name AS customerName, cu.customer_name AS customerName,
a.cust_no AS custNo, cu.monthly_pay_code AS custNo,
cu.salesmen AS salesmen,
cu.first_signing_day AS firstSigningDay,
COUNT(DISTINCT a.bill_code) AS totalTickets, COUNT(DISTINCT a.bill_code) AS totalTickets,
IFNULL(SUM(a.bill_weight), 0) AS totalWeight, 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, 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, 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, SUM(CASE WHEN a.send_country = '0086' AND tl.trans_type = '2' THEN 1 ELSE 0 END) AS airTickets,
@ -4013,11 +4014,9 @@
IFNULL(SUM(CASE WHEN a.receive_country = '0086' THEN a.bill_weight ELSE 0 END), 0) AS importWeight, 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, 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 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 FROM emis_customer_user cu
LEFT JOIN emis_trans_line tl ON a.trans_line_type = tl.line_code AND tl.del_flag = '0' LEFT JOIN emis_waybill a ON cu.monthly_pay_code = a.cust_no
LEFT JOIN emis_customer_user cu ON a.cust_no = cu.monthly_pay_code AND cu.del_flag = '0' AND a.del_flag = '0'
<where>
a.del_flag = '0'
AND a.order_status != '0' AND a.order_status != '0'
AND a.order_status != '2' AND a.order_status != '2'
AND a.cust_no IS NOT NULL AND a.cust_no IS NOT NULL
@ -4036,16 +4035,6 @@
<if test="params.endSendDate != null and params.endSendDate != ''"> <if test="params.endSendDate != null and params.endSendDate != ''">
AND a.send_date <![CDATA[ <= ]]> #{params.endSendDate} AND a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if> </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 != ''"> <if test="sendCountry != null and sendCountry != ''">
AND a.send_country = #{sendCountry} AND a.send_country = #{sendCountry}
@ -4061,6 +4050,20 @@
</otherwise> </otherwise>
</choose> </choose>
</if> </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 != ''"> <if test="salesExecutive != null and salesExecutive != ''">
AND cu.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%') AND cu.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%')
@ -4090,19 +4093,20 @@
) )
</if> </if>
</where> </where>
GROUP BY a.cust_no GROUP BY cu.monthly_pay_code
ORDER BY a.cust_name ORDER BY totalWeight desc,totalTickets desc
</select> </select>
<!-- 按目的国家查询月结客户出货统计 --> <!-- 按目的国家查询月结客户出货统计 -->
<select id="selectMonthlyCustomerShipmentStatByCountry" parameterType="EmisWaybill" resultType="map"> <select id="selectMonthlyCustomerShipmentStatByCountry" parameterType="EmisWaybill" resultType="map">
SELECT SELECT
a.customer_code AS customerCode, cu.customer_code AS customerCode,
a.cust_name AS customerName, cu.customer_name AS customerName,
a.cust_no AS custNo, cu.monthly_pay_code AS custNo,
cu.salesmen AS salesmen,
cu.first_signing_day AS firstSigningDay,
COUNT(DISTINCT a.bill_code) AS totalTickets, COUNT(DISTINCT a.bill_code) AS totalTickets,
IFNULL(SUM(a.bill_weight), 0) AS totalWeight, 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, 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, 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, SUM(CASE WHEN a.receive_country = '0084' THEN 1 ELSE 0 END) AS vietnamTickets,
@ -4118,13 +4122,10 @@
SUM(CASE WHEN a.receive_country = '0066' THEN 1 ELSE 0 END) AS thailandTickets, 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, 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, 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, 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, FROM emis_customer_user cu
0 AS importWeight LEFT JOIN emis_waybill a ON cu.monthly_pay_code = a.cust_no
FROM emis_waybill a AND a.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 != '0'
AND a.order_status != '2' AND a.order_status != '2'
AND a.cust_no IS NOT NULL AND a.cust_no IS NOT NULL
@ -4143,16 +4144,6 @@
<if test="params.endSendDate != null and params.endSendDate != ''"> <if test="params.endSendDate != null and params.endSendDate != ''">
AND a.send_date <![CDATA[ <= ]]> #{params.endSendDate} AND a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if> </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 != ''"> <if test="sendCountry != null and sendCountry != ''">
AND a.send_country = #{sendCountry} AND a.send_country = #{sendCountry}
@ -4168,6 +4159,19 @@
</otherwise> </otherwise>
</choose> </choose>
</if> </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 != ''"> <if test="salesExecutive != null and salesExecutive != ''">
AND cu.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%') AND cu.sales_executive LIKE CONCAT('%', #{salesExecutive}, '%')
@ -4197,8 +4201,8 @@
) )
</if> </if>
</where> </where>
GROUP BY a.cust_no GROUP BY cu.monthly_pay_code
ORDER BY a.cust_name ORDER BY totalWeight desc,totalTickets desc
</select> </select>
<!-- 查询月结客户出货明细 --> <!-- 查询月结客户出货明细 -->