From b111f23684e8e85a36e670fcc1db19e8cb12ae9e Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Wed, 08 Apr 2026 13:46:52 +0800
Subject: [PATCH] opt: 人大金仓数据库改造
---
drone-ops/drone-resource/src/main/java/org/sxkj/resource/mapper/AttachMapper.xml | 60 ++++++++++++++++++++++++++++++++----------------------------
1 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/drone-ops/drone-resource/src/main/java/org/sxkj/resource/mapper/AttachMapper.xml b/drone-ops/drone-resource/src/main/java/org/sxkj/resource/mapper/AttachMapper.xml
index 6d56f41..fccd353 100644
--- a/drone-ops/drone-resource/src/main/java/org/sxkj/resource/mapper/AttachMapper.xml
+++ b/drone-ops/drone-resource/src/main/java/org/sxkj/resource/mapper/AttachMapper.xml
@@ -23,36 +23,40 @@
<!--自定义分页查询-->
<select id="selectAttachPage" resultType="org.sxkj.resource.vo.AttachVO">
select
- ba.*,
- bd.dept_name,
- coalesce(ba.nick_name,ba.original_name) nickName
+ ba.*,
+ bd.dept_name,
+ coalesce(ba.nick_name,ba.original_name) nickName
from
- blade_attach ba
+ blade_attach ba
left join
- blade_dept bd on ba.create_dept = bd.id::VARCHAR
+ /* 修改点1:双向转为 text 对齐 */
+ blade_dept bd on ba.create_dept::text = bd.id::text
where
- ba.is_deleted = 0
- <if test="attach.originalName!=null and attach.originalName!=''">
- and original_name like concat('%',#{attach.originalName},'%')
+ ba.is_deleted = 0
+ <if test="attach.nickName!=null and attach.nickName!=''">
+ and ba.nick_name like concat('%',#{attach.nickName},'%')
</if>
<if test="attach.resultType!=null">
- and result_type = #{attach.resultType}
+ /* 修改点2:如果 resultType 是字符串传入,也需加权转 */
+ and ba.result_type::text = #{attach.resultType}::text
</if>
<if test="attach.deptList != null and attach.deptList.size > 0">
- and ba.create_dept in
+ and ba.create_dept::text in
<foreach collection="attach.deptList" item="deptId" open="(" separator="," close=")">
- #{deptId}
+ #{deptId}::text
</foreach>
</if>
- and result_type in (1,2,3,4,5)
- order by create_time desc,id desc
+ /* 修改点3:result_type 如果是字符型字段,数字必须加单引号 */
+ and ba.result_type::text in ('1','2','3','4','5')
+ order by ba.create_time desc, ba.id desc
</select>
+
<select id="findAiAttachImages" resultType="org.sxkj.resource.vo.AttachVO">
select
DISTINCT attach.id,
attach.link,
attach.name,
- ifNull( attach.nick_name,SUBSTRING_INDEX( SUBSTRING_INDEX( attach.NAME, '/', - 1 ), '.', 1 )) AS nick_name,
+ COALESCE( attach.nick_name,SUBSTRING_INDEX( SUBSTRING_INDEX( attach.NAME, '/', - 1 ), '.', 1 )) AS nick_name,
attach.original_name,
attach.extension,
attach.device_sn,
@@ -69,9 +73,9 @@
wj.name AS job_name,
rela.status
from blade_attach attach
- left join drone_job_event_rela rela on attach.id = rela.attach_id::VARCHAR
- left join wayline_job wj ON attach.wayline_job_id = wj.job_id::VARCHAR
- left join wayline_job_info info on wj.job_info_id = info.id::VARCHAR
+ left join drone_job_event_rela rela on attach.id::VARCHAR = rela.attach_id::VARCHAR
+ left join wayline_job wj ON attach.wayline_job_id::VARCHAR = wj.job_id::VARCHAR
+ left join wayline_job_info info on wj.job_info_id::VARCHAR = info.id::VARCHAR
where attach.is_deleted = 0
and info.is_deleted = 0
and attach.is_thumbnail = 0
@@ -150,7 +154,7 @@
<select id="findAllMd5ByAi" resultType="org.sxkj.resource.vo.EventImgMd5VO">
select md5,original_md5
from drone_job_event_rela rela
- left join ai_event_record record on rela.ai_event_record_uuid = record.uuid::VARCHAR
+ left join ai_event_record record on rela.ai_event_record_uuid::VARCHAR = record.uuid::VARCHAR
<where>
and record.id in
<foreach collection="aiRecordIds" item="eventRecordId" separator="," open="(" close=")">
@@ -183,7 +187,7 @@
attach.create_time,
rela.status
from blade_attach attach
- right join drone_job_event_rela rela on attach.id = rela.attach_id::VARCHAR
+ right join drone_job_event_rela rela on attach.id::VARCHAR = rela.attach_id::VARCHAR
where attach.is_deleted = 0 and attach.is_thumbnail = 0
<if test="attach.nickName != null and attach.nickName != ''">
AND (nick_name LIKE CONCAT('%', #{attach.nickName}, '%') OR name LIKE CONCAT('%', #{attach.nickName}, '%'))
@@ -219,7 +223,7 @@
attach.link,
attach.name,
attach.attach_size,
- ifNull( attach.nick_name,SUBSTRING_INDEX( SUBSTRING_INDEX( attach.NAME, '/', - 1 ), '.', 1 )) nick_name,
+ COALESCE( attach.nick_name,SUBSTRING_INDEX( SUBSTRING_INDEX( attach.NAME, '/', - 1 ), '.', 1 )) nick_name,
attach.original_name,
attach.extension,
attach.device_sn,
@@ -256,7 +260,7 @@
</if>
device.nickName nestName
from blade_attach attach
- left join wayline_job job on attach.wayline_job_id = job.job_id::VARCHAR
+ left join wayline_job job on attach.wayline_job_id::VARCHAR = job.job_id::VARCHAR
left join wayline_job_info wji on wji.id = job.job_info_id::VARCHAR
left join manage_device device on job.dock_sn = device.device_sn::VARCHAR
left join manage_device_expansion mde on job.dock_sn = mde.device_sn::VARCHAR
@@ -269,10 +273,10 @@
and job.job_info_id is not null
<if test="attach.startTime!=null and attach.startTime!='' and attach.endTime!=null and attach.endTime!=''">
and (DATE_FORMAT(FROM_UNIXTIME(job.execute_time/1000,'%Y-%m-%d %H:%i:%s'),'%Y-%m-%d %H:%i:%s') between
- #{attach.startTime} and #{attach.endTime} or rela.create_time between #{attach.startTime} and #{attach.endTime} )
+ #{attach.startTime} and #{attach.endTime} or rela.create_time between #{attach.startTime}::timestamp and #{attach.endTime}::timestamp )
</if>
<if test="attach.name!=null and attach.name!=''">
- and ifNull(attach.nick_name, SUBSTRING_INDEX(SUBSTRING_INDEX(attach.NAME, '/', -1), '.', 1))
+ and COALESCE(attach.nick_name, SUBSTRING_INDEX(SUBSTRING_INDEX(attach.NAME, '/', -1), '.', 1))
like concat('%',#{attach.name},'%')
</if>
<if test="attach.jobName!=null and attach.jobName!=''">
@@ -453,7 +457,7 @@
'$.shootPosition.lat') ) AS latitude
<if test="resultType!=null and resultType!='' and resultType==4">
,odm.orthoimage_api 'url',
- ST_AsText ( odm.geom ) "geom"
+ public.st_astext ( odm.geom ) "geom"
</if>
from blade_attach attach
left join manage_device device on attach.device_sn = device.device_sn::VARCHAR
@@ -515,7 +519,7 @@
attach.create_time,
attach.link,
rela.event_name,
- ifnull(attach.result_type,2) "result_type"
+ COALESCE(attach.result_type,2) "result_type"
FROM blade_attach attach
LEFT JOIN drone_job_event_rela rela ON attach.id = rela.attach_id::VARCHAR
WHERE
@@ -552,7 +556,7 @@
select attach.create_time,
attach.id,
attach.name,
- ifNull(attach.nick_name, SUBSTRING_INDEX(SUBSTRING_INDEX(attach.NAME, '/', - 1), '.', 1)) nick_name,
+ COALESCE(attach.nick_name, SUBSTRING_INDEX(SUBSTRING_INDEX(attach.NAME, '/', - 1), '.', 1)) nick_name,
attach.link,
attach.device_sn,
attach.metadata,
@@ -579,7 +583,7 @@
select attach.create_time,
attach.id,
attach.name,
- ifNull(attach.nick_name, SUBSTRING_INDEX(SUBSTRING_INDEX(attach.NAME, '/', - 1), '.', 1)) nick_name,
+ COALESCE(attach.nick_name, SUBSTRING_INDEX(SUBSTRING_INDEX(attach.NAME, '/', - 1), '.', 1)) nick_name,
attach.link,
attach.device_sn,
attach.metadata,
@@ -829,7 +833,7 @@
wayline_job j ON a.wayline_job_id = j.job_id::VARCHAR
WHERE
(
- FIND_IN_SET(#{lotInfoId}, j.lot_info_id) > 0
+ #{lotInfoId} = ANY(string_to_array(j.lot_info_id, ',')::bigint[])
OR j.lot_info_id = #{lotInfoId}
)
AND a.result_type = 0 -- 根据您的需求,只查询成果类型为 0 (图片) 的数据
--
Gitblit v1.9.3