<?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.ruoyi.project.tr.report.mapper.ReportMapper">
|
<resultMap type="Report" id="deptDangers">
|
<id property="reportId" column="report_id"/>
|
<result property="reportName" column="report_name"/>
|
<collection property="dangers" ofType="Danger" resultMap="dangers"/>
|
</resultMap>
|
<resultMap type="Danger" id="dangers">
|
<id property="dangerId" column="danger_id"/>
|
<result property="dangerLevel" column="danger_level"/>
|
<result property="dangerName" column="danger_name"/>
|
<result property="stage" column="stage"/>
|
<result property="count" column="count"/>
|
<result property="checkTime" column="check_time"/>
|
<result property="rectifyStatus" column="rectify_status"/>
|
<result property="rectifyUserName" column="rectify_user_name"/>
|
<result property="dangerDescription" column="danger_description"/>
|
<result property="whetherDanger" column="whether_danger"/>
|
</resultMap>
|
<resultMap type="DangerByTime" id="dangerByTime">
|
<result property="dateTime" column="date_time"/>
|
<result property="dangerLevel" column="danger_level"/>
|
<result property="count" column="count"/>
|
</resultMap>
|
<resultMap type="RiskDomain" id="riskResult">
|
<result property="count" column="count"/>
|
<result property="id" column="id"/>
|
<result property="name" column="name"/>
|
<result property="riskColor" column="risk_color"/>
|
<result property="regionName" column="region_name"/>
|
<result property="deptName" column="dept_name"/>
|
<result property="parentId" column="parent_id"/>
|
<result property="ancestors" column="ancestors"/>
|
</resultMap>
|
<select id="selectPublicityDanger" parameterType="long" resultMap="dangers">
|
SELECT
|
thdcp.register_create_time check_time,
|
thdcp.danger_name danger_name,
|
thdcp.rectify_status rectify_status,
|
thdcp.danger_level danger_level,
|
thdcp.rectify_user_name rectify_user_name,
|
thdcp.danger_description danger_description
|
FROM
|
tr_hidden_danger_check_point thdcp
|
LEFT JOIN
|
sys_user su
|
ON
|
thdcp.rectify_user_id = su.user_id
|
WHERE
|
su.company_id = #{companyId}
|
and
|
thdcp.whether_danger = 1
|
</select>
|
|
<select id="selectPublicityRisk" parameterType="long" resultMap="riskResult">
|
SELECT
|
trcp.check_point_id id,
|
trcp.evaluation_after_fengxianse risk_color,
|
trl.risk_list_name name,
|
tr.region_name region_name,
|
sd.dept_name dept_name
|
FROM
|
tr_risk_check_point trcp
|
LEFT JOIN
|
tr_risk_evaluation_plan trep
|
ON
|
trcp.plan_id = trep.plan_id
|
LEFT JOIN
|
tr_risk_list trl
|
ON
|
trep.evaluation_risk_id = trl.risk_list_id
|
LEFT JOIN
|
tr_region tr
|
ON
|
trl.region_id = tr.region_id
|
LEFT JOIN
|
sys_dept sd
|
ON
|
trl.dept_id = sd.dept_id
|
WHERE
|
trep.company_id = #{companyId}
|
AND
|
trcp.review_status = 2
|
</select>
|
<select id="selectTroubleAcceptCount" parameterType="long" resultType="int">
|
SELECT
|
COUNT(1)
|
FROM
|
tr_hidden_danger_check_point
|
WHERE
|
accept_user_id = #{userId}
|
AND
|
accept_status = 0
|
</select>
|
<select id="selectTroubleRectifyCount" parameterType="long" resultType="int">
|
SELECT
|
COUNT(1)
|
FROM
|
tr_hidden_danger_check_point
|
WHERE
|
rectify_user_id = #{userId}
|
AND
|
rectify_status = 0
|
</select>
|
<select id="selectTroubleExamineCount" parameterType="long" resultType="int">
|
SELECT
|
COUNT(1)
|
FROM
|
tr_hidden_danger_check_point
|
WHERE
|
examine_user_id = #{userId}
|
AND
|
examine_status = 0
|
</select>
|
<select id="selectTroubleReportCount" parameterType="long" resultType="int">
|
SELECT
|
count(1)
|
FROM
|
tr_hidden_danger_check_point
|
WHERE
|
danger_sources = 2
|
AND
|
((judge_user_id = #{userId} and (report_status = 0)))
|
|
</select>
|
<select id="selectTroubleCheckCount" parameterType="long" resultType="int">
|
SELECT
|
count(1)
|
FROM
|
tr_hidden_danger_check
|
WHERE
|
check_user_id = #{userId}
|
AND
|
plan_execute_status = 0
|
</select>
|
<select id="selectRiskReviewCount" parameterType="long" resultType="int">
|
SELECT
|
COUNT(1)
|
FROM
|
tr_risk_check_point
|
WHERE
|
review_user_id = #{userId}
|
AND
|
review_status = 1
|
AND
|
evaluation_status = 2
|
</select>
|
<select id="selectRiskEvaluationCount" parameterType="long" resultType="int">
|
SELECT
|
COUNT(1)
|
FROM
|
tr_risk_check_point
|
WHERE
|
evaluation_user_id = #{userId}
|
AND
|
evaluation_status = 1
|
</select>
|
<select id="selectRiskIdentityCount" resultType="int">
|
SELECT
|
count(1)
|
FROM
|
tr_risk_evaluation_plan
|
WHERE
|
company_id = #{companyId}
|
AND
|
stage_status = 2
|
AND
|
identify_status = 1
|
AND
|
identify_user_id = #{userId}
|
AND
|
plan_status = 2
|
</select>
|
<select id="selectDangerByRegion" parameterType="long" resultMap="deptDangers">
|
SELECT
|
tr.region_id report_id,
|
tr.region_name report_name,
|
thdcp.id danger_id,
|
thdcp.danger_level danger_level,
|
thdcp.danger_name danger_name,
|
thdcp.stage stage,
|
thdcp.whether_danger,
|
thdcp.rectify_user_name
|
FROM
|
tr_region tr
|
LEFT JOIN
|
tr_hidden_danger_check thdc
|
ON
|
tr.region_id = thdc.danger_place_id
|
LEFT JOIN
|
tr_hidden_danger_check_point thdcp
|
ON
|
thdcp.check_id = thdc.check_id
|
WHERE
|
tr.company_id = #{companyId} and tr.ancestors != '0'
|
and
|
tr.del_flag = '0'
|
</select>
|
|
|
<select id="selectDangerByRegionByCompanyId147" parameterType="long" resultMap="deptDangers">
|
SELECT
|
tr.region_id report_id,
|
tr.region_name report_name,
|
thdcp.id danger_id,
|
thdcp.danger_level danger_level,
|
thdcp.danger_name danger_name,
|
thdcp.stage stage,
|
thdcp.whether_danger,
|
thdcp.rectify_user_name
|
FROM
|
(SELECT region_id, parent_id, ancestors, region_name, order_num,
|
leader, phone, email, status, del_flag, create_by, create_time,
|
region_type,
|
company_unified_social_credit_code, company_business_license,
|
company_registered_address_of_business_license, company_scale, company_number_of_employees,
|
company_established, company_area, company_registered_capital, company_total_assets,
|
company_actual_income_of_the_previous_year, company_annual_profit, company_economic_type,
|
company_industry, company_legal_representative, company_corporate_position, company_legal_person_phone,
|
company_corporate_office_phone, company_person_in_charge_of_rectification, company_rectifier_phone,
|
company_organizer, company_group_company_name, company_security_function, company_postal_code,
|
company_introduction, company_other
|
from tr_region where parent_id = 1215 and company_id = 147) as tr
|
LEFT JOIN
|
tr_hidden_danger_check thdc
|
ON
|
tr.region_id = thdc.danger_place_id
|
LEFT JOIN
|
tr_hidden_danger_check_point thdcp
|
ON
|
thdcp.check_id = thdc.check_id
|
WHERE
|
tr.company_id = #{companyId} and tr.ancestors != '0'
|
and
|
tr.del_flag = '0'
|
</select>
|
|
|
<select id="selectRiskPoint" resultMap="riskResult">
|
SELECT
|
COUNT(1) count,
|
trt.risk_type_id id,
|
trt.risk_type_name name,
|
trcp.evaluation_after_fengxianse risk_color
|
FROM
|
tr_risk_type trt
|
LEFT JOIN
|
tr_risk_list trl
|
ON
|
<if test="riskType == 1">trt.risk_type_id = trl.risk_list_device_type</if>
|
<if test="riskType == 2">trt.risk_type_id = trl.risk_list_work_type</if>
|
<if test="riskType == 3">trt.risk_type_id = trl.risk_list_crafts_type</if>
|
LEFT JOIN
|
tr_risk_evaluation_plan trep
|
ON
|
trl.risk_list_id = trep.evaluation_risk_id
|
LEFT JOIN
|
tr_risk_check_point trcp
|
ON
|
trep.plan_id = trcp.plan_id
|
WHERE
|
trt.risk_type_type = #{riskType}
|
AND
|
trt.company_id = #{companyId}
|
AND
|
trcp.review_status = 2
|
GROUP BY
|
trt.risk_type_id
|
ORDER BY
|
trt.risk_type_id
|
ASC
|
</select>
|
<select id="selectRiskTrend" parameterType="long" resultMap="riskResult">
|
SELECT
|
COUNT(1) count,
|
trcp.check_point_id id,
|
DATE_FORMAT(trcp.create_time, '%Y') name,
|
trcp.evaluation_after_fengxianse risk_color
|
FROM
|
tr_risk_check_point trcp
|
WHERE
|
trcp.plan_id
|
in
|
(
|
SELECT
|
trep.plan_id
|
FROM
|
sys_dept sd
|
LEFT JOIN
|
tr_risk_list trl
|
ON
|
sd.dept_id = trl.dept_id
|
LEFT JOIN
|
tr_risk_evaluation_plan trep
|
ON
|
trl.risk_list_id = trep.evaluation_risk_id
|
WHERE
|
sd.company_id = #{companyId}
|
)
|
AND
|
trcp.review_status = 2
|
GROUP BY
|
DATE_FORMAT(trcp.create_time, '%Y'),
|
trcp.evaluation_after_fengxianse
|
ORDER BY
|
DATE_FORMAT(trcp.create_time, '%Y')
|
ASC
|
</select>
|
<select id="selectRiskByRegion" parameterType="long" resultMap="riskResult">
|
SELECT
|
COUNT(1) count,
|
tr.region_id id,
|
tr.parent_id,
|
tr.ancestors,
|
tr.region_name name,
|
trcp.evaluation_after_fengxianse risk_color
|
FROM
|
tr_region tr
|
LEFT JOIN
|
tr_risk_list trl
|
ON
|
tr.region_id = trl.region_id
|
LEFT JOIN
|
tr_risk_evaluation_plan trep
|
ON
|
trl.risk_list_id = trep.evaluation_risk_id
|
LEFT JOIN
|
tr_risk_check_point trcp
|
ON
|
trep.plan_id = trcp.plan_id
|
WHERE
|
tr.company_id = #{companyId} and tr.ancestors != '0'
|
and
|
tr.del_flag = '0'
|
AND
|
trcp.review_status = 2
|
GROUP BY
|
tr.region_id,trcp.evaluation_after_fengxianse
|
ORDER BY
|
tr.region_id
|
ASC
|
</select>
|
<select id="selectRegion" parameterType="long" resultMap="riskResult">
|
SELECT
|
region_id id,
|
region_name name
|
FROM
|
tr_region
|
WHERE
|
parent_id = (SELECT region_id FROM tr_region WHERE company_id = #{companyId} and ancestors = '0')
|
and
|
del_flag = '0'
|
ORDER BY
|
region_id
|
ASC
|
</select>
|
<select id="selectRiskByDept" parameterType="long" resultMap="riskResult">
|
SELECT
|
COUNT(1) count,
|
sd.dept_id id,
|
sd.dept_name name,
|
trcp.evaluation_after_fengxianse risk_color
|
FROM
|
sys_dept sd
|
LEFT JOIN
|
tr_risk_list trl
|
ON
|
sd.dept_id = trl.dept_id
|
LEFT JOIN
|
tr_risk_evaluation_plan trep
|
ON
|
trl.risk_list_id = trep.evaluation_risk_id
|
LEFT JOIN
|
tr_risk_check_point trcp
|
ON
|
trep.plan_id = trcp.plan_id
|
WHERE
|
sd.company_id = #{companyId}
|
AND
|
trcp.review_status = 2
|
GROUP BY
|
sd.dept_id,trcp.evaluation_after_fengxianse
|
ORDER BY
|
sd.dept_id
|
ASC
|
</select>
|
<select id="selectDept" parameterType="long" resultMap="riskResult">
|
SELECT
|
dept_id id,
|
dept_name name
|
FROM
|
sys_dept
|
WHERE
|
company_id = #{companyId} and parent_id != 0
|
ORDER BY
|
dept_id
|
ASC
|
</select>
|
<select id="selectDangersByMonths" resultMap="dangerByTime">
|
SELECT
|
DATE_FORMAT(register_create_time, '%Y-%m') date_time,
|
count(1) count,
|
danger_level
|
FROM
|
tr_hidden_danger_check_point
|
WHERE
|
register_create_time > DATE_FORMAT(#{date}, '%Y-%m')
|
and
|
whether_danger = 1
|
AND
|
rectify_user_id in (SELECT user_id FROM sys_user WHERE company_id = #{companyId})
|
GROUP BY DATE_FORMAT(register_create_time, '%Y-%m'),
|
danger_level
|
ORDER BY
|
DATE_FORMAT(register_create_time, '%Y-%m') ASC
|
</select>
|
<select id="selectDangersByYear" parameterType="long" resultMap="dangerByTime">
|
SELECT
|
DATE_FORMAT(register_create_time, '%Y') date_time,
|
count(1) count,
|
danger_level
|
FROM
|
tr_hidden_danger_check_point
|
WHERE
|
rectify_user_id in (SELECT user_id FROM sys_user WHERE company_id = #{companyId})
|
and
|
whether_danger = 1
|
GROUP BY DATE_FORMAT(register_create_time, '%Y'),
|
danger_level
|
ORDER BY
|
DATE_FORMAT(register_create_time, '%Y'),danger_level ASC
|
</select>
|
<select id="selectDeptDangers" parameterType="long" resultMap="deptDangers">
|
SELECT
|
sd.dept_id report_id,
|
sd.dept_name report_name,
|
thdcp.id danger_id,
|
thdcp.danger_level danger_level,
|
thdcp.danger_name danger_name,
|
thdcp.stage stage,
|
thdcp.whether_danger,
|
thdcp.rectify_user_name
|
FROM
|
sys_dept sd
|
LEFT JOIN tr_hidden_danger_check thdc
|
ON sd.dept_id = thdc.danger_dept_id
|
LEFT JOIN tr_hidden_danger_check_point thdcp
|
ON thdcp.check_id = thdc.check_id
|
WHERE
|
sd.company_id = #{companyId} and sd.parent_id != 0
|
</select>
|
<select id="selectTroubleTypeDangers" parameterType="long" resultMap="deptDangers">
|
SELECT
|
thtt.hidden_trouble_type_id report_id,
|
thtt.hidden_trouble_name report_name,
|
thdcp.id danger_id,
|
thdcp.danger_level danger_level,
|
thdcp.danger_name danger_name,
|
thdcp.stage stage,
|
thdcp.whether_danger,
|
thdcp.rectify_user_name
|
FROM
|
tr_hidden_trouble_type thtt
|
LEFT JOIN
|
tr_hidden_danger_check_point thdcp
|
ON
|
thtt.hidden_trouble_type_id = thdcp.trouble_type_id
|
WHERE
|
thtt.company_id = #{companyId}
|
</select>
|
|
</mapper>
|