地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
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
<?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.javaweb.hydrology.mapper.HydrologyDataMapper">
    
    <resultMap type="HydrologyData" id="HydrologyDataResult">
        <result property="id"    column="id"    />
        <result property="record"    column="record"    />
        <result property="holeNum"    column="hole_num"    />
        <result property="year"    column="year"    />
        <result property="month"    column="month"    />
        <result property="layer"    column="layer"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>
 
    <sql id="selectHydrologyDataVo">
        select id, record, hole_num, year, month, layer, create_time from js_hydrology_data
    </sql>
 
    <select id="selectHydrologyDataList" parameterType="HydrologyData" resultMap="HydrologyDataResult">
        <include refid="selectHydrologyDataVo"/>
        <where>  
            <if test="record != null "> and record = #{record}</if>
            <if test="holeNum != null  and holeNum != ''"> and hole_num = #{holeNum}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="month != null  and month != ''"> and month = #{month}</if>
            <if test="layer != null  and layer != ''"> and layer = #{layer}</if>
        </where>
    </select>
    
    <select id="selectHydrologyDataListByNum"  resultType="com.javaweb.hydrology.vo.HydrologyDataVo">
        select record, year, month, layer from js_hydrology_data 
        where hole_num = #{holeNum} and year > #{year}
        order by month asc
    </select>
    
    <select id="selectMaxData" parameterType="String"  resultType="com.javaweb.hydrology.vo.HydrologyDataVo">
        select record, year, month, layer from js_hydrology_data 
        where hole_num = #{holeNum} and record is not null
        order by record desc  limit 1
    </select>
    
     <select id="selectMinData" parameterType="String"  resultType="com.javaweb.hydrology.vo.HydrologyDataVo">
        select record, year, month, layer from js_hydrology_data 
        where hole_num = #{holeNum} and record is not null
        order by record asc  limit 1
    </select>
    
    <select id="selectHydrologyDataById" parameterType="Long" resultMap="HydrologyDataResult">
        <include refid="selectHydrologyDataVo"/>
        where id = #{id}
    </select>
    
    
        
    <insert id="insertHydrologyData" parameterType="HydrologyData" useGeneratedKeys="true" keyProperty="id">
        insert into js_hydrology_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="record != null ">record,</if>
            <if test="holeNum != null  and holeNum != ''">hole_num,</if>
            <if test="year != null  and year != ''">year,</if>
            <if test="month != null  and month != ''">month,</if>
            <if test="layer != null  and layer != ''">layer,</if>
            <if test="createTime != null ">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="record != null ">#{record},</if>
            <if test="holeNum != null  and holeNum != ''">#{holeNum},</if>
            <if test="year != null  and year != ''">#{year},</if>
            <if test="month != null  and month != ''">#{month},</if>
            <if test="layer != null  and layer != ''">#{layer},</if>
            <if test="createTime != null ">#{createTime},</if>
         </trim>
    </insert>
 
    <update id="updateHydrologyData" parameterType="HydrologyData">
        update js_hydrology_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="record != null ">record = #{record},</if>
            <if test="holeNum != null  and holeNum != ''">hole_num = #{holeNum},</if>
            <if test="year != null  and year != ''">year = #{year},</if>
            <if test="month != null  and month != ''">month = #{month},</if>
            <if test="layer != null  and layer != ''">layer = #{layer},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteHydrologyDataById" parameterType="Long">
        delete from js_hydrology_data where id = #{id}
    </delete>
    
        
     <delete id="deleteHydrologyDataByEntity" parameterType="HydrologyData">
        delete from js_hydrology_data where 
        hole_num = #{holeNum} and year = #{year} and month = #{month} and layer = #{layer}
    </delete>
    
 
    <delete id="deleteHydrologyDataByIds" parameterType="String">
        delete from js_hydrology_data where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>