wuzeyu
2024-07-11 288fd4f39fae6bcd0a26cdbcbf0a17c3bd3a877d
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?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.dy.pipIrrGlobal.daoIr.IrIrrigateUnitMapper">
    <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoIr.IrIrrigateUnit">
        <!--@mbg.generated-->
        <!--@Table ir_irrigate_unit-->
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="project_id" jdbcType="BIGINT" property="projectId" />
        <result column="intake_id" jdbcType="BIGINT" property="intakeId" />
        <result column="area" jdbcType="FLOAT" property="area" />
        <result column="remarks" jdbcType="VARCHAR" property="remarks" />
        <result column="operator" jdbcType="BIGINT" property="operator" />
        <result column="operate_time" jdbcType="TIMESTAMP" property="operateDt" />
        <result column="deleted" jdbcType="TINYINT" property="deleted" />
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, project_id,intake_id, area, remarks, `operator`,
        operate_time, deleted
    </sql>
 
    <!--添加-->
    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateUnit">
        <!--@mbg.generated-->
        insert into ir_irrigate_unit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="projectId != null">
                project_id,
            </if>
            <if test="intakeId != null">
                intake_id,
            </if>
            <if test="area != null">
                area,
            </if>
            <if test="remarks != null">
                remarks,
            </if>
            <if test="operator != null">
                `operator`,
            </if>
            <if test="operateDt != null">
                operate_time,
            </if>
            <if test="deleted != null">
                deleted,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="projectId != null">
                #{projectId,jdbcType=BIGINT},
            </if>
            <if test="intakeId != null">
                #{intakeId,jdbcType=BIGINT},
            </if>
            <if test="area != null">
                #{area,jdbcType=FLOAT},
            </if>
            <if test="remarks != null">
                #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="operator != null">
                #{operator,jdbcType=BIGINT},
            </if>
            <if test="operateDt != null">
                #{operateDt,jdbcType=TIMESTAMP},
            </if>
            <if test="deleted != null">
                #{deleted,jdbcType=TINYINT},
            </if>
        </trim>
    </insert>
 
    <!--逻辑删除-->
    <delete id="deleteLogicById" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        update ir_irrigate_unit
        set deleted = 1
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <!--修改一个灌溉单元-->
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateUnit">
        update ir_irrigate_unit
        <set>
            <if test="projectId != null">
                project_id = #{projectId,jdbcType=BIGINT},
            </if>
            <if test="intakeId != null">
                intake_id = #{intakeId,jdbcType=BIGINT},
            </if>
            <if test="area != null">
                area = #{area,jdbcType=FLOAT},
            </if>
            <if test="remarks != null">
                remarks = #{remarks,jdbcType=VARCHAR},
            </if>
            <if test="operator != null">
                operator = #{operator,jdbcType=BIGINT},
            </if>
            <if test="operateDt != null">
                operate_time = #{operateDt,jdbcType=TIMESTAMP},
            </if>
            <if test="deleted != null">
                deleted = #{deleted,jdbcType=TINYINT},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <!--查一个灌溉单元-->
    <select id="selectById" resultType="com.dy.pipIrrGlobal.voIr.VoUnitOne">
        select
        CAST(pro.id AS char)AS projectId,
        pro.project_name  AS  projectName,
        CAST(intake.id AS char)AS intakeId,
        intake.name  AS  intakeName,
        CAST(uni.id AS char)AS id,
        CAST(uni.operator AS char)AS operator,
        cli.name         AS operatorName,
        gru.group_code         AS groupCode,
        uni.area,
        uni.remarks,
        uni.operate_time  AS  operateDt
        from ir_irrigate_unit uni
        left join pr_intake intake on intake.id = uni.intake_id
        left join ir_project pro on pro.id = uni.project_id
        left join se_client cli on cli.id = uni.operator
        left join ir_group_unit gu on gu.unit_id = uni.id
        left join ir_irrigate_group gru on gru.id = gu.group_id
        where uni.id = #{id,jdbcType=BIGINT} and uni.deleted = 0
    </select>
    <!--分页查灌溉单元-->
    <select id="getUnits" resultType="com.dy.pipIrrGlobal.voIr.VoUnit">
        SELECT
        CAST(pro.id AS char)AS projectId,
        pro.project_name  AS  projectName,
        CAST(intake.id AS char)AS intakeId,
        intake.name  AS  intakeName,
        CAST(uni.id AS char)AS unitId,
        CAST(uni.operator AS char)AS operator,
        cli.name         AS operatorName,
        gru.group_code         AS groupCode,
        uni.area,
        uni.remarks,
        uni.operate_time  AS  operateDt
        FROM ir_irrigate_unit uni
        left join pr_intake intake on intake.id = uni.intake_id
        left join ir_project pro on pro.id = uni.project_id
        left join se_client cli on cli.id = uni.operator
        left join ir_group_unit gu on gu.unit_id = uni.id
        left join ir_irrigate_group gru on gru.id = gu.group_id
        <where>
            uni.deleted = 0
            <if test="projectName != null and projectName != ''">
                AND pro.project_name LIKE CONCAT('%', #{projectName}, '%')
            </if>
            <if test = "groupCode != null and groupCode != ''">
                AND gru.group_code = #{groupCode}
            </if>
        </where>
        ORDER BY uni.operate_time DESC
        <if test="pageCurr != null and pageSize != null">
            LIMIT ${(pageCurr-1)*pageSize}, ${pageSize}
        </if>
    </select>
    <!--分页查灌溉单元记录数-->
    <select id="getRecordCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM ir_irrigate_unit uni
        left join pr_intake intake on intake.id = uni.intake_id
        left join ir_project pro on pro.id = uni.project_id
        left join se_client cli on cli.id = uni.operator
        left join ir_group_unit gu on gu.unit_id = uni.id
        left join ir_irrigate_group gru on gru.id = gu.group_id
        <where>
            uni.deleted = 0
            <if test="projectName != null and projectName != ''">
                AND pro.project_name LIKE CONCAT('%', #{projectName}, '%')
            </if>
                        <if test = "groupCode != null and groupCode != ''">
                            AND gru.group_code = #{groupCode}
                        </if>
        </where>
    </select>
</mapper>