Commit 4933bf7f by Ren Ping

feat:自动派工任务算法优化

3.2,算法需要带入每个工程师的工作日历,支持工作队的关闭工作日配置
3.5,自动排班需要考虑已经分配人的订单,调整人工单的时间计划
3.6,排除指定工程师逻辑处理
3.7,技术员可以从家庭地址出发
1 parent 6d256b00
package com.dituhui.pea.dispatch.quartz.config;
import org.quartz.Job;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;
/**
* 自定义JobFactory,从Spring容器中拿单例Job
*
* @author RenPing
* @date 2023/11/02
*/
@Component
public class MyQuartzJobFactory extends AdaptableJobFactory implements ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Job job = applicationContext.getBean(bundle.getJobDetail().getJobClass());
return job;
}
}
//package com.dituhui.pea.dispatch.quartz.config;
//
//import org.quartz.Job;
//import org.quartz.spi.TriggerFiredBundle;
//import org.springframework.beans.BeansException;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.scheduling.quartz.AdaptableJobFactory;
//import org.springframework.stereotype.Component;
//
///**
// * 自定义JobFactory,从Spring容器中拿单例Job
// *
// * @author RenPing
// * @date 2023/11/02
// */
//@Component
//public class MyQuartzJobFactory extends AdaptableJobFactory implements ApplicationContextAware {
// private ApplicationContext applicationContext;
//
// @Override
// public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// this.applicationContext = applicationContext;
// }
//
// @Override
// protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
// Job job = applicationContext.getBean(bundle.getJobDetail().getJobClass());
// return job;
// }
//}
package com.dituhui.pea.dispatch.quartz.config;
import org.quartz.spi.JobFactory;
import org.springframework.boot.autoconfigure.quartz.QuartzProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.Properties;
@Configuration
public class QuartzConfig {
@Resource
private JobFactory jobFactory;
@Resource
private QuartzProperties quartzProperties;
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) throws IOException {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setDataSource(dataSource);
Properties properties = new Properties();
for (String key : quartzProperties.getProperties().keySet()) {
properties.put(key, quartzProperties.getProperties().get(key));
}
factory.setQuartzProperties(properties);
factory.setJobFactory(jobFactory);
return factory;
}
}
//package com.dituhui.pea.dispatch.quartz.config;
//
//import org.quartz.spi.JobFactory;
//import org.springframework.boot.autoconfigure.quartz.QuartzProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
//
//import javax.annotation.Resource;
//import javax.sql.DataSource;
//import java.io.IOException;
//import java.util.Properties;
//
//@Configuration
//public class QuartzConfig {
// @Resource
// private JobFactory jobFactory;
//
// @Resource
// private QuartzProperties quartzProperties;
// @Bean
// public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) throws IOException {
// SchedulerFactoryBean factory = new SchedulerFactoryBean();
// factory.setDataSource(dataSource);
//
// Properties properties = new Properties();
//
// for (String key : quartzProperties.getProperties().keySet()) {
// properties.put(key, quartzProperties.getProperties().get(key));
// }
// factory.setQuartzProperties(properties);
// factory.setJobFactory(jobFactory);
// return factory;
// }
//}
......@@ -3,8 +3,8 @@ server:
dispatch:
cron:
expr: 0 15 8-23 * * ?
next-day-limit: 2
expr: 0 32 8-23 * * ?
next-day-limit: 20
# expr: 0 */10 8-18 * * ?
scheduler:
......
......@@ -4,7 +4,7 @@ server:
dispatch:
cron:
expr: 0 */30 8-23 * * ?
next-day-limit: 2
next-day-limit: 20
scheduler:
init-engineer-capacity:
......@@ -80,8 +80,8 @@ spring:
#调度实例失效的检查时间间隔
clusterCheckinInterval: 10000
useProperties: false
#设置调度引擎对触发器超时的忍耐时间 (单位毫秒),20分钟
misfireThreshold: 1200000
#设置调度引擎对触发器超时的忍耐时间 (单位毫秒),60分钟
misfireThreshold: 3600000
threadPool:
class: org.quartz.simpl.SimpleThreadPool
# 指定在线程池里面创建的线程是否是守护线程
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!