|  |  | 
 |  |  |     FROM pr_intake_controller | 
 |  |  |     <where> | 
 |  |  |       <if test = "intakeId != null and intakeId > 0"> | 
 |  |  |         AND intakeId = ${intakeId} | 
 |  |  |         AND intakeId = #{intakeId,jdbcType=BIGINT} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "controllerId != null and controllerId > 0"> | 
 |  |  |         AND controllerId = ${controllerId} | 
 |  |  |         AND controllerId = #{controllerId,jdbcType=BIGINT} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "operateType != null and operateType > 0"> | 
 |  |  |         AND operateType = ${operateType} | 
 |  |  |         AND operateType = #{operateType,jdbcType=BIGINT} | 
 |  |  |       </if> | 
 |  |  |     </where> | 
 |  |  |   </select> | 
 |  |  | 
 |  |  |   <select id="getBindsByIntakeId" resultType="java.util.Map"> | 
 |  |  |     SELECT | 
 |  |  |         user.name AS userName, | 
 |  |  |         con.code AS controllerCode, | 
 |  |  |         <!--con.code AS controllerCode,--> | 
 |  |  |         con.rtuAddr, | 
 |  |  |         (CASE | 
 |  |  |             WHEN ic.operateType = 1 THEN "绑定" | 
 |  |  |             WHEN ic.operateType = 2 THEN "解绑" | 
 |  |  |             WHEN ic.operateType = 1 THEN '绑定' | 
 |  |  |             WHEN ic.operateType = 2 THEN '解绑' | 
 |  |  |         END) AS operateType, | 
 |  |  |         ic.operateDt | 
 |  |  |     FROM pr_intake inta | 
 |  |  |         INNER JOIN pr_intake_controller ic ON inta.id= ic.intakeId | 
 |  |  |         INNER JOIN ba_user user ON ic.operator = user.id | 
 |  |  |         INNER JOIN pr_controller con ON ic.controllerId = con.id | 
 |  |  |     <if test = "intakeId != null and intakeId > 0"> | 
 |  |  |       AND inta.id = ${intakeId} | 
 |  |  |     <if test = "intakeId != null"> | 
 |  |  |       AND inta.id = #{intakeId,jdbcType=BIGINT} | 
 |  |  |     </if> | 
 |  |  |     ORDER BY ic.operateDt DESC | 
 |  |  |   </select> | 
 |  |  | 
 |  |  |   <select id="getBindsByControllerId" resultType="java.util.Map"> | 
 |  |  |     SELECT | 
 |  |  |         (CASE | 
 |  |  |             WHEN ic.operateType = 1 THEN "绑定" | 
 |  |  |             WHEN ic.operateType = 2 THEN "解绑" | 
 |  |  |             WHEN ic.operateType = 1 THEN '绑定' | 
 |  |  |             WHEN ic.operateType = 2 THEN '解绑' | 
 |  |  |         END) AS operateType, | 
 |  |  |         inta.name AS intakeName, | 
 |  |  |         user.name AS userName, | 
 |  |  | 
 |  |  |         INNER JOIN pr_intake_controller ic ON ic.controllerId = con.id | 
 |  |  |         INNER JOIN pr_intake inta ON ic.intakeId = inta.id | 
 |  |  |         INNER JOIN ba_user user ON ic.operator = user.id | 
 |  |  |     <if test = "controllerId != null and controllerId > 0"> | 
 |  |  |       AND con.id = ${controllerId} | 
 |  |  |     <if test = "controllerId != null"> | 
 |  |  |       AND con.id = #{controllerId,jdbcType=BIGINT} | 
 |  |  |     </if> | 
 |  |  |     ORDER BY ic.operateDt DESC | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |  | 
 |  |  |   <!--根据取水口编号修改绑定记录列表--> | 
 |  |  |   <update id="updateByIntakeSelective"> | 
 |  |  |     update pr_intake_controller | 
 |  |  |     <set> | 
 |  |  |       <if test="controllerid != null"> | 
 |  |  |         controllerId = #{controllerid,jdbcType=BIGINT}, | 
 |  |  |       </if> | 
 |  |  |       <if test="operatetype != null"> | 
 |  |  |         operateType = #{operatetype,jdbcType=TINYINT}, | 
 |  |  |       </if> | 
 |  |  |       <if test="remarks != null"> | 
 |  |  |         remarks = #{remarks,jdbcType=VARCHAR}, | 
 |  |  |       </if> | 
 |  |  |       <if test="operator != null"> | 
 |  |  |         `operator` = #{operator,jdbcType=BIGINT}, | 
 |  |  |       </if> | 
 |  |  |       <if test="operatedt != null"> | 
 |  |  |         operateDt = #{operatedt,jdbcType=TIMESTAMP}, | 
 |  |  |       </if> | 
 |  |  |     </set> | 
 |  |  |     where intakeId = #{intakeid,jdbcType=BIGINT} | 
 |  |  |   </update> | 
 |  |  | </mapper> |