init
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package io.v.nutz.task.conn;
|
||||
|
||||
import org.nutz.boot.AppContext;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.quartz.utils.ConnectionProvider;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class NutConnectionProvider implements ConnectionProvider {
|
||||
|
||||
protected DataSource dataSource;
|
||||
protected String iocname = "dataSource";
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
return dataSource.getConnection();
|
||||
}
|
||||
|
||||
public void shutdown() throws SQLException {}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void initialize() throws SQLException {
|
||||
if (dataSource != null)
|
||||
return;
|
||||
Ioc ioc = AppContext.getDefault().getIoc();
|
||||
dataSource = ioc.get(DataSource.class, iocname);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package io.v.nutz.task.constant;
|
||||
|
||||
public enum InstStatusEnum {
|
||||
/**
|
||||
* 进行中
|
||||
*/
|
||||
ON_GOING(0),
|
||||
/**
|
||||
* 终止
|
||||
*/
|
||||
TERMINATION(1),
|
||||
/**
|
||||
* 完成
|
||||
*/
|
||||
COMPLETE(2),
|
||||
/**
|
||||
* 驳回
|
||||
*/
|
||||
REJECTED(3),
|
||||
/**
|
||||
* 撤销
|
||||
*/
|
||||
RESCINDED(4);
|
||||
|
||||
|
||||
private int value = 0;
|
||||
|
||||
InstStatusEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package io.v.nutz.task.constant;
|
||||
|
||||
/**
|
||||
* 南航待办常量类
|
||||
*/
|
||||
public class TaskConstant {
|
||||
|
||||
public static final String APPID = "dyAp1NZ";
|
||||
|
||||
public static final String APPSECRET = "uUYqrJh";
|
||||
|
||||
public static final int THIRDPARTY_ID = 8;
|
||||
|
||||
/*获取 token GET*/
|
||||
public static final String GET_TOKEN_URL = "https://ehall3.nuaa.edu.cn/open/token/get?appid=%s&appsecret=%s";
|
||||
|
||||
/*保存事项列表 POST*/
|
||||
public static final String SAVE_APP_URL = "https://ehall3.nuaa.edu.cn/open/apps-push/push-apps?access_token=%s";
|
||||
|
||||
/*推送任务数据(二次推送同一任务为更新数据) POST*/
|
||||
public static final String PUSH_TASK_URL = "https://ehall3.nuaa.edu.cn/open/apps-push/push-task?access_token=%s";
|
||||
|
||||
/*保存任务操作记录 POST*/
|
||||
public static final String SAVE_TASK_LOG_URL = "https://ehall3.nuaa.edu.cn/open/apps-push/push-task-log?access_token=%s";
|
||||
|
||||
|
||||
/*
|
||||
地址:http://ehall3.nuaa.edu.cn/v2/site/login?isShowType=1
|
||||
账号:xghceshi1
|
||||
密码:TTTssshio777
|
||||
账号:xghceshi2
|
||||
密码:TTTssshio777
|
||||
这个是我们的账号,但是不是同一身份认证的,由于我们的有在南航使用,并定制一些事项,我们首页暂时不开放,
|
||||
您登陆后替换链接至:https://ehall3.nuaa.edu.cn/v2/matter/todo
|
||||
即可进入任务中心
|
||||
APPID:dyAp1NZ APPSECRET:uUYqrJh thirdparty_id: 8
|
||||
请求域名地址 > https://ehall3.nuaa.edu.cn/
|
||||
|
||||
对接文档地址:
|
||||
http://docs.rlstech.cn:8081/crap-api/index.do#/ffff-1533606930458-17217111140-0002/fr
|
||||
ont/interfaceDetail/ffff-1571368576909-127001-0085
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package io.v.nutz.task.constant;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 待办任务状态
|
||||
*/
|
||||
public enum TaskStatusEnum {
|
||||
/**
|
||||
* 未申领
|
||||
*/
|
||||
NOT_RECEIVE(0),
|
||||
|
||||
/**
|
||||
* 进行中
|
||||
*/
|
||||
ON_GOING(1),
|
||||
|
||||
/**
|
||||
* 已驳回
|
||||
*/
|
||||
REJECTED(2),
|
||||
|
||||
/**
|
||||
* 完成
|
||||
*/
|
||||
COMPLETE(3),
|
||||
|
||||
/**
|
||||
* 已撤销
|
||||
*/
|
||||
RESCINDED(4);
|
||||
|
||||
private int value = 0;
|
||||
|
||||
TaskStatusEnum(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package io.v.nutz.task.job;
|
||||
|
||||
import io.v.nutz.zhgh.activity.models.ActivityUserScope;
|
||||
import io.v.nutz.base.utils.DateUtil;
|
||||
import io.v.nutz.base.utils.MsgApi;
|
||||
import io.v.nutz.zhgh.blessing.models.Blessing;
|
||||
import io.v.nutz.zhgh.blessing.models.BlessingUser;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.services.SysTaskService;
|
||||
import io.v.nutz.sys.services.impl.SysTaskServiceImpl;
|
||||
import io.v.nutz.task.services.TaskPlatformService;
|
||||
import io.v.nutz.task.services.impl.TaskPlatformServiceImpl;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@IocBean
|
||||
public class BlessingJob implements Job {
|
||||
@Inject
|
||||
private MsgApi msgApi;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
try {
|
||||
Ioc ioc = Mvcs.ctx().getDefaultIoc();
|
||||
Dao dao = ioc.get(Dao.class);
|
||||
TaskPlatformService taskPlatformService = ioc.get(TaskPlatformServiceImpl.class);
|
||||
SysTaskService sysTaskService = ioc.get(SysTaskServiceImpl.class);
|
||||
|
||||
String taskId = context.getJobDetail().getKey().getName();
|
||||
JobDataMap data = context.getJobDetail().getJobDataMap();
|
||||
Blessing blessing = dao.fetch(Blessing.class, data.getString("blessingId"));
|
||||
List<String> sendTypes = blessing.getSendTypes();
|
||||
String activityGroupId = blessing.getActivityGroupId();
|
||||
String blessingMode = blessing.getBlessingMode();
|
||||
String blessingContent = blessing.getBlessingContent();
|
||||
|
||||
List<Sys_user> sysUsers;
|
||||
List<ActivityUserScope> userScopes = dao.query(ActivityUserScope.class, Cnd.where("groupId", "=", activityGroupId));
|
||||
List<String> userIds = userScopes.stream().map(ActivityUserScope::getUserId).collect(Collectors.toList());
|
||||
|
||||
if (blessingMode.equals("birthday")) {
|
||||
String dateStr = DateUtil.getDate().substring(5);
|
||||
sysUsers = dao.query(Sys_user.class, Cnd.where("id", "in", userIds).and("DATE_FORMAT ( birthday,'%m-%d' )", "=", dateStr));
|
||||
} else {
|
||||
sysUsers = dao.query(Sys_user.class, Cnd.where("id", "in", userIds));
|
||||
}
|
||||
|
||||
ArrayList<Map> list2 = new ArrayList<>();
|
||||
sysUsers.forEach(v->{
|
||||
list2.add(Map.of("type", "User", "userId", v.getLoginname(), "name",v.getUsername()));
|
||||
});
|
||||
//发送消息
|
||||
// msgApi.sendMsg(blessingContent, list2, "职工祝福", "WeChat", MsgApi.sendMode.normal.name());
|
||||
|
||||
//发送消息之后把人加进去
|
||||
List<BlessingUser> blessingUsers = new ArrayList<>();
|
||||
sysUsers.forEach(v -> {
|
||||
BlessingUser blessingUser = new BlessingUser();
|
||||
blessingUser.setBlessingId(blessing.getId());
|
||||
blessingUser.setUserId(v.getId());
|
||||
blessingUser.setApplyDate(DateUtil.getDate());
|
||||
blessingUsers.add(blessingUser);
|
||||
|
||||
});
|
||||
dao.insert(blessingUsers);
|
||||
|
||||
//如果发送的时间已发送完成,就删除定时任务
|
||||
List<String> cronExeTimes = taskPlatformService.getCronExeTimes(blessing.getBlessingCron());
|
||||
if (cronExeTimes.size() == 0) {
|
||||
dao.update(Blessing.class, Chain.make("isSend", 2), Cnd.where("id", "=", blessing.getId()));
|
||||
taskPlatformService.delete(taskId, taskId);
|
||||
sysTaskService.delete(taskId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package io.v.nutz.task.job;
|
||||
|
||||
import io.v.nutz.sys.services.SysTaskService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
@IocBean
|
||||
public class CakeCardJob implements Job {
|
||||
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
protected SysTaskService sysTaskService;
|
||||
|
||||
@Inject
|
||||
protected Dao dao;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
/*JobDataMap data = context.getJobDetail().getJobDataMap();
|
||||
String questionId = data.getString("questionId");
|
||||
//题目id
|
||||
String iid = dao.fetch(Question_issue.class, Cnd.where("iqid", "=", "f1b0567da90c44d2b712f897495c2a3e")).getIid();
|
||||
|
||||
//默认选项
|
||||
Question_wor wor = dao.fetch(Question_wor.class, Cnd.where("wiid", "=", iid).and("wismr", "=", 1));
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
id AS userId
|
||||
FROM
|
||||
`user`
|
||||
WHERE
|
||||
unionid IS NOT NULL
|
||||
AND id NOT IN (
|
||||
SELECT
|
||||
userId
|
||||
FROM
|
||||
question_reply
|
||||
WHERE
|
||||
qid = @questionId)
|
||||
""");
|
||||
|
||||
sql.setParam("questionId", questionId);
|
||||
sql.setCallback(Sqls.callback.entities());
|
||||
sql.setEntity(dao.getEntity(Question_reply.class));
|
||||
dao.execute(sql);
|
||||
List<Question_reply> list = sql.getList(Question_reply.class);
|
||||
|
||||
for (Question_reply questionReply : list) {
|
||||
questionReply.setQid(questionId);
|
||||
questionReply.setRwid(wor.getWid());
|
||||
questionReply.setRtime(DateUtil.getDateTime());
|
||||
questionReply.setSave(false);
|
||||
}
|
||||
|
||||
dao.insert(list);*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package io.v.nutz.task.job;
|
||||
|
||||
import io.v.nutz.zhgh.proposal.services.ProposalConfigService;
|
||||
import io.v.nutz.sys.services.SysTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description 提案 提醒提案人附议情况
|
||||
* @createTime 2022年02月18日 13:41:00
|
||||
*/
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class ProposalRemindCreatorJob implements Job {
|
||||
|
||||
@Inject
|
||||
protected SysTaskService sysTaskService;
|
||||
|
||||
@Inject
|
||||
protected ProposalConfigService proposalConfigService;
|
||||
|
||||
@Inject
|
||||
protected Dao dao;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
String taskId = context.getJobDetail().getKey().getName();
|
||||
JobDataMap data = context.getJobDetail().getJobDataMap();
|
||||
String teacherMeetingId = data.getString("teacherMeetingId");
|
||||
proposalConfigService.remindProposalCreator(teacherMeetingId);
|
||||
// sysTaskService.update(Chain.make("exeAt", (int) (System.currentTimeMillis() / 1000)).add("exeResult", "执行成功"), Cnd.where("id", "=", taskId));
|
||||
sysTaskService.clear(Cnd.where("id", "=", taskId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package io.v.nutz.task.job;
|
||||
|
||||
import io.v.nutz.sys.services.SysTaskService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* Created by Wizzer.cn on 2015/6/27.
|
||||
*/
|
||||
@IocBean
|
||||
public class TestJob implements Job {
|
||||
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
protected SysTaskService sysTaskService;
|
||||
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobDataMap data = context.getJobDetail().getJobDataMap();
|
||||
String taskId = context.getJobDetail().getKey().getName();
|
||||
String hi = data.getString("hi");
|
||||
log.info("Test Job hi::" + hi);
|
||||
sysTaskService.update(Chain.make("exeAt", (int) (System.currentTimeMillis() / 1000)).add("exeResult", "执行成功"), Cnd.where("id", "=", taskId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package io.v.nutz.task.job;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.v.nutz.zhgh.data.model.UserSource;
|
||||
import io.v.nutz.zhgh.data.service.SourceUserService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@IocBean
|
||||
public class UserUpdateJobTask implements Job {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private SourceUserService sourceUserService;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
sourceUserService.dailyScheduledUpdates();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package io.v.nutz.task.job.brithday;
|
||||
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.zhgh.blessing.models.Greeting;
|
||||
import io.v.nutz.sys.models.Sys_config;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.trans.Trans;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author zzr
|
||||
* @Date 2023/5/26
|
||||
* @Description
|
||||
*/
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class GreetingJob implements Job {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
try {
|
||||
Trans.begin();
|
||||
//清除生日中间表
|
||||
baseService.dao().clear("greeting");
|
||||
//查询系统参数:生日祝福查询时间范围(当天+参数值)
|
||||
Sys_config fetch = baseService.dao().fetch(Sys_config.class, Cnd.where("configKey", "=", "GreetingTime"));
|
||||
Integer day = Integer.valueOf(fetch.getConfigValue());
|
||||
|
||||
//时间格式
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date = new Date();
|
||||
//获取当前时间
|
||||
String replace2 = sdf.format(date).replace("-", "").substring(4,8);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, +day);
|
||||
date = calendar.getTime();
|
||||
//获取当天时间的后GreetingTime天
|
||||
String replace1 = sdf.format(date).replace("-", "").substring(4,8);
|
||||
|
||||
//查询用户表
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
su.id,
|
||||
su.idcard,
|
||||
su.loginname,
|
||||
su.birthday,
|
||||
su.username
|
||||
FROM
|
||||
`user` su
|
||||
WHERE
|
||||
su.idcard IS NOT NULL
|
||||
OR su.birthday IS NOT NULL
|
||||
""");
|
||||
List<NutMap> list = baseService.listMap(sql);
|
||||
|
||||
List<Greeting> greetings = new ArrayList<>();
|
||||
for (NutMap su : list) {
|
||||
Greeting greeting = new Greeting();
|
||||
String substring = "";
|
||||
//(生日和身份证不为空),或者(生日不为空,身份证为空)
|
||||
if (Strings.isNotBlank(su.getString("birthday"))) {
|
||||
String birthday = su.getString("birthday");
|
||||
String replace = birthday.replace("-", "");//19951008
|
||||
substring = replace.substring(4,8);
|
||||
//生日为空,身份证不为空
|
||||
} else if (Strings.isNotBlank(su.getString("idcard")) && su.getString("idcard").length() >= 18) {
|
||||
String idcard = su.getString("idcard");
|
||||
substring = idcard.substring(10,14);
|
||||
}
|
||||
//比较截取时间和当前时间大小
|
||||
int i = substring.compareTo(replace2);
|
||||
//比较截取时间和后几天的大小
|
||||
int i1 = substring.compareTo(replace1);
|
||||
if (i <= 0 && i1 >= 0) {
|
||||
greeting.setBirthday(substring);
|
||||
greeting.setUserId(su.getString("id"));
|
||||
greeting.setUsername(su.getString("username"));
|
||||
greeting.setLoginname(su.getString("loginname"));
|
||||
greetings.add(greeting);
|
||||
}
|
||||
}
|
||||
baseService.dao().insert(greetings);
|
||||
Trans.commit();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package io.v.nutz.task.job.club;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.sys.constant.club.ClubRegistAuditState;
|
||||
import io.v.nutz.sys.models.SysClubUserHistory;
|
||||
import io.v.nutz.sys.models.Sys_club_user;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.trans.Trans;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 每天晚上23:59:59查询社团名单,如果在职变为拨付,如果退休变为不拨付
|
||||
* 如果时间为每年的12月31日,则备份一次所有拨付名单
|
||||
*/
|
||||
@IocBean
|
||||
public class ClubUserJob implements Job {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
//判断时间
|
||||
String currentDate = DateUtil.now();
|
||||
boolean day = "12-31".equals(DateUtil.format(DateUtil.parse(currentDate), "MM-dd"));
|
||||
|
||||
List<Sys_user> userList = dao.query(Sys_user.class, Cnd.NEW());
|
||||
Map<String, Sys_user> userMap = userList.stream().collect(Collectors.toMap(Sys_user::getId, o -> o));
|
||||
//查询所有社团名单
|
||||
List<Sys_club_user> clubUserList = dao.query(Sys_club_user.class, Cnd.where("status", "=", 5)
|
||||
.and("isNormal", "=", true)
|
||||
.and(new Static(" clubid in (select id from sys_club where isjs = false and state = %s)".formatted(ClubRegistAuditState.SCHOOL_PASS))));
|
||||
List<Sys_club_user> result = new ArrayList<>();
|
||||
List<SysClubUserHistory> historyList = new ArrayList<>();
|
||||
|
||||
List<String> workList = List.of("在职", "在岗");
|
||||
List<String> txList = List.of("退休", "退休【变号】");
|
||||
|
||||
clubUserList.forEach(item -> {
|
||||
Sys_user user = userMap.get(item.getUserid());
|
||||
if(StrUtil.isBlank(user.getUserState())) {
|
||||
item.setGiveMoney(false);
|
||||
result.add(item);
|
||||
} else {
|
||||
if(workList.contains(user.getUserState()) && !item.getGiveMoney()) {
|
||||
item.setGiveMoney(true);
|
||||
result.add(item);
|
||||
}
|
||||
if(txList.contains(user.getUserState()) && item.getGiveMoney()) {
|
||||
item.setGiveMoney(false);
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
if(day && item.getGiveMoney()) {
|
||||
SysClubUserHistory history = new SysClubUserHistory();
|
||||
history.setClubId(item.getClubid());
|
||||
history.setUserId(item.getUserid());
|
||||
history.setSf(item.getSf());
|
||||
history.setUserState(user.getUserState());
|
||||
history.setBTime(currentDate);
|
||||
historyList.add(history);
|
||||
}
|
||||
});
|
||||
|
||||
Trans.exec(() -> {
|
||||
dao.updateIgnoreNull(result);
|
||||
if(day) {
|
||||
dao.insert(historyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package io.v.nutz.task.job.fitnessWalk;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.v.nutz.sys.services.SysTaskService;
|
||||
import io.v.nutz.sys.services.impl.SysTaskServiceImpl;
|
||||
import io.v.nutz.task.services.TaskPlatformService;
|
||||
import io.v.nutz.task.services.impl.TaskPlatformServiceImpl;
|
||||
import io.v.nutz.zhgh.fitnessWalk.model.FitnessWalkAwardUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
import org.nutz.trans.Trans;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class FitnessWalkLotteryJob implements Job {
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
Ioc ioc = Mvcs.ctx().getDefaultIoc();
|
||||
Dao dao = ioc.get(Dao.class);
|
||||
TaskPlatformService taskPlatformService = ioc.get(TaskPlatformServiceImpl.class);
|
||||
SysTaskService sysTaskService = ioc.get(SysTaskServiceImpl.class);
|
||||
|
||||
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
||||
int lotteryQualificationStep = Integer.parseInt(jobDataMap.getString("lotteryQualificationStep"));
|
||||
int lotteryUserNum = Integer.parseInt(jobDataMap.getString("lotteryUserNum"));
|
||||
String mode = jobDataMap.getString("mode");
|
||||
String activityId = jobDataMap.getString("id");
|
||||
String lotteryQualificationDay = jobDataMap.getString("lotteryQualificationDay");
|
||||
|
||||
String awardName;
|
||||
Date startDate = null;
|
||||
Date endDate = null;
|
||||
if ("custom".equals(mode)){
|
||||
awardName = jobDataMap.getString("awardName");
|
||||
String startTimeStr = jobDataMap.getString("startDate");
|
||||
String endTimeStr = jobDataMap.getString("endDate");
|
||||
startDate = DateUtil.parse(startTimeStr,"yyyy-MM-dd");
|
||||
endDate = DateUtil.parse(endTimeStr,"yyyy-MM-dd");
|
||||
} else {
|
||||
awardName = null;
|
||||
}
|
||||
List<NutMap> userList = new ArrayList<>();
|
||||
|
||||
if (mode.equals("custom")) {
|
||||
//查询出符合条件的用户
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
jws.userId,
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.unionid,
|
||||
u.unionname,
|
||||
u.unitid,
|
||||
u.unitname
|
||||
FROM
|
||||
fitness_walk_step jws
|
||||
LEFT JOIN `user` u ON u.id = jws.userId
|
||||
WHERE
|
||||
jws.activityId = @activityId
|
||||
AND DATE ( jws.applyDate ) >= @startDate
|
||||
AND DATE ( jws.applyDate ) <= @endDate
|
||||
$lotteryQualificationDaySql
|
||||
GROUP BY
|
||||
jws.userId
|
||||
HAVING
|
||||
$stepHavingSql
|
||||
ORDER BY
|
||||
rand()
|
||||
LIMIT @lotteryUserNum
|
||||
""");
|
||||
if (Strings.isNotBlank(lotteryQualificationDay)) {
|
||||
sql.setVar("lotteryQualificationDaySql", new Static(" AND jws.step >= '%s' ".formatted(lotteryQualificationStep)));
|
||||
sql.setVar("stepHavingSql", new Static(" COUNT( jws.applyDate ) >= '%s' ".formatted(lotteryQualificationDay)));
|
||||
} else {
|
||||
sql.setVar("stepHavingSql", new Static(" SUM( jws.step ) > '%s' ".formatted(lotteryQualificationStep)));
|
||||
}
|
||||
sql.setParam("activityId", activityId);
|
||||
sql.setParam("step", lotteryQualificationStep);
|
||||
sql.setParam("startDate", startDate);
|
||||
sql.setParam("endDate", endDate);
|
||||
sql.setParam("lotteryUserNum", lotteryUserNum);
|
||||
userList = (List<NutMap>) Daos.query(dao, sql.toString(), Sqls.callback.maps());
|
||||
} else if (mode.equals("everyday")) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
jws.userId,
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.unionid,
|
||||
u.unionname,
|
||||
u.unitid,
|
||||
u.unitname
|
||||
FROM
|
||||
fitness_walk_step jws
|
||||
LEFT JOIN `user` u ON u.id = jws.userId
|
||||
WHERE
|
||||
jws.activityId = @activityId
|
||||
AND jws.step >= @step
|
||||
AND jws.applyDate = @date
|
||||
ORDER BY
|
||||
rand()
|
||||
LIMIT @lotteryUserNum
|
||||
""");
|
||||
sql.setParam("activityId", activityId);
|
||||
sql.setParam("step", lotteryQualificationStep);
|
||||
sql.setParam("date", DateUtil.today());
|
||||
sql.setParam("lotteryUserNum", lotteryUserNum);
|
||||
userList = (List<NutMap>) Daos.query(dao, sql.toString(), Sqls.callback.maps());
|
||||
}
|
||||
|
||||
List<FitnessWalkAwardUser> awardLists = userList.stream().map(v -> {
|
||||
FitnessWalkAwardUser awardUser = new FitnessWalkAwardUser();
|
||||
awardUser.setActivityId(activityId);
|
||||
awardUser.setUserId(v.getString("userId"));
|
||||
awardUser.setUsername(v.getString("username"));
|
||||
awardUser.setLoginName(v.getString("loginname"));
|
||||
awardUser.setAwardName(awardName);
|
||||
awardUser.setUnionId(v.getString("unionid"));
|
||||
awardUser.setUnionName(v.getString("unionname"));
|
||||
awardUser.setUnitId(v.getString("unitid"));
|
||||
awardUser.setUnitName(v.getString("unitname"));
|
||||
awardUser.setApplyDate(new Date());
|
||||
return awardUser;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
try {
|
||||
FileWriter fileWriter = new FileWriter("C:\\Users\\Administrator\\Desktop\\output.txt");
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
||||
bufferedWriter.write(Json.toJson(awardLists));
|
||||
bufferedWriter.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// dao.insert(awardLists);
|
||||
|
||||
String taskId = context.getJobDetail().getKey().getName();
|
||||
taskPlatformService.delete(taskId, taskId);
|
||||
sysTaskService.update(
|
||||
Chain.make("disabled", 1)
|
||||
.add("exeAt", (int) (System.currentTimeMillis() / 1000))
|
||||
.add("exeResult", Json.toJson(awardLists)),
|
||||
Cnd.where("id", "=", taskId));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package io.v.nutz.task.job.psychology;
|
||||
|
||||
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.base.utils.MsgApi;
|
||||
import io.v.nutz.zhgh.psychology.models.PsychologyMsg;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@IocBean
|
||||
public class SendMsgPsychologyJob implements Job {
|
||||
|
||||
|
||||
@Inject
|
||||
private MsgApi msgApi;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private static SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private static SimpleDateFormat simpleFormat = new SimpleDateFormat("HH:mm");
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
PsychologyMsg psychologyMsg = dao.fetch(PsychologyMsg.class);
|
||||
|
||||
if (!psychologyMsg.getIsSendMsg()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
au.username ,
|
||||
au.loginname ,
|
||||
pai.startTime
|
||||
FROM
|
||||
`psychology_appointment_info` pai
|
||||
LEFT JOIN `user` au ON au.id = pai.appointmentUser
|
||||
WHERE
|
||||
pai.appointmentUser IS NOT NULL
|
||||
AND LEFT ( pai.startTime, 10 )=@starTime
|
||||
""").setParam("starTime", simpleDateFormat.format(new Date()));
|
||||
List<NutMap> list = baseService.listMap(sql);
|
||||
|
||||
list.forEach(item -> {
|
||||
String content = "“%s”老师您好:您预约的心理咨询即将在“%s”开始了,请记得准时参加哦~祝您工作生活愉快!"
|
||||
.formatted(item.getString("username"), item.getString("startTime"));
|
||||
ArrayList<Map> list2 = new ArrayList<>();
|
||||
list2.add(Map.of("type", "User", "userId", item.getString("loginname"), "name", item.getString("username")));
|
||||
// msgApi.sendMsg(content, list2, "心理咨询", "WeChat", MsgApi.sendMode.normal.name());
|
||||
});
|
||||
|
||||
//给咨询师发短信
|
||||
Sql sqld = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname,
|
||||
u.username,
|
||||
info.*
|
||||
FROM
|
||||
psychology_appointment_info info
|
||||
LEFT JOIN `user` u ON u.id = info.doctorUser
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("u.loginname", "is not", null);
|
||||
cnd.and("info.doctorUser", "is not", null);
|
||||
cnd.and("LEFT( info.startTime, 10 )", "=", simpleDateFormat.format(new Date()));
|
||||
sqld.setCondition(cnd);
|
||||
List<NutMap> listDoctor = baseService.listMap(sqld);
|
||||
//分组
|
||||
NutMap result = new NutMap();
|
||||
listDoctor.forEach(item -> {
|
||||
String loginname = item.getString("loginname");
|
||||
if (result.containsKey(loginname)) {
|
||||
result.getAsList(loginname, NutMap.class).add(item);
|
||||
} else {
|
||||
List<NutMap> l = new ArrayList<>();
|
||||
l.add(item);
|
||||
result.put(loginname, l);
|
||||
}
|
||||
});
|
||||
//发短信
|
||||
result.keySet().forEach(item -> {
|
||||
String content = "%s老师您好,今天(%s)您有%s个场次的心理咨询安排,分别是%s,祝您工作生活愉快!";
|
||||
String userName = "";
|
||||
String str = "";
|
||||
String time = "";
|
||||
List<NutMap> asList = result.getAsList(item, NutMap.class);
|
||||
for (NutMap nutMap : asList) {
|
||||
userName = nutMap.getString("username");
|
||||
try {
|
||||
time = simpleFormat.format(simpleDateTimeFormat.parse(nutMap.getString("startTime")));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
str += time + ',';
|
||||
}
|
||||
str = str.substring(0, str.length() - 1);
|
||||
content = content.formatted(userName, simpleDateFormat.format(new Date()), asList.size(), str);
|
||||
ArrayList<Map> list2 = new ArrayList<>();
|
||||
list2.add(Map.of("type", "User", "userId", item, "name", userName));
|
||||
// msgApi.sendMsg(content, list2, "心理咨询", "WeChat", MsgApi.sendMode.normal.name());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package io.v.nutz.task.job.question;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.v.nutz.sys.models.Sys_task;
|
||||
import io.v.nutz.zhgh.question.model.Question;
|
||||
import io.v.nutz.zhgh.question.model.QuestionUserScore;
|
||||
import io.v.nutz.zhgh.question.model.QuestionWinner;
|
||||
import io.v.nutz.zhgh.question.service.QuestionService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 问卷抽奖定时任务
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/06/12
|
||||
*/
|
||||
@IocBean
|
||||
public class QuestionRaffleJob implements Job {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private QuestionService questionService;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobDataMap data = context.getJobDetail().getJobDataMap();
|
||||
DateTime startAnswerDate = DateUtil.parseDate(data.getString("startAnswerDate"));
|
||||
DateTime endAnswerDate = DateUtil.parseDate(data.getString("endAnswerDate"));
|
||||
DateTime raffleTime = DateUtil.parseDate(data.getString("raffleTime"));
|
||||
//抽奖分数
|
||||
int raffleScore = data.getInt("raffleScore");
|
||||
//中奖者人数
|
||||
int raffleWinnerUserNum = data.getInt("raffleWinnerUserNum");
|
||||
//问卷id
|
||||
String questionId = data.getString("questionId");
|
||||
|
||||
Question question = dao.fetch(Question.class, questionId);
|
||||
|
||||
|
||||
//已中奖的用户
|
||||
List<QuestionWinner> winners = dao.query(QuestionWinner.class, Cnd.where("questionId", "=", questionId));
|
||||
List<String> hasWinnUserIds = winners.stream().map(v -> v.getUserId()).collect(Collectors.toList());
|
||||
|
||||
//得分记录
|
||||
List<QuestionUserScore> questionUserScores = dao.query(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).andEX("userId", "not in", hasWinnUserIds));
|
||||
|
||||
//抽奖规则时间范围内的记录
|
||||
List<QuestionUserScore> thisTimeQuestionUserScores = questionUserScores.stream().filter(s -> startAnswerDate.isBeforeOrEquals(s.getAnswerDate()) && endAnswerDate.isAfter(s.getAnswerDate())).collect(Collectors.toList());
|
||||
|
||||
//本次中奖用户
|
||||
List<String> winnerUserIds = new ArrayList<>();
|
||||
|
||||
//每个用户的分数
|
||||
List<NutMap> userScoreMap = new ArrayList<>();
|
||||
|
||||
if (question.getCtMode() == 1) {
|
||||
Map<String, List<QuestionUserScore>> userScoreListMap = thisTimeQuestionUserScores.stream().collect(Collectors.groupingBy(v -> v.getUserId()));
|
||||
userScoreListMap.forEach((userId, v) -> {
|
||||
Map<Date, List<QuestionUserScore>> userDayScoreListMap = v.stream().collect(Collectors.groupingBy(x -> x.getAnswerDate()));
|
||||
AtomicInteger sumScore = new AtomicInteger();
|
||||
userDayScoreListMap.forEach((day, v1) -> {
|
||||
if (question.getCalcScoreMode() == 1) {
|
||||
int score = v1.stream().mapToInt(s -> s.getScore()).max().orElse(0);
|
||||
sumScore.addAndGet(score);
|
||||
} else if (question.getCalcScoreMode() == 2) {
|
||||
int maxAnswerNum = v1.stream().mapToInt(s -> s.getAnswerNum()).max().orElse(1);
|
||||
Integer score = v1.stream().filter(s -> s.getAnswerNum() == maxAnswerNum).findFirst().map(s -> s.getScore()).orElse(0);
|
||||
sumScore.addAndGet(score);
|
||||
}
|
||||
});
|
||||
userScoreMap.add(NutMap.NEW().addv("userId", userId).addv("score", sumScore.get()));
|
||||
});
|
||||
} else if (question.getCtMode() == 2) {
|
||||
if (questionService.isSameDay(question.getStartTime(), question.getEndTime())) {
|
||||
thisTimeQuestionUserScores.stream().collect(Collectors.groupingBy(v -> v.getUserId(), Collectors.summingInt(v -> v.getScore()))).forEach((k, v) -> {
|
||||
userScoreMap.add(NutMap.NEW().addv("userId", k).addv("score", v));
|
||||
});
|
||||
} else {
|
||||
Map<String, List<QuestionUserScore>> userScoreListMap = thisTimeQuestionUserScores.stream().collect(Collectors.groupingBy(v -> v.getUserId()));
|
||||
userScoreListMap.forEach((userId, v) -> {
|
||||
Map<Date, List<QuestionUserScore>> userDayScoreListMap = v.stream().collect(Collectors.groupingBy(x -> x.getAnswerDate()));
|
||||
AtomicInteger sumScore = new AtomicInteger();
|
||||
userDayScoreListMap.forEach((day, v1) -> {
|
||||
if (question.getCalcScoreMode() == 1) {
|
||||
int score = v1.stream().mapToInt(s -> s.getScore()).max().orElse(0);
|
||||
sumScore.addAndGet(score);
|
||||
} else if (question.getCalcScoreMode() == 2) {
|
||||
int maxAnswerNum = v1.stream().mapToInt(s -> s.getAnswerNum()).max().orElse(1);
|
||||
Integer score = v1.stream().filter(s -> s.getAnswerNum() == maxAnswerNum).findFirst().map(s -> s.getScore()).orElse(0);
|
||||
sumScore.addAndGet(score);
|
||||
}
|
||||
});
|
||||
userScoreMap.add(NutMap.NEW().addv("userId", userId).addv("score", sumScore.get()));
|
||||
});
|
||||
}
|
||||
} else if (question.getCtMode() == 3) {
|
||||
Map<String, List<QuestionUserScore>> userScoreListMap = thisTimeQuestionUserScores.stream().collect(Collectors.groupingBy(v -> v.getUserId()));
|
||||
userScoreListMap.forEach((userId, v) -> {
|
||||
AtomicInteger sumScore = new AtomicInteger();
|
||||
if (question.getCalcScoreMode() == 1) {
|
||||
int score = v.stream().mapToInt(s -> s.getScore()).max().orElse(0);
|
||||
sumScore.addAndGet(score);
|
||||
} else if (question.getCalcScoreMode() == 2) {
|
||||
int maxAnswerNum = v.stream().mapToInt(s -> s.getAnswerNum()).max().orElse(1);
|
||||
Integer score = v.stream().filter(s -> s.getAnswerNum() == maxAnswerNum).findFirst().map(s -> s.getScore()).orElse(0);
|
||||
sumScore.addAndGet(score);
|
||||
}
|
||||
userScoreMap.add(NutMap.NEW().addv("userId", userId).addv("score", sumScore.get()));
|
||||
});
|
||||
}
|
||||
|
||||
//待抽奖用户
|
||||
List<String> readyRaffleUserId = userScoreMap.stream().filter(x -> x.getInt("score") >= raffleScore).map(v -> v.getString("userId")).collect(Collectors.toList());
|
||||
|
||||
// 随机打乱用户ID列表
|
||||
Collections.shuffle(readyRaffleUserId);
|
||||
|
||||
if (readyRaffleUserId.size() >= raffleWinnerUserNum) {
|
||||
winnerUserIds = readyRaffleUserId.subList(0, raffleWinnerUserNum);
|
||||
} else {
|
||||
winnerUserIds = readyRaffleUserId.subList(0, readyRaffleUserId.size());
|
||||
}
|
||||
|
||||
List<QuestionWinner> questionWinners = winnerUserIds.stream().map(v -> {
|
||||
QuestionWinner winner = new QuestionWinner();
|
||||
winner.setQuestionId(questionId);
|
||||
winner.setUserId(v);
|
||||
winner.setWinDate(new Date());
|
||||
Integer score = userScoreMap.stream().filter(x -> x.getString("userId").equals(v)).findFirst().map(x -> x.getInt("score", 0)).orElse(0);
|
||||
winner.setScore(score);
|
||||
return winner;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(questionWinners);
|
||||
|
||||
dao.update(Sys_task.class, Chain.make("disabled", 1), Cnd.where("data", "like", "%" + raffleTime + "%").and("data", "like", "%" + questionId + "%"));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package io.v.nutz.task.job.walking;
|
||||
|
||||
import io.v.nutz.base.utils.MsgApi;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean
|
||||
public class WalkingNotifyJob implements Job {
|
||||
|
||||
@Inject
|
||||
private MsgApi msgApi;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
||||
String groupId = jobDataMap.getString("groupId");
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname
|
||||
FROM
|
||||
activity_user_scope aus
|
||||
LEFT JOIN sys_user u on u.id = aus.userId
|
||||
WHERE
|
||||
aus.groupId = @groupId
|
||||
""").setParam("groupId", groupId);
|
||||
List<String> loginnames = ((List<NutMap>) Daos.query(dao, sql.toString(), Sqls.callback.maps())).stream().map(v -> v.getString("loginname")).collect(Collectors.toList());
|
||||
for (String loginname : loginnames) {
|
||||
// msgApi.sendWxMsg("快去上传步数", loginname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package io.v.nutz.task.job.welfare;
|
||||
|
||||
import io.v.nutz.sys.services.SysTaskService;
|
||||
import io.v.nutz.task.services.TaskPlatformService;
|
||||
import io.v.nutz.zhgh.welfare.model.*;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.trans.Trans;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @Author zhf
|
||||
* @Date 2023/1/5 10:43
|
||||
*/
|
||||
@IocBean
|
||||
public class welfareJob implements Job {
|
||||
|
||||
@Inject
|
||||
protected SysTaskService sysTaskService;
|
||||
|
||||
@Inject
|
||||
private TaskPlatformService taskPlatformService;
|
||||
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobDataMap data = context.getJobDetail().getJobDataMap();
|
||||
String welfareId = data.getString("welfareId");
|
||||
WelfareProject welfareProject = dao.fetch(WelfareProject.class, welfareId);
|
||||
|
||||
Trans.exec(() -> {
|
||||
//找出这个福利下的福利
|
||||
WelfareProjectSubject welfareProjectSubject = dao.fetch(WelfareProjectSubject.class, Cnd.where("projectId", "=", welfareId));
|
||||
//通过福利找出具体发放的东西
|
||||
List<WelfareProjectSubjectOption> welfareProjectSubjectOptionList = dao.query(WelfareProjectSubjectOption.class, Cnd.where("subjectId", "=", welfareProjectSubject.getId()));
|
||||
//找出自动发放的东西是哪个东西
|
||||
List<WelfareProjectSubjectOption> list = welfareProjectSubjectOptionList.stream().filter(WelfareProjectSubjectOption::getIsDefaultOption).collect(Collectors.toList());
|
||||
|
||||
//找出这个福利没有领取的人
|
||||
|
||||
List<WelfareUserSelection> userSelectionList = dao.query(WelfareUserSelection.class, Cnd.where("welfareId", "=", welfareId));
|
||||
List<String> ids = userSelectionList.stream().map(WelfareUserSelection::getSelectUserId).collect(Collectors.toList());
|
||||
List<WelfareList> welfareLists = dao.query(WelfareList.class, Cnd.where("projectId", "=", welfareId).and("userId", "not in", ids));
|
||||
|
||||
|
||||
welfareLists.forEach(li -> {
|
||||
list.forEach(o -> {
|
||||
WelfareUserSelection userSelection = new WelfareUserSelection();
|
||||
userSelection.setWelfareId(welfareId);
|
||||
userSelection.setSubjectId(welfareProjectSubject.getId());
|
||||
userSelection.setSelectOptionId(o.getId());
|
||||
userSelection.setSelectUserId(li.getUserId());
|
||||
userSelection.setSelectTime(new Date());
|
||||
userSelection.setIsReceive(true);
|
||||
dao.insert(userSelection);
|
||||
});
|
||||
dao.update(WelfareList.class, Chain.make("isReceive", true), Cnd.where("projectId", "=", welfareId).and("userId", "=", li.getUserId()));
|
||||
|
||||
});
|
||||
|
||||
taskPlatformService.delete(welfareProject.getTaskId(), welfareProject.getTaskId());
|
||||
sysTaskService.delete(welfareProject.getTaskId());
|
||||
|
||||
welfareProject.setTaskId(null);
|
||||
dao.update(welfareProject);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package io.v.nutz.task.legalAid;
|
||||
|
||||
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.base.utils.MsgApi;
|
||||
import io.v.nutz.zhgh.legalAid.models.LegalAidMsg;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@IocBean
|
||||
public class SendMsgLegalAidJob implements Job {
|
||||
|
||||
|
||||
@Inject
|
||||
private MsgApi msgApi;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private static SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private static SimpleDateFormat simpleFormat = new SimpleDateFormat("HH:mm");
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
LegalAidMsg psychologyMsg = dao.fetch(LegalAidMsg.class);
|
||||
|
||||
if (!psychologyMsg.getIsSendMsg()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
au.username ,
|
||||
au.loginname ,
|
||||
pai.startTime
|
||||
FROM
|
||||
`legal_aid_appointment_info` pai
|
||||
LEFT JOIN `user` au ON au.id = pai.appointmentUser
|
||||
WHERE
|
||||
pai.appointmentUser IS NOT NULL
|
||||
AND LEFT ( pai.startTime, 10 )=@starTime
|
||||
""").setParam("starTime", simpleDateFormat.format(new Date()));
|
||||
List<NutMap> list = baseService.listMap(sql);
|
||||
|
||||
list.forEach(item -> {
|
||||
String content = "“%s”老师您好:您预约的法律援助即将在“%s”开始了,请记得准时参加哦~祝您工作生活愉快!"
|
||||
.formatted(item.getString("username"), item.getString("startTime"));
|
||||
ArrayList<Map> list2 = new ArrayList<>();
|
||||
list2.add(Map.of("type", "User", "userId", item.getString("loginname"), "name", item.getString("username")));
|
||||
// msgApi.sendMsg(content, list2, "心理咨询", "WeChat", MsgApi.sendMode.normal.name());
|
||||
});
|
||||
|
||||
//给咨询师发短信
|
||||
Sql sqld = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname,
|
||||
u.username,
|
||||
info.*
|
||||
FROM
|
||||
psychology_appointment_info info
|
||||
LEFT JOIN `user` u ON u.id = info.doctorUser
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("u.loginname", "is not", null);
|
||||
cnd.and("info.doctorUser", "is not", null);
|
||||
cnd.and("LEFT( info.startTime, 10 )", "=", simpleDateFormat.format(new Date()));
|
||||
sqld.setCondition(cnd);
|
||||
List<NutMap> listDoctor = baseService.listMap(sqld);
|
||||
//分组
|
||||
NutMap result = new NutMap();
|
||||
listDoctor.forEach(item -> {
|
||||
String loginname = item.getString("loginname");
|
||||
if (result.containsKey(loginname)) {
|
||||
result.getAsList(loginname, NutMap.class).add(item);
|
||||
} else {
|
||||
List<NutMap> l = new ArrayList<>();
|
||||
l.add(item);
|
||||
result.put(loginname, l);
|
||||
}
|
||||
});
|
||||
//发短信
|
||||
result.keySet().forEach(item -> {
|
||||
String content = "%s老师您好,今天(%s)您有%s个场次的法律援助安排,分别是%s,祝您工作生活愉快!";
|
||||
String userName = "";
|
||||
String str = "";
|
||||
String time = "";
|
||||
List<NutMap> asList = result.getAsList(item, NutMap.class);
|
||||
for (NutMap nutMap : asList) {
|
||||
userName = nutMap.getString("username");
|
||||
try {
|
||||
time = simpleFormat.format(simpleDateTimeFormat.parse(nutMap.getString("startTime")));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
str += time + ',';
|
||||
}
|
||||
str = str.substring(0, str.length() - 1);
|
||||
content = content.formatted(userName, simpleDateFormat.format(new Date()), asList.size(), str);
|
||||
ArrayList<Map> list2 = new ArrayList<>();
|
||||
list2.add(Map.of("type", "User", "userId", item, "name", userName));
|
||||
// msgApi.sendMsg(content, list2, "心理咨询", "WeChat", MsgApi.sendMode.normal.name());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package io.v.nutz.task.model;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Table("proposal_inst_app")
|
||||
@Data
|
||||
public class ProposalInstApp {
|
||||
|
||||
@Id
|
||||
@Comment("实例id")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer inst_id;
|
||||
|
||||
@Comment("事项id")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
private String app_id;
|
||||
|
||||
@Comment("提案id")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
private String proposal_id;
|
||||
|
||||
@Comment("实例发起人")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 10)
|
||||
private String creator;
|
||||
|
||||
@Comment("实例创建时间")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 20)
|
||||
private String created;
|
||||
|
||||
@Comment("实例完成时间")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 20)
|
||||
private String finished;
|
||||
|
||||
@Comment("实例状态")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT,width = 1)
|
||||
private Integer inst_status;
|
||||
|
||||
@Comment("实例节点id")
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
private List<Integer> node_id;
|
||||
|
||||
@Comment("实例节点name")
|
||||
@Column
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
private List<String> node_name;
|
||||
|
||||
@Comment("实例name")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 50)
|
||||
private String inst_name;
|
||||
|
||||
@Comment("实例url")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 500)
|
||||
private String form_url_view;
|
||||
|
||||
@Comment("实例form_mobile_url_view")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 500)
|
||||
private String form_mobile_url_view;
|
||||
|
||||
@Comment("第三方id")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT,width = 1)
|
||||
private Integer thirdparty_id;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package io.v.nutz.task.model;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Table("proposal_task")
|
||||
@Data
|
||||
public class ProposalTask implements Serializable {
|
||||
|
||||
|
||||
@Comment("任务id")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Id
|
||||
private Integer task_id;
|
||||
|
||||
@Comment("提案id")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
private String proposal_id;
|
||||
|
||||
@Comment("任务状态")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer task_status;
|
||||
|
||||
@Comment("任务节点")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 30)
|
||||
private String node_name;
|
||||
|
||||
@Comment("任务人")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
private String user_number;
|
||||
|
||||
@Comment("处理地址")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 500)
|
||||
private String form_url;
|
||||
|
||||
@Comment("查看地址")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 500)
|
||||
private String form_url_view;
|
||||
|
||||
@Comment("查看地址")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 500)
|
||||
private String form_mobile_url;
|
||||
|
||||
@Comment("查看地址")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 500)
|
||||
private String form_mobile_url_view;
|
||||
|
||||
|
||||
@Comment("业务主键")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
private String biz_key;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package io.v.nutz.task.model;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Table("task_token")
|
||||
@Data
|
||||
public class TaskToken implements Serializable {
|
||||
@Comment("id")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
@Comment("token")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 200)
|
||||
private String token;
|
||||
|
||||
@Comment("获取时间")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Long get_time;
|
||||
|
||||
@Comment("过期时间")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer expires_in;
|
||||
|
||||
@Comment("类型")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 20)
|
||||
private String token_type;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package io.v.nutz.task.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2018/3/19.
|
||||
*/
|
||||
public interface TaskPlatformService {
|
||||
/**
|
||||
* 判断任务是否存在
|
||||
*
|
||||
* @param jobName
|
||||
* @param jobGroup
|
||||
* @return
|
||||
*/
|
||||
boolean isExist(String jobName, String jobGroup);
|
||||
|
||||
/**
|
||||
* 添加新任务
|
||||
*
|
||||
* @param jobName
|
||||
* @param jobGroup
|
||||
* @param className
|
||||
* @param cron
|
||||
* @param comment
|
||||
* @param dataMap
|
||||
*/
|
||||
void add(String jobName, String jobGroup, String className, String cron, String comment, String dataMap);
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*
|
||||
* @param jobName
|
||||
* @param jobGroup
|
||||
* @return
|
||||
*/
|
||||
boolean delete(String jobName, String jobGroup);
|
||||
|
||||
/**
|
||||
* 清除所有任务
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* 获取cron表达式最近执行时间
|
||||
*
|
||||
* @param cronExpression
|
||||
* @return
|
||||
*/
|
||||
List<String> getCronExeTimes(String cronExpression) throws Exception;
|
||||
|
||||
List<String> getCronExeTimesPlus(String cronExpression) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package io.v.nutz.task.services.impl;
|
||||
|
||||
import io.v.nutz.task.services.TaskPlatformService;
|
||||
import org.nutz.integration.quartz.QuartzJob;
|
||||
import org.nutz.integration.quartz.QuartzManager;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.quartz.CronExpression;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.TriggerUtils;
|
||||
import org.quartz.impl.triggers.CronTriggerImpl;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2018/3/19.
|
||||
*/
|
||||
@IocBean
|
||||
public class TaskPlatformServiceImpl implements TaskPlatformService {
|
||||
@Inject
|
||||
private QuartzManager quartzManager;
|
||||
|
||||
/**
|
||||
* 判断任务是否存在
|
||||
*
|
||||
* @param jobName
|
||||
* @param jobGroup
|
||||
* @return
|
||||
*/
|
||||
public boolean isExist(String jobName, String jobGroup) {
|
||||
return quartzManager.exist(new JobKey(jobName, jobGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加新任务
|
||||
*
|
||||
* @param jobName
|
||||
* @param jobGroup
|
||||
* @param className
|
||||
* @param cron
|
||||
* @param comment
|
||||
* @param dataMap
|
||||
*/
|
||||
public void add(String jobName, String jobGroup, String className, String cron, String comment, String dataMap) {
|
||||
QuartzJob qj = new QuartzJob();
|
||||
qj.setJobName(jobName);
|
||||
qj.setJobGroup(jobGroup);
|
||||
qj.setClassName(className);
|
||||
qj.setCron(cron);
|
||||
qj.setComment(comment);
|
||||
qj.setDataMap(dataMap);
|
||||
quartzManager.add(qj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*
|
||||
* @param jobName
|
||||
* @param jobGroup
|
||||
* @return
|
||||
*/
|
||||
public boolean delete(String jobName, String jobGroup) {
|
||||
QuartzJob qj = new QuartzJob();
|
||||
qj.setJobName(jobName);
|
||||
qj.setJobGroup(jobGroup);
|
||||
return quartzManager.delete(qj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除任务
|
||||
*/
|
||||
public void clear() {
|
||||
quartzManager.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cron表达式最近执行时间
|
||||
*
|
||||
* @param cronExpression
|
||||
* @return
|
||||
*/
|
||||
public List<String> getCronExeTimes(String cronExpression) throws Exception {
|
||||
List<String> list = new ArrayList<>();
|
||||
CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
|
||||
cronTriggerImpl.setCronExpression(cronExpression);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date now = calendar.getTime();
|
||||
calendar.add(2, 1);
|
||||
List<Date> dates = TriggerUtils.computeFireTimesBetween(cronTriggerImpl, null, now, calendar.getTime());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
for (int i = 0; i < dates.size() && i <= 4; ++i) {
|
||||
list.add(dateFormat.format((Date) dates.get(i)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getCronExeTimesPlus(String cronExpression) throws Exception {
|
||||
// 创建一个列表来存储执行时间
|
||||
List<String> executionTimes = new ArrayList<>();
|
||||
// 创建 CronTriggerImpl 对象,并设置 cron 表达式
|
||||
CronTriggerImpl cronTrigger = new CronTriggerImpl();
|
||||
cronTrigger.setCronExpression(new CronExpression(cronExpression));
|
||||
// 计算未来的执行时间
|
||||
List<Date> nextExecutionTimes = TriggerUtils.computeFireTimes(cronTrigger, null, 5);
|
||||
// 格式化日期并添加到执行时间列表中
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
for (Date date : nextExecutionTimes) {
|
||||
executionTimes.add(dateFormat.format(date));
|
||||
}
|
||||
return executionTimes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user