SELECT
  plan.name as name,
  plan.code as planCode,
  times.servicetimestart as plandatestart,
  times.servicetimeend as plandateend,
  plan.servicetype as servicetypedetail
  ,plan.project_service_id as projectserviceid
  ,plan.project_service_name as  projectservicename
  ,plan.relatedunitid as  relatedunitid
 , plan.relatedunitname as relatedunitname,
  plan.remark as description,
  'plan' as sourcetype,
  plan.depart_id as projectid
  ,plan.dep_name as projectname
 , '3' as bpmStatus
,plan.id as maintain_plan_id
,times.id as maintain_plan_time_id
,plan.contract_id as contractid
,plan.contract_name  as contractname
,plan.create_name
FROM
  t_b_maintain_plan_times times
  LEFT JOIN t_b_maintain_plan plan ON times.maintainplanid = plan.id
where
 times.servicetimestart <= :createFirstDate
and times.is_gen_task ='0'
and plan.bpm_status='3'
and plan.contract_id is not null and  plan.contract_id<>''
