吉安感知网项目-后端
xiebin
2026-04-01 eeb3b5c9c794a35d7b7f3c8e56f9eef8eb8d3451
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
<?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.odm.mapper.OdmTaskInfoMapper">
 
    <!--自定义分页查询-->
    <select id="selectOdmTaskInfoPage" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT
        oti.*,
        wj.name as taskName,wj.job_type as waylineType,wj.dkbh,
        date_format(FROM_UNIXTIME( wj.completed_time/ 1000),'%Y-%m-%d %H:%i:%s') as completedTime,
        md.nickname as airportName,
        wfe.gsd
        FROM
        odm_task_info oti
        left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR
        left join manage_device md on md.device_sn = wj.dock_sn::VARCHAR
        left join blade_dept bd on bd.id = md.dept_id::VARCHAR and bd.is_deleted = 0
        left join wayline_file_extension wfe on wj.file_id = wfe.wayline_id::VARCHAR
        <where>
            and oti.is_deleted = 0
            <if test="odmTaskInfo.waylineJobId!=null and odmTaskInfo.waylineJobId!=''">
                and oti.wayline_job_id = #{odmTaskInfo.waylineJobId}
            </if>
            <if test="odmTaskInfo.taskName!=null and odmTaskInfo.taskName!=''">
                and wj.name like concat('%',#{odmTaskInfo.taskName},'%')
            </if>
            <if test="odmTaskInfo.airportName!=null and odmTaskInfo.airportName!=''">
                and md.nickname like concat('%',#{odmTaskInfo.airportName},'%')
            </if>
            <if test="odmTaskInfo.status!=null">
                and oti.status = #{odmTaskInfo.status}
            </if>
            <if test="odmTaskInfo.waylineType!=null">
                and wj.job_type = #{odmTaskInfo.waylineType}
            </if>
            <if test="odmTaskInfo.deptId!=null">
                and bd.id = #{odmTaskInfo.deptId}
            </if>
            <if test="odmTaskInfo.completedTime!=null and odmTaskInfo.completedTime!=''">
                and date_format(FROM_UNIXTIME( wj.completed_time/ 1000),'%Y-%m-%d') = #{odmTaskInfo.completedTime}
            </if>
            <if test="odmTaskInfo.deptIdList!=null and odmTaskInfo.deptIdList.size>0">
                AND wj.create_dept IN
                <foreach collection="odmTaskInfo.deptIdList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="odmTaskInfo.permissionCondition != null and odmTaskInfo.permissionCondition != ''">
                AND ${odmTaskInfo.permissionCondition}
            </if>
        </where>
        order by oti.id desc,oti.create_time desc
    </select>
 
    <!--查询航线任务类型,航线任务状态需是已完成的-->
    <select id="getWaylineType" resultType="java.lang.Integer">
        select
        wj.job_type
        from wayline_job  wj
        where wj.job_id = #{jobId}
        and wj.status = 3
        and wj.job_type in
        <foreach collection="types" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
 
    <!--查询航线任务图片url集合-->
    <select id="getWaylinePicUrl" resultType="java.lang.String">
        select
        concat('/',SUBSTRING(original_name, LOCATE('/', original_name) + 1))
        from blade_attach
        where wayline_job_id = #{jobId}
        <if test="waylineType!=null">
          <choose>
              <when test="waylineType==6">
                  and original_name LIKE '%.mp4%'
                  and result_type = 1
              </when>
              <otherwise>
                  and original_name LIKE '%.jpeg%'
                  and result_type = 0
              </otherwise>
          </choose>
        </if>
        and media_category = 0
        GROUP BY original_name
    </select>
 
    <!--查询 running_progress 小于 1 的任务并且是已更新完成的-->
    <select id="selectOdmTaskListLess1" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        select oti.*,wj.job_type as waylineType,wj.dkbh,wj.workspace_id as workspaceId,wj.dock_sn as deviceSn,wj.name as waylineJobName,
               date_format(FROM_UNIXTIME( wj.completed_time/ 1000),'%Y-%m-%d %H:%i:%s') as completedTime
        from odm_task_info oti
        left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR and wj.is_deleted = 0
        where
        oti.running_progress &lt; 1.0 and oti.is_update = 0 and oti.is_deleted = 0
    </select>
 
    <!--根据图斑编号 查询导出对应的正射影像信息-->
    <select id="getTbOrthoimageInfo" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT
        oti.project_id,
        oti.task_id,
        oti.wayline_job_id,
        oti.image_count,
        oti.upload_progress,
        oti.resize_progress,
        oti.running_progress,
        oti.processing_time,
        oti.base_path,
        oti.orthoimage_path,
        oti.ort_tb_path,
        oti.orthoimage_api,
        oti.tiles_path,
        oti.status,
        oti.is_update,
        oti.create_time,
        oti.error_num,
        oti.last_error,
        oti.file_del_flag,
        oti.type,
        oti.dem_tif_path,
        oti.vox_grid_tiles_path,
        oti.device_sn,
        wj.dkbh,
        IFNULL( ST_AsText ( oti.geom ), ifnull( tli.sdfw, tli.dkfw )) AS geom
        FROM odm_task_info oti
        left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR
        left join tb_lot_info tli on tli.dkbh = wj.dkbh::VARCHAR
        where oti.is_deleted = 0
        <if test="runningProgress!=null">
            and oti.running_progress = 1.00::VARCHAR
        </if>
        <if test="otrTaskTypes != null and otrTaskTypes.size()>0">
            AND wj.job_type IN
            <foreach collection="otrTaskTypes" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="jobId!=null and jobId != ''">
            and wj.job_id = #{jobId}
        </if>
        <if test="dkbh!=null and dkbh != '' ">
            and wj.dkbh = #{dkbh}
        </if>
        order by oti.id desc,oti.create_time desc
        limit 1
    </select>
 
    <select id="listTbOrthoimageInfoAsc" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT DISTINCT
        oti.project_id,
        oti.task_id,
        oti.wayline_job_id,
        oti.image_count,
        oti.upload_progress,
        oti.resize_progress,
        oti.running_progress,
        oti.processing_time,
        oti.base_path,
        oti.orthoimage_path,
        oti.ort_tb_path,
        oti.orthoimage_api,
        oti.tiles_path,
        oti.status,
        oti.is_update,
        oti.create_time,
        oti.error_num,
        oti.last_error,
        oti.file_del_flag,
        oti.type,
        oti.dem_tif_path,
        oti.vox_grid_tiles_path,
        oti.device_sn,
        tli.dkbh,
        IFNULL( ST_AsText ( oti.geom ), ifnull( tli.sdfw, tli.dkfw )) AS geom
        FROM
        odm_task_info oti
        LEFT JOIN wayline_job wj ON wj.job_id = oti.wayline_job_id::VARCHAR AND wj.is_deleted = 0
        LEFT JOIN tb_lot_info tli ON tli.id = wj.lot_info_id::VARCHAR AND tli.is_deleted = 0
        WHERE
        oti.is_deleted = 0
        <if test="runningProgress != null">
            AND oti.running_progress = 1.00::VARCHAR
        </if>
        <if test="otrTaskTypes != null and otrTaskTypes.size()>0">
            AND wj.job_type IN
            <foreach collection="otrTaskTypes" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="jobId != null and jobId != ''">
            AND wj.job_id = #{jobId}
        </if>
        <if test="lotInfoId != null and lotInfoId != ''">
            AND (
                FIND_IN_SET(#{lotInfoId}, wj.lot_info_id) > 0
                OR wj.lot_info_id = #{lotInfoId}
            )
        </if>
        ORDER BY
        oti.id ASC, oti.create_time ASC
    </select>
    <!--查询所有未在 webodm 创建任务的任务信息,一次暂时只处理1个-->
    <select id="getNotByWebOdmCreateTaskList" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT oti.*,wfe.gsd FROM odm_task_info oti
        left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR
        left join wayline_file_extension wfe on wj.file_id = wfe.wayline_id::VARCHAR
        where (oti.task_id is null or  oti.task_id = '')
        and oti.is_deleted = 0
        order by oti.id desc
        limit 1
    </select>
 
    <!--查询异常任务,异常次数3以下的,超过3次可以手动触发,不会自动进行重试,外加取消的任务,暂定每次只处理一个,每次只查询一个-->
    <select id="getErrorWebOdmTaskList" resultType="org.sxkj.odm.entity.OdmTaskInfo">
        SELECT * FROM odm_task_info
        where status = 30 and is_deleted = 0 and error_num &lt; 3
        or status = 50
        limit 1
    </select>
 
    <!--查询在执行的任务数-->
    <select id="getProcessTaskNum" resultType="java.lang.Integer">
        SELECT count(*) FROM odm_task_info where is_deleted = 0 and (status = 10 or status = 20)
    </select>
 
    <!--查询没有生成的odm任务航线任务-->
    <select id="getNoCreateTaskJob" resultType="java.lang.String">
        SELECT wj.job_id FROM wayline_job wj
        LEFT JOIN odm_task_info oti ON wj.job_id = oti.wayline_job_id::VARCHAR and oti.is_deleted = 0
        WHERE wj.STATUS = 3
          AND wj.is_deleted = 0
          AND wj.job_type IN
            <foreach collection="types" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
          AND oti.id is null
        order by wj.id desc limit 1
    </select>
 
    <!--根据航线任务id获取对应的机构id-->
    <select id="getCreateDeptId" resultType="java.lang.Long">
        select md.dept_id from wayline_job wj
        left join manage_device md on md.device_sn = wj.dock_sn::VARCHAR
        where wj.job_id = #{jobId}
    </select>
 
    <!--查询已完成没有保存到附件表的任务信息集合-->
    <select id="getNoSaveAttachOdmTaskInfoList" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT
            oti.*,wj.job_type as waylineType,wj.dkbh,wj.workspace_id as workspaceId,wj.dock_sn as deviceSn,wj.name as waylineJobName,
            date_format(FROM_UNIXTIME( wj.start_time/ 1000),'%Y-%m-%d %H:%i:%s') as startTime,
            date_format(FROM_UNIXTIME( wj.completed_time/ 1000),'%Y-%m-%d %H:%i:%s') as completedTime
        FROM
            odm_task_info oti
            LEFT JOIN blade_attach ba ON CONCAT( oti.base_path, oti.orthoimage_path )= ba.NAME and ba.is_deleted = 0
            left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR and wj.is_deleted = 0
        WHERE
            ba.id IS NULL
          AND oti.is_deleted = 0
          AND oti.type = 0
          AND oti.STATUS = 40
          AND oti.is_update = 1
          AND file_del_flag = 0
          AND wj.id is not null
    </select>
 
    <!--查询同一图斑重复的任务(历史)-->
    <select id="selectReqOdmList" resultType="org.sxkj.odm.entity.OdmTaskInfo">
        SELECT * FROM odm_task_info
        WHERE id IN (
            SELECT id  FROM (
                SELECT
                    min( oti.id ) AS id,
                    wj.dkbh,
                    count(*) AS c
                FROM
                    odm_task_info oti
                    LEFT JOIN wayline_job wj ON wj.job_id = oti.wayline_job_id::VARCHAR
                WHERE
                    oti.running_progress = 1.00::VARCHAR
                    AND oti.is_deleted = 0
                    AND wj.dkbh IS NOT NULL
                GROUP BY
                    wj.dkbh
                ) a WHERE c > 1
        )
    </select>
 
 
    <!--查询航线任务已经删除的任务-->
    <select id="selectRemWayJobList" resultType="org.sxkj.odm.entity.OdmTaskInfo">
        SELECT
            oti.*
        FROM
            odm_task_info oti
            left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR
        WHERE
            wj.id IS NULL
            AND oti.is_deleted = 0
    </select>
 
    <!--根据航线任务id 获取地块编号-->
    <select id="getDkbhByWayJobId" resultType="java.lang.String">
        SELECT dkbh from  wayline_job where job_id = #{waylineJobId}
    </select>
 
    <!--查询没有处理tif拼图斑面的任务-->
    <select id="getNotParseTifOdmList" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT
            oti.*,wj.dkbh,wj.job_type as waylineType,wj.name as waylineJobName,
            date_format(FROM_UNIXTIME( wj.completed_time/ 1000),'%Y-%m-%d %H:%i:%s') as completedTime
        FROM
            odm_task_info oti
        left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR and wj.is_deleted = 0
        WHERE
        oti.ort_tb_path IS NULL
        and oti.is_deleted = 0
        and oti.status = 40
        and oti.running_progress = 1.0::VARCHAR
        and wj.dkbh is not null
        <if test="otrTaskTypes != null and otrTaskTypes.size()>0">
            AND wj.job_type IN
            <foreach collection="otrTaskTypes" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
 
    <!--查询一个月之外并且没有删除的任务,按天来-->
    <select id="getOneMonLatOdmTask" resultType="org.sxkj.odm.entity.OdmTaskInfo">
        SELECT
            oti.*
        FROM
            odm_task_info oti
            left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR
        WHERE oti.file_del_flag = 0 and oti.is_deleted = 0
        and wj.completed_time &lt; UNIX_TIMESTAMP(NOW() - INTERVAL {day} DAY)*1000
    </select>
 
    <!--查询所有历史 odm 任务列表-->
    <select id="getHistoryOdmTaskByTifComp" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        select oti.*,wj.job_type as waylineType,wj.dkbh,wj.workspace_id as workspaceId,wj.dock_sn as deviceSn
        from odm_task_info oti
        left join wayline_job wj on wj.job_id = oti.wayline_job_id::VARCHAR and wj.is_deleted = 0
        left join blade_attach ba on ba.wayline_job_id = oti.wayline_job_id::VARCHAR and ba.is_deleted = 0 and ba.result_type = 4
        where
        oti.running_progress = 1.0::VARCHAR
        and oti.is_update = 1
        and  oti.file_del_flag = 0
        and  oti.status = 40
        and oti.is_deleted = 0
        <if test="otrTaskTypes != null and otrTaskTypes.size()>0">
            AND wj.job_type IN
            <foreach collection="otrTaskTypes" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        and ba.id is null
    </select>
    <!--根据经纬度获取tif数据-->
    <select id="getTifDataByCoord" resultType="org.sxkj.odm.entity.OdmTaskInfo">
        SELECT * FROM odm_task_info
        WHERE ST_Contains(geom, ST_GeomFromText(concat('POINT(',#{longitude},' ',#{latitude}, ')'))) and is_deleted = 0
        ORDER BY id desc
    </select>
 
    <!--根据经纬度获取附件10公里内的tif数据-->
    <select id="getAllTifDataByCoord" resultType="org.sxkj.odm.entity.OdmTaskInfo">
        SELECT distinct CONCAT(base_path, dem_tif_path) as dem_tif_path
        FROM wayline_dsm_info
        WHERE  geom IS NOT NULL
          AND is_deleted = 0
          AND dem_tif_path IS NOT NULL
          AND ST_Distance_Sphere(
                  ST_Centroid(geom), -- geom中心点
                  ST_GeomFromText(concat('POINT(', #{longitude}, ' ', #{latitude}, ')'))) &lt;= 1000
        ORDER BY id DESC
    </select>
 
    <!--手动更新odm 任务数据,包含了空间面数据-->
    <update id="updateOdmTaskGeomInfoById">
        update odm_task_info SET
        <if test="odmTaskInfo.uploadProgress !=null">
            upload_progress = #{odmTaskInfo.uploadProgress},
        </if>
        <if test="odmTaskInfo.resizeProgress !=null">
            resize_progress = #{odmTaskInfo.resizeProgress},
        </if>
        <if test="odmTaskInfo.runningProgress !=null">
            running_progress = #{odmTaskInfo.runningProgress},
        </if>
        <if test="odmTaskInfo.processingTime !=null">
            processing_time = #{odmTaskInfo.processingTime},
        </if>
        <if test="odmTaskInfo.isUpdate !=null">
            is_update = #{odmTaskInfo.isUpdate},
        </if>
        <if test="odmTaskInfo.lastError !=null and odmTaskInfo.lastError !=''">
            last_error = #{odmTaskInfo.lastError},
        </if>
        <if test="odmTaskInfo.orthoimagePath !=null and odmTaskInfo.orthoimagePath !=''">
            orthoimage_path = #{odmTaskInfo.orthoimagePath},
        </if>
        <if test="odmTaskInfo.ortTbPath !=null and odmTaskInfo.ortTbPath !=''">
            ort_tb_path = #{odmTaskInfo.ortTbPath},
        </if>
        <if test="odmTaskInfo.orthoimageApi !=null and odmTaskInfo.orthoimageApi !=''">
            orthoimage_api = #{odmTaskInfo.orthoimageApi},
        </if>
        <if test="odmTaskInfo.tilesPath !=null and odmTaskInfo.tilesPath !=''">
            tiles_path = #{odmTaskInfo.tilesPath},
        </if>
        <if test="odmTaskInfo.demTifPath !=null and odmTaskInfo.demTifPath !=''">
            dem_tif_path = #{odmTaskInfo.demTifPath},
        </if>
        <if test="odmTaskInfo.voxGridTilesPath !=null and odmTaskInfo.voxGridTilesPath !=''">
            vox_grid_tiles_path = #{odmTaskInfo.voxGridTilesPath},
        </if>
        <if test="odmTaskInfo.status !=null">
            status = #{odmTaskInfo.status},
        </if>
        <if test="odmTaskInfo.type !=null">
            type = #{odmTaskInfo.type},
        </if>
        <if test="odmTaskInfo.geom !=null and odmTaskInfo.geom !=''">
            geom = ST_GeomFromText(${odmTaskInfo.geom})
        </if>
        where id = #{odmTaskInfo.id}
    </update>
 
    <!--根据条件查询所有区域对应的odm统计数据-->
    <select id="getOdmTaskStatisticsByAreaCode" resultType="org.sxkj.odm.vo.OdmTaskStatisticsBO">
        SELECT
        md.area_code "dictKey",
        count(*) "num",
        ROUND( sum( wj3d.area ) / 1000000, 2 ) AS area
        FROM
        blade_attach ba
        LEFT JOIN manage_device md ON ba.device_sn = md.device_sn::VARCHAR
        left join wayline_job wj on ba.wayline_job_id = wj.job_id::VARCHAR AND md.is_deleted = 0
        left join wayline_job_3d_record wj3d on wj3d.job_id = ba.wayline_job_id::VARCHAR
        <where>
            AND ba.is_deleted = 0
            AND wj.job_info_id is not null
            <if test="dto.areaCode!=null and dto.areaCode!=''">
                AND md.area_code like concat(#{dto.areaCode},'%')
            </if>
            <if test="dto.deviceSn!=null and dto.deviceSn!=''">
                AND md.device_sn = #{dto.deviceSn}
            </if>
            <if test="dto.deviceSn!=null and dto.deviceSn!=''">
                AND md.device_sn = #{dto.deviceSn}
            </if>
            <if test="dto.type!=null">
                AND ba.result_type = #{dto.type}
            </if>
            <if test="dto.startDate!=null">
                AND ba.create_time &gt;= #{dto.startDate}
            </if>
            <if test="dto.endDate!=null">
                AND ba.create_time &lt;= #{dto.endDate}
            </if>
        </where>
        group by md.area_code
    </select>
 
    <!--根据jobId 查询对应的设备编号-->
    <select id="getDeviceSnByJobId" resultType="java.lang.String">
        select dock_sn from wayline_job where job_id = #{jobId}
    </select>
 
    <!--获取3dtiles明细数据-->
    <select id="getOdmTaskTilesList" resultType="org.sxkj.odm.vo.OdmTaskTilesVo">
        select md.area_code,
               ba.link as tilesPath
        from blade_attach ba
        left join manage_device md on ba.device_sn = md.device_sn::VARCHAR AND md.is_deleted = 0
        left join wayline_job wj on ba.wayline_job_id = wj.job_id::VARCHAR
        <where>
            AND ba.is_deleted = 0
            AND wj.job_info_id is not null
            <if test="dto.areaCode!=null and dto.areaCode!=''">
                and md.area_code like concat(#{dto.areaCode},'%')
            </if>
            <if test="dto.deviceSn!=null and dto.deviceSn!=''">
                and md.device_sn = #{dto.deviceSn}
            </if>
            <if test="dto.type!=null">
                AND ba.result_type = #{dto.type}
            </if>
            <if test="dto.startDate!=null">
                and ba.create_time &gt;= #{dto.startDate}
            </if>
            <if test="dto.endDate!=null">
                and ba.create_time &lt;= #{dto.endDate}
            </if>
        </where>
    </select>
 
    <!--查询没有设备编号的数据,进行补充-->
    <select id="getNoDeviceOdmTaskList" resultType="org.sxkj.odm.entity.OdmTaskInfo">
        select id,wayline_job_id from odm_task_info where device_sn is null and file_del_flag = 0 and is_deleted = 0
    </select>
 
    <!--获取视频地址-->
    <select id="getMediaFileInfoByWaylineJobId" resultType="java.lang.String">
        SELECT
            ba.original_name
        FROM
            wayline_job wj
        LEFT JOIN blade_attach ba ON wj.job_id = ba.wayline_job_id::VARCHAR
        WHERE wj.job_id = #{jobId}
          AND job_type = 6
          AND result_type = 1
          AND extension = 'mp4'
        GROUP BY ba.original_name
    </select>
 
    <!--查询没有四至点面的数据,进行查询-->
    <select id="getNoGeomOdmTaskList" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        select id,wayline_job_id,project_id,task_id from odm_task_info
        where geom is null and file_del_flag = 0 and project_id is not null and task_id is not null and running_progress = 1.0
        and is_deleted = 0
    </select>
 
    <!--查询已完成的任务中没有将三维白膜的odm 信息集合-->
    <select id="getNoSaveTilesAttachOdmTaskInfoList" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT
            oti.*,
            date_format(FROM_UNIXTIME( wj.completed_time/ 1000),'%Y-%m-%d %H:%i:%s') as completedTime
        FROM
            odm_task_info oti
        LEFT JOIN blade_attach ba ON CONCAT( oti.base_path, oti.vox_grid_tiles_path )= ba.NAME and ba.is_deleted = 0
        LEFT JOIN wayline_job wj ON wj.job_id = oti.wayline_job_id::VARCHAR and wj.is_deleted = 0
        WHERE
          ba.id IS NULL
          AND oti.is_deleted = 0
          AND oti.type = 2
          AND oti.STATUS = 40
          AND oti.is_update = 1
    </select>
 
    <!--odm 信息列-->
    <sql id="odmInfoColumn">
        id,
        project_id,
        task_id,
        wayline_job_id,
        image_count,
        upload_progress,
        resize_progress,
        running_progress,
        processing_time,
        base_path,
        orthoimage_path,
        ort_tb_path,
        orthoimage_api,
        tiles_path,
        status,
        is_update,
        create_time,
        error_num,
        last_error,
        file_del_flag,
        type,
        dem_tif_path,
        vox_grid_tiles_path,
        device_sn
    </sql>
 
    <!--查询状态已经完成已处理过的,然后没有生成出白膜的任务, 随机排序取一条-->
    <select id="getNotCreateTilesTask" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT
        oti.id,
        oti.project_id,
        oti.task_id,
        oti.wayline_job_id,
        oti.image_count,
        oti.upload_progress,
        oti.resize_progress,
        oti.running_progress,
        oti.processing_time,
        oti.base_path,
        oti.orthoimage_path,
        oti.ort_tb_path,
        oti.orthoimage_api,
        oti.tiles_path,
        oti.status,
        oti.is_update,
        oti.create_time,
        oti.error_num,
        oti.last_error,
        oti.file_del_flag,
        oti.type,
        oti.dem_tif_path,
        oti.vox_grid_tiles_path,
        oti.device_sn,
        wj.area_code,wj.create_user,wj.update_user,wj.create_dept,
        date_format(FROM_UNIXTIME( wj.completed_time/ 1000),'%Y-%m-%d %H:%i:%s') as completedTime
        FROM odm_task_info oti
        left join wayline_job wj on oti.wayline_job_id = wj.job_id::VARCHAR and wj.is_deleted = 0
        <where>
            AND oti.is_deleted = 0
            AND oti.STATUS = 40
            AND oti.is_update = 1
            AND wj.id is not null
            <if test="odmTaskInfo.type!=null">
                <if test="odmTaskInfo.type==1">
                    AND ( oti.tiles_path IS NULL OR oti.tiles_path = '' )
                </if>
                <if test="odmTaskInfo.type==2">
                    AND ( oti.vox_grid_tiles_path IS NULL OR oti.vox_grid_tiles_path = '' )
                </if>
                AND oti.type = #{odmTaskInfo.type}
            </if>
            <if test="odmTaskInfo.deviceSn!=null and odmTaskInfo.deviceSn!=''">
                AND oti.device_sn = #{odmTaskInfo.deviceSn}
            </if>
        </where>
        ORDER BY
            RAND()
            LIMIT 1
    </select>
 
    <!--查询状态已经完成已处理过的,然后没有生成出白膜的任务, 随机排序取一条-->
    <select id="getHistoryOdmTaskListByTifComp" resultType="org.sxkj.odm.vo.OdmTaskInfoVO">
        SELECT
            id,
            SUBSTRING_INDEX( SUBSTRING_INDEX( link, 'project/', - 1 ), '/task/', 1 ) AS project_id,
            SUBSTRING_INDEX( SUBSTRING_INDEX( link, '/task/', - 1 ), '/assets/', 1 ) AS task_id,
            wayline_job_id
        FROM blade_attach
        WHERE is_deleted = 0 and result_type = 3
    </select>
 
    <!--查询状态已经完成已处理过的,然后没有生成出白膜的任务, 随机排序取一条-->
    <select id="selectJobBaseInfo" resultType="org.sxkj.odm.entity.OdmTaskInfo">
        SELECT area_code,create_user,update_user,create_dept FROM wayline_job
        WHERE is_deleted = 0 and job_id = #{jobId}
    </select>
 
    <select id="getDemInfo" resultType="java.lang.String">
        select dem_url from dem_info where area_code LIKE concat(#{areaCodePrefix}, '%')
    </select>
</mapper>