zhubaomin
2025-04-15 70b2c7a1f5b54cf9157d8fce4d6a9b0f2fadaebe
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
191
192
193
194
195
196
197
198
199
200
<?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.IrIntakeOperateMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate">
    <!--@mbg.generated-->
    <!--@Table ir_intake_operate-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="plan_id" jdbcType="BIGINT" property="planId" />
    <result column="operate_type" jdbcType="TINYINT" property="operateType" />
    <result column="command_id" jdbcType="BIGINT" property="commandId" />
    <result column="intake_id" jdbcType="BIGINT" property="intakeId" />
    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
    <result column="duration" jdbcType="INTEGER" property="duration" />
    <result column="command_result" jdbcType="TINYINT" property="commandResult" />
    <result column="failure_factors" jdbcType="VARCHAR" property="failureFactors" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, plan_id, operate_type, command_id, intake_id, start_time, duration, command_result, 
    failure_factors
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from ir_intake_operate
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ir_intake_operate
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate">
    <!--@mbg.generated-->
    insert into ir_intake_operate (id, plan_id, operate_type, 
      command_id, intake_id, start_time, 
      duration, command_result, failure_factors
      )
    values (#{id,jdbcType=BIGINT}, #{planId,jdbcType=BIGINT}, #{operateType,jdbcType=TINYINT}, 
      #{commandId,jdbcType=BIGINT}, #{intakeId,jdbcType=BIGINT}, #{startTime,jdbcType=TIMESTAMP}, 
      #{duration,jdbcType=INTEGER}, #{commandResult,jdbcType=TINYINT}, #{failureFactors,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate">
    <!--@mbg.generated-->
    insert into ir_intake_operate
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="planId != null">
        plan_id,
      </if>
      <if test="operateType != null">
        operate_type,
      </if>
      <if test="commandId != null">
        command_id,
      </if>
      <if test="intakeId != null">
        intake_id,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="duration != null">
        duration,
      </if>
      <if test="commandResult != null">
        command_result,
      </if>
      <if test="failureFactors != null">
        failure_factors,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="planId != null">
        #{planId,jdbcType=BIGINT},
      </if>
      <if test="operateType != null">
        #{operateType,jdbcType=TINYINT},
      </if>
      <if test="commandId != null">
        #{commandId,jdbcType=BIGINT},
      </if>
      <if test="intakeId != null">
        #{intakeId,jdbcType=BIGINT},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="duration != null">
        #{duration,jdbcType=INTEGER},
      </if>
      <if test="commandResult != null">
        #{commandResult,jdbcType=TINYINT},
      </if>
      <if test="failureFactors != null">
        #{failureFactors,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate">
    <!--@mbg.generated-->
    update ir_intake_operate
    <set>
      <if test="planId != null">
        plan_id = #{planId,jdbcType=BIGINT},
      </if>
      <if test="operateType != null">
        operate_type = #{operateType,jdbcType=TINYINT},
      </if>
      <if test="commandId != null">
        command_id = #{commandId,jdbcType=BIGINT},
      </if>
      <if test="intakeId != null">
        intake_id = #{intakeId,jdbcType=BIGINT},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="duration != null">
        duration = #{duration,jdbcType=INTEGER},
      </if>
      <if test="commandResult != null">
        command_result = #{commandResult,jdbcType=TINYINT},
      </if>
      <if test="failureFactors != null">
        failure_factors = #{failureFactors,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIntakeOperate">
    <!--@mbg.generated-->
    update ir_intake_operate
    set plan_id = #{planId,jdbcType=BIGINT},
      operate_type = #{operateType,jdbcType=TINYINT},
      command_id = #{commandId,jdbcType=BIGINT},
      intake_id = #{intakeId,jdbcType=BIGINT},
      start_time = #{startTime,jdbcType=TIMESTAMP},
      duration = #{duration,jdbcType=INTEGER},
      command_result = #{commandResult,jdbcType=TINYINT},
      failure_factors = #{failureFactors,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
 
  <!--根据命令ID更新取水口操作记录-->
  <update id="updateByCommandId" >
    update ir_intake_operate
    set command_result = #{commandResult}, failure_factors = #{failureFactors}
    where command_id = #{commandId}
  </update>
 
  <!--根据计划ID获取待终止的取水口ID(已发布开发命令,无论是否成功)-->
  <select id="getToTerminateIntakeIds" resultType="java.lang.Long">
    SELECT
      intake_id AS intakeId
    FROM ir_intake_operate
    WHERE operate_type = 1 AND plan_id = #{planId}
  </select>
 
  <!--根据计划ID获取待终止的命令ID-->
  <select id="getTerminateCommandIds" resultType="java.lang.Long">
    SELECT command_id AS commandId FROM ir_intake_operate WHERE operate_type = 1 AND plan_id = #{planId}
  </select>
 
  <!--根据计划ID获取待终止的取水口列表(开阀成功的)-->
  <select id="getToTerminateIntakes" resultType="com.dy.pipIrrGlobal.voIr.VoToTerminateIntakes">
    SELECT
      command_id AS commandId,
      intake_id AS intakeId,
      start_time AS startTime
    FROM ir_intake_operate
    WHERE operate_type = 1 AND command_result = 1 AND plan_id = #{planId}
  </select>
 
  <!--根据计划ID及管轮组ID获取取水口发布发布结果-->
  <select id="getIntakeResult" resultType="com.dy.pipIrrGlobal.voIr.VoIntakeResult">
    SELECT
        IF(io.command_result = 1, 0, 1) AS code,
        (SELECT name FROM pr_intake WHERE id = io.intake_id) AS intakeName,
        io.failure_factors AS result
    FROM ir_intake_operate io
        inner JOIN ir_group_intake gi ON gi.intake_id = io.intake_id
    WHERE io.plan_id = #{planId} AND gi.group_id = #{groupId} AND operate_type = 1;
  </select>
 
  <!--根据计划ID获取取水口命令发布失败数量,灌溉计划详情页使用-->
  <select id="getFailureCount" resultType="java.lang.Integer">
    SELECT
      COUNT(1) AS failureCount
    FROM ir_intake_operate
    WHERE operate_type = 1 AND command_result != 1 AND plan_id = #{planId}
  </select>
</mapper>