|
@@ -0,0 +1,451 @@
|
|
|
|
|
+<?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.ruoyi.logistics.mapper.LargeScreenReportMapper">
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 按照订单类型查询订单量-->
|
|
|
|
|
+ <select id="queryOrderTypeReport" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+
|
|
|
|
|
+ SELECT dict_label orderTypeName ,dict_value orderType,ifnull(num,0) num FROM (
|
|
|
|
|
+
|
|
|
|
|
+ SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'logistics_type') a
|
|
|
|
|
+ left join (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ order_type,
|
|
|
|
|
+ count(1) num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ biz_waybill_order d
|
|
|
|
|
+ WHERE order_status != 6
|
|
|
|
|
+
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and d.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and d.dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
|
|
+ ${params.dataScope}
|
|
|
|
|
+
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ order_type) b ON a.dict_value = b.order_type
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 每日订单量-->
|
|
|
|
|
+ <select id="queryDayOrdersReport" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ date_list.day_time AS time,
|
|
|
|
|
+ IFNULL(t.order_num, 0) AS order_num,
|
|
|
|
|
+ IFNULL(t.delivery_num, 0) AS delivery_num,
|
|
|
|
|
+ IFNULL(t.proper_num, 0) AS proper_num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ DATE_FORMAT(
|
|
|
|
|
+ DATE_ADD(#{startTime}, INTERVAL (a + 10*b + 100*c) DAY),
|
|
|
|
|
+ '%Y-%m-%d'
|
|
|
|
|
+ ) AS day_time
|
|
|
|
|
+ FROM
|
|
|
|
|
+ (SELECT 0 a UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) ta,
|
|
|
|
|
+ (SELECT 0 b UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) tb,
|
|
|
|
|
+ (SELECT 0 c UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) tc
|
|
|
|
|
+ HAVING
|
|
|
|
|
+ day_time<![CDATA[<=]]>#{endTime}
|
|
|
|
|
+ ) date_list
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ DATE_FORMAT(create_time, '%Y-%m-%d') AS time,
|
|
|
|
|
+ SUM(order_status != 6) AS order_num,
|
|
|
|
|
+ SUM(order_status != 6 AND order_status != 5) AS delivery_num,
|
|
|
|
|
+ SUM(order_status = 5) AS proper_num
|
|
|
|
|
+ FROM biz_waybill_order d
|
|
|
|
|
+ WHERE d.create_time >=#{startTime} AND d.create_time <![CDATA[<=]]> #{endTime}
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and d.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!-- <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and d.dept_id = #{deptId}
|
|
|
|
|
+ </if>-->
|
|
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
|
|
+ ${params.dataScope}
|
|
|
|
|
+
|
|
|
|
|
+ GROUP BY DATE_FORMAT(d.create_time, '%Y-%m-%d')
|
|
|
|
|
+ ) t ON date_list.day_time = t.time
|
|
|
|
|
+ ORDER BY date_list.day_time;
|
|
|
|
|
+
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 按照省份查询订单量-->
|
|
|
|
|
+ <select id="queryProvinceOrdersReport" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ a.province_name,
|
|
|
|
|
+ a.merger_name,
|
|
|
|
|
+ ifnull( b.num, 0 ) num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ ( SELECT NAME province_name, merger_name FROM sys_city WHERE `level` = 0 ) a
|
|
|
|
|
+ LEFT JOIN ( SELECT sender_province, count( 1 ) num FROM biz_waybill_order d WHERE d.order_status != 6
|
|
|
|
|
+
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and d.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and d.dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
|
|
+ ${params.dataScope}
|
|
|
|
|
+
|
|
|
|
|
+ GROUP BY sender_province ) b ON a.province_name = b.sender_province
|
|
|
|
|
+ order by num desc
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 供应商列表-->
|
|
|
|
|
+ <select id="queryDeptList" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ select d.dept_id deptId,d.dept_name deptName
|
|
|
|
|
+ from sys_dept d
|
|
|
|
|
+ where d.status=0 and d.del_flag=0
|
|
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
|
|
+ ${params.dataScope}
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 省份列表-->
|
|
|
|
|
+ <select id="queryProvinceList" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ a.name AS provinceName,
|
|
|
|
|
+ a.lng,
|
|
|
|
|
+ a.lat,
|
|
|
|
|
+ IFNULL(SUM(CASE WHEN a.name = d.sender_province THEN 1 ELSE 0 END), 0) AS sendCount,
|
|
|
|
|
+ IFNULL(SUM(CASE WHEN a.name = d.receiver_province THEN 1 ELSE 0 END), 0) AS recvCount
|
|
|
|
|
+ FROM sys_city a
|
|
|
|
|
+ LEFT JOIN biz_waybill_order d
|
|
|
|
|
+ ON (a.name = d.sender_province OR a.name = d.receiver_province)
|
|
|
|
|
+
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and d.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and d.dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
|
|
+ ${params.dataScope}
|
|
|
|
|
+ WHERE a.level = 0
|
|
|
|
|
+ GROUP BY a.name, a.lng, a.lat
|
|
|
|
|
+ ORDER BY sendCount DESC, recvCount DESC;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 物流轨迹省份查询流出-->
|
|
|
|
|
+ <select id="queryLogisticsTrajectoryOutflow" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ receiver_province provinceName,
|
|
|
|
|
+ lng,
|
|
|
|
|
+ lat,count(1) num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ biz_waybill_order a
|
|
|
|
|
+ LEFT JOIN sys_city b ON a.receiver_province = b.NAME
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ b.LEVEL = 0
|
|
|
|
|
+ and a.order_status != 6
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and a.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
|
|
+ and DATE_FORMAT(a.create_time, '%Y-%m-%d') >= #{startDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
|
|
+ and DATE_FORMAT(a.create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and a.dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="searchProvince != null and searchProvince != ''">
|
|
|
|
|
+ and a.sender_province = #{searchProvince}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ group by receiver_province
|
|
|
|
|
+ </select>
|
|
|
|
|
+ <!-- 物流轨迹省份查询流入-->
|
|
|
|
|
+ <select id="queryLogisticsTrajectoryinflow" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sender_province provinceName,
|
|
|
|
|
+ lng,
|
|
|
|
|
+ lat ,count(1) num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ biz_waybill_order a
|
|
|
|
|
+ LEFT JOIN sys_city b ON a.sender_province = b.NAME
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ b.LEVEL = 0
|
|
|
|
|
+ and a.order_status != 6
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and a.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
|
|
+ and DATE_FORMAT(a.create_time, '%Y-%m-%d') >= #{startDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
|
|
+ and DATE_FORMAT(a.create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and a.dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="searchProvince != null and searchProvince != ''">
|
|
|
|
|
+ and a.receiver_province = #{searchProvince}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ group by sender_province
|
|
|
|
|
+
|
|
|
|
|
+ </select>
|
|
|
|
|
+ <!-- 按照快递快运区分统计-->
|
|
|
|
|
+ <select id="queryTransportTypeReport" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ c.dict_label typeName,
|
|
|
|
|
+ ifnull( d.num, 0 ) num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ ( SELECT DISTINCT dict_label FROM sys_dict_data WHERE dict_type = 'rjsd_logistics_product' ) c
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ dict_label typeName,
|
|
|
|
|
+ count( 1 ) num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ biz_waybill_order d
|
|
|
|
|
+ LEFT JOIN ( SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'rjsd_logistics_product' ) b ON d.product_code = b.dict_value
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ d.order_status != 6
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and d.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and d.dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
|
|
+ ${params.dataScope}
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ dict_label
|
|
|
|
|
+ ) d ON c.dict_label = d.typeName
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 物流费用统计-->
|
|
|
|
|
+ <select id="queryFreeOrdersReport" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ w.dict_label typeName,
|
|
|
|
|
+ ifnull( q.rate_amount, 0.00 ) rateAmount
|
|
|
|
|
+ FROM
|
|
|
|
|
+ ( SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'logistics_type' ) w
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sum(
|
|
|
|
|
+ ifnull( a.adjust_amount, a.rate_amount )) rate_amount,
|
|
|
|
|
+ order_type
|
|
|
|
|
+ FROM
|
|
|
|
|
+ biz_waybill_cost_details a
|
|
|
|
|
+ LEFT JOIN biz_waybill_order d ON a.external_waybill_no = d.external_waybill_no
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ d.order_status != 6
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and d.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
|
|
+ and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and d.dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
|
|
+ ${params.dataScope}
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ order_type
|
|
|
|
|
+ ) q ON w.dict_value = q.order_type
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!--供应商按照金额排名-->
|
|
|
|
|
+ <select id="queryOrdersReportByFree" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ t.dept_name deptName,
|
|
|
|
|
+ t.rate_amount rateAmount,
|
|
|
|
|
+ (@rank := @rank + 1) AS rankNum
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ dept_name,
|
|
|
|
|
+ IFNULL(rate_amount, 0) AS rate_amount
|
|
|
|
|
+ FROM
|
|
|
|
|
+ sys_dept w
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ SUM(IFNULL(a.adjust_amount, a.rate_amount)) AS rate_amount,
|
|
|
|
|
+ a.dept_id
|
|
|
|
|
+ FROM
|
|
|
|
|
+ biz_waybill_cost_details a
|
|
|
|
|
+ LEFT JOIN biz_waybill_order b
|
|
|
|
|
+ ON a.external_waybill_no = b.external_waybill_no
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ b.order_status != 6
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and b.order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(b.create_time, '%Y-%m-%d') >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ and DATE_FORMAT(b.create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and a.dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ a.dept_id
|
|
|
|
|
+ ) q ON w.dept_id = q.dept_id
|
|
|
|
|
+ where w.del_flag='0'
|
|
|
|
|
+ and w.status='0'
|
|
|
|
|
+ ORDER BY
|
|
|
|
|
+ rate_amount DESC
|
|
|
|
|
+ ) t,
|
|
|
|
|
+ (SELECT @rank := 0) r
|
|
|
|
|
+ LIMIT 10;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!--供应商按照订单量排名-->
|
|
|
|
|
+ <select id="queryOrdersReportByNum" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ t.dept_name deptName,
|
|
|
|
|
+ t.num,
|
|
|
|
|
+ (@rank := @rank + 1) AS rankNum
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ dept_name,
|
|
|
|
|
+ IFNULL(num, 0) AS num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ sys_dept w
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ COUNT(external_waybill_no) AS num,
|
|
|
|
|
+ dept_id
|
|
|
|
|
+ FROM
|
|
|
|
|
+ biz_waybill_order
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ order_status != 6
|
|
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
|
|
+ and order_type = #{orderType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
|
|
+ and DATE_FORMAT(create_time, '%Y-%m-%d') >= #{startDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
|
|
+ and DATE_FORMAT(create_time, '%Y-%m-%d')<![CDATA[<=]]> #{endDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
|
|
+ and dept_id = #{deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ dept_id
|
|
|
|
|
+ ) q ON w.dept_id = q.dept_id
|
|
|
|
|
+ ORDER BY
|
|
|
|
|
+ num DESC
|
|
|
|
|
+ ) t,
|
|
|
|
|
+ (SELECT @rank := 0) r
|
|
|
|
|
+ LIMIT 10;
|
|
|
|
|
+
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!--供应商月度增长率-->
|
|
|
|
|
+ <select id="queryDeptMonthlyGrowthRate" parameterType="java.util.Map" resultType="java.util.HashMap" >
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ t1.month,
|
|
|
|
|
+ t1.rate_amount,
|
|
|
|
|
+ IFNULL(t2.rate_amount, 0) AS last_month_amount,
|
|
|
|
|
+ CASE
|
|
|
|
|
+ WHEN IFNULL(t2.rate_amount, 0) = 0 THEN 0
|
|
|
|
|
+ ELSE ROUND((t1.rate_amount - t2.rate_amount) / t2.rate_amount * 100, 2)
|
|
|
|
|
+ END AS growth_rate
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ months.month,
|
|
|
|
|
+ IFNULL(data.rate_amount, 0) AS rate_amount
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL (a) MONTH), '%Y-%m') AS month
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT 0 a UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5
|
|
|
|
|
+ ) t
|
|
|
|
|
+ ) months
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ SUM(IFNULL(a.adjust_amount, a.rate_amount)) rate_amount,
|
|
|
|
|
+ DATE_FORMAT(b.create_time, '%Y-%m') AS month
|
|
|
|
|
+ FROM biz_waybill_cost_details a
|
|
|
|
|
+ LEFT JOIN biz_waybill_order b ON a.external_waybill_no = b.external_waybill_no
|
|
|
|
|
+ WHERE b.order_status != 6
|
|
|
|
|
+ AND b.dept_id = #{deptId}
|
|
|
|
|
+ GROUP BY DATE_FORMAT(b.create_time, '%Y-%m')
|
|
|
|
|
+ ) data ON months.month = data.month
|
|
|
|
|
+ ) t1
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ months.month,
|
|
|
|
|
+ IFNULL(data.rate_amount, 0) AS rate_amount
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL (a) MONTH), '%Y-%m') AS month
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT 0 a UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5
|
|
|
|
|
+ ) t
|
|
|
|
|
+ ) months
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ SUM(IFNULL(a.adjust_amount, a.rate_amount)) rate_amount,
|
|
|
|
|
+ DATE_FORMAT(b.create_time, '%Y-%m') AS month
|
|
|
|
|
+ FROM biz_waybill_cost_details a
|
|
|
|
|
+ LEFT JOIN biz_waybill_order b ON a.external_waybill_no = b.external_waybill_no
|
|
|
|
|
+ WHERE b.order_status != 6
|
|
|
|
|
+ AND b.dept_id = #{deptId}
|
|
|
|
|
+ GROUP BY DATE_FORMAT(b.create_time, '%Y-%m')
|
|
|
|
|
+ ) data ON months.month = data.month
|
|
|
|
|
+ ) t2 ON t1.month = DATE_FORMAT(STR_TO_DATE(CONCAT(t2.month, '-01'), '%Y-%m-%d') + INTERVAL 1 MONTH, '%Y-%m')
|
|
|
|
|
+ ORDER BY t1.month;
|
|
|
|
|
+
|
|
|
|
|
+ </select>
|
|
|
|
|
+</mapper>
|