Sfoglia il codice sorgente

定边报警系统修改

shilin 1 mese fa
parent
commit
9ff0a5a754
29 ha cambiato i file con 845 aggiunte e 177 eliminazioni
  1. 1 1
      alarm-scanner/pom.xml
  2. 16 31
      alarm-scanner/src/main/java/com/gyee/alarm/config/ThreadPoolTaskConfig.java
  3. 3 3
      alarm-scanner/src/main/java/com/gyee/alarm/service/AlarmScannerService.java
  4. 2 2
      alarm-web/pom.xml
  5. 3 3
      alarm-web/src/main/java/com/gyee/alarm/config/ThreadPoolTaskConfig.java
  6. 11 11
      alarm-web/src/main/java/com/gyee/alarm/controller/AlarmConfigurationController.java
  7. 72 0
      alarm-web/src/main/java/com/gyee/alarm/controller/AlarmHistoryController.java
  8. 19 32
      alarm-web/src/main/java/com/gyee/alarm/controller/AlertRuleController.java
  9. 6 6
      alarm-web/src/main/java/com/gyee/alarm/controller/InfoController.java
  10. 83 8
      alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicDeviceController.java
  11. 49 2
      alarm-web/src/main/java/com/gyee/alarm/controller/ProBasicDeviceFaultModeController.java
  12. 97 12
      alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmPlanController.java
  13. 36 8
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java
  14. 2 2
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceMetricsMapper.java
  15. 1 1
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceModelMetricsMapper.java
  16. 12 10
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmPlanMapper.java
  17. 8 3
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRealMapper.java
  18. 1 1
      alarm-web/src/main/java/com/gyee/alarm/model/auto/ProBasicDeviceFaultMode.java
  19. 5 0
      alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmPlan.java
  20. 23 13
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmConfigurationService.java
  21. 123 2
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmHistoryService.java
  22. 14 10
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmRuleService.java
  23. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmWtService.java
  24. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/DeviceFaultModeService.java
  25. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/DeviceService.java
  26. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/auto/IProBasicDeviceModelMetricsService.java
  27. 9 0
      alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProBasicDeviceModelMetricsServiceImpl.java
  28. 18 12
      alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmPlanServiceImpl.java
  29. 227 0
      alarm-web/src/main/java/com/gyee/alarm/util/ExcelUtil.java

+ 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();
             }
 
 

+ 2 - 2
alarm-web/pom.xml

@@ -159,12 +159,12 @@
 <!--        <dependency>-->
 <!--            <groupId>com.taosdata.jdbc</groupId>-->
 <!--            <artifactId>taos-jdbcdriver</artifactId>-->
-<!--            <version>3.2.2</version>-->
+<!--            <version>3.3.0</version>-->
 <!--        </dependency>-->
         <dependency>
             <groupId>com.taosdata.jdbc</groupId>
             <artifactId>taos-jdbcdriver</artifactId>
-            <version>2.0.39</version>
+            <version>2.0.35</version>
         </dependency>
         <!-- 工具类相关 -->
         <dependency>

+ 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;
+
+    }
 }
 
 

+ 19 - 32
alarm-web/src/main/java/com/gyee/alarm/controller/AlertRuleController.java

@@ -76,23 +76,7 @@ public class AlertRuleController {
         }
     }
 
-    @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 = "/querywtalarmdesclist")
     @ApiOperation(value = "通过场站、型号和部件查询报警描述信息", notes = "通过场站、型号和部件查询报警描述信息")
@@ -371,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<>();
@@ -454,7 +441,7 @@ public class AlertRuleController {
 
             int result = alarmRuleService.saveAndUpdateAlertrule(alarmRule);
 
-            proEconAlarmPlanService.updatePlanlistById(alarmRule.getId(), alarmRule.getAlarmPlan());
+
 
             return AjaxResult.successData(AjaxStatus.success.code, result);
         } else {
@@ -535,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;
                 }
