|
@@ -66,74 +66,74 @@ public class EnvTimer {
|
|
|
String passwordMD5 = "21218cca77804d2ba1922c33e0151105";
|
|
|
String baseurl = "https://yzwlw.loongk.com/";
|
|
|
|
|
|
- @Scheduled(cron = "0 0/30 * * * ? ")
|
|
|
-// @Scheduled(cron = "0 * * * * ? ")
|
|
|
- @Transactional
|
|
|
- public void getHuanKong() throws Exception {
|
|
|
- //目前是这家
|
|
|
- Integer farmId = 21;
|
|
|
- String encode = loginOnly();
|
|
|
-// System.out.println("encode" + encode);
|
|
|
- //获取阈值
|
|
|
- EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId));
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("Authorization", encode);
|
|
|
- HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
|
|
- //TODO 只有一家,先拿全部
|
|
|
- List<EnvDevice> list = envDeviceService.list();
|
|
|
- for (EnvDevice envDevice : list) {
|
|
|
- if (ObjectUtil.isNotEmpty(envDevice) && StringUtils.isNotBlank(envDevice.getDeviceCode())) {
|
|
|
- System.out.println(envDevice.getDeviceCode());
|
|
|
- String shishiBody = "";
|
|
|
- try {
|
|
|
- ResponseEntity<String> exchange = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackDatas/" + envDevice.getDeviceCode(), HttpMethod.GET, requestEntity, String.class);
|
|
|
- shishiBody = exchange.getBody();
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println(e);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isBlank(shishiBody)) {
|
|
|
- System.out.println(new Date() + "实时数据" + shishiBody);
|
|
|
- continue;
|
|
|
- }
|
|
|
- ShackDatasDto shackDatasDto = JSONUtil.toBean(shishiBody, ShackDatasDto.class);
|
|
|
-
|
|
|
- ShackDatasDataDto data = shackDatasDto.getData();
|
|
|
- if (ObjectUtil.isEmpty(data)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- String onLine = shackDatasDto.getData().getOnLine();
|
|
|
- if ("N".equals(onLine)) {
|
|
|
- envDevice.setDeviceStatus(0);
|
|
|
- } else {
|
|
|
- envDevice.setDeviceStatus(1);
|
|
|
- envDeviceService.updateById(envDevice);
|
|
|
- List<ShackDatasSensor> sensorDatas = shackDatasDto.getData().getSensorDatas();
|
|
|
- EnvData envData = new EnvData();
|
|
|
- for (ShackDatasSensor sensorData : sensorDatas) {
|
|
|
- if (sensorData.getId().equals(envDevice.getOhter1())) {
|
|
|
- String val = sensorData.getVal();
|
|
|
- //TODO 预警
|
|
|
- saveTemWarning(val, envWarningThreshold, envDevice, farmId);
|
|
|
- envData.setEnvTemp(val);
|
|
|
- }
|
|
|
- if (sensorData.getId().equals(envDevice.getOhter2())) {
|
|
|
- String val = sensorData.getVal();
|
|
|
- //TODO 预警
|
|
|
- saveHumWarning(val, envWarningThreshold, envDevice, farmId);
|
|
|
- envData.setEnvHum(val);
|
|
|
- }
|
|
|
- }
|
|
|
- envData.setCreateTime(new Date());
|
|
|
- envData.setDeviceId(envDevice.getDeviceCode());
|
|
|
- envData.setFarmId(farmId);
|
|
|
- envData.setUnitId(envDevice.getUnitId());
|
|
|
- envDataService.save(envData);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// @Scheduled(cron = "0 0/30 * * * ? ")
|
|
|
+//// @Scheduled(cron = "0 * * * * ? ")
|
|
|
+// @Transactional
|
|
|
+// public void getHuanKong() throws Exception {
|
|
|
+// //目前是这家
|
|
|
+// Integer farmId = 21;
|
|
|
+// String encode = loginOnly();
|
|
|
+//// System.out.println("encode" + encode);
|
|
|
+// //获取阈值
|
|
|
+// EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId));
|
|
|
+// HttpHeaders headers = new HttpHeaders();
|
|
|
+// headers.add("Authorization", encode);
|
|
|
+// HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
|
|
+// //TODO 只有一家,先拿全部
|
|
|
+// List<EnvDevice> list = envDeviceService.list();
|
|
|
+// for (EnvDevice envDevice : list) {
|
|
|
+// if (ObjectUtil.isNotEmpty(envDevice) && StringUtils.isNotBlank(envDevice.getDeviceCode())) {
|
|
|
+// System.out.println(envDevice.getDeviceCode());
|
|
|
+// String shishiBody = "";
|
|
|
+// try {
|
|
|
+// ResponseEntity<String> exchange = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackDatas/" + envDevice.getDeviceCode(), HttpMethod.GET, requestEntity, String.class);
|
|
|
+// shishiBody = exchange.getBody();
|
|
|
+// } catch (Exception e) {
|
|
|
+// System.out.println(e);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (StringUtils.isBlank(shishiBody)) {
|
|
|
+// System.out.println(new Date() + "实时数据" + shishiBody);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// ShackDatasDto shackDatasDto = JSONUtil.toBean(shishiBody, ShackDatasDto.class);
|
|
|
+//
|
|
|
+// ShackDatasDataDto data = shackDatasDto.getData();
|
|
|
+// if (ObjectUtil.isEmpty(data)){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// String onLine = shackDatasDto.getData().getOnLine();
|
|
|
+// if ("N".equals(onLine)) {
|
|
|
+// envDevice.setDeviceStatus(0);
|
|
|
+// } else {
|
|
|
+// envDevice.setDeviceStatus(1);
|
|
|
+// envDeviceService.updateById(envDevice);
|
|
|
+// List<ShackDatasSensor> sensorDatas = shackDatasDto.getData().getSensorDatas();
|
|
|
+// EnvData envData = new EnvData();
|
|
|
+// for (ShackDatasSensor sensorData : sensorDatas) {
|
|
|
+// if (sensorData.getId().equals(envDevice.getOhter1())) {
|
|
|
+// String val = sensorData.getVal();
|
|
|
+// //TODO 预警
|
|
|
+// saveTemWarning(val, envWarningThreshold, envDevice, farmId);
|
|
|
+// envData.setEnvTemp(val);
|
|
|
+// }
|
|
|
+// if (sensorData.getId().equals(envDevice.getOhter2())) {
|
|
|
+// String val = sensorData.getVal();
|
|
|
+// //TODO 预警
|
|
|
+// saveHumWarning(val, envWarningThreshold, envDevice, farmId);
|
|
|
+// envData.setEnvHum(val);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// envData.setCreateTime(new Date());
|
|
|
+// envData.setDeviceId(envDevice.getDeviceCode());
|
|
|
+// envData.setFarmId(farmId);
|
|
|
+// envData.setUnitId(envDevice.getUnitId());
|
|
|
+// envDataService.save(envData);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
@Scheduled(cron = "0 0/59 * * * ?")
|
|
|
@Transactional
|