Commit c7195ea0 authored by 吴俊凯's avatar 吴俊凯

首页故障统计SQL修改

parent 36087d9e
......@@ -13,7 +13,7 @@
IF(ISNULL(position3d) || LENGTH(trim(position3d)) <![CDATA[ <]]> 1,0,1) as is_bind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(ue4_rotation),'[]','')='',NULL,R.ue4_rotation))
IF(ISNULL(IF(replace(trim(ue4_rotation),'[]','')='',NULL,R.ue4_rotation))
AND ISNULL(IF(replace(trim(ue4_location),'[]','')='',NULL,R.ue4_location)),0,1) as is_bind,
</otherwise>
</choose>
......@@ -37,7 +37,7 @@
IF(ISNULL(B.coordinates) || LENGTH(trim(B.coordinates)) <![CDATA[ <]]> 1,0,1) as is_bind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(B.ue4_rotation),'[]','')='',NULL,B.ue4_rotation))
IF(ISNULL(IF(replace(trim(B.ue4_rotation),'[]','')='',NULL,B.ue4_rotation))
AND ISNULL(IF(replace(trim(B.ue4_location),'[]','')='',NULL,B.ue4_location)),0,1) as is_bind,
</otherwise>
</choose>
......@@ -60,14 +60,14 @@
IF(ISNULL(B.position3d) || LENGTH(trim(B.position3d)) <![CDATA[ <]]> 1,0,1) as is_bind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(B.ue4_rotation),'[]','')='',NULL,B.ue4_rotation))
IF(ISNULL(IF(replace(trim(B.ue4_rotation),'[]','')='',NULL,B.ue4_rotation))
AND ISNULL(IF(replace(trim(B.ue4_location),'[]','')='',NULL,B.ue4_location)),0,1) as is_bind,
</otherwise>
</choose>
#{type} as type,
B.name,B.code,B.ue4_location,B.ue4_rotation,
0 as is_region,
B.position3d
B.position3d
from f_risk_source R
left join f_equipment B on B.risk_source_id = R.id AND R.is_region='TRUE'
where 1=1
......@@ -81,14 +81,14 @@
IF(ISNULL(B.position3d) || LENGTH(trim(B.position3d)) <![CDATA[ <]]> 1,0,1) as is_bind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(B.ue4_rotation),'[]','')='',NULL,B.ue4_rotation))
IF(ISNULL(IF(replace(trim(B.ue4_rotation),'[]','')='',NULL,B.ue4_rotation))
AND ISNULL(IF(replace(trim(B.ue4_location),'[]','')='',NULL,B.ue4_location)),0,1) as is_bind,
</otherwise>
</choose>
#{type} as type,
B.name,B.code,B.ue4_location,B.ue4_rotation,
0 as is_region,
B.position3d
B.position3d
from f_risk_source R
left join f_fire_equipment B on B.risk_source_id = R.id AND B.equip_classify = 0
where 1=1
......@@ -102,14 +102,14 @@
IF(ISNULL(B.position3d) || LENGTH(trim(B.position3d)) <![CDATA[ <]]> 1,0,1) as is_bind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(B.ue4_rotation),'[]','')='',NULL,B.ue4_rotation))
IF(ISNULL(IF(replace(trim(B.ue4_rotation),'[]','')='',NULL,B.ue4_rotation))
AND ISNULL(IF(replace(trim(B.ue4_location),'[]','')='',NULL,B.ue4_location)),0,1) as is_bind,
</otherwise>
</choose>
#{type} as type,
B.name,B.code,B.ue4_location,B.ue4_rotation,
0 as is_region,
B.position3d
B.position3d
from f_risk_source R
left join f_fire_equipment B on B.risk_source_id = R.id AND B.equip_classify = 2
where 1=1
......@@ -122,40 +122,40 @@
IF(ISNULL(tmp.position3d) || LENGTH(trim(tmp.position3d)) <![CDATA[ <]]> 1,0,1) as isBind
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(tmp.ue4_rotation),'[]','')='',NULL,tmp.ue4_rotation))
IF(ISNULL(IF(replace(trim(tmp.ue4_rotation),'[]','')='',NULL,tmp.ue4_rotation))
AND ISNULL(IF(replace(trim(tmp.ue4_location),'[]','')='',NULL,tmp.ue4_location)),0,1) as isBind
</otherwise>
</choose>
from (
select id,name,'fireCar' as type,position3d,car_num as code,ue4_location,ue4_rotation,risk_source_id
from f_fire_car
union all
union all
select id,name,'fireEquipment' as type,position3d,code,ue4_location,ue4_rotation,risk_source_id
from f_fire_equipment
where equip_classify =3
union all
select id,name,CASE
union all
select id,name,CASE
WHEN S.type = 1 then 'fireChamber'
WHEN S.type = 2 then 'fireFoamRoom'
END as type,position3d,code,ue4_location,ue4_rotation,risk_source_id
from f_fire_station s
union all
union all
select id,name,
CASE
CASE
WHEN W.type = 1 then 'hydrant'
WHEN W.type = 2 then 'pool'
END as type,position3d,code,ue4_location,ue4_rotation,risk_source_id
from f_water_resource w
) tmp
) tmp
left join f_risk_source R on R.id = tmp.risk_source_id
</when>
</choose>
<if test="orgCode != null">
AND (R.org_code = #{orgCode} OR R.org_code like CONCAT(#{orgCode},'-%'))
</if>
</select>
<select id="getPointDetailByTypeAndId" resultType="java.util.HashMap">
<choose>
<when test="type == 'riskSource'">
......@@ -247,8 +247,8 @@
false as 'showInfo',
#{type} as type,
name as 'title'
from f_water_resource
where type = 1
from f_water_resource
where type = 1
<if test="pointId != null">
AND id = #{pointId}
</if>
......@@ -260,7 +260,7 @@
false as 'showInfo',
#{type} as type,
name as 'title'
from f_water_resource
from f_water_resource
where type = 2
<if test="pointId != null">
AND id = #{pointId}
......@@ -299,7 +299,7 @@
true as 'showInfo',
#{type} as type,
name as 'title'
from f_fire_station
from f_fire_station
where type = 1
<if test="pointId != null">
AND id = #{pointId}
......@@ -312,7 +312,7 @@
true as 'showInfo',
#{type} as type,
name as 'title'
from f_fire_station
from f_fire_station
where type = 2
<if test="pointId != null">
AND id = #{pointId}
......@@ -320,7 +320,7 @@
</when>
</choose>
</select>
<select id="getSafetyIndexWeek" resultType="java.util.HashMap">
<![CDATA[
SELECT distinct temp1.*,IFNULL(S.safety_index,0) as value
......@@ -333,7 +333,7 @@
ORDER BY temp1.date
]]>
</select>
<select id="countUpperRiskPoint" resultType="long">
SELECT
count(DISTINCT frcl.risk_source_id)
......@@ -366,19 +366,19 @@
)
AND pc.`is_ok` = '2'
</select>
<select id="countFireException" resultType="long">
SELECT
count(1)
FROM
f_alarm a
wl_equipment_specific_alarm a
WHERE
`status` = TRUE
status = 1
AND org_code = #{orgCode}
AND type = 'alarm_type_trouble'
AND type = 'BREAKDOWN'
AND date_format(a.update_date, '%Y-%m-%d') = #{date}
</select>
<select id="getAllErrorRiskPoint" resultType="com.yeejoin.amos.fas.business.bo.RiskPointRpnChangeBo" >
SELECT
rcl.id,
......@@ -387,7 +387,7 @@
rs.`name`
FROM
(
SELECT
SELECT
risk_source_id,
MAX(create_date) create_date,
MAX(id) id
......@@ -401,10 +401,10 @@
LEFT JOIN f_risk_source rs ON rs.id = rcl.risk_source_id
WHERE rs.risk_level_id is not NULL
AND (rs.org_code = #{orgCode} OR rs.org_code like CONCAT(#{orgCode},'-%'))
</select>
<select id="getAllErrorPatrolPoint" resultType="com.yeejoin.amos.fas.business.bo.CheckErrorBo">
SELECT
pc.point_id id,
pc.point_name 'name',
......@@ -421,7 +421,7 @@
AND pc.`is_ok` = '2'
GROUP BY pc.point_id,pc.`is_ok`,pc.point_name
</select>
<select id="getAllFaultAlarm" resultType="com.yeejoin.amos.fas.business.bo.CheckErrorBo">
select
ala.id,
......@@ -438,9 +438,9 @@
AND ala.type = 'alarm_type_trouble'
AND ala.org_code = #{orgCode}
AND date_format(ala.update_date, '%Y-%m-%d') = #{date}
</select>
<select id="getStatisticsCheck" resultType="java.util.HashMap">
<![CDATA[
SELECT IFNULL(d.STATUS,'') AS type, count(1) as value
......@@ -448,18 +448,18 @@
left JOIN p_plan_task t on t.id=d.task_no
WHERE
DATEDIFF(t.begin_time,CURRENT_DATE) <= 0 AND DATEDIFF(t.end_time,CURRENT_DATE) >= 0
AND (t.org_code like CONCAT(#{orgCode},'-%') OR t.org_code = #{orgCode})
AND (t.org_code like CONCAT(#{orgCode},'-%') OR t.org_code = #{orgCode})
AND d.status = 0
UNION ALL
select
is_ok as type,count(1) as value
select
is_ok as type,count(1) as value
from p_check a
where (a.org_code like CONCAT(#{orgCode},'-%') OR a.org_code = #{orgCode})
and TO_DAYS(a.check_time) = TO_DAYS(CURRENT_DATE)
GROUP BY a.is_ok
]]>
</select>
<select id="getRiskErrorTop5" resultType="com.yeejoin.amos.fas.business.bo.SafetyExecuteBo">
SELECT n.id,r.code,r.name as label,r.id as pointId,'risk' as type,n.create_date as changeDate
FROM f_rpn_change_log n
......@@ -469,7 +469,7 @@
ORDER BY n.create_date desc
limit 0,5
</select>
<select id="getCheckErrorTop5" resultType="com.yeejoin.amos.fas.business.bo.SafetyExecuteBo">
SELECT p.id,I.point_no as code,
IF(p.is_ok = '2', CONCAT(I.name,' 不合格') ,CONCAT(I.name,' 漏检') ) as label,
......@@ -482,7 +482,7 @@
ORDER BY p.check_time desc
limit 0,5
</select>
<select id="getFireAlarmTop5" resultType="com.yeejoin.amos.fas.business.bo.SafetyExecuteBo">
select
ala.id,
......@@ -520,69 +520,69 @@
ORDER BY wlesi.create_date DESC
limit 0,5
</select>
<select id="getPintsByType" resultType="hashmap">
select CONCAT(type,'-',id) as `key`,sp.* from
(select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'riskSource' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_risk_source where is_region = 'FALSE'
UNION all
select id,name,point_no as code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'patrol' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from p_point WHERE is_delete = FALSE
UNION all
select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'impEquipment' as type,org_code as orgCode,
tmp.relationKeys
from f_equipment e
LEFT JOIN
LEFT JOIN
(select GROUP_CONCAT(fire_equipment_id) as relationKeys,equipment_id from f_equipment_fire_equipment GROUP BY equipment_id) tmp
ON TMP.equipment_id = e.id
UNION all
select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'monitorEquipment' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_fire_equipment where equip_classify = 0
UNION all
select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'video' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_fire_equipment where equip_classify = 2
UNION all
select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'hydrant' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_water_resource where type = 1
UNION all
select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation,'pool' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_water_resource where type = 2
UNION all
select id,name,car_num as code,ue4_location as ue4Location,ue4_rotation as ue4Rotation, 'fireCar' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_fire_car
UNION all
select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation,'fireEquipment' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_fire_equipment where equip_classify = 3
UNION all
select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation , 'fireChamber' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_fire_station where type = 2
UNION all
select id,name,code,ue4_location as ue4Location,ue4_rotation as ue4Rotation ,'fireFoamRoom' as type,org_code as orgCode,
null as relationKeys
null as relationKeys
from f_fire_station where type = 1
) as sp
where
sp.orgCode = #{orgCode}
<if test="type!=null">and sp.type =#{type}</if>
</select>
<select id="getImpEqu3dPoints" resultType="com.yeejoin.amos.fas.business.vo.View3dNodeVo">
SELECT id,name,code,ue4_location,ue4_rotation,
case
case
when equip_classify= 0 then 'monitorEquipment'
when equip_classify= 2 then 'video'
when equip_classify= 3 then 'fireEquipment'
end as type,
case
case
when equip_classify= 0 then 'monitorEquipment'
when equip_classify= 2 then 'video'
when equip_classify= 3 then 'fireEquipment'
......@@ -609,7 +609,7 @@
)
END position,
concat('monitorEquipment-',fe.id) as `key`
FROM f_fire_equipment fe
FROM f_fire_equipment fe
WHERE fe.id IN (
select fire_equipment_id from f_equipment_fire_equipment
) AND (org_code = #{orgCode} OR org_code LIKE CONCAT(#{orgCode},'-%'))
......@@ -639,17 +639,17 @@
END position,
concat('impEquipment-',e.id) as `key`
FROM f_equipment e
LEFT JOIN
LEFT JOIN
(select GROUP_CONCAT(fire_equipment_id) as relationKeys,equipment_id from f_equipment_fire_equipment GROUP BY equipment_id) tmp
ON TMP.equipment_id = e.id
WHERE e.org_code = #{orgCode} OR e.org_code like CONCAT(#{orgCode},'-%')
UNION ALL
SELECT id,name,code,ue4_location,ue4_rotation,
case type
case type
when 1 then 'hydrant'
when 2 then 'pool'
end as type,
case type
case type
when 1 then 'hydrant'
when 2 then 'pool'
end as level,
......@@ -674,7 +674,7 @@
'}'
)
END position,
case type
case type
when 1 then concat('hydrant-',id)
when 2 then concat('pool-',id)
end as `key`
......@@ -682,11 +682,11 @@
WHERE org_code = #{orgCode} OR org_code like CONCAT(#{orgCode},'-%')
UNION ALL
SELECT id,name,code,ue4_location,ue4_rotation,
case
case
when type = 1 then 'fireChamber'
when type = 2 then 'fireFoamRoom'
end as type,
case
case
when type = 1 then 'fireChamber'
when type = 2 then 'fireFoamRoom'
end as level,
......@@ -738,10 +738,10 @@
)
END position,
concat('fireCar-',id) as `key`
FROM f_fire_car
FROM f_fire_car
WHERE org_code = #{orgCode} OR org_code LIKE CONCAT(#{orgCode},'-%')
</select>
<select id="initViewErrorNode" resultType="com.yeejoin.amos.fas.business.vo.View3dNodeVo">
select * from (
select
......@@ -808,7 +808,7 @@
AND tmp.type = #{type}
</if>
</select>
<select id="findViewDataByType" resultType="com.yeejoin.amos.fas.core.common.response.Node3DVoResponse">
SELECT
*
......@@ -862,7 +862,7 @@
<if test="abnormalStatus != false">
AND rs.status = 'ANOMALY'
</if>
AND rs.is_region <![CDATA[<>]]> 'TRUE'
AND rs.is_region <![CDATA[<>]]> 'TRUE'
UNION ALL
SELECT
eq.code,
......@@ -908,14 +908,14 @@
position3d IS NOT NULL
AND eq.risk_source_id in (select id from f_risk_source where is_region='TRUE')
AND position3d != ''
<if test="abnormalStatus != false">
AND eq.id in
<if test="abnormalStatus != false">
AND eq.id in
(select equipment_id from f_equipment_fire_equipment fefe
left join f_fire_equipment fe ON fe.id = fefe.fire_equipment_id
where fe.equip_status = 1)
</if>
UNION ALL
select
select
p.point_no code,
p.id,
p.is_indoor as inDoor,
......@@ -958,8 +958,8 @@
p.risk_source_id as riskSourceId,
0 as frequency,
if(p.status > 1 ,TRUE,FALSE) as twinkle
from
p_point p
from
p_point p
left join f_risk_source rs on p.risk_source_id = rs.id AND rs.is_region='TRUE'
where rs.id is not null
<if test="abnormalStatus != false">
......@@ -971,7 +971,7 @@
fe.code,
fe.id,
fe.is_indoor as inDoor,
case
case
when fe.equip_classify = 0 then CONCAT('monitorEquipment',fe.id)
when fe.equip_classify = 3 then CONCAT('fireEquipment',fe.id)
end as `key`,
......@@ -1003,7 +1003,7 @@
'{ "x": 1, "y": 1, "z": 1 }' scaleDTO,
false as `showInfo`,
fe.name as title,
case
case
when fe.equip_classify = 0 then 'monitorEquipment'
when fe.equip_classify = 3 then 'fireEquipment'
end as type,
......@@ -1011,7 +1011,7 @@
fe.risk_source_id as riskSourceId,
0 as frequency,
false as twinkle
from
from
f_fire_equipment fe
left join f_risk_source rs on fe.risk_source_id = rs.id AND rs.is_region='TRUE'
where rs.id is not null
......@@ -1021,7 +1021,7 @@
AND fe.equip_classify in (0,2,3)
AND fe.position3d != '' AND fe.position3d is not null
UNION ALL
select
select
c.car_num code,
c.id,
c.is_indoor as inDoor,
......@@ -1064,11 +1064,11 @@
where rs.id is not null
AND c.position3d != '' AND c.position3d is not null
UNION ALL
select
select
s.code,
s.id,
s.is_indoor as inDoor,
case
case
when S.type = 1 then CONCAT('fireChamber',s.id)
when S.type = 2 then CONCAT('fireFoamRoom',s.id)
end as `key`,
......@@ -1100,7 +1100,7 @@
'{ "x": 1, "y": 1, "z": 1 }' scaleDTO,
false as `showInfo`,
s.name as title,
case
case
when S.type = 1 then 'fireChamber'
when S.type = 2 then 'fireFoamRoom'
end as type,
......@@ -1108,7 +1108,7 @@
s.risk_source_id as riskSourceId,
0 as frequency,
false as twinkle
from
from
f_fire_station s
left join f_risk_source rs on s.risk_source_id = rs.id AND rs.is_region='TRUE'
where rs.id is not null
......@@ -1152,7 +1152,7 @@
w.code,
w.id,
w.is_indoor as inDoor,
case
case
when w.type = 1 then CONCAT('hydrant',w.id)
when w.type = 2 then CONCAT('pool',w.id)
end as `key`,
......@@ -1184,7 +1184,7 @@
'{ "x": 1, "y": 1, "z": 1 }' scaleDTO,
false as `showInfo`,
w.name as title,
case
case
when w.type = 1 then 'hydrant'
when w.type = 2 then 'pool'
end as type,
......@@ -1192,7 +1192,7 @@
w.risk_source_id as riskSourceId,
0 as frequency,
false as twinkle
from
from
f_water_resource w
left join f_risk_source rs on w.risk_source_id = rs.id AND rs.is_region='TRUE'
where rs.id is not null
......@@ -1212,8 +1212,8 @@
AND (temp.orgCode = #{orgCode} OR temp.orgCode LIKE CONCAT(#{orgCode},'-%'))
</if>
</select>
<select id="retrieveAllCount" resultType="long">
select count(1)
from (
......@@ -1222,7 +1222,7 @@
left join f_risk_level rl ON rl.id = r.risk_level_id
where r.is_region = 'FALSE'
<if test="dataLevel != null and dataLevel != ''">
AND rl.level = #{dataLevel}
AND rl.level = #{dataLevel}
</if>
UNION all
select p.name,p.point_no as code,'patrol' as typeCode,p.org_code as orgCode, p.risk_source_id as riskSourceId
......@@ -1321,7 +1321,7 @@
AND (tmp.orgCode = #{orgCode} OR tmp.orgCode like CONCAT(#{orgCode},'-%') )
</if>
</select>
<select id="retrieveAll" resultType="java.util.HashMap">
select *,'{ "x": 0, "y": 0, "z": 0 }' rotationDTO,'{ "x": 1, "y": 1, "z": 1 }' scaleDTO
from (select concat('riskSource-',r.id) as id,r.id as originId,r.name,r.code,r.ue4_location as ue4Location,r.ue4_rotation as ue4Rotation ,'riskSource' as type,r.org_code as orgCode,
......@@ -1774,7 +1774,7 @@
from f_fire_station where type = 1
) as sp
where
position3d <![CDATA[<>]]> '' and
position3d <![CDATA[<>]]> '' and
risk_source_id in
<foreach collection="ids" open="(" separator="," close=")" item="id">
#{id}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment