3 Commits eda1749232 ... 9ff0a5a754

Author SHA1 Message Date
  shilin 9ff0a5a754 定边报警系统修改 4 months ago
  shilin 0ec1880a3f 添加异步多线程调度功能 4 months ago
  shilin ec4af2de61 添加异步多线程调度功能 4 months ago
55 changed files with 2861 additions and 612 deletions
  1. 13 2
      alarm-custom/src/main/java/com/gyee/alarm/init/CacheContext.java
  2. 229 151
      alarm-custom/src/main/java/com/gyee/alarm/util/realtimesource/EdosUtil.java
  3. 1 1
      alarm-scanner/pom.xml
  4. 16 31
      alarm-scanner/src/main/java/com/gyee/alarm/config/ThreadPoolTaskConfig.java
  5. 3 3
      alarm-scanner/src/main/java/com/gyee/alarm/service/AlarmScannerService.java
  6. 4 4
      alarm-service/src/main/java/com/gyee/alarm/config/GeneratorCodeConfig.java
  7. 20 0
      alarm-service/src/main/java/com/gyee/alarm/controller/ProEconAlarmPlanController.java
  8. 20 0
      alarm-service/src/main/java/com/gyee/alarm/controller/ProEconAlarmRealController.java
  9. 16 0
      alarm-service/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmPlanMapper.java
  10. 16 0
      alarm-service/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRealMapper.java
  11. 47 0
      alarm-service/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmPlan.java
  12. 37 0
      alarm-service/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmReal.java
  13. 14 14
      alarm-service/src/main/java/com/gyee/alarm/service/AlarmBtService.java
  14. 16 0
      alarm-service/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmPlanService.java
  15. 16 0
      alarm-service/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmRealService.java
  16. 20 0
      alarm-service/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmPlanServiceImpl.java
  17. 20 0
      alarm-service/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmRealServiceImpl.java
  18. 6 1
      alarm-web/pom.xml
  19. 2 2
      alarm-web/src/main/java/com/gyee/alarm/config/GeneratorCodeConfig.java
  20. 3 3
      alarm-web/src/main/java/com/gyee/alarm/config/ThreadPoolTaskConfig.java
  21. 11 11
      alarm-web/src/main/java/com/gyee/alarm/controller/AlarmConfigurationController.java
  22. 72 0
      alarm-web/src/main/java/com/gyee/alarm/controller/AlarmHistoryController.java
  23. 49 15
      alarm-web/src/main/java/com/gyee/alarm/controller/AlertRuleController.java
  24. 6 6
      alarm-web/src/main/java/com/gyee/alarm/controller/InfoController.java
  25. 83 8
      alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicDeviceController.java
  26. 49 2
      alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicDeviceFaultModeController.java
  27. 330 0
      alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmPlanController.java
  28. 77 0
      alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmRealController.java
  29. 38 10
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java
  30. 329 0
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper3.java
  31. 3 3
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceFaultModeMapper.java
  32. 2 2
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceMetricsMapper.java
  33. 1 1
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceModelMetricsMapper.java
  34. 78 0
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmPlanMapper.java
  35. 39 0
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRealMapper.java
  36. 2 0
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRuleMapper.java
  37. 1 1
      alarm-web/src/main/java/com/gyee/alarm/model/auto/ProBasicDeviceFaultMode.java
  38. 66 0
      alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmPlan.java
  39. 40 0
      alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmReal.java
  40. 3 0
      alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmRule.java
  41. 23 13
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmConfigurationService.java
  42. 123 2
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmHistoryService.java
  43. 14 10
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmRuleService.java
  44. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmWtService.java
  45. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/DeviceFaultModeService.java
  46. 7 3
      alarm-web/src/main/java/com/gyee/alarm/service/DeviceService.java
  47. 380 0
      alarm-web/src/main/java/com/gyee/alarm/service/TokenNoTokenService.java
  48. 20 310
      alarm-web/src/main/java/com/gyee/alarm/service/TokenService.java
  49. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/auto/IProBasicDeviceModelMetricsService.java
  50. 38 0
      alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmPlanService.java
  51. 16 0
      alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmRealService.java
  52. 9 0
      alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProBasicDeviceModelMetricsServiceImpl.java
  53. 183 0
      alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmPlanServiceImpl.java
  54. 20 0
      alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmRealServiceImpl.java
  55. 227 0
      alarm-web/src/main/java/com/gyee/alarm/util/ExcelUtil.java

+ 13 - 2
alarm-custom/src/main/java/com/gyee/alarm/init/CacheContext.java

@@ -4,6 +4,7 @@ package com.gyee.alarm.init;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.gyee.alarm.init.redis.RedisService;
+import com.gyee.alarm.model.vo.AlarmTypeValue;
 import com.gyee.alarm.model.vo.AlarmVo;
 import com.gyee.common.model.PointData;
 import com.gyee.common.model.StringUtils;
@@ -31,7 +32,8 @@ import java.util.stream.Collectors;
 @Component
 public class CacheContext implements CommandLineRunner {
     Logger logger = LoggerFactory.getLogger(CacheContext.class);
-
+    @Value("${initialcode}")
+    private String initialcode;
     @Resource
     private IProBasicEquipmentService proBasicEquipmentService;
     @Resource
@@ -397,7 +399,16 @@ public class CacheContext implements CommandLineRunner {
             if(null !=stringWindturbinetestingpointnewMap)
             {
                 for(Map.Entry<String,ProBasicEquipmentPoint> entry : stringWindturbinetestingpointnewMap.entrySet()){
-                    wtPointList.add(entry.getValue());
+
+
+                    if (com.gyee.alarm.util.StringUtils.notEmp(initialcode) &&
+                            com.gyee.alarm.util.StringUtils.notEmp(entry.getValue().getNemCode()) &&
+                            !entry.getValue().getNemCode().equals(initialcode)
+                    )
+                    {
+                        wtPointList.add(entry.getValue());
+                    }
+
                 }
             }
 

+ 229 - 151
alarm-custom/src/main/java/com/gyee/alarm/util/realtimesource/EdosUtil.java

@@ -51,23 +51,28 @@ public class EdosUtil implements IEdosUtil {
                 if (point.getNemCode().startsWith("GF-")){
                     url =  baseURL2 + "/latest?null=0";
                 }
-                if (keys.isPresent())
+                if (keys.isPresent()) {
                     url = url + "&keys=" + keys.get();
-                if (thingType.isPresent())
+                }
+                if (thingType.isPresent()) {
                     url = url + "&thingType=" + thingType.get();
-                if (thingId.isPresent())
+                }
+                if (thingId.isPresent()) {
                     url = url + "&thingId=" + thingId.get();
-                if (uniformCodes.isPresent())
+                }
+                if (uniformCodes.isPresent()) {
                     url = url + "&uniformCodes=" + uniformCodes.get();
+                }
 
                 ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
                 JSONObject jsonArray = resp.getBody();
                 if (StringUtils.isNotEmpty(jsonArray)){
                     List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
-                    if (list.size() > 0)
+                    if (list.size() > 0) {
                         return list.get(0);
-                    else
+                    } else {
                         return ErrorRequest.RequestError(point.getNemCode());
+                    }
                 } else {
                     return ErrorRequest.RequestError(point.getNemCode());
                 }
@@ -84,7 +89,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             return po;
         }
 
@@ -105,10 +110,11 @@ public class EdosUtil implements IEdosUtil {
             JSONObject jsonArray = resp.getBody();
             if (StringUtils.isNotEmpty(jsonArray)){
                 List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
-                if (list.size() > 0)
+                if (list.size() > 0) {
                     return list.get(0);
-                else
+                } else {
                     return ErrorRequest.RequestError(point);
+                }
             } else {
                 return ErrorRequest.RequestError(point);
             }
@@ -117,7 +123,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point);
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             return po;
         }
     }
@@ -135,10 +141,11 @@ public class EdosUtil implements IEdosUtil {
             JSONObject jsonArray = resp.getBody();
             if (StringUtils.isNotEmpty(jsonArray)){
                 List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
-                if (list.size() > 0)
+                if (list.size() > 0) {
                     return list.get(0);
-                else
+                } else {
                     return ErrorRequest.RequestError(point.getNemCode());
+                }
             } else {
                 return ErrorRequest.RequestError(point.getNemCode());
             }
@@ -147,7 +154,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             return po;
         }
 
@@ -170,10 +177,11 @@ public class EdosUtil implements IEdosUtil {
             JSONObject jsonArray = resp.getBody();
             if (StringUtils.isNotEmpty(jsonArray)){
                 List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
-                if (list.size() > 0)
+                if (list.size() > 0) {
                     return list.get(0);
-                else
+                } else {
                     return ErrorRequest.RequestError(point.getNemCode());
+                }
             } else {
                 return ErrorRequest.RequestError(point.getNemCode());
             }
@@ -182,7 +190,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             return po;
         }
     }
