危化品全生命周期管理后端
kongzy
2024-08-22 0c73654f55844e34772732914af8cc1e247aab63
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
<?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.hazmat.system.mapper.HzWarningMapper">
    <resultMap type="com.gkhy.hazmat.system.domain.HzWarning" id="HzWarningResult">
        <result property="id"       column="id"       />
        <result property="hazmatId"    column="hazmat_id"    />
        <result property="basicId"    column="basic_id"    />
        <result property="state"     column="state"     />
        <result property="createId"  column="create_id"  />
        <result property="useTime"  column="use_time"  />
        <result property="handleTime"  column="handle_time"  />
        <result property="companyId"         column="company_id"          />
        <result property="version"         column="version"          />
        <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="createName"         column="create_name"          />
        <association property="hazmatBasic" javaType="com.gkhy.hazmat.system.domain.HzHazmatBasic" resultMap="hazmatBasicResult" />
 
    </resultMap>
 
    <resultMap type="com.gkhy.hazmat.system.domain.HzHazmatBasic" id="hazmatBasicResult">
        <result property="id"       column="basic_id"       />
        <result property="name"    column="basic_name"    />
    </resultMap>
 
    <sql id="selectWarningVo">
        select a.id, a.hazmat_id, a.basic_id,a.state, a.create_id,a.use_time,a.handle_time, a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
               b.name as basic_name,c.name as create_name
        from hz_warning a
        left join hz_hazmat_basic b on a.basic_id=b.id
        left join sys_user c on c.id=a.create_id
    </sql>
 
    <update id="batchUpdateState">
        update hz_warning set state=0,handle_time=null where hazmat_id in
        <foreach collection="hazmatIds" item="hazmatId" open="(" separator="," close=")">
            #{hazmatId}
        </foreach>
    </update>
 
    <select id="selectWarningList" resultMap="HzWarningResult"
            parameterType="com.gkhy.hazmat.system.domain.HzWarning">
        <include refid="selectWarningVo"/>
        <where>
            <if test="state != null">
                AND a.state= #{state}
            </if>
            <if test="companyId != null">
                AND a.company_id =#{companyId}
            </if>
        </where>
        order by id desc
    </select>
 
    <select id="selectExistHazmatId" resultType="java.lang.Long">
        select hazmat_id from hz_waring where hazmat_id in
        <foreach collection="hazmatIds" item="hazmatId" open="(" separator="," close=")">
            #{hazmatId}
        </foreach>
    </select>
 
    <select id="selectWarningCount" resultType="java.lang.Integer" parameterType="java.lang.Long">
        select count(1) from hz_warning where company_id=#{companyId} and state=0
    </select>
 
 
</mapper>