郑永安
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
<?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.WorkMaterialInfoRepository">
 
    <resultMap type="com.gkhy.safePlatform.specialWork.entity.WorkMaterialInfo" id="WorkMaterialMap">
        <result property="id" column="id" jdbcType="BIGINT"/>
        <result property="materialName" column="material_name" jdbcType="VARCHAR"/>
        <result property="consumable" column="consumable" jdbcType="INTEGER"/>
        <result property="standVal" column="stand_val" jdbcType="INTEGER"/>
        <result property="configurationLevel" column="configuration_level" jdbcType="TINYINT"/>
        <result property="maBaseId" column="ma_base_id" jdbcType="BIGINT"/>
        <result property="smallClassifyId" column="small_classify_id" jdbcType="BIGINT"/>
        <result property="bigClassifyId" column="big_classify_id" jdbcType="BIGINT"/>
        <result property="bigClassifyName" column="big_classify_name" jdbcType="VARCHAR"/>
        <result property="workApplyId" column="work_apply_id" jdbcType="BIGINT"/>
        <result property="useCount" column="use_count" jdbcType="INTEGER"/>
        <result property="depId" column="dep_id" jdbcType="BIGINT"/>
        <result property="depName" column="dep_name" jdbcType="VARCHAR"/>
        <result property="mdId" column="md_id" jdbcType="BIGINT"/>
        <result property="receiveUids" column="receive_uids" jdbcType="VARCHAR"/>
        <result property="receiveUnames" column="receive_unames" jdbcType="VARCHAR"/>
    </resultMap>
 
    <!--查询单个-->
    <select id="queryById" resultMap="WorkMaterialMap">
        select
          id, material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, small_classify_id, big_classify_name, work_apply_id,use_count,dep_id,dep_name,md_id,receive_uids,receive_unames
        from work_material
        where id = #{id}
    </select>
 
    <!--查询指定行数据-->
    <select id="listByCondition" resultMap="WorkMaterialMap">
        select
          id, material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, small_classify_id, big_classify_name,work_apply_id,use_count,dep_id,dep_name,md_id,receive_uids,receive_unames
        from work_material
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="materialName != null and materialName != ''">
                and material_name = #{materialName}
            </if>
            <if test="standVal != null">
                and stand_val = #{standVal}
            </if>
            <if test="configurationLevel != null">
                and configuration_level = #{configurationLevel}
            </if>
            <if test="maBaseId != null">
                and ma_base_id = #{maBaseId}
            </if>
            <if test="bigClassifyId != null">
                and big_classify_id = #{bigClassifyId}
            </if>
            <if test="bigClassifyName != null and bigClassifyName != ''">
                and big_classify_name = #{bigClassifyName}
            </if>
            <if test="smallClassifyId != null">
                and small_classify_id = #{smallClassifyId}
            </if>
            <if test="workApplyId != null">
                and work_apply_id = #{workApplyId}
            </if>
 
        </where>
 
    </select>
 
    <!--新增所有列-->
    <insert id="insertOne" >
        insert into work_material(id,material_name, consumable, stand_val, configuration_level, ma_base_id,big_classify_id, small_classify_id, big_classify_name, work_apply_id,use_count,dep_id,dep_name,md_id,receive_uids,receive_unames)
        values (#{id},#{materialName}, #{consumable}, #{standVal}, #{configurationLevel}, #{maBaseId}, #{bigClassifyId}, #{smallClassifyId}, #{bigClassifyName},  #{workApplyId}, #{useCount},#{depId},#{depName},#{mdId},#{receiveUids},#{receiveUnames})
    </insert>
 
 
    <!--通过主键修改数据-->
    <update id="updateOne">
        update work_material
        <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">
                and big_classify_id = #{bigClassifyId}
            </if>
            <if test="bigClassifyName != null and bigClassifyName != ''">
                and big_classify_name = #{bigClassifyName}
            </if>
            <if test="smallClassifyId != null">
                and small_classify_id = #{smallClassifyId}
            </if>
            <if test="workApplyId != null">
                work_apply_id = #{workApplyId}
            </if>
            <if test="useCount != null">
                use_count = #{useCount}
            </if>
            <if test="depId != null">
                dep_id = #{depId}
            </if>
            <if test="depName != null and depName != ''">
                dep_name = #{depName}
            </if>
        </set>
        where id = #{id}
    </update>
 
    <insert id="saveBatch" >
        insert into work_material(id,material_name, consumable, stand_val, configuration_level, ma_base_id, big_classify_id, small_classify_id, big_classify_name,work_apply_id,use_count,dep_id,dep_name,md_id,receive_uids,receive_unames)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.id},#{entity.materialName}, #{entity.consumable}, #{entity.standVal}, #{entity.configurationLevel}, #{entity.maBaseId},  #{entity.bigClassifyId}, #{entity.smallClassifyId}, #{entity.bigClassifyName},#{entity.workApplyId}, #{entity.useCount}, #{entity.depId}, #{entity.depName}, #{entity.mdId},#{entity.receiveUids},#{entity.receiveUnames})
        </foreach>
    </insert>
 
</mapper>