|
@@ -160,7 +160,66 @@ public class EnvTimer {
|
|
envData.setEnvTemp(tem);
|
|
envData.setEnvTemp(tem);
|
|
saveHumWarning(hum, envWarningThreshold, envDevice, farmId);
|
|
saveHumWarning(hum, envWarningThreshold, envDevice, farmId);
|
|
envData.setEnvHum(hum);
|
|
envData.setEnvHum(hum);
|
|
|
|
+ envDataService.save(envData);
|
|
|
|
+ }
|
|
|
|
+ Integer farmId1 = 23;
|
|
|
|
+ EnvWarningThreshold envWarningThreshold1 = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId1));
|
|
|
|
+
|
|
|
|
+ List<BasePigpen> list1 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId1).eq("f_type", 3).ne("id", 225));
|
|
|
|
+// String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
|
|
|
|
+// String result = HttpUtil.get(url);
|
|
|
|
+// WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
|
|
|
|
+// List<WeatherLives> lives = weatherDto.getLives();
|
|
|
|
+// WeatherLives weatherLives = lives.get(0);
|
|
|
|
+// int humidity = Integer.parseInt(weatherLives.getHumidity());
|
|
|
|
+// int temperature = Integer.parseInt(weatherLives.getTemperature());
|
|
|
|
+
|
|
|
|
+ for (BasePigpen basePigpen : list1) {
|
|
|
|
+ EnvData envData = new EnvData();
|
|
|
|
+ envData.setCreateTime(new Date());
|
|
|
|
+ envData.setFarmId(farmId1);
|
|
|
|
+ envData.setUnitId(basePigpen.getId());
|
|
|
|
+ EnvDevice envDevice = new EnvDevice();
|
|
|
|
+ envDevice.setUnitName(basePigpen.getBuildName());
|
|
|
|
+ envDevice.setUnitId(basePigpen.getId());
|
|
|
|
+ envDevice.setFarmId(farmId1);
|
|
|
|
|
|
|
|
+ String tem = NumberUtils.getNum(17, 23, 1);
|
|
|
|
+ String hum = NumberUtils.getNum(65, 80, 0);
|
|
|
|
+ saveTemWarning(tem, envWarningThreshold1, envDevice, farmId1);
|
|
|
|
+ envData.setEnvTemp(tem);
|
|
|
|
+ saveHumWarning(hum, envWarningThreshold1, envDevice, farmId1);
|
|
|
|
+ envData.setEnvHum(hum);
|
|
|
|
+ envDataService.save(envData);
|
|
|
|
+ }
|
|
|
|
+ Integer farmId2 = 24;
|
|
|
|
+ EnvWarningThreshold envWarningThreshold2 = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId2));
|
|
|
|
+
|
|
|
|
+ List<BasePigpen> list2 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId2).eq("f_type", 3).ne("id", 217));
|
|
|
|
+// String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
|
|
|
|
+// String result = HttpUtil.get(url);
|
|
|
|
+// WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
|
|
|
|
+// List<WeatherLives> lives = weatherDto.getLives();
|
|
|
|
+// WeatherLives weatherLives = lives.get(0);
|
|
|
|
+// int humidity = Integer.parseInt(weatherLives.getHumidity());
|
|
|
|
+// int temperature = Integer.parseInt(weatherLives.getTemperature());
|
|
|
|
+
|
|
|
|
+ for (BasePigpen basePigpen : list2) {
|
|
|
|
+ EnvData envData = new EnvData();
|
|
|
|
+ envData.setCreateTime(new Date());
|
|
|
|
+ envData.setFarmId(farmId2);
|
|
|
|
+ envData.setUnitId(basePigpen.getId());
|
|
|
|
+ EnvDevice envDevice = new EnvDevice();
|
|
|
|
+ envDevice.setUnitName(basePigpen.getBuildName());
|
|
|
|
+ envDevice.setUnitId(basePigpen.getId());
|
|
|
|
+ envDevice.setFarmId(farmId2);
|
|
|
|
+
|
|
|
|
+ String tem = NumberUtils.getNum(17, 23, 1);
|
|
|
|
+ String hum = NumberUtils.getNum(65, 80, 0);
|
|
|
|
+ saveTemWarning(tem, envWarningThreshold2, envDevice, farmId2);
|
|
|
|
+ envData.setEnvTemp(tem);
|
|
|
|
+ saveHumWarning(hum, envWarningThreshold2, envDevice, farmId2);
|
|
|
|
+ envData.setEnvHum(hum);
|
|
envDataService.save(envData);
|
|
envDataService.save(envData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -272,19 +331,19 @@ public class EnvTimer {
|
|
Integer count = envDeviceService.count(queryWrapper);
|
|
Integer count = envDeviceService.count(queryWrapper);
|
|
QueryWrapper<EnvDevice> queryWrapper1 = new QueryWrapper<>();
|
|
QueryWrapper<EnvDevice> queryWrapper1 = new QueryWrapper<>();
|
|
queryWrapper1.eq("device_status", 0);
|
|
queryWrapper1.eq("device_status", 0);
|
|
- Integer count1 = envDeviceService.count(queryWrapper1);
|
|
|
|
- Integer OffDeviceCount = count - count1;
|
|
|
|
|
|
+ Integer count1 = envDeviceService.count(queryWrapper1);//离线
|
|
|
|
+ Integer OnDeviceCount = count - count1;//在线
|
|
//创建一个数值格式化对象
|
|
//创建一个数值格式化对象
|
|
NumberFormat numberFormat = NumberFormat.getInstance();
|
|
NumberFormat numberFormat = NumberFormat.getInstance();
|
|
//设置精确到小数点后两位
|
|
//设置精确到小数点后两位
|
|
numberFormat.setMaximumFractionDigits(2);
|
|
numberFormat.setMaximumFractionDigits(2);
|
|
- String onDeviceRate = numberFormat.format((float) count1 / (float) count * 100);
|
|
|
|
|
|
+ String onDeviceRate = numberFormat.format((float) OnDeviceCount / (float) count * 100);
|
|
|
|
|
|
EnvDeviceOnline envDeviceOnline = envDeviceOnlineService.getOne(new QueryWrapper<EnvDeviceOnline>().eq("farm_id", farmId).ge("creat_time", beginOfMonth));
|
|
EnvDeviceOnline envDeviceOnline = envDeviceOnlineService.getOne(new QueryWrapper<EnvDeviceOnline>().eq("farm_id", farmId).ge("creat_time", beginOfMonth));
|
|
if (ObjectUtil.isEmpty(envDeviceOnline)) {
|
|
if (ObjectUtil.isEmpty(envDeviceOnline)) {
|
|
envDeviceOnline = new EnvDeviceOnline();
|
|
envDeviceOnline = new EnvDeviceOnline();
|
|
envDeviceOnline.setCreatTime(date);
|
|
envDeviceOnline.setCreatTime(date);
|
|
- envDeviceOnline.setDeviceOff(OffDeviceCount);
|
|
|
|
|
|
+ envDeviceOnline.setDeviceOff(count1);
|
|
envDeviceOnline.setDeviceOn(count1);
|
|
envDeviceOnline.setDeviceOn(count1);
|
|
envDeviceOnline.setFarmId(farmId + "");
|
|
envDeviceOnline.setFarmId(farmId + "");
|
|
envDeviceOnline.setOnlineRate(onDeviceRate);
|
|
envDeviceOnline.setOnlineRate(onDeviceRate);
|
|
@@ -294,7 +353,7 @@ public class EnvTimer {
|
|
} else {
|
|
} else {
|
|
envDeviceOnline = new EnvDeviceOnline();
|
|
envDeviceOnline = new EnvDeviceOnline();
|
|
envDeviceOnline.setCreatTime(date);
|
|
envDeviceOnline.setCreatTime(date);
|
|
- envDeviceOnline.setDeviceOff(OffDeviceCount);
|
|
|
|
|
|
+ envDeviceOnline.setDeviceOff(count1);
|
|
envDeviceOnline.setDeviceOn(count1);
|
|
envDeviceOnline.setDeviceOn(count1);
|
|
envDeviceOnline.setFarmId(farmId + "");
|
|
envDeviceOnline.setFarmId(farmId + "");
|
|
envDeviceOnline.setOnlineRate(onDeviceRate);
|
|
envDeviceOnline.setOnlineRate(onDeviceRate);
|