SampleManagementMapper.xml 9.65 KB
Newer Older
高滢's avatar
高滢 committed
1 2 3 4 5 6
<?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.ruoyi.mapper.SampleManagementMapper">
    
高滢's avatar
高滢 committed
7
    <resultMap type="com.ruoyi.domain.Sample" id="SampleManagementResult">
高滢's avatar
高滢 committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21
        <result property="id"    column="id"    />
        <result property="identificationCode"    column="identification_code"    />
        <result property="sampleNumber"    column="sample_number"    />
        <result property="sampleName"    column="sample_name"    />
        <result property="sampleSender"    column="sample_sender"    />
        <result property="numberOfSamples"    column="number_of_samples"    />
        <result property="deliveryDate"    column="delivery_date"    />
        <result property="manufactureDate"    column="manufacture_date"    />
        <result property="manufacturingEnterprise"    column="manufacturing_enterprise"    />
        <result property="flag"    column="flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
22
        <result property="deleted"    column="deleted"    />
高滢's avatar
高滢 committed
23 24 25 26
        <result property="enterpriseId"    column="enterprise_id"    />
        <result property="remark"    column="remark"    />
        <result property="trademark"    column="trademark"    />
        <result property="samplePhotos"    column="sample_photos"    />
高滢's avatar
高滢 committed
27
        <result property="carCompanyName"    column="car_company_name"    />
高滢's avatar
高滢 committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
    </resultMap>

    <sql id="selectTSampleManagementVo">
        select sm.id,
               sm.identification_code,
               sm.sample_number,
               sm.sample_name,
               sm.sample_sender,
               sm.number_of_samples,
               sm.delivery_date,
               sm.manufacture_date,
               sm.manufacturing_enterprise,
               sm.flag,
               sm.create_by,
               sm.create_time,
               sm.update_by,
               sm.update_time,
45
               sm.deleted,
高滢's avatar
高滢 committed
46 47 48 49
               sm.enterprise_id,
               sm.remark,
               sm.trademark,
               sm.sample_photos,
50
               sm.car_company_name
51
        from t_sample sm
高滢's avatar
高滢 committed
52 53
    </sql>

高滢's avatar
高滢 committed
54
    <select id="selectSampleManagementList" parameterType="com.ruoyi.domain.Sample" resultMap="SampleManagementResult">
高滢's avatar
高滢 committed
55 56
        <include refid="selectTSampleManagementVo"/>
        <where>
