| | |
| | | package com.gkhy.fourierSpecialGasMonitor.schedule; |
| | | |
| | | import com.gkhy.fourierSpecialGasMonitor.controller.DataReceiveController; |
| | | import com.gkhy.fourierSpecialGasMonitor.entity.req.DeviceMonitorReqDTO; |
| | | import com.gkhy.fourierSpecialGasMonitor.entity.req.UploadGasConcentrationReqDTO; |
| | | import com.gkhy.fourierSpecialGasMonitor.entity.req.UploadGasFluxReqDTO; |
| | | import com.gkhy.fourierSpecialGasMonitor.service.DataReceiveService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.text.DecimalFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @author Mr.huang |
| | | * @decription |
| | | * @date 2023/8/22 13:49 |
| | | */ |
| | | @Component |
| | | public class TestSchedule { |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | @Autowired |
| | | private DataReceiveService dataReceiveService; |
| | | |
| | | private static final DateTimeFormatter execformatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | |
| | | //@Scheduled(cron = "1 * * * * ?") |
| | | //@Async(value = "SocketTaskExecutor") |
| | | //public void testDeviceMonitor() { |
| | | // logger.info("【硬件设备一分钟一次推送测试】:" + LocalDateTime.now().format(execformatter)); |
| | | // DeviceMonitorReqDTO deviceMonitorReqDTO = new DeviceMonitorReqDTO(); |
| | | // deviceMonitorReqDTO.setTime(LocalDateTime.now()); |
| | | // deviceMonitorReqDTO.setConState(0); |
| | | // deviceMonitorReqDTO.setFluxState(0); |
| | | // List<Integer> list = new ArrayList<>(); |
| | | // list.add(0); |
| | | // deviceMonitorReqDTO.setHardwareState(list); |
| | | // dataReceiveService.deviceMonitor(deviceMonitorReqDTO); |
| | | //} |
| | | |
| | | |
| | | //@Scheduled(cron = "0/30 * * * * ?") |
| | | //@Async(value = "SocketTaskExecutor") |
| | | //public void testGasConcentration() { |
| | | // logger.info("【气体实时浓度推送测试】:"+LocalDateTime.now().format(execformatter)); |
| | | // Random random = new Random(); |
| | | // double randomDouble = random.nextDouble() * 99.9 + 1; // 生成1到100之间的随机双精度数 |
| | | // DecimalFormat decimalFormat = new DecimalFormat("0.0"); |
| | | // String formattedDouble = decimalFormat.format(randomDouble); |
| | | // double result = Double.parseDouble(formattedDouble); |
| | | // UploadGasConcentrationReqDTO dto = new UploadGasConcentrationReqDTO(); |
| | | // dto.setEquipmentId("No-123456"); |
| | | // dto.setTime(LocalDateTime.now()); |
| | | // dto.setType(1); |
| | | // dto.setLng("东经43"); |
| | | // dto.setLat("北纬53"); |
| | | // dto.setAngle("60"); |
| | | // dto.setTemp(26.9); |
| | | // dto.setHumidity(63.3); |
| | | // dto.setWindSpeed(12.3); |
| | | // dto.setWindDirection(56); |
| | | // dto.setPressure(200.0); |
| | | // dto.setGasName01(1); |
| | | // dto.setGasValue01(result); |
| | | // dto.setGasName02(2); |
| | | // dto.setGasValue02(result); |
| | | // dto.setGasName03(3); |
| | | // dto.setGasValue03(result); |
| | | // dto.setGasName04(4); |
| | | // dto.setGasValue04(result); |
| | | // dto.setGasName05(5); |
| | | // dto.setGasValue05(result); |
| | | // dto.setGasName06(6); |
| | | // dto.setGasValue06(result); |
| | | // dto.setGasName07(7); |
| | | // dto.setGasValue07(result); |
| | | // dto.setGasName08(8); |
| | | // dto.setGasValue08(result); |
| | | // dto.setGasName09(9); |
| | | // dto.setGasValue09(result); |
| | | // dto.setGasName10(10); |
| | | // dto.setGasValue10(result); |
| | | // dto.setGasName11(11); |
| | | // dto.setGasValue11(result); |
| | | // dto.setGasName12(12); |
| | | // dto.setGasValue12(result); |
| | | // dto.setGasName13(13); |
| | | // dto.setGasValue13(result); |
| | | // dto.setGasName14(14); |
| | | // dto.setGasValue14(result); |
| | | // dto.setGasName15(15); |
| | | // dto.setGasValue15(result); |
| | | // dto.setGasName16(16); |
| | | // dto.setGasValue16(result); |
| | | // dto.setGasName17(17); |
| | | // dto.setGasValue17(result); |
| | | // dto.setGasName18(18); |
| | | // dto.setGasValue18(result); |
| | | // dto.setGasName19(19); |
| | | // dto.setGasValue19(result); |
| | | // dto.setGasName20(20); |
| | | // dto.setGasValue20(result); |
| | | // dto.setGasName21(21); |
| | | // dto.setGasValue21(result); |
| | | // dto.setGasName22(22); |
| | | // dto.setGasValue22(result); |
| | | // dto.setGasName23(23); |
| | | // dto.setGasValue23(result); |
| | | // dto.setGasName24(24); |
| | | // dto.setGasValue24(result); |
| | | // dto.setGasName25(25); |
| | | // dto.setGasValue25(result); |
| | | // dto.setGasName26(26); |
| | | // dto.setGasValue26(result); |
| | | // dto.setGasName27(27); |
| | | // dto.setGasValue27(result); |
| | | // dto.setGasName28(28); |
| | | // dto.setGasValue28(result); |
| | | // dto.setGasName29(29); |
| | | // dto.setGasValue29(result); |
| | | // dto.setGasName30(30); |
| | | // dto.setGasValue30(result); |
| | | // dataReceiveService.uploadGasConcentration(dto); |
| | | //} |
| | | |
| | | @Autowired |
| | | private DataReceiveController dataReceiveController; |
| | | |
| | | @Scheduled(cron = "0/30 * * * * ?") |
| | | //@Scheduled(cron = "0 0/15 * * * ?") |
| | | @Async(value = "SocketTaskExecutor") |
| | | public void testGasFlux() { |
| | | logger.info("【气体通量推送测试】:"+LocalDateTime.now().format(execformatter)); |
| | | for (int i = 1; i <= 6 ; i++) { |
| | | Random random = new Random(); |
| | | double randomDouble = random.nextDouble() * 99.9 + 1; // 生成1到100之间的随机双精度数 |
| | | DecimalFormat decimalFormat = new DecimalFormat("0.0"); |
| | | String formattedDouble = decimalFormat.format(randomDouble); |
| | | double result = Double.parseDouble(formattedDouble); |
| | | UploadGasFluxReqDTO dto = new UploadGasFluxReqDTO(); |
| | | dto.setEquipmentId("No-123456"); |
| | | dto.setTime(LocalDateTime.now()); |
| | | dto.setAreaId(i); |
| | | dto.setType(1); |
| | | dto.setWindSpeed(12.3); |
| | | dto.setWindDirection(56); |
| | | dto.setGasName01(1); |
| | | dto.setGasValue01(result); |
| | | dto.setGasName02(2); |
| | | dto.setGasValue02(result); |
| | | dto.setGasName03(3); |
| | | dto.setGasValue03(result); |
| | | dto.setGasName04(4); |
| | | dto.setGasValue04(result); |
| | | dto.setGasName05(5); |
| | | dto.setGasValue05(result); |
| | | dto.setGasName06(6); |
| | | dto.setGasValue06(result); |
| | | dto.setGasName07(7); |
| | | dto.setGasValue07(result); |
| | | dto.setGasName08(8); |
| | | dto.setGasValue08(result); |
| | | dto.setGasName09(9); |
| | | dto.setGasValue09(result); |
| | | dto.setGasName10(10); |
| | | dto.setGasValue10(result); |
| | | dto.setGasName11(11); |
| | | dto.setGasValue11(result); |
| | | dto.setGasName12(12); |
| | | dto.setGasValue12(result); |
| | | dto.setGasName13(13); |
| | | dto.setGasValue13(result); |
| | | dto.setGasName14(14); |
| | | dto.setGasValue14(result); |
| | | dto.setGasName15(15); |
| | | dto.setGasValue15(result); |
| | | dto.setGasName16(16); |
| | | dto.setGasValue16(result); |
| | | dto.setGasName17(17); |
| | | dto.setGasValue17(result); |
| | | dto.setGasName18(18); |
| | | dto.setGasValue18(result); |
| | | dto.setGasName19(19); |
| | | dto.setGasValue19(result); |
| | | dto.setGasName20(20); |
| | | dto.setGasValue20(result); |
| | | dataReceiveController.uploadGasFlux(dto); |
| | | } |
| | | } |
| | | } |
| | | //package com.gkhy.fourierSpecialGasMonitor.schedule; |
| | | // |
| | | //import com.gkhy.fourierSpecialGasMonitor.controller.DataReceiveController; |
| | | //import com.gkhy.fourierSpecialGasMonitor.entity.req.DeviceMonitorReqDTO; |
| | | //import com.gkhy.fourierSpecialGasMonitor.entity.req.UploadGasConcentrationReqDTO; |
| | | //import com.gkhy.fourierSpecialGasMonitor.entity.req.UploadGasFluxReqDTO; |
| | | //import com.gkhy.fourierSpecialGasMonitor.service.DataReceiveService; |
| | | //import org.slf4j.Logger; |
| | | //import org.slf4j.LoggerFactory; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.scheduling.annotation.Async; |
| | | //import org.springframework.scheduling.annotation.Scheduled; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import javax.annotation.PostConstruct; |
| | | //import java.text.DecimalFormat; |
| | | //import java.time.LocalDateTime; |
| | | //import java.time.format.DateTimeFormatter; |
| | | //import java.util.ArrayList; |
| | | //import java.util.List; |
| | | //import java.util.Random; |
| | | //import java.util.concurrent.TimeUnit; |
| | | // |
| | | ///** |
| | | // * @author Mr.huang |
| | | // * @decription |
| | | // * @date 2023/8/22 13:49 |
| | | // */ |
| | | //@Component |
| | | //public class TestSchedule { |
| | | // |
| | | // private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | // |
| | | // @Autowired |
| | | // private DataReceiveService dataReceiveService; |
| | | // |
| | | // private static final DateTimeFormatter execformatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | // |
| | | // |
| | | // //@Scheduled(cron = "1 * * * * ?") |
| | | // //@Async(value = "SocketTaskExecutor") |
| | | // //public void testDeviceMonitor() { |
| | | // // logger.info("【硬件设备一分钟一次推送测试】:" + LocalDateTime.now().format(execformatter)); |
| | | // // DeviceMonitorReqDTO deviceMonitorReqDTO = new DeviceMonitorReqDTO(); |
| | | // // deviceMonitorReqDTO.setTime(LocalDateTime.now()); |
| | | // // deviceMonitorReqDTO.setConState(0); |
| | | // // deviceMonitorReqDTO.setFluxState(0); |
| | | // // List<Integer> list = new ArrayList<>(); |
| | | // // list.add(0); |
| | | // // deviceMonitorReqDTO.setHardwareState(list); |
| | | // // dataReceiveService.deviceMonitor(deviceMonitorReqDTO); |
| | | // //} |
| | | // |
| | | // |
| | | // //@Scheduled(cron = "0/30 * * * * ?") |
| | | // //@Async(value = "SocketTaskExecutor") |
| | | // //public void testGasConcentration() { |
| | | // // logger.info("【气体实时浓度推送测试】:"+LocalDateTime.now().format(execformatter)); |
| | | // // Random random = new Random(); |
| | | // // double randomDouble = random.nextDouble() * 99.9 + 1; // 生成1到100之间的随机双精度数 |
| | | // // DecimalFormat decimalFormat = new DecimalFormat("0.0"); |
| | | // // String formattedDouble = decimalFormat.format(randomDouble); |
| | | // // double result = Double.parseDouble(formattedDouble); |
| | | // // UploadGasConcentrationReqDTO dto = new UploadGasConcentrationReqDTO(); |
| | | // // dto.setEquipmentId("No-123456"); |
| | | // // dto.setTime(LocalDateTime.now()); |
| | | // // dto.setType(1); |
| | | // // dto.setLng("东经43"); |
| | | // // dto.setLat("北纬53"); |
| | | // // dto.setAngle("60"); |
| | | // // dto.setTemp(26.9); |
| | | // // dto.setHumidity(63.3); |
| | | // // dto.setWindSpeed(12.3); |
| | | // // dto.setWindDirection(56); |
| | | // // dto.setPressure(200.0); |
| | | // // dto.setGasName01(1); |
| | | // // dto.setGasValue01(result); |
| | | // // dto.setGasName02(2); |
| | | // // dto.setGasValue02(result); |
| | | // // dto.setGasName03(3); |
| | | // // dto.setGasValue03(result); |
| | | // // dto.setGasName04(4); |
| | | // // dto.setGasValue04(result); |
| | | // // dto.setGasName05(5); |
| | | // // dto.setGasValue05(result); |
| | | // // dto.setGasName06(6); |
| | | // // dto.setGasValue06(result); |
| | | // // dto.setGasName07(7); |
| | | // // dto.setGasValue07(result); |
| | | // // dto.setGasName08(8); |
| | | // // dto.setGasValue08(result); |
| | | // // dto.setGasName09(9); |
| | | // // dto.setGasValue09(result); |
| | | // // dto.setGasName10(10); |
| | | // // dto.setGasValue10(result); |
| | | // // dto.setGasName11(11); |
| | | // // dto.setGasValue11(result); |
| | | // // dto.setGasName12(12); |
| | | // // dto.setGasValue12(result); |
| | | // // dto.setGasName13(13); |
| | | // // dto.setGasValue13(result); |
| | | // // dto.setGasName14(14); |
| | | // // dto.setGasValue14(result); |
| | | // // dto.setGasName15(15); |
| | | // // dto.setGasValue15(result); |
| | | // // dto.setGasName16(16); |
| | | // // dto.setGasValue16(result); |
| | | // // dto.setGasName17(17); |
| | | // // dto.setGasValue17(result); |
| | | // // dto.setGasName18(18); |
| | | // // dto.setGasValue18(result); |
| | | // // dto.setGasName19(19); |
| | | // // dto.setGasValue19(result); |
| | | // // dto.setGasName20(20); |
| | | // // dto.setGasValue20(result); |
| | | // // dto.setGasName21(21); |
| | | // // dto.setGasValue21(result); |
| | | // // dto.setGasName22(22); |
| | | // // dto.setGasValue22(result); |
| | | // // dto.setGasName23(23); |
| | | // // dto.setGasValue23(result); |
| | | // // dto.setGasName24(24); |
| | | // // dto.setGasValue24(result); |
| | | // // dto.setGasName25(25); |
| | | // // dto.setGasValue25(result); |
| | | // // dto.setGasName26(26); |
| | | // // dto.setGasValue26(result); |
| | | // // dto.setGasName27(27); |
| | | // // dto.setGasValue27(result); |
| | | // // dto.setGasName28(28); |
| | | // // dto.setGasValue28(result); |
| | | // // dto.setGasName29(29); |
| | | // // dto.setGasValue29(result); |
| | | // // dto.setGasName30(30); |
| | | // // dto.setGasValue30(result); |
| | | // // dataReceiveService.uploadGasConcentration(dto); |
| | | // //} |
| | | // |
| | | // @Autowired |
| | | // private DataReceiveController dataReceiveController; |
| | | // |
| | | // @Scheduled(cron = "0/30 * * * * ?") |
| | | // //@Scheduled(cron = "0 0/15 * * * ?") |
| | | // @Async(value = "SocketTaskExecutor") |
| | | // public void testGasFlux() { |
| | | // logger.info("【气体通量推送测试】:"+LocalDateTime.now().format(execformatter)); |
| | | // for (int i = 1; i <= 6 ; i++) { |
| | | // Random random = new Random(); |
| | | // double randomDouble = random.nextDouble() * 99.9 + 1; // 生成1到100之间的随机双精度数 |
| | | // DecimalFormat decimalFormat = new DecimalFormat("0.0"); |
| | | // String formattedDouble = decimalFormat.format(randomDouble); |
| | | // double result = Double.parseDouble(formattedDouble); |
| | | // UploadGasFluxReqDTO dto = new UploadGasFluxReqDTO(); |
| | | // dto.setEquipmentId("No-123456"); |
| | | // dto.setTime(LocalDateTime.now()); |
| | | // dto.setAreaId(i); |
| | | // dto.setType(1); |
| | | // dto.setWindSpeed(12.3); |
| | | // dto.setWindDirection(56); |
| | | // dto.setGasName01(1); |
| | | // dto.setGasValue01(result); |
| | | // dto.setGasName02(2); |
| | | // dto.setGasValue02(result); |
| | | // dto.setGasName03(3); |
| | | // dto.setGasValue03(result); |
| | | // dto.setGasName04(4); |
| | | // dto.setGasValue04(result); |
| | | // dto.setGasName05(5); |
| | | // dto.setGasValue05(result); |
| | | // dto.setGasName06(6); |
| | | // dto.setGasValue06(result); |
| | | // dto.setGasName07(7); |
| | | // dto.setGasValue07(result); |
| | | // dto.setGasName08(8); |
| | | // dto.setGasValue08(result); |
| | | // dto.setGasName09(9); |
| | | // dto.setGasValue09(result); |
| | | // dto.setGasName10(10); |
| | | // dto.setGasValue10(result); |
| | | // dto.setGasName11(11); |
| | | // dto.setGasValue11(result); |
| | | // dto.setGasName12(12); |
| | | // dto.setGasValue12(result); |
| | | // dto.setGasName13(13); |
| | | // dto.setGasValue13(result); |
| | | // dto.setGasName14(14); |
| | | // dto.setGasValue14(result); |
| | | // dto.setGasName15(15); |
| | | // dto.setGasValue15(result); |
| | | // dto.setGasName16(16); |
| | | // dto.setGasValue16(result); |
| | | // dto.setGasName17(17); |
| | | // dto.setGasValue17(result); |
| | | // dto.setGasName18(18); |
| | | // dto.setGasValue18(result); |
| | | // dto.setGasName19(19); |
| | | // dto.setGasValue19(result); |
| | | // dto.setGasName20(20); |
| | | // dto.setGasValue20(result); |
| | | // dataReceiveController.uploadGasFlux(dto); |
| | | // } |
| | | // } |
| | | //} |