Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosFireAutoSysRoot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
station
YeeAmosFireAutoSysRoot
Commits
5a91d84b
Commit
5a91d84b
authored
Dec 10, 2021
by
高建强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
item:消防水池液位计算修改
parent
aec51bae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
873 additions
and
896 deletions
+873
-896
RiskSourceServiceImpl.java
...amos/fas/business/service/impl/RiskSourceServiceImpl.java
+10
-9
application-dev.properties
...utoSysStart/src/main/resources/application-dev.properties
+54
-54
dbTemplate_risk_source.xml
...t/src/main/resources/db/mapper/dbTemplate_risk_source.xml
+809
-833
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java
View file @
5a91d84b
...
...
@@ -1404,20 +1404,21 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
area
=
Double
.
valueOf
(
map
.
get
(
"area"
).
toString
());
}
String
maxlevel
=
map
.
get
(
"max_level"
)
!=
null
?
map
.
get
(
"max_level"
).
toString
()
:
"0.0"
;
String
level
=
map
.
get
(
"value"
)
!=
null
&&
StringUtil
.
isNumeric
(
map
.
get
(
"value"
).
toString
())
?
String
.
format
(
"%.2f"
,
(
Double
.
valueOf
(
map
.
get
(
"value"
).
toString
())))
:
maxlevel
;
String
volume
=
String
.
format
(
"%.2f"
,
Double
.
valueOf
(
level
)
*
area
);
//
String level = map.get("value") != null && StringUtil.isNumeric(map.get("value").toString()) ? String.format("%.2f", (Double.valueOf(map.get("value").toString()))) : maxlevel;
String
volume
=
map
.
get
(
"volume"
)
!=
null
&&
StringUtil
.
isNumeric
(
map
.
get
(
"volume"
).
toString
())
?
String
.
format
(
"%.2f"
,
(
Double
.
valueOf
(
map
.
get
(
"volume"
).
toString
())))
:
String
.
format
(
"%.2f"
,
Double
.
valueOf
(
maxlevel
)
*
area
);
//
String volume = String.format("%.2f", Double.valueOf(level) * area);
if
(
hashOperations
.
size
(
"Analogue"
)
>
0
)
{
if
(
ObjectUtils
.
isEmpty
(
map
.
get
(
"
CODE"
))
||
!
hashOperations
.
hasKey
(
"Analogue"
,
map
.
get
(
"CODE
"
)))
{
map
.
put
(
"level"
,
level
);
if
(
ObjectUtils
.
isEmpty
(
map
.
get
(
"
code"
))
||
!
hashOperations
.
hasKey
(
"Analogue"
,
map
.
get
(
"code
"
)))
{
map
.
put
(
"level"
,
max
level
);
map
.
put
(
"volume"
,
volume
);
continue
;
}
EquipCommunicationData
data
=
(
EquipCommunicationData
)
hashOperations
.
get
(
"Analogue"
,
map
.
get
(
"CODE"
));
map
.
put
(
"level"
,
StringUtil
.
isNumeric
(
data
.
getState
())
?
data
.
getState
()
:
level
);
map
.
put
(
"volume"
,
String
.
format
(
"%.2f"
,
(
Double
.
valueOf
(
map
.
get
(
"level"
).
toString
())
*
area
)));
}
else
{
EquipCommunicationData
data
=
(
EquipCommunicationData
)
hashOperations
.
get
(
"Analogue"
,
map
.
get
(
"code"
));
String
level
=
StringUtil
.
isNumeric
(
data
.
getState
())
?
data
.
getState
()
:
maxlevel
;
map
.
put
(
"level"
,
level
);
map
.
put
(
"volume"
,
map
.
get
(
"volume"
)
!=
null
&&
StringUtil
.
isNumeric
(
map
.
get
(
"volume"
).
toString
())
?
volume
:
String
.
format
(
"%.2f"
,
(
Double
.
valueOf
(
level
)
*
area
)));
}
else
{
map
.
put
(
"level"
,
maxlevel
);
map
.
put
(
"volume"
,
volume
);
}
}
...
...
YeeAmosFireAutoSysStart/src/main/resources/application-dev.properties
View file @
5a91d84b
#DB properties:
spring.datasource.url
=
jdbc:mysql://172.16.11.20:3306/autosys_business_v3.0.0.2?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.username
=
root
spring.datasource.password
=
root_123
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
spring.datasource.hikari.maxLifetime
=
1765000
spring.datasource.hikari.maximum-pool-size
=
10
spring.datasource.testWhileIdle
=
true
spring.datasource.validationQuery
=
SELECT 1
#系统服务账号,用户后端服务调用
security.password
=
a1234560
security.loginId
=
fas_autosys
#应用product appkey
security.productWeb
=
STUDIO_APP_WEB
security.appKey
=
studio_normalapp_2681691
eureka.client.serviceUrl.defaultZone
=
http://172.16.11.20:10001/eureka/
eureka.client.register-with-eureka
=
true
eureka.client.fetch-registry
=
true
eureka.client.healthcheck.enabled
=
true
eureka.client.fetchRegistry
=
true
eureka.instance.prefer-ip-address
=
true
#redis
spring.redis.database
=
1
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.password
=
1234560
spring.redis.jedis.pool.max-active
=
200
spring.redis.jedis.pool.max-wait
=
-1
spring.redis.jedis.pool.max-idle
=
10
spring.redis.jedis.pool.min-idle
=
0
spring.redis.timeout
=
1000
#picture upload
windows.img.path
=
C:
\\
linux.img.path = /
file.uploadUrl
=
C:
\\
upload
\\
files
\\
#picture read
file.readUrl=http://172.16.11.33:8085/file/getFile?in=
#jpush 推送开关
params.isPush
=
false
## emqx
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${random.int[1024,65536]}
emqx.broker
=
tcp://172.16.11.33:1883
emqx.user-name
=
admin
emqx.password
=
public
#文件服务器地址
file.downLoad.url
=
http://39.98.246.31:8888/
#DB properties:
spring.datasource.url
=
jdbc:mysql://172.16.10.85:3306/autosys_business_v3.0.0.2?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.username
=
root
spring.datasource.password
=
Amos2019Mysql8
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
spring.datasource.hikari.maxLifetime
=
1765000
spring.datasource.hikari.maximum-pool-size
=
10
spring.datasource.testWhileIdle
=
true
spring.datasource.validationQuery
=
SELECT 1
#系统服务账号,用户后端服务调用
security.password
=
a1234560
security.loginId
=
fas_autosys
#应用product appkey
security.productWeb
=
STUDIO_APP_WEB
security.appKey
=
studio_normalapp_2681691
eureka.client.serviceUrl.defaultZone
=
http://172.16.11.20:10001/eureka/
eureka.client.register-with-eureka
=
true
eureka.client.fetch-registry
=
true
eureka.client.healthcheck.enabled
=
true
eureka.client.fetchRegistry
=
true
eureka.instance.prefer-ip-address
=
true
#redis
spring.redis.database
=
1
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.password
=
1234560
spring.redis.jedis.pool.max-active
=
200
spring.redis.jedis.pool.max-wait
=
-1
spring.redis.jedis.pool.max-idle
=
10
spring.redis.jedis.pool.min-idle
=
0
spring.redis.timeout
=
1000
#picture upload
windows.img.path
=
C:
\\
linux.img.path
=
/
file.uploadUrl
=
C:
\\
upload
\\
files
\\
#picture read
file.readUrl
=
http://172.16.11.33:8085/file/getFile?in=
#jpush 推送开关
params.isPush
=
false
## emqx
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${random.int[1024,65536]}
emqx.broker
=
tcp://172.16.11.33:1883
emqx.user-name
=
admin
emqx.password
=
public
#文件服务器地址
file.downLoad.url
=
http://39.98.246.31:8888/
YeeAmosFireAutoSysStart/src/main/resources/db/mapper/dbTemplate_risk_source.xml
View file @
5a91d84b
<?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=
"com.yeejoin.amos.fas.business.dao.mapper.RiskSourceMapper"
>
<!--统计-->
<select
id=
"countPageData"
resultType=
"long"
>
SELECT
COUNT(1) AS total_num
FROM
f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
<trim
prefix=
"WHERE"
prefixOverrides=
"AND "
>
<if
test=
"name!=null"
>
and rs.name like concat(concat("%",#{name}),"%")
</if>
</trim>
</select>
<!--分页查询 -->
<select
id=
"queryRiskSourceByPage"
resultType=
"java.util.HashMap"
>
SELECT
rs.*, rl.`name` riskLevelName
FROM
f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
<trim
prefix=
"WHERE"
prefixOverrides=
"AND "
>
<if
test=
"name!=null"
>
and rs.name like concat(concat("%",#{name}),"%")
</if>
</trim>
order by rs.id desc
<choose>
<when
test=
"pageSize==-1"
></when>
<when
test=
"pageSize!=-1"
>
limit #{offset},#{pageSize}
</when>
</choose>
</select>
<select
id=
"queryForRegion"
resultType=
"java.util.Map"
>
SELECT
rs.id,
rs.`code`,
rs.`name`,
(select rl.color from f_risk_level rl where rl.id = rs.risk_level_id) color,
(select rl.`level` from f_risk_level rl where rl.id = rs.risk_level_id) level,
rs.parent_id parentId
FROM
f_risk_source rs
where rs.is_region = 'TRUE';
</select>
<select
id=
"queryRPNReport"
resultType=
"java.util.Map"
>
<!-- SELECT
rs.`code`,
rs.id,
rs.`name`,
IFNULL(rs.rpn, 0) rpn,
IFNULL(
(
SELECT
sum(ff.rpni)
FROM
f_fmea ff
WHERE
ff.risk_source_id = rs.id
GROUP BY
ff.risk_source_id
),
0
) rpni
FROM
f_risk_source rs
WHERE
rs.parent_id > 0
ORDER BY rpni DESC
LIMIT 10 -->
SELECT
rs.`code`,
rs.id,
rs.`name`,
IFNULL(rs.rpn, 0) rpn,
IFNULL(rs.rpni, 0) rpni
FROM
f_risk_source rs
WHERE
rs.parent_id
>
0
ORDER BY
rpni DESC, rpn DESC
LIMIT 10
</select>
<select
id=
"queryForRiseUp"
resultType=
"java.util.Map"
>
select
d.countOfType0,
d.countOfSource,
CONCAT(ROUND(IFNULL(d.countOfType0/d.countOfSource,0)*100,2),'%')type0Rate
from
(SELECT
count(DISTINCT cl.risk_source_id) countOfType0,
(select count(1) from f_risk_source rs )countOfSource
FROM
f_rpn_change_log cl
WHERE
cl.type = 0
and cl.create_date BETWEEN '${startTime}' and '${endTime}'
)d
</select>
<select
id=
"queryForMatrix"
resultType=
"java.util.Map"
>
<!-- SELECT
ff1.risk_source_id riskSourceId,
ff1.evaluation_oid evaluationOid,
ff1.evaluation_sid evaluationSid,
d.mutiby,
rs.`name`
FROM
f_fmea ff1
JOIN (
SELECT
ff.risk_source_id sourceId,
MAX(
ff.evaluation_oid * ff.evaluation_sid
) mutiby
FROM
f_fmea ff
GROUP BY
ff.risk_source_id
LIMIT 20
) d ON (
ff1.risk_source_id = d.sourceId
AND ff1.evaluation_oid * ff1.evaluation_sid
)
LEFT JOIN f_risk_source rs ON rs.id = ff1.risk_source_id
GROUP BY ff1.risk_source_id -->
SELECT
ff1.risk_source_id riskSourceId,
d.ovalue evaluationOid,
d.svalue evaluationSid,
d.mutiby,
rs.`name`
FROM
f_fmea ff1
JOIN (
SELECT
o.risk_source_id sourceId,
o.ovalue,
s.svalue,
MAX(o.ovalue * s.svalue) mutiby
FROM
(
SELECT
ff.risk_source_id,
fem.coefficient ovalue
FROM
f_fmea ff
LEFT JOIN f_evaluation_model fem ON fem.id = ff.evaluation_oid
) o
LEFT JOIN (
SELECT
ff.risk_source_id,
fem.coefficient svalue
FROM
f_fmea ff
LEFT JOIN f_evaluation_model fem ON fem.id = ff.evaluation_sid
) s ON s.risk_source_id = o.risk_source_id
GROUP BY
o.risk_source_id
LIMIT 20
) d ON (
ff1.risk_source_id = d.sourceId
)
LEFT JOIN f_risk_source rs ON rs.id = ff1.risk_source_id
GROUP BY
ff1.risk_source_id;
</select>
<resultMap
id=
"riskSourceMap"
type=
"com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"parentId"
column=
"parent_id"
/>
<result
property=
"code"
column=
"code"
/>
<result
property=
"name"
column=
"name"
/>
<result
property=
"level"
column=
"level"
/>
<result
property=
"riskLevelId"
column=
"risk_level_id"
/>
<result
property=
"rpn"
column=
"rpn"
/>
<result
property=
"rpni"
column=
"rpni"
/>
<result
property=
"isRegion"
column=
"is_region"
/>
<result
property=
"isIndoor"
column=
"is_indoor"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"count"
column=
"ccount"
/>
<result
property=
"qualified"
column=
"qualified"
/>
<result
property=
"unqualified"
column=
"unqualified"
/>
<result
property=
"omission"
column=
"omission"
/>
<result
property=
"unplan"
column=
"unplan"
/>
</resultMap>
<select
id=
"getRiskSources"
resultMap=
"riskSourceMap"
>
SELECT
rs.id,
rs.`code`,
rs.parent_id,
rs.`name`,
rl.`level`,
rs.risk_level_id,
rs.rpn,
rs.rpni,
rs.is_region,
rs.position3d,
rs.floor3d,
rs.status,
rs.is_indoor,
rs.source_id as sourceId
FROM
`f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
where rs.org_code = #{compCode}
ORDER BY rs.sort_num,rs.id ASC
</select>
<select
id=
"getRiskSourcesEquipment"
resultMap=
"riskSourceMap"
>
SELECT
sum(a.cc) ccount,
a.`name`,
a.position3d,
a.parent_id,
min(a.level) level,
a.id
FROM
(
SELECT
IF (E.ID, 1, 0) cc,
s.`name`,
s.position3d,
s.parent_id,
s.risk_level_id level,
s.id
FROM
f_equipment e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id
) a
GROUP BY
a.`name`,
a.position3d,
a.parent_id,
a.id
</select>
<select
id=
"getCheckPointRiskSource"
resultMap=
"riskSourceMap"
>
SELECT
sum(a.cc) ccount,
a.`name`,
a.position3d,
a.parent_id,
min(a.level) level,
sum(a.qualified) qualified,
sum(a.unqualified) unqualified,
sum(a.omission) omission,
sum(a.unplan) unplan,
a.id
FROM
(
SELECT
IF (E.ID, 1, 0) cc,
s.`name`,
s.position3d,
s.parent_id,
IFNULL(e.`level`,0) level,
IF (E.`status` = '1', 1, 0) qualified,
IF (E.`status` = '2', 1, 0) unqualified,
IF (E.`status` = '3', 1, 0) omission,
IF (E.`status` = '0', 1, 0) unplan,
e.`status`,
s.id
FROM
p_point e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id and e.is_delete = 0
) a
GROUP BY
a.`name`,
a.position3d,
a.parent_id,
a.id
</select>
<select
id=
"getRiskSourcesFireEquipmentByType"
resultMap=
"riskSourceMap"
>
SELECT
sum(a.cc) ccount,
a.`name`,
a.position3d,
a.parent_id,
min(a.level) level,
a.id
FROM
(
SELECT
IF (E.ID, 1, 0) cc,
s.`name`,
s.position3d,
s.parent_id,
s.risk_level_id level,
s.id
FROM
f_fire_equipment e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id
where e.equip_classify in
<foreach
collection=
"type"
open=
"("
separator=
","
close=
")"
item=
"classify"
>
#{classify}
</foreach>
) a
GROUP BY
a.`name`,
a.position3d,
a.parent_id,
a.id
</select>
<!-- <select id="getRiskSourcePointCount" resultType="long">-->
<!-- SELECT-->
<!-- count(DISTINCT(pp.id))-->
<!-- FROM-->
<!-- `f_risk_source_point_inputitem` rspi-->
<!-- LEFT JOIN p_point pp ON pp.id = rspi.point_id-->
<!-- WHERE-->
<!-- 1 = 1-->
<!-- AND rspi.risk_source_id = #{riskSourceId}-->
<!-- </select>-->
<!-- <select id="getRiskSourcePoints" resultType="java.util.HashMap">-->
<!-- SELECT-->
<!-- rspi.risk_source_id riskId,-->
<!-- pp.id pointId,-->
<!-- pp.point_no pointNo,-->
<!-- pp.`name` pointName,-->
<!-- pp.charge_person_id userId,-->
<!-- pp.charge_dept_id deptId,-->
<!-- GROUP_CONCAT(pii.`name`) inputItems-->
<!-- FROM-->
<!-- `f_risk_source_point_inputitem` rspi-->
<!-- LEFT JOIN p_point pp ON pp.id = rspi.point_id-->
<!-- LEFT JOIN p_input_item pii ON pii.id = rspi.point_inputitem_id-->
<!-- WHERE pii.`name` is not NULL-->
<!-- AND rspi.risk_source_id = #{riskSourceId}-->
<!-- GROUP BY riskId,pointId,pointNo,pointName,depName,username,telephone-->
<!-- <choose>-->
<!-- <when test="pageSize==-1"></when>-->
<!-- <when test="pageSize!=-1">limit #{offset},#{pageSize}</when>-->
<!-- </choose>-->
<!-- </select>-->
<!-- <select id="queryByFireEqument" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource">-->
<!-- SELECT-->
<!-- *-->
<!-- FROM-->
<!-- f_risk_source rs-->
<!-- WHERE-->
<!-- EXISTS (-->
<!-- SELECT-->
<!-- 1-->
<!-- FROM-->
<!-- f_risk_source_equipment se-->
<!-- WHERE-->
<!-- se.fire_equipment_id = ${fireEquipmentId}-->
<!-- AND se.risk_source_id = rs.id-->
<!-- )-->
<!-- </select>-->
<!-- <select id="queryByPoint" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource">-->
<!-- SELECT-->
<!-- *-->
<!-- FROM-->
<!-- f_risk_source rs-->
<!-- WHERE-->
<!-- id in (-->
<!-- SELECT-->
<!-- pi.risk_source_id-->
<!-- FROM-->
<!-- f_risk_source_point_inputitem pi-->
<!-- WHERE-->
<!-- pi.point_id = ${pointId}-->
<!-- AND rs.id = pi.risk_source_id-->
<!-- )-->
<!-- </select>-->
<select
id=
"findRiskSourceDetatil"
resultMap=
"riskSourceMap"
>
SELECT
rs.id,
rs.`code`,
rs.parent_id,
rs.`name`,
rl.`name` as level,
rs.risk_level_id,
rs.rpni,
rs.rpn,
rs.is_region,
rs.floor3d,
rs.is_indoor,
rs.position3d
FROM
`f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
where rs.id = #{id}
</select>
<select
id=
"statistics3dCount"
resultType=
"map"
>
SELECT
(
SELECT
f.rpn
FROM
f_risk_source f
WHERE
f.parent_id = 0
) factoryRpn,
(
SELECT
CASE
WHEN f.increment
>
0 THEN
'UP'
WHEN f.increment = 0 THEN
'NOCHANGE'
WHEN f.increment
<
0 THEN
'DOWN'
END
FROM
f_risk_source f
WHERE
f.parent_id = 0
) rpnUpOrDown,
(
SELECT
count(1)
FROM
f_equipment
) equipmentCount,
(
SELECT
count(1)
FROM
f_risk_source
) riskSourceCount,
(SELECT count(1) FROM p_point p) pointCount;
SELECT
f.rpn
FROM
f_risk_source f
WHERE
f.parent_id = 0;
</select>
<select
id=
"statisticsEquipClassify"
resultType=
"map"
>
SELECT
fe.equip_classify,
count(1) classifyCount
FROM
f_fire_equipment fe
GROUP BY
fe.equip_classify
</select>
<select
id=
"statisticsRiskLevel"
resultType=
"map"
>
SELECT
IFNULL(d.riskLevel,'') riskLevel,
IFNULL(count(1),0) levelRiskCount
FROM
(
SELECT
rs.id,
(
SELECT
fl.`level`
FROM
f_risk_level fl
WHERE
fl.id = rs.risk_level_id
) riskLevel
FROM
f_risk_source rs
) d
GROUP BY
d.riskLevel;
</select>
<select
id=
"statisticsPointStatus"
resultType=
"map"
>
SELECT
sum(
CASE
WHEN p.`status` = 1 THEN
1
ELSE
0
END
) qualifiedCount,
sum(
CASE
WHEN p.`status` = 2 THEN
1
ELSE
0
END
) unqualifiedCount,
sum(
CASE
WHEN p.`status` = 3 THEN
1
ELSE
0
END
) omitCount
FROM
p_point p;
</select>
<select
id=
"queryForRiskSourceLevel"
resultType=
"map"
>
SELECT
rs.`code`,
rs.`name`,
(select rl.`name` from f_risk_level rl where rl.id = rs.risk_level_id)level
FROM
f_risk_source rs
WHERE
rs.id = ${riskSourceId};
</select>
<select
id=
"queryForRiskSourceRpni"
resultType=
"map"
>
SELECT
rs.`rpni` rpni
FROM
f_risk_source rs
WHERE
rs.parent_id = ${parentId};
</select>
<select
id=
"queryForUnqualified"
resultType=
"map"
>
SELECT
(
SELECT
i.`name`
FROM
p_input_item i
WHERE
i.id = ppi.input_item_id
) inputItemName,
(
SELECT
p.`name`
FROM
p_point p
WHERE
p.id = ppi.point_id
) pointName
FROM
f_fmea_point_inputitem pi
LEFT JOIN p_point_inputitem ppi ON ppi.id = pi.point_inputitem_id
LEFT JOIN f_fmea fm ON fm.id = pi.fmea_id
WHERE
pi.`state` = 1
AND fm.risk_source_id = #{riskSourceId};
</select>
<select
id=
"queryForFmeaEquipAlarm"
resultType=
"map"
>
SELECT
ed.`name` as 'fireEquipmentName',
ei.`name` as 'name'
FROM
`f_fmea_equipment_point` AS fmep
LEFT JOIN wl_equipment_specific_index fep ON fep.id = fmep.equipment_point_id
LEFT JOIN wl_equipment_index ei ON ei.id = fep.equipment_index_id
LEFT JOIN wl_equipment_specific fe ON fe.id = fep.equipment_specific_id
LEFT JOIN wl_equipment_detail ed ON ed.id = fe.equipment_detail_id
LEFT JOIN f_fmea fm ON fm.id = fmep.fmea_id
WHERE
fmep.state = 1
AND fm.risk_source_id = #{riskSourceId}
GROUP BY fireEquipmentName,name
</select>
<select
id=
"queryRiskAreaRpn"
resultType=
"java.util.HashMap"
>
SELECT
rs.id,
rs.name,
rs.rpn,
rs.rpni,
rs.risk_level_id as riskLevelId,
rl.`name` as riskLevelName,
rl.level,
rl.color
FROM
f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
WHERE rs.parent_id
>
0
order by rs.sort_num,rs.id
</select>
<select
id=
"queryRiskSourceSecondLevel"
resultType=
"java.util.HashMap"
>
SELECT
rs.id,
rs.name,
rs.rpn,
rs.rpni,
rs.risk_level_id as riskLevelId,
rl.`name` as riskLevelName,
rl.level,
rl.color
FROM
`f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
WHERE
rs.parent_id = (
SELECT
id
FROM
f_risk_source
WHERE
parent_id = 0 and org_code = #{compCode}
)
ORDER BY sort_num,id
</select>
<select
id=
"queryByFactor"
resultType=
"com.yeejoin.amos.fas.dao.entity.RiskSource"
>
SELECT
*
FROM
f_risk_source rs
WHERE
rs.id IN (
SELECT
ff.risk_source_id
FROM
f_fmea ff
JOIN f_risk_factor rf ON ff.risk_factors_id = rf.id
WHERE
rf.id = ${factorId}
)
</select>
<select
id=
"queryContingencyWater"
resultType=
"java.util.HashMap"
>
SELECT
*
FROM
(
SELECT
MAX(
CASE
WHEN a.field_name = 'name' THEN
a.field_value
END
) AS name,
MAX(
CASE
WHEN a.field_name = 'code' THEN
a.field_value
END
) AS code,
MAX(
CASE
WHEN a.field_name = 'height' THEN
a.field_value
END
) AS max_level,
MAX(
CASE
WHEN a.field_name = 'lowWaterHeight' THEN
a.field_value
END
) AS alarm_level,
MAX(
CASE
WHEN a.field_name = 'bottomArea' THEN
a.field_value
END
) AS area,
3.6 AS value
FROM
`wl_form_instance` a
WHERE
a.group_code IN ('pool', 'r_pool')
GROUP BY
a.instance_id
) s
GROUP BY
s.alarm_level,
s.max_level,
s.area,
s.`name`
</select>
<select
id=
"queryFmeaByPointId"
resultType=
"java.util.HashMap"
>
SELECT
frf.`name` riskFactors,
fem1.influence level,
fem2.influence faultFrequency,
fem3.influence detectivity,
ff.engineering,
ff.management,
ff.train,
ff.protection,
ff.disposal
FROM
f_fmea ff
LEFT JOIN f_risk_source frs ON frs.id = ff.risk_source_id
LEFT JOIN f_risk_factor frf ON frf.id = ff.risk_factors_id
LEFT JOIN f_evaluation_model fem1 ON fem1.id = ff.evaluation_sid
LEFT JOIN f_evaluation_model fem2 ON fem2.id = ff.evaluation_oid
LEFT JOIN f_evaluation_model fem3 ON fem3.id = ff.evaluation_did
# LEFT JOIN f_fmea_point_inputitem ffpi ON ffpi.fmea_id = ff.id
# INNER JOIN p_point_inputitem ppi ON ppi.ID = ffpi.point_inputitem_id
LEFT JOIN
(select DISTINCT ffpi.fmea_id ,ppi.point_id from
f_fmea_point_inputitem ffpi
INNER JOIN p_point_inputitem ppi ON ppi.ID = ffpi.point_inputitem_id) ffpi
ON ffpi.fmea_id = ff.id
WHERE
ffpi.point_id = ${pointId}
# EXISTS ( SELECT 1 FROM f_risk_source_point_inputitem frspi WHERE frspi.risk_source_id = frs.id AND frspi.point_id = ${pointId} )
# EXISTS ( SELECT
# 1
# FROM
# f_fmea_point_inputitem fpi
# LEFT JOIN f_fmea f on f.id = fpi.fmea_id
# LEFT JOIN p_point_inputitem ppi on ppi.id = fpi.point_inputitem_id
# WHERE
# f.risk_source_id = frs.id
# AND ppi.point_id = ${pointId}
# )
</select>
<select
id=
"countByParentIdAndIsRegion"
resultType=
"long"
>
select
count(1)
from
f_risk_source
where
is_region = #{isRegion}
and
parent_id = #{riskSourceId}
</select>
<update
id=
"updateRpnForNull"
>
update f_risk_source
set
rpn = null,
rpni = null,
risk_level_id = null,
flicker_frequency = null
where id = #{id}
</update>
<update
id=
"updateRpn"
>
update f_risk_source
<set>
<if
test=
"rpn != null"
>
rpn = #{rpn},
</if>
<if
test=
"rpni != null"
>
rpni = #{rpni},
</if>
<if
test=
"riskLevelId != null"
>
risk_level_id = #{riskLevelId},
</if>
<if
test=
"flickerFrequency != null"
>
flicker_frequency = #{flickerFrequency}
</if>
</set>
where id = #{id}
</update>
<select
id=
"getRegionList"
parameterType=
"string"
resultType=
"com.yeejoin.amos.fas.core.common.response.RegionTreeResponse"
>
select
rs.id,rs.name,rs.code,rs.parent_id,rs.ue4_location,rs.ue4_rotation,rs.ue4_extent,
<choose>
<when
test=
"channelType == '3dpage'"
>
IF(ISNULL(rs.route_path) || LENGTH(trim(rs.route_path))
<![CDATA[ <]]>
1,0,1) as is_bind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(rs.ue4_rotation),'[]','')='',NULL,rs.ue4_rotation))
AND ISNULL(IF(replace(trim(rs.ue4_location),'[]','')='',NULL,rs.ue4_location)),0,1) as is_bind,
</otherwise>
</choose>
IF(rs.is_region = 'TRUE',1,0) as is_region,
rs.route_path,
rl.level,
CONCAT('level_',rl.level) as level_str,
'riskSource' as type
from f_risk_source rs
left join f_risk_level rl ON rs.risk_level_id = rl.id
where is_region = 'TRUE' AND (rs.org_code = #{orgCode} OR rs.org_code like CONCAT(#{orgCode},'-%'))
</select>
<select
id=
"findRegionById"
resultType=
"java.util.HashMap"
>
select
id,name,code,parent_id as parentId,ue4_location as ue4Location,ue4_rotation as ue4Rotation,ue4_extent as ue4Extent,route_path as routePath,
<choose>
<when
test=
"channelType == '3dpage'"
>
IF(ISNULL(route_path) || LENGTH(trim(route_path))
<![CDATA[ <]]>
1,0,1) as isBind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(ue4_rotation),'[]','')='',NULL,ue4_rotation))
AND ISNULL(IF(replace(trim(ue4_location),'[]','')='',NULL,ue4_location)),0,1) as isBind,
</otherwise>
</choose>
IF(is_region = 'TRUE',1,0) as isRegion,
(select name from f_risk_level where level = r.risk_level_id) as riskLevel
from f_risk_source r
where id=#{id} AND (org_code = #{orgCode} OR org_code like CONCAT(#{orgCode},'-%'))
</select>
<update
id=
"batchSaveRegionUe4"
parameterType=
"java.util.List"
>
<foreach
collection=
"list"
item=
"item"
index=
"index"
open=
""
close=
""
separator=
";"
>
update f_risk_source
<set
>
<if
test=
"item.ue4Location != null"
>
ue4_location = #{item.ue4Location,jdbcType=VARCHAR},
</if>
<if
test=
"item.ue4Rotation != null"
>
ue4_rotation = #{item.ue4Rotation,jdbcType=VARCHAR},
</if>
<if
test=
"item.ue4Extent != null"
>
ue4_extent = #{item.ue4Extent,jdbcType=VARCHAR},
</if>
<if
test=
"item.routePath != null"
>
route_path = #{item.routePath,jdbcType=VARCHAR},
</if>
</set>
where id = #{item.riskSourceId,jdbcType=BIGINT}
</foreach>
</update>
<?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=
"com.yeejoin.amos.fas.business.dao.mapper.RiskSourceMapper"
>
<!--统计-->
<select
id=
"countPageData"
resultType=
"long"
>
SELECT
COUNT(1) AS total_num
FROM
f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
<trim
prefix=
"WHERE"
prefixOverrides=
"AND "
>
<if
test=
"name!=null"
>
and rs.name like concat(concat("%",#{name}),"%")
</if>
</trim>
</select>
<!--分页查询 -->
<select
id=
"queryRiskSourceByPage"
resultType=
"java.util.HashMap"
>
SELECT
rs.*, rl.`name` riskLevelName
FROM
f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
<trim
prefix=
"WHERE"
prefixOverrides=
"AND "
>
<if
test=
"name!=null"
>
and rs.name like concat(concat("%",#{name}),"%")
</if>
</trim>
order by rs.id desc
<choose>
<when
test=
"pageSize==-1"
></when>
<when
test=
"pageSize!=-1"
>
limit #{offset},#{pageSize}
</when>
</choose>
</select>
<select
id=
"queryForRegion"
resultType=
"java.util.Map"
>
SELECT
rs.id,
rs.`code`,
rs.`name`,
(select rl.color from f_risk_level rl where rl.id = rs.risk_level_id) color,
(select rl.`level` from f_risk_level rl where rl.id = rs.risk_level_id) level,
rs.parent_id parentId
FROM
f_risk_source rs
where rs.is_region = 'TRUE';
</select>
<select
id=
"queryRPNReport"
resultType=
"java.util.Map"
>
<!-- SELECT
rs.`code`,
rs.id,
rs.`name`,
IFNULL(rs.rpn, 0) rpn,
IFNULL(
(
SELECT
sum(ff.rpni)
FROM
f_fmea ff
WHERE
ff.risk_source_id = rs.id
GROUP BY
ff.risk_source_id
),
0
) rpni
FROM
f_risk_source rs
WHERE
rs.parent_id > 0
ORDER BY rpni DESC
LIMIT 10 -->
SELECT
rs.`code`,
rs.id,
rs.`name`,
IFNULL(rs.rpn, 0) rpn,
IFNULL(rs.rpni, 0) rpni
FROM
f_risk_source rs
WHERE
rs.parent_id
>
0
ORDER BY
rpni DESC, rpn DESC
LIMIT 10
</select>
<select
id=
"queryForRiseUp"
resultType=
"java.util.Map"
>
select
d.countOfType0,
d.countOfSource,
CONCAT(ROUND(IFNULL(d.countOfType0/d.countOfSource,0)*100,2),'%')type0Rate
from
(SELECT
count(DISTINCT cl.risk_source_id) countOfType0,
(select count(1) from f_risk_source rs )countOfSource
FROM
f_rpn_change_log cl
WHERE
cl.type = 0
and cl.create_date BETWEEN '${startTime}' and '${endTime}'
)d
</select>
<select
id=
"queryForMatrix"
resultType=
"java.util.Map"
>
<!-- SELECT
ff1.risk_source_id riskSourceId,
ff1.evaluation_oid evaluationOid,
ff1.evaluation_sid evaluationSid,
d.mutiby,
rs.`name`
FROM
f_fmea ff1
JOIN (
SELECT
ff.risk_source_id sourceId,
MAX(
ff.evaluation_oid * ff.evaluation_sid
) mutiby
FROM
f_fmea ff
GROUP BY
ff.risk_source_id
LIMIT 20
) d ON (
ff1.risk_source_id = d.sourceId
AND ff1.evaluation_oid * ff1.evaluation_sid
)
LEFT JOIN f_risk_source rs ON rs.id = ff1.risk_source_id
GROUP BY ff1.risk_source_id -->
SELECT
ff1.risk_source_id riskSourceId,
d.ovalue evaluationOid,
d.svalue evaluationSid,
d.mutiby,
rs.`name`
FROM
f_fmea ff1
JOIN (
SELECT
o.risk_source_id sourceId,
o.ovalue,
s.svalue,
MAX(o.ovalue * s.svalue) mutiby
FROM
(
SELECT
ff.risk_source_id,
fem.coefficient ovalue
FROM
f_fmea ff
LEFT JOIN f_evaluation_model fem ON fem.id = ff.evaluation_oid
) o
LEFT JOIN (
SELECT
ff.risk_source_id,
fem.coefficient svalue
FROM
f_fmea ff
LEFT JOIN f_evaluation_model fem ON fem.id = ff.evaluation_sid
) s ON s.risk_source_id = o.risk_source_id
GROUP BY
o.risk_source_id
LIMIT 20
) d ON (
ff1.risk_source_id = d.sourceId
)
LEFT JOIN f_risk_source rs ON rs.id = ff1.risk_source_id
GROUP BY
ff1.risk_source_id;
</select>
<resultMap
id=
"riskSourceMap"
type=
"com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"parentId"
column=
"parent_id"
/>
<result
property=
"code"
column=
"code"
/>
<result
property=
"name"
column=
"name"
/>
<result
property=
"level"
column=
"level"
/>
<result
property=
"riskLevelId"
column=
"risk_level_id"
/>
<result
property=
"rpn"
column=
"rpn"
/>
<result
property=
"rpni"
column=
"rpni"
/>
<result
property=
"isRegion"
column=
"is_region"
/>
<result
property=
"isIndoor"
column=
"is_indoor"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"count"
column=
"ccount"
/>
<result
property=
"qualified"
column=
"qualified"
/>
<result
property=
"unqualified"
column=
"unqualified"
/>
<result
property=
"omission"
column=
"omission"
/>
<result
property=
"unplan"
column=
"unplan"
/>
</resultMap>
<select
id=
"getRiskSources"
resultMap=
"riskSourceMap"
>
SELECT
rs.id,
rs.`code`,
rs.parent_id,
rs.`name`,
rl.`level`,
rs.risk_level_id,
rs.rpn,
rs.rpni,
rs.is_region,
rs.position3d,
rs.floor3d,
rs.status,
rs.is_indoor,
rs.source_id as sourceId
FROM
`f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
where rs.org_code = #{compCode}
ORDER BY rs.sort_num,rs.id ASC
</select>
<select
id=
"getRiskSourcesEquipment"
resultMap=
"riskSourceMap"
>
SELECT
sum(a.cc) ccount,
a.`name`,
a.position3d,
a.parent_id,
min(a.level) level,
a.id
FROM
(
SELECT
IF (E.ID, 1, 0) cc,
s.`name`,
s.position3d,
s.parent_id,
s.risk_level_id level,
s.id
FROM
f_equipment e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id
) a
GROUP BY
a.`name`,
a.position3d,
a.parent_id,
a.id
</select>
<select
id=
"getCheckPointRiskSource"
resultMap=
"riskSourceMap"
>
SELECT
sum(a.cc) ccount,
a.`name`,
a.position3d,
a.parent_id,
min(a.level) level,
sum(a.qualified) qualified,
sum(a.unqualified) unqualified,
sum(a.omission) omission,
sum(a.unplan) unplan,
a.id
FROM
(
SELECT
IF (E.ID, 1, 0) cc,
s.`name`,
s.position3d,
s.parent_id,
IFNULL(e.`level`,0) level,
IF (E.`status` = '1', 1, 0) qualified,
IF (E.`status` = '2', 1, 0) unqualified,
IF (E.`status` = '3', 1, 0) omission,
IF (E.`status` = '0', 1, 0) unplan,
e.`status`,
s.id
FROM
p_point e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id and e.is_delete = 0
) a
GROUP BY
a.`name`,
a.position3d,
a.parent_id,
a.id
</select>
<select
id=
"getRiskSourcesFireEquipmentByType"
resultMap=
"riskSourceMap"
>
SELECT
sum(a.cc) ccount,
a.`name`,
a.position3d,
a.parent_id,
min(a.level) level,
a.id
FROM
(
SELECT
IF (E.ID, 1, 0) cc,
s.`name`,
s.position3d,
s.parent_id,
s.risk_level_id level,
s.id
FROM
f_fire_equipment e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id
where e.equip_classify in
<foreach
collection=
"type"
open=
"("
separator=
","
close=
")"
item=
"classify"
>
#{classify}
</foreach>
) a
GROUP BY
a.`name`,
a.position3d,
a.parent_id,
a.id
</select>
<!-- <select id="getRiskSourcePointCount" resultType="long">-->
<!-- SELECT-->
<!-- count(DISTINCT(pp.id))-->
<!-- FROM-->
<!-- `f_risk_source_point_inputitem` rspi-->
<!-- LEFT JOIN p_point pp ON pp.id = rspi.point_id-->
<!-- WHERE-->
<!-- 1 = 1-->
<!-- AND rspi.risk_source_id = #{riskSourceId}-->
<!-- </select>-->
<!-- <select id="getRiskSourcePoints" resultType="java.util.HashMap">-->
<!-- SELECT-->
<!-- rspi.risk_source_id riskId,-->
<!-- pp.id pointId,-->
<!-- pp.point_no pointNo,-->
<!-- pp.`name` pointName,-->
<!-- pp.charge_person_id userId,-->
<!-- pp.charge_dept_id deptId,-->
<!-- GROUP_CONCAT(pii.`name`) inputItems-->
<!-- FROM-->
<!-- `f_risk_source_point_inputitem` rspi-->
<!-- LEFT JOIN p_point pp ON pp.id = rspi.point_id-->
<!-- LEFT JOIN p_input_item pii ON pii.id = rspi.point_inputitem_id-->
<!-- WHERE pii.`name` is not NULL-->
<!-- AND rspi.risk_source_id = #{riskSourceId}-->
<!-- GROUP BY riskId,pointId,pointNo,pointName,depName,username,telephone-->
<!-- <choose>-->
<!-- <when test="pageSize==-1"></when>-->
<!-- <when test="pageSize!=-1">limit #{offset},#{pageSize}</when>-->
<!-- </choose>-->
<!-- </select>-->
<!-- <select id="queryByFireEqument" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource">-->
<!-- SELECT-->
<!-- *-->
<!-- FROM-->
<!-- f_risk_source rs-->
<!-- WHERE-->
<!-- EXISTS (-->
<!-- SELECT-->
<!-- 1-->
<!-- FROM-->
<!-- f_risk_source_equipment se-->
<!-- WHERE-->
<!-- se.fire_equipment_id = ${fireEquipmentId}-->
<!-- AND se.risk_source_id = rs.id-->
<!-- )-->
<!-- </select>-->
<!-- <select id="queryByPoint" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource">-->
<!-- SELECT-->
<!-- *-->
<!-- FROM-->
<!-- f_risk_source rs-->
<!-- WHERE-->
<!-- id in (-->
<!-- SELECT-->
<!-- pi.risk_source_id-->
<!-- FROM-->
<!-- f_risk_source_point_inputitem pi-->
<!-- WHERE-->
<!-- pi.point_id = ${pointId}-->
<!-- AND rs.id = pi.risk_source_id-->
<!-- )-->
<!-- </select>-->
<select
id=
"findRiskSourceDetatil"
resultMap=
"riskSourceMap"
>
SELECT
rs.id,
rs.`code`,
rs.parent_id,
rs.`name`,
rl.`name` as level,
rs.risk_level_id,
rs.rpni,
rs.rpn,
rs.is_region,
rs.floor3d,
rs.is_indoor,
rs.position3d
FROM
`f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
where rs.id = #{id}
</select>
<select
id=
"statistics3dCount"
resultType=
"map"
>
SELECT
(
SELECT
f.rpn
FROM
f_risk_source f
WHERE
f.parent_id = 0
) factoryRpn,
(
SELECT
CASE
WHEN f.increment
>
0 THEN
'UP'
WHEN f.increment = 0 THEN
'NOCHANGE'
WHEN f.increment
<
0 THEN
'DOWN'
END
FROM
f_risk_source f
WHERE
f.parent_id = 0
) rpnUpOrDown,
(
SELECT
count(1)
FROM
f_equipment
) equipmentCount,
(
SELECT
count(1)
FROM
f_risk_source
) riskSourceCount,
(SELECT count(1) FROM p_point p) pointCount;
SELECT
f.rpn
FROM
f_risk_source f
WHERE
f.parent_id = 0;
</select>
<select
id=
"statisticsEquipClassify"
resultType=
"map"
>
SELECT
fe.equip_classify,
count(1) classifyCount
FROM
f_fire_equipment fe
GROUP BY
fe.equip_classify
</select>
<select
id=
"statisticsRiskLevel"
resultType=
"map"
>
SELECT
IFNULL(d.riskLevel,'') riskLevel,
IFNULL(count(1),0) levelRiskCount
FROM
(
SELECT
rs.id,
(
SELECT
fl.`level`
FROM
f_risk_level fl
WHERE
fl.id = rs.risk_level_id
) riskLevel
FROM
f_risk_source rs
) d
GROUP BY
d.riskLevel;
</select>
<select
id=
"statisticsPointStatus"
resultType=
"map"
>
SELECT
sum(
CASE
WHEN p.`status` = 1 THEN
1
ELSE
0
END
) qualifiedCount,
sum(
CASE
WHEN p.`status` = 2 THEN
1
ELSE
0
END
) unqualifiedCount,
sum(
CASE
WHEN p.`status` = 3 THEN
1
ELSE
0
END
) omitCount
FROM
p_point p;
</select>
<select
id=
"queryForRiskSourceLevel"
resultType=
"map"
>
SELECT
rs.`code`,
rs.`name`,
(select rl.`name` from f_risk_level rl where rl.id = rs.risk_level_id)level
FROM
f_risk_source rs
WHERE
rs.id = ${riskSourceId};
</select>
<select
id=
"queryForRiskSourceRpni"
resultType=
"map"
>
SELECT
rs.`rpni` rpni
FROM
f_risk_source rs
WHERE
rs.parent_id = ${parentId};
</select>
<select
id=
"queryForUnqualified"
resultType=
"map"
>
SELECT
(
SELECT
i.`name`
FROM
p_input_item i
WHERE
i.id = ppi.input_item_id
) inputItemName,
(
SELECT
p.`name`
FROM
p_point p
WHERE
p.id = ppi.point_id
) pointName
FROM
f_fmea_point_inputitem pi
LEFT JOIN p_point_inputitem ppi ON ppi.id = pi.point_inputitem_id
LEFT JOIN f_fmea fm ON fm.id = pi.fmea_id
WHERE
pi.`state` = 1
AND fm.risk_source_id = #{riskSourceId};
</select>
<select
id=
"queryForFmeaEquipAlarm"
resultType=
"map"
>
SELECT
ed.`name` as 'fireEquipmentName',
ei.`name` as 'name'
FROM
`f_fmea_equipment_point` AS fmep
LEFT JOIN wl_equipment_specific_index fep ON fep.id = fmep.equipment_point_id
LEFT JOIN wl_equipment_index ei ON ei.id = fep.equipment_index_id
LEFT JOIN wl_equipment_specific fe ON fe.id = fep.equipment_specific_id
LEFT JOIN wl_equipment_detail ed ON ed.id = fe.equipment_detail_id
LEFT JOIN f_fmea fm ON fm.id = fmep.fmea_id
WHERE
fmep.state = 1
AND fm.risk_source_id = #{riskSourceId}
GROUP BY fireEquipmentName,name
</select>
<select
id=
"queryRiskAreaRpn"
resultType=
"java.util.HashMap"
>
SELECT
rs.id,
rs.name,
rs.rpn,
rs.rpni,
rs.risk_level_id as riskLevelId,
rl.`name` as riskLevelName,
rl.level,
rl.color
FROM
f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
WHERE rs.parent_id
>
0
order by rs.sort_num,rs.id
</select>
<select
id=
"queryRiskSourceSecondLevel"
resultType=
"java.util.HashMap"
>
SELECT
rs.id,
rs.name,
rs.rpn,
rs.rpni,
rs.risk_level_id as riskLevelId,
rl.`name` as riskLevelName,
rl.level,
rl.color
FROM
`f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
WHERE
rs.parent_id = (
SELECT
id
FROM
f_risk_source
WHERE
parent_id = 0 and org_code = #{compCode}
)
ORDER BY sort_num,id
</select>
<select
id=
"queryByFactor"
resultType=
"com.yeejoin.amos.fas.dao.entity.RiskSource"
>
SELECT
*
FROM
f_risk_source rs
WHERE
rs.id IN (
SELECT
ff.risk_source_id
FROM
f_fmea ff
JOIN f_risk_factor rf ON ff.risk_factors_id = rf.id
WHERE
rf.id = ${factorId}
)
</select>
<select
id=
"queryContingencyWater"
resultType=
"java.util.HashMap"
>
SELECT
*
FROM
(
SELECT
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS `name`,
MAX( CASE WHEN a.field_name = 'code' THEN a.field_value END ) AS `code`,
MAX( CASE WHEN a.field_name = 'height' THEN a.field_value END ) AS max_level,
MAX( CASE WHEN a.field_name = 'lowWaterHeight' THEN a.field_value END ) AS alarm_level,
MAX( CASE WHEN a.field_name = 'bottomArea' THEN a.field_value END ) AS area,
MAX( CASE WHEN a.field_name = 'volume' THEN a.field_value END ) AS volume
FROM
`wl_form_instance` a
WHERE
a.group_code IN ( 'pool', 'r_pool' )
GROUP BY
a.instance_id
) s
GROUP BY
s.alarm_level,
s.max_level,
s.area,
s.`name`
</select>
<select
id=
"queryFmeaByPointId"
resultType=
"java.util.HashMap"
>
SELECT
frf.`name` riskFactors,
fem1.influence level,
fem2.influence faultFrequency,
fem3.influence detectivity,
ff.engineering,
ff.management,
ff.train,
ff.protection,
ff.disposal
FROM
f_fmea ff
LEFT JOIN f_risk_source frs ON frs.id = ff.risk_source_id
LEFT JOIN f_risk_factor frf ON frf.id = ff.risk_factors_id
LEFT JOIN f_evaluation_model fem1 ON fem1.id = ff.evaluation_sid
LEFT JOIN f_evaluation_model fem2 ON fem2.id = ff.evaluation_oid
LEFT JOIN f_evaluation_model fem3 ON fem3.id = ff.evaluation_did
# LEFT JOIN f_fmea_point_inputitem ffpi ON ffpi.fmea_id = ff.id
# INNER JOIN p_point_inputitem ppi ON ppi.ID = ffpi.point_inputitem_id
LEFT JOIN
(select DISTINCT ffpi.fmea_id ,ppi.point_id from
f_fmea_point_inputitem ffpi
INNER JOIN p_point_inputitem ppi ON ppi.ID = ffpi.point_inputitem_id) ffpi
ON ffpi.fmea_id = ff.id
WHERE
ffpi.point_id = ${pointId}
# EXISTS ( SELECT 1 FROM f_risk_source_point_inputitem frspi WHERE frspi.risk_source_id = frs.id AND frspi.point_id = ${pointId} )
# EXISTS ( SELECT
# 1
# FROM
# f_fmea_point_inputitem fpi
# LEFT JOIN f_fmea f on f.id = fpi.fmea_id
# LEFT JOIN p_point_inputitem ppi on ppi.id = fpi.point_inputitem_id
# WHERE
# f.risk_source_id = frs.id
# AND ppi.point_id = ${pointId}
# )
</select>
<select
id=
"countByParentIdAndIsRegion"
resultType=
"long"
>
select
count(1)
from
f_risk_source
where
is_region = #{isRegion}
and
parent_id = #{riskSourceId}
</select>
<update
id=
"updateRpnForNull"
>
update f_risk_source
set
rpn = null,
rpni = null,
risk_level_id = null,
flicker_frequency = null
where id = #{id}
</update>
<update
id=
"updateRpn"
>
update f_risk_source
<set>
<if
test=
"rpn != null"
>
rpn = #{rpn},
</if>
<if
test=
"rpni != null"
>
rpni = #{rpni},
</if>
<if
test=
"riskLevelId != null"
>
risk_level_id = #{riskLevelId},
</if>
<if
test=
"flickerFrequency != null"
>
flicker_frequency = #{flickerFrequency}
</if>
</set>
where id = #{id}
</update>
<select
id=
"getRegionList"
parameterType=
"string"
resultType=
"com.yeejoin.amos.fas.core.common.response.RegionTreeResponse"
>
select
rs.id,rs.name,rs.code,rs.parent_id,rs.ue4_location,rs.ue4_rotation,rs.ue4_extent,
<choose>
<when
test=
"channelType == '3dpage'"
>
IF(ISNULL(rs.route_path) || LENGTH(trim(rs.route_path))
<![CDATA[ <]]>
1,0,1) as is_bind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(rs.ue4_rotation),'[]','')='',NULL,rs.ue4_rotation))
AND ISNULL(IF(replace(trim(rs.ue4_location),'[]','')='',NULL,rs.ue4_location)),0,1) as is_bind,
</otherwise>
</choose>
IF(rs.is_region = 'TRUE',1,0) as is_region,
rs.route_path,
rl.level,
CONCAT('level_',rl.level) as level_str,
'riskSource' as type
from f_risk_source rs
left join f_risk_level rl ON rs.risk_level_id = rl.id
where is_region = 'TRUE' AND (rs.org_code = #{orgCode} OR rs.org_code like CONCAT(#{orgCode},'-%'))
</select>
<select
id=
"findRegionById"
resultType=
"java.util.HashMap"
>
select
id,name,code,parent_id as parentId,ue4_location as ue4Location,ue4_rotation as ue4Rotation,ue4_extent as ue4Extent,route_path as routePath,
<choose>
<when
test=
"channelType == '3dpage'"
>
IF(ISNULL(route_path) || LENGTH(trim(route_path))
<![CDATA[ <]]>
1,0,1) as isBind,
</when>
<otherwise>
IF(ISNULL(IF(replace(trim(ue4_rotation),'[]','')='',NULL,ue4_rotation))
AND ISNULL(IF(replace(trim(ue4_location),'[]','')='',NULL,ue4_location)),0,1) as isBind,
</otherwise>
</choose>
IF(is_region = 'TRUE',1,0) as isRegion,
(select name from f_risk_level where level = r.risk_level_id) as riskLevel
from f_risk_source r
where id=#{id} AND (org_code = #{orgCode} OR org_code like CONCAT(#{orgCode},'-%'))
</select>
<update
id=
"batchSaveRegionUe4"
parameterType=
"java.util.List"
>
<foreach
collection=
"list"
item=
"item"
index=
"index"
open=
""
close=
""
separator=
";"
>
update f_risk_source
<set
>
<if
test=
"item.ue4Location != null"
>
ue4_location = #{item.ue4Location,jdbcType=VARCHAR},
</if>
<if
test=
"item.ue4Rotation != null"
>
ue4_rotation = #{item.ue4Rotation,jdbcType=VARCHAR},
</if>
<if
test=
"item.ue4Extent != null"
>
ue4_extent = #{item.ue4Extent,jdbcType=VARCHAR},
</if>
<if
test=
"item.routePath != null"
>
route_path = #{item.routePath,jdbcType=VARCHAR},
</if>
</set>
where id = #{item.riskSourceId,jdbcType=BIGINT}
</foreach>
</update>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment