huangzhen
2024-02-22 5eeac9f272d1228a328cdae46961834f168f5086
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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(1);
        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);
    //    }
    //}
}