中央热水项目
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.

120 lines
5.9 KiB

//package com.mh.user.utils;
//
//import com.mh.user.entity.DeviceCodeParamEntity;
//import com.mh.user.entity.DeviceInstallEntity;
//import com.mh.user.entity.PumpSetEntity;
//import com.mh.user.model.SerialPortModel;
//import com.mh.user.serialport.SerialPortSingle;
//import com.mh.user.service.DeviceInstallService;
//import com.mh.user.service.PumpSetService;
//import io.swagger.models.auth.In;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.ApplicationContext;
//
//import java.text.SimpleDateFormat;
//import java.util.*;
//
//public class TimedTask2 {
//
// ApplicationContext context = SpringBeanUtil.getApplicationContext();
// PumpSetService pumpSetService=context.getBean(PumpSetService.class);
// DeviceInstallService deviceInstallService=context.getBean(DeviceInstallService.class);
//
// public void cronJobClose(int shi, int fen, int miao) { //定时关机
// Calendar cal = Calendar.getInstance();
// // 每天定点执行
// cal.set(Calendar.HOUR_OF_DAY, shi);
// cal.set(Calendar.MINUTE, fen);
// cal.set(Calendar.SECOND, miao);
//
// Timer timer = new Timer();
// timer.schedule(new TimerTask() {
//
// public void run() {
// // 把run方法里的内容换成你要执行的内容
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// System.out.println("当前的系统时间为:" + sdf.format(new Date()));
// SerialPortSingle serialPortSingle = new SerialPortSingle(); //发送接收类
// DeviceCodeParamEntity deviceCodeParam=new DeviceCodeParamEntity();//参数实体类
// List<DeviceInstallEntity> deviceList=deviceInstallService.selectDevicePump();
// if (deviceList.size()>0){
// for (DeviceInstallEntity deviceInstall :deviceList){
// deviceCodeParam.setDeviceAddr(deviceInstall.getDeviceAddr()); //传入通讯编号
// deviceCodeParam.setDeviceType(deviceInstall.getDeviceType());
// deviceCodeParam.setDataCom(deviceInstall.getDataCom());
// deviceCodeParam.setBaudrate(deviceInstall.getBaudRate());
// deviceCodeParam.setParity(deviceInstall.getParity());
// deviceCodeParam.setDataValue("0000");//传入相关参数值,关机
// deviceCodeParam.setBuildingId(deviceInstall.getBuildingId());
// deviceCodeParam.setBrand(deviceInstall.getBrand());
// deviceCodeParam.setRegisterAddr("0000"); //寄存器地址
// deviceCodeParam.setFunCode("06");
// serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
// }
// }
// }
// }, cal.getTime(), 24 * 60 * 60 * 1000);
// }
//
// public void cronJobStart(int shi, int fen, int miao) { //定时开机
// Calendar cal = Calendar.getInstance();
// // 每天定点执行
// cal.set(Calendar.HOUR_OF_DAY, shi);
// cal.set(Calendar.MINUTE, fen);
// cal.set(Calendar.SECOND, miao);
//
// Timer timer = new Timer();
// timer.schedule(new TimerTask() {
//
// public void run() {
// // 把run方法里的内容换成你要执行的内容
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// System.out.println("当前的系统时间为:" + sdf.format(new Date()));
//// SerialPortSingle serialPortSingle = new SerialPortSingle(); //发送接收类
//// DeviceCodeParamEntity deviceCodeParam=new DeviceCodeParamEntity();//参数实体类
//// List<DeviceInstallEntity> deviceList=deviceInstallService.selectDevicePump();
//// if (deviceList.size()>0){
//// for (DeviceInstallEntity deviceInstall :deviceList){
//// deviceCodeParam.setDeviceAddr(deviceInstall.getDeviceAddr()); //传入通讯编号
//// deviceCodeParam.setDeviceType(deviceInstall.getDeviceType());
//// deviceCodeParam.setDataCom(deviceInstall.getDataCom());
//// deviceCodeParam.setBaudrate(deviceInstall.getBaudRate());
//// deviceCodeParam.setParity(deviceInstall.getParity());
//// deviceCodeParam.setDataValue("0003");//传入相关参数值,制热
//// deviceCodeParam.setBuildingId(deviceInstall.getBuildingId());
//// deviceCodeParam.setBrand(deviceInstall.getBrand());
//// deviceCodeParam.setRegisterAddr("0000"); //寄存器地址
//// deviceCodeParam.setFunCode("06");
//// serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
//// }
//// }
//
// }
// }, cal.getTime(), 24 * 60 * 60 * 1000);
// }
//
// public void cronJob(){
// PumpSetEntity pumpSet=pumpSetService.queryHandTime();
// if (pumpSet!=null){
// String HH="";
// String mm="";
// String startTime=pumpSet.getStartTime1();
// HH=startTime.substring(0,2);
// mm=startTime.substring(3,5);
//// cronJobStart(Integer.valueOf(HH), Integer.valueOf(mm), 00);
// cronJobStart(16, 13, 00);
// System.out.println("-----------小时:"+HH+",分钟:"+mm+"-----------");
//// String closeTime=pumpSet.getCloseTime1();
//// HH=closeTime.substring(0,2);
//// mm=closeTime.substring(3,5);
//// cronJobClose(Integer.valueOf(HH), Integer.valueOf(mm), 00);
// System.out.println("-----------小时:"+HH+",分钟:"+mm+"-----------");
// }
// }
////
//// public static void main(String[] args) {
//// cronJob(11, 46, 0); //24小时制 时分秒
//// }
//
//
//}