|  |  |  | 
|---|
|  |  |  | ) AS planState | 
|---|
|  |  |  | FROM ir_irrigate_plan plan | 
|---|
|  |  |  | INNER JOIN ir_project pro ON pro.id = plan.project_id | 
|---|
|  |  |  | WHERE plan.deleted = 0 AND (plan.plan_state = 1 OR NOW() < plan.plan_stop_time) | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | AND plan.deleted = 0 | 
|---|
|  |  |  | AND (plan.plan_state = 1 OR NOW() < plan.plan_stop_time) | 
|---|
|  |  |  | AND plan.executing_state != 3 | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | ORDER BY plan.plan_state DESC | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | plan.plan_start_time AS planStartTime, | 
|---|
|  |  |  | plan.plan_stop_time AS planStopTime, | 
|---|
|  |  |  | plan.duration, | 
|---|
|  |  |  | IF(plan.plan_state = 1, 1, | 
|---|
|  |  |  | IF(NOW() < plan.plan_start_time, 2, | 
|---|
|  |  |  | IF(NOW() >= plan.plan_start_time AND NOW() < plan.plan_stop_time, 3, 4) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) AS planState | 
|---|
|  |  |  | IF(plan.executing_state = 3, 5, 4) AS planState | 
|---|
|  |  |  | FROM ir_irrigate_plan plan | 
|---|
|  |  |  | INNER JOIN ir_project pro ON pro.id = plan.project_id | 
|---|
|  |  |  | WHERE plan.deleted = 0 AND (plan.plan_state = 2 AND NOW() >= plan.plan_stop_time) | 
|---|
|  |  |  | WHERE plan.deleted = 0 AND ((plan.plan_state = 2 AND NOW() >= plan.plan_stop_time) OR (plan.executing_state = 3)) | 
|---|
|  |  |  | ORDER BY plan.plan_state DESC | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|