|
@@ -10,11 +10,12 @@ import com.huimv.common.result.ResultCode;
|
|
import com.huimv.environment.entity.*;
|
|
import com.huimv.environment.entity.*;
|
|
import com.huimv.environment.repo.*;
|
|
import com.huimv.environment.repo.*;
|
|
import com.huimv.environment.service.IEnvironmentControlService;
|
|
import com.huimv.environment.service.IEnvironmentControlService;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
+import org.apache.commons.lang.ArrayUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@@ -233,13 +234,80 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
|
|
@Override
|
|
@Override
|
|
@DS("slave")
|
|
@DS("slave")
|
|
public void examine() {
|
|
public void examine() {
|
|
- String todayDate = new DateUtil().formatDate(new Date());
|
|
|
|
- System.out.println(todayDate);
|
|
|
|
- List allByIdAfter = deviceUpDataEntityRepo.findAllByIdAfter(todayDate);
|
|
|
|
- System.out.println(allByIdAfter);
|
|
|
|
|
|
+ String today= cn.hutool.core.date.DateUtil.today();
|
|
|
|
+ System.out.println(today);
|
|
|
|
+ List<FarmSm> all = farmSmRepository.findAll();
|
|
|
|
+ List<Map<String,String>> allByIdAfter = deviceUpDataEntityRepo.findAllByIdAfter(today);
|
|
|
|
+
|
|
|
|
+ if (allByIdAfter == null){
|
|
|
|
+ for (FarmSm farmSm : all) {
|
|
|
|
+ WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
|
|
|
|
+ warningInfoEntity.setLQID(farmSm.getLqid());
|
|
|
|
+ warningInfoEntity.setType("故障");
|
|
|
|
+ warningInfoEntity.setUploadTime(new Date());
|
|
|
|
+ warningInfoEntityRepo.save(warningInfoEntity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else {
|
|
|
|
+ List list1= new ArrayList();
|
|
|
|
+ List list2= new ArrayList();
|
|
|
|
+ for (Map<String, String> stringStringMap : allByIdAfter) {
|
|
|
|
+ String lqid = stringStringMap.get("device_id");
|
|
|
|
+ list1.add(lqid);
|
|
|
|
+ }
|
|
|
|
+ for (FarmSm farmSm : all) {
|
|
|
|
+ list2.add(farmSm.getLqid());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Collection<String> subtract = CollectionUtils.subtract(list2, list1);
|
|
|
|
+ if (subtract == null){
|
|
|
|
+ return;
|
|
|
|
+ }else {
|
|
|
|
+ for (String s : subtract) {
|
|
|
|
+ WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
|
|
|
|
+ warningInfoEntity.setLQID(s);
|
|
|
|
+ warningInfoEntity.setType("故障");
|
|
|
|
+ warningInfoEntity.setUploadTime(new Date());
|
|
|
|
+ warningInfoEntityRepo.save(warningInfoEntity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Result findExamine() {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Date stratTime = cn.hutool.core.date.DateUtil.beginOfDay(cn.hutool.core.date.DateUtil.offsetDay(new Date(),-1));
|
|
|
|
+ Date endTime = cn.hutool.core.date.DateUtil.endOfDay(cn.hutool.core.date.DateUtil.offsetDay(new Date(),-1));
|
|
|
|
+
|
|
|
|
+ List<WarningInfoEntity> allByUploadTimeBetween = warningInfoEntityRepo.findAllByUploadTimeBetween(stratTime, endTime);
|
|
|
|
+
|
|
|
|
+ List list = new ArrayList();
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ for (WarningInfoEntity warningInfoEntity : allByUploadTimeBetween) {
|
|
|
|
+
|
|
|
|
+ FarmSm byLqid = farmSmRepository.findByLqid(warningInfoEntity.getLQID());
|
|
|
|
+ Date uploadTime = warningInfoEntity.getUploadTime();
|
|
|
|
+
|
|
|
|
+ String str = warningInfoEntity.getType()+"报警,当天无数据上传";
|
|
|
|
+
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("farmName",byLqid.getName());
|
|
|
|
+ map.put("time",simpleDateFormat.format(uploadTime));
|
|
|
|
+ map.put("msg",str);
|
|
|
|
+ list.add(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return new Result(ResultCode.SUCCESS,list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/* @Override
|
|
/* @Override
|
|
public Result getAllFarm() {
|
|
public Result getAllFarm() {
|
|
|
|
|