@@ -34,6 +34,11 @@ public class XxlJobInfo {
this.triggerStatus = 1;
}
+ public XxlJobInfo(int id, String executorParam) {
+ this.id = id;
+ this.executorParam = executorParam;
+ }
+
private int id;
/**
* 执行器主键ID
@@ -132,6 +137,10 @@ public class XxlJobInfo {
return new XxlJobInfo(id, "周期群发任务", URLEncoder.createQuery().encode(corn, Charset.defaultCharset()), jobGroups, author.getName(), author.email, "yh_corp_msg_bulk_task_cycle_job", executorParam);
+ public static XxlJobInfo getExecuteTaskInstance(int id, String executorParam) {
+ return new XxlJobInfo(id, executorParam);
@Getter
public enum AUTHOR {
@@ -107,6 +107,21 @@ public class XxlJobUtil {
return Jsons.parseObject(execute.body(), JSONObject.class);
+ /**
+ * 立即执行某一定时任务
+ * @param jobParam
+ */
+ public static XxlJobResult executeMarkDynamicRuleTagJob(String jobParam) throws Exception {
+ String path = "/jobinfo/trigger";
+ String targetUrl = BASE_URL + path + jobParam;
+ HttpResponse execute = HttpUtil.createPost(targetUrl)
+ .header("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
+ .header("Cookie", getCookie())
+ .execute();
+ return Jsons.parseObject(execute.body(), XxlJobResult.class);
* 获取登录cookie
@@ -19,4 +19,6 @@ public interface CorpMsgBulkTaskService extends IService<CorpMsgBulkTask> {
void remindBulkTask(String msgid);
Map<String, List<CorpTag>> getTagDetail(Long id) throws Exception;
+ void executeDynamicRuleTagTask(Long tagId) throws Exception;
@@ -127,6 +127,18 @@ public class CorpMsgBulkTaskServiceImpl extends ServiceImpl<CorpMsgBulkTaskMappe
return collect;
+ @Override
+ public void executeDynamicRuleTagTask(Long tagId) throws Exception {
+ CorpTag corpTag = corpTagMapper.selectById(tagId);
+ Assert.notNull(corpTag, "标签不存在");
+ if (corpTag.getType() != 2) {
+ Assert.notNull(corpTag, "非动态标签");
+ //执行动态标签标记任务id
+ int taskId = 100;
+ XxlJobResult xxlJobResult = XxlJobUtil.executeMarkDynamicRuleTagJob(XxlJobInfo.getExecuteTaskInstance(taskId, String.valueOf(tagId)).toString());
* 创建企业群发
*/
@@ -168,4 +168,13 @@ public class CorpMsgBulkTaskController {
corpMsgBulkTaskService.remindBulkTask(msgid);
return GatewayResponse.SUCCESS.newBuilder().toResult("提醒群发成功");
+ * 立即执行 打动态标签
+ @PostMapping("/execute/dynamicRuleTag/{tagId}")
+ public Result<String> executeDynamicRuleTagTask(@PathVariable Long tagId) throws Exception {
+ corpMsgBulkTaskService.executeDynamicRuleTagTask(tagId);
+ return GatewayResponse.SUCCESS.newBuilder().toResult();