工作中的笔记

<!--定时作业-->
<!--添加释放记录-->
<insert id="automaticRelease1" >
    insert into zxzq_drawcash_record (status ,memberid , releasenum, securitiesnum, securitiesnum_after, time, securitiesid)
    select 2, h.memberid,
    TRUNCATE( if(r.securities > TRUNCATE(h.securitiesnum * 0.999,2), TRUNCATE(h.securitiesnum-r.securities,2),TRUNCATE(h.securitiesnum * 0.001,2)),2),
    h.securitiesnum,
    TRUNCATE(if(r.securities > TRUNCATE(h.securitiesnum * 0.999,2),r.securities,TRUNCATE(h.securitiesnum - TRUNCATE(
    if(r.securities > TRUNCATE(h.securitiesnum * 0.999,2),TRUNCATE(h.securitiesnum-r.securities,2) ,TRUNCATE(h.securitiesnum * 0.001,2)),2),2)),2),
    NOW(),r.securitiesid
    from zxzq_holding h ,zxzq_record r where h.securitiesid = r.securitiesid and r.price = r.realprice and h.securitiesnum > r.securities
</insert>

<update id="automaticRelease2">
    replace into zxzq_drawcash (memberid, securitiesnum) select h.memberid ,
    TRUNCATE(d.securitiesnum + sum(if(r.securities > TRUNCATE(h.securitiesnum*0.999,2),
    TRUNCATE(h.securitiesnum-r.securities,2),TRUNCATE(h.securitiesnum*0.001,2))),2)
    from zxzq_holding h inner join zxzq_drawcash d on d.memberid = h.memberid
    inner join zxzq_record r on r.price=r.realprice and h.securitiesnum > r.securities  and h.securitiesid=r.securitiesid group by h.memberid
</update>
<update id="automaticRelease3">
    update zxzq_holding h, zxzq_record r set h.securitiesnum =
    if( r.securities > TRUNCATE(h.securitiesnum * 0.999,2) , r.securities,  TRUNCATE(h.securitiesnum * 0.999,2)) where r.securitiesid = h.securitiesid
    and r.price = r.realprice
</update>

作为定时器的sql代码,通过spring定时任务来完成。


<task:annotation-driven />
<task:scheduled-tasks>
   <task:scheduled ref="securitiesController" method="automaticRelease" cron="0 0 0 ? * MON-FRI"/>
</task:scheduled-tasks>

还需要在
securitiesController
automaticRelease
方法上面增加
@Scheduled
注解。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值