@@ -630,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("上传文件失败!");
+    }
 }

+ 97 - 12
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmPlanController.java

@@ -22,10 +22,8 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -42,6 +40,86 @@ 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")
@@ -95,16 +173,17 @@ public class ProEconAlarmPlanController {
 
             @ApiImplicitParam(name = "pageNum", value = "页号", required = true, dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "pageSize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "pageSize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "types", value = "名称", required = false, dataType = "string", paramType = "query"),
-            @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "string", 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 = "types", required = false) String types,
-                                  @RequestParam(value = "name", required = false) String name
+
+                                  @RequestParam(value = "name", required = false) String name ,
+                                  @RequestParam(value = "types", required = false) String types
     ) {
         Page<ProEconAlarmPlan> page = new Page(pageNum, pageSize);
 
@@ -123,7 +202,7 @@ public class ProEconAlarmPlanController {
     //@UserLoginToken
     @PostMapping(value = "/save-batch")
     @ResponseBody
-    @ApiOperation(value = "批量保存", notes = "分页查询")
+    @ApiOperation(value = "批量保存", notes = "批量保存")
     public AjaxResult saveAlertruleBatch(HttpServletRequest request, @RequestBody List<ProEconAlarmPlan> lst) throws Exception {
 
 
@@ -181,11 +260,11 @@ public class ProEconAlarmPlanController {
 
         List<ProEconAlarmPlan> list = Arrays.asList(
                 ProEconAlarmPlan.builder().id("1").types("类型1").troubleMethod("排查步骤1")
-                        .processMethod("检修方案").tools("所需工具1").spareParts("备品备件1").name("名字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")
+                        .processMethod("检修方案2").tools("所需工具2").spareParts("备品备件2").name("名字2").typedetails("类别2")
 
                         .build()
 
@@ -217,6 +296,12 @@ public class ProEconAlarmPlanController {
                 } 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;

+ 36 - 8
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java

@@ -244,7 +244,7 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
 
 
     @Select({"<script>",
-            "select deviceid as wtId,stationid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmCt " ,
+            "select deviceid as wtId,stationid as stationId,alarmid,characteristic as description  ,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmCt " ,
             "<where>" ,
 
             " ts &gt;= #{begin}",
@@ -264,13 +264,13 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "</if>",
             "</where>",
 
-            " group by deviceid,components,stationid,alarmid,description ",
+            " group by deviceid,components,stationid,alarmid,characteristic ",
             " order by deviceid  ",
             "</script>"})
     List<ProBasicFeatureStat> findCtFeatureStat( @Param("begin")long begin, @Param("end") long end, @Param("stationid") String stationid, @Param("modelId")String modelId, @Param("components") String components, @Param("alarmid") String alarmid, @Param("deviceType")String deviceType);
 
     @Select({"<script>",
-            "select  stationid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmCt " ,
+            "select  stationid as stationId,alarmid,characteristic as description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmCt " ,
             "<where>" ,
 
             " ts &gt;= #{begin}",
@@ -291,14 +291,14 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "</if>",
             "</where>",
 
-            " group by  components,stationid,alarmid,description ",
-            " order by stationid  ",
+            " group by  components,stationid,alarmid,characteristic ",
+            " order by ts  ",
             "</script>"})
     List<ProBasicFeatureStat> findCtFeatureStatByWpId( @Param("begin")long begin, @Param("end") long end, @Param("stationid") String stationid, @Param("modelId")String modelId, @Param("components") String components, @Param("alarmid") String alarmid, @Param("deviceType")String deviceType);
 
 
-    @Select({"<script>",
-            "select  lineid as stationId,alarmid,description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmCt " ,
+       @Select({"<script>",
+            "select  lineid as stationId,alarmid,characteristic as description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmCt " ,
             "<where>" ,
 
             " ts &gt;= #{begin}",
@@ -319,11 +319,39 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "</if>",
             "</where>",
 
-            " group by  components,lineid,alarmid,description ",
+            " group by  components,lineid,alarmid,characteristic ",
             " order by lineid  ",
             "</script>"})
     List<ProBasicFeatureStat> findCtFeatureStatByLnId( @Param("begin")long begin, @Param("end") long end, @Param("stationid") String stationid, @Param("modelId")String modelId, @Param("components") String components, @Param("alarmid") String alarmid, @Param("deviceType")String deviceType);
 
+
+    @Select({"<script>",
+            "select  lineid as stationId,alarmid,characteristic as description,components as typeCode,max(timeLong) as maxSeconds,min(timeLong) as minSeconds,avg(timeLong) as avgSeconds,sum(timeLong) as totalSeconds,count(*) as total from alarmCt " ,
+            "<where>" ,
+
+            " ts &gt;= #{begin}",
+            "and ts &lt;= #{end}",
+            "and deviceid = #{wtId}",
+            "<if test='modelId != null'>",
+            "and modelId = #{modelId}",
+            "</if>",
+
+            "<if test='alarmid != null'>",
+            "and alarmid in(${alarmid}) ",
+            "</if>",
+            "<if test='components != null'>",
+            "and components in(${components}) ",
+            "</if>",
+            "<if test='deviceType != null'>",
+            "and deviceType = #{deviceType}",
+            "</if>",
+            "</where>",
+
+            " group by  components,lineid,alarmid,characteristic ",
+            " order by ts  ",
+            "</script>"})
+    List<ProBasicFeatureStat> findCtFeatureStatByWtId( @Param("begin")long begin, @Param("end") long end, @Param("wtId") String wtId, @Param("modelId")String modelId, @Param("components") String components, @Param("alarmid") String alarmid, @Param("deviceType")String deviceType);
+
     @Select("${sql}")
     List<AlarmSimpleVo> selectLastRowByTbname( @Param("sql") String sql);
 }

+ 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>",

+ 12 - 10
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmPlanMapper.java

@@ -29,23 +29,25 @@ public interface ProEconAlarmPlanMapper extends BaseMapper<ProEconAlarmPlan> {
             " 1=1 ",
 
             "<if test='troubleMethod !=null  '>",
-            "and trouble_method = #{troubleMethod} ",
+            "and name = #{name} ",
+            "</if>",
+            "<if test='troubleMethod !=null  '>",
+            "and types = #{types} ",
             "</if>",
-
             "</where>",
 
             "</script>"})
-    List<ProEconAlarmPlan> queryObject(@Param("troubleMethod") String troubleMethod);
+    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}" ,
+            "types = #{types},",
+            "trouble_method = #{troubleMethod},",
+            "process_method = #{processMethod},",
+            "tools = #{tools}," ,
+            "spare_parts = #{spareParts}," ,
             "name = #{name}" ,
             "</set>",
             "where id = #{id}",
@@ -61,10 +63,10 @@ public interface ProEconAlarmPlanMapper extends BaseMapper<ProEconAlarmPlan> {
 
 
             "<if test='name !=null  '>",
-            "and a.name like #{name} ",
+            "and name like #{name}",
             "</if>",
             "<if test='types !=null  '>",
-            "and a.types = #{types} ",
+            "and types = #{types} ",
             "</if>",
             "</where>",
 

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

@@ -7,7 +7,9 @@ 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;
 
 /**
@@ -22,13 +24,16 @@ public interface ProEconAlarmRealMapper extends BaseMapper<ProEconAlarmReal> {
 
 
     @Select({"<script>",
-            "select a.* from pro_econ_alarm_real a",
+            "select * from pro_econ_alarm_real a",
             "<where>",
-            " a.alarm_id = #{alarmId} ",
+            " alarm_id = #{alarmId} ",
             "</where>",
 
             "</script>"})
     List<ProEconAlarmReal> alarmPlanlistById( @Param("alarmId") String alarmId);
 
-    void update(ProEconAlarmReal ar);
+    @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);
+
 }

+ 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;
 
     /**
      * 结构编码

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

@@ -58,4 +58,9 @@ public class ProEconAlarmPlan extends Model {
      * 名称
      */
     private String name;
+
+    /**
+     * 明细分类
+     */
+    private String typedetails;
 }

+ 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);
             }
         }

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

@@ -320,7 +320,7 @@ public class DeviceService {
 
     }
 
-    public int deleteDeviceStructure(long dsId) {
+    public int deleteDeviceStructure(String dsId) {
         int code = proBasicDeviceStructureMapper.deleteById(dsId);
         if (code >= 1) {
             //树结构变化清空树结构缓存

+ 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) ;
 }

+ 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;
+    }
 }

