|  |  |  | 
|---|
|  |  |  | FROM ir_irrigate_schedule sche | 
|---|
|  |  |  | INNER JOIN ir_plan_schedule ps ON schedule_id = sche.id | 
|---|
|  |  |  | WHERE ps.plan_id = #{planId} | 
|---|
|  |  |  | LIMIT 1 | 
|---|
|  |  |  | <!--        LIMIT 1--> | 
|---|
|  |  |  | ) AS has_intersection | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--判断当前计划与最近终止的计划的轮灌组是否有重叠 --> | 
|---|
|  |  |  | <select id="hasPlanOverlapWithTerminated" resultType="java.lang.Integer"> | 
|---|
|  |  |  | SELECT COUNT(1) | 
|---|
|  |  |  | FROM ( | 
|---|
|  |  |  | SELECT sche1.group_id | 
|---|
|  |  |  | FROM ir_plan_schedule ps1 | 
|---|
|  |  |  | INNER JOIN ir_irrigate_schedule sche1 ON ps1.schedule_id = sche1.id | 
|---|
|  |  |  | WHERE ps1.plan_id = #{planId} | 
|---|
|  |  |  | ) AS current_groups | 
|---|
|  |  |  | INNER JOIN ( | 
|---|
|  |  |  | SELECT sche2.group_id | 
|---|
|  |  |  | FROM ir_plan_schedule ps2 | 
|---|
|  |  |  | INNER JOIN ir_irrigate_schedule sche2 ON ps2.schedule_id = sche2.id | 
|---|
|  |  |  | WHERE ps2.plan_id = #{terminatedPlanId} | 
|---|
|  |  |  | ) AS terminated_groups | 
|---|
|  |  |  | ON current_groups.group_id = terminated_groups.group_id | 
|---|
|  |  |  | LIMIT 1 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--根据计划ID获取计划最新状态--> | 
|---|
|  |  |  | <select id="getPlanLatestState" resultType="java.lang.Integer"> | 
|---|
|  |  |  | SELECT | 
|---|