地质所 沉降监测网建设项目
zmk
2024-10-23 3f47c88e7cb4e53b3637620794420181f47b5a5e
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
<?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.geo.mapper.HoleLogMapper">
    
    <resultMap type="HoleLog" id="HoleLogResult">
        <result property="id"    column="id"    />
        <result property="projectId"    column="project_id"    />
        <result property="holeId"    column="hole_id"    />
        <result property="code"    column="code"    />
        <result property="beginDepth"    column="begin_depth"    />
        <result property="endDepth"    column="end_depth"    />
        <result property="createTime"    column="create_time"    />
        <result property="recordPerson"    column="record_person"    />
        <result property="description"    column="description"    />
        <result property="isDelete"    column="is_delete"    />
    </resultMap>
 
    <sql id="selectHoleLogVo">
        select id, project_id, hole_id, code, begin_depth, end_depth, create_time, record_person, description, is_delete from js_hole_log
    </sql>
 
    <select id="selectHoleLogList" parameterType="HoleLog" resultMap="HoleLogResult">
        <include refid="selectHoleLogVo"/>
        <where>  
            <if test="projectId != null  and projectId != ''"> and project_id = #{projectId}</if>
            <if test="holeId != null  and holeId != ''"> and hole_id = #{holeId}</if>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="beginDepth != null "> and begin_depth = #{beginDepth}</if>
            <if test="endDepth != null "> and end_depth = #{endDepth}</if>
            <if test="recordPerson != null  and recordPerson != ''"> and record_person = #{recordPerson}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <!-- 开始时间检索 -->
            <if test="params.beginCreateTime != null and params.beginCreateTime != ''">
                and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginCreateTime},'%y%m%d')
            </if>
            <!-- 结束时间检索 -->
            <if test="params.endCreateTime != null and params.endCreateTime != ''">
                and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endCreateTime},'%y%m%d')
            </if>
        </where>
        order by create_time asc
    </select>
    
    <select id="selectHoleLogById" parameterType="String" resultMap="HoleLogResult">
        <include refid="selectHoleLogVo"/>
        where id = #{id}
    </select>
 
    <select id="SUMHoleLog" resultType="com.javaweb.geo.vo.DrillDateVo">
        SELECT
            DATE_FORMAT(create_time, '%Y-%m-%d') AS drillDate,
            SUM( end_depth - begin_depth ) AS totalDrilledMeters
        FROM
            js_hole_log
        WHERE
            create_time >= CURDATE( ) - INTERVAL 10 DAY
        GROUP BY
            DATE( create_time )
        ORDER BY
            create_time;
    </select>
 
    <select id="SUMProjectHoleLog" resultType="com.javaweb.geo.vo.DrillDateVo" parameterType="HoleLog">
        SELECT
            DATE_FORMAT(create_time, '%Y-%m-%d') AS drillDate,
            SUM( end_depth - begin_depth ) AS totalDrilledMeters
        FROM
            js_hole_log
        WHERE
            create_time >= (CURDATE( ) - INTERVAL 10 DAY) and project_id =#{projectId}
        GROUP BY
            DATE( create_time )
        ORDER BY
            create_time;
    </select>
 
    <insert id="insertHoleLog" parameterType="HoleLog">
        insert into js_hole_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="projectId != null  and projectId != ''">project_id,</if>
            <if test="holeId != null  and holeId != ''">hole_id,</if>
            <if test="code != null  and code != ''">code,</if>
            <if test="beginDepth != null ">begin_depth,</if>
            <if test="endDepth != null ">end_depth,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="recordPerson != null  and recordPerson != ''">record_person,</if>
            <if test="description != null  and description != ''">description,</if>
            <if test="isDelete != null  and isDelete != ''">is_delete,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">#{id},</if>
            <if test="projectId != null  and projectId != ''">#{projectId},</if>
            <if test="holeId != null  and holeId != ''">#{holeId},</if>
            <if test="code != null  and code != ''">#{code},</if>
            <if test="beginDepth != null ">#{beginDepth},</if>
            <if test="endDepth != null ">#{endDepth},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="recordPerson != null  and recordPerson != ''">#{recordPerson},</if>
            <if test="description != null  and description != ''">#{description},</if>
            <if test="isDelete != null  and isDelete != ''">#{isDelete},</if>
         </trim>
    </insert>
 
    <update id="updateHoleLog" parameterType="HoleLog">
        update js_hole_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectId != null  and projectId != ''">project_id = #{projectId},</if>
            <if test="holeId != null  and holeId != ''">hole_id = #{holeId},</if>
            <if test="code != null  and code != ''">code = #{code},</if>
            <if test="beginDepth != null ">begin_depth = #{beginDepth},</if>
            <if test="endDepth != null ">end_depth = #{endDepth},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="recordPerson != null  and recordPerson != ''">record_person = #{recordPerson},</if>
            <if test="description != null  and description != ''">description = #{description},</if>
            <if test="isDelete != null  and isDelete != ''">is_delete = #{isDelete},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteHoleLogById" parameterType="String">
        delete from js_hole_log where id = #{id}
    </delete>
 
    <delete id="deleteHoleLogByIds" parameterType="String">
        delete from js_hole_log where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>