返回参数
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,37 +6,62 @@
|
|||||||
|
|
||||||
<select id="monthCount" resultType="com.cdzy.operations.model.dto.EbikeBikeOrderMonthCountDto">
|
<select id="monthCount" resultType="com.cdzy.operations.model.dto.EbikeBikeOrderMonthCountDto">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
SELECT #{receiverId} as receiverId,
|
SELECT #{receiverId} as receiverId,
|
||||||
CASE aot.order_type
|
CASE aot.order_type
|
||||||
WHEN 1 THEN '巡检工单'
|
WHEN 1 THEN '巡检工单'
|
||||||
WHEN 2 THEN '换电工单'
|
WHEN 2 THEN '换电工单'
|
||||||
WHEN 3 THEN '调度工单'
|
WHEN 3 THEN '调度工单'
|
||||||
WHEN 4 THEN '维修工单'
|
WHEN 4 THEN '维修工单'
|
||||||
END as orderType,
|
END as orderType,
|
||||||
COALESCE(COUNT(CASE
|
COALESCE(COUNT(CASE
|
||||||
WHEN DATE_TRUNC('month', ebo.handle_at) = DATE_TRUNC('month', CURRENT_DATE)
|
WHEN DATE_TRUNC('month', ebo.handle_at) = DATE_TRUNC('month', CURRENT_DATE)
|
||||||
THEN 1
|
THEN 1
|
||||||
END), 0) as thisMonthCount,
|
END), 0) as thisMonthCount,
|
||||||
COALESCE(COUNT(CASE
|
COALESCE(COUNT(CASE
|
||||||
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,
|
||||||
FROM generate_series(1, 4) as aot(order_type)
|
CASE
|
||||||
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
WHEN COALESCE(COUNT(CASE
|
||||||
AND ebo.handle_state = 2
|
WHEN DATE_TRUNC('month', ebo.handle_at) =
|
||||||
AND ebo.handle_at IS NOT NULL
|
DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
|
||||||
AND ebo.is_deleted = false
|
THEN 1
|
||||||
AND ebo.receiver_id = #{receiverId}
|
END), 0) = 0 THEN 0
|
||||||
AND ebo.handle_at >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
|
ELSE ROUND(
|
||||||
AND ebo.handle_at < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month'
|
(COALESCE(COUNT(CASE
|
||||||
GROUP BY aot.order_type
|
WHEN DATE_TRUNC('month', ebo.handle_at) =
|
||||||
ORDER BY aot.order_type;
|
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)
|
||||||
|
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
||||||
|
AND ebo.handle_state = 2
|
||||||
|
AND ebo.handle_at IS NOT NULL
|
||||||
|
AND ebo.is_deleted = false
|
||||||
|
AND ebo.receiver_id = #{receiverId}
|
||||||
|
AND ebo.handle_at >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month')
|
||||||
|
AND ebo.handle_at < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month'
|
||||||
|
GROUP BY aot.order_type
|
||||||
|
ORDER BY aot.order_type;
|
||||||
|
]]>
|
||||||
</select>
|
</select>
|
||||||
<select id="dayCount" resultType="com.cdzy.operations.model.dto.EbikeBikeOrderDayCountDto">
|
<select id="dayCount" resultType="com.cdzy.operations.model.dto.EbikeBikeOrderDayCountDto">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
SELECT #{receiverId} as receiverId,
|
SELECT #{receiverId} as receiverId,
|
||||||
CASE aot.order_type
|
CASE aot.order_type
|
||||||
WHEN 1 THEN '巡检工单'
|
WHEN 1 THEN '巡检工单'
|
||||||
WHEN 2 THEN '换电工单'
|
WHEN 2 THEN '换电工单'
|
||||||
@ -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,46 +113,68 @@
|
|||||||
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,
|
SELECT #{receiverId} as receiverId,
|
||||||
DATE_TRUNC('week', CURRENT_DATE - INTERVAL '1 week') as last_week_start
|
CASE aot.order_type
|
||||||
)
|
WHEN 1 THEN '巡检工单'
|
||||||
SELECT #{receiverId} as receiverId,
|
WHEN 2 THEN '换电工单'
|
||||||
CASE aot.order_type
|
WHEN 3 THEN '调度工单'
|
||||||
WHEN 1 THEN '巡检工单'
|
WHEN 4 THEN '维修工单'
|
||||||
WHEN 2 THEN '换电工单'
|
END as orderType,
|
||||||
WHEN 3 THEN '调度工单'
|
COALESCE(COUNT(CASE
|
||||||
WHEN 4 THEN '维修工单'
|
WHEN ebo.handle_at >= wr.current_week_start
|
||||||
END as orderType,
|
AND ebo.handle_at < wr.current_week_end
|
||||||
COALESCE(COUNT(CASE
|
THEN 1
|
||||||
WHEN ebo.handle_at >= wr.current_week_start
|
END), 0) as thisWeekCount,
|
||||||
AND ebo.handle_at < wr.current_week_end
|
COALESCE(COUNT(CASE
|
||||||
THEN 1
|
WHEN ebo.handle_at >= wr.last_week_start
|
||||||
END), 0) as thisWeekCount,
|
AND ebo.handle_at < wr.current_week_start
|
||||||
COALESCE(COUNT(CASE
|
THEN 1
|
||||||
WHEN ebo.handle_at >= wr.last_week_start
|
END), 0) as lastWeekCount,
|
||||||
AND ebo.handle_at < wr.current_week_start
|
COALESCE(
|
||||||
THEN 1
|
CASE
|
||||||
END), 0) as lastWeekCount
|
WHEN COALESCE(COUNT(CASE
|
||||||
FROM generate_series(1, 4) as aot(order_type)
|
WHEN ebo.handle_at >= wr.last_week_start
|
||||||
CROSS JOIN week_range wr
|
AND ebo.handle_at < wr.current_week_start
|
||||||
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
THEN 1
|
||||||
AND ebo.handle_state = 2
|
END), 0) = 0
|
||||||
AND ebo.handle_at IS NOT NULL
|
THEN 0.0
|
||||||
AND ebo.is_deleted = false
|
ELSE ROUND(
|
||||||
AND ebo.receiver_id = #{receiverId}
|
(COALESCE(COUNT(CASE
|
||||||
AND ebo.handle_at >= wr.last_week_start
|
WHEN ebo.handle_at >= wr.current_week_start
|
||||||
AND ebo.handle_at < wr.current_week_end
|
AND ebo.handle_at < wr.current_week_end
|
||||||
GROUP BY aot.order_type
|
THEN 1
|
||||||
ORDER BY aot.order_type;
|
END), 0) -
|
||||||
]]>
|
COALESCE(COUNT(CASE
|
||||||
</select>
|
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)
|
||||||
|
CROSS JOIN week_range wr
|
||||||
|
LEFT JOIN ebike_bike_order ebo ON aot.order_type = ebo.order_type
|
||||||
|
AND ebo.handle_state = 2
|
||||||
|
AND ebo.handle_at IS NOT NULL
|
||||||
|
AND ebo.is_deleted = false
|
||||||
|
AND ebo.receiver_id = #{receiverId}
|
||||||
|
AND ebo.handle_at >= wr.last_week_start
|
||||||
|
AND ebo.handle_at < wr.current_week_end
|
||||||
|
GROUP BY aot.order_type
|
||||||
|
ORDER BY aot.order_type;
|
||||||
|
]]>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user