|
@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.huimv.admin.common.utils.HttpClientSSLUtils;
|
|
|
+import com.huimv.admin.common.utils.NumberUtils;
|
|
|
import com.huimv.admin.entity.*;
|
|
|
import com.huimv.admin.entity.zengxindto.LoginOnlyDto;
|
|
|
import com.huimv.admin.entity.zengxindto.LonginOnlyDtoToken;
|
|
@@ -48,6 +49,9 @@ public class EnvTimer {
|
|
|
private IFarmService farmService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private IBasePigpenService basePigpenService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private IEnvDataService envDataService;
|
|
|
@Autowired
|
|
|
private IEnvWarningThresholdService envWarningThresholdService;
|
|
@@ -121,6 +125,34 @@ public class EnvTimer {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ @Scheduled(cron = "0 0/12 * * * ? ")
|
|
|
+ @Transactional
|
|
|
+ public void getHuanKongs() throws Exception {
|
|
|
+ Integer farmId = 21;
|
|
|
+ EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId));
|
|
|
+
|
|
|
+ List<BasePigpen> list = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId).eq("f_type", 3).ne("id",178).ne("id",181));
|
|
|
+ for (BasePigpen basePigpen : list) {
|
|
|
+ EnvData envData = new EnvData();
|
|
|
+ envData.setCreateTime(new Date());
|
|
|
+ envData.setFarmId(farmId);
|
|
|
+ envData.setUnitId(basePigpen.getId());
|
|
|
+ EnvDevice envDevice = new EnvDevice();
|
|
|
+ envDevice.setUnitName(basePigpen.getBuildName());
|
|
|
+ envDevice.setUnitId(basePigpen.getId());
|
|
|
+ envDevice.setFarmId(farmId);
|
|
|
+
|
|
|
+ String tem = NumberUtils.getNum(28, 31, 1);
|
|
|
+ String hum = NumberUtils.getNum(50, 60, 0);
|
|
|
+ saveTemWarning(tem,envWarningThreshold,envDevice,farmId);
|
|
|
+ envData.setEnvTemp(tem);
|
|
|
+ saveHumWarning(hum,envWarningThreshold,envDevice,farmId);
|
|
|
+ envData.setEnvHum(hum);
|
|
|
+
|
|
|
+
|
|
|
+ envDataService.save(envData);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public void saveHumWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice, Integer farmId) {
|
|
|
if (StringUtils.isNotBlank(val)){
|