郑永安
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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?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.specialWork.repository.MaterialDetialInfoRepository">
 
    <resultMap type="com.gkhy.safePlatform.specialWork.entity.MaterialDetailInfo" id="MaterialDetialMap">
        <result property="id" column="id" jdbcType="BIGINT"/>
        <result property="materialName" column="material_name" jdbcType="VARCHAR"/>
        <result property="consumable" column="consumable" jdbcType="TINYINT"/>
        <result property="standVal" column="stand_val" jdbcType="INTEGER"/>
        <result property="configurationLevel" column="configuration_level" jdbcType="INTEGER"/>
        <result property="maBaseId" column="ma_base_id" jdbcType="BIGINT"/>
        <result property="bigClassifyId" column="big_classify_id" jdbcType="BIGINT"/>
        <result property="bigClassifyName" column="big_classify_name" jdbcType="VARCHAR"/>
        <result property="smallClassifyId" column="small_classify_id" jdbcType="BIGINT"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
        <result property="createUid" column="create_uid" jdbcType="INTEGER"/>
        <result property="createUname" column="create_uname" jdbcType="VARCHAR"/>
        <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
        <result property="modifiedUid" column="modified_uid" jdbcType="BIGINT"/>
        <result property="modifiedUname" column="modified_uname" jdbcType="VARCHAR"/>
    </resultMap>
 
    <!--查询单个-->
    <select id="queryById" resultMap="MaterialDetialMap">
        select
          id, material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, big_classify_name, small_classify_id, status, gmt_create, create_uid, create_uname, gmt_modified, modified_uid, modified_uname
        from material_detail
        where id = #{id}
    </select>
 
    <!--查询数据-->
    <select id="listAll" resultMap="MaterialDetialMap">
        select
        id, material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, big_classify_name, small_classify_id
        from material_detail
        where status = #{status}
    </select>
 
    <!--新增所有列-->
    <insert id="insertOne" >
        insert into material_detail(id,material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, big_classify_name, small_classify_id, status, gmt_create, create_uid, create_uname, gmt_modified, modified_uid, modified_uname)
        values (#{id},#{materialName}, #{consumable}, #{standVal}, #{configurationLevel}, #{maBaseId}, #{bigClassifyId}, #{bigClassifyName}, #{smallClassifyId}, #{status}, #{gmtCreate}, #{createUid}, #{createUname}, #{gmtModified}, #{modifiedUid}, #{modifiedUname})
    </insert>
 
    <!--通过主键修改数据-->
    <update id="updateOne">
        update material_detail
        <set>
            <if test="materialName != null and materialName != ''">
                material_name = #{materialName},
            </if>
            <if test="consumable != null">
                consumable = #{consumable},
            </if>
            <if test="standVal != null">
                stand_val = #{standVal},
            </if>
            <if test="configurationLevel != null">
                configuration_level = #{configurationLevel},
            </if>
            <if test="maBaseId != null">
                ma_base_id = #{maBaseId},
            </if>
            <if test="bigClassifyId != null">
                big_classify_id = #{bigClassifyId},
            </if>
            <if test="bigClassifyName != null and bigClassifyName != ''">
                big_classify_name = #{bigClassifyName},
            </if>
            <if test="smallClassifyId != null">
                small_classify_id = #{smallClassifyId},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
            <if test="gmtCreate != null">
                gmt_create = #{gmtCreate},
            </if>
            <if test="createUid != null">
                create_uid = #{createUid},
            </if>
            <if test="createUname != null and createUname != ''">
                create_uname = #{createUname},
            </if>
            <if test="gmtModified != null">
                gmt_modified = #{gmtModified},
            </if>
            <if test="modifiedUid != null">
                modified_uid = #{modifiedUid},
            </if>
            <if test="modifiedUname != null and modifiedUname != ''">
                modified_uname = #{modifiedUname},
            </if>
        </set>
        where id = #{id}
    </update>
 
    <!--逻辑删除-->
    <update id="updateStatus">
        update material_detail set status = #{status} where id = #{id}
    </update>
 
    <!--批量删除-->
    <update id="batchUpdateStatus">
        update material_detail set status = #{status}
        where id in
        <foreach collection="ids" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </update>
    <select id="listByMaBaseId" resultMap="MaterialDetialMap">
        select
        id, material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, big_classify_name, small_classify_id
        from material_detail
        where ma_base_id = #{maBaseId}
        and status = #{status}
 
    </select>
    <!--批量插入-->
    <insert id="saveBatch" >
        insert into material_detail(id,material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, big_classify_name, small_classify_id, status, gmt_create, create_uid, create_uname, gmt_modified, modified_uid, modified_uname)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.id},#{entity.materialName}, #{entity.consumable}, #{entity.standVal}, #{entity.configurationLevel}, #{entity.maBaseId}, #{entity.bigClassifyId}, #{entity.bigClassifyName}, #{entity.smallClassifyId}, #{entity.status}, #{entity.gmtCreate}, #{entity.createUid}, #{entity.createUname}, #{entity.gmtModified}, #{entity.modifiedUid}, #{entity.modifiedUname})
        </foreach>
    </insert>
    <!--批量更新-->
    <update id="updateBatch">
        <foreach collection="list" item="md" index="index" open="" close="" separator=";">
            update material_detail
            <set>
                <if test="md.materialName != null and md.materialName != ''">
                    material_name = #{md.materialName},
                </if>
                <if test="md.consumable != null">
                    consumable = #{md.consumable},
                </if>
                <if test="md.standVal != null">
                    stand_val = #{md.standVal},
                </if>
                <if test="md.configurationLevel != null">
                    configuration_level = #{md.configurationLevel},
                </if>
                <if test="md.maBaseId != null">
                    ma_base_id = #{md.maBaseId},
                </if>
                <if test="md.bigClassifyId != null">
                    big_classify_id = #{md.bigClassifyId},
                </if>
                <if test="md.bigClassifyName != null and md.bigClassifyName != ''">
                    big_classify_name = #{md.bigClassifyName},
                </if>
                <if test="md.smallClassifyId != null">
                    small_classify_id = #{md.smallClassifyId},
                </if>
                <if test="md.status != null">
                    status = #{md.status},
                </if>
                <if test="md.gmtCreate != null">
                    gmt_create = #{md.gmtCreate},
                </if>
                <if test="md.createUid != null">
                    create_uid = #{md.createUid},
                </if>
                <if test="md.createUname != null and md.createUname != ''">
                    create_uname = #{md.createUname},
                </if>
                <if test="md.gmtModified != null">
                    gmt_modified = #{md.gmtModified},
                </if>
                <if test="md.modifiedUid != null">
                    modified_uid = #{md.modifiedUid},
                </if>
                <if test="md.modifiedUname != null and md.modifiedUname != ''">
                    modified_uname = #{md.modifiedUname},
                </if>
            </set>
            where id = #{md.id}
        </foreach>
    </update>
    <update id="updateStatusByMaBaseId">
        update material_detail set status = #{status} where ma_base_id = #{maBaseId}
    </update>
    <update id="batchUpdateStatusByMaBaseIds">
        update material_detail
        set status = #{status}
        where ma_base_id in
        <foreach collection="maBaseIds" item="maBaseId" open="(" close=")" separator=",">
           #{maBaseId}
        </foreach>
    </update>
    <select id="listByMaBaseIds" resultMap="MaterialDetialMap">
        select
            id, material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, big_classify_name, small_classify_id
        from material_detail
        where status = #{status} and ma_base_id in
        <foreach collection="maBaseIds" item="maBaseId" open="(" close=")" separator=",">
            #{maBaseId}
        </foreach>
    </select>
 
    <select id="listByIds" resultMap="MaterialDetialMap">
        select
        id, material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, big_classify_name, small_classify_id
        from material_detail
        where status = #{status} and id in
        <foreach collection="ids" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </select>
 
</mapper>