返回参数
This commit is contained in:
parent
ed9463b28b
commit
303e903d69
@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
|
|||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工单信息 实体类。
|
* 工单信息 实体类。
|
||||||
@ -42,4 +43,10 @@ public class EbikeBikeOrderDayCountDto implements Serializable {
|
|||||||
* 昨天完成量
|
* 昨天完成量
|
||||||
*/
|
*/
|
||||||
private Integer yesterdayCount;
|
private Integer yesterdayCount;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变化量
|
||||||
|
*/
|
||||||
|
private BigDecimal changePercentage;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
|
|||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工单信息 实体类。
|
* 工单信息 实体类。
|
||||||
@ -42,4 +43,9 @@ public class EbikeBikeOrderMonthCountDto implements Serializable {
|
|||||||
* 上月完成量
|
* 上月完成量
|
||||||
*/
|
*/
|
||||||
private Integer lastMonthCount;
|
private Integer lastMonthCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变化量
|
||||||
|
*/
|
||||||
|
private BigDecimal changePercentage;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
|
|||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工单信息 实体类。
|
* 工单信息 实体类。
|
||||||
@ -42,4 +43,10 @@ public class EbikeBikeOrderWeekCountDto implements Serializable {
|
|||||||
* 上周完成量
|
* 上周完成量
|
||||||
*/
|
*/
|
||||||
private Integer lastWeekCount;
|
private Integer lastWeekCount;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变化量
|
||||||
|
*/
|
||||||
|
private BigDecimal changePercentage;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,32 @@
|
|||||||
WHEN DATE_TRUNC('month', ebo.handle_at) =
|
WHEN DATE_TRUNC('month', ebo.handle_at) =
|
||||||
DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
|
DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
|
||||||
THEN 1
|
THEN 1
|
||||||
END), 0) as lastMonthCount
|
END), 0) as lastMonthCount,
|
||||||
|
CASE
|
||||||
|
WHEN COALESCE(COUNT(CASE
|
||||||
|
WHEN DATE_TRUNC('month', ebo.handle_at) =
|
||||||
|
DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
|
||||||
|
THEN 1
|
||||||
|
END), 0) = 0 THEN 0
|
||||||
|
ELSE ROUND(
|
||||||
|
(COALESCE(COUNT(CASE
|
||||||
|
WHEN DATE_TRUNC('month', ebo.handle_at) =
|
||||||
|
DATE_TRUNC('month', CURRENT_DATE)
|
||||||
|
THEN 1
|
||||||
|
END), 0) -
|
||||||
|
COALESCE(COUNT(CASE
|
||||||
|
WHEN DATE_TRUNC('month', ebo.handle_at) =
|
||||||
|
DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
|
||||||
|
THEN 1
|
||||||
|
END), 0)) * 100.0 /
|
||||||
|
COALESCE(COUNT(CASE
|
||||||
|
WHEN DATE_TRUNC('month', ebo.handle_at) =
|
||||||
|
DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
|
||||||
|
THEN 1
|
||||||
|
END), 0),
|
||||||
|
2
|
||||||
|
)
|
||||||
|
END as changePercentage
|
||||||
FROM generate_series(1, 4) as aot(order_type)
|
FROM generate_series(1, 4) as aot(order_type)
|
||||||
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
||||||
AND ebo.handle_state = 2
|
AND ebo.handle_state = 2
|
||||||
@ -50,7 +75,31 @@
|
|||||||
COALESCE(COUNT(CASE
|
COALESCE(COUNT(CASE
|
||||||
WHEN DATE (ebo.handle_at) = CURRENT_DATE - INTERVAL '1 day'
|
WHEN DATE (ebo.handle_at) = CURRENT_DATE - INTERVAL '1 day'
|
||||||
THEN 1
|
THEN 1
|
||||||
END), 0) as yesterdayCount
|
END), 0) as yesterdayCount,
|
||||||
|
COALESCE(
|
||||||
|
CASE
|
||||||
|
WHEN COALESCE(COUNT(CASE
|
||||||
|
WHEN DATE (ebo.handle_at) = CURRENT_DATE - INTERVAL '1 day'
|
||||||
|
THEN 1
|
||||||
|
END), 0) = 0
|
||||||
|
THEN 0.0
|
||||||
|
ELSE ROUND(
|
||||||
|
(COALESCE(COUNT(CASE
|
||||||
|
WHEN DATE (ebo.handle_at) = CURRENT_DATE
|
||||||
|
THEN 1
|
||||||
|
END), 0) -
|
||||||
|
COALESCE(COUNT(CASE
|
||||||
|
WHEN DATE (ebo.handle_at) = CURRENT_DATE - INTERVAL '1 day'
|
||||||
|
THEN 1
|
||||||
|
END), 0)) * 100.0 /
|
||||||
|
COALESCE(COUNT(CASE
|
||||||
|
WHEN DATE (ebo.handle_at) = CURRENT_DATE - INTERVAL '1 day'
|
||||||
|
THEN 1
|
||||||
|
END), 0),
|
||||||
|
2
|
||||||
|
)
|
||||||
|
END, 0.0
|
||||||
|
) as changePercentage
|
||||||
FROM generate_series(1, 4) as aot(order_type)
|
FROM generate_series(1, 4) as aot(order_type)
|
||||||
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
||||||
AND ebo.handle_state = 2
|
AND ebo.handle_state = 2
|
||||||
@ -64,15 +113,11 @@
|
|||||||
GROUP BY aot.order_type
|
GROUP BY aot.order_type
|
||||||
ORDER BY aot.order_type;
|
ORDER BY aot.order_type;
|
||||||
]]>
|
]]>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="weekCount" resultType="com.cdzy.operations.model.dto.EbikeBikeOrderWeekCountDto">
|
<select id="weekCount" resultType="com.cdzy.operations.model.dto.EbikeBikeOrderWeekCountDto">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
WITH week_range AS (
|
WITH week_range AS (SELECT DATE_TRUNC('week', CURRENT_DATE) as current_week_start,
|
||||||
SELECT
|
DATE_TRUNC('week', CURRENT_DATE) + INTERVAL '1 week' as current_week_end, DATE_TRUNC('week', CURRENT_DATE - INTERVAL '1 week') as last_week_start
|
||||||
DATE_TRUNC('week', CURRENT_DATE) as current_week_start,
|
|
||||||
DATE_TRUNC('week', CURRENT_DATE) + INTERVAL '1 week' as current_week_end,
|
|
||||||
DATE_TRUNC('week', CURRENT_DATE - INTERVAL '1 week') as last_week_start
|
|
||||||
)
|
)
|
||||||
SELECT #{receiverId} as receiverId,
|
SELECT #{receiverId} as receiverId,
|
||||||
CASE aot.order_type
|
CASE aot.order_type
|
||||||
@ -90,7 +135,35 @@
|
|||||||
WHEN ebo.handle_at >= wr.last_week_start
|
WHEN ebo.handle_at >= wr.last_week_start
|
||||||
AND ebo.handle_at < wr.current_week_start
|
AND ebo.handle_at < wr.current_week_start
|
||||||
THEN 1
|
THEN 1
|
||||||
END), 0) as lastWeekCount
|
END), 0) as lastWeekCount,
|
||||||
|
COALESCE(
|
||||||
|
CASE
|
||||||
|
WHEN COALESCE(COUNT(CASE
|
||||||
|
WHEN ebo.handle_at >= wr.last_week_start
|
||||||
|
AND ebo.handle_at < wr.current_week_start
|
||||||
|
THEN 1
|
||||||
|
END), 0) = 0
|
||||||
|
THEN 0.0
|
||||||
|
ELSE ROUND(
|
||||||
|
(COALESCE(COUNT(CASE
|
||||||
|
WHEN ebo.handle_at >= wr.current_week_start
|
||||||
|
AND ebo.handle_at < wr.current_week_end
|
||||||
|
THEN 1
|
||||||
|
END), 0) -
|
||||||
|
COALESCE(COUNT(CASE
|
||||||
|
WHEN ebo.handle_at >= wr.last_week_start
|
||||||
|
AND ebo.handle_at < wr.current_week_start
|
||||||
|
THEN 1
|
||||||
|
END), 0)) * 100.0 /
|
||||||
|
COALESCE(COUNT(CASE
|
||||||
|
WHEN ebo.handle_at >= wr.last_week_start
|
||||||
|
AND ebo.handle_at < wr.current_week_start
|
||||||
|
THEN 1
|
||||||
|
END), 0),
|
||||||
|
2
|
||||||
|
)
|
||||||
|
END, 0.0
|
||||||
|
) as changePercentage
|
||||||
FROM generate_series(1, 4) as aot(order_type)
|
FROM generate_series(1, 4) as aot(order_type)
|
||||||
CROSS JOIN week_range wr
|
CROSS JOIN week_range wr
|
||||||
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
||||||
@ -103,7 +176,5 @@
|
|||||||
GROUP BY aot.order_type
|
GROUP BY aot.order_type
|
||||||
ORDER BY aot.order_type;
|
ORDER BY aot.order_type;
|
||||||
]]>
|
]]>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user