0 then "未完成" else "完成" end) coursefinish,
(case cc.jhly when "bmn" then "部门级计划内" when "bmw" then "部门级计划外" when "sj" then "院级" end) jhly,
cc.bjmc,
(case when cc.realteacher is not null and cc.realteacher!="" then "完成" else "未完成" end) classfinish,
cc.bjlb,
cc.addgroupname,
uc.jhrs,
cc.starttime,
cc.endtime,
cc.sfbfzs,
cc.pxxsh,
cc.pxxs,
cc.sfkh,
(case cc.sfkh when "是" then cc.khlx when "否" then "无" end) khlx,
(case cc.sfkh when "是" then cc.khfs when "否" then "无" end) khfs,
cc.teacher,
cc.realteacher,
cc.teacher_code,
cc.teacher_department,
cc.price,
(case cc.status when -1 then "被驳回" when 0 then "未开班" when 1 then "已下发" when 2 then "已开班" when 3 then "待审核" end) ccstatus,
pg.pgwjmc,
(case pg.status when 0 then "未发布" when 1 then "已发布" end) pgstatus,
ecc.name,
ecc.startdate,
ecc.enddate,
ecc.state,
fcc.title,
fcc.uploadtime
from et_train_pd_cc cc left join et_train_pd_cc_pg pg on cc.id=pg.ccid
left join et_train_pd_cc_pgwjyxx yxx on pg.id = yxx.pgID
left join (select kcmcid,count(*) nofinishcount from et_train_pd_cc where realteacher is null or realteacher="" group by kcmcid) tab1 on tab1.kcmcid=cc.kcmcid
left join (select exam.name,exam.startdate,exam.enddate,exam.state,class.class_id as c_id from et_exam_exampaper_and_editexampaper exam
inner join et_exam_limitation_class class on exam.id = class.exam_id group by exam.id
union all
select exam.name,exam.startdate,exam.enddate,exam.state,course.course_id as c_id from et_exam_exampaper_and_editexampaper exam
inner join et_exam_limitation_course course on exam.id = course.exam_id group by exam.id
) ecc on ecc.c_id = cc.id or ecc.c_id = cc.kcmcid
left join (
SELECT
file.title,
file.uploadtime,
course.course_id AS f_id
FROM
et_resource_file file
inner JOIN (select a.file_id,b.course_id from et_resource_limitation a left join et_resource_limitation_course b on a.id=b.limitation_id GROUP BY b.course_id) course on course.file_id = file.id
union all
SELECT
file.title,
file.uploadtime,
class.class_id AS f_id
FROM
et_resource_file file
inner JOIN (select a.file_id,b.class_id from et_resource_limitation a left join et_resource_limitation_class b on a.id=b.limitation_id GROUP BY b.class_id) class on class.file_id = file.id
) fcc on fcc.f_id = cc.id or fcc.f_id = cc.kcmcid
left join (select cc.id,count(*) jhrs FROM et_train_pd_cc cc left join et_train_pd_cc_user ccu on cc.id = ccu.ccid group by cc.id) uc on cc.id = uc.id
where 1=1
<@p p=" and cc.addgroupid = %s" f="?">addgroupid@p>
<@p p=" and cc.addusercode = %s" f="?">addusercode@p>
<@p p=" and (kcmc like ?">kcmc@p>
<@p p=" or bjmc like ?">bjmc@p>
<@p p=" or cc.addgroupname like ?">addgroupname@p>
<@p p=" or cc.teacher like ?">teacher@p>
<@p p=" or cc.realteacher like ?">realteacher@p>
<@p p=" or cc.teacher_code like ?">teacher_code@p>
<@p p=" or starttime like binary ?">starttime@p>
<@p p=" or endtime like binary ? )">endtime@p>
) a
]]>
addgroupid@p>
<@p p=" and cc.addusercode = %s" f="?">addusercode@p>
<@p p="AND (%s)" s="OR" f="%S LIKE ?">kcmc,bjmc,addgroupname@p>
<@p p="and starttime >= ?">startdate1@p>
<@p p="and starttime <= ?">startdate2@p>
<@p p="and endtime >= ?">enddate1@p>
<@p p="and endtime <= ?">enddate2@p>
order by convert(starttime using gbk) desc
]]>
addgroupid@p>
<@p p=" and cc.addusercode = %s" f="?">addusercode@p>
<@p p="AND (%s)" s="OR" f="%S LIKE ?">kcmc,bjmc@p>
]]>
addgroupid@p>
<@p p=" and tab1.addusercode = %s" f="?">addusercode@p>
<@p p="AND (%s)" s="OR" f="%S LIKE ?">kcmc,bjmc@p>
group by kcmcid,ccid,uid) tab11
group by kcmcid,ccid
order by kcmc,bjmc
]]>