瀏覽代碼

修改首页报警信息

523096025 4 年之前
父節點
當前提交
76295220e7

+ 8 - 0
huimv-ql-farm/huimv-ql-environment/src/main/java/com/huimv/environment/entity/WarningInfoEntity.java

@@ -50,4 +50,12 @@ public class WarningInfoEntity implements Serializable {
     @Column(name = "LQID")
     private String LQID;
 
+
+    @Column(name = "warning_type")
+    private Integer warningType;
+
+
+    @Column(name = "show_status")
+    private Integer showStatus;
+
 }

+ 1 - 1
huimv-ql-farm/huimv-ql-environment/src/main/java/com/huimv/environment/repo/WarningInfoEntityRepo.java

@@ -9,5 +9,5 @@ import java.util.List;
 
 public interface WarningInfoEntityRepo extends JpaRepository<WarningInfoEntity, Integer>, JpaSpecificationExecutor<WarningInfoEntity> {
 
-    List<WarningInfoEntity> findAllByUploadTimeBetween(Date startTime, Date endTime);
+    List<WarningInfoEntity> findAllByShowStatusAndUploadTimeBetween(Integer showStatus,Date starTime, Date endTime);
 }

+ 11 - 4
huimv-ql-farm/huimv-ql-environment/src/main/java/com/huimv/environment/service/impl/EnvironmentControlServiceImpl.java

@@ -234,6 +234,8 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
     @Override
     @DS("slave")
     public void examine() {
+
+
         String today= cn.hutool.core.date.DateUtil.today();
         System.out.println(today);
         List<FarmSm> all = farmSmRepository.findAll();
@@ -243,8 +245,10 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
             for (FarmSm farmSm : all) {
                 WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
                 warningInfoEntity.setLQID(farmSm.getLqid());
-                warningInfoEntity.setType("故障");
+                warningInfoEntity.setType("设备故障");
                 warningInfoEntity.setUploadTime(new Date());
+                warningInfoEntity.setShowStatus(0);
+                warningInfoEntity.setWarningType(1);
                 warningInfoEntityRepo.save(warningInfoEntity);
             }
 
@@ -266,8 +270,10 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
                 for (String s : subtract) {
                     WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
                     warningInfoEntity.setLQID(s);
-                    warningInfoEntity.setType("故障");
+                    warningInfoEntity.setType("设备故障,当天无数据上传");
                     warningInfoEntity.setUploadTime(new Date());
+                    warningInfoEntity.setWarningType(1);
+                    warningInfoEntity.setShowStatus(0);
                     warningInfoEntityRepo.save(warningInfoEntity);
                 }
             }
@@ -277,13 +283,14 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
     }
 
     @Override
+    @DS("slave")
     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<WarningInfoEntity> allByUploadTimeBetween = warningInfoEntityRepo.findAllByShowStatusAndUploadTimeBetween(0,stratTime,endTime);
 
         List list = new ArrayList();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -292,7 +299,7 @@ public class EnvironmentControlServiceImpl implements IEnvironmentControlService
             FarmSm byLqid = farmSmRepository.findByLqid(warningInfoEntity.getLQID());
             Date uploadTime = warningInfoEntity.getUploadTime();
 
-            String str = warningInfoEntity.getType()+"报警,当天无数据上传";
+            String str = warningInfoEntity.getType();
 
             Map map = new HashMap();
             map.put("farmName",byLqid.getName());

+ 10 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/domain/WarningInfoEntity.java

@@ -1,5 +1,6 @@
 package com.huimv.production.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import javax.persistence.*;
