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); } }
导入之后,找到对应的定时任务 执行