|
@@ -285,37 +285,18 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getHydraulicPatrolTask" parameterType="CenterdataTHydraulicPatrolTask" resultType="java.util.Map">
|
|
|
- SELECT t1.deptId, t1.ancestors,t1.patrolTrajectory,ifnull(TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM ROUND(t2.length/1000,2))),0) realLength FROM (
|
|
|
- select a.id,a.create_time,a.dept_id deptId ,d.ancestors ancestors,
|
|
|
- a.patrol_trajectory patrolTrajectory
|
|
|
- from centerdata_t_hydraulic_patrol_task a
|
|
|
- left join ${database_system}.sys_dept d on a.dept_id = d.dept_id
|
|
|
+ SELECT
|
|
|
+ a.dept_id deptId,
|
|
|
+ d.ancestors ancestors,
|
|
|
+ IFNULL( Round( sum( c.distance )/ 1000 ), 0 ) realLength,
|
|
|
+ a.patrol_trajectory patrolTrajectory
|
|
|
+ FROM centerdata_t_hydraulic_patrol_task a
|
|
|
+ LEFT JOIN onest_system.sys_dept d ON a.dept_id = d.dept_id
|
|
|
+ LEFT JOIN centerdata_t_hydraulic_patrol_plan_record c ON c.task_id = a.id
|
|
|
<where>
|
|
|
- <if test="type != null and type != ''">and a.type = #{type}</if>
|
|
|
+ <if test="type != null">and a.type = #{type}</if>
|
|
|
${params.dataScope}
|
|
|
</where>
|
|
|
- ) t1
|
|
|
- LEFT JOIN (
|
|
|
- SELECT task_id, sum( c.juli ) length FROM (
|
|
|
- SELECT a.task_id,
|
|
|
- IFNULL( st_distance_sphere ( point ( a.longitude, a.latitude ), point ( b.longitude, b.latitude ) ), 0 ) AS juli
|
|
|
- FROM (
|
|
|
- SELECT a.*,(@i := @i + 1) AS xh FROM (
|
|
|
- SELECT a.task_id,b.longitude,b.latitude
|
|
|
- FROM centerdata_t_hydraulic_patrol_plan_record a
|
|
|
- LEFT JOIN centerdata_t_hydraulic_patrol_track b ON b.record_id = a.id
|
|
|
- ORDER BY b.create_time) a,(SELECT @i := 1) AS itable
|
|
|
- ) a
|
|
|
- LEFT JOIN (
|
|
|
- SELECT a.*,(@j := @j + 1) AS xh FROM(
|
|
|
- SELECT a.task_id,b.longitude,b.latitude
|
|
|
- FROM centerdata_t_hydraulic_patrol_plan_record a
|
|
|
- LEFT JOIN centerdata_t_hydraulic_patrol_track b ON b.record_id = a.id
|
|
|
- ORDER BY b.create_time) a,(SELECT @j := 0) AS itable
|
|
|
- ) b ON a.xh = b.xh AND a.task_id = b.task_id
|
|
|
- ) c
|
|
|
- GROUP BY task_id
|
|
|
- ) t2 ON t2.task_id = t1.id
|
|
|
- ORDER BY t1.create_time DESC
|
|
|
+ GROUP BY a.id
|
|
|
</select>
|
|
|
</mapper>
|