双重预防项目-国泰新华二开定制版
heheng
9 天以前 5746e59e622daa8ce62d0c29aaba9b8bd5308bcd
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?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.PreventRiskDangerInfoRepository" >
 
    <resultMap id="BaseResultMap" type="com.ruoyi.doublePrevention.entity.PreventRiskDangerInfo">
        <id column="id" property="id"/>
        <result column="uuid" property="uuid"/>
        <result column="danger_check_point_id" property="dangerCheckPointId"/>
        <result column="hazard_code" property="hazardCode"/>
        <result column="danger_src" property="dangerSrc"/>
        <result column="danger_desc" property="dangerDesc"/>
        <result column="danger_reason" property="dangerReason"/>
        <result column="hazard_danger_type" property="hazardDangerType"/>
        <result column="danger_state" property="dangerState"/>
        <result column="danger_result" property="dangerResult"/>
        <result column="timeout_flag" property="timeoutFlag"/>
        <result column="report_time" property="reportTime"/>
        <result column="update_report_data_time" property="updateReportDataTime"/>
        <result column="report_status" property="reportStatus"/>
        <result column="report_switch" property="reportSwitch"/>
    </resultMap>
 
 
<!--    int insertDangerInfo(PreventRiskDangerInfo dangerInfo);-->
    <insert id="insertDangerInfo">
        insert into prevent_risk_danger_info values
        (null, #{uuid}, #{dangerCheckPointId}, #{hazardCode}, #{dangerSrc}, #{dangerDesc}, #{dangerReason}, #{dangerResult}, #{hazardDangerType}, #{dangerState},
            #{timeoutFlag}, #{reportTime}, #{updateReportDataTime}, #{reportStatus}, #{reportSwitch})
    </insert>
 
<!--    int updateDangerInfo(PreventRiskDangerInfo dangerInfo);-->
    <update id="updateDangerInfoBak">
 
        update prevent_risk_danger_info set
            hazard_code = #{hazardCode},
        <if test="dangerSrc != null and dangerSrc != ''">
            danger_src = #{dangerSrc},
        </if>
            danger_desc = #{dangerDesc},
            danger_reason = #{dangerReason},
            hazard_danger_type = #{hazardDangerType},
            danger_state = #{dangerState},
            danger_result =#{dangerResult},
            timeout_flag = #{timeoutFlag},
            update_report_data_time = #{updateReportDataTime},
            report_status = #{reportStatus},
            report_switch = #{reportSwitch}
        where danger_check_point_id = #{dangerCheckPointId}
    </update>
 
 
 
    <update id="updateDangerInfo">
 
        update prevent_risk_danger_info
        <set>
            <if test="hazardCode != null  ">
                hazard_code = #{hazardCode},
            </if>
            <if test="hazardCode == null or hazardCode == '' ">
                hazard_code = null,
            </if>
            <if test="dangerSrc != null and dangerSrc != ''">
                danger_src = #{dangerSrc},
            </if>
            <if test="dangerDesc != null ">
                danger_desc = #{dangerDesc},
            </if>
            <if test="dangerReason != null">
                danger_reason = #{dangerReason},
            </if>
            <if test="hazardDangerType != null  ">
                hazard_danger_type = #{hazardDangerType},
            </if>
            <if test="dangerState != null">
                danger_state = #{dangerState},
            </if>
            <if test="dangerResult != null ">
                danger_result =#{dangerResult},
            </if>
            <if test="timeoutFlag != null">
                timeout_flag = #{timeoutFlag},
            </if>
            <if test="updateReportDataTime != null">
                update_report_data_time = #{updateReportDataTime},
            </if>
            <if test="reportStatus != null ">
                report_status = #{reportStatus},
            </if>
            <if test="reportSwitch != null">
                report_switch = #{reportSwitch},
            </if>
 
        </set>
        where danger_check_point_id = #{dangerCheckPointId}
    </update>
 
 
    <!--    int deleteDangerInfo(Long id);-->
    <delete id="deleteDangerInfo">
        delete from prevent_risk_danger_info where danger_check_point_id = #{id}
    </delete>
 
    <resultMap id="listDangerResultCountByTimeResultMap" type="com.ruoyi.doublePrevention.entity.dto.DataCountDangerResultRespDO">
        <result property="riskCount" column="risk_count" />
        <result property="deathCount" column="death_count" />
        <result property="heavyInjureCount" column="heavy_injure_count" />
        <result property="lightInjureCount" column="light_injure_count" />
    </resultMap>
 
    <select id="listDangerResultCountByTime"  resultMap="listDangerResultCountByTimeResultMap">
        select
            count(id) risk_count,
            IFNULL(sum(CASE WHEN danger_result='2' then 1 else 0 END),0) light_injure_count,
            IFNULL(sum(CASE WHEN danger_result='3' then 1 else 0 END),0) heavy_injure_count,
            IFNULL(sum(CASE WHEN danger_result='4' then 1 else 0 END),0) death_count
        from (SELECT p.id,p.rectify_dept_id,p.examine_create_time,p.whether_danger,p.examine_status,i.danger_check_point_id,i.danger_result
              from tr_hidden_danger_check_point as p , prevent_risk_danger_info i WHERE p.id = i.danger_check_point_id) as t
        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>
 
<!--    int updateDangerInfoState(PreventRiskDangerInfo dangerInfo);-->
    <update id="updateDangerInfoState">
        update prevent_risk_danger_info set
            danger_state = #{dangerState},
            update_report_data_time = #{updateReportDataTime},
            report_status = #{reportStatus},
            report_switch = #{reportSwitch}
        where danger_check_point_id = #{dangerCheckPointId}
    </update>
 
 
<!--    List<PreventRiskDangerInfo> listReportDanger();-->
    <select id="listReportDanger" resultMap="BaseResultMap">
<!--        select * from prevent_risk_danger_info-->
<!--        where report_switch = 0 and (update_report_data_time > report_time or report_time is null) and (hazard_code !='' or hazard_code != null )-->
        select * from prevent_risk_danger_info
        where report_switch = 0 and (update_report_data_time > report_time or report_time is null) and (hazard_code !='' or hazard_code != null) and danger_state = 9
    </select>
 
<!--    PreventRiskDangerInfo updateDangerInfoReportStatus(HandlerReportParam handlerReportParam);-->
    <select id="updateDangerInfoReportStatus">
        update prevent_risk_danger_info set
            report_status =  #{reportStatus},
            report_time = #{reportTime}
        where id = #{id}
    </select>
 
<!--    PreventRiskDangerInfo getByHiddenDangerId(Long id);resultType="com.ruoyi.doublePrevention.entity.PreventRiskDangerInfo"-->
    <select id="getByHiddenDangerId" resultMap="BaseResultMap">
        select * from prevent_risk_danger_info
        where danger_check_point_id = #{id}
    </select>
</mapper>