YNICTE/Dao/MyBatis/Maps/Lect.xml

2752 lines
141 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>
<typeAlias alias="lect" type="NP.Model.Lect, NP.Model" />
<typeAlias alias="scdlect" type="NP.Model.SCDLect, NP.Model" />
<typeAlias alias="lectrs" type="NP.Model.LectRS, NP.Model" />
<typeAlias alias="edub2b" type="NP.Model.EduB2B, NP.Model" />
<typeAlias alias="lectinning" type="NP.Model.LectInning, NP.Model" />
<typeAlias alias="lectinningpage" type="NP.Model.LectInningPage, NP.Model" />
<typeAlias alias="pagelog" type="NP.Model.PageLog, NP.Model" />
<typeAlias alias="lectex" type="NP.Model.LectEX, NP.Model" />
<typeAlias alias="lectexq" type="NP.Model.LectEXQ, NP.Model" />
<typeAlias alias="lectsd" type="NP.Model.LectSD, NP.Model" />
<typeAlias alias="lectsdboard" type="NP.Model.LectSDBoard, NP.Model" />
<typeAlias alias="exam" type="NP.Model.Exam, NP.Model"/>
<typeAlias alias="examuser" type="NP.Model.ExamUser, NP.Model"/>
<typeAlias alias="examuserrenew" type="NP.Model.ExamUserRenew, NP.Model"/>
</alias>
<cacheModels>
<cacheModel id="lectCache" implementation="LRU" >
<flushInterval hours="1" />
<property name="CacheSize" value="1000" />
</cacheModel>
</cacheModels>
<resultMaps></resultMaps>
<statements>
<select id="lect.lects.my" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,a.cmno,a.payno,a.pino,a.userno,a.status,a.iscomplete,a.isrebate,a.cdt
,pi.pstatus,pi.rstatus
,b.cname,b.classno,b.studytime,b.sstime,b.setime
,bc.refcode
,cg.cgname
,pcg.cgcode pcgcode
,c.tyear,c.tseq
,u.username,u.uduty
,case when uc.cname = '기타' then u.ccpositionetc else uc.cname end ccpositionname
,ua.asname
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">a.cdt desc</isNull>) rno
,count(a.cdt) over() pagetotalcount
from lect a
left outer join payitem pi on pi.pino=a.pino
inner join cm b on b.cmno=a.cmno
left outer join comcode bc on bc.ccode=b.certgradecc
inner join cg cg on cg.cgno=b.cgno
inner join cg pcg on pcg.cgno=cg.pcgno
inner join term c on c.tmno=b.tmno
inner join users u on u.userno=a.userno
left outer join comcode uc on uc.ccode=u.ccposition
left outer join assign ua on ua.asno=u.asno
where a.ischanged=0
<isNotNull property="lectno">and a.lectno=#lectno#</isNotNull>
<isNotNull property="userno">and a.userno=#userno#</isNotNull>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="lect.lects.my2" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,a.cmno,a.payno,a.pino,a.userno,a.status,a.iscomplete,a.isrebate,a.cdt, a.cmisno
,pi.pstatus,pi.rstatus
,b.cname,b.classno,b.studytime,b.sstime,b.setime
,bc.refcode
,cg.cgname
,pcg.cgcode pcgcode
,c.tyear,c.tseq
,u.username,u.uduty
,case when uc.cname = '기타' then u.ccpositionetc else uc.cname end ccpositionname
,ua.asname
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">a.cdt desc</isNull>) rno
,count(a.cdt) over() pagetotalcount
, b.cshape, ifnull(e.scdtype, 1) as scdtype
<!--, (case when e.scdtype is null then h.cname else g.cname end ) as studyplace-->
, g.cname as studyplace
, (case when b.cshape=0 then '온라인' when b.cshape=1 then '교육장교육' else '온라인교육' end) cshapename
, a.edate
from lect a
left outer join payitem pi on pi.pino=a.pino
inner join cm b on b.cmno=a.cmno
left outer join comcode bc on bc.ccode=b.certgradecc
inner join cg cg on cg.cgno=b.cgno
inner join cg pcg on pcg.cgno=cg.pcgno
inner join term c on c.tmno=b.tmno
inner join users u on u.userno=a.userno
left outer join comcode uc on uc.ccode=u.ccposition
left outer join assign ua on ua.asno=u.asno
left outer join (
select lectno,max(cmino) as cmino
from lectinning t
group by lectno
) d on a.lectno = d.lectno
left outer join cminning e on b.cmno = e.cmno and d.cmino = d.cmino and e.userno = a.userno
left outer join cminningscd f on a.cmisno = f.cmisno
left outer join comcode g on f.studyplace = g.ccode
left outer join comcode h on b.studyplace = h.ccode
where a.ischanged=0
<isNotNull property="lectno">and a.lectno=#lectno#</isNotNull>
<isNotNull property="userno">and a.userno=#userno#</isNotNull>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="lect.check.lectinning.hascminning" parameterClass="hashtable" resultClass="long">
select a.lectno
from lect a
inner join lectinning b on b.lectno=a.lectno
<dynamic prepend="where">
<isNotNull property="cmno" prepend="and">a.cmno=#cmno#</isNotNull>
</dynamic>
limit 1
</select>
<select id="lect.check.count" parameterClass="hashtable" resultClass="int">
select count(a.lectno)
from lect a
<dynamic prepend="where">
<isNotNull property="cmno" prepend="and">a.cmno=#cmno#</isNotNull>
<isNotNull property="status" prepend="and">a.status in (1,2,3,4)</isNotNull>
<isNotNull property="ispc" prepend="and">a.ispc=#ispc#</isNotNull>
</dynamic>
</select>
<select id="lect.users" parameterClass="hashtable" resultClass="lect">
select a.lectno,a.cmno,a.payno,a.pino,a.userno,a.status,a.iscomplete,a.orgcmno,a.attrate,a.isrebate,a.ispc
,b.username,b.isacceptemail
,CAST(AES_DECRYPT(UNHEX(b.email), <include refid="sql.digest"></include>) AS char) email
,CAST(AES_DECRYPT(UNHEX(b.mobile), <include refid="sql.digest"></include>) AS char) mobile
from lect a
inner join users b on b.userno=a.userno and b.status=1
<dynamic prepend="where">
<isNotNull property="cmno" prepend="and">a.cmno=#cmno#</isNotNull>
<isNotNull property="status" prepend="and">a.status=#status#</isNotNull>
</dynamic>
order by b.username
</select>
<select id="lect.cms" parameterClass="hashtable" resultClass="cm">
select
a.cmno,c.tyear,c.tseq,d.cgname,b.quota,b.cshape,b.cname,b.classno,b.rstime,b.retime,b.sstime,b.setime,a.countlect,a.countstandby,a.rno,a.pagetotalcount,a.countnoresult,a.countfail,a.countcomplete,a.countsuccess,a.countstanbypay,a.countstanbydraw,a.countstanbyaccept,b.studydays,code.cname studyplacename
from (
select a.cmno,a.countlect,a.countstandby,a.rno,a.pagetotalcount,a.countnoresult,a.countfail,a.countcomplete,a.countsuccess,a.countstanbypay,a.countstanbydraw,a.countstanbyaccept
from (
select b.cmno,count(u.userno) countlect
,sum(case when ifnull(d.isready,0) = 1 and d.status = 3 then 1 else 0 end) countstandby
,sum(case when d.iscomplete is null then 1 else 0 end) countnoresult
,sum(d.iscomplete) countcomplete
,sum(case when d.iscomplete=0 then 1 else 0 end) countfail
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">case when b.retime &lt; now() then 1 else 2 end,b.retime desc</isNull>) rno
,sum(case when d.lectno is not null and p.pstatus=1 then 1 else 0 end) countsuccess
,sum(case when d.lectno is not null and p.pstatus=21 then 1 else 0 end) countstanbypay
,sum(case when d.lectno is not null and p.pstatus = 22 then 1 else 0 end) countstanbydraw
,sum(case when d.lectno is not null and p.pstatus = 55 then 1 else 0 end) countstanbyaccept
,count(a.cdt) over() pagetotalcount
from term a
inner join cm b on b.tmno=a.tmno <isNotNull property="cshape">and b.cshape=#cshape#</isNotNull> <isNotNull property="cnamelike">and b.cname like concat('%',#cnamelike#,'%')</isNotNull>
inner join cg c on c.cgno=b.cgno
<isNotNull property="islect">
left outer join lect d on d.cmno=b.cmno and (d.status &lt; 5 or d.status = 6) and d.ischanged=0
left outer join users u on u.userno = d.userno
inner join payitem pi on pi.pino=d.pino
inner join pay p on p.payno=pi.payno
</isNotNull>
<isNull property="islect">
inner join lect d on d.cmno=b.cmno <isNotNull property="status">and d.status=#status#</isNotNull> and (d.status &lt; 5 or d.status = 6) and d.ischanged=0
left outer join users u on d.userno = u.userno and u.status = 1
inner join payitem pi on pi.pino=d.pino
inner join pay p on p.payno=pi.payno
</isNull>
<isNotNull property="profno">
inner join cmprof pr on pr.cmno=b.cmno and pr.userno=#profno#
</isNotNull>
<dynamic prepend="where">
<isNotNull property="tyear" prepend="and">a.tyear=#tyear#</isNotNull>
<isNotNull property="tmno" prepend="and">a.tmno=#tmno#</isNotNull>
<isNotNull property="islect" prepend="and" >b.isdel=0 and (u.status in (1,99) or u.status is null)</isNotNull>
<!--<isNotNull property="isallday" prepend="and">
date_format(b.retime,'%Y%m%d') = '20991231'
or
(
date_format(b.sstime,'%Y%m%d') &gt;= date_format(#sstime#,'%Y%m%d')
and date_format(b.setime,'%Y%m%d') &lt;= date_format(#setime#,'%Y%m%d')
)
</isNotNull>-->
<isNotNull property="sstime" prepend="and">
date_format(b.sstime,'%Y%m%d') &gt;= date_format(#sstime#,'%Y%m%d') or date_format(b.retime,'%Y%m%d') = '20991231'
</isNotNull>
<isNotNull property="setime" prepend="and">
date_format(b.setime,'%Y%m%d') &lt;= date_format(#setime#,'%Y%m%d') or date_format(b.retime,'%Y%m%d') = '20991231'
</isNotNull>
</dynamic>
group by b.cmno
<isNotNull property="nocomplete">having sum(d.iscomplete) &lt; 1</isNotNull>
<isNotNull property="hascomplete">having sum(d.iscomplete) &gt; 0</isNotNull>
<isNotNull property="result">having sum(case when d.iscomplete is not null then 1 else 0 end) &gt; 0</isNotNull>
<isNotNull property="noresult">having sum(case when d.iscomplete is null then 1 else 0 end) &gt; 0</isNotNull>
) a
<include refid="sql.pagedynamic"></include>
) a
inner join cm b on b.cmno=a.cmno
inner join term c on c.tmno=b.tmno
inner join cg d on d.cgno=b.cgno
left join comcode code on code.cgroup = 'studyplace' and code.ccode = b.studyplace
order by a.rno
</select>
<select id="lect.lects" parameterClass="hashtable" resultClass="lect">
select a.lectno,a.cdt,a.status,a.userno,a.oktime,a.cmisno,a.cmno
,af.fileurl,af.fileno,af.orgname
,f.asname,e.asno
,d.username cnoname,d.userid cnoid
,e.username,e.status ustatus,e.depart,e.userid,e.uduty
,e.kfcfyear,e.isassignuser,e.edus
,CAST(AES_DECRYPT(UNHEX(e.email), <include refid="sql.digest"></include>) AS char) email
,CAST(AES_DECRYPT(UNHEX(e.mobile), <include refid="sql.digest"></include>) AS char) mobile
,CAST(AES_DECRYPT(UNHEX(e.telno), <include refid="sql.digest"></include>) AS char) telno
,cc.cname ccpositionname
,c.pstatus,c.payno,c.userno payuserno
,b.rstatus
,a2.rstime,a2.retime,a.sdate sstime,a.edate setime,a2.cshape,a2.studydays
,a.sdate,a.edate,a.isrebate,a.iscomplete
,scd.estart,scd.eend,scd.studyplace
,pp.typeman, pp.typeedu, pp.typegrade, pp.typejob, pp.typejobitem, pp.pplno
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">a.payno,a.pino</isNull>) rno
,count(a.cdt) over() pagetotalcount
,a2.typejobitem as typejobitems
from lect a
inner join cm a2 on a2.cmno=a.cmno
left outer join fileinfo af on af.fgno=a.fgno and af.isdel=0
inner join payitem b on b.pino=a.pino
inner join pay c on c.payno=b.payno
<isNotNull property="paystatusnotin">and c.pstatus not in ($paystatusnotin$)</isNotNull>
<isNotNull property="paystatus">and c.pstatus=#paystatus#</isNotNull>
<isNotNull property="rstatus">and c.rstatus=#rstatus#</isNotNull>
inner join users d on d.userno=c.userno
inner join users e on e.userno=a.userno and e.status in (1,99)
left outer join comcode cc on cc.ccode=e.ccposition
left outer join assign f on f.asno=e.asno
left outer join payrfditem rfdi on rfdi.pino=a.pino
left outer join payrfd rfd on rfd.rfdno=rfdi.rfdno
left outer join cminningscd scd on a.cmisno = scd.cmisno
left outer join pplog pp on c.pplno = pp.pplno
where a.ischanged=0
<isNotNull property="isready" prepend="and">ifnull(a.isready,0)=#isready#</isNotNull>
<isNotNull property="lectno" prepend="and">a.lectno=#lectno#</isNotNull>
<isNotNull property="cmno" prepend="and">a.cmno=#cmno#</isNotNull>
<isNotNull property="status" prepend="and">a.status=#status#</isNotNull>
<isNotNull property="statusin" prepend="and">a.status in ($statusin$)</isNotNull>
<isNotNull property="refundcall">and (rfd.rstatus = 0 and rfdi.rfdno is not null)</isNotNull>
<isNotNull property="searchtext" prepend="and">
(d.username like concat('%', #searchtext#,'%')
or
d.userid like concat('%', #searchtext#,'%'))
</isNotNull>
<isNotNull property="scdestart" prepend="and">
date_format(scd.estart,'%Y%m%d') = date_format(#scdestart#,'%Y%m%d')
</isNotNull>
<isNotNull property="payno" prepend="and">a.payno=#payno#</isNotNull>
and (rfdi.rfdno is null or rfd.rfdno is not null)
order by rno
</select>
<select id="lect.lects.att" parameterClass="int" resultClass="lect">
select a.lectno,a.cdt,a.status
,p.pstatus,p.rstatus
,pu.username cnoname,pu.userid cnoid
,b.username,b.userid,b.uduty
,CAST(AES_DECRYPT(UNHEX(b.email), <include refid="sql.digest"></include>) AS char) email
,CAST(AES_DECRYPT(UNHEX(b.mobile), <include refid="sql.digest"></include>) AS char) mobile
,CAST(AES_DECRYPT(UNHEX(b.telno), <include refid="sql.digest"></include>) AS char) telno
,b.depart,b.kfcfyear,b.isassignuser,b.edus
,(select cname from comcode com where com.ccode = pp.typeman) as typemanname
,(select cname from comcode com where com.ccode = pp.typeedu) as typeeduname
,(select cname from comcode com where com.ccode = pp.typegrade) as typegradename
,(select cname from comcode com where com.ccode = pp.typejob) as typejobname
,scd.estart,scd.eend
,cc.cname ccpositionname
,c.isjoin,c.asname
,row_number() over(order by b.username) rno
from lect a
inner join pay p on p.payno=a.payno
<isNotNull property="paystatusnotin">and p.pstatus not in ($paystatusnotin$)</isNotNull>
inner join users pu on pu.userno=p.userno
inner join users b on b.userno=a.userno <isNotNull property="status"> and b.status=#status#</isNotNull>
left outer join comcode cc on cc.ccode=b.ccposition
left outer join assign c on c.asno=b.asno
left outer join pplog pp on p.pplno = pp.pplno
left outer join cminningscd scd on a.cmisno = scd.cmisno
where a.cmno=#cmno#
<isNotNull property="isready"> and ifnull(a.isready,0) = #isready# </isNotNull>
<isNotNull property="status"> and a.status &lt; 5 and p.pstatus in (1,22 ) </isNotNull>
<isNotNull property="statusin" prepend="and">a.status in ($statusin$)</isNotNull>
and a.ischanged=0
order by rno
</select>
<update id="lect.sedate.change" parameterClass="hashtable">
update lect set <include refid="sql.up"></include>,sdate =#sdate#,edate=#edate# where lectno=#lectno# and status = 1
</update>
<update id="lect.status" parameterClass="hashtable">
update lect set <include refid="sql.up"></include>,status=#status#,oktime=case when oktime is null and #status# = 4 and status&lt;&gt;4 then now() else oktime end where lectno=#lectno# and status in (3,4,5);
<isGreaterThan property="status" compareValue="3">
update pay a
inner join lect b on b.lectno=#lectno# and b.payno=a.payno and b.status in (4,5)
set a.pstatus=case when b.status = 4 then 21 else 52 end
where a.pstatus=51;
update payitem a
inner join lect b on b.lectno=#lectno# and b.pino=a.pino and b.status in (4,5)
set a.pstatus=case when b.status=4 then 21 else 52 end
where a.pstatus=51
</isGreaterThan>
</update>
<update id="lect.status3" parameterClass="hashtable">
update lect set <include refid="sql.up"></include>,status=#status#,oktime=case when oktime is null and #status# = 4 and status=6 then now() else oktime end where lectno=#lectno# and status in (4,5,6);
<isGreaterThan property="status" compareValue="3">
<isLessThan property="status" compareValue="6">
update pay a
inner join lect b on b.lectno=#lectno# and b.payno=a.payno and b.status in (4,5)
set a.pstatus=case when b.status = 4 then 21 else 52 end
where a.pstatus=55;
update payitem a
inner join lect b on b.lectno=#lectno# and b.pino=a.pino and b.status in (4,5)
set a.pstatus=case when b.status=4 then 21 else 52 end
where a.pstatus=55
</isLessThan>
</isGreaterThan>
</update>
<update id="lect.status2" parameterClass="hashtable">
update lect set <include refid="sql.up"></include>
,status = #status#
,oktime = now()
where lectno in ($lectnos$) and status in (4,5,6);
update pay a
inner join lect b on b.lectno in ($lectnos$) and b.payno=a.payno and b.status in (4,5,6)
set a.pstatus=case when b.status = 6 then 55 when b.status = 4 then 21 else 52 end
where a.pstatus in (55, 21, 52);
update payitem a
inner join lect b on b.lectno in ($lectnos$) and b.pino=a.pino and b.status in (4,5,6)
set a.pstatus=case when b.status = 6 then 55 when b.status = 4 then 21 else 52 end
where a.pstatus in (55, 21, 52)
</update>
<select id="lect.cmforchange" parameterClass="int" resultClass="cm">
select b.cmno,b.cname,b.classno,b.cshape
,t.tyear,t.tseq
from cm a
inner join cm b on b.ismaster=0 and b.pcmno=a.pcmno and b.cmno &lt;&gt; #cmno# and b.setime is not null and b.setime &gt; now() and b.isuse=1 and b.isdel=0
inner join term t on t.tmno=b.tmno
left outer join lect c on c.cmno=b.cmno and c.status in (1,3,4) and c.ischanged=0
where a.cmno=#cmno#
group by b.cmno,b.cname,b.classno,b.quota,b.cshape
,t.tyear,t.tseq
having b.quota = 0 or b.quota &gt; count(c.lectno)
order by b.cname,b.classno,b.setime
</select>
<update id="lect.lectchange" parameterClass="hashtable">
update lect set <include refid="sql.up"></include>
,ischanged=1
where lectno=#lectno#;
insert into lect (cmno,payno,pino,userno,status,iscomplete,orgcmno,attrate,isrebate,ispc,isjoin,fgno,ischanged,<include refid="sql.inc"></include>)
select #cmno#,payno,pino,userno,status,null,cmno,0,isrebate,ispc,isjoin,fgno,0,<include refid="sql.inv"></include>
from lect a
where a.lectno=#lectno#
</update>
<select id="lect.scdlects" parameterClass="hashtable" resultClass="scdlect">
select a.scdno,a.dday,a.dtime,a.istalk,a.isemail,a.issms,a.isuse
from scdlect a
order by a.scdno
</select>
<update id="lect.scdlect.save" parameterClass="scdlect">
insert into scdlectlog (userno,scdno,dday,dtime,istalk,isemail,issms,isuse,<include refid="sql.inc"></include>)
select #uno#,scdno,dday,dtime,istalk,isemail,issms,isuse,<include refid="sql.inv"></include>
from scdlect;
update scdlect a
inner join (
<iterate property="Ds" open="" conjunction="union all" close=""> select #Ds[].scdno# scdno,#Ds[].dday# dday,#Ds[].dtime# dtime,#Ds[].istalk# istalk,#Ds[].isemail# isemail,#Ds[].issms# issms,#Ds[].isuse# isuse </iterate>
) b on b.scdno=a.scdno
set a.dday=b.dday,a.dtime=b.dtime,a.istalk=b.istalk,a.isemail=b.isemail,a.issms=b.issms,a.isuse=b.isuse,a.udt=<include refid="sql.now"></include>,a.uno=#uno#,a.uip=#uip#;
insert into scdlect (scdno,dday,dtime,istalk,isemail,issms,isuse,<include refid="sql.inc"></include>)
select a.scdno,a.dday,a.dtime,a.istalk,a.isemail,a.issms,a.isuse,<include refid="sql.inv"></include>
from (
<iterate property="Ds" open="" conjunction="union all" close=""> select #Ds[].scdno# scdno,#Ds[].dday# dday,#Ds[].dtime# dtime,#Ds[].istalk# istalk,#Ds[].isemail# isemail,#Ds[].issms# issms,#Ds[].isuse# isuse </iterate>
) a
left outer join scdlect b on b.scdno=a.scdno
where b.scdno is null
</update>
<!--<sql id="sql.encourages" parameterClass="hashtable" resultClass="scdlect">
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
,null place
from scdlect a
inner join cm b on b.ismaster=0 and date_format(b.setime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.cshape in (0,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.attrate &lt; 80 and c.status=1 and c.ischanged=0
inner join users d on d.userno=c.userno and d.status=1
where a.scdno &lt; 3 and a.isuse=1 and a.dtime=#dtime#
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
,null place
from scdlect a
inner join cm b on b.ismaster=0 and date_format(b.setime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.cshape in (0,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0
inner join users d on d.userno=c.userno and d.status=1
inner join cmex e on e.cmno=c.cmno and e.extype=case when a.scdno=3 then 0 else 1 end and e.isdel=0
left outer join lectex f on f.lectno=c.lectno and f.exno=e.exno
where a.scdno &gt; 2 and a.scdno &lt; 5 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
,null place
from scdlect a
inner join cm b on b.ismaster=0 and date_format(b.setime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.cshape in (0,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0
inner join users d on d.userno=c.userno and d.status=1
inner join cmsd e on e.cmno=c.cmno and e.sdtype=0 and e.isdel=0
left outer join lectsd f on f.lectno=c.lectno and f.sdno=e.sdno
where a.scdno=5 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
,null place
from scdlect a
inner join cm b on b.ismaster=0 and date_format(b.setime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.cshape in (0,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0
inner join users d on d.userno=c.userno and d.status=1
inner join cmsd e on e.cmno=c.cmno and e.sdtype=1 and e.isdel=0
left outer join lectsd f on f.lectno=c.lectno and f.sdno=e.sdno
where a.scdno=6 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
,null place
from scdlect a
inner join cm b on b.ismaster=0 and date_format(b.setime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.cshape in (0,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0
inner join users d on d.userno=c.userno and d.status=1
inner join cmrs e on e.cmno=c.cmno and e.rstype=0 and e.isdel=0
left outer join lectrs f on f.lectno=c.lectno and f.rsno=e.rsno
where a.scdno=7 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,b.sstime
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char),CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char)
,bc.cname place
from scdlect a
inner join cm b on b.ismaster=0 and date_format(b.sstime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.cshape =1 and b.isuse=1 and b.isdel=0
left outer join comcode bc on bc.ccode=b.studyplace
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0
inner join users d on d.userno=c.userno and d.status=1
where a.scdno=8 and a.isuse=1 and a.dtime=#dtime#
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.exno cmexno,b.exname cname,b.estime
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char),CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char)
,b.elocation place
from scdlect a
inner join exam b on date_format(b.estime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.isopen=1
inner join examuser c on c.exno=b.exno and c.status=1 and c.pstatus=1
inner join users d on d.userno=c.userno and d.status=1
where a.scdno=9 and a.isuse=1 and a.dtime=#dtime#
</sql>-->
<sql id="sql.encourages" parameterClass="hashtable" resultClass="scdlect">
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,null etime,null studyplace,null days
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
from scdlect a
inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.attrate &lt; 80 and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d')
inner join users d on d.userno=c.userno and d.status=1
where a.scdno &lt; 3 and a.isuse=1 and a.dtime=#dtime#
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,null etime,null studyplace,null days
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
from scdlect a
inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d')
inner join users d on d.userno=c.userno and d.status=1
inner join cmex e on e.cmno=c.cmno and e.extype=case when a.scdno=3 then 0 else 1 end and e.isdel=0
left outer join lectex f on f.lectno=c.lectno and f.exno=e.exno
where a.scdno &gt; 2 and a.scdno &lt; 5 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,null etime,null studyplace,null days
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
from scdlect a
inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d')
inner join users d on d.userno=c.userno and d.status=1
inner join cmsd e on e.cmno=c.cmno and e.sdtype=0 and e.isdel=0
left outer join lectsd f on f.lectno=c.lectno and f.sdno=e.sdno
where a.scdno=5 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,null etime,null studyplace,null days
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
from scdlect a
inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d')
inner join users d on d.userno=c.userno and d.status=1
inner join cmsd e on e.cmno=c.cmno and e.sdtype=1 and e.isdel=0
left outer join lectsd f on f.lectno=c.lectno and f.sdno=e.sdno
where a.scdno=6 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,null stime
,null etime,null studyplace,null days
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char) mobile
from scdlect a
inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d')
inner join users d on d.userno=c.userno and d.status=1
inner join cmrs e on e.cmno=c.cmno and e.rstype=0 and e.isdel=0
left outer join lectrs f on f.lectno=c.lectno and f.rsno=e.rsno
where a.scdno=7 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.cmno cmexno,b.cname,c.sdate stime
,c.edate etime,e.cname studyplace,b.studytime days
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char),CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char)
from scdlect a
inner join cm b on b.ismaster=0 and b.cshape =1 and b.isuse=1 and b.isdel=0
inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.sdate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d')
inner join users d on d.userno=c.userno and d.status=1
left outer join comcode e on e.ccode = b.studyplace
where a.scdno=8 and a.isuse=1 and a.dtime=#dtime#
union all
select a.scdno,a.dday,a.istalk,a.isemail,a.issms
,d.userno,d.username
,b.exno cmexno,b.exname cname,b.estime stime
,null etime,null studyplace,null days
,CAST(AES_DECRYPT(UNHEX(d.email), <include refid="sql.digest"></include>) AS char),CAST(AES_DECRYPT(UNHEX(d.mobile), <include refid="sql.digest"></include>) AS char)
from scdlect a
inner join exam b on date_format(b.estime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.isopen=1
inner join examuser c on c.exno=b.exno and c.status=1 and c.pstatus=1
inner join users d on d.userno=c.userno and d.status=1
where a.scdno=9 and a.isuse=1 and a.dtime=#dtime#
</sql>
<select id="lect.encourages" parameterClass="hashtable" resultClass="scdlect">
insert into alarms (userno,atime,scdno,cmexno,dday,isdel,<include refid="sql.inc"></include>)
select a.userno,<include refid="sql.now"></include>,a.scdno,a.cmexno,a.dday,0,<include refid="sql.inv"></include>
from (
<include refid="sql.encourages"></include>
) a;
<include refid="sql.encourages"></include>
</select>
<select id="lect.cmrss" parameterClass="hashtable" resultClass="cmrs">
select a.*
from (
select a.*
,row_number() over(order by a.tyear desc,a.tseq,a.cname,a.classno ) rno
,count(a.cdt) over() pagetotalcount
from (
select d.rsno,b.cmno,a.tyear,a.tseq,c.cgname,b.cshape,b.cname,b.classno,b.sstime,b.setime,d.rstype
,count(distinct e.lectno) countlect,count(distinct f.lectno) countok,a.cdt
from term a
inner join cm b on b.ismaster=0 and b.tmno=a.tmno <isNotNull property="cshape">and b.cshape=#cshape#</isNotNull> <isNotNull property="cnamelike">and b.cname like concat('%',#cnamelike#,'%')</isNotNull>
inner join cg c on c.cgno=b.cgno
inner join cmrs d on d.cmno=b.cmno <isNotNull property="rstype">and d.rstype=#rstype#</isNotNull> and d.isdel=0
inner join lect e on e.cmno=d.cmno and e.status =1 and e.ischanged=0
left outer join lectrs f on f.lectno=e.lectno and f.rsno=d.rsno
<dynamic prepend="where">
<isNotNull property="tyear" prepend="and">a.tyear=#tyear#</isNotNull>
<isNotNull property="tmno" prepend="and">a.tmno=#tmno#</isNotNull>
</dynamic>
group by d.rsno,b.cmno,a.tyear,a.tseq,c.cgname,b.cshape,b.cname,b.classno,b.sstime,b.setime,d.rstype
) a
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="lect.cmrs" parameterClass="int" resultClass="cmrs">
select a.rsno,a.rstype,a2.rscno,a2.rscname,b.cshape,b.cname,b.classno,b.rstime,b.retime,b.sstime,b.setime
,c.tyear,c.tseq
,count(distinct d.lectno) countlect,count(distinct e.lectno) countok
from cmrs a
inner join rsc a2 on a2.rscno=a.rscno
inner join cm b on b.cmno=a.cmno
inner join term c on c.tmno=b.tmno
inner join lect d on d.cmno=b.cmno and d.status=1 and d.ischanged=0
left outer join lectrs e on e.lectno=d.lectno and e.rsno=a.rsno
where a.rsno=#rsno#
group by a.rsno,a.rstype,a2.rscno,a2.rscname,b.cshape,b.cname,b.classno,b.rstime,b.retime,b.sstime,b.setime,c.tyear,c.tseq
</select>
<select id="lect.cmrscqs" parameterClass="int" resultClass="rscq">
select a.rsno
,b.rscqno
,c.qno,c.qtext,c.atype
,d.qino,d.qitext
,sum(case when concat(',',e.atext,',') like concat('%,',d.qino,',%') then 1 else 0 end) scount
,count(e.atext) acount
,group_concat(e.atext order by e.cdt separator '<![CDATA[<br />]]>') atext
from cmrs a
inner join rscq b on b.rscno=a.rscno
inner join question c on c.qno=b.qno
left outer join questionitem d on d.qno=c.qno and d.isdel=0
left outer join lectrs e on e.rsno=a.rsno and e.rscqno=b.rscqno
where a.rsno=#rsno#
group by a.rsno
,b.rscqno
,c.qno,c.qtext,c.atype
,d.qino,d.qitext
order by b.dseq,b.qno,d.qino
</select>
<select id="lect.rscq" parameterClass="int" resultClass="rscq">
select a.rscqno,a.qno,q.atype,qi.qino,row_number() over(partition by qi.qno order by qi.qino) rno
from rscq a
inner join question q on q.qno=a.qno
left outer join questionitem qi on qi.qno=q.qno and qi.isdel=0
where a.rscno=#rscno#
order by a.dseq
</select>
<select id="lect.lectrss" parameterClass="int" resultClass="lectrs">
select a.rsno,b.lectno,c.rscno,c.rscqno,u.username,u.userid,uc.cname ccpositionname,b.isrebate,c.cdt,c.atext
from cmrs a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users u on u.userno=b.userno
left outer join assign ua on ua.asno=u.asno
left outer join comcode uc on uc.ccode=u.ccposition
inner join lectrs c on c.lectno=b.lectno and c.rsno=a.rsno
inner join rscq rq on rq.rscqno=c.rscqno
inner join question q on q.qno=rq.qno
where a.rsno=#rsno#
order by u.username,u.userno,rq.dseq,rq.rscqno
</select>
<select id="lect.edub2bs" parameterClass="hashtable" resultClass="edub2b">
select a.*
from (
select a.eduno,a.etype,a.userno,a.edate,a.esubject,a.etarget,a.ecount,a.eplace,a.ecomment,a.compname,a.ceoname,a.brno,a.addr,a.btype,a.bkind,a.manname
,CAST(AES_DECRYPT(UNHEX(a.email), <include refid="sql.digest"></include>) AS char) email
,CAST(AES_DECRYPT(UNHEX(a.telno), <include refid="sql.digest"></include>) AS char) telno
,a.fgno,a.cdt
,b.userid,b.username
,c.asname
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">a.cdt desc</isNull>) rno
,count(a.cdt) over() pagetotalcount
from edub2b a
inner join users b on b.userno=a.userno
left outer join assign c on c.asno=b.asno
<dynamic prepend="where">
<isNotNull property="eduno" prepend="and">a.eduno=#eduno#</isNotNull>
</dynamic>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="lect.checkuser" parameterClass="hashtable" resultClass="lect">
select a.lectno,a.cmno,a.userno,b.userid
from lect a
inner join users b on b.userno = a.userno
<dynamic prepend="where">
<isNotNull property="cmno" prepend="and">a.cmno = #cmno#</isNotNull>
<isNotNull property="userno" prepend="and">a.userno=#userno#</isNotNull>
<isNotEmpty property="cmnos" prepend="and">a.cmno in ($cmnos$)</isNotEmpty>
<isNotEmpty property="userids" prepend="and">b.userid in ($userids$)</isNotEmpty>
</dynamic>
and a.ischanged=0 and a.status &lt; 5
</select>
<select id="lect.checkuser2" parameterClass="hashtable" resultClass="lect">
select a.lectno,a.cmno,a.userno
from lect a
where
<isNotEmpty property="cmnos">a.cmno in ($cmnos$) and</isNotEmpty> a.ischanged=0 and a.status &lt; 5
</select>
<select id="lect.checkuser3" parameterClass="hashtable" resultClass="lect">
select a.userno,a.lectno,a.cmno
from lect a
where
<isNotEmpty property="cmnos">a.cmno in ($cmnos$) and</isNotEmpty> a.ischanged=0 and a.status &lt; 5
group by a.userno
</select>
<select id="lect.attoffs" parameterClass="datetime" resultClass="cminning">
select c.tyear,c.tseq
,a.cmno,a.cname,a.classno
,b.cmino,b.week,b.iseq,b.ititle,b.idate,b.ist,b.iet
,d.username
from cm a
inner join cminning b on b.cmno=a.cmno and b.isonline=0 and b.idate=#edate#
inner join term c on c.tmno=a.tmno
left outer join users d on d.userno=b.userno
where a.ismaster=0 and a.sstime &lt;=#edate# and a.setime &gt;= #edate# and a.isuse=1 and a.isdel=0
order by b.iet,a.cname
</select>
<select id="lect.cminning" parameterClass="long" resultClass="cminning">
select c.tyear,c.tseq
,b.cshape,b.cname,b.classno
,a.cmino,a.ititle,a.idate,a.ist,a.iet
from cminning a
inner join cm b on b.cmno=a.cmno
inner join term c on c.tmno=b.tmno
where a.cmino=#cmino#
</select>
<select id="lect.lectinnings.foratt" parameterClass="long" resultClass="lectinning">
select a.cmino,b.lectno,c.userno
,ca.asname,c.username,c.userid,d.stime,d.etime,d.istatus
,row_number() over(order by d.udt desc,c.username) rno
,count(a.cdt) over() pagetotalcount
from cminning a
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
left outer join assign ca on ca.asno=c.asno
left outer join lectinning d on d.lectno=b.lectno and d.cmino=a.cmino
where a.cmino=#cmino#
order by rno
</select>
<select id="lect.lectinnings.forattscd_old" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,c.cmino,b.cmno,b.cshape,b.cname,b2.isoffabs
,a.isrebate,p.payoktime,a.iscomplete, a.stime
,a.sdate,a.edate
,a.cmisno
,d.sseq,f.cname studyplacename
,d.estart,d.eend
,e.userno,e.userid, e.username
,g.istatus
<!--,row_number() over(order by a.cdt desc,e.username) rno-->
,row_number() over(order by e.username) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join pay p on p.payno = a.payno
inner join cm b on b.cmno = a.cmno
inner join cmev b2 on b2.cmno = b.cmno
inner join cminning c on c.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno and d.cmino = c.cmino
inner join users e on e.userno = a.userno
left outer join comcode f on f.ccode = d.studyplace and f.isuse =1
left outer join lectinning g on g.cmino = c.cmino and g.lectno = a.lectno
where a.status=1 and a.ischanged=0 and c.isscd=1 and c.scdtype=0 and b.cshape=2
<isNotNull property="edate">and date_format(a.edate,'%Y%m%d') = date_format(#edate#,'%Y%m%d')</isNotNull>
<isNotNull property="cname">and b.cname like concat('%',#cname#,'%')</isNotNull>
<isNotNull property="studyplace">and d.studyplace = #studyplace#</isNotNull>
<isNotNull property="stringval17">
<isEqual property="stringval17" compareValue="0">and g.istatus is null</isEqual>
<isEqual property="stringval17" compareValue="2">and g.istatus = 2 </isEqual>
</isNotNull>
<isNotEmpty property="searchtext">
<isEqual property="searchtype" compareValue="usernamestr">and e.username like concat('%',#searchtext#,'%')</isEqual>
<isEqual property="searchtype" compareValue="useridstr">and e.userid like concat('%',#searchtext#,'%')</isEqual>
</isNotEmpty>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="lect.lectinnings.forattscd" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,c.cmino,c.cmno,c.cshape,c.cname,b2.isoffabs
,a.isrebate,p.payoktime,a.iscomplete, a.stime
,a.sdate,a.edate, date_format(g.stime, '%Y-%m-%d') zstring3
,a.cmisno
,c.sseq,f.cname studyplacename
,c.estart,c.eend
,e.userno,e.userid, e.username
,g.istatus
,row_number() over(order by e.username) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join pay p on p.payno = a.payno
inner join (
select c.cmno, c.cshape, c.cname, ci.cmino,d.cmisno,d.sseq,d.estart,d.eend,d.studyplace
from cm c
inner join cminning ci on c.cmno = ci.cmno
inner join cminningscd d on d.cmino = ci.cmino
where c.cshape=2 and ci.isscd=1 and ci.scdtype=0
) c on c.cmno = a.cmno and c.cmisno = a.cmisno
inner join cmev b2 on b2.cmno = c.cmno
inner join users e on e.userno = a.userno
left outer join comcode f on f.ccode = c.studyplace and f.isuse =1
left outer join lectinning g on g.cmino = c.cmino and g.lectno = a.lectno
where a.status=1 and a.ischanged=0
<isNotNull property="edate">and date_format(a.edate,'%Y%m%d') = date_format(#edate#,'%Y%m%d')</isNotNull>
<isNotNull property="cname">and c.cname like concat('%',#cname#,'%')</isNotNull>
<isNotNull property="studyplace">and c.studyplace = #studyplace#</isNotNull>
<isNotNull property="stringval17">
<isEqual property="stringval17" compareValue="0">and g.istatus is null</isEqual>
<isEqual property="stringval17" compareValue="2">and g.istatus = 2 </isEqual>
</isNotNull>
<isNotEmpty property="searchtext">
<isEqual property="searchtype" compareValue="usernamestr">and e.username like concat('%',#searchtext#,'%')</isEqual>
<isEqual property="searchtype" compareValue="useridstr">and e.userid like concat('%',#searchtext#,'%')</isEqual>
</isNotEmpty>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="lect.lectinnings.forattscd2_old" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,c.cmino,b.cmno,b.cshape,b.cname,b2.isoffabs
,a.isrebate,p.payoktime,a.iscomplete, a.stime
,a.sdate,a.edate
,a.cmisno
,d.sseq,f.cname studyplacename
,d.estart,d.eend
,e.userno,e.userid, e.username
,g.istatus
,cc.cname zstring0
,cc2.cname zstring1
,cc3.cname zstring2
,CAST(AES_DECRYPT(UNHEX(e.mobile), 'np123@!') AS CHAR) mobile
,CAST(AES_DECRYPT(UNHEX(e.email), 'np123@!') AS CHAR) email
,row_number() over(order by a.cdt desc,e.username) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join pay p on p.payno = a.payno
INNER JOIN pplog pp ON p.pplno = pp.pplno
INNER JOIN comcode cc ON pp.typeman = cc.ccode
INNER JOIN comcode cc2 ON pp.typeedu = cc2.ccode
INNER JOIN comcode cc3 ON pp.typegrade = cc3.ccode
inner join cm b on b.cmno = a.cmno
inner join cmev b2 on b2.cmno = b.cmno
inner join cminning c on c.cmno = b.cmno
left outer join cminningscd d on d.cmisno = a.cmisno and d.cmino = c.cmino
inner join users e on e.userno = a.userno
left outer join comcode f on f.ccode = d.studyplace and f.isuse =1
left outer join lectinning g on g.cmino = c.cmino and g.lectno = a.lectno
where a.status=1 and a.ischanged=0 and c.isscd=1 and c.scdtype=0 and b.cshape=2
<isNotNull property="edate">and date_format(a.edate,'%Y%m%d') = date_format(#edate#,'%Y%m%d')</isNotNull>
<isNotNull property="cname">and b.cname like concat('%',#cname#,'%')</isNotNull>
<isNotNull property="studyplace">and d.studyplace = #studyplace#</isNotNull>
<isNotNull property="stringval17">
<isEqual property="stringval17" compareValue="0">and g.istatus is null</isEqual>
<isEqual property="stringval17" compareValue="2">and g.istatus = 2 </isEqual>
</isNotNull>
<isNotEmpty property="searchtext">
<isEqual property="searchtype" compareValue="usernamestr">and e.username like concat('%',#searchtext#,'%')</isEqual>
<isEqual property="searchtype" compareValue="useridstr">and e.userid like concat('%',#searchtext#,'%')</isEqual>
</isNotEmpty>
) a
<include refid="sql.pagedynamic"></include>
order by a.username
</select>
<select id="lect.lectinnings.forattscd2" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,c.cmino,c.cmno,c.cshape,c.cname,b2.isoffabs
,a.isrebate,p.payoktime,a.iscomplete, a.stime
,a.sdate,a.edate, date_format(g.stime, '%Y-%m-%d') zstring3
,a.cmisno
,c.sseq,f.cname studyplacename
,c.estart,c.eend
,e.userno,e.userid, e.username
,CAST(AES_DECRYPT(UNHEX(e.mobile), <include refid="sql.digest"></include>) AS char) mobile
,CAST(AES_DECRYPT(UNHEX(e.email), <include refid="sql.digest"></include>) AS char) email
,g.istatus
,cc.cname zstring0
,cc2.cname zstring1
,cc3.cname zstring2
,(case when cc4.cname is null then '-' else cc4.cname end) zstring4
,(case when cc5.cname is null then '-' else cc5.cname end) zstring5
,row_number() over(order by a.cdt desc,e.username) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join pay p on p.payno = a.payno
INNER JOIN pplog pp ON p.pplno = pp.pplno
INNER JOIN comcode cc ON pp.typeman = cc.ccode
INNER JOIN comcode cc2 ON pp.typeedu = cc2.ccode
INNER JOIN comcode cc3 ON pp.typegrade = cc3.ccode
LEFT OUTER JOIN comcode cc4 ON pp.typejob = cc4.ccode
LEFT OUTER JOIN comcode cc5 ON pp.typejobitem = cc5.ccode
inner join (
select c.cmno, c.cshape, c.cname, ci.cmino,d.cmisno,d.sseq,d.estart,d.eend,d.studyplace
from cm c
inner join cminning ci on c.cmno = ci.cmno
inner join cminningscd d on d.cmino = ci.cmino
where c.ismaster = 0 and c.isdel = 0 and c.cshape=2 and ci.isscd=1 and ci.scdtype=0
) c on c.cmno = a.cmno and c.cmisno = a.cmisno
inner join cmev b2 on b2.cmno = c.cmno
inner join users e on e.userno = a.userno
left outer join comcode f on f.ccode = c.studyplace and f.isuse =1
left outer join lectinning g on g.cmino = c.cmino and g.lectno = a.lectno
where a.status=1 and a.ischanged=0
<isNotNull property="edate">and date_format(a.edate,'%Y%m%d') = date_format(#edate#,'%Y%m%d')</isNotNull>
<isNotNull property="cname">and c.cname like concat('%',#cname#,'%')</isNotNull>
<isNotNull property="studyplace">and c.studyplace = #studyplace#</isNotNull>
<isNotNull property="stringval17">
<isEqual property="stringval17" compareValue="0">and g.istatus is null</isEqual>
<isEqual property="stringval17" compareValue="2">and g.istatus = 2 </isEqual>
</isNotNull>
<isNotEmpty property="searchtext">
<isEqual property="searchtype" compareValue="usernamestr">and e.username like concat('%',#searchtext#,'%')</isEqual>
<isEqual property="searchtype" compareValue="useridstr">and e.userid like concat('%',#searchtext#,'%')</isEqual>
</isNotEmpty>
) a
<include refid="sql.pagedynamic"></include>
order by a.username
</select>
<select id="lect.atts" parameterClass="hashtable" resultClass="lect">
select a.lectno,a.isrebate,a.attrate,a.stime,a.sip,a.etime,a.eip
,b.username,b.userid,b.userno
,c.asname
,count(d.cmino) countinning
,sum(case when e.istatus=2 then 1 else 0 end) countattok
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">b.username</isNull>) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join users b on b.userno=a.userno and b.status &lt; 99
left outer join assign c on c.asno=b.asno
inner join cminning d on d.cmno=a.cmno
left outer join lectinning e on e.lectno=a.lectno and e.cmino=d.cmino
where a.ischanged=0 <isNotNull property="cmno">and a.cmno=#cmno#</isNotNull> <isNotNull property="status">and a.status=#status#</isNotNull> <isNotNull property="isrebate">and a.isrebate=#isrebate#</isNotNull>
group by a.lectno,a.isrebate,a.attrate,a.stime,a.sip,a.etime,a.eip
,b.username,b.userid
,c.asname
order by rno
</select>
<select id="lect.lectinnings.bycmino" parameterClass="hashtable" resultClass="lectinning">
select b.lectno,a.cmino
,u.userno,u.userid,u.username
,ua.asname
,c.stime,c.etime,c.istatus
,c.udt,d.userid unoid
,row_number() over(order by u.username) rno
,count(b.lectno) over() pagetotalcount
from cminning a
inner join lect b on b.cmno=a.cmno and b.status=1 and b.ischanged=0
inner join users u on u.userno=b.userno and u.status=1
left outer join assign ua on ua.asno=u.asno
left outer join lectinning c on c.lectno=b.lectno and c.cmino=a.cmino
left outer join users d on d.userno = c.uno
left outer join cminningscd e on e.cmisno = b.cmisno
<dynamic prepend="where">
<isNotNull property="cmino" prepend="and">a.cmino=#cmino#</isNotNull>
<isNotNull property="cmisno" prepend="and">e.cmisno=#cmisno#</isNotNull>
<isNotNull property="lectno" prepend="and">b.lectno=#lectno#</isNotNull>
</dynamic>
group by b.lectno,a.cmino,u.userno,u.userid,u.username,ua.asname,c.stime,c.etime,c.istatus
order by u.username
</select>
<select id="lect.lectinningpages" parameterClass="hashtable" resultClass="lectinningpage">
select a.lectno,b.cmino,d.logno,f.sstime,f.setime
,b.iseq,b.isonline,b.ititle,b.atime
,c.istatus,c.totstudy litotstudy,c.stime listime,c.etime lietime,c.sip lisip,c.eip lieip,c.ispcs liispcs,c.ispce liispce
,c.statustime,c.statusreason,c.statususerno,cu.username statususername,cu.userid statususerid
,d.totstudy,d.stime,d.etime,d.sip,d.eip,d.ispc,d.ispc ispcs,d.webkitinfo
,e.pseq,e.cpno
from lect a
inner join cminning b on b.cmno=a.cmno
inner join cm f on f.cmno=a.cmno
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino
left outer join users cu on cu.userno=c.statususerno
left outer join lectinningpage d on d.lectno=c.lectno and d.cmino=c.cmino
left outer join ctpage e on e.cpno=d.cpno
<dynamic prepend="where">
<isNotNull property="lectno" prepend="and">a.lectno=#lectno#</isNotNull>
<isNotNull property="userno" prepend="and">a.userno=#userno#</isNotNull>
<isNotNull property="isscd" prepend="and">ifnull(b.isscd,0)=#isscd#</isNotNull>
</dynamic>
order by b.iseq,d.stime
</select>
<select id="lect.pagelogs" parameterClass="hashtable" resultClass="pagelog">
select a.cdt,a.uip,b.pagename,a.loginfo
from pagelog a
left outer join menupage b on b.pno=a.pno
<dynamic prepend="where">
<isNotNull property="logsite" prepend="and">a.logsite=#logsite#</isNotNull>
<isNotNull property="userno" prepend="and">a.userno=#userno#</isNotNull>
<isNotNull property="start" prepend="and">a.cdt between #start# and #end#</isNotNull>
<isNotNull property="from" prepend="and">a.cdt &gt;= #from#</isNotNull>
<isNotNull property="to" prepend="and">a.cdt &lt;= #to#</isNotNull>
</dynamic>
union all
select a.cdt,a.uip,'로그인', '로그인'
from loginlog a
<dynamic prepend="where">
<isNotNull property="logsite" prepend="and">a.logsite=#logsite#</isNotNull>
<isNotNull property="userno" prepend="and">a.userno=#userno# and a.loginstatus &lt; 2</isNotNull>
<isNotNull property="start" prepend="and">a.cdt between #start# and #end#</isNotNull>
<isNotNull property="from" prepend="and">a.cdt &gt;= #from#</isNotNull>
<isNotNull property="to" prepend="and">a.cdt &lt;= #to#</isNotNull>
</dynamic>
order by cdt desc
</select>
<select id="lect.pagelogs_page_OLD" parameterClass="hashtable" resultClass="pagelog">
select a.cdt,a.uip,b.pagename,a.loginfo
from (
select cdt, uip, loginfo, pno
from pagelog a
where a.userno=#userno# and a.logsite=#logsite# and DATE_FORMAT(a.cdt, '%Y-%m-%d') = #start#
) a
left outer join menupage b on b.pno=a.pno
<dynamic prepend="where">
<isNotNull property="logsite" prepend="and"></isNotNull>
<isNotNull property="userno" prepend="and"></isNotNull>
<isNotNull property="from" prepend="and">a.cdt &gt;= #from#</isNotNull>
<isNotNull property="to" prepend="and">a.cdt &lt;= #to#</isNotNull>
</dynamic>
</select>
<select id="lect.pagelogs_page" parameterClass="hashtable" resultClass="pagelog">
select a.cdt,a.uip,b.pagename,a.loginfo
from menupage b
inner join (
select cdt, uip, loginfo, pno
from pagelog a
where a.userno=#userno# and a.logsite=#logsite# and a.cdt between #start# and #end#
) a on b.pno=a.pno
</select>
<select id="lect.pagelogs_login" parameterClass="hashtable" resultClass="pagelog">
select a.cdt,a.uip,'로그인' as pagename, '로그인' as loginfo
from loginlog a
<dynamic prepend="where">
<isNotNull property="logsite" prepend="and">a.logsite=#logsite#</isNotNull>
<isNotNull property="userno" prepend="and">a.userno=#userno# and a.loginstatus &lt; 2</isNotNull>
<isNotNull property="start" prepend="and">a.cdt between #start# and #end#</isNotNull>
<isNotNull property="from" prepend="and">a.cdt &gt;= #from#</isNotNull>
<isNotNull property="to" prepend="and">a.cdt &lt;= #to#</isNotNull>
</dynamic>
<!--order by cdt desc-->
</select>
<select id="lect.lectexes" parameterClass="hashtable" resultClass="lectex">
select a.*
from (
select a.lectno,a.userno,a.cmno,a.isrebate
,b.exno
,c.estart,c.eend,c.eip,c.tpoint,c.recount,c.entercount,c.cblock
,d.username,d.userid
,e.asname, b.extype
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">d.username</isNull>) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join cmex b on b.isdel=0 <isNotNull property="exno">and b.exno=#exno#</isNotNull>
left outer join lectex c on c.lectno=a.lectno and c.exno=b.exno
inner join users d on d.userno=a.userno and d.status &lt; 99
left outer join assign e on e.asno=d.asno
where a.status=1 and a.ischanged=0
<isNotNull property="extype">and b.extype = #extype#</isNotNull>
<isNotNull property="cmno">and a.cmno = #cmno#</isNotNull>
<isNotNull property="isrebate">and a.isrebate=#isrebate#</isNotNull>
<isNotNull property="estate">
<isEqual property="estate" compareValue="0">and c.estart is null</isEqual>
<isEqual property="estate" compareValue="1">and c.estart is not null and c.eend is null</isEqual>
<isEqual property="estate" compareValue="2">and c.eend is not null</isEqual>
</isNotNull>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<select id="lect.lectexes.all" parameterClass="hashtable" resultClass="lectex">
select a.*
from (
select a.lectno,a.userno,a.cmno,a.isrebate
,p.payoktime,a.sdate,a.edate
,b.exno,b.exname,b.extype <!--#xodus 수정완료 성적처리관련 컬럼 추가-->
,b2.cshape,b2.cname
,c.estart,c.eend,c.eip,c.tpoint,c.recount,c.entercount,c.cblock,c.isbyadmin
,d.username,d.userid
,e.asname
,f.cmisno,f.estart lestart,f.eend leend,f.sseq
,g.cname studyplacename
,a.iscomplete
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">d.username</isNull>) rno
,count(a.cdt) over() pagetotalcount
,cast(AES_DECRYPT(UNHEX(d.mobile), 'np123@!' ) as char) as mobile
from lect a
inner join cmex b on b.isdel=0 and b.cmno = a.cmno
inner join cm b2 on b2.cmno = b.cmno
inner join pay p on p.payno = a.payno
left outer join lectex c on c.lectno = a.lectno and c.exno =b.exno
inner join users d on d.userno = a.userno
left outer join assign e on e.asno = d.asno
left outer join cminningscd f on f.cmisno = a.cmisno
left outer join comcode g on g.ccode = f.studyplace and g.isuse =1
left outer join cmev ce on b2.cmno=ce.cmno
left outer join lect l on a.lectno = l.lectno
left outer join cminningscd cis on l.cmisno = cis.cmisno
left outer join lectinning li on a.lectno = li.lectno and cis.cmino = li.cmino
where a.status = 1 and a.ischanged=0 and d.status &lt; 99
<isNotNull property="extype">and b.extype = #extype#</isNotNull>
<isNotNull property="cmno">and a.cmno = #cmno#</isNotNull>
<isNotNull property="isrebate">and a.isrebate=#isrebate#</isNotNull>
<isNotNull property="edate">and (date_format((case when b2.cshape = 2 and f.eend is not null then f.eend else a.edate end),'%Y-%m-%d') = #edate#)</isNotNull>
<isNotNull property="edate1">and ((case when b2.cshape = 2 and f.eend is not null then f.eend else a.edate end) >= #edate1#)</isNotNull>
<isNotNull property="edate2">and ((case when b2.cshape = 2 and f.eend is not null then f.eend else a.edate end) &lt;= #edate2#)</isNotNull>
<isNotNull property="cshape">and b2.cshape = #cshape#</isNotNull>
<isNotEmpty property="cname">and b2.cname like concat('%',#cname#,'%')</isNotEmpty>
<isNotEmpty property="cnamestr">and b2.cname like concat('%',#cname#,'%')</isNotEmpty>
<isNotNull property="iscomplete">and ifnull(a.iscomplete,0) = #iscomplete#</isNotNull>
<isNotNull property="studyplace">and f.studyplace = #studyplace#</isNotNull>
<isNotEmpty property="usernamestr">and d.username like concat('%',#usernamestr#,'%')</isNotEmpty>
<isNotEmpty property="useridstr">and d.userid like concat('%',#useridstr#,'%')</isNotEmpty>
<isNotEmpty property="searchtext">
<isEqual property="searchtype" compareValue="usernamestr">and d.username like concat('%',#usernamestr#,'%')</isEqual>
<isEqual property="searchtype" compareValue="useridstr">and d.userid like concat('%',#useridstr#,'%')</isEqual>
</isNotEmpty>
<isNotNull property="estate">
<isEqual property="estate" compareValue="0">and c.estart is null</isEqual>
<isEqual property="estate" compareValue="1">and c.estart is not null and c.eend is null</isEqual>
<isEqual property="estate" compareValue="2">and c.eend is not null</isEqual>
</isNotNull>
<isNotEmpty property="sdateall">and (case when b2.cshape = 0 and a.isrebate = 0 then p.payoktime else a.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
<isNotEmpty property="edateall">and (case when b2.cshape = 2 then f.eend else a.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
<isNotEmpty property="asname">and e.asname like concat('%',#asname#,'%')</isNotEmpty>
<isNotNull property="mobile">and (cast(AES_DECRYPT(UNHEX(d.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%'))</isNotNull>
<isNotNull property="attendance" >
<!--해당없음-->
<isEqual property="attendance" compareValue="1" prepend="and"> ifnull(ce.isoffabs,0) = 0</isEqual>
<!--대상자(미입력/출석/결석)-->
<isEqual property="attendance" compareValue="2" prepend="and"> ifnull(ce.isoffabs,0) = 1</isEqual>
<!--미입력-->
<isEqual property="attendance" compareValue="3" prepend="and">ifnull(ce.isoffabs,0) = 1 and li.istatus is null </isEqual>
<!--출석-->
<isEqual property="attendance" compareValue="4" prepend="and">ifnull(ce.isoffabs,0) = 1 and ifnull(li.istatus,-1) = 2</isEqual>
<!--결석-->
<isEqual property="attendance" compareValue="5" prepend="and">ifnull(ce.isoffabs,0) = 1 and ifnull(li.istatus,-1) = 0</isEqual>
</isNotNull>
<isNotNull property="isbyadmin">
<isEqual property="isbyadmin" compareValue="-1" prepend="and">(c.isbyadmin = 0 or c.isbyadmin is null) and c.estart is null</isEqual>
<isEqual property="isbyadmin" compareValue="0" prepend="and">c.isbyadmin = 0 and c.estart is not null</isEqual>
<isEqual property="isbyadmin" compareValue="1" prepend="and">c.isbyadmin = 1</isEqual>
</isNotNull>
) a
<include refid="sql.pagedynamic"></include>
order by a.rno
</select>
<!--문제 점수만 변경, 문제 재설정변경-->
<update id="lect.reexam" parameterClass="hashtable">
insert into lectexrelog(lectno,exno,estart,eend,eip,<include refid="sql.inc"></include>)
select a.lectno lectno,a.exno exno,a.estart estart,a.eend eend,a.eip eip,<include refid="sql.inv"></include>
from lectex a
where a.lectno=#lectno# and a.exno=#exno#;
update lectex set estart=null,eend=null,eip=null,tpoint=0,recount=recount+1,entercount=0,cblock=0,isbyadmin=0 where lectno=#lectno# and exno=#exno#;
update lectexq a
inner join cmex b on b.exno=a.exno <!--and b.eqtype=0-->
set a.atext=null,a.qinos=null,a.cpoint=0,a.iscorrect=null
where a.lectno=#lectno# and a.exno=#exno#;
<!--최종평가, lect.fpoint, 진도율 환산점수 update #xodus 수정완료-->
<!--최종평가 수정일 경우, 영남은 중간 평가가 없다. 중간평가는 ce.extype = 0 -->
<!--최종평가-->
<isEqual property="extype" compareValue="1">
update lect a
inner join lectex le on a.lectno = le.lectno
inner join cmex ce on a.cmno = ce.cmno and ce.isdel = 0
inner join cmev cv on a.cmno = cv.cmno
set a.udt=<include refid="sql.now"></include>,a.uno=#uno#,a.uip=#uip#
,a.fpoint = 0
,a.exfpoint = null
<!--,a.tpoint = round(0 + ifnull(a.apoint, 0) + ifnull(a.spoint, 0) + ifnull(a.dpoint, 0) + ifnull(a.mpoint, 0),0)-->
where ce.extype = 1 and a.lectno=#lectno# and le.exno = #exno#;
</isEqual>
<!--중간평가-->
<isEqual property="extype" compareValue="0">
update lect a
inner join lectex le on a.lectno = le.lectno
inner join cmex ce on a.cmno = ce.cmno and ce.isdel = 0
inner join cmev cv on a.cmno = cv.cmno
set a.udt=<include refid="sql.now"></include>,a.uno=#uno#,a.uip=#uip#
,a.mpoint = 0
,a.exmpoint = null
<!--,a.tpoint = round(0 + ifnull(a.apoint, 0) + ifnull(a.spoint, 0) + ifnull(a.dpoint, 0) + ifnull(a.fpoint, 0))-->
where ce.extype = 0 and a.lectno=#lectno# and le.exno = #exno#;
</isEqual>
</update>
<update id="lect.reexam.manulset" parameterClass="hashtable">
<!--update lectex set estart=null,eend=null,eip=null,tpoint=0,recount=recount+1,entercount=0,cblock=0 where lectno=#lectno# and exno=#exno#;-->
<isNotEmpty property="qdiff">
update cmexlayer
set qcount=#qcount#
where exno=#exno# and qdiff=#qdiff#;
</isNotEmpty>
lectno not in (
select le.lectno
from lectexq le
inner join lect l on le.lectno = l.lectno
inner join users u on l.userno = u.userno
where le.exno = #exno#
group by le.lectno, u.userid
)
delete from lectexq where lectno=#lectno# and exno=#exno# and eqno in (
select a.eqno
from (
select b.eqno
from cmex a
inner join lectexq b on b.lectno=#lectno# and b.exno=a.exno
where a.exno=#exno# and a.eqtype=1
) a
);
insert into lectexq (lectno,exno,eqno,cpoint,dpoint,qseq,<include refid="sql.inc"></include>)
select a.lectno,a.exno,a.eqno,0,a.rpoint,row_number() over(order by case when a.israndq=0 then a.qseq else rand() end),<include refid="sql.inv"></include>
from (
select a.*
from (
select a.lectno,a.exno,d.eqno,c.israndq,el.qcount,d.rpoint,d.qseq,rank() over(partition by el.qdiff,el.cc1,el.cc2,el.cc3,el.cc4,el.cc5 order by rand()) rank
from (select #lectno# lectno, #exno# exno) a
left outer join lectex b on b.lectno=a.lectno and b.exno=a.exno
inner join cmex c on c.exno=a.exno and c.eqtype=1
inner join cmexlayer el on el.exno=c.exno and el.qcount &gt; 0
inner join cmexq d on d.exno=el.exno
inner join question e on e.qno=d.qno
and e.qdiff=case when el.qdiff=0 then e.qdiff else el.qdiff end
and e.cc1=case when el.cc1=0 then e.cc1 else el.cc1 end
and e.cc2=case when el.cc2=0 then e.cc2 else el.cc2 end
and e.cc3=case when el.cc3=0 then e.cc3 else el.cc3 end
and e.cc4=case when el.cc4=0 then e.cc4 else el.cc4 end
and e.cc5=case when el.cc5=0 then e.cc5 else el.cc5 end
<!--where b.lectno is null-->
) a
where a.rank &lt;= a.qcount
) a
order by rand()
</update>
<select id="lect.reexam.log" parameterClass="hashtable" resultClass="lectex">
select a.*
from (
select a.estart,eend,eip
,row_number() over(order by a.cdt desc) rno
,count(a.cno) over() pagetotalcount
from lectexrelog a
where a.lectno=#lectno# and a.exno=#exno#
) a
order by a.rno
</select>
<sql id="lectexcreate">
insert into lectexq (lectno,exno,eqno,cpoint,dpoint,qseq,<include refid="sql.inc"></include>)
select a.lectno,a.exno,d.eqno,0,d.rpoint,row_number() over(order by case when c.israndq=0 then d.qseq else rand() * d.qseq end),<include refid="sql.inv"></include>
from (select #lectno# lectno, #exno# exno) a
<isNotNull property="userno">
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
</isNotNull>
left outer join lectex b on b.lectno=a.lectno and b.exno=a.exno
inner join cmex c on c.exno=a.exno and c.eqtype=0
inner join cmexq d on d.exno=c.exno
inner join (
select count(b.lectno) exq
from (select 1 col1) a
left outer join lectexq b on b.lectno=#lectno# and b.exno=#exno#
) z on z.exq &lt; 1
where b.lectno is null
order by rand();
insert into lectexq (lectno,exno,eqno,cpoint,dpoint,qseq,<include refid="sql.inc"></include>)
select a.lectno,a.exno,a.eqno,0,a.rpoint,row_number() over(order by case when a.israndq=0 then a.qseq else rand() end),<include refid="sql.inv"></include>
from (
select a.lectno,a.exno,d.eqno,d.rpoint,el.qcount,c.israndq,d.qseq,rank() over(partition by el.qdiff, el.cc1, el.cc2, el.cc3, el.cc4, el.cc5 order by rand()) rank
from (select #lectno# lectno, #exno# exno) a
<isNotNull property="userno">
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
</isNotNull>
left outer join lectex b on b.lectno=a.lectno and b.exno=a.exno
inner join cmex c on c.exno=a.exno and c.eqtype=1
inner join cmexlayer el on el.exno=c.exno and el.qcount &gt; 0
inner join cmexq d on d.exno=el.exno
inner join question e on e.qno=d.qno
and e.qdiff=case when el.qdiff=0 then e.qdiff else el.qdiff end
and e.cc1=case when el.cc1=0 then e.cc1 else el.cc1 end
and e.cc2=case when el.cc2=0 then e.cc2 else el.cc2 end
and e.cc3=case when el.cc3=0 then e.cc3 else el.cc3 end
and e.cc4=case when el.cc4=0 then e.cc4 else el.cc4 end
and e.cc5=case when el.cc5=0 then e.cc5 else el.cc5 end
where b.lectno is null
) a
inner join (
select count(b.lectno) exq
from (select 1 col1) a
left outer join lectexq b on b.lectno=#lectno# and b.exno=#exno#
) z on z.exq &lt; 1
where a.rank &lt;= a.qcount
order by rand();
insert into lectex (lectno,exno,tpoint,recount,cblock,<include refid="sql.inc"></include>)
select a.lectno,a.exno,0,0,0,<include refid="sql.inv"></include>
from (select #lectno# lectno, #exno# exno) a
<isNotNull property="userno">
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
</isNotNull>
left outer join lectex b on b.lectno=a.lectno and b.exno=a.exno
where b.lectno is null;
</sql>
<select id="lect.lectex" parameterClass="hashtable" resultClass="lectex">
<include refid="lectexcreate"></include>
select a.exno,a.tpoint extpoint
,b.lectno,b.tpoint
,c.userno,c.username,c.userid
,d.asname
from cmex a
inner join lectex b on b.lectno=#lectno# and b.exno=a.exno
inner join lect b2 on b2.lectno=b.lectno
inner join users c on c.userno=b2.userno
left outer join assign d on d.asno=c.asno
where a.exno=#exno#
</select>
<select id="lect.lectexq" parameterClass="hashtable" resultClass="lectexq">
select a.lectno,a.exno,a.eqno,a.atext,a.qinos,a.cpoint,a.dpoint,a.iscorrect,a.qseq
,c.qno,c.atype,c.qtext
from lectexq a
inner join cmexq b on b.eqno=a.eqno
inner join question c on c.qno=b.qno
where a.lectno=#lectno# and a.exno=#exno#
order by a.qseq
</select>
<select id="lect.lectexqs" parameterClass="hashtable" resultClass="questionitem">
select c.qno
,sum(case when concat(',',a.atext,',') like concat('%,',c.qino,',%') then 1 else 0 end) countselect
,avg(case when concat(',',a.atext,',') like concat('%,',c.qino,',%') then 100 else 0 end) avgselect
from lectexq a
inner join cmexq b on b.eqno=a.eqno
inner join questionitem c on c.qno=b.qno
where a.exno=#exno# and a.eqno in ($eqnos$) and a.atext is not null
group by c.qno
</select>
<update id="lect.lectexq.point" parameterClass="hashtable">
update lectexq set <include refid="sql.up"></include>
,rechecktime=<include refid="sql.now"></include>
,cpoint=#cpoint#
<isNotNull property="iscorrect">,iscorrect = #iscorrect#</isNotNull>
where lectno=#lectno# and exno=#exno# and eqno=#eqno#;
update lectex a
inner join (
select lectno, sum(cpoint) tpoint
from lectexq where lectno=#lectno# and exno=#exno#
group by lectno
) b on b.lectno=a.lectno
set a.udt=<include refid="sql.now"></include>,a.uno=#uno#,a.uip=#uip#
,a.tpoint=b.tpoint
,a.rechecktime=<include refid="sql.now"></include>
where a.lectno=#lectno# and a.exno=#exno#;
<!--최종평가, lect.fpoint #xodus 수정완료-->
<!--최종평가 수정일 경우, 영남은 중간 평가가 없다 -->
<!--extype 최종평가:1, 중간평가:0-->
update lect l
inner join (
select l.lectno, round(avg(le.tpoint),1) as avgtpoint, sum(le.tpoint) sumpoint, ce.tpoint
from lect l
inner join cmex ce on l.cmno = ce.cmno and ce.extype = #extype# and ce.isdel = 0
left outer join lectex le on l.lectno = le.lectno and ce.exno = le.exno
where l.status = 1 and l.lectno = #lectno#
group by l.lectno
)t on l.lectno = t.lectno
inner join cmev cv on l.cmno = cv.cmno
set l.exfpoint = t.avgtpoint
, l.fpoint = round((t.avgtpoint / t.tpoint * 100) * cv.final / 100,1)
, l.udt = now()
, l.uno = #uno#
, l.uip=#uip#
where l.lectno = #lectno#;
</update>
<select id="lect.lectsds" parameterClass="hashtable" resultClass="lectsd">
select a.lectno,a.userno,a.cmno,a.isrebate
,b.sdno
,c.atext,c.fgno<isNotNull property="isproduct" >,round((f.MAX_SCORE/100)) copyrate</isNotNull>,c.iscopy,c.cpoint,c.feedb,c.submittime,c.submitip,c.checktime,c.checkip
,cf.fileno,cf.orgname,cf.fileurl
,d.username,d.userid
,e.asname
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">d.username</isNull>) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join cmsd b on b.isdel=0 and b.cmno = a.cmno <isNotNull property="sdno">and b.sdno=#sdno#</isNotNull>
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
left outer join fileinfo cf on cf.fgno=c.fgno and cf.isdel=0
inner join users d on d.userno=a.userno and d.status &lt; 99
left outer join assign e on e.asno=d.asno
<isNotNull property="isproduct">left outer join mch_source_v_lectsd_list f on f.DOC_ID = concat(b.sdno ,'_',a.lectno )</isNotNull>
where a.status=1 and a.ischanged=0
<isNotNull property="sdtype">and b.sdtype=#sdtype#</isNotNull>
<isNotNull property="cmno">and a.cmno=#cmno# </isNotNull>
<isNotNull property="isrebate">and a.isrebate=#isrebate#</isNotNull>
<isNotNull property="sdstate">
<isEqual property="sdstate" compareValue="0">and c.submittime is null</isEqual>
<isEqual property="sdstate" compareValue="1">and c.submittime is not null</isEqual>
</isNotNull>
order by rno
</select>
<select id="lect.lectsds.all" parameterClass="hashtable" resultClass="lectsd">
select a.*
from (
select a.lectno,a.userno,a.cmno,a.isrebate
,p.payoktime,a.sdate,a.edate
,g.cname,g.cshape
,b.sdno,b.tpoint
,c.atext<isNotNull property="isproduct">,round((f.MAX_SCORE/100)) copyrate</isNotNull>,c.iscopy,c.cpoint,c.feedb,c.submittime,c.submitip,c.checktime,c.checkip
,d.username,d.userid,d.usertype
,cast(AES_DECRYPT(UNHEX(d.mobile), 'np123@!' ) as char) as mobile
,e.asname
,h.cmisno,h.estart lestart,h.eend leend,h.sseq
,i.cname studyplacename
,a.iscomplete
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">d.username</isNull>) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join pay p on p.payno = a.payno
inner join cm g on g.cmno = a.cmno
inner join cmsd b on b.isdel=0 and b.cmno = a.cmno
left outer join lectsd c on c.lectno = a.lectno and c.sdno = b.sdno
inner join users d on d.userno = a.userno
left outer join assign e on e.asno = d.asno
<isNotNull property="isproduct">left outer join mch_source_v_lectsd_list f on f.DOC_ID = concat(b.sdno ,'_',a.lectno )</isNotNull>
left outer join cminningscd h on h.cmisno = a.cmisno
left outer join comcode i on i.ccode = h.studyplace and i.isuse=1
left outer join cmev ce on a.cmno=ce.cmno
<!--left outer join lect l on a.lectno = l.lectno-->
<!--left outer join cminningscd cis on a.cmisno = cis.cmisno-->
left outer join lectinning li on a.lectno = li.lectno and h.cmino = li.cmino
where a.status=1 and a.ischanged=0
<isNotNull property="edate">
<isNotEmpty property="edate">and date_format((case when g.cshape = 2 and h.eend is not null then h.eend else a.edate end),'%Y-%m-%d') = #edate#</isNotEmpty>
</isNotNull>
<isNotNull property="edate1">
<isNotEmpty property="edate1">and (case when g.cshape = 2 and h.eend is not null then h.eend else a.edate end) >= #edate1#</isNotEmpty>
</isNotNull>
<isNotNull property="edate2">
<isNotEmpty property="edate2">and (case when g.cshape = 2 and h.eend is not null then h.eend else a.edate end) &lt;= #edate2#</isNotEmpty>
</isNotNull>
<isNotNull property="cshape">
<isNotEmpty property="cshape">and g.cshape = #cshape#</isNotEmpty>
</isNotNull>
<isNotNull property="cname">
<isNotEmpty property="cname">and g.cname like concat('%',#cname#,'%')</isNotEmpty>
</isNotNull>
<isNotNull property="cnamestr">
<isNotEmpty property="cnamestr">and g.cname like concat('%',#cname#,'%')</isNotEmpty>
</isNotNull>
<isNotNull property="iscomplete">
<isNotEmpty property="iscomplete">and ifnull(a.iscomplete,0) = #iscomplete#</isNotEmpty>
</isNotNull>
<isNotNull property="studyplace">
<isNotEmpty property="studyplace">and h.studyplace = #studyplace#</isNotEmpty>
</isNotNull>
<isNotNull property="usernamestr">
<isNotEmpty property="usernamestr">and d.username like concat('%',#usernamestr#,'%')</isNotEmpty>
</isNotNull>
<isNotNull property="useridstr">
<isNotEmpty property="useridstr">and d.userid like concat('%',#useridstr#,'%')</isNotEmpty>
</isNotNull>
<isNotNull property="sdtype">
<isNotEmpty property="sdtype">and b.sdtype=#sdtype#</isNotEmpty>
</isNotNull>
<isNotNull property="cmno">
<isNotEmpty property="cmno">and a.cmno=#cmno# </isNotEmpty>
</isNotNull>
<isNotNull property="isrebate">
<isNotEmpty property="isrebate">and a.isrebate=#isrebate#</isNotEmpty>
</isNotNull>
<isNotNull property="sdstate">
<isNotEmpty property="sdstate">
<isEqual property="sdstate" compareValue="0">and c.submittime is null</isEqual>
<isEqual property="sdstate" compareValue="1">and c.submittime is not null</isEqual>
</isNotEmpty>
</isNotNull>
<isNotNull property="searchtext">
<isNotEmpty property="searchtext">
<isEqual property="searchtype" compareValue="usernamestr">and d.username like concat('%',#searchtext#,'%')</isEqual>
<isEqual property="searchtype" compareValue="useridstr">and d.userid like concat('%',#searchtext#,'%')</isEqual>
</isNotEmpty>
</isNotNull>
<isNotNull property="sdateall">
<isNotEmpty property="sdateall">and (case when g.cshape = 0 and a.isrebate = 0 then p.payoktime else a.sdate end) &gt;= date_format(#sdateall#,'%Y-%m-%d 00:00:00')</isNotEmpty>
</isNotNull>
<isNotNull property="edateall">
<isNotEmpty property="edateall">and (case when g.cshape = 2 then h.eend else a.edate end) &lt;= date_format(#edateall#,'%Y-%m-%d 23:59:59')</isNotEmpty>
</isNotNull>
<isNotNull property="asname">
<isNotEmpty property="asname">and e.asname like concat('%',#asname#,'%')</isNotEmpty>
</isNotNull>
<isNotNull property="mobile">
<isNotEmpty property="mobile">and cast(AES_DECRYPT(UNHEX(d.mobile), 'np123@!' ) as char) like concat('%',#mobile#,'%')</isNotEmpty>
</isNotNull>
<isNotNull property="ustatus">
<isNotEmpty property="ustatus">and d.status &lt; #ustatus#</isNotEmpty>
</isNotNull>
<isNotNull property="cpointchk">
<isEqual property="cpointchk" compareValue="0">and ifnull(c.cpoint,0) = 0</isEqual>
<isEqual property="cpointchk" compareValue="1">and ifnull(c.cpoint,0) > 0</isEqual>
<isNotEmpty property="ustatus">and d.status &lt; #ustatus#</isNotEmpty>
</isNotNull>
<isNotNull property="mosarate">
<isNotEmpty property="ustatus">and f.MAX_SCORE >= #mosarate#</isNotEmpty>
</isNotNull>
<isNotNull property="attendance" >
<!--해당없음-->
<isEqual property="attendance" compareValue="1" prepend="and"> ifnull(ce.isoffabs,0) = 0</isEqual>
<!--대상자(미입력/출석/결석)-->
<isEqual property="attendance" compareValue="2" prepend="and"> ifnull(ce.isoffabs,0) = 1</isEqual>
<!--미입력-->
<isEqual property="attendance" compareValue="3" prepend="and">ifnull(ce.isoffabs,0) = 1 and li.istatus is null </isEqual>
<!--출석-->
<isEqual property="attendance" compareValue="4" prepend="and">ifnull(ce.isoffabs,0) = 1 and ifnull(li.istatus,-1) = 2</isEqual>
<!--결석-->
<isEqual property="attendance" compareValue="5" prepend="and">ifnull(ce.isoffabs,0) = 1 and ifnull(li.istatus,-1) = 0</isEqual>
</isNotNull>
) a
<include refid="sql.pagedynamic"></include>
order by rno
</select>
<select id="lect.lectsd" parameterClass="hashtable" resultClass="lectsd">
select a.sdno,a.tpoint sdtpoint
,b.lectno,b.atext,b.fgno<isNotNull property="isproduct">,round((g.MAX_SCORE/100)) copyrate</isNotNull>
<!--,b.iscopy,b.cpoint,b.feedb, b.comment,b.submittime,b.checktime,c.userno,c.username-->
,b.iscopy,b.cpoint,b.feedb, b.memo,b.submittime,b.checktime,c.userno,c.username
,c.userid,d.asname,f.fileno,f.orgname,f.fileurl, b2.cmno
from cmsd a
inner join lect b2 on b2.lectno=#lectno#
inner join users c on c.userno=b2.userno
left outer join assign d on d.asno=c.asno
left outer join lectsd b on b.lectno=b2.lectno and b.sdno=a.sdno
left outer join fileinfo f on f.fgno=b.fgno and f.isdel=0
<isNotNull property="isproduct">left outer join mch_source_v_lectsd_list g on g.DOC_ID = concat(b.sdno ,'_',b.lectno )</isNotNull>
where a.sdno=#sdno#
</select>
<update id="lect.lectsd.save" parameterClass="lectsd">
update lectsd set <include refid="sql.up"></include>
,iscopy=#iscopy#,cpoint=#cpoint#
,feedb=#feedb#
,memo=#memo#
,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end
,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end
,fgno=#fgno#
where lectno=#lectno# and sdno=#sdno#;
insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,memo,submittime,submitip,checktime,checkip,<include refid="sql.inc"></include>)
select #lectno#,#sdno#,null,#fgno#,null,#iscopy#,#cpoint#,#feedb#,#memo#,null,null
,case when #cpoint# is not null or #feedb# is not null then now() else null end
,case when #cpoint# is not null or #feedb# is not null then #uip# else null end
,<include refid="sql.inv"></include>
from (select 1 col1) a
left outer join lectsd b on b.lectno=#lectno# and b.sdno=#sdno#
where b.lectno is null
</update>
<update id="lect.lectsd.save2" parameterClass="lectsd">
update lectsd set <include refid="sql.up"></include>
,iscopy=#iscopy#,cpoint=#cpoint#
,feedb=#feedb#
,memo=#memo#
,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end
,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end
,submittime=case when #zstring0# = 'T' then now() else submittime end
,submitip=case when #zstring0# = 'T' then #uip# else submitip end
,fgno=#fgno#
where lectno=#lectno# and sdno=#sdno#;
insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,memo,submittime,submitip,checktime,checkip,<include refid="sql.inc"></include>)
select #lectno#,#sdno#,null,#fgno#,null,#iscopy#,#cpoint#,#feedb#,#memo#
,case when #zstring0# = 'T' then now() else null end
,case when #zstring0# = 'T' then #uip# else null end
,case when #cpoint# is not null or #feedb# is not null then now() else null end
,case when #cpoint# is not null or #feedb# is not null then #uip# else null end
,<include refid="sql.inv"></include>
from (select 1 col1) a
left outer join lectsd b on b.lectno=#lectno# and b.sdno=#sdno#
where b.lectno is null;
<!--과제(중복시 아래 avg로 처리됨),, lect.spoint, 과제 환산점수 update #xodus 수정완료-->
update lect l
inner join (
select l.lectno, round(avg(ifnull(ls.cpoint,0)),1) as avgtpoint, round(((round(avg(ifnull(ls.cpoint,0)),1) * ce.subject / 100) ),1) spoint
from lect l
inner 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 and ls.sdno=#sdno#
inner join cmev ce on l.cmno = ce.cmno
where l.status = 1 and l.lectno = #lectno#
group by l.lectno
)t on l.lectno = t.lectno
set l.spoint = t.spoint
, l.subjectpoint = t.avgtpoint
, l.udt = now()
, l.uno = #uno#
, l.uip=#uip#
where l.status = 1 and l.lectno = #lectno#;
<!--토론(중복시 아래 avg로 처리됨),, lect.dpoint, 토론 환산점수 update #xodus 수정완료-->
update lect l
inner join (
select l.lectno, round(avg(ifnull(ls.cpoint,0)),1) as avgtpoint, round(((round(avg(ifnull(ls.cpoint,0)),1) * ce.discuss / 100)),1) dpoint
from lect l
inner join cmsd cs on l.cmno = cs.cmno and cs.sdtype = 1 and cs.isdel = 0
left outer join lectsd ls on l.lectno = ls.lectno and cs.sdno = ls.sdno and ls.sdno=#sdno#
inner join cmev ce on l.cmno = ce.cmno
where l.status = 1 and l.lectno = #lectno#
group by l.lectno
)t on l.lectno = t.lectno
set l.dpoint = t.dpoint
, l.discusspoint = t.avgtpoint
, l.udt = now()
, l.uno = #uno#
, l.uip=#uip#
where l.status = 1 and l.lectno = #lectno#;
</update>
<update id="lect.lectsd.savebatch" parameterClass="lectsd">
update lectsd set <include refid="sql.up"></include>
,iscopy=#iscopy#,cpoint=#cpoint#,feedb=#feedb#
,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end
,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end
where lectno in ($lectnos$) and sdno=#sdno#;
insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,submittime,submitip,checktime,checkip,<include refid="sql.inc"></include>)
select a.lectno,#sdno#,null,null,null,#iscopy#,#cpoint#,#feedb#,null,null
,case when #cpoint# is not null or #feedb# is not null then now() else null end
,case when #cpoint# is not null or #feedb# is not null then #uip# else null end
,<include refid="sql.inv"></include>
from lect a
left outer join lectsd b on b.lectno=a.lectno and b.sdno=#sdno#
where a.lectno in ($lectnos$) and a.status=1 and a.ischanged=0 and b.lectno is null
</update>
<update id="lect.lectsd2.save" parameterClass="lectsd">
update lectsd set <include refid="sql.up"></include>
,cpoint=#cpoint#,feedb=#feedb#
,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end
,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end
where lectno=#lectno# and sdno=#sdno#;
insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,submittime,submitip,checktime,checkip,<include refid="sql.inc"></include>)
select #lectno#,#sdno#,null,null,null,0,#cpoint#,#feedb#,null,null
,case when #cpoint# is not null or #feedb# is not null then now() else null end
,case when #cpoint# is not null or #feedb# is not null then #uip# else null end
,<include refid="sql.inv"></include>
from (select 1 col1) a
left outer join lectsd b on b.lectno=#lectno# and b.sdno=#sdno#
where b.lectno is null
</update>
<update id="lect.lectsd2.savebatch" parameterClass="lectsd">
update lectsd set <include refid="sql.up"></include>
,cpoint=#cpoint#,feedb=#feedb#
,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end
,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end
where lectno in ($lectnos$) and sdno=#sdno#;
insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,submittime,submitip,checktime,checkip,<include refid="sql.inc"></include>)
select a.lectno,#sdno#,null,null,null,0,#cpoint#,#feedb#,null,null
,case when #cpoint# is not null or #feedb# is not null then checktime else null end
,case when #cpoint# is not null or #feedb# is not null then #uip# else null end
,<include refid="sql.inv"></include>
from lect a
left outer join lectsd b on b.lectno=a.lectno and b.sdno=#sdno#
where a.lectno in ($lectnos$) and a.status=1 and a.ischanged=0 and b.lectno is null
</update>
<select id="lect.lectsdfiles" parameterClass="int" resultClass="lectsd">
select d.orgname,d.fileurl,c.userno,c.userid,c.username
from lectsd a
inner join lect b on b.lectno=a.lectno and b.status=1 and b.ischanged=0
inner join users c on c.userno=b.userno
inner join fileinfo d on d.fgno=a.fgno and d.isdel=0
where a.sdno=#sdno#
</select>
<select id="lect.lectdiscusses" parameterClass="hashtable" resultClass="lectsd">
select a.lectno,a.userno,a.cmno,a.isrebate
,b.sdno
,c.cpoint,c.feedb,c.submittime,c.submitip,c.checktime,c.checkip
,d.username,d.userid
,e.asname
,count(c2.bno) ccount
,row_number() over(order by <isNotNull property="orderby">$orderby$</isNotNull><isNull property="orderby">d.username</isNull>) rno
,count(a.cdt) over() pagetotalcount
from lect a
inner join cmsd b on b.isdel=0 <isNotNull property="sdno">and b.sdno=#sdno#</isNotNull>
left outer join lectsd c on c.lectno=a.lectno and c.sdno=b.sdno
left outer join lectsdboard c2 on c2.lectno=c.lectno and c2.sdno=c.sdno and c2.isdel=0
inner join users d on d.userno=a.userno and d.status &lt; 99
left outer join assign e on e.asno=d.asno
where a.cmno=#cmno# and a.status=1 and a.ischanged=0
<isNotNull property="isrebate">and a.isrebate=#isrebate#</isNotNull>
group by a.lectno,a.userno,a.cmno,a.isrebate
,b.sdno
,c.cpoint,c.feedb,c.submittime,c.submitip,c.checktime,c.checkip
,d.username,d.userid
,e.asname
<isNotNull property="dcount">
having count(c2.bno) $dcount$
</isNotNull>
order by rno
</select>
<select id="lect.lectdiscuss" parameterClass="hashtable" resultClass="lectsd">
select a.sdno,a.tpoint sdtpoint
,b.lectno,b.cpoint,b.feedb,b.submittime,b.checktime
,c.userno,c.username,c.userid
,d.asname
from cmsd a
inner join lect b2 on b2.lectno=#lectno#
inner join users c on c.userno=b2.userno
left outer join assign d on d.asno=c.asno
left outer join lectsd b on b.lectno=b2.lectno and b.sdno=a.sdno
where a.sdno=#sdno#
</select>
<select id="lect.lectsdboards" parameterClass="hashtable" resultClass="lectsdboard">
select bno,a.lectno,a.sdno,a.subject,a.contents,a.fgno,a.rcount,a.cdt,a.cip
from lectsdboard a
where a.isdel=0
<isNotNull property="lectno">and a.lectno=#lectno#</isNotNull>
<isNotNull property="sdno">and a.sdno=#sdno#</isNotNull>
order by a.lectno,a.cdt desc
</select>
<update id="lect.edub2b" parameterClass="edub2b">
insert into edub2b (etype,userno,edate,esubject,etarget,ecount,eplace,ecomment,compname,ceoname,brno,addr,btype,bkind,manname,email,telno,fgno,<include refid="sql.inc"></include>)
values (#etype#,#userno#,#edate#,#esubject#,#etarget#,#ecount#,#eplace#,#ecomment#,#compname#,#ceoname#,#brno#,#addr#,#btype#,#bkind#,#manname#,HEX(AES_ENCRYPT(#email#, <include refid="sql.digest"></include>)),HEX(AES_ENCRYPT(#telno#, <include refid="sql.digest"></include>)),#fgno#,<include refid="sql.inv"></include>)
</update>
<select id="lect.mydata" parameterClass="int" resultClass="data">
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8,a.intval9
,a.longval,a.longval2
,a.strval,a.strval2,a.strval3
,a.time,a.time2
,a.time3,a.time4
,a.time5,a.time6
,a.rno
,a.iscomplete
,a.studytime
,a.studyplacename studyplacename,
a.studyplace
,a.cshape
from(
select 1 dtype
,d.tyear intval,d.tseq intval2,c.cshape intval3,a.pstatus intval4,case when e.rfdno is null then 0 else 1 end intval5,a.isrebate intval6,a.itemno intval7
,case when (case when l.sdate is null then c.sstime else l.sdate end) &lt; now() and (case when l.edate is null then c.setime else l.edate end) &gt; now() then 1 else 0 end intval8
,c.studydays intval9
,l.lectno longval,a.payno longval2
,c.cname strval,null strval2,null strval3
,c.rstime time,c.retime time2
,b.cdt time3,f.estart time4
,CASE
WHEN l.sdate IS NULL then <!--lect의 시작일자가 없으면-->
(case
when c.cshape ='1' then f.estart <!--교육장교육일경우 교육일정의 시작일자-->
else l.cdt <!--그외는 lect의 등록일자-->
end)
ELSE l.sdate
end AS time5
,case
when l.edate is null then f.eend <!-- lect의 종료일자가 없으면-->
else l.edate
end time6
,case when b.pstatus = 1 then 99 else b.pstatus end as sortpstatus
,row_number() over(order by sortpstatus, c.retime, b.payno,a.pino) rno
,l.iscomplete
,c.studytime,
cc.cname studyplacename,
cmis.studyplace,
l.cdt
,c.cshape
from payitem a
inner join pay b on b.payno=a.payno and b.pstatus in (21,22,51,55) and b.rstatus &lt; 2
inner join cm c on c.cmno=a.itemno and c.rstime &lt; <include refid="sql.now"></include> and c.retime &gt; <include refid="sql.now"></include>
inner join lect l on l.cmno=c.cmno and (l.status &lt; 5 or l.status = 6) and l.ischanged=0 and l.userno=b.userno
inner join term d on d.tmno=c.tmno
left outer join payrfd e on e.payno=a.payno and e.payno=a.payno and e.rstatus=0
left outer join cminningscd f on f.cmisno = l.cmisno
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = l.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a.ptype in (0,1,4) and a.userno=#userno# and a.pstatus in (21,22,51,55) and a.rstatus=0
and 1 = case when c.retime = '2099-12-31 23:59:59' and l.stime is not null then 0 else 1 end
order by sortpstatus,l.cdt desc, c.retime desc, b.payno,a.pino
) a
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8,0 intval9
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3
,a.time,a.time2
,a.time3,a.time4
,a.time5,a.time6
,a.rno
,a.iscomplete
,a.studytime,
a.studyplacename studyplacename,
a.studyplace
,a.cshape
from (
select 2 dtype
,c.tyear intval,c.tseq intval2,b.cshape intval3,0 intval4,0 intval5,a.isrebate intval6,a.cmno intval7,0 intval8
,a.lectno longval,0 longval2
,b.cname strval,null strval2,null strval3
,case
WHEN a.sdate IS NULL then <!--lect의 시작일자가 없으면-->
(case
when b.cshape ='1' then d.estart <!--교육장교육일경우 교육일정의 시작일자-->
else a.cdt <!--그외는 lect의 등록일자-->
end)
ELSE a.sdate
end AS time
,case
when a.edate is null then d.eend <!--lect의 종료일자가 없으면-->
else a.edate
end time2
,d.estart time3,d.eend time4
,e.cdt time5,null time6
,row_number() over(order by b.setime desc) rno
,case when d.eend is not null then d.eend else a.edate end as sortedate
,a.iscomplete
,b.studytime,
cc.cname studyplacename,
cmis.studyplace
,b.cshape
from lect a
inner join pay e on e.payno = a.payno
inner join cm b on b.cmno=a.cmno
inner join term c on c.tmno=b.tmno
left outer join cminningscd d on a.cmisno = d.cmisno
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a.userno=#userno# and a.status=1 and a.ischanged=0
<!--and (case when a.sdate is null then b.sstime else a.sdate end) &lt; <include refid="sql.now"></include>-->
and (case when a.sdate is null then b.setime else a.edate end) &gt;= <include refid="sql.now"></include>
order by case when time2 > now() then 1 else 0 end asc ,sortedate asc, time2 asc
) a
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8,0 intval9
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3
,a.time,a.time2
,null time3, null time4
,null time5, null time6
,a.rno
,a.iscomplete
,a.studytime,
a.studyplacename studyplacename,
a.studyplace
,a.cshape
from (
select 3 dtype
,1 intval,c.iseq intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,a.cmno intval7,0 intval8
,a.lectno longval
,b.cname strval,null strval2,null strval3
,case when a.sdate is null then b.sstime else a.sdate end as time
,case when a.edate is null then b.setime else a.edate end as time2
,row_number() over(partition by a.cmno order by c.iseq) rno2
,row_number() over(order by b.setime) rno
,a.iscomplete
,b.studytime,
cc.cname studyplacename,
cmis.studyplace
,b.cshape
from lect a
inner join cm b on b.cmno=a.cmno <!--and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include>-->
inner join cminning c on c.cmno=b.cmno and c.isonline=1 and c.isscd = 0
left outer join lectinning d on d.lectno=a.lectno and d.cmino=c.cmino and d.istatus=2
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a.userno=#userno# and a.status=1 and a.ischanged=0 and d.lectno is null
and a.sdate &lt; <include refid="sql.now"></include> and a.edate &gt; <include refid="sql.now"></include>
) a
where a.rno2=1
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8,0 intval9
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3
,a.time,a.time2
,null time3, null time4
,null time5, null time6
,a.rno
,a.iscomplete
,a.studytime,
a.studyplacename studyplacename,
a.studyplace
,a.cshape
from (
select 3 dtype
,2 intval,c.iseq intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,a.cmno intval7,0 intval8
,a.lectno longval
,b.cname strval,bc.cname strval2,concat(date_format(c.idate,'%m/%d'),' ',left(c.ist,2),':',right(c.ist,2),' ~ ',left(c.iet,2),':',right(c.iet,2)) strval3
,case when a.sdate is null then b.sstime else a.sdate end as time
,case when a.edate is null then b.setime else a.edate end as time2
,row_number() over(partition by a.cmno order by c.iseq) rno2
,row_number() over(order by b.setime) rno
,a.iscomplete
,b.studytime,
cc.cname studyplacename,
cmis.studyplace
,b.cshape
from lect a
inner join cm b on b.cmno=a.cmno <!--and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include> and b.cshape=1-->
left outer join comcode bc on bc.ccode=b.studyplace
inner join cminning c on c.cmno=b.cmno and c.isonline=0 and c.isscd = 0
<!--left outer join lectinning d on d.lectno=a.lectno and d.cmino=c.cmino and d.istatus=2-->
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a.userno=#userno# and a.status=1 and a.ischanged=0 <!--and d.lectno is null-->
and a.sdate &lt; <include refid="sql.now"></include> and a.edate &gt; <include refid="sql.now"></include>
) a
where a.rno2=1
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8,0 intval9
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3
,a.time,a.time2
,null time3, null time4
,null time5, null time6
,a.rno
,a.iscomplete
,a.studytime,
a.studyplacename studyplacename,
a.studyplace
,a.cshape
from (
select 3 dtype
,3 intval,0 intval2,b.classno intval3,c.extype intval4,0 intval5,0 intval6,a.cmno intval7,0 intval8
,a.lectno longval
,b.cname strval,bc.cname strval2,null strval3
,case when a.sdate is null then b.sstime else a.sdate end as time
,case when a.edate is null then b.setime else a.edate end as time2
,row_number() over(partition by a.cmno order by c.extype,c.cdt) rno2
,row_number() over(order by b.setime) rno
,a.iscomplete
,b.studytime,
cc.cname studyplacename,
cmis.studyplace
,b.cshape
from lect a
inner join cm b on b.cmno=a.cmno <!--and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include>-->
left outer join comcode bc on bc.ccode=b.studyplace
inner join cmex c on c.cmno=b.cmno and c.isdel=0 and c.econdition &lt;= a.attrate
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
left outer join lectex d on d.lectno=a.lectno and d.exno=c.exno and d.eend is not null
where a.userno=#userno# and a.status=1 and a.ischanged=0 and d.lectno is null
and a.sdate &lt; <include refid="sql.now"></include> and a.edate &gt; <include refid="sql.now"></include>
) a
where a.rno2=1
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8,0 intval9
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3
,a.time,a.time2
,null time3, null time4
,null time5, null time6
,a.rno
,a.iscomplete
,a.studytime,
a.studyplacename studyplacename,
a.studyplace
,a.cshape
from (
select 3 dtype
,4 intval,0 intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,a.cmno intval7,0 intval8
,a.lectno longval
,b.cname strval,bc.cname strval2,null strval3
,case when a.sdate is null then b.sstime else a.sdate end as time
,case when a.edate is null then b.setime else a.edate end as time2
,row_number() over(partition by a.cmno order by c.cdt) rno2
,row_number() over(order by b.setime) rno
,a.iscomplete
,b.studytime,
cc.cname as studyplacename,
cmis.studyplace
,b.cshape
from lect a
inner join cm b on b.cmno=a.cmno <!--and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include>-->
left outer join comcode bc on bc.ccode=b.studyplace
inner join cmsd c on c.sdtype=0 and c.cmno=b.cmno and c.isdel=0 and c.sdcondition &lt;= a.attrate
left outer join lectsd d on d.lectno=a.lectno and d.sdno=c.sdno and d.submittime is not null
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a.userno=#userno# and a.status=1 and a.ischanged=0 and d.lectno is null
and a.sdate &lt; <include refid="sql.now"></include> and a.edate &gt; <include refid="sql.now"></include>
) a
where a.rno2=1
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8,0 intval9
,a.longval,0 longval2
,a.strval,a.strval2,a.strval3
,a.time,a.time2
,null time3, null time4
,null time5, null time6
,a.rno
,a.iscomplete
,a.studytime,
a.studyplacename studyplacename,
a.studyplace
,a.cshape
from (
select 3 dtype
,5 intval,0 intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,a.cmno intval7,0 intval8
,a.lectno longval
,b.cname strval,bc.cname strval2,null strval3
,case when a.sdate is null then b.sstime else a.sdate end as time
,case when a.edate is null then b.setime else a.edate end as time2
,row_number() over(partition by a.cmno order by c.cdt) rno2
,row_number() over(order by b.setime) rno
,a.iscomplete
,b.studytime,
cc.cname studyplacename,
cmis.studyplace
,b.cshape
from lect a
inner join cm b on b.cmno=a.cmno <!--and b.sstime &lt; <include refid="sql.now"></include> and b.setime &gt; <include refid="sql.now"></include>-->
left outer join comcode bc on bc.ccode=b.studyplace
inner join cmsd c on c.sdtype=1 and c.cmno=b.cmno and c.isdel=0 and c.sdcondition &lt;= a.attrate
left outer join lectsdboard d on d.lectno=a.lectno and d.sdno=c.sdno and d.isdel=0
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a.userno=#userno# and a.status=1 and a.ischanged=0 and d.lectno is null
and a.sdate &lt; <include refid="sql.now"></include> and a.edate &gt; <include refid="sql.now"></include>
) a
where a.rno2=1
union all
select a.dtype,a.intval,a.intval2,a.intval3,a.intval4,a.intval5,a.intval6,a.intval7,a.intval8,0 intval9
,a.longval,a.longval2
,a.strval,a.strval2,a.strval3
,a.time,a.time2
,null time3, null time4
,null time5, null time6
,a.rno
,a.iscomplete
,a.studytime,
a.studyplacename studyplacename,
a.studyplace
,a.cshape
from (
select 4 dtype
,a.scdno intval,a.dday intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,b.cmno intval7,0 intval8
,c.lectno longval,a.alno longval2
,b.cname strval,null strval2,null strval3
,a.atime time,c.edate time2
,row_number() over(order by a.atime desc) rno
,c.iscomplete
,b.studytime,
cc.cname studyplacename,
cmis.studyplace
,b.cshape
from alarms a
inner join cm b on b.cmno=a.cmexno
inner join lect c on c.cmno=b.cmno and c.userno=a.userno and c.status=1 and c.ischanged=0
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = c.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a.userno=#userno# and a.scdno &lt; 9 and a.isdel=0
order by a.atime desc
limit 5
) a
</select>
<update id="lect.alarm.del" parameterClass="hashtable">
update alarms set isdel=1 where alno=#alno# and userno=#userno#
</update>
<select id="lect.mylectures" parameterClass="hashtable" resultClass="lect">
select a.lectno,a.cmno,a.userno,a.isrebate,a.iscomplete,b.studytime,b.outfee
,case when a.sdate is null then b.sstime else a.sdate end as sdate
,case when a.edate is null then b.setime else a.edate end as edate
,b.cmno,b.cname,b.cshape
<!--,case when a.ispc=1 then pc.sstime else b.sstime end sstime
,case when a.ispc=1 then pc.setime else b.setime end setime-->
,b.sstime,b.setime
,b.classno,b.isrefund
,c.tyear,c.tseq
,e.isgroup,e.payno
,u.username,null ccpositionname,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email,ua.asname
,1 rno
,e.cdt
,scd.estart,scd.eend
<!--,cc.ccode studyplace
,cc.cname studyplacename-->
,ccc.cname studyplacename,
cmis.studyplace
,case when scd.eend is not null then scd.eend else a.edate end as sortedate
,ci.scdtype
from lect a
inner join cm b on b.cmno=a.cmno <!--and b.sstime &lt; <include refid="sql.now"></include>-->
<!--inner join cm pc on pc.cmno=case when a.ispc=1 then a.pcno else a.cmno end and pc.sstime &lt; <include refid="sql.now"></include>-->
inner join term c on c.tmno=b.tmno
inner join cg d on d.cgno=b.cgno <isNotNull property="cgcode">and d.cgcode=#cgcode#</isNotNull>
inner join pay e on e.payno=a.payno and e.isgroup=0
inner join users u on u.userno=a.userno
left outer join assign ua on ua.asno=u.asno
left outer join cminningscd scd on scd.cmisno = a.cmisno
left outer join cminning ci on ci.cmino = scd.cmino
<!--left outer join comcode cc on cc.ccode = b.studyplace-->
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode ccc ON ccc.ccode = cmis.studyplace and ccc.cgroup ='studyplace'
where a.userno=#userno# and a.status=1 and a.ischanged=0 <!-- 20220810 and a.sdate &lt; <include refid="sql.now"></include>-->
<!--20220810 where a.userno=#userno# and a.status=1 and a.ischanged=0 and a.sdate &lt; <include refid="sql.now"></include>-->
<isNotNull property="cshape">and b.cshape=#cshape#</isNotNull>
<isNotNull property="issubtable">
and (ifnull(a.iscomplete,0) = 0 <!-- 20220810 and b.cshape = 2 --> and scd.estart &gt; '1900-01-01' and scd.eend &gt; '1900-01-01'
<!--and scd.estart &gt; now()-->
<!--and (date_add(scd.eend,interval +5 day) &gt; date_format(now(),'%Y-%m-%d 23:59:59'))-->
and date_add(a.cdt, interval +1 year) &gt;= date_format(now(),'%Y-%m-%d 23:59:59'))
</isNotNull>
<isNotNull property="changeDate">
<Equal property="changeDate" compareValue="1">and (case when a.sdate is null then b.sstime else a.sdate end) > DATE_ADD(NOW(), INTERVAL -1 YEAR)</Equal>
</isNotNull>
union all
select a.lectno,a.cmno,a.userno,a.isrebate,a.iscomplete,b.studytime,b.outfee
,case when a.sdate is null then b.sstime else a.sdate end as sdate
,case when a.edate is null then b.setime else a.edate end as edate
,b.cmno,b.cname,b.cshape,b.sstime,b.setime,b.classno,b.isrefund
,c.tyear,c.tseq
,e.isgroup,e.payno
,u.username,null ccpositionname,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email,ua.asname
,row_number() over(partition by e.payno) rno
,e.cdt,null estart, null eend
<!--null studyplace
,null studyplacename-->
,a.edate as sortedate
,null scdtype,
cc.cname studyplacename,
cmis.studyplace
from pay e
inner join lect a on a.payno=e.payno and a.status=1 and a.ischanged=0
inner join cm b on b.cmno=a.cmno and b.sstime &lt; <include refid="sql.now"></include>
inner join term c on c.tmno=b.tmno
inner join cg d on d.cgno=b.cgno <isNotNull property="iscover">and d.iscover=1</isNotNull>
inner join users u on u.userno=a.userno
left outer join assign ua on ua.asno=u.asno
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where e.isgroup=1 and e.userno=#userno# and e.pstatus=1
<isNotNull property="cshape">and b.cshape=#cshape#</isNotNull>
<isNotNull property="changeDate">
<Equal property="changeDate" compareValue="1">and (case when a.sdate is null then b.sstime else a.sdate end) > DATE_ADD(NOW(), INTERVAL -1 YEAR)</Equal>
</isNotNull>
union all
select a.lectno,a.cmno,a.userno,a.isrebate,a.iscomplete,b.studytime,b.outfee
,case when a.sdate is null then b.sstime else a.sdate end as sdate
,case when a.edate is null then b.setime else a.edate end as edate
,b.cmno,b.cname,b.cshape,b.sstime,b.setime,b.classno,b.isrefund
,c.tyear,c.tseq
,e.isgroup,e.payno
,u.username,null ccpositionname,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email,ua.asname
,row_number() over(partition by e.payno) rno
,e.cdt,null estart, null eend
<!--null studyplace
,null studyplacename-->
,a.edate as sortedate
,null scdtype,
cc.cname studyplacename,
cmis.studyplace
from lect a0
inner join pay e on e.payno=a0.payno and e.isgroup=1 and e.userno&lt;&gt;#userno# and e.pstatus=1
inner join lect a on a.payno=e.payno and a.status=1 and a.ischanged=0
inner join cm b on b.cmno=a.cmno and b.sstime &lt; <include refid="sql.now"></include>
inner join term c on c.tmno=b.tmno
inner join cg d on d.cgno=b.cgno <isNotNull property="iscover">and d.iscover=1</isNotNull>
inner join users u on u.userno=a.userno
left outer join assign ua on ua.asno=u.asno
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a0.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a0.userno=#userno# and a0.status=1 and a0.ischanged=0
<isNotNull property="cshape">and b.cshape=#cshape#</isNotNull>
<isNotNull property="changeDate">
<Equal property="changeDate" compareValue="1">and (case when a.sdate is null then b.sstime else a.sdate end) > DATE_ADD(NOW(), INTERVAL -1 YEAR)</Equal>
</isNotNull>
order by case when setime &lt; now() then 0 else 1 end desc,sortedate desc, edate desc,payno
</select>
<select id="lect.mylectures2" parameterClass="hashtable" resultClass="lect">
select a.lectno,a.cmno,a.userno,a.isrebate,a.iscomplete,b.studytime,b.outfee
,case when a.sdate is null then b.sstime else a.sdate end as sdate
,case when a.edate is null then b.setime else a.edate end as edate
,b.cmno,b.cname,b.cshape
<!--,case when a.ispc=1 then pc.sstime else b.sstime end sstime
,case when a.ispc=1 then pc.setime else b.setime end setime-->
,b.sstime,b.setime
,b.classno,b.isrefund
,c.tyear,c.tseq
,e.isgroup,e.payno
,u.username,null ccpositionname,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email,ua.asname
,1 rno
,e.cdt
,scd.estart,scd.eend
<!--,cc.ccode studyplace
,cc.cname studyplacename-->
,ccc.cname studyplacename,
cmis.studyplace
,case when scd.eend is not null then scd.eend else a.edate end as sortedate
,ci.scdtype
from lect a
inner join cm b on b.cmno=a.cmno <!--and b.sstime &lt; <include refid="sql.now"></include>-->
<!--inner join cm pc on pc.cmno=case when a.ispc=1 then a.pcno else a.cmno end and pc.sstime &lt; <include refid="sql.now"></include>-->
inner join term c on c.tmno=b.tmno
inner join cg d on d.cgno=b.cgno <isNotNull property="cgcode">and d.cgcode=#cgcode#</isNotNull>
inner join pay e on e.payno=a.payno and e.isgroup=0
inner join users u on u.userno=a.userno
left outer join assign ua on ua.asno=u.asno
left outer join cminningscd scd on scd.cmisno = a.cmisno
left outer join cminning ci on ci.cmino = scd.cmino
<!--left outer join comcode cc on cc.ccode = b.studyplace-->
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode ccc ON ccc.ccode = cmis.studyplace and ccc.cgroup ='studyplace'
where a.userno=#userno# and a.status=1 and a.ischanged=0 <!-- 20220810 and a.sdate &lt; <include refid="sql.now"></include>-->
and (case when a.sdate is null then b.sstime else a.sdate end) > DATE_ADD(NOW(), INTERVAL -1 YEAR)
<!--20220810 where a.userno=#userno# and a.status=1 and a.ischanged=0 and a.sdate &lt; <include refid="sql.now"></include>-->
<isNotNull property="cshape">and b.cshape=#cshape#</isNotNull>
<isNotNull property="issubtable">
and (ifnull(a.iscomplete,0) = 0 <!-- 20220810 and b.cshape = 2 --> and scd.estart &gt; '1900-01-01' and scd.eend &gt; '1900-01-01'
<!--and scd.estart &gt; now()-->
<!--and (date_add(scd.eend,interval +5 day) &gt; date_format(now(),'%Y-%m-%d 23:59:59'))-->
and date_add(a.cdt, interval +1 year) &gt;= date_format(now(),'%Y-%m-%d 23:59:59'))
</isNotNull>
union all
select a.lectno,a.cmno,a.userno,a.isrebate,a.iscomplete,b.studytime,b.outfee
,case when a.sdate is null then b.sstime else a.sdate end as sdate
,case when a.edate is null then b.setime else a.edate end as edate
,b.cmno,b.cname,b.cshape,b.sstime,b.setime,b.classno,b.isrefund
,c.tyear,c.tseq
,e.isgroup,e.payno
,u.username,null ccpositionname,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email,ua.asname
,row_number() over(partition by e.payno) rno
,e.cdt,null estart, null eend
<!--null studyplace
,null studyplacename-->
,a.edate as sortedate
,null scdtype,
cc.cname studyplacename,
cmis.studyplace
from pay e
inner join lect a on a.payno=e.payno and a.status=1 and a.ischanged=0
inner join cm b on b.cmno=a.cmno and b.sstime &lt; <include refid="sql.now"></include>
inner join term c on c.tmno=b.tmno
inner join cg d on d.cgno=b.cgno <isNotNull property="iscover">and d.iscover=1</isNotNull>
inner join users u on u.userno=a.userno
left outer join assign ua on ua.asno=u.asno
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where e.isgroup=1 and e.userno=#userno# and e.pstatus=1
and (case when a.sdate is null then b.sstime else a.sdate end) > DATE_ADD(NOW(), INTERVAL -1 YEAR)
<isNotNull property="cshape">and b.cshape=#cshape#</isNotNull>
union all
select a.lectno,a.cmno,a.userno,a.isrebate,a.iscomplete,b.studytime,b.outfee
,case when a.sdate is null then b.sstime else a.sdate end as sdate
,case when a.edate is null then b.setime else a.edate end as edate
,b.cmno,b.cname,b.cshape,b.sstime,b.setime,b.classno,b.isrefund
,c.tyear,c.tseq
,e.isgroup,e.payno
,u.username,null ccpositionname,CAST(AES_DECRYPT(UNHEX(u.email), <include refid="sql.digest"></include>) AS char) email,ua.asname
,row_number() over(partition by e.payno) rno
,e.cdt,null estart, null eend
<!--null studyplace
,null studyplacename-->
,a.edate as sortedate
,null scdtype,
cc.cname studyplacename,
cmis.studyplace
from lect a0
inner join pay e on e.payno=a0.payno and e.isgroup=1 and e.userno&lt;&gt;#userno# and e.pstatus=1
inner join lect a on a.payno=e.payno and a.status=1 and a.ischanged=0
inner join cm b on b.cmno=a.cmno and b.sstime &lt; <include refid="sql.now"></include>
inner join term c on c.tmno=b.tmno
inner join cg d on d.cgno=b.cgno <isNotNull property="iscover">and d.iscover=1</isNotNull>
inner join users u on u.userno=a.userno
left outer join assign ua on ua.asno=u.asno
LEFT OUTER JOIN cminningscd cmis ON cmis.cmisno = a0.cmisno
LEFT OUTER JOIN comcode cc ON cc.ccode = cmis.studyplace and cc.cgroup ='studyplace'
where a0.userno=#userno# and a0.status=1 and a0.ischanged=0
and (case when a.sdate is null then b.sstime else a.sdate end) > DATE_ADD(NOW(), INTERVAL -1 YEAR)
<isNotNull property="cshape">and b.cshape=#cshape#</isNotNull>
order by case when setime &lt; now() then 0 else 1 end desc,sortedate desc, edate desc,payno
</select>
<select id="lect.myexams" parameterClass="hashtable" resultClass="examuser">
select a.exno,a.userno,a.status,a.payno,a.pino,a.pstatus,a.epoint1,a.epoint2,a.epoint3,a.avrg,a.ispass,a.certdate,a.certindate
,b.exname,b.isopen,b.rstime,b.retime,b.estime,b.elocation,b.isresultopen
,c.certdate firstcertdate
,u.username,u.userid
,cc.cname gradename
from examuser a
inner join exam b on b.exno=a.exno <isNotNull property="isresultopen">and b.isresultopen=#isresultopen#</isNotNull>
left outer join examuserrenew c on c.exno=a.exno and c.userno=a.userno and c.isfirst=1
inner join users u on u.userno=a.userno
inner join comcode cc on cc.ccode=b.certgradecc
<dynamic prepend="where">
<isNotNull property="userno" prepend="and">a.userno=#userno#</isNotNull>
<isNotNull property="validstatus" prepend="and">a.status &lt; 9 and a.pstatus &lt; 8</isNotNull>
</dynamic>
order by a.cdt desc
</select>
<select id="lect.myexamrenews" parameterClass="hashtable" resultClass="examuserrenew">
select a.exno,a.userno,a.certtime,a.certdate,a.certindate,a.renewreason,a.isfirst,a.certidx
,b.username cnoname
from examuserrenew a
left outer join users b on b.userno=a.cno
where a.exno=#exno# and a.userno=#userno#
order by a.certdate desc
</select>
<select id="lect.myexamrenewlects" parameterClass="hashtable" resultClass="lect">
select a.*,b.cmno,b.oktime,b.iscomplete
from (
select distinct(c.cmno),c.cname,c.cshape
from examuser a
inner join exam b on b.exno=a.exno
inner join cm c on c.certcc=b.certcc and c.certgradecc=b.certgradecc and c.isdel=0 and c.isuse=1
inner join cg d on d.cgno = c.cgno and d.isuse=1 and d.isdel=0 and d.iscover=1
where a.exno=#exno# and a.userno=#userno#
)a
inner join lect b on b.cmno=a.cmno
where b.status=1 and b.iscomplete=1 and b.ischanged=0 and b.userno=#userno#
group by a.cmno,a.cname,a.cshape,b.oktime,b.iscomplete
limit 3
</select>
<select id="lect.myalarm" parameterClass="int" resultClass="data">
select 4 dtype,a.scdno intval,a.dday intval2,b.classno intval3,0 intval4,0 intval5,0 intval6,b.cmno intval7
,c.lectno longval,a.alno longval2
,b.cname strval,null strval2,null strval3
,a.atime time,null time2
from alarms a
inner join cm b on b.cmno=a.cmexno
inner join lect c on c.cmno=b.cmno and c.userno=a.userno and c.status=1 and c.ischanged=0
where a.userno=#userno# and date_add(a.atime, interval 3 month) &gt; now() and a.scdno &lt; 9 and a.isdel=0
order by a.atime desc
</select>
<select id="lect.lectex.result" parameterClass="hashtable" resultClass="lectex">
select a.etime,a.exname,a.tpoint fullpoint,a.isresultopen
,b.estart,b.eend,b.tpoint, b.udt
from cmex a
inner join lectex b on b.lectno=#lectno# and b.exno=a.exno
inner join lect c on c.lectno=b.lectno and c.userno=#userno#
where a.exno=#exno#
</select>
<select id="lect.lectexq.result" parameterClass="hashtable" resultClass="lectexq">
select d.atype,b.cpoint,b.dpoint,d.qtext,b.atext,d.qdesc,b.iscorrect,c.qno,b.eqno,b.qseq
from lectex a
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
inner join lectexq b on b.lectno=a.lectno and b.exno=a.exno
inner join cmexq c on c.eqno=b.eqno
inner join question d on d.qno=c.qno
where a.lectno=#lectno# and a.exno=#exno#
order by b.qseq
</select>
<select id="lect.lectexqqi.list" parameterClass="string" resultClass="questionitem">
select a.qno,a.qitext,b.fileurl,a.isright,a.qino
from questionitem a
left outer join fileinfo b on b.fgno=a.fgno and b.isdel=0
where a.qno in ($qnos$) and a.isdel=0
order by a.qno, a.qino
</select>
<select id="lect.lectexresult.rightrate" parameterClass="string" resultClass="cmexq">
select a.eqno,sum(a.iscorrect)/count(a.eqno)*100 rightrate
from lectexq a
where a.eqno in ($eqnos$)
group by a.eqno
</select>
<select id="lect.lectexresult.selectrate" parameterClass="hashtable" resultClass="cmexq">
select a.eqno,sum(case when a.atext = b.atext then 1 else 0 end) / count(b.eqno) * 100 selectrate
from lectexq a
inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno#
inner join lectexq b on b.exno=a.exno and b.eqno=a.eqno
where a.lectno=#lectno# and a.exno=#exno#
group by a.eqno
</select>
<select id="lect.myrecomm" parameterClass="int" resultClass="cm">
select c.tyear,c.tseq,a.cmno,b.cshape,b.cname,b.rstime,b.retime,e.cgcode,b.isrefund
from (
select a.*
from (
select distinct b.ispre idx,c.cmno
from lect a
inner join cmrelay b on b.cmno=a.cmno
inner join cm c on c.ismaster=0 and c.pcmno=b.rcmno and c.rstime &lt; now() and c.retime &gt; now()
left outer join lect d on d.userno=a.userno and d.cmno=c.cmno
where a.userno=#userno# and a.status=1 and a.ischanged=0 and d.lectno is null
order by b.ispre,c.retime
limit 2
) a
union all
select a.*
from (
select 2 idx,c.cmno
from users a
inner join comcode b on b.ccode=a.ccposition
inner join cm c on c.ismaster=0 and c.rstime &lt; now() and c.retime &gt; now() and c.jobpositiongrade like concat('%',b.refcode,'%')
left outer join lect d on d.userno=a.userno and d.cmno=c.cmno
where a.userno=#userno# and d.lectno is null
order by c.retime
limit 2
) a
) a
inner join cm b on b.cmno=a.cmno
inner join term c on c.tmno=b.tmno
inner join cg d on d.cgno=b.cgno
inner join cg e on e.cgno=d.pcgno
order by a.idx,b.retime
limit 2
</select>
<update id="lect.completetime.change" parameterClass="hashtable">
update lect set <include refid="sql.up"></include>
,completetime=#completetime#
where lectno=#lectno# and iscomplete=1;
</update>
<select id="lect.attcert.check" parameterClass="hashtable" resultClass="data">
select ifnull(a.isattcheck,0) intval,b.ischkatt intval2,c.ischkatt intval3
,CAST(AES_DECRYPT(UNHEX(b.mobile), <include refid="sql.digest"></include>) AS char) strval
from lect a
inner join users b on b.userno = a.userno
inner join cm c on c.cmno = a.cmno
where a.lectno = #lectno#
</select>
<select id="lect.lectinning.attcert.check" parameterClass="hashtable" resultClass="data">
select ifnull(d.isattcheck,0) intval,b.ischkatt intval2,c.ischkatt intval3
,CAST(AES_DECRYPT(UNHEX(b.mobile), <include refid="sql.digest"></include>) AS char) strval
,b.authplatform strval2
from lect a
inner join users b on b.userno = a.userno
inner join cm c on c.cmno = a.cmno
left outer join lectinning d on d.lectno = a.lectno and d.cmino = #cmino#
where a.lectno = #lectno# and a.userno = #userno#
</select>
<select id="lect.lecture.document" parameterClass="hashtable" resultClass="lect">
select a.*
from (
select a.lectno,a.userno,a.iscomplete,a.sdate,a.edate,a.status
,b.cmno,b.cname,b.cshape,b.studytime
,b.rstime,b.retime
,b.sstime,b.setime
,c.tyear,c.tseq
,u.username,u.userid
,e1.asname
,e.payno,e.pstatus,e.payamt,e.ptype,e.ispg,e.pgkey,e.payoktime,e.rstatus,e.iscashrct, e.isbill
,e2.pino,e2.payamt pipayamt,e2.itemname
,f.estart,f.eend
,cc.cname studyplacename
,cc.ccode studyplace
,pt.taxno,pt.taxdate taxdate2,pt.mgtkey,pt.iscancel,pt.statecode,pt.ischeck
,a.cdt
,e.cdt paycdt
,pv.cshrpgkey
,ifnull(pi.isrebate,0) isrebate
,row_number() over(order by a.cdt desc) rno
,count(a.lectno) over() pagetotalcount
from lect a
inner join cm b on b.cmno = a.cmno
inner join term c on c.tmno = b.tmno
inner join pay e on e.payno = a.payno
inner join payitem pi on pi.payno = a.payno
left outer join(
select c.payno,c.pino,c.payamt
,case c.ptype when 0 then c0.cname when 2 then c2.bkname when 4 then c0.cname when 3 then c3.exname else '-' end itemname
from lect a
inner join pay b on b.payno = a.payno
left outer join payitem c on c.payno = b.payno
left outer join cm c0 on c.ptype in (0,1,4) and c0.cmno=c.itemno
left outer join book c2 on c.ptype=2 and c2.bkno=c.itemno
left outer join exam c3 on c.ptype=3 and c3.exno=c.itemno
where a.status in (1,2) and a.ischanged = 0 <isNotNull property="userno">and a.userno = #userno#</isNotNull>
group by a.payno
) e2 on e2.payno = e.payno
left outer join pplog e1 on e1.pplno = e.pplno
left outer join users u on u.userno = a.userno
left outer join assign ass on ass.asno = u.asno
left outer join cminningscd f on f.cmisno = a.cmisno
left outer join comcode cc on cc.ccode = f.studyplace
left outer join paytax pt on pt.payno = e.payno and ifnull(pt.iscancel,0) =0
left outer join payvbankin pv on pv.payno = a.payno
where a.status in (1,2) and a.ischanged=0
<isNotNull property="cdts">and a.cdt &gt;= #cdts#</isNotNull>
<isNotNull property="cdte">and a.cdt &lt;= #cdte#</isNotNull>
<isNotNull property="asname">and ass.asname like concat('%',#asname#,'%')</isNotNull>
<isNotNull property="asno">and ass.asno = #asno#</isNotNull>
<isNotNull property="userno">and a.userno = #userno#</isNotNull>
<isNotNull property="isrebates">and ifnull(a.isrebate,0) in ($isrebates$)</isNotNull>
<isNotNull property="username">and u.username like concat('%',#username#,'%')</isNotNull>
<isNotNull property="userid">and u.userid like concat('%',#userid#,'%')</isNotNull>
<isNotNull property="itemname">and b.cname like concat('%',#itemname#,'%')</isNotNull>
<isNotNull property="usernameiditemname">and(u.username like concat('%',#usernameiditemname#,'%') or u.userid like concat('%',#usernameiditemname#,'%') or b.cname like concat('%',#usernameiditemname#,'%'))</isNotNull>
) a
<include refid="sql.pagedynamic"></include>
</select>
<select id="lect.lecture.document.past" parameterClass="hashtable" resultClass="lect">
select no lectno,substr(a.cshape,1,3) cshapename2,a.cgname cname,a.ssdate sstime,a.sedate setime
,case when a.rprice> 0 then 1 else 0 end isrebate
from docprintpast a
inner join users b on b.userpno= a.userpno
where userno = #userno#
</select>
<update id="lect.drop2day" parameterClass="hashtable">
update pay a
inner join lect b on b.payno = a.payno and b.cmno = #cmno# and b.ischanged=0 and ifnull(b.isready,0) = 1 and b.status = 4 and DATE_ADD(b.oktime, INTERVAL 2 DAY) &lt; <include refid="sql.now"></include>
set a.pstatus = 52, a.udt = now(), a.uno = #uno#, a.uip = #uip#;
update payitem a
inner join pay b on b.payno = a.payno and b.pstatus = 52
inner join lect c on c.payno = b.payno and c.cmno = #cmno# and c.ischanged=0 and ifnull(c.isready,0) = 1 and c.status = 4 and DATE_ADD(c.oktime, INTERVAL 2 DAY) &lt; <include refid="sql.now"></include>
set a.pstatus = b.pstatus, a.udt = now(), a.uno = #uno#, a.uip = #uip#;
update lect
set status = 5, oktime = now(), udt = now(), uno = #uno#, uip = #uip#
where cmno = #cmno# and ifnull(isready,0) = 1 and ischanged=0 and status = 4 and DATE_ADD(oktime, INTERVAL 2 DAY) &lt; <include refid="sql.now"></include>
</update>
<update id="lect.isatt.in" parameterClass="hashtable">
update lect
set isattcheck = 1,
lakey = #lakey#,
latime = now()
where lectno = #lectno#
</update>
<update id="lect.lectinning.isatt.in" parameterClass="hashtable">
update lectinning a
inner join lect b on b.lectno=a.lectno and b.userno=#userno#
set a.isattcheck = #isattcheck#,a.udt=now(),a.uno=#uno#,a.uip=#uip#
where a.lectno=#lectno# and a.cmino=#cmino#;
insert into lectinning (lectno,cmino,totstudy,stime,etime,istatus,finishtime,sip,eip,ispcs,ispce,pseq,psec,isattcheck,<include refid="sql.inc"></include>)
select #lectno#,a.cmino,0,now(),now(),case when a.atime=0 then 2 else 0 end,case when a.atime=0 then now() else null end,#uip#,#uip#,1,null,ctp.pseq,0,#isattcheck#,<include refid="sql.inv"></include>
from cminning a
inner join ctpage ctp on ctp.ctno=a.ctno and ctp.isdel=0 and ctp.pseq=1
left outer join lectinning b on b.lectno=#lectno# and b.cmino=#cmino#
where a.cmino=#cmino# and b.lectno is null;
</update>
<update id="lect.cmisno.up" parameterClass="hashtable">
update lect
set cmisno = #cmisno#
where lectno = #lectno#;
update pplog a
left outer join (
select a.lectno,a.payno,b.pplno,a.cmisno
from lect a
inner join pay b on b.payno = a.payno
where a.lectno = #lectno#
) b on b.pplno = a.pplno
set a.cmisno = b.cmisno
where b.lectno = #lectno#;
update lect a
left outer join cminningscd b on b.cmisno = a.cmisno
left outer join cm c on a.cmno = c.cmno
set a.edate = (case when b.eend is not null then date_format(b.eend,'%Y-%m-%d 23:59:59') else a.edate end)
,a.sdate = (case when b.estart is not null then date_format(b.estart,'%Y-%m-%d 00:00:00') else a.sdate end)
where a.lectno = #lectno# and c.cshape = 1;
update lect a
left outer join cminningscd b on b.cmisno = a.cmisno
left outer join cm c on a.cmno = c.cmno
set a.edate = case when b.eend is not null then date_format(b.eend,'%Y-%m-%d 23:59:59') else a.edate end
where a.lectno = #lectno# and c.cshape &lt;&gt; 1;
</update>
<select id="lect.checkuser.cmisno" parameterClass="hashtable" resultClass="int">
select count(c.cmisno )
from lect a
inner join cminningscd b on b.cmisno = a.cmisno
left outer join cminningscd c on c.cmisno = #cmisno# and date_format(c.estart ,'%Y%m%d') = date_format(b.estart ,'%Y%m%d')
where a.status in (1,2) and a.ischanged =0
<isNotNull property="userno">and a.userno = #userno#</isNotNull>
</select>
<select id="lect.lectinning.new" parameterClass="hashtable" resultClass="data">
select a.logno longval
,a.lectno intval,a.cmino intval2,max(a.intval+a.intval2) intval3
,a.strval,a.strval2,a.intval3 intval4
from(
select a.logno,a.lectno,a.cmino
,case when b.edate &lt; <include refid="sql.now"></include> then 0 when b.status &lt;&gt; 1 then 0 else case when a.stime = a.etime then 1 else 0 end end intval
,case when b.edate &lt; <include refid="sql.now"></include> then 0 when b.status &lt;&gt; 1 then 0 else case when (timestampdiff(second,a.stime,a.etime)%300) = 0 then 1 else 0 end end intval2
,c.cname strval,d.ititle strval2,d.iseq intval3
from lectinningpage a
inner join lect b on b.lectno = a.lectno
inner join cm c on c.cmno = b.cmno
inner join cminning d on d.cmino = a.cmino
where b.userno = #userno#
order by a.cdt desc
limit 1
) a
</select>
<select id="lect.eqno.listforcheck" parameterClass="string" resultClass="questionitem">
select e.qno,b.eqno,e.qino,e.qitext,d.atype,c.atext,d.ispassspace,d.isignorecase
from cmex a
inner join cmexq b on b.exno = a.exno
inner join lectexq c on c.eqno = b.eqno
inner join question d on d.qno = b.qno
inner join questionitem e on e.qno = d.qno
where e.isright =1 and e.isdel=0
<isNotNull property="exno">and a.exno = #exno#</isNotNull>
<isNotNull property="lectno">and c.lectno = #lectno#</isNotNull>
<isNotEmpty property="eqnos">and b.eqno in ($eqnos$)</isNotEmpty>
order by e.qno,e.qino
</select>
<select id="lect.count.user" parameterClass="hashtable" resultClass="int">
select max(lectCnt) * min(checkNum)
from (
select count(t1.lectno) as lectCnt, 1 as checkNum
from lect t1
inner join cm t2 on t1.cmno = t2.cmno
inner join cg t3 on t2.cgno= t3.cgno
inner join pay t4 on t1.payno = t4.payno
inner join pplog t5 on t1.cmno= t5.cmno and t1.userno = t5.userno and t4.pplno = t5.pplno
where (t1.status = 1 or t1.status = 2) and (t4.pstatus= 1 or t4.pstatus=22) and t5.typeman = 28
<isNotNull property="userno">and t1.userno = #userno#</isNotNull>
<isNotEmpty property="edu">
<isNotEqual property="edu" compareValue="30">and t5.typegrade in (38,39)</isNotEqual>
</isNotEmpty>
<isNotEmpty property="cgcode">
<isNotEqual property="cgcode" compareValue="105">and t3.cgcode in (103,104)</isNotEqual>
<Equal property="cgcode" compareValue="105">and t3.cgcode = 105</Equal>
</isNotEmpty>
union
select 0 as lectCnt, (case when count(t1.lectno) > 0 then -1 else 1 end) as checkNum
from lect t1
inner join cm t2 on t1.cmno = t2.cmno
inner join cg t3 on t2.cgno= t3.cgno
where (t1.status = 1 or t1.status = 2) and t2.isdel= 0 and t2.isuse= 1 and t2.ismaster = 0 and t1.userno = #userno# and t2.pcmno = #pcmno#
)t
</select>
<select id="lect.count.user2" parameterClass="hashtable" resultClass="int">
select max(lectCnt) * min(checkNum)
from (
select count(t1.lectno) as lectCnt, 1 as checkNum
from lect t1
inner join cm t2 on t1.cmno = t2.cmno
inner join cg t3 on t2.cgno= t3.cgno
inner join pay t4 on t1.payno = t4.payno
inner join pplog t5 on t1.cmno= t5.cmno and t1.userno = t5.userno and t4.pplno = t5.pplno
where (t1.status = 1 or t1.status = 2) and (t4.pstatus= 1 or t4.pstatus=22) and t3.cgcode in (103,104,105) and t5.typegrade = #grade# and t5.typeedu = #edu#
and t1.userno = #userno# and t5.typeman = 28
union
select 0 as lectCnt, (case when count(t1.lectno) > 0 then -1 else 1 end) as checkNum
from lect t1
inner join cm t2 on t1.cmno = t2.cmno
inner join cg t3 on t2.cgno= t3.cgno
where (t1.status = 1 or t1.status = 2) and t2.isdel= 0 and t2.isuse= 1 and t2.ismaster = 0 and t1.userno = #userno# and t2.pcmno = #pcmno#
)t
</select>
<select id="lect.count.user3" parameterClass="hashtable" resultClass="int">
select max(lectCnt) * min(checkNum)
from (
select count(t1.lectno) as lectCnt, 1 as checkNum
from lect t1
inner join cm t2 on t1.cmno = t2.cmno
inner join cg t3 on t2.cgno= t3.cgno
inner join pay t4 on t1.payno = t4.payno
inner join pplog t5 on t1.cmno= t5.cmno and t1.userno = t5.userno and t4.pplno = t5.pplno
where (t1.status = 1 or t1.status = 2) and (t4.pstatus= 1 or t4.pstatus=22) and t3.cgcode in (103,104) and t5.typeedu = 30
and t1.userno = #userno# and t5.typeman = 28
union
select 0 as lectCnt, (case when count(t1.lectno) > 0 then -1 else 1 end) as checkNum
from lect t1
inner join cm t2 on t1.cmno = t2.cmno
inner join cg t3 on t2.cgno= t3.cgno
where (t1.status = 1 or t1.status = 2) and t2.isdel= 0 and t2.isuse= 1 and t2.ismaster = 0 and t1.userno = #userno# and t2.pcmno = #pcmno#
)t
</select>
<select id="lect.count.user4" parameterClass="hashtable" resultClass="int">
select count(t1.lectno)
from lect t1
inner join cm t2 on t1.cmno = t2.cmno
inner join cg t3 on t2.cgno= t3.cgno
where (t1.status = 1 or t1.status = 2) and t2.isdel= 0 and t2.isuse= 1 and t2.ismaster = 0 and t1.userno = #userno# and t2.pcmno = #pcmno#
</select>
<select id="lect.pplog.get" parameterClass="hashtable" resultClass="lect">
select l.lectno, l.cmno, l.payno, pp.cshape, cc.cname zstring1, cc2.cname zstring2, cc3.cname zstring3, cc4.cname zstring4, cc5.cname zstring5
from lect l
inner join pay p on l.payno = p.payno and l.userno = p.userno
inner join pplog pp on p.pplno = pp.pplno
left outer join comcode cc on cc.ccode = pp.typeman
left outer join comcode cc2 on cc2.ccode = pp.typeedu
left outer join comcode cc3 on cc3.ccode = pp.typegrade
left outer join comcode cc4 on cc4.ccode = pp.typejob
left outer join comcode cc5 on cc5.ccode = pp.typejobitem
where l.lectno = #lectno# and l.userno = #userno#
</select>
<!--과제 첨부 삭제시-->
<update id="lect.lectsd.del" parameterClass="int">
update lectsd set <include refid="sql.up"></include>
,submittime=null
,submitip=null
,fgno=null
where lectno=#lectno# and sdno=#sdno#;
</update>
<select id="lect.get.lectsdChk" parameterClass="hashtable" resultClass="lect">
SELECT l.lectno, ( CASE WHEN g.stime IS NULL THEN 0 ELSE 1 END) intv1
FROM lect l
INNER JOIN users u ON l.userno= u.userno
INNER JOIN cminning ci ON l.cmno = ci.cmno AND ci.isscd=1 AND ci.scdtype=0
LEFT OUTER JOIN lectinning g ON g.cmino = ci.cmino AND g.lectno = l.lectno
WHERE l.lectno in ($lectnos$)
</select>
<select id="lect.lectex.forgradeupload" parameterClass="hashtable" resultClass="lectex">
select a.cmino, b.lectno, ifnull(b.iscomplete,0) as iscomplete, c.cmno, c.cname, e.exno, e.exname, e.tpoint
from lectinning a
inner join lect b on b.lectno = a.lectno and b.status = 1 and b.ischanged = 0
inner join cm c on c.cmno = b.cmno and c.cshape = 2 and c.isdel = 0
inner join cminning d on d.cmno = b.cmno and d.cmino = a.cmino and d.isscd = 1
inner join cmex e on e.cmno = b.cmno and e.extype = 1 and e.isdel = 0
where a.istatus = 2
<isNotNull property="lectno">and a.lectno = #lectno#</isNotNull>
<isNotNull property="stime">and cast(a.stime as date) = #stime#</isNotNull>
and b.userno = #userno#;
</select>
<update id="lect.lectex.point.byadmin" parameterClass="lectex" >
<include refid="lectexcreate"></include>
update lectex
set <include refid="sql.up"></include>
,tpoint=#tpoint#
,isbyadmin=1
where lectno=#lectno# and exno=#exno#;
update lect l
inner join (
select l.lectno, round(avg(le.tpoint),1) as avgtpoint, sum(le.tpoint) sumpoint, ce.tpoint
from lect l
inner 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
where l.status = 1 and l.lectno = #lectno#
group by l.lectno
)t on l.lectno = t.lectno
inner join cmev cv on l.cmno = cv.cmno
set l.exfpoint = t.avgtpoint
, l.fpoint = round((t.avgtpoint / t.tpoint * 100) * cv.final / 100,1)
, l.udt = now()
, l.uno = #uno#
, l.uip=#uip#
where l.lectno = #lectno#;
</update>
</statements>
</sqlMap>