|
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -170,30 +171,59 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
|
|
|
}
|
|
|
|
|
|
|
|
|
+// @Override
|
|
|
+// @DS("slave")
|
|
|
+// public Result warningInfor() {
|
|
|
+// List endList = new ArrayList();
|
|
|
+// List<DeviceUpDataEntity> allByTimestampBetween = deviceUpDataEntityRepo.findAllByTimestampBetween(minTemp, maxTemp, cn.hutool.core.date.DateUtil.today());
|
|
|
+// for (DeviceUpDataEntity deviceUpDataEntity : allByTimestampBetween) {
|
|
|
+// Map map = new HashMap();
|
|
|
+// map.put("farmName",farmSmRepository.findByLqid(deviceUpDataEntity.getDeviceId()).getName());
|
|
|
+// map.put("time",deviceUpDataEntity.getTimestamp());
|
|
|
+// String str = "";
|
|
|
+// if (deviceUpDataEntity.getDataTempConvert() < minTemp){
|
|
|
+// str = str +"温度过低,温度:"+ deviceUpDataEntity.getDataTempConvert();
|
|
|
+// }
|
|
|
+// if (deviceUpDataEntity.getDataTempConvert() > maxTemp){
|
|
|
+// str = str +"温度过高,温度:"+ deviceUpDataEntity.getDataTempConvert();
|
|
|
+// }
|
|
|
+// map.put("msg",str);
|
|
|
+// endList.add(map);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return new Result(ResultCode.SUCCESS,endList) ;
|
|
|
+// }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WarningInfoEntityRepo warningInfoEntityRepo;
|
|
|
+
|
|
|
@Override
|
|
|
@DS("master")
|
|
|
public Result warningInfor() {
|
|
|
- List endList = new ArrayList();
|
|
|
- List<DeviceUpDataEntity> allByTimestampBetween = deviceUpDataEntityRepo.findAllByTimestampBetween(minTemp, maxTemp, cn.hutool.core.date.DateUtil.today());
|
|
|
- for (DeviceUpDataEntity deviceUpDataEntity : allByTimestampBetween) {
|
|
|
- Map map = new HashMap();
|
|
|
- map.put("farmName",farmSmRepository.findByLqid(deviceUpDataEntity.getDeviceId()).getName());
|
|
|
- map.put("time",deviceUpDataEntity.getTimestamp());
|
|
|
- String str = "";
|
|
|
- if (deviceUpDataEntity.getDataTempConvert() < minTemp){
|
|
|
- str = str +"温度过低,温度:"+ deviceUpDataEntity.getDataTempConvert();
|
|
|
- }
|
|
|
- if (deviceUpDataEntity.getDataTempConvert() > maxTemp){
|
|
|
- str = str +"温度过高,温度:"+ deviceUpDataEntity.getDataTempConvert();
|
|
|
- }
|
|
|
+ List<WarningInfoEntity> all = warningInfoEntityRepo.findAll();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ List list = new ArrayList();
|
|
|
+
|
|
|
+ for (WarningInfoEntity warningInfoEntity : all) {
|
|
|
+ Map map = new HashMap();
|
|
|
+
|
|
|
+ String lqid = warningInfoEntity.getLQID();
|
|
|
+ FarmSm byLqid = farmSmRepository.findByLqid(lqid);
|
|
|
+ Date uploadTime = warningInfoEntity.getUploadTime();
|
|
|
+ String name = byLqid.getName();
|
|
|
+ String type = warningInfoEntity.getType();
|
|
|
+ Double temperature = warningInfoEntity.getTemperature();
|
|
|
+ String str = type+"报警,当前温度为:"+temperature+" ℃";
|
|
|
+
|
|
|
+ map.put("farmName",name);
|
|
|
+ map.put("time",simpleDateFormat.format(uploadTime));
|
|
|
map.put("msg",str);
|
|
|
- endList.add(map);
|
|
|
- }
|
|
|
+ list.add(map);
|
|
|
|
|
|
- return new Result(ResultCode.SUCCESS,endList) ;
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,list);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
@DS("master")
|
|
|
public Result findByZSID() {
|