|
@@ -10,12 +10,24 @@
|
|
|
<result property="count" column="count_num"/>
|
|
|
</resultMap>
|
|
|
|
|
|
- <select id="statisticsByRule" resultMap="byRule">
|
|
|
- select rule.id as rule_id,rule.`name` as rule_name,count(record.id) as count_num
|
|
|
+ <select id="statisticsByRule" parameterType="string" resultMap="byRule">
|
|
|
+ SELECT t.id as rule_id,t.`name` as rule_name,IFNULL(temp.count_num,'0') as count_num
|
|
|
+ from ax_beidou_warning_rule t
|
|
|
+ LEFT JOIN
|
|
|
+ (select rule.id as rule_id,rule.`name` as rule_name,count(record.id) as count_num
|
|
|
from ax_beidou_warning_rule rule
|
|
|
LEFT JOIN ax_beidou_warning_record record on record.rule_id = rule.id
|
|
|
- where rule.del_flag = '0'
|
|
|
- GROUP BY rule.id,rule_name ORDER BY rule.id
|
|
|
+ LEFT JOIN ax_beidou_ship_archives archives ON archives.devide_no = record.device_id
|
|
|
+ LEFT JOIN ax_beidou_dept dept ON archives.police_station_id = dept.pscbh
|
|
|
+ where rule.del_flag = '0' and (record.`start` is null or record.`start` != 'false')
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
+ and dept.xw_dept_id like concat('%',#{deptId},'%')
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime != ''">and record.warning_time > #{startTime}</if>
|
|
|
+ <if test="endTime != null and endTime != ''">and record.warning_time < #{endTime}</if>
|
|
|
+ GROUP BY rule.id,rule_name) as temp ON t.id = temp.rule_id
|
|
|
+ where t.del_flag = '0'
|
|
|
+ ORDER BY t.id
|
|
|
</select>
|
|
|
|
|
|
<select id="warningRecordList" parameterType="string" resultType="warningRecordListResult">
|
|
@@ -25,12 +37,12 @@
|
|
|
record.warning_time AS warningTime, dis.id AS disposeId ,temp.num as num,
|
|
|
location.location
|
|
|
FROM ax_beidou_warning_record record
|
|
|
- INNER JOIN (select rec.device_id,MAX(rec.id) as id,count(rec.device_id) AS num
|
|
|
+ INNER JOIN (select rec.device_id,MAX(UNIX_TIMESTAMP(rec.warning_time)) as `time`,count(rec.device_id) AS num
|
|
|
from ax_beidou_warning_record rec
|
|
|
where rec.rule_id = #{ruleId}
|
|
|
<if test="startTime != null and startTime != ''">and rec.warning_time > #{startTime}</if>
|
|
|
<if test="endTime != null and endTime != ''">and rec.warning_time < #{endTime}</if>
|
|
|
- GROUP BY rec.device_id) as temp on record.id = temp.id
|
|
|
+ GROUP BY rec.device_id) as temp on UNIX_TIMESTAMP(record.warning_time) = temp.time and record.device_id = temp.device_id
|
|
|
INNER JOIN ax_beidou_ship_archives archives ON archives.devide_no = record.device_id
|
|
|
LEFT JOIN ax_beidou_ship_dispose dis ON record.id = dis.warning_id
|
|
|
LEFT JOIN ax_beidou_warning_area area ON area.id = record.area_id
|
|
@@ -57,16 +69,22 @@
|
|
|
select record.id,warning_time as warningTime,dis.id as disposeId
|
|
|
from ax_beidou_warning_record record
|
|
|
LEFT JOIN ax_beidou_ship_dispose dis ON dis.warning_id = record.id
|
|
|
- where record.device_id = #{devideNo} and record.rule_id = #{ruleId} and (record.`start` is null or record.`start` != 'false') ORDER BY warning_time DESC
|
|
|
+ where record.device_id = #{devideNo} and record.rule_id = #{ruleId}
|
|
|
+ and (record.`start` is null or record.`start` != 'false')
|
|
|
+ <if test="startTime != null and startTime != ''">and record.warning_time > #{startTime}</if>
|
|
|
+ <if test="endTime != null and endTime != ''">and record.warning_time < #{endTime}</if>
|
|
|
+ ORDER BY warning_time DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="warningRecordExcel" parameterType="string" resultType="warningRecordExcel">
|
|
|
select archives.devide_no as devideNo,archives.ship_id as shipId,archives.owner_name as ownerName,archives.owner_tel_no as ownerTelNo,
|
|
|
+ area.name as warningDetail,
|
|
|
record.warning_time as warningTime,location.longitude,location.latitude,dept.xw_dept_name as deptName
|
|
|
from ax_beidou_warning_record record
|
|
|
INNER JOIN ax_beidou_ship_archives archives ON archives.devide_no = record.device_id
|
|
|
INNER JOIN ax_beidou_dept dept ON archives.police_station_id = dept.pscbh
|
|
|
LEFT JOIN ax_beidou_ship_location location ON location.device_id = record.device_id
|
|
|
+ LEFT JOIN ax_beidou_warning_area area ON area.id = record.area_id
|
|
|
<where>
|
|
|
record.rule_id = #{ruleId} and (record.`start` is null or record.`start` != 'false')
|
|
|
<if test="deptId != null and deptId != ''">
|