郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
<?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.gkhy.safePlatform.doublePrevention.repository.PreventProduceDeviceRepository" >
 
    <!--IPage selectPage(Long pageIndex, Long pageSize, Map<String, Object> params);-->
    <resultMap id="BaseResultMap" type="com.gkhy.safePlatform.doublePrevention.entity.PreventProduceDevice">
        <id column="id" property="id"/>
        <result column="uuid" property="uuid"/>
        <result column="delete_status" property="deleteStatus"/>
        <result column="risk_level" property="riskLevel"/>
        <result column="status" property="status"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="gmt_moditify" property="gmtModitify"/>
        <result column="dep_id" property="depId"/>
        <result column="enterprise_id" property="enterpriseId"/>
        <result column="dep_uuid" property="depUuid"/>
        <result column="enterprise_uuid" property="enterpriseUuid"/>
        <result column="dep_name" property="depName"/>
        <result column="create_by_user_name" property="createByUserName"/>
        <result column="last_edit_user_name" property="lastEditUserName"/>
        <result column="produce_device_name" property="produceDeviceName" jdbcType="VARCHAR"/>
        <result column="location" property="location"/>
    </resultMap>
 
    <select id="getDevicePage" resultMap="BaseResultMap">
        select * from prevent_produce_device
        <where>
            delete_status = 0
            <if test="queryParams.riskLevel != null">
                and risk_level = #{queryParams.riskLevel}
            </if>
            <if test="queryParams.status != null">
                and status = #{queryParams.status}
            </if>
            <if test="queryParams.depId != null">
                and dep_id = #{queryParams.depId}
            </if>
            <if test="queryParams.produceDeviceName != null">
                and produce_device_name like '%' #{queryParams.produceDeviceName} '%'
            </if>
            <if test="queryParams.location != null">
                and location = #{queryParams.location}
            </if>
        </where>
        order by gmt_create desc
    </select>
 
<!--    List<PreventProduceDevice> getByRiskLevel(Integer riskLevel);-->
    <select id="getByRiskLevel" resultType="com.gkhy.safePlatform.doublePrevention.entity.PreventProduceDevice">
            select * from prevent_produce_device where delete_status = 0 and risk_level= #{riskLevel}
    </select>
 
    <!--PreventProduceDevice getByDeviceName(String produceDeviceName);-->
    <select id="getByNameAndLocation" resultType="com.gkhy.safePlatform.doublePrevention.entity.PreventProduceDevice">
        select * from  prevent_produce_device
        where delete_status = 0 and produce_device_name = {produceDeviceName} and location = #{location}
    </select>
 
   <!-- PreventProduceDevice getByDeviceName(String produceDeviceName);-->
    <select id="getByDeviceName" resultType="com.gkhy.safePlatform.doublePrevention.entity.PreventProduceDevice">
        select * from  prevent_produce_device
        where delete_status = 0 and produce_device_name = #{produceDeviceName}
    </select>
 
    <!--PreventProduceDevice selectByDeviceId(Long id);-->
    <select id="selectByDeviceId" resultMap="BaseResultMap">
        select
            id,
            produce_device_name
            from  prevent_produce_device
        where delete_status = 0 and id = #{id}
    </select>
 
    <!--List<PreventProduceDevice> getListDevices();-->
    <select id="getListDevices" resultMap="BaseResultMap">
        select
            id,
            produce_device_name
        from  prevent_produce_device
        where delete_status = 0
    </select>
    <select id="countDeviceEveryLevel" resultType="com.gkhy.safePlatform.doublePrevention.entity.statistics.DeviceEveryLevelCountDO">
        select
        count(if(risk_level = 1,1,null)) lowRisk,
        count(if(risk_level = 2,1,null)) generalRisk,
        count(if(risk_level = 3,1,null)) higherRisk,
        count(if(risk_level = 4,1,null)) majorRisk
        from prevent_produce_device
        where delete_status = 0
    </select>
 
    <update id="updateProduceDevice">
        update prevent_produce_device set
        produce_device_name = #{produceDeviceName},
        dep_id = #{depId},
        dep_name = #{depName},
        dep_uuid = #{depUuid},
        risk_level = #{riskLevel},
        status = #{status},
        location = #{location},
        last_edit_user_name = #{lastEditUserName},
        gmt_moditify = #{gmtModitify}
        where delete_status = 0 and id = #{id}
    </update>
 
    <!--int deleteOne(Long id);-->
    <update id="deleteOne">
        update  prevent_produce_device set
        delete_status = 1,
        last_edit_user_name = #{lastEditUserName},
        gmt_moditify = #{gmtModitify}
        where id = #{id}
    </update>
 
</mapper>