hdy
7 天以前 b9df2fc5c64a1d989991655a9e42e4d1f2ec4075
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
<?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.billion.main.da.mapper.DaMaterialCollectionMapper">
    
    <resultMap type="DaMaterialCollection" id="DaMaterialCollectionResult">
        <result property="id"    column="id"    />
        <result property="sfcCode"    column="sfc_code"    />
        <result property="locationCode"    column="location_code"    />
        <result property="paramCode"    column="param_code"    />
        <result property="paramName"    column="param_name"    />
        <result property="paramValue"    column="param_value"    />
        <result property="collectTime"    column="collect_time"    />
    </resultMap>
 
    <sql id="selectDaMaterialCollectionVo">
        select id, sfc_code, location_code, param_code, param_name, param_value, collect_time from da_material_collection
    </sql>
 
    <select id="selectDaMaterialCollectionList" parameterType="DaMaterialCollection" resultMap="DaMaterialCollectionResult">
        <include refid="selectDaMaterialCollectionVo"/>
        <where>  
            <if test="sfcCode != null  and sfcCode != ''"> and sfc_code = #{sfcCode}</if>
            <if test="locationCode != null  and locationCode != ''"> and location_code like concat('%', #{locationCode}, '%')</if>
            <if test="paramCode != null  and paramCode != ''"> and param_code like concat('%', #{paramCode}, '%')</if>
            <if test="paramName != null  and paramName != ''"> and param_name like concat('%', #{paramName}, '%')</if>
            <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"><!-- 开始时间检索 -->
                and collect_time BETWEEN #{params.beginTime} and #{params.endTime}
            </if>
        </where>
    </select>
    
    <select id="selectDaMaterialCollectionById" parameterType="Long" resultMap="DaMaterialCollectionResult">
        <include refid="selectDaMaterialCollectionVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertDaMaterialCollection" parameterType="DaMaterialCollection" useGeneratedKeys="true" keyProperty="id">
        insert into da_material_collection
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sfcCode != null">sfc_code,</if>
            <if test="locationCode != null">location_code,</if>
            <if test="paramCode != null">param_code,</if>
            <if test="paramName != null">param_name,</if>
            <if test="paramValue != null">param_value,</if>
            <if test="collectTime != null">collect_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sfcCode != null">#{sfcCode},</if>
            <if test="locationCode != null">#{locationCode},</if>
            <if test="paramCode != null">#{paramCode},</if>
            <if test="paramName != null">#{paramName},</if>
            <if test="paramValue != null">#{paramValue},</if>
            <if test="collectTime != null">#{collectTime},</if>
         </trim>
    </insert>
 
    <update id="updateDaMaterialCollection" parameterType="DaMaterialCollection">
        update da_material_collection
        <trim prefix="SET" suffixOverrides=",">
            <if test="sfcCode != null">sfc_code = #{sfcCode},</if>
            <if test="locationCode != null">location_code = #{locationCode},</if>
            <if test="paramCode != null">param_code = #{paramCode},</if>
            <if test="paramName != null">param_name = #{paramName},</if>
            <if test="paramValue != null">param_value = #{paramValue},</if>
            <if test="collectTime != null">collect_time = #{collectTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteDaMaterialCollectionById" parameterType="Long">
        delete from da_material_collection where id = #{id}
    </delete>
 
    <delete id="deleteDaMaterialCollectionByIds" parameterType="String">
        delete from da_material_collection where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>