隐患排查APP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

272 lines
10 KiB

2 years ago
<?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.hisense.hiatmp.server_api.mapper.OperatorMapper">
2 years ago
<select id="getOperatorByName" resultType="com.hisense.hiatmp.model.common.Operator">
2 years ago
select *
from operator
where cusername = #{cusername}
2 years ago
</select>
2 years ago
<select id="getOperatorById" resultType="com.hisense.hiatmp.model.common.Operator">
select o.*,d.cdepartmentname,d.nlevel,d.parentdepartment,d.departmentflag
from operator o
LEFT JOIN department d on o.cdepartmentid = d.cdepartmentid
where o.nuserid = #{nuserid}
2 years ago
</select>
2 years ago
<select id="getAllOperator" resultType="com.hisense.hiatmp.model.common.Operator">
2 years ago
select *
from operator;
2 years ago
</select>
<select id="updateByPrimaryKeySelective" resultType="String">
2 years ago
update operator
set cuserpwd = #{cuserpwd},last_mod_date = NOW()
2 years ago
where nuserid = #{nuserid} RETURNING nuserid;
</select>
<select id="getRoleById" resultType="String">
select r.rolename from user_role_relation ror
2 years ago
LEFT JOIN "public"."role" r on ror.roleid = r.roleid
where ror.nuserid = #{nuserid}
2 years ago
</select>
<select id="getOperatorDataSum" resultType="com.hisense.hiatmp.model.common.HighDangerBaseNum">
SELECT 'MyPC' AS status, COUNT
( 0 )
FROM
(
SELECT
CASE
WHEN
<![CDATA[
now( ) AT TIME ZONE'Asia/Shanghai' < t1.nearEndTime THEN
9
WHEN now( ) AT TIME ZONE'Asia/Shanghai' >= t1.nearEndTime
AND now( ) AT TIME ZONE'Asia/Shanghai' <= t1.planEndTime THEN
2
WHEN now( ) AT TIME ZONE'Asia/Shanghai' >= t1.planEndTime THEN
1
END AS time_status,
FLOOR ( EXTRACT ( EPOCH FROM ( now( ) AT TIME ZONE'Asia/Shanghai' - planEndTime ) ) / ( 1440 * 60 ) ) delayDay,
CEIL (
MOD ( CEIL ( EXTRACT ( EPOCH FROM ( now( ) AT TIME ZONE'Asia/Shanghai' - planEndTime ) ) ) :: INTEGER, 1440 * 60 ) :: FLOAT / 3600
) delayHour,
FLOOR ( EXTRACT ( EPOCH FROM ( planEndTime - now( ) AT TIME ZONE'Asia/Shanghai' ) ) / ( 1440 * 60 ) ) nearDay,
CEIL (
MOD ( CEIL ( EXTRACT ( EPOCH FROM ( planEndTime - now( ) AT TIME ZONE'Asia/Shanghai' ) ) ) :: INTEGER, 1440 * 60 ) :: FLOAT / 3600
) nearHour,
]]>
t1.*
FROM
(
SELECT
hdb.nid,
hdb.NAME,
hdb.pc_start_time,
hdb.pc_end_time,
hdb.zl_start_time,
hdb.business_id,
hdb."type",
hdb."report_dept",
hdb."operator",
hdb.pc_count,
hdb."status",
hdr.belong_xq,
hdr.xzjd,
et.enumname,
hdb.approve_status,
hdr.section_code,
hdr.if_cross,
hdr.cross_code,
COALESCE ( hdb.last_mod_date, hdb.insert_time ) AS hdb_last_mode_date,
COALESCE ( hdb.pc_end_time, hdb.pc_start_time + INTERVAL '1 day' * tpc.param_value :: INTEGER ) AS planEndTime,
COALESCE ( hdb.pc_end_time, hdb.pc_start_time + INTERVAL '1 day' * tpc.param_value :: INTEGER ) - INTERVAL '3 day' AS nearEndTime,
bs.section_name,
bs.section_code
FROM
tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id
AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601'
AND et.enumvalue = hdb.status
LEFT JOIN bis_section bs ON hdr.section_code = bs.section_code
LEFT JOIN tht_param_config tpc ON tpc.param_code = 'THT_PC_ROAD_XT'
WHERE
1 = 1
AND hdb.business_id IN (
SELECT
ta.business_id
FROM
tht_approve ta
WHERE
1 = 1
and ta.OPERATOR = #{nuserid}
AND ( ta.operate_content = '0' OR ta.approve_result != '-1' )
AND ta.status IN ( '10', '0' )
<if test="departmentid != null">
AND hdr.belong_xq like concat(concat(#{departmentid}::text,'%'))
</if>
<if test="startTime != null and startTime !=''">
and COALESCE(hdb.last_mod_date, hdb.insert_time) &gt;= to_date(#{startTime}, 'yyyy-MM-DD')
and COALESCE(hdb.last_mod_date, hdb.insert_time) &lt;= to_date(#{endTime}, 'yyyy-MM-DD') + 1
</if>
)
AND hdb.approve_status != '-1'
AND hdr.nid IS NOT NULL
) t1
ORDER BY
time_status ASC,
t1.planEndTime ASC
) tmp_count
UNION ALL
SELECT 'MyZL' AS status, COUNT
( 0 )
FROM
(
SELECT
CASE
<![CDATA[
WHEN now( ) AT TIME ZONE'Asia/Shanghai' < t1.nearEndTime THEN
9
WHEN now( ) AT TIME ZONE'Asia/Shanghai' >= t1.nearEndTime
AND now( ) AT TIME ZONE'Asia/Shanghai' <= t1.planEndTime THEN
2
WHEN now( ) AT TIME ZONE'Asia/Shanghai' >= t1.planEndTime THEN
1
END AS time_status,
]]>
FLOOR ( EXTRACT ( EPOCH FROM ( now( ) AT TIME ZONE'Asia/Shanghai' - planEndTime ) ) / ( 1440 * 60 ) ) delayDay,
CEIL (
MOD ( CEIL ( EXTRACT ( EPOCH FROM ( now( ) AT TIME ZONE'Asia/Shanghai' - planEndTime ) ) ) :: INTEGER, 1440 * 60 ) :: FLOAT / 3600
) delayHour,
FLOOR ( EXTRACT ( EPOCH FROM ( planEndTime - now( ) AT TIME ZONE'Asia/Shanghai' ) ) / ( 1440 * 60 ) ) nearDay,
CEIL (
MOD ( CEIL ( EXTRACT ( EPOCH FROM ( planEndTime - now( ) AT TIME ZONE'Asia/Shanghai' ) ) ) :: INTEGER, 1440 * 60 ) :: FLOAT / 3600
) nearHour,
t1.*
FROM
(
SELECT
hdb.nid,
hdb.NAME,
hdb.pc_start_time,
hdb.pc_end_time,
hdb.zl_start_time,
hdb.business_id,
hdb."type",
hdb."report_dept",
hdb."operator",
hdb.pc_count,
hdb."status",
hdr.belong_xq,
hdr.xzjd,
et.enumname,
hdb.approve_status,
hdr.section_code,
hdr.if_cross,
hdr.cross_code,
COALESCE ( hdb.last_mod_date, hdb.insert_time ) AS hdb_last_mode_date,
COALESCE ( hdb.pc_end_time, hdb.pc_start_time + INTERVAL '1 day' * tpc.param_value :: INTEGER ) AS planEndTime,
COALESCE ( hdb.pc_end_time, hdb.pc_start_time + INTERVAL '1 day' * tpc.param_value :: INTEGER ) - INTERVAL '3 day' AS nearEndTime,
bs.section_name,
bs.section_code
FROM
tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id
AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601'
AND et.enumvalue = hdb.status
LEFT JOIN bis_section bs ON hdr.section_code = bs.section_code
LEFT JOIN tht_param_config tpc ON tpc.param_code = 'THT_ZL_ROAD_XT'
WHERE
1 = 1
AND hdb.business_id IN (
SELECT
ta.business_id
FROM
tht_approve ta
WHERE
ta.OPERATOR = #{nuserid}
AND ( ta.operate_content = '0' OR ta.approve_result != '-1' )
AND ta.status = '20'
<if test="departmentid != null">
AND hdr.belong_xq like concat(concat(#{departmentid}::text,'%'))
</if>
<if test="startTime != null and startTime !=''">
and COALESCE(hdb.last_mod_date, hdb.insert_time) &gt;= to_date(#{startTime}, 'yyyy-MM-DD')
and COALESCE(hdb.last_mod_date, hdb.insert_time) &lt;= to_date(#{endTime}, 'yyyy-MM-DD') + 1
</if>
)
AND hdb.approve_status != '-1'
AND hdr.nid IS NOT NULL
) t1
ORDER BY
time_status ASC,
t1.planEndTime ASC
) tmp_count
UNION ALL
SELECT 'MySP' AS status, COUNT
( 0 )
FROM
(
SELECT
hdb.nid,
hdb.NAME,
hdb.pc_start_time,
hdb.pc_end_time,
hdb.business_id,
hdb."type",
hdb."report_dept",
hdb."operator",
hdb.pc_count,
hdb."status",
hdr.belong_xq,
hdr.xzjd,
et.enumname,
hdb.approve_status,
hdr.section_code,
hdr.if_cross,
hdr.cross_code,
COALESCE ( hdb.last_mod_date, hdb.insert_time ) AS hdb_last_mode_date,
bs.section_name,
bs.section_code
FROM
tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id
AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601'
AND et.enumvalue = hdb.status
LEFT JOIN bis_section bs ON hdr.section_code = bs.section_code
WHERE
1 = 1
AND hdb.business_id IN (
SELECT
ta.business_id
FROM
tht_approve ta
WHERE
ta.OPERATOR = #{nuserid}
AND ta.operate_content IN ( '-1', '1', '2' )
AND ta.status IN ( '10', '0', '20', '30', '40', '50', '60' )
<if test="departmentid != null">
AND hdr.belong_xq like concat(concat(#{departmentid}::text,'%'))
</if>
)
AND hdr.nid IS NOT NULL
<if test="startTime != null and startTime !=''">
and COALESCE(hdb.last_mod_date, hdb.insert_time) &gt;= to_date(#{startTime}, 'yyyy-MM-DD')
and COALESCE(hdb.last_mod_date, hdb.insert_time) &lt;= to_date(#{endTime}, 'yyyy-MM-DD') + 1
</if>
) t1
</select>
2 years ago
</mapper>