双重预防项目-国泰新华二开定制版
heheng
2 天以前 8e3dd5851dcedef5b21858dc1cfd5d11f1965ce6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?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.doublePrevention.repository.TrHiddenDangerCheckPointRepository">
    <resultMap id="BaseFields" type="com.ruoyi.doublePrevention.entity.TrHiddenDangerCheckPoint">
        <result property="id" column="id"/>
        <result property="checkPointId" column="check_point_id"/>
        <result property="checkId" column="check_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="whetherDanger" column="whether_danger"/>
        <result property="dangerName" column="danger_name"/>
        <result property="dangerDescription" column="danger_description"/>
        <result property="dangerLevel" column="danger_level"/>
        <result property="troubleTypeId" column="trouble_type_id"/>
        <result property="troubleTypeName" column="trouble_type_name"/>
        <result property="checkTime" column="check_time"/>
        <result property="preRectifyPhoto" column="pre_rectify_photo"/>
        <result property="registerUserId" column="register_user_id"/>
        <result property="registerUserName" column="register_user_name"/>
        <result property="registerCreateTime" column="register_create_time"/>
        <result property="registerSubmitTime" column="register_submit_time"/>
        <result property="judgeUserId" column="judge_user_id"/>
        <result property="judgeUserName" column="judge_user_name"/>
        <result property="judgeCreateTime" column="judge_create_time"/>
        <result property="judgeCreateUserId" column="judge_create_user_id"/>
        <result property="dangerSources" column="danger_sources"/>
        <result property="reportStatus" column="report_status"/>
        <result property="examineUserId" column="examine_user_id"/>
        <result property="examineUserName" column="examine_user_name"/>
        <result property="examineStatus" column="examine_status"/>
        <result property="examineOpinion" column="examine_opinion"/>
        <result property="examineResult" column="examine_result"/>
        <result property="examineCreateTime" column="examine_create_time"/>
        <result property="treatMeasure" column="treat_measure"/>
        <result property="rectifyUserId" column="rectify_user_id"/>
        <result property="rectifyUserName" column="rectify_user_name"/>
        <result property="rectifyDeptId" column="rectify_dept_id"/>
        <result property="rectifyDeptName" column="rectify_dept_name"/>
        <result property="rectifyDeadlineTime" column="rectify_deadline_time"/>
        <result property="rectifyType" column="rectify_type"/>
        <result property="rectifyAttachment" column="rectify_attachment"/>
        <result property="rectifyMeasure" column="rectify_measure"/>
        <result property="rectifyCondition" column="rectify_condition"/>
        <result property="rectifyFund" column="rectify_fund"/>
        <result property="rectifyCompleteTime" column="rectify_complete_time"/>
        <result property="rectifyStatus" column="rectify_status"/>
        <result property="rectifyCreateTime" column="rectify_create_time"/>
        <result property="acceptUserId" column="accept_user_id"/>
        <result property="acceptUserName" column="accept_user_name"/>
        <result property="postRectifyPhoto" column="post_rectify_photo"/>
        <result property="acceptResult" column="accept_result"/>
        <result property="acceptOpinion" column="accept_opinion"/>
        <result property="acceptFile" column="accept_file"/>
        <result property="acceptCreateTime" column="accept_create_time"/>
        <result property="acceptStatus" column="accept_status"/>
        <result property="stage" column="stage"/>
        <result property="scheduleCheckStatus" column="schedule_check_status"/>
        <result property="checkType" column="check_type"/>
        <result property="companyId" column="company_id"/>
    </resultMap>
 
 
 
    <resultMap id="ListDangerLevelCountByTime" type="com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRespDO">
        <result property="heavyRiskCount" column="heavy_risk_count" />
        <result property="lightRiskCount" column="light_risk_count" />
    </resultMap>
    <select id="listDangerLevelCountByTime" resultMap="ListDangerLevelCountByTime">
        select
            IFNULL(sum(CASE WHEN danger_level='0' then 1 else 0 END),0) light_risk_count,
            IFNULL(sum(CASE WHEN danger_level='1' then 1 else 0 END),0) heavy_risk_count
        from tr_hidden_danger_check_point
        WHERE whether_danger = '1'
          and examine_status = '1'
          and examine_create_time >= #{startTime}
          and examine_create_time &lt;= #{endTime}
          <if test="depIds != null and depIds.size() > 0">
              and rectify_dept_id in (
              <foreach collection="depIds"  item="depId" index="index" separator=",">
                  #{depId}
              </foreach> )
          </if>
    </select>
 
 
    <resultMap id="ListDangerLevelRectifiedCountByTime" type="com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRectifiedRespDO">
        <result property="heavyRiskRectifyCount" column="heavy_risk_rectify_count" />
        <result property="lightRiskRectifyCount" column="light_risk_rectify_count" />
    </resultMap>
    <select id="listDangerLevelRectifiedCountByTime" resultMap="ListDangerLevelRectifiedCountByTime">
        select
            IFNULL(sum(CASE WHEN danger_level='0' then 1 else 0 END),0) light_risk_rectify_count,
            IFNULL(sum(CASE WHEN danger_level='1' then 1 else 0 END),0) heavy_risk_rectify_count
        from tr_hidden_danger_check_point
        WHERE whether_danger = '1'
          and examine_status = '1'
          and accept_status = '1'
          and accept_create_time >= #{startTime}
          and accept_create_time &lt;= #{endTime}
          <if test="depIds != null and depIds.size() > 0">
              and rectify_dept_id in (
              <foreach collection="depIds"  item="depId" index="index" separator=",">
                  #{depId}
              </foreach> )
          </if>
    </select>
 
 
<!--    List<TroubleDataRespDTO> getSPIData(SPIDataReqBO spiDataReqBO);-->
    <select id="getSPIData" resultType="com.ruoyi.doublePrevention.entity.SPI.TroubleData">
        SELECT
            DATE_FORMAT(register_create_time, '%Y-%m') time, sum(1) count,
            sum(case when rectify_status = '1' then 1 else 0 end) rectifyFinish,
            sum(case when rectify_status = '0' then 1 else 0 end) rectifyNotFinish,
            sum(case when accept_result = '1' then 1 else 0 end) accept,
            sum(case when danger_level = '0' then 1 else 0 end) generalDanger,
            sum(case when danger_level = '1' then 1 else 0 end) majorDanger
        FROM tr_hidden_danger_check_point
        WHERE whether_danger =1 and examine_status =1 and  register_create_time >= #{spiDataReqBO.startTime} and #{spiDataReqBO.endTime} >= register_create_time and whether_danger = 1
        GROUP BY time
        ORDER BY time ASC
    </select>
 
<!--    TroubleLevel getTroubleLevel(SPIDataReqBO spiDataReqBO);-->
    <select id="getTroubleLevel" resultType="com.ruoyi.doublePrevention.entity.SPI.TroubleLevel">
        select
            sum(case when trouble_type_name = 'A级隐患' then 1 else 0 end) A,
            sum(case when trouble_type_name = 'B级隐患' then 1 else 0 end) B,
            sum(case when trouble_type_name = 'C级隐患' then 1 else 0 end) C,
            sum(case when rectify_status = '1' then 1 else 0 end) rectifyFinish,
            sum(case when rectify_status = '0' then 1 else 0 end) rectifyNotFinish
        from tr_hidden_danger_check_point
        WHERE  whether_danger =1 and examine_status =1 and YEAR(register_create_time) = #{spiDataReqBO.year}
        <if test="spiDataReqBO.month != null and spiDataReqBO.month != ''">
            AND MONTH(register_create_time) = #{spiDataReqBO.month}
        </if>
    </select>
</mapper>