57 58 59 60
            sm.deleted = 0
            <if test="identificationCode != null  and identificationCode != ''"> and sm.identification_code like concat('%', #{identificationCode}, '%')</if>
            <if test="sampleNumber != null  and sampleNumber != ''"> and sm.sample_number like concat('%', #{sampleNumber}, '%')</if>
            <if test="sampleName != null  and sampleName != ''"> and sm.sample_name like concat('%', #{sampleName}, '%')</if>
高滢's avatar
高滢 committed
61
            <if test="flag != null and flag != ''"> and sm.flag = #{flag}  </if>
高滢's avatar
高滢 committed
62 63 64 65 66
        </where>
    </select>
    
    <select id="selectSampleManagementById" parameterType="Long" resultMap="SampleManagementResult">
        <include refid="selectTSampleManagementVo"/>
67
        where sm.id = #{id}
高滢's avatar
高滢 committed
68 69
    </select>
        
高滢's avatar
高滢 committed
70
    <insert id="insertSampleManagement" parameterType="com.ruoyi.domain.Sample" useGeneratedKeys="true" keyProperty="id">
71
        insert into t_sample
高滢's avatar
高滢 committed
72 73 74 75 76
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="identificationCode != null">identification_code,</if>
            <if test="sampleNumber != null">sample_number,</if>
            <if test="sampleName != null">sample_name,</if>
            <if test="sampleSender != null">sample_sender,</if>
77
            <if test="numberOfSamples != null">number_of_samples,</if>
高滢's avatar
高滢 committed
78 79 80 81 82 83 84 85 86 87 88 89
            <if test="deliveryDate != null">delivery_date,</if>
            <if test="manufactureDate != null">manufacture_date,</if>
            <if test="manufacturingEnterprise != null">manufacturing_enterprise,</if>
            <if test="flag != null">flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="enterpriseId != null">enterprise_id,</if>
            <if test="remark != null">remark,</if>
            <if test="trademark != null">trademark,</if>
            <if test="samplePhotos != null">sample_photos,</if>
90
            <if test="deleted != null">deleted,</if>
高滢's avatar
高滢 committed
91 92 93 94 95 96
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="identificationCode != null">#{identificationCode},</if>
            <if test="sampleNumber != null">#{sampleNumber},</if>
            <if test="sampleName != null">#{sampleName},</if>
            <if test="sampleSender != null">#{sampleSender},</if>
97
            <if test="numberOfSamples != null">#{numberOfSamples},</if>
高滢's avatar
高滢 committed
98 99 100 101 102 103 104 105 106 107 108 109
            <if test="deliveryDate != null">#{deliveryDate},</if>
            <if test="manufactureDate != null">#{manufactureDate},</if>
            <if test="manufacturingEnterprise != null">#{manufacturingEnterprise},</if>
            <if test="flag != null">#{flag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="enterpriseId != null">#{enterpriseId}</if>
            <if test="remark != null">#{remark},</if>
            <if test="trademark != null">#{trademark},</if>
            <if test="samplePhotos != null">#{samplePhotos},</if>
110
            <if test="deleted != null">#{deleted},</if>
高滢's avatar
高滢 committed
111 112 113
         </trim>
    </insert>

高滢's avatar
高滢 committed
114
    <update id="updateSampleManagement" parameterType="com.ruoyi.domain.Sample">
115
        update t_sample
高滢's avatar
高滢 committed
116 117 118 119 120
        <trim prefix="SET" suffixOverrides=",">
            <if test="identificationCode != null">identification_code = #{identificationCode},</if>
            <if test="sampleNumber != null">sample_number = #{sampleNumber},</if>
            <if test="sampleName != null">sample_name = #{sampleName},</if>
            <if test="sampleSender != null">sample_sender = #{sampleSender},</if>
121
            <if test="numberOfSamples != null">number_of_samples = #{numberOfSamples},</if>
高滢's avatar
高滢 committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
            <if test="deliveryDate != null">delivery_date = #{deliveryDate},</if>
            <if test="manufactureDate != null">manufacture_date = #{manufactureDate},</if>
            <if test="manufacturingEnterprise != null">manufacturing_enterprise = #{manufacturingEnterprise},</if>
            <if test="flag != null">flag = #{flag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="trademark != null">trademark = #{trademark},</if>
            <if test="samplePhotos != null">sample_photos = #{samplePhotos},</if>
        </trim>
        where id = #{id}
    </update>

高滢's avatar
高滢 committed
138
    <select id="selectIdentificationCodeCount" parameterType="com.ruoyi.domain.Sample" resultType="integer">
139
        select count(id) from t_sample
高滢's avatar
高滢 committed
140
        <where>
141
            deleted = 0
高滢's avatar
高滢 committed
142 143 144 145 146 147
            <if test="flag != null and flag != ''">and flag = #{flag}</if>
            <if test="identificationCode != null  and identificationCode != ''"> and identification_code = #{identificationCode}</if>
            <if test="id != null and id != ''">and id != #{id}</if>
        </where>
    </select>

高滢's avatar
高滢 committed
148
    <select id="selectSampleNumberCount" parameterType="com.ruoyi.domain.Sample" resultType="integer">
149
        select count(id) from t_sample
高滢's avatar
高滢 committed
150
        <where>
151
            deleted = 0
高滢's avatar
高滢 committed
152 153 154 155 156
            <if test="flag != null and flag != ''">and flag = #{flag}</if>
            <if test="sampleNumber != null  and sampleNumber != ''"> and sample_number = #{sampleNumber}</if>
            <if test="id != null and id != ''">and id != #{id}</if>
        </where>
    </select>
高滢's avatar
高滢 committed
157 158 159 160 161 162 163 164 165 166

    <select id="selectSampleList" parameterType="com.ruoyi.domain.Sample" resultMap="SampleManagementResult">
        <include refid="selectTSampleManagementVo"/>
        <where>
            sm.deleted = 0
            <if test="identificationCode != null  and identificationCode != ''"> and sm.identification_code = #{identificationCode}</if>
            <if test="sampleNumber != null  and sampleNumber != ''"> and sm.sample_number = #{sampleNumber}</if>
            <if test="flag != null and flag != ''"> and sm.flag = #{flag} </if>
        </where>
    </select>
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181

    <resultMap type="com.ruoyi.web.response.SampleListResponse" id="SampleListResponse">
        <result property="id"    column="id"    />
        <result property="identificationCode"    column="identification_code"    />
        <result property="sampleNumber"    column="sample_number"    />
        <result property="sampleName"    column="sample_name"    />
        <result property="enterpriseId"    column="enterprise_id"    />
    </resultMap>
    <select id="findByIdList" resultMap="SampleListResponse">
        select id,identification_code,sample_number,sample_name,enterprise_id from t_sample
        WHERE id IN
        <foreach collection="relationList" item="relation" open="(" separator="," close=")">
            #{relation.sampleId}
        </foreach>
    </select>
高滢's avatar
高滢 committed
182
</mapper>