You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
7.0 KiB
159 lines
7.0 KiB
//package com.mh.user.job; |
|
// |
|
//import com.mh.user.constants.SocketMessage; |
|
//import com.mh.user.entity.GatewayManageEntity; |
|
//import com.mh.user.serialport.SerialPortThread; |
|
//import com.mh.user.service.DeviceCodeParamService; |
|
//import com.mh.user.service.GatewayManageService; |
|
//import com.mh.user.utils.GetReadOrder485; |
|
//import lombok.SneakyThrows; |
|
//import lombok.extern.slf4j.Slf4j; |
|
//import org.quartz.DisallowConcurrentExecution; |
|
//import org.quartz.Job; |
|
//import org.quartz.JobExecutionContext; |
|
//import org.quartz.JobExecutionException; |
|
//import org.springframework.beans.factory.annotation.Autowired; |
|
//import java.util.ArrayList; |
|
//import java.util.List; |
|
// |
|
///** |
|
// * @author ljf |
|
// * @title : |
|
// * @description : 定时采集冷量计任务 |
|
// * @updateTime 2020-05-18 |
|
// * @throws : |
|
// */ |
|
///** |
|
// * :@DisallowConcurrentExecution : 此标记用在实现Job的类上面,意思是不允许并发执行. |
|
// * :注意org.quartz.threadPool.threadCount线程池中线程的数量至少要多个,否则@DisallowConcurrentExecution不生效 |
|
// * :假如Job的设置时间间隔为3秒,但Job执行时间是5秒,设置@DisallowConcurrentExecution以后程序会等任务执行完毕以后再去执行, |
|
// * 否则会在3秒时再启用新的线程执行 |
|
// */ |
|
//@DisallowConcurrentExecution |
|
//@Slf4j |
|
//public class JobCloudAndMeter implements Job { |
|
// |
|
// @Autowired |
|
// private SocketMessage socketMessage; |
|
// |
|
// @Autowired |
|
// GatewayManageService gatewayManageService; |
|
// |
|
// @Autowired |
|
// DeviceCodeParamService deviceCodeParamService; |
|
// |
|
// private static int taskTimes = 1; |
|
// List<GatewayManageEntity> gatewayDtoList=new ArrayList<>(); |
|
// GetReadOrder485 getReadOrder485=new GetReadOrder485(); |
|
// |
|
// @SneakyThrows |
|
// @Override |
|
// public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { |
|
// log.info("定时采集开始>>>>>>"); |
|
// if(taskTimes==2){//2 |
|
// int r=deviceCodeParamService.queryCount2(); //查询记录数 |
|
// if (r==0){ |
|
// getReadOrder485.createOrderParam2(); //生成采集参数 |
|
// } |
|
// |
|
// SerialPortThread myThread = new SerialPortThread(); |
|
// Thread thread = new Thread(myThread); |
|
// myThread.setName("2","1"); |
|
// thread.start(); |
|
// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
// Thread.currentThread().sleep(3000);//毫秒 |
|
// |
|
//// SerialPortThread myThread2 = new SerialPortThread(); |
|
//// Thread thread2 = new Thread(myThread2); |
|
//// myThread2.setName("2","2"); |
|
//// thread2.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
//// |
|
//// SerialPortThread myThread3 = new SerialPortThread(); |
|
//// Thread thread3 = new Thread(myThread3); |
|
//// myThread3.setName("2","3"); |
|
//// thread3.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
//// |
|
//// SerialPortThread myThread4= new SerialPortThread(); |
|
//// Thread thread4 = new Thread(myThread4); |
|
//// myThread4.setName("2","4"); |
|
//// thread4.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
// System.out.println("采集水、电、运行状态!"+taskTimes); |
|
// taskTimes++; |
|
// }else if(taskTimes==3){//5 |
|
// int r=deviceCodeParamService.queryCount3();//查询记录数 |
|
// if (r==0){ |
|
// getReadOrder485.createOrderParam3(); //生成采集参数 |
|
// } |
|
// |
|
// SerialPortThread myThread = new SerialPortThread(); |
|
// Thread thread = new Thread(myThread); |
|
// myThread.setName("3","1"); |
|
// thread.start(); |
|
// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
// Thread.currentThread().sleep(3000);//毫秒 |
|
// |
|
//// SerialPortThread myThread2 = new SerialPortThread(); |
|
//// Thread thread2 = new Thread(myThread2); |
|
//// myThread2.setName("3","2"); |
|
//// thread2.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
//// |
|
//// SerialPortThread myThread3 = new SerialPortThread(); |
|
//// Thread thread3 = new Thread(myThread3); |
|
//// myThread3.setName("3","3"); |
|
//// thread3.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
//// |
|
//// SerialPortThread myThread4= new SerialPortThread(); |
|
//// Thread thread4 = new Thread(myThread4); |
|
//// myThread4.setName("3","4"); |
|
//// thread4.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
// System.out.println("采集设定温度、设定水位、故障状态!"+taskTimes); |
|
// taskTimes=1; |
|
// }else if(taskTimes==1){ |
|
// int r=deviceCodeParamService.queryCount(); //查询记录数 |
|
// if (r==0){ |
|
// getReadOrder485.createOrderParam(); //生成采集参数 |
|
// } |
|
// SerialPortThread myThread = new SerialPortThread(); |
|
// Thread thread = new Thread(myThread); |
|
// myThread.setName("1","1"); |
|
// thread.start(); |
|
// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
// Thread.currentThread().sleep(3000);//毫秒 |
|
// |
|
//// SerialPortThread myThread2 = new SerialPortThread(); |
|
//// Thread thread2 = new Thread(myThread2); |
|
//// myThread2.setName("1","2"); |
|
//// thread2.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
//// |
|
//// SerialPortThread myThread3 = new SerialPortThread(); |
|
//// Thread thread3 = new Thread(myThread3); |
|
//// myThread3.setName("1","3"); |
|
//// thread3.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
//// |
|
//// SerialPortThread myThread4= new SerialPortThread(); |
|
//// Thread thread4 = new Thread(myThread4); |
|
//// myThread4.setName("1","4"); |
|
//// thread4.start(); |
|
//// System.out.println("当前活动线程数:"+Thread.activeCount()); |
|
//// Thread.currentThread().sleep(3000);//毫秒 |
|
// System.out.println("采集水位、水温!"+taskTimes); |
|
// taskTimes++; |
|
// } |
|
// } |
|
//}
|
|
|