package com.stylefeng.guns.modular.system.util.quartz.jobs;
|
|
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics;
|
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
|
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
|
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
|
import com.stylefeng.guns.modular.system.util.PushUtil;
|
import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil;
|
import com.stylefeng.guns.modular.system.util.quartz.model.QuartzJob;
|
import lombok.extern.slf4j.Slf4j;
|
import org.quartz.JobDataMap;
|
import org.quartz.JobDetail;
|
import org.quartz.JobExecutionContext;
|
import org.quartz.JobKey;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
|
/**
|
* 订单司机超时提醒任务
|
* @author zhibing.pu
|
* @Date 2024/4/18 15:19
|
*/
|
@Slf4j
|
@Component
|
public class OrderTimeOutJob extends QuartzJob {
|
|
@Resource
|
private PushUtil pushUtil;
|
@Resource
|
private IOrderPrivateCarService orderPrivateCarService;
|
@Resource
|
private IOrderLogisticsService orderLogisticsService;
|
|
|
|
@Override
|
public QuartzJob buildQuartzJob() {
|
return super.buildQuartzJob();
|
}
|
|
@Override
|
public QuartzJob buildQuartzJob(String name) {
|
return super.buildQuartzJob(name);
|
}
|
|
@Override
|
public QuartzJob buildQuartzJob(String name, String group) {
|
return super.buildQuartzJob(name, group);
|
}
|
|
@Override
|
public QuartzJob buildQuartzJob(String name, String group, JobDataMap jobDataMap) {
|
return super.buildQuartzJob(name, group, jobDataMap);
|
}
|
|
/**
|
* 执行的业务逻辑
|
* @param jobExecutionContext 定时任务上下文对象
|
*/
|
@Override
|
public void run(JobExecutionContext jobExecutionContext) {
|
JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
|
Integer driverId = jobDataMap.getIntegerFromString("driverId");
|
Integer orderId = jobDataMap.getIntegerFromString("orderId");
|
Integer orderType = jobDataMap.getIntegerFromString("orderType");
|
String describe = jobDataMap.getString("describe");
|
if(1 == orderType){
|
OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
|
if(2 != orderPrivateCar.getState()){
|
JobKey key = jobExecutionContext.getJobDetail().getKey();
|
boolean b = QuartzUtil.deleteQuartzTask(key);
|
if(!b){
|
log.error("定时任务关闭失败:" + key.toString());
|
}
|
return;
|
}
|
}
|
if(4 == orderType){
|
OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId);
|
if(2 != orderLogistics.getState()){
|
JobKey key = jobExecutionContext.getJobDetail().getKey();
|
boolean b = QuartzUtil.deleteQuartzTask(key);
|
if(!b){
|
log.error("定时任务关闭失败:" + key.toString());
|
}
|
return;
|
}
|
}
|
pushUtil.pushOrderTimeOut(2, driverId, orderId, orderType, describe);
|
}
|
|
|
/**
|
* 初始化任务对象
|
* @return
|
*/
|
public static QuartzJob init(){
|
return new OrderTimeOutJob().buildQuartzJob();
|
}
|
|
/**
|
* 初始化任务对象
|
* @param name
|
* @return
|
*/
|
public static QuartzJob init(String name){
|
return new OrderTimeOutJob().buildQuartzJob(name);
|
}
|
|
|
|
/**
|
* 初始化任务对象
|
* @param name
|
* @param group
|
* @return
|
*/
|
public static QuartzJob init(String name, String group){
|
return new OrderTimeOutJob().buildQuartzJob(name, group);
|
}
|
|
|
|
/**
|
* 初始化任务对象
|
* @param name
|
* @param group
|
* @return
|
*/
|
public static QuartzJob init(String name, String group, JobDataMap jobDataMap){
|
return new OrderTimeOutJob().buildQuartzJob(name, group, jobDataMap);
|
}
|
}
|