地质所 沉降监测网建设项目
chenhuan
2024-05-16 0fdd42e318f51f9e3c6581473416af1cca69877f
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?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.HolePersonMapper">
    
    <resultMap type="HolePerson" id="HolePersonResult">
        <result property="ids"    column="ids"    />
        <result property="code"    column="code"    />
        <result property="projectId"    column="project_id"    />
        <result property="holeId"    column="hole_id"    />
        <result property="type"    column="type"    />
        <result property="recordPerson"    column="record_person"    />
        <result property="operatePerson"    column="operate_person"    />
        <result property="recordPersonName"    column="record_person_name"    />
        <result property="testType"    column="test_type"    />
        <result property="createTime"    column="create_time"  jdbcType="TIMESTAMP"    />
        <result property="isDeleted"    column="is_deleted"    />
        <!--select子查询, column 传给子查询的参数-->
<!--        <collection property="holeMediaList" ofType="com.javaweb.geo.domain.HoleMedia" select="queryDetail" column="ids" />-->
    </resultMap>
 
    <resultMap type="HoleMedia" id="HoleMediaResult">
        <result property="ids"    column="ids"    />
        <result property="recordId"    column="record_id"    />
        <result property="projectId"    column="project_id"    />
        <result property="name"    column="name"    />
        <result property="createTime"    column="create_time"  jdbcType="TIMESTAMP" />
        <result property="type"    column="type"    />
        <result property="internetPath"    column="internet_path"    />
        <result property="createUser"    column="create_user"    />
        <result property="uploadUser"    column="upload_user"    />
    </resultMap>
 
    <!--子查询的sql-->
    <select id="queryDetail" resultMap="HoleMediaResult">
       SELECT * FROM js_hole_media where record_id = #{ids}
    </select>
 
    <sql id="selectHolePersonVo">
        select ids,code, project_id, hole_id, type, record_person ,operate_person, test_type, create_time, is_deleted from js_hole_person
    </sql>
 
    <select id="selectHolePersonList" parameterType="HolePerson" resultMap="HolePersonResult">
        select
        a.ids,
        a.code,
        a.project_id,
        a.hole_id,
        a.type,
        a.record_person ,
        u.real_name AS record_person_name,
        a.operate_person,
        a.test_type,
        a.create_time,
        a.is_deleted
        from js_hole_person a LEFT JOIN js_company_user u ON a.record_person = u.ids
        <where>  
            <if test="code != null  and code != ''"> and a.code = #{code}</if>
            <if test="projectId != null  and projectId != ''"> and a.project_id = #{projectId}</if>
            <if test="holeId != null  and holeId != ''"> and a.hole_id = #{holeId}</if>
            <if test="type != null  and type != ''"> and a.type = #{type}</if>
            <if test="recordPerson != null  and recordPerson != ''"> and a.record_person = #{recordPerson}</if>
            <if test="operatePerson != null  and operatePerson != ''"> and a.operate_person = #{operatePerson}</if>
            <if test="testType != null  and testType != ''"> and a.test_type = #{testType}</if>
            <if test="isDeleted != null  and isDeleted != ''"> and a.is_deleted = #{isDeleted}</if>
        </where>
    </select>
    
    <select id="selectHolePersonById" parameterType="String" resultMap="HolePersonResult">
        select
        a.ids,
        a.code,
        a.project_id,
        a.hole_id,
        a.type,
        a.record_person ,
        u.real_name AS record_person_name,
        a.operate_person,
        a.test_type,
        a.create_time,
        a.is_deleted
        from js_hole_person a LEFT JOIN js_company_user u ON a.record_person = u.ids
        where a.ids = #{ids}
    </select>
 
    <select id="selectHolePersonByHoleId"  parameterType="String" resultMap="HolePersonResult">
        <include refid="selectHolePersonVo"/> where hole_id = #{holeId}
    </select>
 
    <select id="selectHolePersonByProjectId" parameterType="String" resultMap="HolePersonResult">
        <include refid="selectHolePersonVo"/> WHERE project_id = #{projectId}
    </select>
 
    <insert id="insertHolePerson" parameterType="HolePerson">
        insert into js_hole_person
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ids != null  and ids != ''">ids,</if>
            <if test="code != null  and code != ''">code,</if>
            <if test="projectId != null  and projectId != ''">project_id,</if>
            <if test="holeId != null  and holeId != ''">hole_id,</if>
            <if test="type != null  and type != ''">type,</if>
            <if test="recordPerson != null  and recordPerson != ''">record_person,</if>
            <if test="operatePerson != null  and operatePerson != ''">operate_person,</if>
            <if test="testType != null  and testType != ''">test_type,</if>
            <if test="createTime != null">create_time,</if>
            <if test="isDeleted != null  and isDeleted != ''">is_deleted,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ids != null  and ids != ''">#{ids},</if>
            <if test="code != null  and code != ''">#{code},</if>
            <if test="projectId != null  and projectId != ''">#{projectId},</if>
            <if test="holeId != null  and holeId != ''">#{holeId},</if>
            <if test="type != null  and type != ''">#{type},</if>
            <if test="recordPerson != null  and recordPerson != ''">#{recordPerson},</if>
            <if test="operatePerson != null  and operatePerson != ''">#{operatePerson},</if>
            <if test="testType != null  and testType != ''">#{testType},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="isDeleted != null  and isDeleted != ''">#{isDeleted},</if>
         </trim>
    </insert>
 
    <insert id="insertHolePersonList" parameterType="java.util.List">
        insert into js_hole_person
            (ids,code, project_id, hole_id, type, record_person ,operate_person, test_type, create_time, is_deleted)
        VALUES
            <foreach collection="list" item="item" separator =",">
                (#{item.ids}, #{item.code}, #{item.projectId},#{item.holeId},#{item.type},#{item.recordPerson},#{item.operatePerson},#{item.testType},#{item.createTime},#{item.isDeleted})
            </foreach >
    </insert>
 
    <update id="updateHolePerson" parameterType="HolePerson">
        update js_hole_person
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null  and code != ''">code = #{code},</if>
            <if test="projectId != null  and projectId != ''">project_id = #{projectId},</if>
            <if test="holeId != null  and holeId != ''">hole_id = #{holeId},</if>
            <if test="type != null  and type != ''">type = #{type},</if>
            <if test="recordPerson != null  and recordPerson != ''">record_person = #{recordPerson},</if>
            <if test="operatePerson != null  and operatePerson != ''">operate_person = #{operatePerson},</if>
            <if test="testType != null  and testType != ''">test_type = #{testType},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="isDeleted != null  and isDeleted != ''">is_deleted = #{isDeleted},</if>
        </trim>
        where ids = #{ids}
    </update>
 
    <delete id="deleteHolePersonById" parameterType="String">
        delete from js_hole_person where ids = #{ids}
    </delete>
 
    <delete id="deleteHolePersonByIds" parameterType="String">
        delete from js_hole_person where ids in 
        <foreach item="ids" collection="array" open="(" separator="," close=")">
            #{ids}
        </foreach>
    </delete>
    
</mapper>