@@ -201,12 +209,13 @@ public class EdosUtil implements IEdosUtil {
             Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
             //通过时间区间和时间间隔获取点数
             Long finalInterval;
-            if (pried != null)
+            if (pried != null) {
                 finalInterval = pried;
-            else if (count != null)
+            } else if (count != null) {
                 finalInterval = (endDate - beginDate) / count;
-            else
+            } else {
                 return ErrorRequest.RequestListError(point.getNemCode());
+            }
             Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
 
             try {
@@ -216,22 +225,28 @@ public class EdosUtil implements IEdosUtil {
                 }
 
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                else {
-                    if (thingType.isPresent())
+                } else {
+                    if (thingType.isPresent()) {
                         url = url + "&thingType=" + thingType.get();
-                    if (thingId.isPresent())
+                    }
+                    if (thingId.isPresent()) {
                         url = url + "&thingId=" + thingId.get();
-                    if (uniformCode.isPresent())
+                    }
+                    if (uniformCode.isPresent()) {
                         url = url + "&uniformCodes=" + uniformCode.get();
+                    }
                 }
-                if (startTs.isPresent())
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
-                if (interval.isPresent())
+                }
+                if (interval.isPresent()) {
                     url = url + "&interval=" + interval.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
                 JSONArray jsonArray = resp.getBody();
@@ -276,7 +291,7 @@ public class EdosUtil implements IEdosUtil {
                                 } else {
                                     PointData data = new PointData();
                                     data.setEdnaId(point.getNemCode());
-                                    data.setPointTime(0l);
+                                    data.setPointTime(0L);
                                     data.setPointValue("0");
                                     data.setPointName("1");
                                     data.setPointValueInDouble(0.0);
@@ -285,7 +300,7 @@ public class EdosUtil implements IEdosUtil {
                             } else {
                                 PointData data = new PointData();
                                 data.setEdnaId(point.getNemCode());
-                                data.setPointTime(0l);
+                                data.setPointTime(0L);
                                 data.setPointValue("0");
                                 data.setPointName("1");
                                 data.setPointValueInDouble(0.0);
@@ -316,7 +331,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -355,7 +370,7 @@ public class EdosUtil implements IEdosUtil {
             } else {
                 PointData data = new PointData();
                 data.setEdnaId(pointid);
-                data.setPointTime(0l);
+                data.setPointTime(0L);
                 data.setPointValue("0");
                 data.setPointName("1");
                 data.setPointValueInDouble(0.0);
@@ -391,27 +406,32 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL2 + "/history/snap?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                else {
-                    if (thingType.isPresent())
+                } else {
+                    if (thingType.isPresent()) {
                         url = url + "&thingType=" + thingType.get();
-                    if (thingId.isPresent())
+                    }
+                    if (thingId.isPresent()) {
                         url = url + "&thingId=" + thingId.get();
-                    if (uniformCode.isPresent())
+                    }
+                    if (uniformCode.isPresent()) {
                         url = url + "&uniformCodes=" + uniformCode.get();
+                    }
                 }
 
-                if (startTs.isPresent())
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
                 JSONArray jsonArray = resp.getBody();
-                if (jsonArray != null)
+                if (jsonArray != null) {
                     return JsonObjectHelper.phrasePointData(jsonArray, point.getNemCode());
-                else {
+                } else {
                     return ErrorRequest.RequestListError(point.getNemCode());
                 }
 
@@ -429,7 +449,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -455,24 +475,28 @@ public class EdosUtil implements IEdosUtil {
                 }
 
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (keys.isPresent())
+                if (keys.isPresent()) {
                     url = url + "&keys=" + keys.get();
-                else {
-                    if (thingType.isPresent())
+                } else {
+                    if (thingType.isPresent()) {
                         url = url + "&thingType=" + thingType.get();
-                    if (thingId.isPresent())
+                    }
+                    if (thingId.isPresent()) {
                         url = url + "&thingId=" + thingId.get();
-                    if (uniformCodes.isPresent())
+                    }
+                    if (uniformCodes.isPresent()) {
                         url = url + "&uniformCodes=" + uniformCodes.get();
+                    }
                 }
                 ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
                 JSONObject jsonArray = resp.getBody();
                 if (StringUtils.isNotEmpty(jsonArray)){
                     List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
-                    if (list.size() > 0)
+                    if (list.size() > 0) {
                         return list.get(0);
-                    else
+                    } else {
                         return ErrorRequest.RequestError(point.getNemCode());
+                    }
                 } else {
                     return ErrorRequest.RequestError(point.getNemCode());
                 }
@@ -490,7 +514,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             return po;
         }
 
@@ -509,12 +533,13 @@ public class EdosUtil implements IEdosUtil {
             Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
             //通过时间区间和时间间隔获取点数
             Long finalInterval;
-            if (pried != null)
+            if (pried != null) {
                 finalInterval = pried;
-            else if (count != null)
+            } else if (count != null) {
                 finalInterval = (endDate - beginDate) / count;
-            else
+            } else {
                 return ErrorRequest.RequestListError(point.getNemCode());
+            }
             Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
 
             try {
@@ -525,22 +550,28 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL + "/history/snap?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                else {
-                    if (thingType.isPresent())
+                } else {
+                    if (thingType.isPresent()) {
                         url = url + "&thingType=" + thingType.get();
-                    if (thingId.isPresent())
+                    }
+                    if (thingId.isPresent()) {
                         url = url + "&thingId=" + thingId.get();
-                    if (uniformCode.isPresent())
+                    }
+                    if (uniformCode.isPresent()) {
                         url = url + "&uniformCodes=" + uniformCode.get();
+                    }
                 }
-                if (startTs.isPresent())
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
-                if (interval.isPresent())
+                }
+                if (interval.isPresent()) {
                     url = url + "&interval=" + interval.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
                 JSONArray jsonArray = resp.getBody();
@@ -586,7 +617,7 @@ public class EdosUtil implements IEdosUtil {
                                 } else {
                                     PointData data = new PointData();
                                     data.setEdnaId(point.getNemCode());
-                                    data.setPointTime(0l);
+                                    data.setPointTime(0L);
                                     data.setPointValue("0");
                                     data.setPointName("1");
                                     data.setPointValueInDouble(0.0);
@@ -595,7 +626,7 @@ public class EdosUtil implements IEdosUtil {
                             } else {
                                 PointData data = new PointData();
                                 data.setEdnaId(point.getNemCode());
-                                data.setPointTime(0l);
+                                data.setPointTime(0L);
                                 data.setPointValue("0");
                                 data.setPointName("1");
                                 data.setPointValueInDouble(0.0);
@@ -623,7 +654,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -649,27 +680,32 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL + "/history/snap?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                else {
-                    if (thingType.isPresent())
+                } else {
+                    if (thingType.isPresent()) {
                         url = url + "&thingType=" + thingType.get();
-                    if (thingId.isPresent())
+                    }
+                    if (thingId.isPresent()) {
                         url = url + "&thingId=" + thingId.get();
-                    if (uniformCode.isPresent())
+                    }
+                    if (uniformCode.isPresent()) {
                         url = url + "&uniformCodes=" + uniformCode.get();
+                    }
                 }
 
-                if (startTs.isPresent())
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
                 JSONArray jsonArray = resp.getBody();
-                if (jsonArray != null)
+                if (jsonArray != null) {
                     return JsonObjectHelper.phrasePointData(jsonArray, point.getNemCode());
-                else {
+                } else {
                     return ErrorRequest.RequestListError(point.getNemCode());
                 }
             } catch (HttpClientErrorException exception) {
@@ -686,7 +722,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -705,19 +741,21 @@ public class EdosUtil implements IEdosUtil {
             }
 
             try {
-                if (keys.isPresent())
+                if (keys.isPresent()) {
                     url = url + "&keys=" + keys.get();
-                else
+                } else {
                     return null;
+                }
 
                 ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
                 JSONObject jsonArray = resp.getBody();
                 if (StringUtils.isNotEmpty(jsonArray)){
                     List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
-                    if (list.size() > 0)
+                    if (list.size() > 0) {
                         return list.get(0);
-                    else
+                    } else {
                         return ErrorRequest.RequestError(pointid);
+                    }
                 } else {
                     return ErrorRequest.RequestError(pointid);
                 }
@@ -735,7 +773,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(pointid);
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             return po;
         }
 
@@ -752,9 +790,9 @@ public class EdosUtil implements IEdosUtil {
             url = baseURL2 + "/latest?null=0";
         }
         try {
-            if (keys.isPresent())
+            if (keys.isPresent()) {
                 url = url + "&keys=" + keys.get();
-            else {
+            } else {
                 return ErrorRequest.RequestListError(pointids);
             }
             ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
@@ -784,8 +822,9 @@ public class EdosUtil implements IEdosUtil {
                     // 获得key
                     String key = sIterator.next();
                     PointData pointData = pointDataHashMap.get(key);
-                    if (pointData == null)
+                    if (pointData == null) {
                         continue;
+                    }
                     // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
                     JSONObject jsonData = jsonObject.getJSONObject(key);
                     Long ts = jsonData.getLong("ts");
@@ -846,9 +885,9 @@ public class EdosUtil implements IEdosUtil {
             url = baseURL2 + "/latest?null=0";
         }
         try {
-            if (keys.isPresent())
+            if (keys.isPresent()) {
                 url = url + "&keys=" + keys.get();
-            else {
+            } else {
                 String[] arr = new String[pointids.size()];
                 return ErrorRequest.RequestListError(pointids.toArray(arr));
             }
@@ -880,8 +919,9 @@ public class EdosUtil implements IEdosUtil {
                     // 获得key
                     String key = sIterator.next();
                     PointData pointData = pointDataHashMap.get(key);
-                    if (pointData == null)
+                    if (pointData == null) {
                         continue;
+                    }
                     // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
                     JSONObject jsonData = jsonObject.getJSONObject(key);
                     Long ts = jsonData.getLong("ts");
@@ -951,10 +991,11 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL2 + "/latest?null=0";
                 }
                 try {
-                    if (keys.isPresent())
+                    if (keys.isPresent()) {
                         url = url + "&keys=" + keys.get();
-                    else
+                    } else {
                         return null;
+                    }
                     ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
                     JSONObject jsonArray = resp.getBody();
                     if (StringUtils.isNotEmpty(jsonArray)){
@@ -980,8 +1021,9 @@ public class EdosUtil implements IEdosUtil {
                         }
                         return resultMap;
 
-                    } else
+                    } else {
                         return ErrorRequest.RequestMapError();
+                    }
                 } catch (HttpClientErrorException exception) {
                     if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
                         //System.out.println("404请求错误");
@@ -1029,12 +1071,13 @@ public class EdosUtil implements IEdosUtil {
 
             //通过时间区间和时间间隔获取点数
             Long finalInterval;
-            if (pried != null)
+            if (pried != null) {
                 finalInterval = pried;
-            else if (count != null)
+            } else if (count != null) {
                 finalInterval = (endDate - beginDate) / count;
-            else
+            } else {
                 return ErrorRequest.RequestListError(pointid);
+            }
             Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
 
             try {
@@ -1043,15 +1086,19 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL2 + "/history/snap?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
+                }
 
-                if (startTs.isPresent())
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
-                if (interval.isPresent())
+                }
+                if (interval.isPresent()) {
                     url = url + "&interval=" + interval.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
                 JSONArray jsonArray = resp.getBody();
@@ -1095,7 +1142,7 @@ public class EdosUtil implements IEdosUtil {
                                 } else {
                                     PointData data = new PointData();
                                     data.setEdnaId(pointid);
-                                    data.setPointTime(0l);
+                                    data.setPointTime(0L);
                                     data.setPointValue("0");
                                     data.setPointName("1");
                                     data.setPointValueInDouble(0.0);
@@ -1104,7 +1151,7 @@ public class EdosUtil implements IEdosUtil {
                             } else {
                                 PointData data = new PointData();
                                 data.setEdnaId(pointid);
-                                data.setPointTime(0l);
+                                data.setPointTime(0L);
                                 data.setPointValue("0");
                                 data.setPointName("1");
                                 data.setPointValueInDouble(0.0);
@@ -1132,7 +1179,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(pointid);
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -1158,19 +1205,22 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL2 + "/history/raw?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                if (startTs.isPresent())
+                }
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
 
                 JSONArray jsonArray = resp.getBody();
-                if (jsonArray != null)
+                if (jsonArray != null) {
                     return JsonObjectHelper.phrasePointData(jsonArray, pointid);
-                else {
+                } else {
                     return ErrorRequest.RequestListError(pointid);
                 }
             } catch (HttpClientErrorException exception) {
@@ -1187,7 +1237,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(pointid);
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -1214,12 +1264,13 @@ public class EdosUtil implements IEdosUtil {
 
             //通过时间区间和时间间隔获取点数
             Long finalInterval;
-            if (pried != null)
+            if (pried != null) {
                 finalInterval = pried;
-            else if (count != null)
+            } else if (count != null) {
                 finalInterval = (endDate - beginDate) / count;
-            else
+            } else {
                 return ErrorRequest.RequestListError(point.getNemCode());
+            }
             Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
 
             try {
@@ -1230,28 +1281,34 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL + "/history/stat?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                else {
-                    if (thingType.isPresent())
+                } else {
+                    if (thingType.isPresent()) {
                         url = url + "&thingType=" + thingType.get();
-                    if (thingId.isPresent())
+                    }
+                    if (thingId.isPresent()) {
                         url = url + "&thingId=" + thingId.get();
-                    if (uniformCode.isPresent())
+                    }
+                    if (uniformCode.isPresent()) {
                         url = url + "&uniformCodes=" + uniformCode.get();
+                    }
                 }
-                if (startTs.isPresent())
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
-                if (interval.isPresent())
+                }
+                if (interval.isPresent()) {
                     url = url + "&interval=" + interval.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
                 JSONArray jsonArray = resp.getBody();
-                if (jsonArray != null)
+                if (jsonArray != null) {
                     return JsonObjectHelper.GeneralTsDataToPointDataByStat(jsonArray, point.getNemCode(), type);
-                else {
+                } else {
                     return ErrorRequest.RequestListError(point.getNemCode());
                 }
             } catch (HttpClientErrorException exception) {
@@ -1268,7 +1325,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -1288,12 +1345,13 @@ public class EdosUtil implements IEdosUtil {
             Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
             //通过时间区间和时间间隔获取点数
             Long finalInterval;
-            if (pried != null)
+            if (pried != null) {
                 finalInterval = pried;
-            else if (count != null)
+            } else if (count != null) {
                 finalInterval = (endDate - beginDate) / count;
-            else
+            } else {
                 return ErrorRequest.RequestListError(point.getNemCode());
+            }
             Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
 
             try {
@@ -1302,28 +1360,34 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL2 + "/history/stat?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                else {
-                    if (thingType.isPresent())
+                } else {
+                    if (thingType.isPresent()) {
                         url = url + "&thingType=" + thingType.get();
-                    if (thingId.isPresent())
+                    }
+                    if (thingId.isPresent()) {
                         url = url + "&thingId=" + thingId.get();
-                    if (uniformCode.isPresent())
+                    }
+                    if (uniformCode.isPresent()) {
                         url = url + "&uniformCodes=" + uniformCode.get();
+                    }
                 }
-                if (startTs.isPresent())
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
-                if (interval.isPresent())
+                }
+                if (interval.isPresent()) {
                     url = url + "&interval=" + interval.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
                 JSONArray jsonArray = resp.getBody();
-                if (jsonArray != null)
+                if (jsonArray != null) {
                     return JsonObjectHelper.GeneralTsDataToPointDataByStat(jsonArray, point.getNemCode(), type);
-                else {
+                } else {
                     return ErrorRequest.RequestListError(point.getNemCode());
                 }
             } catch (HttpClientErrorException exception) {
@@ -1340,7 +1404,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(point.getNemCode());
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -1358,12 +1422,13 @@ public class EdosUtil implements IEdosUtil {
             Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
             //通过时间区间和时间间隔获取点数
             Long finalInterval;
-            if (count != null)
+            if (count != null) {
                 finalInterval = (endDate - beginDate) / count;
-            else if (pried != null)
+            } else if (pried != null) {
                 finalInterval = pried;
-            else
+            } else {
                 return null;
+            }
             Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
             try {
                 String url = baseURL + "/history/stat?null=0";
@@ -1371,20 +1436,24 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL2 + "/history/stat?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                if (startTs.isPresent())
+                }
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
-                if (interval.isPresent())
+                }
+                if (interval.isPresent()) {
                     url = url + "&interval=" + interval.get();
+                }
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
                 JSONArray jsonArray = resp.getBody();
-                if (jsonArray != null)
+                if (jsonArray != null) {
                     return JsonObjectHelper.GeneralTsDataToPointDataByStat(jsonArray, pointid, type);
-                else {
+                } else {
                     return ErrorRequest.RequestListError(pointid);
                 }
             } catch (HttpClientErrorException exception) {
@@ -1402,7 +1471,7 @@ public class EdosUtil implements IEdosUtil {
             PointData po=new PointData();
             po.setEdnaId(pointid);
             po.setPointValueInDouble(0.0);
-            po.setPointTime(0l);
+            po.setPointTime(0L);
             pols.add(po);
             return pols;
         }
@@ -1427,14 +1496,18 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL2 + "/history/stat?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
-                if (startTs.isPresent())
+                }
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
-                if (interval.isPresent())
+                }
+                if (interval.isPresent()) {
                     url = url + "&interval=" + interval.get();
+                }
 
                 ////System.out.println(restTemplate.getForEntity(url, JSONArray.class));
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
@@ -1650,8 +1723,9 @@ public class EdosUtil implements IEdosUtil {
                     throw exception;
                 }
             }
-        } else
+        } else {
             return;
+        }
     }
 
 
@@ -1772,7 +1846,7 @@ public class EdosUtil implements IEdosUtil {
             Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
 
             //通过时间区间和时间间隔获取点数
-            Long finalInterval=60l;
+            Long finalInterval= 60L;
 
             Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
 
@@ -1782,15 +1856,19 @@ public class EdosUtil implements IEdosUtil {
                     url = baseURL2 + "/history/snap?null=0";
                 }
                 //tagName 或thingType,thingId,uniformCode可以确定一个标签点
-                if (tagName.isPresent())
+                if (tagName.isPresent()) {
                     url = url + "&tagName=" + tagName.get();
+                }
 
-                if (startTs.isPresent())
+                if (startTs.isPresent()) {
                     url = url + "&startTs=" + startTs.get();
-                if (endTs.isPresent())
+                }
+                if (endTs.isPresent()) {
                     url = url + "&endTs=" + endTs.get();
-                if (interval.isPresent())
+                }
+                if (interval.isPresent()) {
                     url = url + "&interval=60" ;
+                }
 
 
                 ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);

+ 1 - 1
alarm-scanner/pom.xml

@@ -206,7 +206,7 @@
         <dependency>
             <groupId>com.taosdata.jdbc</groupId>
             <artifactId>taos-jdbcdriver</artifactId>
-            <version>3.2.2</version>
+            <version>3.3.0</version>
         </dependency>
 
     </dependencies>

+ 16 - 31
alarm-scanner/src/main/java/com/gyee/alarm/config/ThreadPoolTaskConfig.java

@@ -1,14 +1,11 @@
 package com.gyee.alarm.config;
 
-import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
 import java.util.concurrent.ThreadPoolExecutor;
 
 @Configuration
-
 public class ThreadPoolTaskConfig {
     /**
      *   默认情况下,在创建了线程池后,线程池中的线程数为0,当有任务来之后,就会创建一个线程去执行任务,
@@ -16,44 +13,31 @@ public class ThreadPoolTaskConfig {
      *  当队列满了,就继续创建线程,当线程数量大于等于maxPoolSize后,开始使用拒绝策略拒绝
      */
 
-    /**
-     * 核心线程数(默认线程数)
-     */
-    private static final int corePoolSize = 40;
-    /**
-     * 最大线程数
-     */
-    private static final int maxPoolSize = 100;
-    /**
-     * 允许线程空闲时间(单位:默认为秒)
-     */
+    /** 核心线程数(默认线程数) */
+    private static final int corePoolSize =30;
+    /** 最大线程数 */
+    private static final int maxPoolSize = 120;
+    /** 允许线程空闲时间(单位:默认为秒) */
     private static final int keepAliveTime = 60;
-    /**
-     * 缓冲队列大小
-     */
-    private static final int queueCapacity = 300;
-    /**
-     * 允许等待最长时间
-     */
-    private static final int awaitTime = 15;
-    /**
-     * 线程池名前缀
-     */
-    private static final String threadNamePrefix = "Alarm-Thread-";
+    /** 缓冲队列大小 */
+    private static final int queueCapacity = 360;
+    /** 允许等待最长时间 */
+    private static final int awaitTime = 30;
+    /** 线程池名前缀 */
+    private static final String threadNamePrefix = "GYEE-Thread-";
 
     private ThreadPoolTaskExecutor executor;
 
-    public ThreadPoolTaskExecutor getExecutor() {
-        if (executor == null) {
+    public ThreadPoolTaskExecutor getExecutor(){
+        if (executor == null)
+        {
             executor = taskExecutor();
         }
-
         return executor;
     }
 
 
-    @Bean("taskExecutor")
-    public ThreadPoolTaskExecutor taskExecutor() {
+    private ThreadPoolTaskExecutor taskExecutor(){
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(corePoolSize);
         executor.setMaxPoolSize(maxPoolSize);
@@ -69,4 +53,5 @@ public class ThreadPoolTaskConfig {
         executor.initialize();
         return executor;
     }
+
 }

+ 3 - 3
alarm-scanner/src/main/java/com/gyee/alarm/service/AlarmScannerService.java

@@ -172,8 +172,8 @@ public class AlarmScannerService {
                 executor.execute(new AlarmThread(executor, edosUtil, alarmService, alarmTags, interval, String.valueOf(1), readRows, alarmType, countDownLatch, alarmTsService, historymap));
                 executor.execute(new AlarmThread(executor, edosUtil, alarmService, alarmInTags, interval, String.valueOf(2), readRows, alarmType, countDownLatch, alarmTsService, historymap));
 
-//                countDownLatch.await(30, TimeUnit.SECONDS);
-                countDownLatch.await();
+                countDownLatch.await(30, TimeUnit.SECONDS);
+//                countDownLatch.await();
             } else {
 
 
@@ -208,8 +208,8 @@ public class AlarmScannerService {
 
 //                    new Thread(new AlarmThread(executor, edosUtil, alarmService, alarmls, interval, String.valueOf(len), readRows, alarmType, countDownLatch, alarmTsService, historymap)).start();
                 }
+                countDownLatch.await(30, TimeUnit.SECONDS);
 //                countDownLatch.await(30, TimeUnit.SECONDS);
-                countDownLatch.await();
             }
 
 

+ 4 - 4
alarm-service/src/main/java/com/gyee/alarm/config/GeneratorCodeConfig.java

@@ -39,8 +39,8 @@ public class GeneratorCodeConfig {
         // 全局配置
         GlobalConfig gc = new GlobalConfig();
         String projectPath = System.getProperty("user.dir");
-        gc.setOutputDir(projectPath+"/alarmXK"+ "/src/main/java");
-        gc.setAuthor("xieshengjie");
+        gc.setOutputDir(projectPath+"/alarm-service"+ "/src/main/java");
+        gc.setAuthor("shilin");
         gc.setOpen(false);
         //实体属性 Swagger2 注解
         gc.setSwagger2(false);
@@ -61,7 +61,7 @@ public class GeneratorCodeConfig {
         dsc.setDriverName("org.postgresql.Driver");
         dsc.setUsername("postgres");
         dsc.setPassword("gd123");
-        dsc.setUrl("jdbc:postgresql://127.0.0.1:5432/sd20230309");
+        dsc.setUrl("jdbc:postgresql://127.0.0.1:5432/IMS_NEM_JN");
 //        dsc.setDriverName("org.postgresql.Driver");
 //        dsc.setUsername("postgres");
 //        dsc.setPassword("postgres");
@@ -76,7 +76,7 @@ public class GeneratorCodeConfig {
         // 包配置
         PackageConfig pc = new PackageConfig();
 //        pc.setModuleName(scanner("模块名"));
-        pc.setParent("com.gyee.generation");
+        pc.setParent("com.gyee.alarm");
         pc.setEntity("model.auto");
         pc.setMapper("mapper.auto");
         pc.setService("service.auto");

+ 20 - 0
alarm-service/src/main/java/com/gyee/alarm/controller/ProEconAlarmPlanController.java

@@ -0,0 +1,20 @@
+package com.gyee.alarm.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@RestController
+@RequestMapping("//pro-econ-alarm-plan")
+public class ProEconAlarmPlanController {
+
+}

+ 20 - 0
alarm-service/src/main/java/com/gyee/alarm/controller/ProEconAlarmRealController.java

@@ -0,0 +1,20 @@
+package com.gyee.alarm.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@RestController
+@RequestMapping("//pro-econ-alarm-real")
+public class ProEconAlarmRealController {
+
+}

+ 16 - 0
alarm-service/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmPlanMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.alarm.mapper.auto;
+
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+public interface ProEconAlarmPlanMapper extends BaseMapper<ProEconAlarmPlan> {
+
+}

+ 16 - 0
alarm-service/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRealMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.alarm.mapper.auto;
+
+import com.gyee.alarm.model.auto.ProEconAlarmReal;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+public interface ProEconAlarmRealMapper extends BaseMapper<ProEconAlarmReal> {
+
+}

+ 47 - 0
alarm-service/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmPlan.java

@@ -0,0 +1,47 @@
+package com.gyee.alarm.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconAlarmPlan extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private String id;
+
+    /**
+     * 类型
+     */
+    private String types;
+
+    /**
+     * 排查方法
+     */
+    private String troubleMethod;
+
+    /**
+     * 处理方法
+     */
+    private String processMethod;
+
+    /**
+     * 工器具
+     */
+    private String tools;
+
+
+}

+ 37 - 0
alarm-service/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmReal.java

@@ -0,0 +1,37 @@
+package com.gyee.alarm.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconAlarmReal extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private String id;
+
+    /**
+     * 预警编号
+     */
+    private String alarmId;
+
+    /**
+     * 排查方法
+     */
+    private String alarmPlan;
+
+
+}

+ 14 - 14
alarm-service/src/main/java/com/gyee/alarm/service/AlarmBtService.java

@@ -78,20 +78,20 @@ public class AlarmBtService {
                         vo.getName(),
                         vo.getNemCode(),vo.getFaultCause(),vo.getResolvent(),vo.getFaultType(),vo.getAname());
 
-                alarmTsService.updateTable(vo.getTbName(), vo.getAlarmid(), vo.getAlarmtype(),
-                        vo.getCharacteristic(), vo.getComponents(),
-                        vo.getDescription(),
-                        vo.getDeviceid(), vo.getDevicename(),
-                        vo.getDevicetype(), vo.getEnabled(),
-                        vo.getLineid(), vo.getLinename(),
-                        vo.getModelId(), vo.getProjectid(),
-                        vo.getProjectname(), vo.getRank(),
-                        vo.getResettable(), vo.getStationid(),
-                        vo.getStationname(), vo.getSubcomponents(),
-                        vo.getSuffix(), vo.getTagid(),
-                        vo.getTriggertype(), vo.getUniformcode(), vo.getSuperTableName(),
-                        vo.getName(),
-                        vo.getNemCode(),vo.getFaultCause(),vo.getResolvent(),vo.getFaultType(),vo.getAname());
+//                alarmTsService.updateTable(vo.getTbName(), vo.getAlarmid(), vo.getAlarmtype(),
+//                        vo.getCharacteristic(), vo.getComponents(),
+//                        vo.getDescription(),
+//                        vo.getDeviceid(), vo.getDevicename(),
+//                        vo.getDevicetype(), vo.getEnabled(),
+//                        vo.getLineid(), vo.getLinename(),
+//                        vo.getModelId(), vo.getProjectid(),
+//                        vo.getProjectname(), vo.getRank(),
+//                        vo.getResettable(), vo.getStationid(),
+//                        vo.getStationname(), vo.getSubcomponents(),
+//                        vo.getSuffix(), vo.getTagid(),
+//                        vo.getTriggertype(), vo.getUniformcode(), vo.getSuperTableName(),
+//                        vo.getName(),
+//                        vo.getNemCode(),vo.getFaultCause(),vo.getResolvent(),vo.getFaultType(),vo.getAname());
 
             }
         }

+ 16 - 0
alarm-service/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmPlanService.java

@@ -0,0 +1,16 @@
+package com.gyee.alarm.service.auto;
+
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+public interface IProEconAlarmPlanService extends IService<ProEconAlarmPlan> {
+
+}

+ 16 - 0
alarm-service/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmRealService.java

@@ -0,0 +1,16 @@
+package com.gyee.alarm.service.auto;
+
+import com.gyee.alarm.model.auto.ProEconAlarmReal;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+public interface IProEconAlarmRealService extends IService<ProEconAlarmReal> {
+
+}

+ 20 - 0
alarm-service/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmPlanServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.alarm.service.auto.impl;
+
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.gyee.alarm.mapper.auto.ProEconAlarmPlanMapper;
+import com.gyee.alarm.service.auto.IProEconAlarmPlanService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@Service
+public class ProEconAlarmPlanServiceImpl extends ServiceImpl<ProEconAlarmPlanMapper, ProEconAlarmPlan> implements IProEconAlarmPlanService {
+
+}

+ 20 - 0
alarm-service/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmRealServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.alarm.service.auto.impl;
+
+import com.gyee.alarm.model.auto.ProEconAlarmReal;
+import com.gyee.alarm.mapper.auto.ProEconAlarmRealMapper;
+import com.gyee.alarm.service.auto.IProEconAlarmRealService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@Service
+public class ProEconAlarmRealServiceImpl extends ServiceImpl<ProEconAlarmRealMapper, ProEconAlarmReal> implements IProEconAlarmRealService {
+
+}

+ 6 - 1
alarm-web/pom.xml

@@ -156,10 +156,15 @@
             <version>3.17</version>
         </dependency>
 
+<!--        <dependency>-->
+<!--            <groupId>com.taosdata.jdbc</groupId>-->
+<!--            <artifactId>taos-jdbcdriver</artifactId>-->
+<!--            <version>3.3.0</version>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>com.taosdata.jdbc</groupId>
             <artifactId>taos-jdbcdriver</artifactId>
-            <version>3.2.2</version>
+            <version>2.0.35</version>
         </dependency>
         <!-- 工具类相关 -->
         <dependency>

+ 2 - 2
alarm-web/src/main/java/com/gyee/alarm/config/GeneratorCodeConfig.java

@@ -39,7 +39,7 @@ public class GeneratorCodeConfig {
         // 全局配置
         GlobalConfig gc = new GlobalConfig();
         String projectPath = System.getProperty("user.dir");
-        gc.setOutputDir(projectPath+"/alarm-web"+ "/src/main/java");
+        gc.setOutputDir(projectPath+"/alarm-service"+ "/src/main/java");
         gc.setAuthor("shilin");
         gc.setOpen(false);
         //实体属性 Swagger2 注解
@@ -61,7 +61,7 @@ public class GeneratorCodeConfig {
         dsc.setDriverName("org.postgresql.Driver");
         dsc.setUsername("postgres");
         dsc.setPassword("gd123");
-        dsc.setUrl("jdbc:postgresql://10.81.3.151:5432/IMS_NEM_JN");
+        dsc.setUrl("jdbc:postgresql://127.0.0.1:5432/IMS_NEM_JN");
 //        dsc.setDriverName("org.postgresql.Driver");
 //        dsc.setUsername("postgres");
 //        dsc.setPassword("postgres");

+ 3 - 3
alarm-web/src/main/java/com/gyee/alarm/config/ThreadPoolTaskConfig.java

@@ -14,13 +14,13 @@ public class ThreadPoolTaskConfig {
      */
 
     /** 核心线程数(默认线程数) */
-    private static final int corePoolSize =100;
+    private static final int corePoolSize =120;
     /** 最大线程数 */
-    private static final int maxPoolSize = 240;
+    private static final int maxPoolSize = 360;
     /** 允许线程空闲时间(单位:默认为秒) */
     private static final int keepAliveTime = 60;
     /** 缓冲队列大小 */
-    private static final int queueCapacity = 100;
+    private static final int queueCapacity = 240;
     /** 允许等待最长时间 */
     private static final int awaitTime = 30;
     /** 线程池名前缀 */

+ 11 - 11
alarm-web/src/main/java/com/gyee/alarm/controller/AlarmConfigurationController.java

@@ -209,7 +209,7 @@ public class AlarmConfigurationController {
             for (ProEconAlarmConfiguration alertrule : list) {
                 String msg = "";
                 boolean result = true;
-                if (StringUtils.isBlank(alertrule.getDescription())) {
+                if (StringUtils.empty(alertrule.getDescription())) {
                     msg = "报警名称不能为空";
                     result = false;
                 }else if (StringUtils.empty(alertrule.getTriggerType())) {
@@ -218,7 +218,7 @@ public class AlarmConfigurationController {
                 } else if (StringUtils.empty(alertrule.getResetTable())) {
                     msg = "是否可以复位不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getDeviceId())) {
+                } else if (StringUtils.empty(alertrule.getDeviceId())) {
                     msg = "设备不能为空";
                     result = false;
                 } else if (alertrule.getEnable()) {
@@ -227,24 +227,24 @@ public class AlarmConfigurationController {
                 } else if (StringUtils.empty(alertrule.getRank())) {
                     msg = "报警级别不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getStationId())) {
+                } else if (StringUtils.empty(alertrule.getStationId())) {
                     msg = "风场不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getAlarmType())) {
+                } else if (StringUtils.empty(alertrule.getAlarmType())) {
                     msg = "报警类别不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getDeviceType())) {
+                } else if (StringUtils.empty(alertrule.getDeviceType())) {
                     msg = "报警设备类型不能为空";
                     result = false;
-                }else if (StringUtils.isBlank(alertrule.getUniformCode())) {
+                }else if (StringUtils.empty(alertrule.getUniformCode())) {
                     msg = "统一编码不能为空";
                     result = false;
-                }else if (StringUtils.isBlank(alertrule.getCharacteristic())) {
+                }else if (StringUtils.empty(alertrule.getCharacteristic())) {
                     msg = "特性不能为空";
                     result = false;
                 }
-                if (alertrule.getComponents().equals(AlarmTypeValue.WT.getCode())) {
-                    if (StringUtils.isBlank(alertrule.getModelId())) {
+                if (StringUtils.notEmp(alertrule.getAlarmType()) && alertrule.getAlarmType().equals(AlarmTypeValue.WT.getCode())) {
+                    if (StringUtils.empty(alertrule.getModelId())) {
                         msg = "风机型号不能为空";
                         result = false;
                     }
@@ -252,8 +252,8 @@ public class AlarmConfigurationController {
                         msg = "关联部件不能为空";
                         result = false;
                     }
-                }else  if (alertrule.getComponents().equals(AlarmTypeValue.BT.getCode())) {
-                    if (StringUtils.isBlank(alertrule.getTagId())) {
+                }else  if (StringUtils.notEmp(alertrule.getAlarmType()) && alertrule.getAlarmType().equals(AlarmTypeValue.BT.getCode())) {
+                    if (StringUtils.empty(alertrule.getTagId())) {
                         msg = "测点不能为空";
                         result = false;
                     }

+ 72 - 0
alarm-web/src/main/java/com/gyee/alarm/controller/AlarmHistoryController.java

@@ -398,6 +398,78 @@ public class AlarmHistoryController {
 
     }
 
+
+
+    @GetMapping(value = "/history/findCtFeatureStatByWtId")
+    @ApiOperation(value = "查询自定义报警类型、报警时长、报警次数", notes = "查询报警类型、报警时长、报警次数")
+    @ApiImplicitParams({
+
+            @ApiImplicitParam(name = "begin", value = "开始时间", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "end", value = "结束时间", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "deviceid", value = "设备编号", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "modelId", value = "型号编号", required = false, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "components", value = "部件集合", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "deviceType", value = "报警类型 booststation:升压站报警,windturbine:设备报警,inverter:光伏", required = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "alarmIds", value = "报警编号集合", required = false, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "timeType", value = "秒、分、时(s,m,h)", required = false, dataType = "string", paramType = "query")
+    })
+    public List<Map.Entry<String, List<AlarmStatVo>>> findCtFeatureStatByWtId(
+
+            @RequestParam(value = "begin", required = true) String begin,
+            @RequestParam(value = "end", required = true) String end,
+            @RequestParam(value = "deviceid", required = true) String wtId,
+            @RequestParam(value = "modelId", required = false) String modelId,
+            @RequestParam(value = "components", required = false) String components,
+            @RequestParam(value = "deviceType", required = false) String deviceType,
+            @RequestParam(value = "alarmIds", required = false) String alarmIds,
+            @RequestParam(value = "timeType", required = false) String timeType
+    ) throws ParseException {
+
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date dtStart = sdf.parse(begin);
+        Date dtEnd = sdf.parse(end);
+
+        if(StringUtils.empty(modelId))
+        {
+            modelId=null;
+        }
+        List<AlarmStatVo> pressureList = alarmHistoryService.findCtFeatureStatByWtId(wtId,modelId, dtStart, dtEnd,components,deviceType,alarmIds,timeType);
+
+//
+//        Map<String, List<AlarmStatVo>> map=new TreeMap<>();
+//
+//        for(AlarmStatVo vo:pressureList)
+//        {
+//            if(map.containsKey(vo.getRelateParts()))
+//            {
+//                List<AlarmStatVo>
+//            }
+//        }
+        //根据风机编号分组
+        Map<String, List<AlarmStatVo>> alarmStatMapGroupbyWindturbineId = pressureList.stream().collect(Collectors.groupingBy(AlarmStatVo::getStationId));
+
+        Map<String, List<AlarmStatVo>> resultMap = new TreeMap<>();
+
+        for (Map.Entry<String, List<AlarmStatVo>> entry : alarmStatMapGroupbyWindturbineId.entrySet()) {
+            String wpId = entry.getKey();
+            resultMap.put(wpId, entry.getValue());
+        }
+
+        //根据风机编号进行排序
+        List<Map.Entry<String, List<AlarmStatVo>>> list = new ArrayList<>(resultMap.entrySet());
+        Collections.sort(list, new Comparator<Map.Entry<String, List<AlarmStatVo>>>() {
+            @Override
+            public int compare(Map.Entry<String, List<AlarmStatVo>> o1, Map.Entry<String, List<AlarmStatVo>> o2) {
+                String key1=o1.getKey();
+                String key2=o1.getKey();
+                return key1.compareTo(key2);
+            }
+        });
+
+        return list;
+
+    }
 }
 
 

+ 49 - 15
alarm-web/src/main/java/com/gyee/alarm/controller/AlertRuleController.java

@@ -9,6 +9,8 @@ import com.gyee.alarm.model.vo.*;
 import com.gyee.alarm.service.AlarmRuleService;
 
 import com.gyee.alarm.service.TokenService;
+import com.gyee.alarm.service.auto.IProEconAlarmPlanService;
+import com.gyee.alarm.service.auto.IProEconAlarmRealService;
 import com.gyee.alarm.service.auto.IProEconAlarmTypeService;
 import com.gyee.alarm.util.ExcelUtils;
 import com.gyee.alarm.util.SnowflakeGenerator;
@@ -50,9 +52,32 @@ public class AlertRuleController {
     @Resource
     private IProEconAlarmTypeService proEconAlarmTypeService;
 
+
+    @Resource
+    private IProEconAlarmPlanService proEconAlarmPlanService;
+
+    @Resource
+    private IProEconAlarmRealService proEconAlarmRealService;
+
     @Resource
     private TokenService tokenService;
 
+
+
+    @GetMapping(value = "/alarmPlanlist")
+    @ApiOperation(value = "预警解决方案列表", notes = "预警解决方案列表")
+    public AjaxResult queryAlarmPlanlist() {
+        List<ProEconAlarmPlan> alertrules = proEconAlarmPlanService.list();
+        if (StringUtils.notEmp(alertrules)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, alertrules);
+        } else {
+            return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
+        }
+    }
+
+
+
     @GetMapping(value = "/querywtalarmdesclist")
     @ApiOperation(value = "通过场站、型号和部件查询报警描述信息", notes = "通过场站、型号和部件查询报警描述信息")
     @ApiImplicitParams({
@@ -330,6 +355,9 @@ public class AlertRuleController {
 
     @GetMapping(value = "/querysubpointllist")
     @ApiOperation(value = "获得升压站主键获得测点信息", notes = "获得升压站主键获得测点信息")
+    @ApiImplicitParams({
+
+            @ApiImplicitParam(name = "subId", value = "升压站编号", required = true, dataType = "string", paramType = "query")})
     public AjaxResult querySubPointlList(String subId) {
 
         Map<String, List<ProBasicPowerstationPoint>> map = new HashMap<>();
@@ -410,8 +438,11 @@ public class AlertRuleController {
 
         if (StringUtils.notEmp(alarmRule)) {
 
+
             int result = alarmRuleService.saveAndUpdateAlertrule(alarmRule);
 
+
+
             return AjaxResult.successData(AjaxStatus.success.code, result);
         } else {
             return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
@@ -429,6 +460,9 @@ public class AlertRuleController {
 
         int i = alarmRuleService.deleteAlertrule(id);
 
+
+
+
         if (StringUtils.notEmp(i)) {
             return AjaxResult.successData(AjaxStatus.success.code, i);
         } else {
@@ -488,30 +522,30 @@ public class AlertRuleController {
         for (ProEconAlarmRule alertrule : lst) {
             String msg = "";
             boolean result = true;
-            if (StringUtils.isBlank(alertrule.getName())) {
+            if (StringUtils.empty(alertrule.getName())) {
                 msg = "报警名称不能为空";
                 result = false;
-            } else if (StringUtils.isBlank(alertrule.getDescription())) {
+            } else if (StringUtils.empty(alertrule.getDescription())) {
                 msg = "规则描述不能为空";
                 result = false;
-            } else if (StringUtils.isBlank(alertrule.getExpression())) {
+            } else if (StringUtils.empty(alertrule.getExpression())) {
                 msg = "报警规则不能为空";
                 result = false;
             } else if (StringUtils.empty(alertrule.getRank())) {
                 msg = "报警级别不能为空";
                 result = false;
-            } else if (StringUtils.isBlank(alertrule.getStationId())) {
+            } else if (StringUtils.empty(alertrule.getStationId())) {
                 msg = "风场不能为空";
                 result = false;
-            } else if (StringUtils.isBlank(alertrule.getCategory())) {
+            } else if (StringUtils.empty(alertrule.getCategory())) {
                 msg = "报警类别不能为空";
                 result = false;
-            } else if (StringUtils.isBlank(alertrule.getUniformCode())) {
+            } else if (StringUtils.empty(alertrule.getUniformCode())) {
                 msg = "统一编码不能为空";
                 result = false;
             }
             if (alertrule.getCategory().equals(AlarmCustomType.WT.getCode())) {
-                if (StringUtils.isBlank(alertrule.getModelId())) {
+                if (StringUtils.empty(alertrule.getModelId())) {
                     msg = "风机型号不能为空";
                     result = false;
                 }
@@ -583,30 +617,30 @@ public class AlertRuleController {
             for (ProEconAlarmRule alertrule : list) {
                 String msg = "";
                 boolean result = true;
-                if (StringUtils.isBlank(alertrule.getName())) {
+                if (StringUtils.empty(alertrule.getName())) {
                     msg = "报警名称不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getDescription())) {
+                } else if (StringUtils.empty(alertrule.getDescription())) {
                     msg = "规则描述不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getExpression())) {
+                } else if (StringUtils.empty(alertrule.getExpression())) {
                     msg = "报警规则不能为空";
                     result = false;
                 } else if (StringUtils.empty(alertrule.getRank())) {
                     msg = "报警级别不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getStationId())) {
+                } else if (StringUtils.empty(alertrule.getStationId())) {
                     msg = "风场不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getCategory())) {
+                } else if (StringUtils.empty(alertrule.getCategory())) {
                     msg = "报警类别不能为空";
                     result = false;
-                } else if (StringUtils.isBlank(alertrule.getUniformCode())) {
+                } else if (StringUtils.empty(alertrule.getUniformCode())) {
                     msg = "统一编码不能为空";
                     result = false;
                 }
-                if (alertrule.getCategory().equals(AlarmCustomType.WT.getCode())) {
-                    if (StringUtils.isBlank(alertrule.getModelId())) {
+                if (StringUtils.notEmp(alertrule.getCategory()) && alertrule.getCategory().equals(AlarmCustomType.WT.getCode())) {
+                    if (StringUtils.empty(alertrule.getModelId())) {
                         msg = "风机型号不能为空";
                         result = false;
                     }

+ 6 - 6
alarm-web/src/main/java/com/gyee/alarm/controller/InfoController.java

@@ -104,8 +104,8 @@ public class InfoController {
 
         List<ProBasicEquipmentPoint> lst = new ArrayList<>();
         if (StringUtils.isNotBlank(stationId) && StringUtils.isNotBlank(modelId)) {
-            String stationStr = stationId.replace("_FDC", "").replace("_GDC", "").trim();
-            lst = proBasicEquipmentPointService.selectByStationAndModel(stationStr, modelId);
+//            String stationStr = stationId.replace("_FDC", "").replace("_GDC", "").trim();
+            lst = proBasicEquipmentPointService.selectByStationAndModel(stationId, modelId);
         }
         return lst;
     }
@@ -118,10 +118,10 @@ public class InfoController {
     ) {
         List<ProBasicEquipmentPoint> lst = new ArrayList<>();
         if (StringUtils.isNotBlank(stationId) || StringUtils.isNotBlank(modelId)) {
-            String stationStr = "";
-            if (StringUtils.isNotBlank(stationId))
-                stationStr = stationId.replace("_FDC", "").replace("_GDC", "").trim();
-            lst = proBasicEquipmentPointService.selectByStationAndModel(stationStr, modelId);
+
+            lst = proBasicEquipmentPointService.selectByStationAndModel(stationId, modelId);
+
+
         }
         return lst;
 

+ 83 - 8
alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicDeviceController.java

@@ -1,16 +1,19 @@
 package com.gyee.alarm.controller;
 
 
-import cn.hutool.poi.excel.ExcelUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.alarm.mapper.auto.ProBasicDeviceModelMetricsMapper;
 import com.gyee.alarm.model.auto.*;
 import com.gyee.alarm.model.vo.AjaxResult;
 import com.gyee.alarm.model.vo.TreeNode;
 import com.gyee.alarm.service.DeviceService;
+import com.gyee.alarm.service.auto.IProBasicDeviceModelMetricsService;
 import com.gyee.alarm.service.auto.IProBasicDeviceModelService;
 import com.gyee.alarm.service.auto.IProBasicDeviceService;
 import com.gyee.alarm.service.auto.IProBasicDeviceStructureService;
+import com.gyee.alarm.util.ExcelUtil;
+import com.gyee.alarm.util.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -19,10 +22,15 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -48,8 +56,8 @@ public class ProBasicDeviceController {
     private IProBasicDeviceStructureService proBasicDeviceStructureService;
     @Resource
     private IProBasicDeviceModelService proBasicDeviceModelService;
-
-
+    @Resource
+    private  IProBasicDeviceModelMetricsService proBasicDeviceModelMetricsService;
 
     @GetMapping(value = "/list")
     public List<ProBasicDevice> getAllDevice() {
@@ -90,7 +98,7 @@ public class ProBasicDeviceController {
     }
 
     @DeleteMapping(value = "/structure/delete/{dsId}")
-    public int deleteDeviceStructure(@PathVariable("dsId") long dsId) {
+    public int deleteDeviceStructure(@PathVariable("dsId") String dsId) {
         return deviceService.deleteDeviceStructure(dsId);
     }
 
@@ -154,15 +162,37 @@ public class ProBasicDeviceController {
     @ApiOperation(value = "分页查询标准测点")
     public IPage<ProBasicDeviceMetrics> queryByPage(Integer pageNum,Integer pageSize,String categorydata,String  keyword,String  model,String deviceId,String structureCode
     ){
-        Page<ProBasicDeviceMetrics> page =new Page(pageNum,pageSize);
 
+
+
+        Page<ProBasicDeviceMetrics> page = new Page(pageNum, pageSize);
         try {
-            return  deviceService.pageQueryAll(page,deviceId,structureCode);
+
+
+            IPage<ProBasicDeviceMetrics>  bmpage=deviceService.pageQueryAll(page,deviceId,structureCode);
+
+            if(!bmpage.getRecords().isEmpty())
+            {
+                List<ProBasicDeviceMetrics> ls=bmpage.getRecords();
+
+
+                for(ProBasicDeviceMetrics dm:ls)
+                {
+                    dm.setDeviceModelMetrics(new ArrayList());
+                    if(StringUtils.notEmp(dm.getMetricCode()))
+                    {
+                        dm.setDeviceModelMetrics(  proBasicDeviceModelMetricsService.getDeviceModelMetricsById(dm.getMetricCode()));
+                    }
+
+                }
+                return bmpage;
+            }
+
         } catch (Exception e) {
             logger.error("操作失败",e);
-            return null;
-        }
 
+        }
+        return  new Page<>();
     }
 
 
@@ -322,4 +352,49 @@ public class ProBasicDeviceController {
 
         return wrapper;
     }
+
+    @PostMapping(value ="/input")
+    @ResponseBody
+    public AjaxResult InputExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
+        if (!file.isEmpty()) {
+            try {
+                //获取原始的文件名
+                String originalFilename = file.getOriginalFilename();
+                //获取文件类型
+                String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
+                //默认从第一行开始读取
+                Integer startRows = 1;
+                //获取输入流
+                InputStream is = file.getInputStream();
+                List<ProBasicDeviceMetrics> bindingList = new ArrayList<>();
+                //List<Bookcase> bookcaseList = new ArrayList<>();
+                //Excel导入导出的单元类
+                List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
+                //遍历Excel表每一行的数据
+                for (String[] str : strings) {
+                    ProBasicDeviceMetrics deviceMetrics = new ProBasicDeviceMetrics();
+                    if(str[0]==null||str[0].length()<=0){
+                        deviceMetrics.setStructureCode("1010102");
+                    }else {
+                        deviceMetrics.setStructureCode(str[0]);
+                    }
+                    deviceMetrics.setMetricCode(str[1]);
+                    deviceMetrics.setName(str[2]);
+                    deviceMetrics.setEnname(str[3]);
+                    deviceMetrics.setUnitName(str[4]);
+                    deviceMetrics.setCategoryData(str[5]);
+                    deviceMetrics.setCategorysci(str[6]);
+                    deviceMetrics.setDescription(str[7]);
+                    bindingList.add(deviceMetrics);
+                }
+                int bookState = deviceService.insertOrUpdate(bindingList);
+                if(bookState>0){
+                    return AjaxResult.success("上传文件成功!");
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return AjaxResult.error("上传文件失败!");
+    }
 }

+ 49 - 2
alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicDeviceFaultModeController.java

@@ -1,10 +1,11 @@
 package com.gyee.alarm.controller;
 
 
-import cn.hutool.poi.excel.ExcelUtil;
+
 import com.gyee.alarm.model.auto.ProBasicDeviceFaultMode;
 import com.gyee.alarm.model.vo.AjaxResult;
 import com.gyee.alarm.service.DeviceFaultModeService;
+import com.gyee.alarm.util.ExcelUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -77,7 +78,7 @@ public class ProBasicDeviceFaultModeController {
         if (ds.getCode() == null || ds.getCode().equals("")) {
             msg = "结构编码不能为空";
             result = false;
-        } else if (ds.getDeviceid() == null || ds.getDeviceid().equals("")) {
+        } else if (ds.getDeviceId() == null || ds.getDeviceId().equals("")) {
             msg = "设备ID不能为空";
             result = false;
         } else if (ds.getName() == null || ds.getName().equals("")) {
@@ -114,4 +115,50 @@ public class ProBasicDeviceFaultModeController {
         }
         return wrapper;
     }
+
+    @PostMapping(value ="/input")
+    @ResponseBody
+    public AjaxResult InputExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
+        if (!file.isEmpty()) {
+            try {
+                //获取原始的文件名
+                String originalFilename = file.getOriginalFilename();
+                //获取文件类型
+                String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
+                //默认从第一行开始读取
+                Integer startRows = 1;
+                //获取输入流
+                InputStream is = file.getInputStream();
+                List<ProBasicDeviceFaultMode> bindingList = new ArrayList<>();
+                //List<Bookcase> bookcaseList = new ArrayList<>();
+                //Excel导入导出的单元类
+                List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
+                //遍历Excel表每一行的数据
+                for (String[] str : strings) {
+                    ProBasicDeviceFaultMode deviceFaultMode = new ProBasicDeviceFaultMode();
+                    if(str[0]==null||str[0].length()<=0){
+                        deviceFaultMode.setStructureCode("1010102");
+                    }else {
+                        deviceFaultMode.setStructureCode(str[0]);
+                    }
+                    deviceFaultMode.setName(str[1]);
+                    deviceFaultMode.setCode(str[2]);
+                    deviceFaultMode.setOccurence(Integer.parseInt(str[3]));
+                    deviceFaultMode.setSeverity(Integer.parseInt(str[4]));
+                    deviceFaultMode.setDetection(Integer.parseInt(str[5]));
+                    deviceFaultMode.setCause(str[6]);
+                    deviceFaultMode.setEffects(str[7]);
+                    deviceFaultMode.setMeasure(str[8]);
+                    bindingList.add(deviceFaultMode);
+                }
+                boolean bookState = deviceFaultModeService.insertOrUpdate(bindingList);
+                if(bookState){
+                    return AjaxResult.success("上传文件成功!");
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return AjaxResult.error("上传文件失败!");
+    }
 }

+ 330 - 0
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmPlanController.java

@@ -0,0 +1,330 @@
+package com.gyee.alarm.controller;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.gyee.alarm.model.vo.AjaxResult;
+import com.gyee.alarm.model.vo.AjaxStatus;
+import com.gyee.alarm.model.vo.AlarmCustomType;
+import com.gyee.alarm.service.auto.IProEconAlarmPlanService;
+import com.gyee.alarm.util.ExcelUtils;
+import com.gyee.alarm.util.StringUtils;
+import com.gyee.common.util.DateUtils;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@RestController
+@RequestMapping("//alarmplan")
+public class ProEconAlarmPlanController {
+
+    @Resource
+    private IProEconAlarmPlanService proEconAlarmPlanService;
+
+    @GetMapping(value = "/alarmPlanlistById")
+    @ApiOperation(value = "通过预警编号获得报警解决方案列表", notes = "通过预警编号获得报警解决方案列表")
+    public AjaxResult alarmPlanlistById(String alarmId) {
+
+        List<ProEconAlarmPlan> vos=new ArrayList<>();
+        if(StringUtils.notEmp( alarmId) )
+        {
+            vos= proEconAlarmPlanService.alarmPlanlistById(alarmId);
+        }
+
+        if (StringUtils.notEmp(vos)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, vos);
+        } else {
+            return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
+        }
+    }
+    @GetMapping(value = "/alarmPlanTypelist")
+    @ApiOperation(value = "预警解决方案分类列表", notes = "预警解决方案分类列表")
+    public AjaxResult queryAlarmPlanlist() {
+
+        List<String> namels=new ArrayList();
+        List<ProEconAlarmPlan> alertrules = proEconAlarmPlanService.list();
+
+        Map<String, List<ProEconAlarmPlan>> map = alertrules.stream()
+                .collect(Collectors.groupingBy(ProEconAlarmPlan::getTypes));
+
+        for (Map.Entry<String, List<ProEconAlarmPlan>> entry : map.entrySet()) {
+            String key = entry.getKey();
+            namels.add(key);
+        }
+        if (StringUtils.notEmp(namels)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, namels);
+        } else {
+            return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
+        }
+    }
+
+    @GetMapping(value = "/alarmPlanTypeDeallist")
+    @ApiOperation(value = "预警解决方案分类列表", notes = "预警解决方案分类列表")
+    public AjaxResult alarmPlanTypeDeallist() {
+
+        List<String> namels=new ArrayList();
+        List<ProEconAlarmPlan> alertrules = proEconAlarmPlanService.list();
+
+        Map<String, List<ProEconAlarmPlan>> map = alertrules.stream()
+                .collect(Collectors.groupingBy(ProEconAlarmPlan::getTypedetails));
+
+        for (Map.Entry<String, List<ProEconAlarmPlan>> entry : map.entrySet()) {
+            String key = entry.getKey();
+            namels.add(key);
+        }
+        if (StringUtils.notEmp(namels)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, namels);
+        } else {
+            return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
+        }
+    }
+
+    @GetMapping(value = "/queryAlarmPlanMap")
+    @ApiOperation(value = "预警解决方案分类列表", notes = "预警解决方案分类列表")
+    public AjaxResult queryAlarmPlanMap() {
+
+        List<String> namels=new ArrayList();
+        List<ProEconAlarmPlan> alertrules = proEconAlarmPlanService.list();
+
+        Map<String, List<ProEconAlarmPlan>> map = alertrules.stream()
+                .collect(Collectors.groupingBy(ProEconAlarmPlan::getTypes));
+
+
+        if (StringUtils.notEmp(map)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, map);
+        } else {
+            return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
+        }
+    }
+
+
+    //@UserLoginToken
+    @PostMapping(value = "/save")
+    @ResponseBody
+    @ApiOperation(value = "进行修改和保存", notes = "进行修改和保存")
+    public AjaxResult saveAndUpdateAlertrule(HttpServletRequest request, @RequestBody ProEconAlarmPlan alarmRule) throws Exception {
+
+
+        if (StringUtils.notEmp(alarmRule)) {
+
+
+            int result = proEconAlarmPlanService.saveAndUpdateAlertrule(alarmRule);
+
+
+            return AjaxResult.successData(AjaxStatus.success.code, result);
+        } else {
+            return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
+        }
+
+
+    }
+
+    @DeleteMapping(value = "/delete")
+    @ApiOperation(value = "删除", notes = "删除")
+    @ApiImplicitParams({
+
+            @ApiImplicitParam(name = "id", value = "自定义报警主键", required = true, dataType = "string", paramType = "query")})
+    public AjaxResult deleteAlertrule(String id) {
+        boolean i =false;
+        if(StringUtils.notEmp(id))
+        {
+            List<String> idls= Arrays.asList(id.split(","));   ;
+            i = proEconAlarmPlanService.deleteAlertrule(idls);
+        }
+
+
+
+
+
+        if (StringUtils.notEmp(i)) {
+            return AjaxResult.successData(AjaxStatus.success.code, i);
+        } else {
+            return AjaxResult.successData(AjaxStatus.error.code, "error");
+        }
+    }
+
+    //@UserLoginToken
+    @GetMapping(value = "/page")
+    @ApiOperation(value = "分页查询", notes = "分页查询")
+    @ApiImplicitParams({
+
+            @ApiImplicitParam(name = "pageNum", value = "页号", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageSize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
+
+            @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "types", value = "名称", required = false, dataType = "string", paramType = "query")
+           })
+
+    public AjaxResult queryByPage(HttpServletRequest request,
+                                  @RequestParam(value = "pageNum") Integer pageNum,
+                                  @RequestParam(value = "pageSize") Integer pageSize,
+
+                                  @RequestParam(value = "name", required = false) String name ,
+                                  @RequestParam(value = "types", required = false) String types
+    ) {
+        Page<ProEconAlarmPlan> page = new Page(pageNum, pageSize);
+
+        IPage<ProEconAlarmPlan> pageResult = proEconAlarmPlanService.pageQueryAll(page, name,types);
+
+
+        if (StringUtils.notEmp(pageResult)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, pageResult);
+        } else {
+            return AjaxResult.successData(AjaxStatus.error.code, "error");
+        }
+    }
+
+
+    //@UserLoginToken
+    @PostMapping(value = "/save-batch")
+    @ResponseBody
+    @ApiOperation(value = "批量保存", notes = "批量保存")
+    public AjaxResult saveAlertruleBatch(HttpServletRequest request, @RequestBody List<ProEconAlarmPlan> lst) throws Exception {
+
+
+        boolean allCheck = true;
+
+        for (ProEconAlarmPlan alertrule : lst) {
+            String msg = "";
+            boolean result = true;
+            if (StringUtils.isBlank(alertrule.getName())) {
+                msg = "名称不能为空";
+                result = false;
+            } else if (StringUtils.isBlank(alertrule.getSpareParts())) {
+                msg = "备件不能为空";
+                result = false;
+            } else if (StringUtils.isBlank(alertrule.getTroubleMethod())) {
+                msg = "排查步骤不能为空";
+                result = false;
+            } else if (StringUtils.empty(alertrule.getProcessMethod())) {
+                msg = "检修方案不能为空";
+                result = false;
+            } else if (StringUtils.isBlank(alertrule.getTools())) {
+                msg = "所需工具不能为空";
+                result = false;
+            }
+
+            if (result != true) {
+                allCheck = false;
+                if (!result) {
+                    return AjaxResult.successData(AjaxStatus.error.code, msg);
+                }
+            }
+        }
+        if (allCheck) {
+            for (ProEconAlarmPlan alertRule : lst) {
+                int result = proEconAlarmPlanService.saveAndUpdateAlertrule(alertRule);
+                if (result <= 0) {
+                    return AjaxResult.successData(AjaxStatus.error.code, alertRule.getName() + ":" + "操作数据库失败");
+
+                }
+            }
+            return AjaxResult.successData(AjaxStatus.success.code, "ok");
+        } else {
+            return AjaxResult.successData(AjaxStatus.error.code, "error");
+        }
+
+
+    }
+
+
+    @GetMapping("/importtemplate")
+    @ApiOperation(value = "获得导入模板")
+    public void importTemplate(HttpServletResponse response) throws IOException {
+        // 手动创建导出 demo
+
+
+        List<ProEconAlarmPlan> list = Arrays.asList(
+                ProEconAlarmPlan.builder().id("1").types("类型1").troubleMethod("排查步骤1")
+                        .processMethod("检修方案").tools("所需工具1").spareParts("备品备件1").name("名字1").typedetails("类别1")
+
+                        .build(),
+                ProEconAlarmPlan.builder().id("2").types("类型2").troubleMethod("排查步骤2")
+                        .processMethod("检修方案2").tools("所需工具2").spareParts("备品备件2").name("名字2").typedetails("类别2")
+
+                        .build()
+
+        );
+
+        // 输出
+        ExcelUtils.write(response, "导入模板.xls", "导入模板", ProEconAlarmPlan.class, list);
+    }
+
+    @PostMapping("/import")
+    @ApiOperation(value = "导入", notes = "导入")
+    public AjaxResult importExcel(@RequestParam("file") MultipartFile file) throws Exception {
+        List<ProEconAlarmPlan> list = ExcelUtils.read(file, ProEconAlarmPlan.class);
+
+        if (com.gyee.common.model.StringUtils.notEmp(list) && !list.isEmpty()) {
+            boolean allCheck = true;
+            for (ProEconAlarmPlan alertrule : list) {
+                String msg = "";
+                boolean result = true;
+                if (StringUtils.isBlank(alertrule.getTypes())) {
+                    msg = "类型不能为空";
+                    result = false;
+                } else if (StringUtils.isBlank(alertrule.getTroubleMethod())) {
+                    msg = "排查方法不能为空";
+                    result = false;
+                } else if (StringUtils.isBlank(alertrule.getProcessMethod())) {
+                    msg = "处理方法不能为空";
+                    result = false;
+                } else if (StringUtils.empty(alertrule.getTools())) {
+                    msg = "处理工具不能为空";
+                    result = false;
+                } else if (StringUtils.empty(alertrule.getName())) {
+                    msg = "名称不能为空";
+                    result = false;
+                } else if (StringUtils.empty(alertrule.getTypedetails())) {
+                    msg = "类别不能为空";
+                    result = false;
+                }
+                if (result != true) {
+                    allCheck = false;
+                    if (!result) {
+                        return AjaxResult.successData(AjaxStatus.error.code, msg);
+                    }
+                }
+
+                if (allCheck) {
+
+
+                    proEconAlarmPlanService.saveAndUpdateAlertrule(alertrule);
+                }
+
+            }
+        }
+        if (com.gyee.common.model.StringUtils.isNotNull(list)) {
+            return AjaxResult.successData(AjaxStatus.success.code, list);
+        } else {
+            return AjaxResult.successData(AjaxStatus.error.code, "error");
+        }
+
+
+    }
+
+}

+ 77 - 0
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmRealController.java

@@ -0,0 +1,77 @@
+package com.gyee.alarm.controller;
+
+
+import com.gyee.alarm.model.auto.ProBasicPowerstation;
+import com.gyee.alarm.model.auto.ProBasicSubStation;
+import com.gyee.alarm.model.vo.AjaxResult;
+import com.gyee.alarm.model.vo.AjaxStatus;
+import com.gyee.alarm.model.vo.AlarmTypeValue;
+import com.gyee.alarm.service.TokenService;
+import com.gyee.alarm.util.StringUtils;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@RestController
+@RequestMapping("///electricity")
+public class ProEconAlarmRealController {
+
+    @Resource
+    private TokenService tokenService;
+
+
+    @GetMapping(value = "/czlist")
+    @ApiOperation(value = "查询场站列表", notes = "查询场站列表")
+    public AjaxResult queryWplList(String types) {
+
+        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
+        List<ProBasicPowerstation> wpls = tokenService.getWpls(request);
+        List<ProBasicPowerstation> vos = new ArrayList<>();
+        if(!wpls.isEmpty())
+        {
+            for(ProBasicPowerstation wp:wpls)
+            {
+                if(StringUtils.notEmp(types))
+                {
+                    if(types.equals(AlarmTypeValue.WT.getCode())  && wp.getId().contains("FDC"))
+                    {
+                        vos.add(wp);
+                    }else if(types.equals(AlarmTypeValue.IN.getCode())  && wp.getId().contains("GDC"))
+                    {
+                        vos.add(wp);
+                    }else if(types.equals(AlarmTypeValue.BT.getCode()))
+                    {
+                        List<ProBasicSubStation> subwpls = tokenService.getSubwpls(request);
+                        return AjaxResult.successData(AjaxStatus.success.code, subwpls);
+                    }
+                }else
+                {
+                    vos =wpls;
+                }
+            }
+        }
+        if (StringUtils.notEmp(vos)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, vos);
+        } else {
+            return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
+        }
+    }
+
+}

File diff suppressed because it is too large
+ 38 - 10
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java


File diff suppressed because it is too large
+ 329 - 0
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper3.java


+ 3 - 3
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceFaultModeMapper.java

@@ -32,7 +32,7 @@ public interface ProBasicDeviceFaultModeMapper extends BaseMapper<ProBasicDevice
             "select * from pro_basic_device_fault_mode a ",
             "<where>",
             "<if test='deviceId !=null' >",
-            "and a.deviceid=#{deviceId}",
+            "and a.device_id=#{deviceId}",
             "</if>",
             "</where>",
 
@@ -43,7 +43,7 @@ public interface ProBasicDeviceFaultModeMapper extends BaseMapper<ProBasicDevice
             "select * from pro_basic_device_fault_mode a ",
             "<where>",
             "<if test='deviceId !=null' >",
-            "and a.deviceId=#{deviceId}",
+            "and a.device_id=#{deviceId}",
             "</if>",
             "<if test='structureCode !=null' >",
             "and   a.structure_code like '${structureCode}%'",
@@ -58,7 +58,7 @@ public interface ProBasicDeviceFaultModeMapper extends BaseMapper<ProBasicDevice
             "select * from pro_basic_device_fault_mode a ",
             "<where>",
             "<if test='deviceId !=null' >",
-            "and a.deviceId=#{deviceId}",
+            "and a.device_id=#{deviceId}",
             "</if>",
             "<if test='nodeCode !=null' >",
             "and a.code=#{nodeCode}",

+ 2 - 2
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceMetricsMapper.java

@@ -5,8 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.alarm.model.auto.ProBasicDevice;
 import com.gyee.alarm.model.auto.ProBasicDeviceMetrics;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.*;
 
 import java.util.List;
 
@@ -71,6 +70,7 @@ public interface ProBasicDeviceMetricsMapper extends BaseMapper<ProBasicDeviceMe
             "</where>",
             "order by metric_code ",
             "</script>"})
+
     IPage<ProBasicDeviceMetrics> pageQueryAll(Page page, @Param("deviceId")String deviceId, @Param("structureCode")String structureCode);
     @Select({"<script>",
             "select * from pro_basic_device_metrics a ",

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceModelMetricsMapper.java

@@ -20,7 +20,7 @@ public interface ProBasicDeviceModelMetricsMapper extends BaseMapper<ProBasicDev
             "select * from pro_basic_device_model_metrics a ",
             "<where>",
 
-            "<if test='nodeCode !=null '>",
+            "<if test='metriccode !=null '>",
             "and a.metric_code=#{metriccode}",
             "</if>",
             "</where>",

+ 78 - 0
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmPlanMapper.java

@@ -0,0 +1,78 @@
+package com.gyee.alarm.mapper.auto;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.gyee.alarm.model.auto.ProEconAlarmRule;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+public interface ProEconAlarmPlanMapper extends BaseMapper<ProEconAlarmPlan> {
+
+
+
+    @Select({"<script>",
+            "select trouble_method from pro_econ_alarm_plan ",
+            "<where>",
+            " 1=1 ",
+
+            "<if test='troubleMethod !=null  '>",
+            "and name = #{name} ",
+            "</if>",
+            "<if test='troubleMethod !=null  '>",
+            "and types = #{types} ",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmPlan> queryObject(@Param("name") String name,@Param("types") String types);
+
+
+    @Update({"<script>",
+            "update pro_econ_alarm_plan ",
+            "<set>",
+            "types = #{types},",
+            "trouble_method = #{troubleMethod},",
+            "process_method = #{processMethod},",
+            "tools = #{tools}," ,
+            "spare_parts = #{spareParts}," ,
+            "name = #{name}" ,
+            "</set>",
+            "where id = #{id}",
+
+            "</script>"})
+    Integer updateByAlertruleId(ProEconAlarmPlan alertrule);
+
+
+    @Select({"<script>",
+            "select * from pro_econ_alarm_plan ",
+            "<where>",
+            " 1=1 ",
+
+
+            "<if test='name !=null  '>",
+            "and name like #{name}",
+            "</if>",
+            "<if test='types !=null  '>",
+            "and types = #{types} ",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    IPage<ProEconAlarmPlan> pageQueryAll(Page page,
+                                         @Param("name") String name, @Param("types") String types);
+
+
+}

+ 39 - 0
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRealMapper.java

@@ -0,0 +1,39 @@
+package com.gyee.alarm.mapper.auto;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.gyee.alarm.model.auto.ProEconAlarmReal;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+public interface ProEconAlarmRealMapper extends BaseMapper<ProEconAlarmReal> {
+
+
+    @Select({"<script>",
+            "select * from pro_econ_alarm_real a",
+            "<where>",
+            " alarm_id = #{alarmId} ",
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmReal> alarmPlanlistById( @Param("alarmId") String alarmId);
+
+    @Update("update pro_econ_alarm_real   set alarm_id=#{alarmId},alarm_plan=#{alarmPlan}  where id=#{id}")
+    public int  updateProEconAlarmReal(@Param(value = "alarmId") String alarmId, @Param(value = "alarmPlan")String alarmPlan,
+                                @Param(value = "id")String id);
+
+}

+ 2 - 0
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRuleMapper.java

@@ -2,6 +2,7 @@ package com.gyee.alarm.mapper.auto;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
 import com.gyee.alarm.model.auto.ProEconAlarmRule;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.gyee.alarm.model.vo.AlarmRuleVo;
@@ -23,6 +24,7 @@ import java.util.List;
 public interface ProEconAlarmRuleMapper extends BaseMapper<ProEconAlarmRule> {
 
 
+
     @Update({"<script>",
             "update pro_econ_alarm_rule ",
             "<set>",

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/model/auto/ProBasicDeviceFaultMode.java

@@ -69,7 +69,7 @@ public class ProBasicDeviceFaultMode extends Model {
     /**
      * 设备
      */
-    private String deviceid;
+    private String deviceId;
 
     /**
      * 结构编码

+ 66 - 0
alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmPlan.java

@@ -0,0 +1,66 @@
+package com.gyee.alarm.model.auto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
+public class ProEconAlarmPlan extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    @TableId(value = "ID",type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 类型
+     */
+    private String types;
+
+    /**
+     * 排查步骤
+     */
+    private String troubleMethod;
+
+    /**
+     * 检修方案
+     */
+    private String processMethod;
+
+    /**
+     * 所需工具
+     */
+    private String tools;
+    /**
+     * 备品备件
+     */
+    private String spareParts;
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 明细分类
+     */
+    private String typedetails;
+}

+ 40 - 0
alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmReal.java

@@ -0,0 +1,40 @@
+package com.gyee.alarm.model.auto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconAlarmReal extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    @TableId(value = "ID",type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 预警编号
+     */
+    private String alarmId;
+
+    /**
+     * 排查方法
+     */
+    private String alarmPlan;
+
+
+}

+ 3 - 0
alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmRule.java

@@ -159,4 +159,7 @@ public class ProEconAlarmRule extends Model {
     private String stationName;
     @TableField(exist = false)
     private String relatedPartsName;
+
+    @TableField(exist = false)
+    private String alarmPlan;
 }

+ 23 - 13
alarm-web/src/main/java/com/gyee/alarm/service/AlarmConfigurationService.java

@@ -52,24 +52,34 @@ public class AlarmConfigurationService {
 
         if (StringUtils.notEmp(alarmRule)) {
             List<ProEconAlarmConfiguration>  oldRulels =null;
-            if(!alarmRule.getAlarmType().equals(AlarmTypeValue.BT.getCode()))
-            {
-                oldRulels = proEconAlarmConfigurationMapper.queryObject(alarmRule.getDescription(),alarmRule.getStationId(),alarmRule.getModelId());
 
-            }else
-            {
-               oldRulels = proEconAlarmConfigurationMapper.queryObject(alarmRule.getDescription(),alarmRule.getStationId(),null);
+            if (StringUtils.notEmp(alarmRule.getId())) {
+
+                if(!alarmRule.getAlarmType().equals(AlarmTypeValue.BT.getCode()))
+                {
+                    oldRulels = proEconAlarmConfigurationMapper.queryObject(alarmRule.getDescription(),alarmRule.getStationId(),alarmRule.getModelId());
+
+                }else
+                {
+                    oldRulels = proEconAlarmConfigurationMapper.queryObject(alarmRule.getDescription(),alarmRule.getStationId(),null);
+
+                }
+                if(!oldRulels.isEmpty())
+                {
+                    ProEconAlarmConfiguration oldRule2=oldRulels.get(0);
+                    alarmRule.setId(oldRule2.getId());
+                    result = proEconAlarmConfigurationService.updateById(alarmRule);
+                    ruleUpdateEventService.saveEventWarning(alarmRule,oldRule2);
+                }else
+                {
+                    result = proEconAlarmConfigurationService.updateById(alarmRule);
+//                  ruleUpdateEventService.saveEventWarning(alarmRule,null);
+                }
 
-            }
-            if (StringUtils.notEmp(oldRulels) && !oldRulels.isEmpty()) {
-                ProEconAlarmConfiguration oldRule2=oldRulels.get(0);
-                alarmRule.setId(oldRule2.getId());
-                result = proEconAlarmConfigurationService.updateById(alarmRule);
-                ruleUpdateEventService.saveEventWarning(alarmRule,oldRule2);
             }else
             {
                 alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
-                ruleUpdateEventService.saveEventWarning(alarmRule,null);
+//                ruleUpdateEventService.saveEventWarning(alarmRule,null);
                 result = saveAlertrule(alarmRule);
             }
 

+ 123 - 2
alarm-web/src/main/java/com/gyee/alarm/service/AlarmHistoryService.java

@@ -979,7 +979,128 @@ public class AlarmHistoryService   {
             StringBuilder sb=new StringBuilder();
             sb.append(fs.getStationId()).append("_").append(fs.getAlarmid());
 
-            if(map.containsKey(String.valueOf(sb)))
+            if(vomap.containsKey(String.valueOf(sb)))
+            {
+                List<AlarmStatVo> ls=vomap.get(String.valueOf(sb));
+                ls.add(d);
+            }else
+            {
+                List<AlarmStatVo> ls=new ArrayList<>();
+                ls.add(d);
+                vomap.put(String.valueOf(sb),ls);
+            }
+            resultList.add(d);
+        }
+
+
+        return resultList;
+    }
+
+
+
+    public List<AlarmStatVo> findCtFeatureStatByWtId(String wtId,String modelId, Date startTime, Date endTime,String components,String deviceType,String alarmIds,String timeType) {
+        List<AlarmStatVo> resultList = new ArrayList<>();
+
+
+        StringBuilder alarmIdList=new StringBuilder();
+        StringBuilder componentsList=new StringBuilder();
+
+        Map<String,String> alarmIdMap=new HashMap<>();
+        Map<String,String> componentsMap=new HashMap();
+
+        if(StringUtils.notEmp(components))
+        {
+            String [] componentsStr=components.split(",");
+            for(String c:componentsStr)
+            {
+                componentsList.append("'").append(c).append("',");
+                componentsMap.put(c,c);
+            }
+
+        }
+        if(StringUtils.notEmp(alarmIds))
+        {
+            String [] alarmIdStr=alarmIds.split(",");
+            for(String c:alarmIdStr)
+            {
+                alarmIdList.append("'").append(c).append("',");
+                alarmIdMap.put(c,c);
+            }
+
+        }
+        String alarmId=null;
+        String component=null;
+        if(alarmIdList.length()>0)
+        {
+            alarmId=String.valueOf(alarmIdList.substring(0,alarmIdList.length()-1));
+        }
+        if(componentsList.length()>0)
+        {
+            component=String.valueOf(componentsList.substring(0,componentsList.length()-1));
+        }
+        List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStatByWtId(startTime.getTime(), endTime.getTime(),wtId,modelId,component,alarmId,deviceType);
+
+
+        Map<String, ProBasicFeatureStat> map = new HashMap<>();
+        Date statDate=DateUtils.truncate(new Date());
+
+        if (!fsls.isEmpty()) {
+            for (ProBasicFeatureStat fs : fsls) {
+                if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
+                    ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode());
+                    fs.setTypeName(at.getName());
+                }
+                fs.setStatDate(new Timestamp(statDate.getTime()));
+                fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                StringBuilder sb = new StringBuilder();
+                sb.append(fs.getStationId()).append("_").append(fs.getAlarmid());
+                map.put(String.valueOf(sb), fs);
+            }
+        }
+
+
+
+        Map<String,List<AlarmStatVo>> vomap=new HashMap<>();
+        for(ProBasicFeatureStat fs:fsls)
+        {
+            AlarmStatVo d = new AlarmStatVo();
+            d.setRelateParts(fs.getTypeCode());
+            d.setRelatePartsText(fs.getTypeName());
+            d.setAlertText(fs.getDescription());
+            d.setCount(fs.getTotal());
+            d.setAlarmid(fs.getAlarmid());
+            if(StringUtils.notEmp(timeType))
+            {
+                if(AlarmTime.H.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(360), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    d.setTime(times);
+                }else if(AlarmTime.M.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    d.setTime(times);
+                }else
+                {
+                    d.setTime(fs.getTotalSeconds());
+                }
+            }else
+            {
+                double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                d.setTime(times);
+            }
+            d.setStationId(fs.getStationId());
+            d.setSnapId(SnowflakeGenerator.generateId());
+            d.setWindturbineId(fs.getWtId());
+            if(CacheContext.wtmap.containsKey(fs.getWtId()))
+            {
+                ProBasicEquipment  wt=CacheContext.wtmap.get(fs.getStationId());
+                d.setWindturbineCode(wt.getNemCode());
+            }
+
+            StringBuilder sb=new StringBuilder();
+            sb.append(fs.getStationId()).append("_").append(fs.getAlarmid());
+
+            if(vomap.containsKey(String.valueOf(sb)))
             {
                 List<AlarmStatVo> ls=vomap.get(String.valueOf(sb));
                 ls.add(d);
@@ -1016,7 +1137,7 @@ public class AlarmHistoryService   {
                 fs.setTypeName(CacheContext.alarmTypeMap.get(at.getRelatedParts()).getName());
             }
             fs.setAlarmid(at.getId());
-            fs.setDescription(at.getDescription());
+            fs.setDescription(at.getName());
             fs.setTotal(0l);
             fs.setAvgSeconds(0.0);
             fs.setMaxSeconds(0.0);

+ 14 - 10
alarm-web/src/main/java/com/gyee/alarm/service/AlarmRuleService.java

@@ -13,6 +13,7 @@ import com.gyee.alarm.model.auto.*;
 import com.gyee.alarm.model.vo.AlarmConfigurationVo;
 import com.gyee.alarm.model.vo.AlarmRuleVo;
 
+import com.gyee.alarm.service.auto.IProEconAlarmPlanService;
 import com.gyee.alarm.util.SnowflakeGenerator;
 import com.gyee.alarm.util.StringUtil;
 import com.gyee.alarm.util.StringUtils;
@@ -31,7 +32,8 @@ public class AlarmRuleService {
     @Resource
     private RuleUpdateEventService ruleUpdateEventService;
 
-
+    @Resource
+    private IProEconAlarmPlanService proEconAlarmPlanService;
     /**
      * 查询报警信息接口
      * @param wpId 场站不编号
@@ -153,21 +155,18 @@ public class AlarmRuleService {
 
         if (StringUtils.notEmp(alarmRule)) {
 
-            List<ProEconAlarmRule>  oldRulels = proEconAlarmRuleMapper.queryObject(alarmRule.getName(),alarmRule.getStationId(),alarmRule.getModelId());
-            if(!oldRulels.isEmpty())
+            if(StringUtils.notEmp(alarmRule.getId()))
             {
-                ProEconAlarmRule   oldRule2=oldRulels.get(0);
-                if (oldRule2 != null) {
-
+                List<ProEconAlarmRule>  oldRulels = proEconAlarmRuleMapper.queryObject(alarmRule.getName(),alarmRule.getStationId(),alarmRule.getModelId());
+                if(!oldRulels.isEmpty())
+                {
+                    ProEconAlarmRule   oldRule2=oldRulels.get(0);
                     alarmRule.setId(oldRule2.getId());
                     result = proEconAlarmRuleMapper.updateByAlertruleId(alarmRule);
                     ruleUpdateEventService.saveEventAlertRule(alarmRule,oldRule2);
                 }else
                 {
-                    alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
-                    alarmRule.setCreateTime(new Date());
-                    ruleUpdateEventService.saveEventAlertRule(alarmRule,null);
-                    result = saveAlertrule(alarmRule);
+                    result = proEconAlarmRuleMapper.updateByAlertruleId(alarmRule);
                 }
             }else
             {
@@ -176,6 +175,8 @@ public class AlarmRuleService {
                 ruleUpdateEventService.saveEventAlertRule(alarmRule,null);
                 result = saveAlertrule(alarmRule);
             }
+
+            proEconAlarmPlanService.updatePlanlistById(alarmRule.getId(), alarmRule.getAlarmPlan());
         }
 
         return result;
@@ -328,7 +329,10 @@ public class AlarmRuleService {
 
         List<ProEconAlarmRule> rules = proEconAlarmRuleMapper.getUniformCodeByNameAndStation(name, station, modelid);
         if (rules == null || rules.size() == 0)
+        {
             return null;
+        }
+
 
         ProEconAlarmRule rule = rules.get(0);
         String expression = "(([A][I])|([D][I]))([0-9]+)";

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/service/AlarmWtService.java

@@ -8,7 +8,7 @@ import com.gyee.alarm.service.auto.IProEconAlarmInfoService;
 import com.gyee.alarm.util.DateUtils;
 import com.gyee.alarm.util.StringUtils;
 
-import org.java_websocket.WebSocket;
+
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.web.context.request.RequestContextHolder;

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/service/DeviceFaultModeService.java

@@ -65,7 +65,7 @@ public class DeviceFaultModeService {
                 deviceFaultMode.setId(deviceMetrics2.getId());
                 s =  proBasicDeviceFaultModeService.updateById(deviceFaultMode);
             }else {
-                deviceFaultMode.setDeviceid("windturbine");
+                deviceFaultMode.setDeviceId("windturbine");
                 s = proBasicDeviceFaultModeService.save(deviceFaultMode);
             }
         }

+ 7 - 3
alarm-web/src/main/java/com/gyee/alarm/service/DeviceService.java

@@ -65,7 +65,11 @@ public class DeviceService {
         String modelId = "";
         ProBasicEquipment windturbine = windturbineCache.getWindturbine(windturbineId);
         if (windturbine != null)
+        {
             modelId = windturbine.getModelId();
+        }
+
+
 
         if (StringUtils.isNotBlank(structCode)) {
             List<ProBasicDeviceMetrics> metricsList = proBasicDeviceMetricsService.getDeviceMetricsByStructureCode(deviceId, structCode);
@@ -316,7 +320,7 @@ public class DeviceService {
 
     }
 
-    public int deleteDeviceStructure(long dsId) {
+    public int deleteDeviceStructure(String dsId) {
         int code = proBasicDeviceStructureMapper.deleteById(dsId);
         if (code >= 1) {
             //树结构变化清空树结构缓存
@@ -364,7 +368,7 @@ public class DeviceService {
     public int saveOrUpdateDeviceMetric(ProBasicDeviceMetrics metrics, List<ProBasicDeviceModelMetrics> deviceModelMetrics) {
 
         int result = 0;
-        if ( StringUtils.notEmp(metrics.getId())) {
+        if ( StringUtils.empty(metrics.getId())) {
             //如果id为空,则通过雪花算法 生成一个id
             metrics.setId(String.valueOf(SnowflakeGenerator.generateId()));
             result = proBasicDeviceMetricsMapper.insert(metrics);
@@ -378,7 +382,7 @@ public class DeviceService {
         }
         if (deviceModelMetrics != null && deviceModelMetrics.size() > 0) {
             for (ProBasicDeviceModelMetrics deviceModelMetrics1 : deviceModelMetrics) {
-                if (StringUtils.notEmp(deviceModelMetrics1.getId())) {
+                if (StringUtils.empty(deviceModelMetrics1.getId())) {
                     //如果id为空,则通过雪花算法 生成一个id
                     deviceModelMetrics1.setId(String.valueOf(SnowflakeGenerator.generateId()));
                     result = roBasicDeviceModelMetricsMapper.insert(deviceModelMetrics1);

+ 380 - 0
alarm-web/src/main/java/com/gyee/alarm/service/TokenNoTokenService.java

@@ -0,0 +1,380 @@
+package com.gyee.alarm.service;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.gyee.alarm.init.CacheContext;
+import com.gyee.alarm.model.auto.*;
+import com.gyee.alarm.model.vo.TokenVo;
+import com.gyee.alarm.service.auto.ISysUserService;
+import com.gyee.common.model.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Service
+public class TokenNoTokenService {
+    @Resource
+    private ISysUserService sysUserService;
+
+
+    public static Map<String, List<ProBasicEquipment>> sessionWtMap = new ConcurrentHashMap<>();
+    public static Map<String, List<ProBasicPowerstation>> sessionWpMap = new ConcurrentHashMap<>();
+    public static Map<String,  List<ProBasicSubStation> > sessionSubMap = new ConcurrentHashMap<>();
+    public static Map<String, List<ProBasicWeatherStation>> sessionWeMap = new ConcurrentHashMap<>();
+
+    public static Map<String, TokenVo> sessionMap=  new ConcurrentHashMap<>();
+
+    public  List<ProBasicEquipment>  getWtls(HttpServletRequest request ) {
+
+        String token = request.getHeader("token");
+        String userId = request.getHeader("userId");
+
+        List<ProBasicEquipment> wtlist = new ArrayList<>();
+        if (StringUtils.notEmp(token) && StringUtils.notEmp(userId))
+        {
+//            if (sessionMap.containsKey(token) && !sessionWtMap.containsKey(token)) {
+
+                List<String> depls = sysUserService.getUserByuserId(Long.valueOf(userId));
+                if (!depls.isEmpty()) {
+                    String depId = depls.get(0);
+
+                    if (CacheContext.wpwtmap.containsKey(depId)) {
+
+                        List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(depId);
+                        for(ProBasicEquipment wt:wtls)
+                        {
+                            ProBasicEquipment newWt=  new ProBasicEquipment();
+                            BeanUtil.copyProperties( wt,newWt);
+                            wtlist.add(newWt);
+                        }
+
+                    } else if (CacheContext.cmwtlsmap.containsKey(depId)) {
+
+                        List<ProBasicEquipment> wtls=CacheContext.cmwtlsmap.get(depId);
+                        for(ProBasicEquipment wt:wtls)
+                        {
+                            ProBasicEquipment newWt=  new ProBasicEquipment();
+                            BeanUtil.copyProperties( wt,newWt);
+                            wtlist.add(newWt);
+                        }
+
+                    } else if (CacheContext.rgwtlsmap.containsKey(depId)) {
+
+                        List<ProBasicEquipment> wtls=CacheContext.rgwtlsmap.get(depId);
+                        for(ProBasicEquipment wt:wtls)
+                        {
+                            ProBasicEquipment newWt=  new ProBasicEquipment();
+                            BeanUtil.copyProperties( wt,newWt);
+                            wtlist.add(newWt);
+                        }
+
+                    }else  if(depId.equals("0"))
+                    {
+                        for(ProBasicEquipment wt:CacheContext.wtls)
+                        {
+                            ProBasicEquipment newWt=  new ProBasicEquipment();
+                            BeanUtil.copyProperties( wt,newWt);
+                            wtlist.add(newWt);
+                        }
+
+                    }
+                }
+//                sessionWtMap.put(token,wtlist);
+//            } else if (sessionMap.containsKey(token) && sessionWtMap.containsKey(token))
+//            {
+//                wtlist =sessionWtMap.get(token);
+//            }
+        }else
+        {
+            for(ProBasicEquipment wt:CacheContext.wtls)
+            {
+                ProBasicEquipment newWt=  new ProBasicEquipment();
+                BeanUtil.copyProperties( wt,newWt);
+                wtlist.add(newWt);
+            }
+
+        }
+        return wtlist;
+    }
+
+    public  List<ProBasicPowerstation>  getWpls(HttpServletRequest request )
+    {
+        String token = request.getHeader("token");
+        String userId = request.getHeader("userId");
+
+        List<ProBasicPowerstation> wplist=new ArrayList<>();
+        if(StringUtils.notEmp(token)  && StringUtils.notEmp(token))
+        {
+//            if(sessionMap.containsKey(token) && !sessionWpMap.containsKey(token))
+//            {
+
+                List<String> depls= sysUserService.getUserByuserId(Long.valueOf(userId));
+                if(!depls.isEmpty())
+                {
+                    String depId=depls.get(0);
+
+                    if(CacheContext.wpmap.containsKey(depId))
+                    {
+
+                        ProBasicPowerstation wp= CacheContext.wpmap.get(depId);
+                        ProBasicPowerstation newWp=  new ProBasicPowerstation();
+                        BeanUtil.copyProperties(wp, newWp);
+                        wplist.add(newWp);
+                    }else  if(CacheContext.cpwpmap.containsKey(depId))
+                    {
+                        List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(depId);
+                        for(ProBasicPowerstation wp:wpls)
+                        {
+                            ProBasicPowerstation newWp=  new ProBasicPowerstation();
+                            BeanUtil.copyProperties(wp, newWp);
+                            wplist.add(newWp);
+                        }
+
+                    }else  if(CacheContext.rgmap.containsKey(depId))
+                    {
+                        List<ProBasicCompany> rgcpls= CacheContext.rgcpmap.get(depId);
+                        for(ProBasicCompany cp:rgcpls)
+                        {
+                            List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(cp.getId());
+                            for(ProBasicPowerstation wp:wpls)
+                            {
+                                ProBasicPowerstation newWp=  new ProBasicPowerstation();
+                                BeanUtil.copyProperties(wp, newWp);
+                                wplist.add(newWp);
+                            }
+                        }
+
+                    }else if(depId.equals("0"))
+                    {
+                        wplist=sessionWpMap.get(token);
+                    }else if(depId.equals("0"))
+                    {
+                        List<ProBasicPowerstation> wpls=CacheContext.wpls;
+                        for(ProBasicPowerstation wp:wpls)
+                        {
+                            ProBasicPowerstation newWp=  new ProBasicPowerstation();
+                            BeanUtil.copyProperties(wp, newWp);
+                            wplist.add(newWp);
+                        }
+
+                    }
+                }
+//                sessionWpMap.put(token,wplist);
+//            }else if (sessionMap.containsKey(token) && sessionWpMap.containsKey(token))
+//            {
+//                wplist=sessionWpMap.get(token);
+//            }
+
+        }else
+        {
+            List<ProBasicPowerstation> wpls=CacheContext.wpls;
+            for(ProBasicPowerstation wp:wpls)
+            {
+                ProBasicPowerstation newWp=  new ProBasicPowerstation();
+                BeanUtil.copyProperties(wp, newWp);
+                wplist.add(newWp);
+            }
+        }
+        return wplist;
+    }
+
+    public  List<ProBasicSubStation>  getSubwpls(HttpServletRequest request )
+    {
+        String token = request.getHeader("token");
+        String userId = request.getHeader("userId");
+        List<ProBasicSubStation> wplist=new ArrayList<>();
+        if(StringUtils.notEmp(token) && StringUtils.notEmp(userId))
+        {
+//            if(!sessionSubMap.containsKey(token))
+//            {
+
+                List<String> depls= sysUserService.getUserByuserId(Long.valueOf(userId));
+                if(!depls.isEmpty())
+                {
+                    String depId=depls.get(0);
+
+                    if(CacheContext.wpmap.containsKey(depId))
+                    {
+                        for(ProBasicSubStation subStation:CacheContext.subwpls)
+                        {
+                            if(subStation.getWindpowerstationId().equals(depId))
+                            {
+                                ProBasicSubStation newSub=  new ProBasicSubStation();
+                                BeanUtil.copyProperties(subStation, newSub);
+                                wplist.add(newSub);
+                            }
+                        }
+                    }else  if(CacheContext.cpwpmap.containsKey(depId))
+                    {
+                        List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(depId);
+
+                        for(ProBasicPowerstation wp:wpls)
+                        {
+                            for(ProBasicSubStation subStation:CacheContext.subwpls)
+                            {
+                                if(subStation.getWindpowerstationId().equals(wp.getId()))
+                                {
+                                    ProBasicSubStation newSub=  new ProBasicSubStation();
+                                    BeanUtil.copyProperties(subStation, newSub);
+                                    wplist.add(newSub);
+                                    break;
+                                }
+                            }
+                        }
+                    }else  if(CacheContext.rgmap.containsKey(depId))
+                    {
+                        List<ProBasicCompany> rgcpls= CacheContext.rgcpmap.get(depId);
+                        for(ProBasicCompany cp:rgcpls)
+                        {
+                            List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(cp.getId());
+
+                            for(ProBasicPowerstation wp:wpls)
+                            {
+                                for(ProBasicSubStation subStation:CacheContext.subwpls)
+                                {
+                                    if(subStation.getWindpowerstationId().equals(wp.getId()))
+                                    {
+                                        ProBasicSubStation newSub=  new ProBasicSubStation();
+                                        BeanUtil.copyProperties(subStation, newSub);
+                                        wplist.add(newSub);
+                                        break;
+                                    }
+                                }
+
+                            }
+                        }
+                    }else if(depId.equals("0"))
+                    {
+                        for(ProBasicSubStation subStation:CacheContext.subwpls)
+                        {
+                            ProBasicSubStation newSub=  new ProBasicSubStation();
+                            BeanUtil.copyProperties(subStation, newSub);
+                            wplist.add(newSub);
+                        }
+
+                    }
+                }
+//                sessionSubMap.put(token,wplist);
+//            }else  if (sessionMap.containsKey(token) && sessionSubMap.containsKey(token))
+//            {
+//                wplist=sessionSubMap.get(token);
+//
+//            }
+        }else
+        {
+            for(ProBasicSubStation subStation:CacheContext.subwpls)
+            {
+                ProBasicSubStation newSub=  new ProBasicSubStation();
+                BeanUtil.copyProperties(subStation, newSub);
+                wplist.add(newSub);
+            }
+        }
+        return wplist;
+    }
+
+
+    public   List<ProBasicWeatherStation>  getWeawpls (HttpServletRequest request )
+    {
+        String token = request.getHeader("token");
+        String userId = request.getHeader("userId");
+
+        List<ProBasicWeatherStation> wplist=new ArrayList<>();
+        if(StringUtils.notEmp(token) && StringUtils.notEmp(userId))
+        {
+//            if(!sessionWeMap.containsKey(token))
+//            {
+
+                List<String> depls= sysUserService.getUserByuserId(Long.valueOf(userId));
+                if(!depls.isEmpty())
+                {
+                    String depId=depls.get(0);
+
+                    if(CacheContext.wpmap.containsKey(depId))
+                    {
+                        for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
+                        {
+                            if(weatherStation.getWindpowerstationId().equals(depId))
+                            {
+
+                                ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
+                                BeanUtil.copyProperties(weatherStation, newWeb);
+                                wplist.add(newWeb);
+                            }
+                        }
+
+                    }else  if(CacheContext.cpwpmap.containsKey(depId))
+                    {
+                        List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(depId);
+
+                        for(ProBasicPowerstation wp:wpls)
+                        {
+                            for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
+                            {
+                                if(weatherStation.getWindpowerstationId().equals(wp.getId()))
+                                {
+                                    ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
+                                    BeanUtil.copyProperties(weatherStation, newWeb);
+                                    wplist.add(newWeb);
+                                    break;
+                                }
+                            }
+
+                        }
+                    }else  if(CacheContext.rgmap.containsKey(depId))
+                    {
+                        List<ProBasicCompany> rgcpls= CacheContext.rgcpmap.get(depId);
+                        for(ProBasicCompany cp:rgcpls)
+                        {
+                            List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(cp.getId());
+
+                            for(ProBasicPowerstation wp:wpls)
+                            {
+                                for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
+                                {
+                                    if(weatherStation.getWindpowerstationId().equals(wp.getId()))
+                                    {
+                                        ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
+                                        BeanUtil.copyProperties(weatherStation, newWeb);
+                                        wplist.add(newWeb);
+                                        break;
+                                    }
+                                }
+
+                            }
+                        }
+
+                    }else if(depId.equals("0"))
+                    {
+                        for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
+                        {
+                            ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
+                            BeanUtil.copyProperties(weatherStation, newWeb);
+                            wplist.add(newWeb);
+                        }
+                    }
+                }
+//                sessionWeMap.put(token,wplist);
+//            }else  if (sessionMap.containsKey(token) && sessionWeMap.containsKey(token))
+//            {
+//                wplist=sessionWeMap.get(token);
+//            }
+
+        }else
+        {
+            for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
+            {
+                ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
+                BeanUtil.copyProperties(weatherStation, newWeb);
+                wplist.add(newWeb);
+            }
+
+
+        }
+        return wplist;
+    }
+}

+ 20 - 310
alarm-web/src/main/java/com/gyee/alarm/service/TokenService.java

@@ -34,248 +34,44 @@ public class TokenService {
 
     public  List<ProBasicEquipment>  getWtls(HttpServletRequest request ) {
 
-        String token = request.getHeader("token");
-        String userId = request.getHeader("userId");
 
-        List<ProBasicEquipment> wtlist = new ArrayList<>();
-        if (StringUtils.notEmp(token) && StringUtils.notEmp(userId))
-        {
-//            if (sessionMap.containsKey(token) && !sessionWtMap.containsKey(token)) {
-
-                List<String> depls = sysUserService.getUserByuserId(Long.valueOf(userId));
-                if (!depls.isEmpty()) {
-                    String depId = depls.get(0);
-
-                    if (CacheContext.wpwtmap.containsKey(depId)) {
-
-                        List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(depId);
-                        for(ProBasicEquipment wt:wtls)
-                        {
-                            ProBasicEquipment newWt=  new ProBasicEquipment();
-                            BeanUtil.copyProperties( wt,newWt);
-                            wtlist.add(newWt);
-                        }
-
-                    } else if (CacheContext.cmwtlsmap.containsKey(depId)) {
-
-                        List<ProBasicEquipment> wtls=CacheContext.cmwtlsmap.get(depId);
-                        for(ProBasicEquipment wt:wtls)
-                        {
-                            ProBasicEquipment newWt=  new ProBasicEquipment();
-                            BeanUtil.copyProperties( wt,newWt);
-                            wtlist.add(newWt);
-                        }
-
-                    } else if (CacheContext.rgwtlsmap.containsKey(depId)) {
-
-                        List<ProBasicEquipment> wtls=CacheContext.rgwtlsmap.get(depId);
-                        for(ProBasicEquipment wt:wtls)
-                        {
-                            ProBasicEquipment newWt=  new ProBasicEquipment();
-                            BeanUtil.copyProperties( wt,newWt);
-                            wtlist.add(newWt);
-                        }
-
-                    }else  if(depId.equals("0"))
-                    {
-                        for(ProBasicEquipment wt:CacheContext.wtls)
-                        {
-                            ProBasicEquipment newWt=  new ProBasicEquipment();
-                            BeanUtil.copyProperties( wt,newWt);
-                            wtlist.add(newWt);
-                        }
 
-                    }
-                }
-//                sessionWtMap.put(token,wtlist);
-//            } else if (sessionMap.containsKey(token) && sessionWtMap.containsKey(token))
-//            {
-//                wtlist =sessionWtMap.get(token);
-//            }
-        }else
+        List<ProBasicEquipment> wtlist = new ArrayList<>();
+        for(ProBasicEquipment wt:CacheContext.wtls)
         {
-            for(ProBasicEquipment wt:CacheContext.wtls)
-            {
-                ProBasicEquipment newWt=  new ProBasicEquipment();
-                BeanUtil.copyProperties( wt,newWt);
-                wtlist.add(newWt);
-            }
-
+            ProBasicEquipment newWt=  new ProBasicEquipment();
+            BeanUtil.copyProperties( wt,newWt);
+            wtlist.add(newWt);
         }
         return wtlist;
     }
 
     public  List<ProBasicPowerstation>  getWpls(HttpServletRequest request )
     {
-        String token = request.getHeader("token");
-        String userId = request.getHeader("userId");
-
-        List<ProBasicPowerstation> wplist=new ArrayList<>();
-        if(StringUtils.notEmp(token)  && StringUtils.notEmp(token))
-        {
-//            if(sessionMap.containsKey(token) && !sessionWpMap.containsKey(token))
-//            {
 
-                List<String> depls= sysUserService.getUserByuserId(Long.valueOf(userId));
-                if(!depls.isEmpty())
-                {
-                    String depId=depls.get(0);
 
-                    if(CacheContext.wpmap.containsKey(depId))
-                    {
-
-                        ProBasicPowerstation wp= CacheContext.wpmap.get(depId);
-                        ProBasicPowerstation newWp=  new ProBasicPowerstation();
-                        BeanUtil.copyProperties(wp, newWp);
-                        wplist.add(newWp);
-                    }else  if(CacheContext.cpwpmap.containsKey(depId))
-                    {
-                        List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(depId);
-                        for(ProBasicPowerstation wp:wpls)
-                        {
-                            ProBasicPowerstation newWp=  new ProBasicPowerstation();
-                            BeanUtil.copyProperties(wp, newWp);
-                            wplist.add(newWp);
-                        }
-
-                    }else  if(CacheContext.rgmap.containsKey(depId))
-                    {
-                        List<ProBasicCompany> rgcpls= CacheContext.rgcpmap.get(depId);
-                        for(ProBasicCompany cp:rgcpls)
-                        {
-                            List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(cp.getId());
-                            for(ProBasicPowerstation wp:wpls)
-                            {
-                                ProBasicPowerstation newWp=  new ProBasicPowerstation();
-                                BeanUtil.copyProperties(wp, newWp);
-                                wplist.add(newWp);
-                            }
-                        }
-
-                    }else if(depId.equals("0"))
-                    {
-                        wplist=sessionWpMap.get(token);
-                    }else if(depId.equals("0"))
-                    {
-                        List<ProBasicPowerstation> wpls=CacheContext.wpls;
-                        for(ProBasicPowerstation wp:wpls)
-                        {
-                            ProBasicPowerstation newWp=  new ProBasicPowerstation();
-                            BeanUtil.copyProperties(wp, newWp);
-                            wplist.add(newWp);
-                        }
-
-                    }
-                }
-//                sessionWpMap.put(token,wplist);
-//            }else if (sessionMap.containsKey(token) && sessionWpMap.containsKey(token))
-//            {
-//                wplist=sessionWpMap.get(token);
-//            }
+        List<ProBasicPowerstation> wplist=new ArrayList<>();
 
-        }else
+        List<ProBasicPowerstation> wpls=CacheContext.wpls;
+        for(ProBasicPowerstation wp:wpls)
         {
-            List<ProBasicPowerstation> wpls=CacheContext.wpls;
-            for(ProBasicPowerstation wp:wpls)
-            {
-                ProBasicPowerstation newWp=  new ProBasicPowerstation();
-                BeanUtil.copyProperties(wp, newWp);
-                wplist.add(newWp);
-            }
+            ProBasicPowerstation newWp=  new ProBasicPowerstation();
+            BeanUtil.copyProperties(wp, newWp);
+            wplist.add(newWp);
         }
         return wplist;
     }
 
     public  List<ProBasicSubStation>  getSubwpls(HttpServletRequest request )
     {
-        String token = request.getHeader("token");
-        String userId = request.getHeader("userId");
-        List<ProBasicSubStation> wplist=new ArrayList<>();
-        if(StringUtils.notEmp(token) && StringUtils.notEmp(userId))
-        {
-//            if(!sessionSubMap.containsKey(token))
-//            {
-
-                List<String> depls= sysUserService.getUserByuserId(Long.valueOf(userId));
-                if(!depls.isEmpty())
-                {
-                    String depId=depls.get(0);
-
-                    if(CacheContext.wpmap.containsKey(depId))
-                    {
-                        for(ProBasicSubStation subStation:CacheContext.subwpls)
-                        {
-                            if(subStation.getWindpowerstationId().equals(depId))
-                            {
-                                ProBasicSubStation newSub=  new ProBasicSubStation();
-                                BeanUtil.copyProperties(subStation, newSub);
-                                wplist.add(newSub);
-                            }
-                        }
-                    }else  if(CacheContext.cpwpmap.containsKey(depId))
-                    {
-                        List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(depId);
-
-                        for(ProBasicPowerstation wp:wpls)
-                        {
-                            for(ProBasicSubStation subStation:CacheContext.subwpls)
-                            {
-                                if(subStation.getWindpowerstationId().equals(wp.getId()))
-                                {
-                                    ProBasicSubStation newSub=  new ProBasicSubStation();
-                                    BeanUtil.copyProperties(subStation, newSub);
-                                    wplist.add(newSub);
-                                    break;
-                                }
-                            }
-                        }
-                    }else  if(CacheContext.rgmap.containsKey(depId))
-                    {
-                        List<ProBasicCompany> rgcpls= CacheContext.rgcpmap.get(depId);
-                        for(ProBasicCompany cp:rgcpls)
-                        {
-                            List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(cp.getId());
 
-                            for(ProBasicPowerstation wp:wpls)
-                            {
-                                for(ProBasicSubStation subStation:CacheContext.subwpls)
-                                {
-                                    if(subStation.getWindpowerstationId().equals(wp.getId()))
-                                    {
-                                        ProBasicSubStation newSub=  new ProBasicSubStation();
-                                        BeanUtil.copyProperties(subStation, newSub);
-                                        wplist.add(newSub);
-                                        break;
-                                    }
-                                }
-
-                            }
-                        }
-                    }else if(depId.equals("0"))
-                    {
-                        for(ProBasicSubStation subStation:CacheContext.subwpls)
-                        {
-                            ProBasicSubStation newSub=  new ProBasicSubStation();
-                            BeanUtil.copyProperties(subStation, newSub);
-                            wplist.add(newSub);
-                        }
+        List<ProBasicSubStation> wplist=new ArrayList<>();
 
-                    }
-                }
-//                sessionSubMap.put(token,wplist);
-//            }else  if (sessionMap.containsKey(token) && sessionSubMap.containsKey(token))
-//            {
-//                wplist=sessionSubMap.get(token);
-//
-//            }
-        }else
+        for(ProBasicSubStation subStation:CacheContext.subwpls)
         {
-            for(ProBasicSubStation subStation:CacheContext.subwpls)
-            {
-                ProBasicSubStation newSub=  new ProBasicSubStation();
-                BeanUtil.copyProperties(subStation, newSub);
-                wplist.add(newSub);
-            }
+            ProBasicSubStation newSub=  new ProBasicSubStation();
+            BeanUtil.copyProperties(subStation, newSub);
+            wplist.add(newSub);
         }
         return wplist;
     }
@@ -283,100 +79,14 @@ public class TokenService {
 
     public   List<ProBasicWeatherStation>  getWeawpls (HttpServletRequest request )
     {
-        String token = request.getHeader("token");
-        String userId = request.getHeader("userId");
 
         List<ProBasicWeatherStation> wplist=new ArrayList<>();
-        if(StringUtils.notEmp(token) && StringUtils.notEmp(userId))
-        {
-//            if(!sessionWeMap.containsKey(token))
-//            {
-
-                List<String> depls= sysUserService.getUserByuserId(Long.valueOf(userId));
-                if(!depls.isEmpty())
-                {
-                    String depId=depls.get(0);
-
-                    if(CacheContext.wpmap.containsKey(depId))
-                    {
-                        for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
-                        {
-                            if(weatherStation.getWindpowerstationId().equals(depId))
-                            {
 
-                                ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
-                                BeanUtil.copyProperties(weatherStation, newWeb);
-                                wplist.add(newWeb);
-                            }
-                        }
-
-                    }else  if(CacheContext.cpwpmap.containsKey(depId))
-                    {
-                        List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(depId);
-
-                        for(ProBasicPowerstation wp:wpls)
-                        {
-                            for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
-                            {
-                                if(weatherStation.getWindpowerstationId().equals(wp.getId()))
-                                {
-                                    ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
-                                    BeanUtil.copyProperties(weatherStation, newWeb);
-                                    wplist.add(newWeb);
-                                    break;
-                                }
-                            }
-
-                        }
-                    }else  if(CacheContext.rgmap.containsKey(depId))
-                    {
-                        List<ProBasicCompany> rgcpls= CacheContext.rgcpmap.get(depId);
-                        for(ProBasicCompany cp:rgcpls)
-                        {
-                            List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(cp.getId());
-
-                            for(ProBasicPowerstation wp:wpls)
-                            {
-                                for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
-                                {
-                                    if(weatherStation.getWindpowerstationId().equals(wp.getId()))
-                                    {
-                                        ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
-                                        BeanUtil.copyProperties(weatherStation, newWeb);
-                                        wplist.add(newWeb);
-                                        break;
-                                    }
-                                }
-
-                            }
-                        }
-
-                    }else if(depId.equals("0"))
-                    {
-                        for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
-                        {
-                            ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
-                            BeanUtil.copyProperties(weatherStation, newWeb);
-                            wplist.add(newWeb);
-                        }
-                    }
-                }
-//                sessionWeMap.put(token,wplist);
-//            }else  if (sessionMap.containsKey(token) && sessionWeMap.containsKey(token))
-//            {
-//                wplist=sessionWeMap.get(token);
-//            }
-
-        }else
+        for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
         {
-            for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
-            {
-                ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
-                BeanUtil.copyProperties(weatherStation, newWeb);
-                wplist.add(newWeb);
-            }
-
-
+            ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
+            BeanUtil.copyProperties(weatherStation, newWeb);
+            wplist.add(newWeb);
         }
         return wplist;
     }

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/service/auto/IProBasicDeviceModelMetricsService.java

@@ -17,5 +17,5 @@ import java.util.List;
 public interface IProBasicDeviceModelMetricsService extends IService<ProBasicDeviceModelMetrics> {
     List<ProBasicDeviceModelMetrics> getDeviceModelMetrics(List<String> collect,String modelId);
     List<ProBasicDeviceModelMetrics> getAll();
-
+    List<ProBasicDeviceModelMetrics> getDeviceModelMetricsById(String metriccode) ;
 }

+ 38 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmPlanService.java

@@ -0,0 +1,38 @@
+package com.gyee.alarm.service.auto;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.alarm.init.CacheContext;
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.gyee.alarm.model.auto.ProEconAlarmRule;
+import com.gyee.alarm.model.vo.AlarmConfigurationVo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+public interface IProEconAlarmPlanService extends IService<ProEconAlarmPlan> {
+
+
+   public  List<ProEconAlarmPlan>  alarmPlanlistById(String alarmId) ;
+
+   void  updatePlanlistById(String alarmId,String planIds) ;
+
+   public int saveAndUpdateAlertrule(ProEconAlarmPlan alarmRule) throws Exception;
+
+
+   public boolean deleteAlertrule( List<String> idls);
+
+   public IPage<ProEconAlarmPlan> pageQueryAll(Page page, String name,String types);
+
+}

+ 16 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmRealService.java

@@ -0,0 +1,16 @@
+package com.gyee.alarm.service.auto;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.alarm.model.auto.ProEconAlarmReal;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+public interface IProEconAlarmRealService extends IService<ProEconAlarmReal> {
+
+}

+ 9 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProBasicDeviceModelMetricsServiceImpl.java

@@ -7,8 +7,10 @@ import com.gyee.alarm.model.auto.ProBasicEquipmentPoint;
 import com.gyee.alarm.service.auto.IProBasicDeviceModelMetricsService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.common.model.StringUtils;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
@@ -22,6 +24,8 @@ import java.util.List;
 @Service
 public class ProBasicDeviceModelMetricsServiceImpl extends ServiceImpl<ProBasicDeviceModelMetricsMapper, ProBasicDeviceModelMetrics> implements IProBasicDeviceModelMetricsService {
 
+    @Resource
+    private ProBasicDeviceModelMetricsMapper proBasicDeviceModelMetricsMapper;
     @Override
     public List<ProBasicDeviceModelMetrics> getDeviceModelMetrics(List<String> collect, String modelId) {
         QueryWrapper<ProBasicDeviceModelMetrics> qw = new QueryWrapper<>();
@@ -41,4 +45,9 @@ public class ProBasicDeviceModelMetricsServiceImpl extends ServiceImpl<ProBasicD
         List<ProBasicDeviceModelMetrics> list = baseMapper.selectList(null);
         return list;
     }
+    @Override
+   public List<ProBasicDeviceModelMetrics> getDeviceModelMetricsById(String metriccode) {
+        List<ProBasicDeviceModelMetrics> list =proBasicDeviceModelMetricsMapper.getDeviceModelMetricsById(metriccode);
+        return list;
+    }
 }

+ 183 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmPlanServiceImpl.java

@@ -0,0 +1,183 @@
+package com.gyee.alarm.service.auto.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.alarm.init.CacheContext;
+import com.gyee.alarm.mapper.auto.ProEconAlarmPlanMapper;
+import com.gyee.alarm.mapper.auto.ProEconAlarmRealMapper;
+import com.gyee.alarm.mapper.auto.ProEconAlarmPlanMapper;
+import com.gyee.alarm.model.auto.*;
+import com.gyee.alarm.model.auto.ProEconAlarmPlan;
+import com.gyee.alarm.model.vo.AlarmConfigurationVo;
+import com.gyee.alarm.service.RuleUpdateEventService;
+import com.gyee.alarm.service.auto.IProEconAlarmPlanService;
+import com.gyee.alarm.util.SnowflakeGenerator;
+import com.gyee.alarm.util.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@Service
+public class ProEconAlarmPlanServiceImpl extends ServiceImpl<ProEconAlarmPlanMapper, ProEconAlarmPlan> implements IProEconAlarmPlanService {
+
+
+    @Resource
+    private ProEconAlarmRealMapper proEconAlarmRealMapper;
+
+    @Resource
+    private ProEconAlarmPlanMapper proEconAlarmPlanMapper;
+      public void  updatePlanlistById(String alarmId, String planIds)
+    {
+        List<ProEconAlarmReal>  ls= proEconAlarmRealMapper.alarmPlanlistById(alarmId);
+
+        if(!ls.isEmpty())
+        {
+            ProEconAlarmReal ar=ls.get(0);
+
+            ar.setAlarmPlan(planIds);
+
+            proEconAlarmRealMapper.updateProEconAlarmReal(ar.getAlarmId(),ar.getAlarmPlan(),ar.getId());
+        }else
+        {
+            ProEconAlarmReal ar=new ProEconAlarmReal();
+
+            ar.setId(String.valueOf(SnowflakeGenerator.generateId()));
+            ar.setAlarmId(alarmId);
+            ar.setAlarmPlan(planIds);
+
+            proEconAlarmRealMapper.insert(ar);
+        }
+    }
+    public  List<ProEconAlarmPlan>  alarmPlanlistById(String alarmId) {
+
+        List<ProEconAlarmPlan> vos=new ArrayList();
+
+        List<ProEconAlarmReal>  ls= proEconAlarmRealMapper.alarmPlanlistById( alarmId);
+
+        if(!ls.isEmpty())
+        {
+            ProEconAlarmReal ar=ls.get(0);
+
+            if(StringUtils.notEmp(ar.getAlarmPlan()))
+            {
+               String[] strs= ar.getAlarmPlan().split(",");
+
+                List<String> alarmPlanListId = Arrays.stream(strs).filter(s -> StringUtils.notEmp(s)).collect(Collectors.toList());
+
+                QueryWrapper<ProEconAlarmPlan> qw = new QueryWrapper<>();
+
+
+                if (alarmPlanListId != null && !alarmPlanListId.isEmpty()) {
+                    qw.in("id", alarmPlanListId);
+                }
+                List<ProEconAlarmPlan> list = baseMapper.selectList(qw);
+                return list;
+            }
+        }
+
+
+
+        return vos;
+    }
+
+
+    public int saveAndUpdateAlertrule(ProEconAlarmPlan alarmRule) throws Exception {
+
+        int result = 0;
+
+        if (StringUtils.notEmp(alarmRule) && null !=alarmRule.getName()&& null !=alarmRule.getTypes()) {
+
+            if(StringUtils.notEmp(alarmRule.getId()))
+            {
+                ProEconAlarmPlan oldRulel = proEconAlarmPlanMapper.selectById(alarmRule.getId());
+                if(StringUtils.notEmp(oldRulel))
+                {
+
+                    if (oldRulel != null) {
+                        alarmRule.setId(oldRulel.getId());
+                        result = proEconAlarmPlanMapper.updateByAlertruleId(alarmRule);
+
+                    }
+                }else
+                {
+                    if(StringUtils.empty(alarmRule.getId()))
+                    {
+                        alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                    }
+
+                    result = saveAlertrule(alarmRule);
+                }
+            }else
+            {
+                if(StringUtils.empty(alarmRule.getId()))
+                {
+                    alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                }
+
+                result = saveAlertrule(alarmRule);
+            }
+        }
+
+        return result;
+    }
+
+
+    private int saveAlertrule(ProEconAlarmPlan alarmRule) throws Exception {
+
+        int result = 0;
+
+        if (StringUtils.notEmp(alarmRule)) {
+
+
+            alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
+
+            result= proEconAlarmPlanMapper.insert(alarmRule);
+        }
+//        if (result > 0) {
+//            int i = eventService.saveEventAlertRule(alarmRule, oldRule2, userData.getUserName());
+        return result;
+    }
+
+    public boolean deleteAlertrule( List<String> idls) {
+
+
+          return removeByIds(idls);
+    }
+
+
+    public IPage<ProEconAlarmPlan> pageQueryAll(Page page, String name,String types) {
+
+
+        if(StringUtils.notEmp(name))
+        {
+            name="%"+name+"%";
+        }else
+        {
+            name=null;
+        }
+
+        if(StringUtils.notEmp(types))
+        {
+            types=types;
+        }else
+        {
+            types=null;
+        }
+        IPage<ProEconAlarmPlan> alertruleIPage = proEconAlarmPlanMapper.pageQueryAll(page, name,types);
+
+
+        return alertruleIPage;
+    }
+}

+ 20 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmRealServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.alarm.service.auto.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.alarm.mapper.auto.ProEconAlarmRealMapper;
+import com.gyee.alarm.model.auto.ProEconAlarmReal;
+import com.gyee.alarm.service.auto.IProEconAlarmRealService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@Service
+public class ProEconAlarmRealServiceImpl extends ServiceImpl<ProEconAlarmRealMapper, ProEconAlarmReal> implements IProEconAlarmRealService {
+
+}

+ 227 - 0
alarm-web/src/main/java/com/gyee/alarm/util/ExcelUtil.java

@@ -0,0 +1,227 @@
+package com.gyee.alarm.util;
+
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class ExcelUtil {
+
+    public static void createExcel(List<String> header, List<String[]> data, OutputStream out) throws IOException {
+        // 创建一个Excel文件
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        // 创建一个工作表
+        HSSFSheet sheet = workbook.createSheet("sheet1");
+        // 添加表头行
+        HSSFRow hssfRow = sheet.createRow(0);
+        // 设置单元格格式居中
+        HSSFCellStyle cellStyle = workbook.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+
+        // 添加表头内容
+        for (int i = 0; i < header.size(); i++) {
+            HSSFCell headCell = hssfRow.createCell(i);
+            headCell.setCellValue(header.get(i));
+            headCell.setCellStyle(cellStyle);
+        }
+
+        // 添加数据内容
+        for (int i = 0; i < data.size(); i++) {
+            String[] strings = data.get(i);
+            hssfRow = sheet.createRow(i + 1);
+            for (int j = 0; j < strings.length; j++) {
+                HSSFCell cell = hssfRow.createCell(j);
+                cell.setCellValue(strings[j]);
+                cell.setCellStyle(cellStyle);
+            }
+        }
+        //单元格自适应
+        sheet.autoSizeColumn(2,true);
+        // 保存Excel文件
+        workbook.write(out);
+    }
+
+    public static void createExcel(String title,List<String> header, List<String[]> data, OutputStream out) throws IOException {
+        // 创建一个Excel文件
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        // 创建一个工作表
+        HSSFSheet sheet = workbook.createSheet("sheet1");
+        // 添加表头行
+        HSSFRow hssfRow = sheet.createRow(0);
+        HSSFCell cellTitle = hssfRow.createCell(0);
+        // 设置标题外的单元格格式居中
+        HSSFCellStyle cellStyle = workbook.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+        //设置标题的样式
+        HSSFCellStyle titleCellStyle = workbook.createCellStyle();
+        titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
+        titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        //设置标题字体的样式
+        HSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);//设置字体大小
+        titleCellStyle.setFont(font);
+        //标题设置(四个参数分别表示起始行,终止行,起始列,终止列)
+        cellTitle.setCellValue(title);
+        int lastCol = header.size() > 1 ? header.size() : 2;
+        CellRangeAddress region1 = new CellRangeAddress(0, 1, (short) 0, (short) lastCol - 1);
+        sheet.addMergedRegion(region1);
+        hssfRow = sheet.createRow(1);
+        hssfRow = sheet.createRow(2);
+        cellTitle.setCellStyle(titleCellStyle);
+        // 添加表头内容
+        for (int i = 0; i < header.size(); i++) {
+            HSSFCell headCell = hssfRow.createCell(i);
+            headCell.setCellValue(header.get(i));
+            headCell.setCellStyle(cellStyle);
+        }
+
+        // 添加数据内容
+        for (int i = 0; i < data.size(); i++) {
+            String[] strings = data.get(i);
+            hssfRow = sheet.createRow(i + 3);
+            for (int j = 0; j < strings.length; j++) {
+                HSSFCell cell = hssfRow.createCell(j);
+                cell.setCellValue(strings[j]);
+                cell.setCellStyle(cellStyle);
+            }
+        }
+
+        // 保存Excel文件
+        workbook.write(out);
+    }
+
+    /**
+     * 读取Excel的内容
+     *
+     * @param fileType 文件类型,xls或xlsx
+     * @param startRows 开始读取行数,比喻行头不需要读入 忽略的行数为1
+     * @param ignoreRowBlank 是否忽略空行
+     * @param is 文件输入流
+     * @return 读出的Excel中数据的内容
+     * @throws IOException duxxxxx
+     */
+    public static List<String[]> readData(String fileType, int startRows, boolean ignoreRowBlank, InputStream is) throws IOException {
+        List<String[]> result = new ArrayList<>();
+
+        Workbook wb = readExcel(fileType, is);
+        for (int sheetIndex = 0; sheetIndex < wb.getNumberOfSheets(); sheetIndex++) {
+            Sheet sheet = wb.getSheetAt(sheetIndex);
+
+            for (int rowIndex = startRows, z = sheet.getLastRowNum(); rowIndex <= z; rowIndex++) {
+                Row row = sheet.getRow(rowIndex);
+                if (row == null) {
+                    continue;
+                }
+
+                int rowSize = sheet.getRow(0).getLastCellNum();
+                String[] values = new String[rowSize];
+                boolean hasValue = false;
+                for (int columnIndex = 0; columnIndex < rowSize; columnIndex++) {
+                    String value = "";
+                    Cell cell = row.getCell(columnIndex);
+                    if (cell != null) {
+                        // 注意:一定要设成这个,否则可能会出现乱码,后面版本默认设置
+                        switch (cell.getCellType()) {
+                            case STRING:
+                                value = cell.getStringCellValue();
+                                break;
+                            case NUMERIC:
+                                if (HSSFDateUtil.isCellDateFormatted(cell)) {
+                                    Date date = cell.getDateCellValue();
+                                    if (date != null) {
+                                        value = new SimpleDateFormat("yyyy-MM-dd")
+                                                .format(date);
+                                    } else {
+                                        value = "";
+                                    }
+                                } else {
+                                    //value = new DecimalFormat("0").format(cell.getNumericCellValue());
+                                    if (HSSFDateUtil.isCellDateFormatted(cell)) {
+                                        value = String.valueOf(cell.getDateCellValue());
+                                    } else {
+//                                        cell.setCellType(Cell.CELL_TYPE_STRING);
+
+                                        String temp = cell.getStringCellValue();
+                                        // 判断是否包含小数点,如果不含小数点,则以字符串读取,如果含小数点,则转换为Double类型的字符串
+                                        if (temp.indexOf(".") > -1) {
+                                            value = String.valueOf(new Double(temp)).trim();
+                                        } else {
+                                            value = temp.trim();
+                                        }
+                                    }
+                                }
+                                break;
+                            case FORMULA:
+                                // 导入时如果为公式生成的数据则无值
+                                if (!cell.getStringCellValue().equals("")) {
+                                    value = cell.getStringCellValue();
+                                } else {
+                                    value = cell.getNumericCellValue() + "";
+                                }
+                                break;
+                            case BLANK:
+                                break;
+                            case ERROR:
+                                value = "";
+                                break;
+                            case BOOLEAN:
+                                value = (cell.getBooleanCellValue() == true ? "Y"
+
+                                        : "N");
+                                break;
+                            default:
+                                value = "";
+                        }
+                    }
+                    values[columnIndex] = value;
+                    if (!value.isEmpty()) {
+                        hasValue = true;
+                    }
+                }
+                if (!ignoreRowBlank || hasValue) {//不为忽略空行模式或不为空行
+                    result.add(values);
+                }
+            }
+        }
+        return result;
+    }
+
+    //读取excel
+    private static Workbook readExcel(String fileType, InputStream is) throws IOException {
+        if ("xls".equals(fileType)) {
+            return new HSSFWorkbook(is);
+        } else if ("xlsx".equals(fileType)) {
+            return new XSSFWorkbook(is);
+        } else {
+            throw new IllegalArgumentException("不支持的文件类型,仅支持xls和xlsx");
+        }
+    }
+
+    /**
+     * 去掉字符串右边的空格
+     *
+     * @param str 要处理的字符串
+     * @return 处理后的字符串
+     */
+    private static String rightTrim(String str) {
+        if (str == null) {
+            return "";
+        }
+        int length = str.length();
+        for (int i = length - 1; i >= 0; i--) {
+            if (str.charAt(i) != 0x20) {
+                break;
+            }
+            length--;
+        }
+        return str.substring(0, length);
+    }
+}