Quartz 定时任务

public void daiyueList(SysQuartzJobContext jobContext){
    try{
        HQLInfo hqlInfo = new HQLInfo();
        hqlInfo.setWhereBlock("docStatus=:docStatus");
        hqlInfo.setParameter("docStatus","20");

        List<CnnchnLoanAtm> list = getServiceImp().findList(hqlInfo);
        for (CnnchnLoanAtm cnnchnLoanAtm : list) {
            // 获取提款到期日
            Date withdrawalDate = cnnchnLoanAtm.getFdWithdrawalDate();
            if (withdrawalDate == null) {
                return; // 如果提款到期日为 null,直接返回
            }

            // 计算前一个月的日期
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(withdrawalDate);
            calendar.add(Calendar.MONTH, -1); // 减去一个月
            Date oneMonthBefore = calendar.getTime();
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
            String oneMonthBefore1 = sdf.format(oneMonthBefore);
            // 获取当前日期
            Date currentDate = new Date();
            String currentDate1 = sdf.format(currentDate);


            // 计算前一个月的日期
            Calendar calenda = Calendar.getInstance();
            calenda.setTime(withdrawalDate);
            calenda.add(Calendar.MONTH, -2); // 减去2个月
            Date twoMonth = calenda.getTime();
            String two = sdf.format(twoMonth);
            // 获取当前日期
            Date current = new Date();
            String current1 = sdf.format(current);

            // 如果当前日期等于前一个月的日期,发送待阅通知
            if (two.equals(current1)) {
                // 获取提款发起人
                NotifyContext notifyContext = getSysNotifyMainCoreService().getContext("");
                List<SysOrgElement> targets = new ArrayList<>();
                targets.add(cnnchnLoanAtm.getDocCreator());
                notifyContext.setNotifyTarget(targets);
                notifyContext.setSubject(new StringBuilder().append("提醒:您的提款计划距离到期日还有两个月,请及时处理!").toString());
                notifyContext.setNotifyType("todo"); // 待阅通知
                notifyContext.setFlag(SysNotifyConstant.NOTIFY_TODOTYPE_ONCE); // 一次性待阅
                notifyContext.setKey("");
                // 发送通知
                getSysNotifyMainCoreService().send(cnnchnLoanAtm, notifyContext, null);
                System.out.println("已向提款发起人发送待阅通知:" + cnnchnLoanAtm.getDocCreator().getFdName());
            }else if(currentDate1.equals(oneMonthBefore1)){
                // 获取提款发起人
                NotifyContext notifyContext = getSysNotifyMainCoreService().getContext("");
                List<SysOrgElement> targets = new ArrayList<>();
                targets.add(cnnchnLoanAtm.getDocCreator());
                notifyContext.setNotifyTarget(targets);
                notifyContext.setSubject(new StringBuilder().append("提醒:您的提款计划距离到期日还有一个月,请及时处理!").toString());
                notifyContext.setNotifyType("todo"); // 待阅通知
                notifyContext.setFlag(SysNotifyConstant.NOTIFY_TODOTYPE_ONCE); // 一次性待阅
                notifyContext.setKey("");
                // 发送通知
                getSysNotifyMainCoreService().send(cnnchnLoanAtm, notifyContext, null);
                System.out.println("已向提款发起人发送待阅通知:" + cnnchnLoanAtm.getDocCreator().getFdName());
            }

            }
            jobContext.logMessage("任务执行成功");

    }catch (Exception e){
        jobContext.logError(e);
    }

}

 导入之后,找到对应的定时任务  执行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值