YNICTE/Dao/MyBatis/Maps/Attend.xml

216 lines
12 KiB
XML
Raw Normal View History

2020-10-12 14:39:23 +09:00
<?xml version="1.0" encoding="utf-8"?>
<sqlMap xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/tr/xmlschema-1/" namespace="">
<alias>
</alias>
<cacheModels>
<cacheModel id="attendCache" implementation="LRU" >
<flushInterval hours="1" />
<property name="CacheSize" value="1000" />
</cacheModel>
</cacheModels>
<resultMaps></resultMaps>
<statements>
<update id="att.attend.allin" parameterClass="hashtable">
update lectinning
set istatus=2
,stime=case when stime is null then <include refid="sql.now"></include> else stime end
,etime=case when etime is null then <include refid="sql.now"></include> else etime end
,sip=case when sip is null then #uip# else sip end
,eip=case when eip is null then #uip# else eip end
,ispcs=case when ispcs is null then 1 else ispcs end
,ispce=case when ispce is null then 1 else ispce end
,statustime=<include refid="sql.now"></include>
,statusreason=#statusreason#
,statususerno=#uno#
where lectno in ($lectnos$) and (istatus is null or istatus&lt;2);
insert into lectinning(lectno,cmino,totstudy,stime,etime,istatus,statustime,statusreason,statususerno,<include refid="sql.inc"></include>)
select a.lectno,b.cmino,0,<include refid="sql.now"></include>,<include refid="sql.now"></include>,2,<include refid="sql.now"></include>,#statusreason#,#uno#,<include refid="sql.inv"></include>
from lect a
inner join cminning b on b.cmno=a.cmno
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino
where a.lectno in ($lectnos$) and a.status=1 and a.ischanged=0 and c.lectno is null;
update lect set <include refid="sql.up"></include>
,attrate=100
,stime=case when stime is null then <include refid="sql.now"></include> else stime end
,etime=case when etime is null then <include refid="sql.now"></include> else etime end
,sip=case when sip is null then #uip# else sip end
,eip=case when eip is null then #uip# else eip end
,ispcs=case when ispcs is null then 1 else ispcs end
,ispce=case when ispce is null then 1 else ispce end
where lectno in ($lectnos$)
</update>
<update id="att.off.save" parameterClass="cminning">
update lectinning a
inner join (
<iterate property="Ds" open="" conjunction="union all" close=""> select #Ds[].lectno# lectno,#Ds[].istatus# istatus </iterate>
) b on b.lectno=a.lectno
set a.uip=#uip#,a.uno=#uno#
,a.istatus=b.istatus
,a.stime = a.stime
,a.etime = a.etime
,a.sip = case when a.sip is null then #uip# else a.sip end
,a.eip = case when a.eip is null then #uip# else a.eip end
,a.ispcs = case when a.ispcs is null then 1 else a.ispcs end
,a.ispce = case when a.ispce is null then 1 else a.ispce end
where a.cmino=#cmino#;
insert into lectinning (lectno,cmino,totstudy<!--,stime,etime-->,istatus,statustime,statusreason,sip,eip,ispcs,ispce,<include refid="sql.inc"></include>)
select a.lectno,#cmino#,0
<!--,case when a.istatus is not null then <include refid="sql.now"></include> else NULL end
,case when a.istatus is not null then <include refid="sql.now"></include> else NULL end-->
,a.istatus,null,null,#uip#,#uip#,1,1,<include refid="sql.inv"></include>
from (
<iterate property="Ds" open="" conjunction="union all" close=""> select #Ds[].lectno# lectno,#Ds[].istatus# istatus </iterate>
) a
left outer join lectinning b on b.cmino=#cmino# and b.lectno=a.lectno
where b.lectno is null;
update lect a
inner join (
select a.lectno,convert(100*count(c.lectno)/count(b.cmino), int) attrate
from lect a
2021-11-03 15:19:08 +09:00
inner join cminning b on b.cmno=a.cmno and ifnull(b.isscd,0)=0
2020-10-12 14:39:23 +09:00
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino and c.istatus in (1,2)
where a.lectno in ($lectnos$)
group by a.lectno
) b on b.lectno=a.lectno
set a.attrate=b.attrate
,a.stime=case when a.stime is null then <include refid="sql.now"></include> else a.stime end
,a.etime=case when a.etime is null then <include refid="sql.now"></include> else a.etime end
,a.sip=case when a.sip is null then #uip# else a.sip end
,a.eip=case when a.eip is null then #uip# else a.eip end
,a.ispcs=case when a.ispcs is null then 1 else a.ispcs end
,a.ispce=case when a.ispce is null then 1 else a.ispce end
</update>
2021-11-03 15:19:08 +09:00
<update id="att.scd.save" parameterClass="cminning">
update lectinning a
inner join (
<iterate property="Ds" open="" conjunction="union all" close=""> select #Ds[].lectno# lectno,#Ds[].cmino# cmino,#Ds[].istatus# istatus </iterate>
) b on b.lectno=a.lectno and b.cmino = a.cmino
set a.uip=#uip#,a.uno=#uno#
,a.istatus=b.istatus
,a.stime = a.stime
,a.etime = a.etime
,a.sip = case when a.sip is null then #uip# else a.sip end
,a.eip = case when a.eip is null then #uip# else a.eip end
,a.ispcs = case when a.ispcs is null then 1 else a.ispcs end
,a.ispce = case when a.ispce is null then 1 else a.ispce end;
insert into lectinning (lectno,cmino,totstudy<!--,stime,etime-->,istatus,statustime,statusreason,sip,eip,ispcs,ispce,<include refid="sql.inc"></include>)
select a.lectno,a.cmino,0
,a.istatus,null,null,#uip#,#uip#,1,1,<include refid="sql.inv"></include>
from (
<iterate property="Ds" open="" conjunction="union all" close=""> select #Ds[].lectno# lectno,#Ds[].cmino# cmino,#Ds[].istatus# istatus </iterate>
) a
left outer join lectinning b on b.cmino=a.cmino and b.lectno=a.lectno
where b.lectno is null;
update lect a
inner join (
select a.lectno,convert(100*count(c.lectno)/count(b.cmino), int) attrate
from lect a
inner join cminning b on b.cmno=a.cmno and ifnull(b.isscd,0)=0
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino and c.istatus in (1,2)
where a.lectno in ($lectnos$)
group by a.lectno
) b on b.lectno=a.lectno
set a.attrate=b.attrate
,a.stime=case when a.stime is null then <include refid="sql.now"></include> else a.stime end
,a.etime=case when a.etime is null then <include refid="sql.now"></include> else a.etime end
,a.sip=case when a.sip is null then #uip# else a.sip end
,a.eip=case when a.eip is null then #uip# else a.eip end
,a.ispcs=case when a.ispcs is null then 1 else a.ispcs end
,a.ispce=case when a.ispce is null then 1 else a.ispce end;
</update>
2020-10-12 14:39:23 +09:00
<update id="att.att.in" parameterClass="hashtable">
update lectinning set <include refid="sql.up"></include>
,lectno=#lectno#,cmino=#cmino#,totstudy=0
,stime=<include refid="sql.now"></include>,etime=null
,istatus=1,statustime=null,statusreason=null
where lectno=#lectno# and cmino=#cmino# and istatus is null;
insert into lectinning (lectno,cmino,totstudy,stime,etime,istatus,statustime,statusreason,sip,eip,ispcs,ispce,<include refid="sql.inc"></include>)
select #lectno#,#cmino#,0,<include refid="sql.now"></include>,null,1,null,null,#uip#,null,1,null,<include refid="sql.inv"></include>
from (select 1 col1) a
left outer join lectinning b on b.lectno=#lectno# and b.cmino=#cmino#
where b.lectno is null;
update lect
set stime = case when stime is null then <include refid="sql.now"></include> else stime end
,sip = case when sip is null then #uip# else sip end
,ispcs = case when ispcs is null then 1 else ispcs end
where lectno=#lectno#
</update>
<update id="att.att.out" parameterClass="hashtable">
update lectinning set <include refid="sql.up"></include>
,totstudy=timestampdiff(SECOND, stime, <include refid="sql.now"></include>)
,etime=<include refid="sql.now"></include>
,eip=#uip#
,ispce=1
,istatus=2
where lectno=#lectno# and cmino=#cmino# and istatus=1;
update lect a
inner join (
select a.lectno,convert(100*count(c.lectno)/count(b.cmino), int) attrate
from lectinning a
2021-11-03 15:19:08 +09:00
inner join cminning b on b.cmino=a.cmino and ifnull(b.isscd,0)=0
2020-10-12 14:39:23 +09:00
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino and c.istatus=2
where a.lectno=#lectno# and a.cmino=#cmino# and a.istatus=2
group by a.lectno
) b on b.lectno=a.lectno
set a.attrate=b.attrate
,a.etime=<include refid="sql.now"></include>,a.eip=#uip#,a.ispce=1
</update>
<update id="att.abs" parameterClass="hashtable">
update lectinning
set istatus=2
,stime=case when stime is null then <include refid="sql.now"></include> else stime end
,etime=case when etime is null then <include refid="sql.now"></include> else etime end
,sip=case when sip is null then #uip# else sip end
,eip=case when eip is null then #uip# else eip end
,ispcs=case when ispcs is null then 1 else ispcs end
,ispce=case when ispce is null then 1 else ispce end
,statustime=<include refid="sql.now"></include>
,statusreason=#statusreason#
,statususerno=#uno#
where lectno=#lectno# and cmino=#cmino# and (istatus is null or istatus&lt;2);
insert into lectinning(lectno,cmino,totstudy,stime,etime,istatus,statustime,statusreason,statususerno,<include refid="sql.inc"></include>)
select a.lectno,#cmino#,0,<include refid="sql.now"></include>,<include refid="sql.now"></include>,2,<include refid="sql.now"></include>,#statusreason#,#uno#,<include refid="sql.inv"></include>
from lect a
left outer join lectinning b on b.lectno=a.lectno and b.cmino=#cmino#
where a.lectno=#lectno# and a.status=1 and a.ischanged=0 and b.lectno is null;
update lect a
inner join (
select a.lectno,convert(100*count(c.lectno)/count(b.cmino), int) attrate
from lectinning a
inner join lect a2 on a2.lectno=a.lectno
2021-11-03 15:19:08 +09:00
inner join cminning b on b.cmno=a2.cmno and ifnull(b.isscd,0)=0
2020-10-12 14:39:23 +09:00
left outer join lectinning c on c.lectno=a.lectno and c.cmino=b.cmino and c.istatus=2
where a.lectno=#lectno# and a.cmino=#cmino# and a.istatus=2
group by a.lectno
) b on b.lectno=a.lectno
set a.attrate=b.attrate
,a.stime=case when a.stime is null then <include refid="sql.now"></include> else a.stime end
,a.etime=case when a.etime is null then <include refid="sql.now"></include> else a.etime end
,a.sip=case when a.sip is null then #uip# else a.sip end
,a.eip=case when a.eip is null then #uip# else a.eip end
,a.ispcs=case when a.ispcs is null then 1 else a.ispcs end
,a.ispce=case when a.ispce is null then 1 else a.ispce end
where a.lectno=#lectno#
</update>
</statements>
</sqlMap>