<?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="org.sxkj.resource.mapper.IFileMapper">
|
<select id="getPage" resultType="org.sxkj.resource.entity.MediaFileEntity">
|
SELECT * FROM media_new_file WHERE workspace_id = #{workspaceId}
|
|
<if test="query.startTime !=null and query.endTime !=null">
|
AND DATE_FORMAT(FROM_UNIXTIME(create_time/1000,'%Y-%m-%d'),'%Y-%m-%d') >=
|
DATE_FORMAT(#{query.startTime},'%Y-%m-%d')
|
</if>
|
|
<if test="query.endTime !=null and query.endTime !=null">
|
AND DATE_FORMAT(FROM_UNIXTIME(create_time/1000,'%Y-%m-%d'),'%Y-%m-%d') <=
|
DATE_FORMAT(#{query.endTime},'%Y-%m-%d')
|
</if>
|
|
<if test="query.name !=null and query.name !=null">
|
AND file_name LIKE CONCAT('%',#{query.name},'%')
|
</if>
|
|
<if test="query.subFileType != null and query.subFileType !='' ">
|
AND sub_file_type in
|
<foreach collection="query.subFileType.split(',')" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
|
<if test="query.payload != null and query.payload !='' ">
|
AND payload LIKE CONCAT('%',#{query.payload},'%')
|
</if>
|
ORDER BY create_time DESC
|
</select>
|
<select id="mediaPage" resultType="org.sxkj.resource.model.MediaJobDTO">
|
SELECT
|
j.collect_status,
|
m.job_id,
|
t.url,
|
COUNT( CASE WHEN m.file_name LIKE '%.mp4' THEN 1 END) AS videoCount,
|
COUNT( CASE WHEN m.file_name LIKE '%.jpeg' THEN 1 END ) AS picCount,
|
DATE_FORMAT(FROM_UNIXTIME(j.create_time/1000,'%Y-%m-%d'),'%Y-%m-%d') as create_time
|
FROM
|
media_file m LEFT JOIN wayline_job j ON m.job_id = j.job_id
|
-- LEFT JOIN (SELECT CONCAT("https://dev.jxpskj.com:8026/cloud-bucket",object_key) as url,job_id from media_file
|
WHERE file_name LIKE '%.jpeg' GROUP BY job_id) t ON t.job_id = m.job_id
|
LEFT JOIN (SELECT CONCAT(#{param.fileAddress},object_key) as url,job_id from media_file WHERE file_name LIKE
|
'%.jpeg' GROUP BY job_id) t ON t.job_id = m.job_id
|
LEFT JOIN wayline_file w ON w.wayline_id = j.file_id
|
where 1=1
|
<if test="workspaceId != null and workspaceId != ''">
|
and j.workspace_id = #{workspaceId}
|
</if>
|
<if test="param.dockSn !=null and param.dockSn != ''">
|
and j.dock_sn = #{param.dockSn}
|
</if>
|
<if test="param.startTime !=null and param.endTime !=null">
|
AND DATE_FORMAT(FROM_UNIXTIME(j.create_time/1000,'%Y-%m-%d'),'%Y-%m-%d') >=
|
DATE_FORMAT(#{param.startTime},'%Y-%m-%d')
|
</if>
|
|
<if test="param.endTime !=null and param.endTime !=null">
|
AND DATE_FORMAT(FROM_UNIXTIME(j.create_time/1000,'%Y-%m-%d'),'%Y-%m-%d') <=
|
DATE_FORMAT(#{param.endTime},'%Y-%m-%d')
|
</if>
|
<if test="param.waylineFileId != null and param.waylineFileId != ''">
|
and w.wayline_id = #{param.waylineFileId}
|
</if>
|
GROUP BY m.job_id
|
ORDER BY
|
<if test="param.sort eq 2">
|
j.collect_status = 1 desc,
|
</if>
|
<if test="param.sort eq 3">
|
m.collect_status = 1 desc,
|
</if>
|
j.create_time desc
|
</select>
|
<select id="mediaDetail" resultType="org.sxkj.resource.model.MediaJobDTO">
|
SELECT
|
m.collect_status,
|
m.job_id,
|
m.file_id,
|
CONCAT(#{fileAddress},m.object_key) as url,
|
CASE WHEN m.file_name LIKE '%.mp4' THEN "视频" ELSE "图片" END AS type,
|
DATE_FORMAT( FROM_UNIXTIME( m.create_time / 1000, '%Y-%m-%d' ), '%Y-%m-%d' ) AS create_time
|
FROM
|
media_file m
|
WHERE
|
1 = 1
|
<if test="jobId != null and jobId != ''">
|
and m.job_id = #{jobId}
|
</if>
|
ORDER BY type = '视频' DESC
|
</select>
|
|
<!--查询odm 信息-->
|
<select id="getOdm" resultType="org.sxkj.common.model.OdmUrlDto">
|
SELECT
|
odm.base_path basePath,
|
wj.dkbh,
|
IFNULL(odm.ort_tb_path,odm.orthoimage_path) path,
|
FROM_UNIXTIME( wj.completed_time/ 1000) as createTime,
|
md.nickname as airportName
|
FROM
|
odm_task_info odm
|
LEFT JOIN wayline_job wj ON wj.job_id = odm.wayline_job_id
|
LEFT JOIN manage_device md on md.device_sn = wj.dock_sn
|
<where>
|
AND wj.job_type = 4
|
AND wj.workspace_id = #{workspaceId}
|
<if test="dkbhList != null and dkbhList.size() > 0">
|
AND wj.dkbh in
|
<foreach collection="dkbhList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
AND date_format(FROM_UNIXTIME( wj.completed_time/1000),'%Y-%m-%d') between #{startTime} and #{endTime}
|
</if>
|
AND odm.running_progress = 1.00
|
AND odm.orthoimage_path IS NOT NULL
|
ORDER BY
|
wj.end_time DESC
|
</where>
|
</select>
|
|
|
<select id="getMediaFieByTid" resultType="org.sxkj.resource.entity.MediaFileEntity">
|
select *
|
from (SELECT *
|
from media_new_file
|
where drone = #{deviceId}) a
|
where CAST(JSON_EXTRACT(metadata, '$.createdTime') AS UNSIGNED) >= #{timestamp}
|
ORDER BY CAST(JSON_EXTRACT(metadata, '$.createdTime') / 1000 AS UNSIGNED) ASC
|
LIMIT 1;
|
</select>
|
|
<!--媒体文件信息查询-->
|
<select id="getMediaFileByObjectKey" resultType="org.sxkj.resource.entity.MediaFileEntity">
|
SELECT *
|
FROM media_new_file
|
WHERE object_key = #{objectKey}
|
limit 1
|
</select>
|
|
<!--根据类型获取数据成果数量-->
|
<select id="getMediaFileCountByResultType" resultType="org.sxkj.resource.vo.MediaFileCountVO">
|
SELECT
|
IFNULL( sum( CASE WHEN result_type = 0 THEN 1 ELSE 0 END ), 0 ) AS "phoneNum",
|
IFNULL( sum( CASE WHEN result_type = 1 THEN 1 ELSE 0 END ), 0 ) AS "videoNum",
|
IFNULL( sum( CASE WHEN result_type = 2 THEN 1 ELSE 0 END ), 0 ) AS "aiNum",
|
IFNULL( sum( CASE WHEN result_type = 3 THEN 1 ELSE 0 END ), 0 ) AS "gisNum",
|
IFNULL( sum( CASE WHEN result_type = 4 THEN 1 ELSE 0 END ), 0 ) AS "tifNum",
|
IFNULL( sum( CASE WHEN result_type = 5 THEN 1 ELSE 0 END ), 0 ) AS "fullNum"
|
FROM
|
blade_attach a
|
LEFT JOIN wayline_job wj ON a.wayline_job_id = wj.job_id
|
left JOIN wayline_job_info wji ON wji.id = wj.job_info_id AND wji.is_deleted = 0
|
left join drone_job_event_rela rela on a.id = rela.attach_id
|
<where>
|
<if test="resultType != null">
|
AND a.result_type = #{resultType}
|
</if>
|
<if test="areaCode != null and areaCode != ''">
|
AND wj.area_code LIKE CONCAT(#{areaCode}, '%')
|
</if>
|
|
<if test="deptIdList!=null and deptIdList.size>0">
|
AND a.create_dept IN
|
<foreach collection="deptIdList" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="permissionCondition != null and permissionCondition != ''">
|
AND ${permissionCondition}
|
</if>
|
AND (rela.is_deleted = 0 or rela.is_deleted is null)
|
AND a.is_deleted = 0
|
AND wji.is_deleted = 0
|
AND wj.job_info_id is not null
|
AND a.result_type IN ( 0, 1, 2, 3, 4, 5,15 )
|
</where>
|
</select>
|
|
|
<!-- 计算三维面积 -->
|
<select id="calculateTheThreeDimensionalArea" resultType="org.sxkj.resource.vo.MediaFileCountVO">
|
SELECT
|
ROUND( sum( wj3d.area ) / 1000000, 2 ) AS gisNum
|
FROM
|
blade_attach a
|
LEFT JOIN wayline_job wj ON a.wayline_job_id = wj.job_id
|
left JOIN wayline_job_info wji ON wji.id = wj.job_info_id AND wji.is_deleted = 0
|
left join drone_job_event_rela rela on a.id = rela.attach_id
|
left join wayline_job_3d_record wj3d on wj3d.job_id = wj.job_id
|
<where>
|
<if test="resultType != null">
|
AND a.result_type = #{resultType}
|
</if>
|
<if test="areaCode != null and areaCode != ''">
|
AND wj3d.area_code LIKE CONCAT(#{areaCode}, '%')
|
</if>
|
<if test="deptIdList!=null and deptIdList.size>0">
|
AND a.create_dept IN
|
<foreach collection="deptIdList" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="permissionCondition != null and permissionCondition != ''">
|
AND ${permissionCondition}
|
</if>
|
AND (rela.is_deleted = 0 or rela.is_deleted is null)
|
AND a.is_deleted = 0
|
AND wji.is_deleted = 0
|
AND wj.job_info_id is not null
|
AND a.result_type in (3,13)
|
AND wj3d.is_deleted = 0
|
</where>
|
</select>
|
|
<!--根据类型获取数据成果数量-->
|
<select id="getCountByResultType" resultType="org.sxkj.resource.vo.MediaFileCountVO">
|
SELECT
|
IFNULL( sum( CASE WHEN result_type = 3 THEN 1 ELSE 0 END ), 0 ) AS "gisNum",
|
IFNULL( sum( CASE WHEN result_type = 5 THEN 1 ELSE 0 END ), 0 ) AS "fullNum"
|
FROM
|
blade_attach a
|
LEFT JOIN blade_dept b ON (a.create_dept = b.id)
|
<where>
|
-- 成果类型:0图片,1=视频,2=ai,3=三维,4=正射,5=全景, 6=图片压缩小,7=图片压缩中,8视频一帧图,9视频压缩,10ai压缩小,11ai压缩中',
|
AND a.result_type IN ( 3, 5 )
|
AND a.is_deleted = 0
|
</where>
|
</select>
|
|
|
<select id="timeEventNumStatistics" resultType="org.sxkj.resource.vo.JobStatisticsTimeVoBo">
|
select count(*) "num", DATE_FORMAT(create_time,#{formatTime}) "time"
|
FROM
|
blade_attach a
|
LEFT JOIN wayline_job wj ON a.wayline_job_id = wj.job_id
|
left JOIN wayline_job_info wji ON wji.id = wj.job_info_id and wji.is_deleted = 0
|
LEFT JOIN blade_dept b ON (a.create_dept = b.id)
|
<where>
|
<if test="startDate!=null">
|
and a.create_time >= #{startDate}
|
</if>
|
<if test="endDate!=null">
|
and a.create_time <= #{endDate}
|
</if>
|
and a.result_type in(0,1)
|
and a.is_deleted = 0
|
</where>
|
group by DATE_FORMAT(create_time,#{formatTime})
|
</select>
|
|
<select id="countEventNumStatistics" resultType="java.lang.Long">
|
select count(*) "num"
|
FROM
|
blade_attach a
|
LEFT JOIN wayline_job wj ON a.wayline_job_id = wj.job_id
|
left JOIN wayline_job_info wji ON wji.id = wj.job_info_id and wji.is_deleted = 0
|
LEFT JOIN blade_dept b ON (a.create_dept = b.id)
|
<where>
|
<if test="startDate!=null">
|
and a.create_time >= #{startDate}
|
</if>
|
<if test="endDate!=null">
|
and a.create_time <= #{endDate}
|
</if>
|
and a.result_type in(0,1)
|
and a.is_deleted = 0
|
</where>
|
</select>
|
|
|
<!--媒体文件信息更新-->
|
<update id="updateMediaFileByObjectKey">
|
update media_new_file
|
set min_object_key = #{minObjectKey}
|
WHERE object_key = #{objectKey}
|
</update>
|
|
|
<delete id="batchDeleteByKeys" parameterType="java.util.List">
|
DELETE FROM media_new_file
|
WHERE id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
|
<select id="findNearByMediaUrl" resultType="org.sxkj.resource.entity.MediaFileEntity">
|
SELECT domain_url,file_path,file_name,create_time
|
FROM media_new_file
|
WHERE ST_Distance_Sphere(
|
POINT(#{longitude}, #{latitude}),
|
POINT(json_extract(metadata,"$.shootPosition.lng"), json_extract(metadata,"$.shootPosition.lat"))
|
|
) <= #{distance}
|
<if test="startDate!=null">
|
and create_time >=#{startDateLong}
|
</if>
|
<if test="endDate!=null">
|
and create_time <=#{endDateLong}
|
</if>
|
</select>
|
</mapper>
|