|
@@ -333,9 +333,12 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
|
|
|
@DS("master")
|
|
|
public void save(DeviceUpDataEntity[] forObject) {
|
|
|
|
|
|
+ //把之前的报警信息清除
|
|
|
+ warningInfoEntityRepo.updateShowStatusByWarningType();
|
|
|
|
|
|
+ //查找全部栋舍
|
|
|
List<FarmSm> all = farmSmRepository.findAll();
|
|
|
- warningInfoEntityRepo.updateShowStatusByWarningType();
|
|
|
+ //没有信息,全部栋舍无数据,都加入到报警表中
|
|
|
if (forObject == null){
|
|
|
for (FarmSm farmSm : all) {
|
|
|
WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
|
|
@@ -347,6 +350,11 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
|
|
|
warningInfoEntityRepo.save(warningInfoEntity);
|
|
|
}
|
|
|
}else {
|
|
|
+ //同步数据
|
|
|
+ for (DeviceUpDataEntity deviceUpDataEntity : forObject) {
|
|
|
+ deviceUpDataEntityRepo.save(deviceUpDataEntity);
|
|
|
+ }
|
|
|
+ //拿出没有数据的栋舍集合
|
|
|
List list1= new ArrayList();
|
|
|
List list2= new ArrayList();
|
|
|
for (DeviceUpDataEntity deviceUpDataEntity : forObject) {
|
|
@@ -356,6 +364,8 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
|
|
|
list2.add(farmSm.getLqid());
|
|
|
}
|
|
|
Collection<String> subtract = CollectionUtils.subtract(list2, list1);
|
|
|
+
|
|
|
+ //又没数据的栋舍就加入到报警表中,没有直接返回
|
|
|
if (subtract == null){
|
|
|
return;
|
|
|
}else {
|
|
@@ -371,11 +381,7 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (forObject != null){
|
|
|
- for (DeviceUpDataEntity deviceUpDataEntity : forObject) {
|
|
|
- deviceUpDataEntityRepo.save(deviceUpDataEntity);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|