Commit 4933bf7f by Ren Ping

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

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