YNICTE/Dao/MyBatis/Maps/Grade.xml

1846 lines
128 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<sqlMap xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/tr/xmlschema-1/" namespace="">
<alias>
</alias>
<cacheModels>
<cacheModel id="gradeCache" implementation="LRU" >
<flushInterval hours="1" />
<property name="CacheSize" value="1000" />
</cacheModel>
</cacheModels>
<resultMaps></resultMaps>
<statements>
<sql id="grade.query">
select a.lectno
,(b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100) * 100 apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,(a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100) * 100 mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,(a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100) * 100 fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,(a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100) * 100 spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,(a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100) * 100 dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,(case when (case when b.isrebate=1 then d.attendcutrfd else d.attendcut end) &lt;= b.attrate then 1 else 0 end) ispassa
,(case when (case when b.isrebate=1 then d.midcutrfd else d.midcut end) &lt;= a.ex0lectpoint then 1 else 0 end) ispassm
,(case when (case when b.isrebate=1 then d.finalcutrfd else d.finalcut end) &lt;= a.ex1lectpoint then 1 else 0 end) ispassf
,(case when (case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end) &lt;= a.sd0lectpoint then 1 else 0 end) ispasss
,(case when (case when b.isrebate=1 then d.discusscutrfd else d.discusscut end) &lt;= a.sd1lectpoint then 1 else 0 end) ispassd
,(case when (case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end) &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end) ispassat
,(case when
(case when (case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end) &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end) = 1 and
(case when (case when b.isrebate=1 then d.attendcutrfd else d.attendcut end) &lt;= b.attrate then 1 else 0 end) =1 and
(case when (case when b.isrebate=1 then d.midcutrfd else d.midcut end) &lt;= a.ex0lectpoint then 1 else 0 end) =1 and
(case when (case when b.isrebate=1 then d.finalcutrfd else d.finalcut end) &lt;= a.ex1lectpoint then 1 else 0 end) =1 and
(case when (case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end) &lt;= a.sd0lectpoint then 1 else 0 end) =1 and
(case when (case when b.isrebate=1 then d.discusscutrfd else d.discusscut end) &lt;= a.sd1lectpoint then 1 else 0 end) =1 and
(case when (case when b.isrebate=1 then d.cutrfd else d.cut end) &lt;=
((b.attrate / 100) * ((case when b.isrebate=1 then d.attendrfd else d.attend end) / 100 * 100))
+((a.ex0lectpoint / 100) * ((case when b.isrebate=1 then d.midrfd else d.mid end) / 100)* 100)
+((a.ex1lectpoint / 100) * ((case when b.isrebate=1 then d.finalrfd else d.final end) / 100)* 100)
+((a.sd0lectpoint / 100) * ((case when b.isrebate=1 then d.subjectrfd else d.subject end) / 100)* 100)
+((a.sd1lectpoint / 100) * ((case when b.isrebate=1 then d.discussrfd else d.discuss end) / 100)* 100) then 1 else 0 end) = 1 then 1 else 0 end) ispass
from (
select a.lectno
,sum(ex0cnt) ex0cnt,sum(ex0lectcnt) ex0lectcnt,sum(ex0lectpoint) ex0lectpoint
,sum(ex1cnt) ex1cnt,sum(ex1lectcnt) ex1lectcnt,sum(ex1lectpoint) ex1lectpoint
,sum(sd0cnt) sd0cnt,sum(sd0lectcnt) sd0lectcnt,sum(sd0lectpoint) sd0lectpoint
,sum(sd1cnt) sd1cnt,sum(sd1lectcnt) sd1lectcnt,sum(sd1lectpoint) sd1lectpoint
,sum(rs0cnt) rs0cnt,sum(rs0lectcnt) rs0lectcnt,sum(rs0lectpoint) rs0lectpoint
,sum(at0cnt) at0cnt,sum(at0lectcnt) at0lectcnt
from (
select a.lectno
,count(b.exno) ex0cnt,count(c.lectno) ex0lectcnt,avg(ifnull(c.tpoint,0) / b.tpoint * 100) ex0lectpoint
,0 ex1cnt,0 ex1lectcnt,0 ex1lectpoint
,0 sd0cnt,0 sd0lectcnt,0 sd0lectpoint
,0 sd1cnt,0 sd1lectcnt,0 sd1lectpoint
,0 rs0cnt,0 rs0lectcnt,0 rs0lectpoint
,0 at0cnt,0 at0lectcnt
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
<isNotNull property="lectno">and b.lectno=#lectno#</isNotNull>
<isNotNull property="userno">and b.userno=#userno#</isNotNull>
<isNotNull property="attrateunder">and b.attrate &lt;= #attrateunder#</isNotNull>
<isNotNull property="isrebate">and b.isrebate=#isrebate#</isNotNull>
<isNotNull property="lectnos">and b.lectno in ($lectnos$)</isNotNull>
inner join users c on c.userno=b.userno and c.status=1
<isNotNull property="userid">and c.userid=#userid#</isNotNull>
<isNotNull property="username">and c.username=#username#</isNotNull>
where a.ismaster=0
<isNotNull property="cgno">and a.cgno=#cgno#</isNotNull>
<isNotNull property="tmno">and a.tmno=#tmno#</isNotNull>
<isNotNull property="cmno">and a.cmno=#cmno#</isNotNull>
<isNotNull property="cmnos">and a.cmno in ($cmnos$)</isNotNull>
<isNotNull property="cshapes">and a.cshape in ($cshapes$)</isNotNull>
and <!--a.isuse=1 and--> a.isdel=0
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=0 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,count(b.exno),count(c.lectno),avg(ifnull(c.tpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
<isNotNull property="lectno">and b.lectno=#lectno#</isNotNull>
<isNotNull property="userno">and b.userno=#userno#</isNotNull>
<isNotNull property="attrateunder">and b.attrate &lt;= #attrateunder#</isNotNull>
<isNotNull property="isrebate">and b.isrebate=#isrebate#</isNotNull>
<isNotNull property="lectnos">and b.lectno in ($lectnos$)</isNotNull>
inner join users c on c.userno=b.userno and c.status=1
<isNotNull property="userid">and c.userid=#userid#</isNotNull>
<isNotNull property="username">and c.username=#username#</isNotNull>
where a.ismaster=0
<isNotNull property="cgno">and a.cgno=#cgno#</isNotNull>
<isNotNull property="tmno">and a.tmno=#tmno#</isNotNull>
<isNotNull property="cmno">and a.cmno=#cmno#</isNotNull>
<isNotNull property="cmnos">and a.cmno in ($cmnos$)</isNotNull>
<isNotNull property="cshapes">and a.cshape in ($cshapes$)</isNotNull>
<!--and a.isuse=1--> and a.isdel=0
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=1 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
<isNotNull property="lectno">and b.lectno=#lectno#</isNotNull>
<isNotNull property="userno">and b.userno=#userno#</isNotNull>
<isNotNull property="attrateunder">and b.attrate &lt;= #attrateunder#</isNotNull>
<isNotNull property="isrebate">and b.isrebate=#isrebate#</isNotNull>
<isNotNull property="lectnos">and b.lectno in ($lectnos$)</isNotNull>
inner join users c on c.userno=b.userno and c.status=1
<isNotNull property="userid">and c.userid=#userid#</isNotNull>
<isNotNull property="username">and c.username=#username#</isNotNull>
where a.ismaster=0
<isNotNull property="cgno">and a.cgno=#cgno#</isNotNull>
<isNotNull property="tmno">and a.tmno=#tmno#</isNotNull>
<isNotNull property="cmno">and a.cmno=#cmno#</isNotNull>
<isNotNull property="cmnos">and a.cmno in ($cmnos$)</isNotNull>
<isNotNull property="cshapes">and a.cshape in ($cshapes$)</isNotNull>
<!--and a.isuse=1--> and a.isdel=0
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
<isNotNull property="lectno">and b.lectno=#lectno#</isNotNull>
<isNotNull property="userno">and b.userno=#userno#</isNotNull>
<isNotNull property="attrateunder">and b.attrate &lt;= #attrateunder#</isNotNull>
<isNotNull property="isrebate">and b.isrebate=#isrebate#</isNotNull>
<isNotNull property="lectnos">and b.lectno in ($lectnos$)</isNotNull>
inner join users c on c.userno=b.userno and c.status=1
<isNotNull property="userid">and c.userid=#userid#</isNotNull>
<isNotNull property="username">and c.username=#username#</isNotNull>
where a.ismaster=0
<isNotNull property="cgno">and a.cgno=#cgno#</isNotNull>
<isNotNull property="tmno">and a.tmno=#tmno#</isNotNull>
<isNotNull property="cmno">and a.cmno=#cmno#</isNotNull>
<isNotNull property="cmnos">and a.cmno in ($cmnos$)</isNotNull>
<isNotNull property="cshapes">and a.cshape in ($cshapes$)</isNotNull>
<!--and a.isuse=1--> and a.isdel=0
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.rsno),count(c.lectno),0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
<isNotNull property="lectno">and b.lectno=#lectno#</isNotNull>
<isNotNull property="userno">and b.userno=#userno#</isNotNull>
<isNotNull property="attrateunder">and b.attrate &lt;= #attrateunder#</isNotNull>
<isNotNull property="isrebate">and b.isrebate=#isrebate#</isNotNull>
<isNotNull property="lectnos">and b.lectno in ($lectnos$)</isNotNull>
inner join users c on c.userno=b.userno and c.status=1
<isNotNull property="userid">and c.userid=#userid#</isNotNull>
<isNotNull property="username">and c.username=#username#</isNotNull>
where a.ismaster=0
<isNotNull property="cgno">and a.cgno=#cgno#</isNotNull>
<isNotNull property="tmno">and a.tmno=#tmno#</isNotNull>
<isNotNull property="cmno">and a.cmno=#cmno#</isNotNull>
<isNotNull property="cmnos">and a.cmno in ($cmnos$)</isNotNull>
<isNotNull property="cshapes">and a.cshape in ($cshapes$)</isNotNull>
<!--and a.isuse=1--> and a.isdel=0
) a
left outer join cmrs b on b.cmno=a.cmno and b.rstype=0 and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.cmino),count(c.lectno)
from (
select b.lectno,a.cmno
from cm a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
<isNotNull property="lectno">and b.lectno=#lectno#</isNotNull>
<isNotNull property="userno">and b.userno=#userno#</isNotNull>
<isNotNull property="attrateunder">and b.attrate &lt;= #attrateunder#</isNotNull>
<isNotNull property="isrebate">and b.isrebate=#isrebate#</isNotNull>
<isNotNull property="lectnos">and b.lectno in ($lectnos$)</isNotNull>
inner join users c on c.userno=b.userno and c.status=1
<isNotNull property="userid">and c.userid=#userid#</isNotNull>
<isNotNull property="username">and c.username=#username#</isNotNull>
where a.ismaster=0
<isNotNull property="cgno">and a.cgno=#cgno#</isNotNull>
<isNotNull property="tmno">and a.tmno=#tmno#</isNotNull>
<isNotNull property="cmno">and a.cmno=#cmno#</isNotNull>
<isNotNull property="cmnos">and a.cmno in ($cmnos$)</isNotNull>
<isNotNull property="cshapes">and a.cshape in ($cshapes$)</isNotNull>
<!--and a.isuse=1--> and a.isdel=0
) a
left outer join cminning b on b.cmno=a.cmno and b.isonline =0 and b.isscd = 1
left outer join lectinning c on c.cmino=b.cmino and c.lectno = a.lectno and c.istatus = 2
group by a.lectno
) a
group by a.lectno
) a
inner join lect b on b.lectno=a.lectno
inner join cmev d on d.cmno=b.cmno
</sql>
<select id="grade.lectgrades_old" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,b.userno,b.payno
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">c.cname,c.cmno,u.username</isNull> ) rno
,count(a.lectno) over() pagetotalcount
,b.isrebate
,case when ppl.asname is not null then ppl.asname else ua.asname end asname
,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association
,CAST(AES_DECRYPT(UNHEX(ppl.mphone), <include refid="sql.digest"></include>) AS char) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), <include refid="sql.digest"></include>) AS char) taxemail
,u.username,u.userid,u.slevel,u.uduty
,b.iscomplete,b.completetime,b.completeno,b.sdate,b.edate
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,b.cmisno
,p.payoktime,p.payamt
,c.cshape,c.sstime,c.cmno,c.cname,c.classno,c.studytime
,t.tyear
,cg.cgname,cg.pcgno,pcg.cgname as pcgname
,d.isoffabs
,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,a.ispassat
,e.sseq,e.estart,e.eend,e.studyplace
,f.istatus
,cc.cname studyplacename
,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname
,date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') edatestring
,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), <include refid="sql.digest"></include>) AS char) as rbankaccnum
from (
<include refid="grade.query"></include>
) a
inner join lect b on b.lectno=a.lectno
inner join pay p on p.payno=b.payno
inner join users u on u.userno=b.userno <isNotNull property="ustatus">and u.status=#ustatus#</isNotNull>
left outer join assign ua on ua.asno=u.asno
inner join cm c on c.cmno=b.cmno
inner join cm c2 on c2.cmno=c.pcmno
inner join cmev d on d.cmno=c.cmno
left outer join term t on t.tmno = c.tmno
left outer join cg cg on cg.cgno = c.cgno
left outer join cg pcg on pcg.cgno = cg.pcgno
left outer join payitem pi on pi.payno = p.payno
left outer join cminningscd e on e.cmisno = b.cmisno
left outer join lectinning f on f.lectno = b.lectno and f.cmino = e.cmino
left outer join comcode cc on cc.ccode = e.studyplace and cc.isuse=1
left outer join pplog ppl on ppl.pplno = p.pplno
left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob
<dynamic prepend="where">
<isNotNull property="cshape" prepend="and">c.cshape = #cshape#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="est1not" prepend="and">a.ex0lectcnt &lt; a.ex0cnt</isNotNull>
<isNotNull property="est2not" prepend="and">a.ex1lectcnt &lt; a.ex1cnt</isNotNull>
<isNotNull property="est11not" prepend="and">a.sd0lectcnt &lt; a.sd0cnt</isNotNull>
<isNotNull property="est12not" prepend="and">a.sd1lectcnt &lt; a.sd1cnt</isNotNull>
<isNotNull property="est21not" prepend="and">a.rs0lectcnt &lt; a.rs0cnt</isNotNull>
<isNotNull property="cname" prepend="and">c2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotNull property="cnamestr" prepend="and">c.cname like concat('%',#cnamestr#,'%')</isNotNull>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull>
<isNotNull property="ispasss" prepend="and">((a.sd0cnt &gt; 0 and a.sd0lectcnt &gt; 0))</isNotNull>
<isNotNull property="ispassa" prepend="and">a.ispassa = #ispassa#</isNotNull>
<isNotNull property="ispassex" prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNull property="usernamestr" prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmpty property="sdateall" prepend="and">(case when c.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when c.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="asname" prepend="and">ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="edate" prepend="and">date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="mobile" prepend="and">cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotNull>
</dynamic>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="grade.lectgrades" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,b.userno,b.payno
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">c.cname,c.cmno,u.username</isNull> ) rno
,count(a.lectno) over() pagetotalcount
,b.isrebate
,case when ppl.asname is not null then ppl.asname else ua.asname end asname
,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association
,CAST(AES_DECRYPT(UNHEX(ppl.mphone), <include refid="sql.digest"></include>) AS char) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), <include refid="sql.digest"></include>) AS char) taxemail
,u.username,u.userid,u.slevel,u.uduty
,b.iscomplete,b.completetime,b.completeno,b.sdate,b.edate
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,b.cmisno
,p.payoktime,p.payamt
,c.cshape,c.sstime,c.cmno,c.cname,c.classno,c.studytime
,t.tyear
,cg.cgname,cg.pcgno,pcg.cgname as pcgname
,d.isoffabs
,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,a.ispassat
,e.sseq,e.estart,e.eend,e.studyplace
,f.istatus
,cc.cname studyplacename
,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname
,date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') edatestring
,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), <include refid="sql.digest"></include>) AS char) as rbankaccnum
from (
select a.lectno
,(b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100) * 100 apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,(a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100) * 100 mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,(a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100) * 100 fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,(a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100) * 100 spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,(a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100) * 100 dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end &lt;= b.attrate then 1 else 0 end ispassa
,case when case when b.isrebate=1 then d.midcutrfd else d.midcut end &lt;= a.ex0lectpoint then 1 else 0 end ispassm
,case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end &lt;= a.ex1lectpoint then 1 else 0 end ispassf
,case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end &lt;= a.sd0lectpoint then 1 else 0 end ispasss
,case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end &lt;= a.sd1lectpoint then 1 else 0 end ispassd
,case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end ispassat
,case when
case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end = 1 and
case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end &lt;= b.attrate then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.midcutrfd else d.midcut end &lt;= a.ex0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end &lt;= a.ex1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end &lt;= a.sd0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end &lt;= a.sd1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.cutrfd else d.cut end &lt;=
((b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100 * 100))
+((a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100)* 100)
+((a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100)* 100)
+((a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100)* 100)
+((a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100)* 100) then 1 else 0 end = 1 then 1 else 0 end ispass
from (
select a.lectno
,sum(ex0cnt) ex0cnt,sum(ex0lectcnt) ex0lectcnt,sum(ex0lectpoint) ex0lectpoint
,sum(ex1cnt) ex1cnt,sum(ex1lectcnt) ex1lectcnt,sum(ex1lectpoint) ex1lectpoint
,sum(sd0cnt) sd0cnt,sum(sd0lectcnt) sd0lectcnt,sum(sd0lectpoint) sd0lectpoint
,sum(sd1cnt) sd1cnt,sum(sd1lectcnt) sd1lectcnt,sum(sd1lectpoint) sd1lectpoint
,sum(rs0cnt) rs0cnt,sum(rs0lectcnt) rs0lectcnt,sum(rs0lectpoint) rs0lectpoint
,sum(at0cnt) at0cnt,sum(at0lectcnt) at0lectcnt
from (
select a.lectno
,count(b.exno) ex0cnt,count(c.lectno) ex0lectcnt,avg(ifnull(c.tpoint,0) / b.tpoint * 100) ex0lectpoint
,0 ex1cnt,0 ex1lectcnt,0 ex1lectpoint
,0 sd0cnt,0 sd0lectcnt,0 sd0lectpoint
,0 sd1cnt,0 sd1lectcnt,0 sd1lectpoint
,0 rs0cnt,0 rs0lectcnt,0 rs0lectpoint
,0 at0cnt,0 at0lectcnt
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr">and c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=0 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,count(b.exno),count(c.lectno),avg(ifnull(c.tpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr">and c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=1 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr">and c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr">and c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.rsno),count(c.lectno),0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr">and c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmrs b on b.cmno=a.cmno and b.rstype=0 and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.cmino),count(c.lectno)
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr">and c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cminning b on b.cmno=a.cmno and b.isonline =0 and b.isscd = 1
left outer join lectinning c on c.cmino=b.cmino and c.lectno = a.lectno and c.istatus = 2
group by a.lectno
) a
group by a.lectno
) a
inner join lect b on b.lectno=a.lectno
inner join cmev d on d.cmno=b.cmno
) a
inner join lect b on b.lectno=a.lectno
inner join pay p on p.payno=b.payno
inner join users u on u.userno=b.userno
left outer join assign ua on ua.asno=u.asno
inner join cm c on c.cmno=b.cmno
inner join cm c2 on c2.cmno=c.pcmno
inner join cmev d on d.cmno=c.cmno
left outer join term t on t.tmno = c.tmno
left outer join cg cg on cg.cgno = c.cgno
left outer join cg pcg on pcg.cgno = cg.pcgno
left outer join payitem pi on pi.payno = p.payno
left outer join cminningscd e on e.cmisno = b.cmisno
left outer join lectinning f on f.lectno = b.lectno and f.cmino = e.cmino
left outer join comcode cc on cc.ccode = e.studyplace and cc.isuse=1
left outer join pplog ppl on ppl.pplno = p.pplno
left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob
<dynamic prepend="where">
<isNotNull property="cshape" prepend="and">c.cshape = #cshape#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="est1not" prepend="and">a.ex0lectcnt &lt; a.ex0cnt</isNotNull>
<isNotNull property="est2not" prepend="and">a.ex1lectcnt &lt; a.ex1cnt</isNotNull>
<isNotNull property="est11not" prepend="and">a.sd0lectcnt &lt; a.sd0cnt</isNotNull>
<isNotNull property="est12not" prepend="and">a.sd1lectcnt &lt; a.sd1cnt</isNotNull>
<isNotNull property="est21not" prepend="and">a.rs0lectcnt &lt; a.rs0cnt</isNotNull>
<isNotNull property="cname" prepend="and">c2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotNull property="cnamestr" prepend="and">c.cname like concat('%',#cnamestr#,'%')</isNotNull>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull>
<isNotNull property="ispasss" prepend="and">((a.sd0cnt &gt; 0 and a.sd0lectcnt &gt; 0))</isNotNull>
<isNotNull property="ispassa" prepend="and">a.ispassa = #ispassa#</isNotNull>
<isNotNull property="ispassex" prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNull property="usernamestr" prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmpty property="sdateall" prepend="and">(case when c.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when c.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="asname" prepend="and">ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="edate" prepend="and">date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="mobile" prepend="and">cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotNull>
</dynamic>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="grade.lectgradesToAll_old" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,b.userno,b.payno
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">c.cname,c.cmno,u.username</isNull> ) rno
,count(a.lectno) over() pagetotalcount
,b.isrebate
<!--,case when ppl.asname is not null then ppl.asname else ua.asname end asname-->
<!--,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association-->
<!--,CAST(AES_DECRYPT(UNHEX(ppl.mphone), <include refid="sql.digest"></include>) AS char) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), <include refid="sql.digest"></include>) AS char) taxemail-->
,u.username,u.userid,u.slevel,u.uduty
,b.iscomplete,b.completetime,b.completeno,b.sdate,b.edate
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,b.cmisno
,p.payoktime<!--,p.payamt-->
,c.cshape<!--,c.sstime-->,c.cmno,c.cname<!--,c.classno,c.studytime-->
<!--,t.tyear-->
<!--,cg.cgname,cg.pcgno,pcg.cgname as pcgname-->
,d.isoffabs
,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
<!--,a.ispassat-->
,e.sseq,e.estart,e.eend,e.studyplace
,f.istatus
,cc.cname studyplacename
<!--,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname-->
,date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') edatestring
<!--,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), <include refid="sql.digest"></include>) AS char) as rbankaccnum-->
from (
select a.lectno
,(b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100) * 100 apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,(a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100) * 100 mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,(a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100) * 100 fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,(a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100) * 100 spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,(a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100) * 100 dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
<!--,case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end &lt;= b.attrate then 1 else 0 end ispassa
,case when case when b.isrebate=1 then d.midcutrfd else d.midcut end &lt;= a.ex0lectpoint then 1 else 0 end ispassm
,case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end &lt;= a.ex1lectpoint then 1 else 0 end ispassf
,case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end &lt;= a.sd0lectpoint then 1 else 0 end ispasss
,case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end &lt;= a.sd1lectpoint then 1 else 0 end ispassd
,case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end ispassat
,case when
case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end = 1 and
case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end &lt;= b.attrate then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.midcutrfd else d.midcut end &lt;= a.ex0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end &lt;= a.ex1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end &lt;= a.sd0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end &lt;= a.sd1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.cutrfd else d.cut end &lt;=
((b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100 * 100))
+((a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100)* 100)
+((a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100)* 100)
+((a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100)* 100)
+((a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100)* 100) then 1 else 0 end = 1 then 1 else 0 end ispass-->
from (
select a.lectno
,sum(ex0cnt) ex0cnt,sum(ex0lectcnt) ex0lectcnt,sum(ex0lectpoint) ex0lectpoint
,sum(ex1cnt) ex1cnt,sum(ex1lectcnt) ex1lectcnt,sum(ex1lectpoint) ex1lectpoint
,sum(sd0cnt) sd0cnt,sum(sd0lectcnt) sd0lectcnt,sum(sd0lectpoint) sd0lectpoint
,sum(sd1cnt) sd1cnt,sum(sd1lectcnt) sd1lectcnt,sum(sd1lectpoint) sd1lectpoint
,sum(rs0cnt) rs0cnt,sum(rs0lectcnt) rs0lectcnt,sum(rs0lectpoint) rs0lectpoint
,sum(at0cnt) at0cnt,sum(at0lectcnt) at0lectcnt
from (
select a.lectno
,count(b.exno) ex0cnt,count(c.lectno) ex0lectcnt,avg(ifnull(c.tpoint,0) / b.tpoint * 100) ex0lectpoint
,0 ex1cnt,0 ex1lectcnt,0 ex1lectpoint
,0 sd0cnt,0 sd0lectcnt,0 sd0lectpoint
,0 sd1cnt,0 sd1lectcnt,0 sd1lectpoint
,0 rs0cnt,0 rs0lectcnt,0 rs0lectpoint
,0 at0cnt,0 at0lectcnt
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=0 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,count(b.exno),count(c.lectno),avg(ifnull(c.tpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=1 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.rsno),count(c.lectno),0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmrs b on b.cmno=a.cmno and b.rstype=0 and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.cmino),count(c.lectno)
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and a2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cminning b on b.cmno=a.cmno and b.isonline =0 and b.isscd = 1
left outer join lectinning c on c.cmino=b.cmino and c.lectno = a.lectno and c.istatus = 2
group by a.lectno
) a
group by a.lectno
) a
inner join lect b on b.lectno=a.lectno
inner join cmev d on d.cmno=b.cmno
) a
inner join lect b on b.lectno=a.lectno
inner join pay p on p.payno=b.payno
inner join users u on u.userno=b.userno
left outer join assign ua on ua.asno=u.asno
inner join cm c on c.cmno=b.cmno
inner join cm c2 on c2.cmno=c.pcmno
inner join cmev d on d.cmno=c.cmno
left outer join term t on t.tmno = c.tmno
<!--left outer join cg cg on cg.cgno = c.cgno-->
<!--left outer join cg pcg on pcg.cgno = cg.pcgno
left outer join payitem pi on pi.payno = p.payno-->
left outer join cminningscd e on e.cmisno = b.cmisno
left outer join lectinning f on f.lectno = b.lectno and f.cmino = e.cmino
left outer join comcode cc on cc.ccode = e.studyplace and cc.isuse=1
left outer join pplog ppl on ppl.pplno = p.pplno
<!--left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob-->
<dynamic prepend="where">
<isNotNull property="cshape" prepend="and">c.cshape = #cshape#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="est1not" prepend="and">a.ex0lectcnt &lt; a.ex0cnt</isNotNull>
<isNotNull property="est2not" prepend="and">a.ex1lectcnt &lt; a.ex1cnt</isNotNull>
<isNotNull property="est11not" prepend="and">a.sd0lectcnt &lt; a.sd0cnt</isNotNull>
<isNotNull property="est12not" prepend="and">a.sd1lectcnt &lt; a.sd1cnt</isNotNull>
<isNotNull property="est21not" prepend="and">a.rs0lectcnt &lt; a.rs0cnt</isNotNull>
<isNotNull property="cname" prepend="and">c2.cname like concat('%',#cname#,'%')</isNotNull>
<isNotNull property="cnamestr" prepend="and">c.cname like concat('%',#cnamestr#,'%')</isNotNull>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull>
<isNotNull property="ispasss" prepend="and">((a.sd0cnt &gt; 0 and a.sd0lectcnt &gt; 0))</isNotNull>
<isNotNull property="ispassa" prepend="and">a.ispassa = #ispassa#</isNotNull>
<isNotNull property="ispassex" prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNull property="usernamestr" prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmpty property="sdateall" prepend="and">(case when c.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when c.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="asname" prepend="and">ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="edate" prepend="and">date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="mobile" prepend="and">cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotNull>
</dynamic>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="grade.lectgradesToAll" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,b.userno,b.payno
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">c.cname,c.cmno,u.username</isNull> ) rno
,count(a.lectno) over() pagetotalcount
,b.isrebate
,case when ppl.asname is not null then ppl.asname else ua.asname end asname
,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association
,CAST(AES_DECRYPT(UNHEX(ppl.mphone), <include refid="sql.digest"></include>) AS char) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), <include refid="sql.digest"></include>) AS char) taxemail
,u.username,u.userid,u.slevel,u.uduty
,b.iscomplete,b.completetime,b.completeno,b.sdate,b.edate, c.studydays
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), <include refid="sql.digest"></include>) AS char) mobile
,b.cmisno
,p.payoktime,p.payamt
,c.cshape,c.sstime,c.cmno,c.cname,c.classno,c.studytime
,t.tyear
,cg.cgname,cg.pcgno,pcg.cgname as pcgname
,d.isoffabs
,b.attrate
,a.apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,a.mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,a.fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,a.spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,a.dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,a.ispassat
,e.sseq,e.estart,e.eend,e.studyplace
,f.istatus
,cc.cname studyplacename
,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname
,date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') edatestring
,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), <include refid="sql.digest"></include>) AS char) as rbankaccnum
, date_format(f.stime, '%Y-%m-%d') zstring3
from (
select a.lectno
,(b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100) * 100 apoint
,a.ex0cnt,a.ex0lectcnt,a.ex0lectpoint,(a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100) * 100 mpoint
,a.ex1cnt,a.ex1lectcnt,a.ex1lectpoint,(a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100) * 100 fpoint
,a.sd0cnt,a.sd0lectcnt,a.sd0lectpoint,(a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100) * 100 spoint
,a.sd1cnt,a.sd1lectcnt,a.sd1lectpoint,(a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100) * 100 dpoint
,a.rs0cnt,a.rs0lectcnt,a.rs0lectpoint
,case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end &lt;= b.attrate then 1 else 0 end ispassa
,case when case when b.isrebate=1 then d.midcutrfd else d.midcut end &lt;= a.ex0lectpoint then 1 else 0 end ispassm
,case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end &lt;= a.ex1lectpoint then 1 else 0 end ispassf
,case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end &lt;= a.sd0lectpoint then 1 else 0 end ispasss
,case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end &lt;= a.sd1lectpoint then 1 else 0 end ispassd
,case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end ispassat
,case when
case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end = 1 and
case when case when b.isrebate=1 then d.attendcutrfd else d.attendcut end &lt;= b.attrate then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.midcutrfd else d.midcut end &lt;= a.ex0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.finalcutrfd else d.finalcut end &lt;= a.ex1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.subjectcutrfd else d.subjectcut end &lt;= a.sd0lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.discusscutrfd else d.discusscut end &lt;= a.sd1lectpoint then 1 else 0 end =1 and
case when case when b.isrebate=1 then d.cutrfd else d.cut end &lt;=
((b.attrate / 100) * (case when b.isrebate=1 then d.attendrfd else d.attend end / 100 * 100))
+((a.ex0lectpoint / 100) * (case when b.isrebate=1 then d.midrfd else d.mid end / 100)* 100)
+((a.ex1lectpoint / 100) * (case when b.isrebate=1 then d.finalrfd else d.final end / 100)* 100)
+((a.sd0lectpoint / 100) * (case when b.isrebate=1 then d.subjectrfd else d.subject end / 100)* 100)
+((a.sd1lectpoint / 100) * (case when b.isrebate=1 then d.discussrfd else d.discuss end / 100)* 100) then 1 else 0 end = 1 then 1 else 0 end ispass
from (
select a.lectno
,sum(ex0cnt) ex0cnt,sum(ex0lectcnt) ex0lectcnt,sum(ex0lectpoint) ex0lectpoint
,sum(ex1cnt) ex1cnt,sum(ex1lectcnt) ex1lectcnt,sum(ex1lectpoint) ex1lectpoint
,sum(sd0cnt) sd0cnt,sum(sd0lectcnt) sd0lectcnt,sum(sd0lectpoint) sd0lectpoint
,sum(sd1cnt) sd1cnt,sum(sd1lectcnt) sd1lectcnt,sum(sd1lectpoint) sd1lectpoint
,sum(rs0cnt) rs0cnt,sum(rs0lectcnt) rs0lectcnt,sum(rs0lectpoint) rs0lectpoint
,sum(at0cnt) at0cnt,sum(at0lectcnt) at0lectcnt
from (
select a.lectno
,count(b.exno) ex0cnt,count(c.lectno) ex0lectcnt,avg(ifnull(c.tpoint,0) / b.tpoint * 100) ex0lectpoint
,0 ex1cnt,0 ex1lectcnt,0 ex1lectpoint
,0 sd0cnt,0 sd0lectcnt,0 sd0lectpoint
,0 sd1cnt,0 sd1lectcnt,0 sd1lectpoint
,0 rs0cnt,0 rs0lectcnt,0 rs0lectpoint
,0 at0cnt,0 at0lectcnt
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="edate1" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNull property="edate2" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) &lt;= #edate2#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and (a2.cname like concat('%',#cname#,'%') or a.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=0 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,count(b.exno),count(c.lectno),avg(ifnull(c.tpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="edate1" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNull property="edate2" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) &lt;= #edate2#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and (a2.cname like concat('%',#cname#,'%') or a.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmex b on b.cmno=a.cmno and b.extype=1 and b.isdel=0
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="edate1" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNull property="edate2" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) &lt;= #edate2#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and (a2.cname like concat('%',#cname#,'%') or a.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=0 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,count(b.sdno),count(c.lectno),avg(ifnull(c.cpoint,0) / b.tpoint * 100)
,0,0,0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="edate1" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNull property="edate2" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) &lt;= #edate2#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and (a2.cname like concat('%',#cname#,'%') or a.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmsd b on b.cmno=a.cmno and b.sdtype=1 and b.isdel=0
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.rsno),count(c.lectno),0
,0,0
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="edate1" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNull property="edate2" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) &lt;= #edate2#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and (a2.cname like concat('%',#cname#,'%') or a.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cmrs b on b.cmno=a.cmno and b.rstype=0 and b.isdel=0
left outer join lectrs c on c.lectno=a.lectno and c.rsno=b.rsno
group by a.lectno
union all
select a.lectno
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,0,0,0
,count(b.cmino),count(c.lectno)
from (
select b.lectno,a.cmno
from cm a
inner join cm a2 on a.pcmno = a2.cmno
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno and c.status=1
inner join pay p on p.payno=b.payno
left outer join cminningscd e on e.cmisno = b.cmisno
where a.ismaster=0 and a.isdel=0
<isNotNull property="usernamestr" prepend="and">c.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">c.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(c.userid like concat('%',#usernameid#,'%') or c.username like concat('%',#usernameid#,'%') or c.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull> <isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="edate1" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) >= #edate1#</isNotNull>
<isNotNull property="edate2" prepend="and">(case when a.cshape = 2 and e.eend is not null then e.eend else b.edate end) &lt;= #edate2#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and a.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and (a2.cname like concat('%',#cname#,'%') or a.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
) a
left outer join cminning b on b.cmno=a.cmno and b.isonline =0 and b.isscd = 1
left outer join lectinning c on c.cmino=b.cmino and c.lectno = a.lectno and c.istatus = 2
group by a.lectno
) a
group by a.lectno
) a
inner join lect b on b.lectno=a.lectno
inner join cmev d on d.cmno=b.cmno
) a
inner join lect b on b.lectno=a.lectno
inner join pay p on p.payno=b.payno
inner join users u on u.userno=b.userno
left outer join assign ua on ua.asno=u.asno
inner join cm c on c.cmno=b.cmno
inner join cm c2 on c2.cmno=c.pcmno
inner join cmev d on d.cmno=c.cmno
left outer join term t on t.tmno = c.tmno
left outer join cg cg on cg.cgno = c.cgno
left outer join cg pcg on pcg.cgno = cg.pcgno
left outer join payitem pi on pi.payno = p.payno
left outer join cminningscd e on e.cmisno = b.cmisno
left outer join lectinning f on f.lectno = b.lectno and f.cmino = e.cmino
left outer join comcode cc on cc.ccode = e.studyplace and cc.isuse=1
left outer join pplog ppl on ppl.pplno = p.pplno
left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob
<dynamic prepend="where">
<isNotNull property="cshape" prepend="and">c.cshape = #cshape#</isNotNull>
<isNotNull property="studyplace" prepend="and">e.studyplace = #studyplace#</isNotNull>
<isNotNull property="est1not" prepend="and">a.ex0lectcnt &lt; a.ex0cnt</isNotNull>
<isNotNull property="est2not" prepend="and">a.ex1lectcnt &lt; a.ex1cnt</isNotNull>
<isNotNull property="est11not" prepend="and">a.sd0lectcnt &lt; a.sd0cnt</isNotNull>
<isNotNull property="est12not" prepend="and">a.sd1lectcnt &lt; a.sd1cnt</isNotNull>
<isNotNull property="est21not" prepend="and">a.rs0lectcnt &lt; a.rs0cnt</isNotNull>
<!--<isNotNull property="cname" prepend="and">c2.cname like concat('%',#cname#,'%')</isNotNull>-->
<isNotNull property="cname" prepend="and"> (c2.cname like concat('%',#cname#,'%') or c.cname like concat('%',#cname#,'%'))</isNotNull>
<isNotNull property="cnamestr" prepend="and">c.cname like concat('%',#cnamestr#,'%')</isNotNull>
<isNotNull property="iscomplete" prepend="and">ifnull(b.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">b.cmisno = #cmisno#</isNotNull>
<isNotNull property="ispasss" prepend="and">((a.sd0cnt &gt; 0 and a.sd0lectcnt &gt; 0))</isNotNull>
<isNotNull property="ispassa" prepend="and">a.ispassa = #ispassa#</isNotNull>
<isNotNull property="ispassex" prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNull property="usernamestr" prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmpty property="sdateall" prepend="and">(case when c.cshape = 0 and b.isrebate = 0 then p.payoktime else b.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when c.cshape = 2 then e.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="asname" prepend="and">ua.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="edate" prepend="and">date_format((case when c.cshape = 2 and e.eend is not null then e.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="mobile" prepend="and">cast(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotNull>
<isNotNull property="attendance" >
<!--해당없음-->
<isEqual property="attendance" compareValue="1" prepend="and"> ifnull(d.isoffabs,0) = 0</isEqual>
<!--대상자(미입력/출석)-->
<isEqual property="attendance" compareValue="2" prepend="and"> ifnull(d.isoffabs,0) = 1</isEqual>
<!--미입력-->
<isEqual property="attendance" compareValue="3" prepend="and"> ifnull(d.isoffabs,0) = 1 and f.istatus is null </isEqual>
<!--출석-->
<isEqual property="attendance" compareValue="4" prepend="and"> ifnull(d.isoffabs,0) = 1 and ifnull(f.istatus,-1) = 2</isEqual>
<!--결석-->
<isEqual property="attendance" compareValue="5" prepend="and"> ifnull(d.isoffabs,0) = 1 and ifnull(f.istatus,-1) = 0</isEqual>
</isNotNull>
</dynamic>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<!--#xodus-->
<select id="grade.lectgradesToAll2_old" parameterClass="hashtable" resultClass="lect">
select *
from (
SELECT a.*
, (CASE WHEN ppl.asname IS NOT NULL THEN ppl.asname ELSE ua.asname END) asname
,CAST(AES_DECRYPT(UNHEX(ppl.mphone), 'np123@!' ) AS CHAR) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), 'np123@!' ) AS CHAR) taxemail
,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association
,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname
,date_format((case when a.cshape = 2 and a.eend is not null then a.eend else a.edate end),'%Y-%m-%d') edatestring
,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), 'np123@!' ) AS char) as rbankaccnum
, date_format(f.stime, '%Y-%m-%d') zstring3
,row_number() over(order by ua.asname,ua.asno,a.username ) rno
,count(a.lectno) over() pagetotalcount
FROM (
SELECT a.*
,(a.attrate / 100) * (CASE WHEN a.isrebate=1 THEN d.attendrfd ELSE d.attend END / 100) * 100 apoint
,d.isoffabs,t.tyear
,cg.cgname,cg.pcgno,pcg.cgname as pcgname
,cc.cname studyplacename
,(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.attendcutrfd ELSE d.attendcut END) &lt;= a.attrate THEN 1 ELSE 0 END )ispassa
,(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.midcutrfd ELSE d.midcut END) &lt;= a.ex0lectpoint THEN 1 ELSE 0 END) ispassm
,(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.finalcutrfd ELSE d.finalcut END) &lt;= a.ex1lectpoint THEN 1 ELSE 0 END) ispassf
,(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.subjectcutrfd ELSE d.subjectcut END) &lt;= a.sd0lectpoint THEN 1 ELSE 0 END) ispasss
,(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.discusscutrfd ELSE d.discusscut END) &lt;= a.sd1lectpoint THEN 1 ELSE 0 END) ispassd
,(CASE WHEN (CASE WHEN IFNULL(d.isoffabs,0)=1 THEN IFNULL(a.at0cnt,0) ELSE 0 END) &lt;= IFNULL(a.at0lectcnt,0) THEN 1 ELSE 0 END) ispassat
<!--,(CASE WHEN
(CASE WHEN (CASE WHEN IFNULL(d.isoffabs,0)=1 THEN IFNULL(a.at0cnt,0) ELSE 0 END) &lt;= IFNULL(a.at0lectcnt,0) THEN 1 ELSE 0 END) = 1 AND
(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.attendcutrfd ELSE d.attendcut END) &lt;= a.attrate THEN 1 ELSE 0 END )=1 AND
(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.midcutrfd ELSE d.midcut END) &lt;= a.ex0lectpoint THEN 1 ELSE 0 END) =1 AND
(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.finalcutrfd ELSE d.finalcut END) &lt;= a.ex1lectpoint THEN 1 ELSE 0 END) =1 AND
(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.subjectcutrfd ELSE d.subjectcut END) &lt;= a.sd0lectpoint THEN 1 ELSE 0 END) =1 AND
(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.discusscutrfd ELSE d.discusscut END) &lt;= a.sd1lectpoint THEN 1 ELSE 0 END) =1 AND
(CASE WHEN (CASE WHEN a.isrebate=1 THEN d.cutrfd ELSE d.cut END &lt;=
((a.attrate / 100) * (CASE WHEN a.isrebate=1 THEN d.attendrfd ELSE d.attend END / 100 * 100))
+((a.ex0lectpoint / 100) * (CASE WHEN a.isrebate=1 THEN d.midrfd ELSE d.mid END / 100)* 100)
+((a.ex1lectpoint / 100) * (CASE WHEN a.isrebate=1 THEN d.finalrfd ELSE d.final END / 100)* 100)
+((a.sd0lectpoint / 100) * (CASE WHEN a.isrebate=1 THEN d.subjectrfd ELSE d.subject END / 100)* 100)
+((a.sd1lectpoint / 100) * (CASE WHEN a.isrebate=1 THEN d.discussrfd ELSE d.discuss END / 100)* 100) THEN 1 ELSE 0 END) = 1 THEN 1 ELSE 0 END) ispass-->
,case when
case when case when ifnull(d.isoffabs,0)=1 then ifnull(a.at0cnt,0) else 0 end &lt;= ifnull(a.at0lectcnt,0) then 1 else 0 end = 1 and
case when case when a.isrebate=1 then d.attendcutrfd else d.attendcut end &lt;= a.attrate then 1 else 0 end =1 and
case when case when a.isrebate=1 then d.midcutrfd else d.midcut end &lt;= a.ex0lectpoint then 1 else 0 end =1 and
case when case when a.isrebate=1 then d.finalcutrfd else d.finalcut end &lt;= a.ex1lectpoint then 1 else 0 end =1 and
case when case when a.isrebate=1 then d.subjectcutrfd else d.subjectcut end &lt;= a.sd0lectpoint then 1 else 0 end =1 and
case when case when a.isrebate=1 then d.discusscutrfd else d.discusscut end &lt;= a.sd1lectpoint then 1 else 0 end =1 and
case when case when a.isrebate=1 then d.cutrfd else d.cut end &lt;=
((a.attrate / 100) * (case when a.isrebate=1 then d.attendrfd else d.attend end / 100 * 100))
+((a.ex0lectpoint / 100) * (case when a.isrebate=1 then d.midrfd else d.mid end / 100)* 100)
+((a.ex1lectpoint / 100) * (case when a.isrebate=1 then d.finalrfd else d.final end / 100)* 100)
+((a.sd0lectpoint / 100) * (case when a.isrebate=1 then d.subjectrfd else d.subject end / 100)* 100)
+((a.sd1lectpoint / 100) * (case when a.isrebate=1 then d.discussrfd else d.discuss end / 100)* 100) then 1 else 0 end = 1 then 1 else 0 end ispass
FROM (
SELECT l.lectno, c.cmno, c.cgno, u.userid, u.username, u.userno, u.asno,u.slevel,u.uduty
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) AS CHAR) mobile
, l.attrate, l.mpoint, l.fpoint, l.spoint, l.dpoint, l.isrebate, l.iscomplete, l.completetime, l.completeno,l.sdate,l.edate, l.cmisno
, c.cshape, c.sstime,c.cname,c.classno,c.studytime, c.tmno
,cis.sseq,cis.estart,cis.eend,cis.studyplace, li.istatus, li.cmino
, p.payno, p.payamt
, (CASE WHEN IFNULL(ce.exno,0) = 0 THEN 0 ELSE 1 END) AS ex0cnt<!-- 최종평가-->
, (CASE WHEN IFNULL(le.lectno,0) = 0 THEN 0 ELSE 1 END) AS ex0lectcnt <!-- 최종평가-->
, AVG(IFNULL(le.tpoint,0) / ce.tpoint * 100) ex0lectpoint <!-- 최종평가-->
, (CASE WHEN IFNULL(ce2.exno,0) = 0 THEN 0 ELSE 1 END) AS ex1cnt<!-- 중간평가-->
, (CASE WHEN IFNULL(le2.lectno,0) = 0 THEN 0 ELSE 1 END) AS ex1lectcnt <!-- 중간평가-->
, AVG(IFNULL(le2.tpoint,0) / ce2.tpoint * 100) ex1lectpoint
, SUM(CASE WHEN IFNULL(cs.sdno,0) = 0 THEN 0 ELSE 1 END) AS sd0cnt <!-- `과제제출`-->
, SUM(CASE WHEN IFNULL(ls.lectno,0) = 0 THEN 0 ELSE 1 END) AS sd0lectcnt <!-- `과제제출`-->
, ROUND(AVG(IFNULL(ls.cpoint,0)),0) AS sd0lectpoint <!-- `과제평균`-->
, (CASE WHEN IFNULL(cs2.sdno,0) = 0 THEN 0 ELSE 1 END) AS sd1cnt <!-- `토론제출`-->
, (CASE WHEN IFNULL(ls2.lectno,0) = 0 THEN 0 ELSE 1 END) AS sd1lectcnt <!-- `토론제출`-->
, AVG(IFNULL(ls2.cpoint,0) / cs2.tpoint * 100) sd1lectpoint
, (CASE WHEN IFNULL(cr.rsno,0) = 0 THEN 0 ELSE 1 END) AS rs0cnt <!-- `설문제출`-->
, SUM(CASE WHEN IFNULL(lt.lectno,0) = 0 THEN 0 ELSE 1 END) AS rs0lectcnt
, (CASE WHEN IFNULL(lt.lectno,0) = 0 THEN 0 ELSE 1 END) AS rs0lectpoint <!-- `설문제출`-->
,COUNT(ci.cmino) at0cnt, COUNT(li.lectno) at0lectcnt
, p.payoktime
, p.pplno
FROM lect l
INNER JOIN cm c ON l.cmno = c.cmno
LEFT OUTER JOIN cminningscd cis ON l.cmisno = cis.cmisno
INNER JOIN users u ON l.userno = u.userno
INNER JOIN pay p ON p.payno = l.payno
<!--최종평가-->
LEFT OUTER JOIN cmex ce ON l.cmno = ce.cmno AND ce.extype = 1 AND ce.isdel = 0
LEFT OUTER JOIN lectex le ON l.lectno = le.lectno AND ce.exno = le.exno
<!--중간평가-->
LEFT OUTER JOIN cmex ce2 ON l.cmno = ce2.cmno AND ce2.extype = 0 AND ce2.isdel = 0
LEFT OUTER JOIN lectex le2 ON l.lectno = le2.lectno AND ce2.exno = le2.exno
<!--과제-->
LEFT OUTER JOIN cmsd cs ON l.cmno = cs.cmno AND cs.sdtype = 0 AND cs.isdel = 0
LEFT OUTER JOIN lectsd ls ON l.lectno = ls.lectno AND cs.sdno = ls.sdno
<!--토론-->
LEFT OUTER JOIN cmsd cs2 ON l.cmno = cs2.cmno AND cs2.sdtype = 1 AND cs2.isdel = 0
LEFT OUTER JOIN lectsd ls2 ON l.lectno = ls2.lectno AND cs2.sdno = ls2.sdno
<!--설문-->
LEFT OUTER JOIN cmrs cr ON l.cmno = cr.cmno AND cr.rstype = 0 AND cr.isdel = 0
LEFT OUTER JOIN lectrs lt ON l.lectno = lt.lectno AND cr.rsno = lt.rsno
<!--집합출석-->
LEFT OUTER JOIN cminning ci ON l.cmno=ci.cmno AND ci.isonline =0 AND ci.isscd = 1
LEFT OUTER JOIN lectinning li ON ci.cmino = li.cmino AND l.lectno = li.lectno AND li.istatus = 2
WHERE u.status = 1 AND c.ismaster=0 AND c.isdel=0 AND l.status = 1 AND l.ischanged = 0
<isNotNull property="usernamestr" prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(l.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">l.cmisno = #cmisno#</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when c.cshape = 0 and l.isrebate = 0 then p.payoktime else l.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when c.cshape = 2 then cis.eend else l.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="edate1" prepend="and">(case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end) >= #edate1#</isNotNull>
<isNotNull property="edate2" prepend="and">(case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end) &lt;= #edate2#</isNotNull>
<isNotNull property="studyplace" prepend="and">cis.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and l.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and c.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when c.cshape = 0 and l.isrebate = 0 then p.payoktime else l.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when c.cshape = 2 then cis.eend else l.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
GROUP BY l.lectno
) a
INNER JOIN cmev d ON a.cmno=d.cmno
LEFT OUTER JOIN term t ON t.tmno = a.tmno
LEFT OUTER JOIN cg cg ON a.cgno = cg.cgno
LEFT OUTER JOIN cg pcg ON cg.pcgno = pcg.cgno
left outer join comcode cc on cc.ccode = a.studyplace and cc.isuse=1
) a
LEFT OUTER JOIN pplog ppl ON ppl.pplno = a.pplno
LEFT OUTER JOIN assign ua ON ua.asno=a.asno
left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob
inner join payitem pi on a.payno = pi.payno
left outer join lectinning f on a.lectno = f.lectno and a.cmino = f.cmino
<dynamic prepend="where">
<isNotNull property="cshape" prepend="and">a.cshape = #cshape#</isNotNull>
<isNotNull property="studyplace" prepend="and">a.studyplace = #studyplace#</isNotNull>
<isNotNull property="est1not" prepend="and">a.ex0lectcnt &lt; a.ex0cnt</isNotNull>
<isNotNull property="est2not" prepend="and">a.ex1lectcnt &lt; a.ex1cnt</isNotNull>
<isNotNull property="est11not" prepend="and">a.sd0lectcnt &lt; a.sd0cnt</isNotNull>
<isNotNull property="est12not" prepend="and">a.sd1lectcnt &lt; a.sd1cnt</isNotNull>
<isNotNull property="est21not" prepend="and">a.rs0lectcnt &lt; a.rs0cnt</isNotNull>
<isNotNull property="cname" prepend="and">a.pcgname like concat('%',#cname#,'%')</isNotNull>
<isNotNull property="cnamestr" prepend="and">a.cname like concat('%',#cnamestr#,'%')</isNotNull>
<isNotNull property="iscomplete" prepend="and">ifnull(a.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">a.cmisno = #cmisno#</isNotNull>
<isNotNull property="ispasss" prepend="and">((a.sd0cnt &gt; 0 and a.sd0lectcnt &gt; 0))</isNotNull>
<isNotNull property="ispassa" prepend="and">a.ispassa = #ispassa#</isNotNull>
<isNotNull property="ispassex" prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotNull property="usernamestr" prepend="and">a.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">a.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(a.userid like concat('%',#usernameid#,'%') or a.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and a.isrebate = 0 then a.payoktime else a.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then a.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="asname" prepend="and">a.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and a.eend is not null then a.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="mobile" prepend="and">a.mobile like concat('%',#mobile#,'%')</isNotNull>
</dynamic>
)a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="grade.lectgradesToAll2" parameterClass="hashtable" resultClass="lect">
select *
from (
SELECT a.*
, (CASE WHEN ppl.asname IS NOT NULL THEN ppl.asname ELSE ua.asname END) asname
,CAST(AES_DECRYPT(UNHEX(ppl.mphone), 'np123@!' ) AS CHAR) mphone
,CAST(AES_DECRYPT(UNHEX(ppl.taxemail), 'np123@!' ) AS CHAR) taxemail
,ppl.brno,ppl.ceoname,ppl.post,ppl.address1,ppl.address2,ppl.btype,ppl.bkind,ppl.eino,ppl.mname,ppl.association
,tm.cname typemanname, te.cname typeeduname
,tg.cname typegradename, tj.cname typejobname
,date_format((case when a.cshape = 2 and a.eend is not null then a.eend else a.edate end),'%Y-%m-%d') edatestring
,pi.tbankuser rbankuser,pi.rbank,pi.pino,pi.rbankamt
,CAST(AES_DECRYPT(UNHEX(pi.rbankaccnum), 'np123@!' ) AS char) as rbankaccnum
, date_format(f.stime, '%Y-%m-%d') zstring3
, ROUND(a.apoint + a.mpoint + a.fpoint + a.spoint + a.dpoint,0) AS tpoint
,row_number() over(order by ua.asname,ua.asno,a.username ) rno
,count(a.lectno) over() pagetotalcount
FROM (
SELECT a.*
,(a.attrate / 100) * (d.attend / 100) * 100 apoint
,d.isoffabs,t.tyear
,cg.cgname,cg.pcgno,pcg.cgname as pcgname
,cc.cname studyplacename
FROM (
SELECT l.lectno, c.cmno, c.cgno, u.userid, u.username, u.userno, u.asno,u.slevel,u.uduty
,concat(substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),1,6),'-',substring(CAST(AES_DECRYPT(UNHEX(u.userpno),<include refid="sql.digest"></include>) as char),7,7)) userpno
,CAST(AES_DECRYPT(UNHEX(u.mobile), 'np123@!' ) AS CHAR) mobile
,l.attrate, ifnull(l.mpoint,0) AS mpoint, ifnull(l.fpoint,0) fpoint
,ifnull(l.spoint,0) AS spoint,ifnull(l.dpoint,0) AS dpoint
, ifnull(l.exmpoint,-1) as dblv1, ifnull(l.exfpoint,-1) as dblv2
, ifnull(l.subjectpoint,-1) as dblv3, ifnull(l.discusspoint,-1) as dblv4
, l.isrebate, l.iscomplete, l.completetime, l.completeno,l.sdate,l.edate, l.cmisno
, c.cshape, c.sstime,c.cname,c.classno,c.studytime, c.tmno
,cis.sseq,cis.estart,cis.eend,cis.studyplace, li.istatus, li.cmino
, p.payno, p.payamt
, (CASE WHEN IFNULL(ce.exno,0) = 0 THEN 0 ELSE 1 END) AS ex0cnt<!-- 중간평가-->
, (CASE WHEN IFNULL(ce2.exno,0) = 0 THEN 0 ELSE 1 END) AS ex1cnt<!-- 최종평가-->
, SUM(CASE WHEN IFNULL(cs.sdno,0) = 0 THEN 0 ELSE 1 END) AS sd0cnt <!-- `과제제출`-->
, (CASE WHEN IFNULL(cs2.sdno,0) = 0 THEN 0 ELSE 1 END) AS sd1cnt <!-- `토론제출`-->
, (CASE WHEN IFNULL(cr.rsno,0) = 0 THEN 0 ELSE 1 END) AS rs0cnt <!-- `설문제출`-->
, SUM(CASE WHEN IFNULL(lt.lectno,0) = 0 THEN 0 ELSE 1 END) AS rs0lectcnt
, (CASE WHEN IFNULL(lt.lectno,0) = 0 THEN 0 ELSE 1 END) AS rs0lectpoint <!-- `설문제출`-->
,COUNT(ci.cmino) at0cnt, COUNT(li.lectno) at0lectcnt
, p.payoktime
, p.pplno
FROM lect l
INNER JOIN cm c ON l.cmno = c.cmno
LEFT OUTER JOIN cminningscd cis ON l.cmisno = cis.cmisno
INNER JOIN users u ON l.userno = u.userno
INNER JOIN pay p ON p.payno = l.payno
<!--중간평가-->
LEFT OUTER JOIN cmex ce ON l.cmno = ce.cmno AND ce.extype = 0 AND ce.isdel = 0
<!--최종평가-->
LEFT OUTER JOIN cmex ce2 ON l.cmno = ce2.cmno AND ce2.extype = 1 AND ce2.isdel = 0
<!--과제-->
LEFT OUTER JOIN cmsd cs ON l.cmno = cs.cmno AND cs.sdtype = 0 AND cs.isdel = 0
<!--토론-->
LEFT OUTER JOIN cmsd cs2 ON l.cmno = cs2.cmno AND cs2.sdtype = 1 AND cs2.isdel = 0
<!--설문-->
LEFT OUTER JOIN cmrs cr ON l.cmno = cr.cmno AND cr.rstype = 0 AND cr.isdel = 0
LEFT OUTER JOIN lectrs lt ON l.lectno = lt.lectno AND cr.rsno = lt.rsno
<!--집합출석-->
LEFT OUTER JOIN cminning ci ON l.cmno=ci.cmno AND ci.isonline =0 AND ci.isscd = 1
LEFT OUTER JOIN lectinning li ON ci.cmino = li.cmino AND l.lectno = li.lectno AND li.istatus = 2
WHERE u.status = 1 AND c.ismaster=0 AND c.isdel=0 AND l.status = 1 AND l.ischanged = 0
<isNotNull property="usernamestr" prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotNull property="usernamestr" prepend="and">u.username like concat('%',#usernamestr#,'%')</isNotNull>
<isNotNull property="useridstr" prepend="and">u.userid like concat('%',#useridstr#,'%')</isNotNull>
<isNotEmpty property="usernameid" prepend="and">(u.userid like concat('%',#usernameid#,'%') or u.username like concat('%',#usernameid#,'%') or u.usernameeng like concat('%',#usernameid#,'%')) </isNotEmpty>
<isNotNull property="iscomplete" prepend="and">ifnull(l.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">l.cmisno = #cmisno#</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when c.cshape = 0 and l.isrebate = 0 then p.payoktime else l.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when c.cshape = 2 then cis.eend else l.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="edate" prepend="and">date_format((case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="edate1" prepend="and">(case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end) >= #edate1#</isNotNull>
<isNotNull property="edate2" prepend="and">(case when c.cshape = 2 and cis.eend is not null then cis.eend else l.edate end) &lt;= #edate2#</isNotNull>
<isNotNull property="studyplace" prepend="and">cis.studyplace = #studyplace#</isNotNull>
<isNotNull property="cmno" >and l.cmno = #cmno#</isNotNull>
<isNotNull property="cname" >and c.cname like concat('%',#cname#,'%')</isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when c.cshape = 0 and l.isrebate = 0 then p.payoktime else l.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when c.cshape = 2 then cis.eend else l.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
GROUP BY l.lectno
) a
INNER JOIN cmev d ON a.cmno=d.cmno
LEFT OUTER JOIN term t ON t.tmno = a.tmno
LEFT OUTER JOIN cg cg ON a.cgno = cg.cgno
LEFT OUTER JOIN cg pcg ON cg.pcgno = pcg.cgno
left outer join comcode cc on cc.ccode = a.studyplace and cc.isuse=1
) a
LEFT OUTER JOIN pplog ppl ON ppl.pplno = a.pplno
LEFT OUTER JOIN assign ua ON ua.asno=a.asno
left outer join comcode tm on tm.ccode = ppl.typeman
left outer join comcode te on te.ccode = ppl.typeedu
left outer join comcode tg on tg.ccode = ppl.typegrade
left outer join comcode tj on tj.ccode = ppl.typejob
inner join payitem pi on a.payno = pi.payno
left outer join lectinning f on a.lectno = f.lectno and a.cmino = f.cmino
<dynamic prepend="where">
<isNotNull property="cshape" prepend="and">a.cshape = #cshape#</isNotNull>
<isNotNull property="studyplace" prepend="and">a.studyplace = #studyplace#</isNotNull>
<isNotNull property="est1not" prepend="and">a.ex0lectcnt &lt; a.ex0cnt</isNotNull>
<isNotNull property="est2not" prepend="and">a.ex1lectcnt &lt; a.ex1cnt</isNotNull>
<isNotNull property="est11not" prepend="and">a.sd0lectcnt &lt; a.sd0cnt</isNotNull>
<isNotNull property="est12not" prepend="and">a.sd1lectcnt &lt; a.sd1cnt</isNotNull>
<isNotNull property="est21not" prepend="and">a.rs0lectcnt &lt; a.rs0cnt</isNotNull>
<isNotNull property="cname" prepend="and">(a.pcgname like concat('%',#cname#,'%') or a.cname like concat('%',#cnamestr#,'%'))</isNotNull>
<isNotNull property="cnamestr" prepend="and">(a.pcgname like concat('%',#cname#,'%') or a.cname like concat('%',#cnamestr#,'%'))</isNotNull>
<isNotNull property="iscomplete" prepend="and">ifnull(a.iscomplete,0)=#iscomplete#</isNotNull>
<isNotNull property="cmisno" prepend="and">a.cmisno = #cmisno#</isNotNull>
<isNotNull property="ispasss" prepend="and">((a.sd0cnt &gt; 0 and a.sd0lectcnt &gt; 0))</isNotNull>
<isNotNull property="ispassa" prepend="and">a.ispassa = #ispassa#</isNotNull>
<isNotNull property="ispassex" prepend="and">(a.ispassm = #ispassex# and a.ispassf = #ispassex#) </isNotNull>
<isNotEmpty property="sdateall" prepend="and">(case when a.cshape = 0 and a.isrebate = 0 then a.payoktime else a.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall" prepend="and">(case when a.cshape = 2 then a.eend else b.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotNull property="asname" prepend="and">a.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="edate" prepend="and">date_format((case when a.cshape = 2 and a.eend is not null then a.eend else b.edate end),'%Y-%m-%d') = #edate#</isNotNull>
<isNotNull property="mobile" prepend="and">a.mobile like concat('%',#mobile#,'%')</isNotNull>
<isNotNull property="attendance" >
<!--해당없음-->
<isEqual property="attendance" compareValue="1" prepend="and"> ifnull(a.isoffabs,0) = 0</isEqual>
<!--대상자(미입력/출석)-->
<isEqual property="attendance" compareValue="2" prepend="and"> ifnull(a.isoffabs,0) = 1</isEqual>
<!--미입력-->
<isEqual property="attendance" compareValue="3" prepend="and"> ifnull(a.isoffabs,0) = 1 and f.istatus is null </isEqual>
<!--출석-->
<isEqual property="attendance" compareValue="4" prepend="and"> ifnull(a.isoffabs,0) = 1 and ifnull(f.istatus,-1) = 2</isEqual>
<!--결석-->
<isEqual property="attendance" compareValue="5" prepend="and"> ifnull(a.isoffabs,0) = 1 and ifnull(f.istatus,-1) = 0</isEqual>
</isNotNull>
</dynamic>
)a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<update id="grade.lectcomplete.abs" parameterClass="hashtable">
update lect set <include refid="sql.up"></include>
,iscomplete=1
where lectno in ($lectnos$)
</update>
<update id="grade.lectcomplete" parameterClass="hashtable">
update lect a
inner join (
<include refid="grade.query"></include>
) b on b.lectno=a.lectno
set a.udt=<include refid="sql.now"></include>,a.uno=#uno#,a.uip=#uip#
,a.iscomplete=b.ispass
,a.apoint=b.apoint
,a.mpoint=a.mpoint
,a.fpoint=b.fpoint
,a.spoint=b.spoint
,a.dpoint=b.dpoint
,a.tpoint=b.apoint+b.mpoint+b.fpoint+b.spoint+b.dpoint
where a.status=1 and a.ischanged=0
<isNotEmpty property="cmnos">and a.cmno in ($cmnos$)</isNotEmpty>
<isNotEmpty property="lectnos">and a.lectno in ($lectnos$)</isNotEmpty>
</update>
<select id="grade.nocompletecm" parameterClass="string" resultClass="cm">
select a.cmno, max(a.iscomplete)
from lect a
inner join users b on b.userno=a.userno and b.status=1
where a.cmno in ($cmnos$) and a.status=1 and a.ischanged=0
group by a.cmno
having ifnull(max(a.iscomplete),0) &lt;&gt;1
</select>
<update id="grade.lectcomplete.abs2" parameterClass="lect">
update lect l
inner join (
select c.lectno,c.completeno,c.completetime
from (
select t1.*
,concat('제 ',t1.cyear,t1.code1,lpad(ifnull(t2.seqNo,0) + t1.rno , 6, 0), ' 호') as completeno
from (
select l.lectno
,date_format(l.edate,'%Y') cyear
,pcg.cgcode code2
,case when cm.cshape = 1 then 'F' else 'N' end code1
,case when te.cremark = '1' then te.refcode
when tm.cremark in ('1','2','3','4') then tm.refcode
else '05' end code3
,case when cm.cshape = 0 then now()
when cm.cshape = 1 then l.edate <!--cm.setime-->
else cs.eend end completetime
,row_number() over(partition by date_format(l.cdt,'%Y') order by l.cdt) rno
from lect l
inner join cm cm on cm.cmno = l.cmno
inner join pay p on p.payno = l.payno
left outer join pplog pl on pl.pplno = p.pplno
inner join cg cg on cg.cgno = cm.cgno
inner join cg pcg on pcg.cgno = cg.pcgno
left outer join comcode tm on tm.isuse=1 and tm.ccode = pl.typeman
left outer join comcode te on te.isuse=1 and te.ccode = pl.typeedu
left outer join cminningscd cs on cs.cmisno = pl.cmisno
where l.lectno in ($lectnos$)
) t1
left outer join (
select date_format(l.edate, '%Y') cyear
,max(substring(replace(replace(l.completeno, ' - N105 - ','N'), '호',''), -6)) seqNo
from lect l
group by date_format(l.edate, '%Y')
) t2 on t2.cyear = t1.cyear
) c
) b
set l.uno = #uno#
,l.udt = now()
,l.uip= #uip#
,l.iscomplete=1
,l.completetime=b.completetime
,l.completeno=b.completeno
where l.lectno = b.lectno
</update>
<!--#수료처리 #xodus-->
<update id="grade.lectcomplete2" parameterClass="hashtable">
update lect a
inner join (
<include refid="grade.query"></include>
) b on b.lectno=a.lectno
inner join (
select c.lectno,c.completeno,c.completetime
from (
select t1.*
<!--,concat('제 ',t1.cyear,' - ',t1.code1,t1.code2,t1.code3,' - ',lpad(ifnull(t2.seqNo,0)+ t1.rno , 6, 0)) completeno-->
<!--,concat('제 ',t1.cyear,t1.code1,lpad(ifnull(t2.seqNo,0)+ t1.rno , 6, 0)) completeno-->
,concat('제 ',t1.cyear,t1.code1,lpad(ifnull(t2.seqNo,0) + t1.rno , 6, 0), ' 호') as completeno
from (
select l.lectno
,date_format(l.edate,'%Y') cyear
,pcg.cgcode code2
,case when cm.cshape = 1 then 'F' else 'N' end code1
,case when te.cremark = '1' then te.refcode
when tm.cremark in ('1','2','3','4') then tm.refcode
else '05' end code3
,case when cm.cshape = 0 then now()
when cm.cshape = 1 then l.edate <!--cm.setime-->
else cs.eend end completetime
, l.iscomplete
,row_number() over(partition by date_format(l.cdt,'%Y') order by l.cdt) rno
from lect l
inner join cm cm on cm.cmno = l.cmno
inner join pay p on p.payno = l.payno
left outer join pplog pl on pl.pplno = p.pplno
inner join cg cg on cg.cgno = cm.cgno
inner join cg pcg on pcg.cgno = cg.pcgno
left outer join comcode tm on tm.isuse=1 and tm.ccode = pl.typeman
left outer join comcode te on te.isuse=1 and te.ccode = pl.typeedu
left outer join cminningscd cs on cs.cmisno = pl.cmisno
where 1=1
<isNotNull property="lectnos">and l.lectno in ($lectnos$)</isNotNull>
<isNotNull property="lectno">and l.lectno =#lectno#</isNotNull>
) t1
left outer join (
select date_format(l.edate, '%Y') cyear
,max(substring(replace(replace(l.completeno, ' - N105 - ','N'), '호',''), -6)) seqNo
from lect l
group by date_format(l.edate, '%Y')
) t2 on t2.cyear = t1.cyear
) c
) c on c.lectno = a.lectno
inner join cm d on d.cmno = a.cmno
set a.udt=<include refid="sql.now"></include>,a.uno=#uno#,a.uip=#uip#
,a.iscomplete=b.ispass
,a.apoint=b.apoint
,a.mpoint=a.mpoint
,a.fpoint=b.fpoint
,a.spoint=b.spoint
,a.dpoint=b.dpoint
,a.tpoint=b.apoint+b.mpoint+b.fpoint+b.spoint+b.dpoint
,a.completetime = case when b.ispass = 1 then c.completetime else null end
,a.completeno = c.completeno
where a.status=1 and a.ischanged=0 and a.lectno = c.lectno and ifnull(a.iscomplete, 0) &lt;> 1
<isNotNull property="cmno">and a.cmno = #cmno#</isNotNull>
<isNotNull property="lectno">and a.lectno = #lectno#</isNotNull>
<isNotNull property="cmnos">and a.cmno in ($cmnos$)</isNotNull>
<isNotNull property="lectnos">and a.lectno in ($lectnos$)</isNotNull>
</update>
<!--수료 취소 #xodus-->
<update id="grade.lectcomplete.cancel" parameterClass="hashtable">
update lect
set <include refid="sql.up"></include>
,iscomplete=0
,completetime=null
where lectno=#lectno# and ifnull(iscomplete,0) &lt;> 1
</update>
<update id="grade.lectcomplete.cancel2" parameterClass="hashtable">
update lect
set <include refid="sql.up"></include>
,iscomplete=0
,completetime=null
where lectno=#lectno# and ifnull(iscomplete,0)
</update>
<select id ="grade.nocompletelect" parameterClass="string" resultClass="lect">
select distinct c.lectno , b.cmno
,case when c.iscomplete = 1 then 1 else 0 end iscomplete
from lect a2
inner join cm a on a.cmno = a2.cmno
inner join cm b on b.cmno = a.cmno
inner join lect c on c.cmno = b.cmno
where c.status=1 and c.ischanged=0 and a2.lectno in ($lectnos$)
group by b.cmno,c.lectno
</select>
<select id ="grade.nocompletelectcm" parameterClass="string" resultClass="lect">
select distinct c.lectno , b.cmno
,case when c.iscomplete = 1 then 1 else 0 end iscomplete
from lect a2
inner join cm a on a.cmno = a2.cmno
inner join cm b on b.cmno = a.cmno
inner join lect c on c.cmno = b.cmno
where c.status=1 and c.ischanged=0 and a2.cmno in ($cmnos$)
group by b.cmno,c.lectno
</select>
<select id="grade.ispass" parameterClass="hashtable" resultClass="lect">
select a.*
from (
<include refid="grade.query"></include>
) a
<dynamic prepend="where">
<isNotNull property="lectno" prepend="and">a.lectno = #lectno#</isNotNull>
</dynamic>
</select>
</statements>
</sqlMap>