@@ -34,6 +35,7 @@ public class WarningInfoEntity implements Serializable {
      * 上传时间
      */
     @Column(name = "upload_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GTM+8")
     private Date uploadTime;
 
     /**
@@ -48,4 +50,12 @@ public class WarningInfoEntity implements Serializable {
     @Column(name = "LQID")
     private String LQID;
 
+
+    @Column(name = "warning_type")
+    private Integer warningType;
+
+
+    @Column(name = "show_status")
+    private Integer showStatus;
+
 }

+ 9 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/repo/WarningInfoEntityRepo.java

@@ -3,7 +3,16 @@ package com.huimv.production.repo;
 import com.huimv.production.domain.WarningInfoEntity;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.Date;
+import java.util.List;
 
 public interface WarningInfoEntityRepo extends JpaRepository<WarningInfoEntity, Integer>, JpaSpecificationExecutor<WarningInfoEntity> {
 
+    @Query(nativeQuery = true,value = "SELECT * FROM warning_info WHERE type like CONCAT('%',?1,'%') AND upload_time < ?2")
+    List<WarningInfoEntity> findDataTypeLikeLeNow(String name, Date date);
+
+    List<WarningInfoEntity> findAllByShowStatus(int showStatus);
+
 }

+ 3 - 1
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/service/impl/WarningInfoServiceImpl.java

@@ -31,7 +31,7 @@ public class WarningInfoServiceImpl implements WarningInfoService {
 
     @Override
     public Result warningInfor() {
-        List<WarningInfoEntity> all = warningInfoEntityRepo.findAll();
+        List<WarningInfoEntity> all = warningInfoEntityRepo.findAllByShowStatus(0);
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         List list  = new ArrayList();
 
@@ -43,6 +43,7 @@ public class WarningInfoServiceImpl implements WarningInfoService {
                 map.put("farmName","");
                 map.put("time",simpleDateFormat.format(uploadTime));
                 map.put("msg",warningInfoEntity.getType());
+                map.put("type",warningInfoEntity.getWarningType());
                 list.add(map);
             }else {
                 FarmSmEntity byLqid = farmSmEntityRepo.findByLQID(lqid);
@@ -55,6 +56,7 @@ public class WarningInfoServiceImpl implements WarningInfoService {
                 map.put("farmName",name);
                 map.put("time",simpleDateFormat.format(uploadTime));
                 map.put("msg",str);
+                map.put("type",warningInfoEntity.getWarningType());
                 list.add(map);
             }
 

+ 32 - 0
huimv-ql-farm/huimv-ql-production/src/main/java/com/huimv/production/task/WarningParameterTask.java

@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -40,6 +41,7 @@ public class WarningParameterTask {
     private WarningParameterEntityRepo warningParameterEntityRepo;
 
     @Scheduled(cron = "0 0 0/12 * * ?")
+//    @Scheduled(cron = "0 41 17 * * ?")
     public void warningTask() {
         List<ConfigEntity> all = configEntityRepo.findAll();
         ConfigEntity configEntity = all.get(0);
@@ -47,6 +49,9 @@ public class WarningParameterTask {
 
         List<WarningParameter> warningParameterList = warningParameterEntityRepo.findAll();
 
+        //当前时间
+        Date date = new Date();
+
         if ("true".equals(propertyValue)) {
             List<IndexParameter2Entity> localList = indexParameter2EntityRepo.findAll();
             List<IndexParameter2Entity> collect = localList.stream()
@@ -61,9 +66,22 @@ public class WarningParameterTask {
             for (IndexParameter2Entity indexParameter2Entity : collect1) {
                 WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
                 warningInfoEntity.setUploadTime(new Date());
+                warningInfoEntity.setWarningType(3);
                 warningInfoEntity.setType("本地数据的 " + indexParameter2Entity.getName() + " 参数小于阈值,请核查!");
                 warningInfoEntityRepo.save(warningInfoEntity);
             }
+
+            collect.removeAll(collect1);
+
+            List<WarningInfoEntity> list = new ArrayList<>();
+            for (IndexParameter2Entity indexParameter2Entity : collect) {
+                List<WarningInfoEntity> warningInfoEntityList = warningInfoEntityRepo.findDataTypeLikeLeNow("本地数据的 " + indexParameter2Entity.getName(),date);
+                list.addAll(warningInfoEntityList);
+            }
+            for (WarningInfoEntity warningInfoEntity : list) {
+                warningInfoEntity.setShowStatus(1);
+                warningInfoEntityRepo.saveAndFlush(warningInfoEntity);
+            }
         }
 
         if ("false".equals(propertyValue)) {
@@ -80,9 +98,23 @@ public class WarningParameterTask {
             for (IndexParameterEntity indexParameter2Entity : collect1) {
                 WarningInfoEntity warningInfoEntity = new WarningInfoEntity();
                 warningInfoEntity.setUploadTime(new Date());
+                warningInfoEntity.setWarningType(3);
                 warningInfoEntity.setType("ERP数据的 " + indexParameter2Entity.getName() + " 参数小于阈值,请核查!");
                 warningInfoEntityRepo.save(warningInfoEntity);
             }
+
+            collect.removeAll(collect1);
+
+            List<WarningInfoEntity> list = new ArrayList<>();
+            for (IndexParameterEntity indexParameterEntity : collect) {
+                List<WarningInfoEntity> warningInfoEntityList = warningInfoEntityRepo.findDataTypeLikeLeNow("ERP数据的 " + indexParameterEntity.getName(),date);
+                list.addAll(warningInfoEntityList);
+            }
+            for (WarningInfoEntity warningInfoEntity : list) {
+                warningInfoEntity.setShowStatus(1);
+                warningInfoEntityRepo.saveAndFlush(warningInfoEntity);
+            }
+
         }
     }
 }

+ 2 - 2
huimv-ql-farm/huimv-ql-production/src/main/resources/application.properties

@@ -5,13 +5,13 @@
 #spring.profiles.active=haiyan-demo1
 #spring.profiles.active=haiyan-demo2
 #spring.profiles.active=haiyan-demo3
-#spring.profiles.active=haiyan-demo4
+spring.profiles.active=haiyan-demo4
 #spring.profiles.active=haiyan-demo5
 #spring.profiles.active=haiyan-demo6
 #spring.profiles.active=ycg-demo1
 #spring.profiles.active=ycg-demo2
 #spring.profiles.active=ycg-demo3
-spring.profiles.active=ycg-demo4
+#spring.profiles.active=ycg-demo4
 #spring.profiles.active=ycg-demo5
 #spring.profiles.active=ycg-demo6