From 0b39edb68acc67ed01fbfe5d31bfa776a1b17de1 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期三, 25 三月 2026 09:14:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/show-demo' into show_demo
---
jyz-base-start/src/main/resources/xml/OilRecordMapper.xml | 89 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 88 insertions(+), 1 deletions(-)
diff --git a/jyz-base-start/src/main/resources/xml/OilRecordMapper.xml b/jyz-base-start/src/main/resources/xml/OilRecordMapper.xml
index a4201eb..1c5b368 100644
--- a/jyz-base-start/src/main/resources/xml/OilRecordMapper.xml
+++ b/jyz-base-start/src/main/resources/xml/OilRecordMapper.xml
@@ -52,7 +52,7 @@
select
oil_position oilPosition, count(1) oilCount, sum(oil_volume) OilVolume
from t_oil_record
- where org_code =#{orgCode}
+ where org_code like concat(#{orgCode}, '%')
<if test="dateMonth != null and dateMonth != ''">and DATE_FORMAT(start_time, '%Y-%m')=#{dateMonth}</if>
GROUP BY oil_position
</select>
@@ -87,6 +87,22 @@
<where>
<if test="startTime != null and startTime != ''">and capture_time >= #{startTime}</if>
<if test="endTime != null and endTime != ''">and capture_time < #{endTime}</if>
+ <if test="orgCode != null and orgCode != ''">and org_code like concat(#{orgCode}, '%')</if>
+ </where>
+ </sql>
+ <sql id="statBeforeOilFreqCondition">
+ <where>
+ and behavior = 1
+ <if test="beforeStartTime != null and beforeStartTime != ''">and start_time >= #{beforeStartTime}</if>
+ <if test="beforeEndTime != null and beforeEndTime != ''">and start_time < #{beforeEndTime}</if>
+ <if test="orgCode != null and orgCode != ''">and org_code like concat(#{orgCode}, '%')</if>
+ </where>
+ </sql>
+ <sql id="statAfterOilFreqCondition">
+ <where>
+ and behavior = 1
+ <if test="afterStartTime != null and afterStartTime != ''">and start_time >= #{afterStartTime}</if>
+ <if test="afterEndTime != null and afterEndTime != ''">and start_time < #{afterEndTime}</if>
<if test="orgCode != null and orgCode != ''">and org_code like concat(#{orgCode}, '%')</if>
</where>
</sql>
@@ -183,6 +199,38 @@
GROUP BY org_code
limit 10
</select>
+ <select id="statisOilFreqCompare" resultType="java.util.Map" parameterType="com.tievd.jyz.entity.vo.DataStatisReqVo">
+ select
+ l.licenseNum licenseNum,
+ ifnull(b.beforeOilCount, 0) beforeOilCount,
+ ifnull(a.afterOilCount, 0) afterOilCount,
+ ifnull(a.afterOilCount, 0) - ifnull(b.beforeOilCount, 0) diffOilCount,
+ case
+ when ifnull(b.beforeOilCount, 0) = 0 then null
+ else round((ifnull(a.afterOilCount, 0) - ifnull(b.beforeOilCount, 0)) * 100 / ifnull(b.beforeOilCount, 0), 2)
+ end diffRate
+ from (
+ select license_num licenseNum from t_oil_record
+ <include refid="statBeforeOilFreqCondition"/>
+ union
+ select license_num licenseNum from t_oil_record
+ <include refid="statAfterOilFreqCondition"/>
+ ) l
+ left join (
+ select license_num licenseNum, count(1) beforeOilCount
+ from t_oil_record
+ <include refid="statBeforeOilFreqCondition"/>
+ group by license_num
+ ) b on l.licenseNum = b.licenseNum
+ left join (
+ select license_num licenseNum, count(1) afterOilCount
+ from t_oil_record
+ <include refid="statAfterOilFreqCondition"/>
+ group by license_num
+ ) a on l.licenseNum = a.licenseNum
+ order by afterOilCount desc, beforeOilCount desc, licenseNum asc
+ limit 200
+ </select>
<select id="statFanByModel" resultType="com.tievd.jyz.entity.vo.StatDataTableVo" parameterType="com.tievd.jyz.entity.vo.DataStatisReqVo">
select
count(if(behavior=1,1,null)) oilCount,
@@ -220,4 +268,43 @@
GROUP BY model_code
) f on m.model_code = f.model_code
</select>
+
+ <select id="getVehicleFrequencyBeforeActivity" resultType="java.util.Map">
+ SELECT
+ COUNT(DISTINCT license_num) as totalVehicles,
+ COUNT(*) as totalOilRecords,
+ AVG(oil_volume) as avgOilVolume,
+ SUM(oil_volume) as totalOilVolume
+ FROM t_oil_record
+ WHERE start_time < #{startTime}
+ <foreach collection="orgCodes" item="orgCode" open="AND (" separator=" OR " close=")">
+ org_code LIKE concat(#{orgCode}, '%')
+ </foreach>
+ </select>
+
+ <select id="getVehicleFrequencyDuringActivity" resultType="java.util.Map">
+ SELECT
+ COUNT(DISTINCT license_num) as totalVehicles,
+ COUNT(*) as totalOilRecords,
+ AVG(oil_volume) as avgOilVolume,
+ SUM(oil_volume) as totalOilVolume
+ FROM t_oil_record
+ WHERE start_time >= #{startTime} AND start_time <= #{endTime}
+ <foreach collection="orgCodes" item="orgCode" open="AND (" separator=" OR " close=")">
+ org_code LIKE concat(#{orgCode}, '%')
+ </foreach>
+ </select>
+
+ <select id="getVehicleFrequencyAfterActivity" resultType="java.util.Map">
+ SELECT
+ COUNT(DISTINCT license_num) as totalVehicles,
+ COUNT(*) as totalOilRecords,
+ AVG(oil_volume) as avgOilVolume,
+ SUM(oil_volume) as totalOilVolume
+ FROM t_oil_record
+ WHERE start_time > #{endTime}
+ <foreach collection="orgCodes" item="orgCode" open="AND (" separator=" OR " close=")">
+ org_code LIKE concat(#{orgCode}, '%')
+ </foreach>
+ </select>
</mapper>
--
Gitblit v1.8.0