123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package com.txz.mall.task;
- import cn.hutool.core.collection.CollUtil;
- import com.txz.mall.service.StoreFlashActivityService;
- import com.txz.mall.service.StoreOrderService;
- import com.xxl.job.core.biz.model.ReturnT;
- import com.xxl.job.core.handler.annotation.XxlJob;
- import lombok.extern.slf4j.Slf4j;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.stereotype.Component;
- import tk.mybatis.mapper.entity.Condition;
- import javax.annotation.Resource;
- import java.util.List;
- /**
- * 常规job
- *
- * 开发步骤:
- * 1、在Spring Bean实例中,开发Job方法,方式格式要求为 "public ReturnT<String> execute(String param)"
- * 2、为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")",注解value值对应的是调度中心新建任务的JobHandler属性的值。
- * 3、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
- *
- * @author xuxueli 2019-12-11 21:52:51
- */
- @Component
- @Slf4j
- public class GeneralJob {
- // private static Logger logger = LoggerFactory.getLogger(GeneralJob.class);
- @Resource
- private StoreOrderService storeOrderService;
- @Resource
- private StoreFlashActivityService storeFlashActivityService;
- /**
- * 1、简单任务示例(Bean模式)
- */
- @XxlJob("newScheduledTaskStorePinkSummaryClose")
- public ReturnT<String> newsScheduledTaskStorePinkSummaryClose(String param) throws Exception {
- try {
- log.info("newScheduledTaskStorePinkSummaryClose start");
- storeOrderService.scheduledTaskStorePinkSummaryClose();
- log.info("newsScheduledTaskStorePinkSummaryClose end");
- } catch (Exception e) {
- log.error("newScheduledTaskStorePinkSummaryCloseError:e{}", e);
- return ReturnT.FAIL;
- }
- return ReturnT.SUCCESS;
- }
- @XxlJob("newScheduledTaskBatchSigning")
- public ReturnT<String> newScheduledTaskBatchSigning(String param) throws Exception {
- try {
- log.info("newScheduledTaskBatchSigning start");
- storeOrderService.batchSigning();
- log.info("newScheduledTaskBatchSigning end");
- } catch (Exception e) {
- log.error("newScheduledTaskBatchSigningError:e{}", e);
- return ReturnT.FAIL;
- }
- return ReturnT.SUCCESS;
- }
- @XxlJob("newOrderTimeoutAutomaticCancel")
- public ReturnT<String> newOrderTimeoutAutomaticCancel(String param) throws Exception {
- try {
- log.info("newOrderTimeoutAutomaticCancel start");
- storeOrderService.orderTimeoutAutomaticCancel();
- log.info("newOrderTimeoutAutomaticCancel end");
- } catch (Exception e) {
- log.error("newOrderTimeoutAutomaticCancelError:e{}", e);
- return ReturnT.FAIL;
- }
- return ReturnT.SUCCESS;
- }
- @XxlJob("newActivityStatusJudgmentTimedTask")
- public ReturnT<String> newActivityStatusJudgmentTimedTask(String param) throws Exception {
- try {
- log.info("newActivityStatusJudgmentTimedTask start");
- storeFlashActivityService.activityStatusJudgmentTimedTask();
- log.info("newActivityStatusJudgmentTimedTask end");
- } catch (Exception e) {
- log.error("newActivityStatusJudgmentTimedTaskError:e{}", e);
- return ReturnT.FAIL;
- }
- return ReturnT.SUCCESS;
- }
- }
|