+ 18 - 12
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmPlanServiceImpl.java

@@ -40,7 +40,7 @@ public class ProEconAlarmPlanServiceImpl extends ServiceImpl<ProEconAlarmPlanMap
     private ProEconAlarmPlanMapper proEconAlarmPlanMapper;
       public void  updatePlanlistById(String alarmId, String planIds)
     {
-        List<ProEconAlarmReal>  ls= proEconAlarmRealMapper.alarmPlanlistById( alarmId);
+        List<ProEconAlarmReal>  ls= proEconAlarmRealMapper.alarmPlanlistById(alarmId);
 
         if(!ls.isEmpty())
         {
@@ -48,12 +48,12 @@ public class ProEconAlarmPlanServiceImpl extends ServiceImpl<ProEconAlarmPlanMap
 
             ar.setAlarmPlan(planIds);
 
-            proEconAlarmRealMapper.update(ar);
+            proEconAlarmRealMapper.updateProEconAlarmReal(ar.getAlarmId(),ar.getAlarmPlan(),ar.getId());
         }else
         {
             ProEconAlarmReal ar=new ProEconAlarmReal();
 
-            ar.setId(StringUtils.getUUID());
+            ar.setId(String.valueOf(SnowflakeGenerator.generateId()));
             ar.setAlarmId(alarmId);
             ar.setAlarmPlan(planIds);
 
@@ -97,20 +97,26 @@ public class ProEconAlarmPlanServiceImpl extends ServiceImpl<ProEconAlarmPlanMap
 
         int result = 0;
 
-        if (StringUtils.notEmp(alarmRule) && null !=alarmRule.getTroubleMethod()) {
+        if (StringUtils.notEmp(alarmRule) && null !=alarmRule.getName()&& null !=alarmRule.getTypes()) {
 
-            List<ProEconAlarmPlan>  oldRulels = proEconAlarmPlanMapper.queryObject(alarmRule.getTroubleMethod());
-            if(!oldRulels.isEmpty())
+            if(StringUtils.notEmp(alarmRule.getId()))
             {
-                ProEconAlarmPlan   oldRule2=oldRulels.get(0);
-                if (oldRule2 != null) {
+                ProEconAlarmPlan oldRulel = proEconAlarmPlanMapper.selectById(alarmRule.getId());
+                if(StringUtils.notEmp(oldRulel))
+                {
 
-                    alarmRule.setId(oldRule2.getId());
-                    result = proEconAlarmPlanMapper.updateByAlertruleId(alarmRule);
+                    if (oldRulel != null) {
+                        alarmRule.setId(oldRulel.getId());
+                        result = proEconAlarmPlanMapper.updateByAlertruleId(alarmRule);
 
+                    }
                 }else
                 {
-                    alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                    if(StringUtils.empty(alarmRule.getId()))
+                    {
+                        alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                    }
+
                     result = saveAlertrule(alarmRule);
                 }
             }else
@@ -162,7 +168,7 @@ public class ProEconAlarmPlanServiceImpl extends ServiceImpl<ProEconAlarmPlanMap
             name=null;
         }
 
-        if(StringUtils.notEmp(name))
+        if(StringUtils.notEmp(types))
         {
             types=types;
         }else

+ 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);
+    }
+}