危化品全生命周期管理后端
“djh”
2025-02-24 34f448ffe2aacb496c15ab5da44a24128e0682be
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
<?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.HzWarehouseMapper">
    <resultMap type="com.gkhy.hazmat.system.domain.HzWarehouse" id="HzWarehouseResult">
        <result property="id"       column="id"       />
        <result property="name"    column="name"    />
        <result property="address"    column="address"    />
        <result property="companyId"         column="company_id"          />
        <result property="delFlag"         column="del_flag"          />
        <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="companyName"         column="company_name"/>
    </resultMap>
 
    <sql id="selectWarehouseVo">
        select a.id,  a.name,  a.address, a.version, a.company_id,a.del_flag,a.create_by,  a.create_time,  a.update_by,  a.update_time,  a.remark,
               b.name as company_name
        from hz_warehouse a
        left join sys_company b on b.id=a.company_id
    </sql>
    <insert id="insertCupboard">
        insert into hz_warehouse_cupboard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="warehouseId != null">warehouse_id,</if>
            <if test="cupboardName != null and cupboardName != ''">cupboard_name,</if>
            <if test="mess != null and mess != ''">mess,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="warehouseId != null">#{warehouseId},</if>
            <if test="cupboardName != null and cupboardName != ''">#{cupboardName},</if>
            <if test="mess != null and mess != ''">#{mess},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
        </trim>
    </insert>
    <update id="deleteWarehouseById" parameterType="java.lang.Long">
        update hz_warehouse set del_flag=1 where id=#{warehouseId}
    </update>
    <update id="updateCupboard">
        update hz_warehouse_cupboard
        <trim prefix="SET" suffixOverrides=",">
            <if test="cupboardName != null">cupboard_name = #{cupboardName},</if>
            <if test="mess != null and mess != ''">mess = #{mess},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteByCupboardId">
        delete from hz_warehouse_cupboard where id = #{cupboardId}
    </delete>
 
    <select id="checkNameUnique" resultType="com.gkhy.hazmat.system.domain.HzWarehouse">
        select id,name from hz_warehouse where name=#{name} and company_id=#{companyId} and del_flag=0 limit 1
    </select>
 
    <select id="selectWarehouseList" resultMap="HzWarehouseResult"
            parameterType="com.gkhy.hazmat.system.domain.HzWarehouse">
        <include refid="selectWarehouseVo"/>
        <where>
            and a.del_flag=0
            <if test="name != null and name != ''">
                AND a.name like concat('%', #{name}, '%')
            </if>
            <if test="companyId != null">
                AND a.company_id= #{companyId}
            </if>
        </where>
        order by a.id desc
    </select>
 
    <select id="selectWarehouseListByIds" resultType="com.gkhy.hazmat.system.domain.HzWarehouse">
        select id,name from hz_warehouse where del_flag=0 and  id in
        <foreach collection="warehouseIds" item="warehouse" open="(" separator="," close=")">
            #{warehouse}
        </foreach>
    </select>
    <select id="selectByWarehouseIdAndCupboardName" resultType="com.gkhy.hazmat.system.domain.HzWarehouseCupboard">
        SELECT
            id,
            warehouse_id,
            cupboard_name,
            mess,
            create_by,
            create_time,
            update_by,
            update_time,
            del_flag
        FROM
            hz_warehouse_cupboard
        WHERE
            warehouse_id = #{id} and cupboard_name =#{cupboardName}
          AND del_flag = 0
    </select>
    <select id="selectByWarehouseId" resultType="com.gkhy.hazmat.system.domain.HzWarehouseCupboard">
        SELECT
            id,
            warehouse_id,
            cupboard_name,
            mess,
            create_by,
            create_time,
            update_by,
            update_time,
            del_flag
        FROM
            hz_warehouse_cupboard
        WHERE
            warehouse_id = #{id}
          AND del_flag = 0
    </select>
</mapper>