Browse Source

宁夏分公司代码修改

shilin 1 month ago
parent
commit
d3a01e7601

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

@@ -1,5 +1,6 @@
 package com.gyee.alarm.controller;
 
+import com.gyee.alarm.model.auto.ProBasicFeatureStat;
 import com.gyee.alarm.model.vo.*;
 import com.gyee.alarm.service.AlarmHistoryService;
 
@@ -319,6 +320,48 @@ public class AlarmHistoryController {
     }
 
 
+    @GetMapping(value = "/history/findCtFeatureStatByComponents")
+    @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 = "stationid", 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 = true, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "timeType", value = "秒、分、时(s,m,h)", required = false, dataType = "string", paramType = "query")
+    })
+    public List<ProBasicFeatureStat> findCtFeatureStatByComponents(
+
+            @RequestParam(value = "begin", required = true) String begin,
+            @RequestParam(value = "end", required = true) String end,
+            @RequestParam(value = "stationid", required = true) String stId,
+            @RequestParam(value = "modelId", required = false) String modelId,
+            @RequestParam(value = "components", required = true) String components,
+            @RequestParam(value = "deviceType", required = true) String deviceType,
+            @RequestParam(value = "alarmIds", required = true) 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<ProBasicFeatureStat> list = alarmHistoryService.findCtFeatureStatByComponents(stId,modelId, dtStart, dtEnd,components,deviceType,alarmIds,timeType);
+
+
+        return list;
+
+
+    }
+
 
     @GetMapping(value = "/history/findCtFeatureStatByWpId")
     @ApiOperation(value = "查询自定义报警类型、报警时长、报警次数", notes = "查询报警类型、报警时长、报警次数")

+ 8 - 17
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconShutdownEvent2Controller.java

@@ -44,6 +44,7 @@ public class ProEconShutdownEvent2Controller {
 
             @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "wtId", value = "设备编号", required = false, dataType = "string", paramType = "query"),
+            @ApiImplicitParam(name = "modelId", value = "型号", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "description", value = "故障描述 模糊查询", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "begin", value = "开始时间", required = true, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "end", value = "结束时间", required = true, dataType = "string", paramType = "query"),
@@ -52,30 +53,20 @@ public class ProEconShutdownEvent2Controller {
             @ApiImplicitParam(name = "type", value = "类型(gz 故障、wh 维护)", required = true, dataType = "string", paramType = "query")
 
     })
-    public AjaxResult queryshutdowneventlist(String wpId, String wtId,String description,String begin,String end,Integer pageNum, Integer pageSize,String type) {
+    public AjaxResult queryshutdowneventlist(String wpId, String wtId,String description,String begin,String end,Integer pageNum, Integer pageSize,String type,String modelId) {
 
-        IPage<ProEconShutdownEvent2> vos=new Page<>();
+        Map<String,Object> map=new HashMap();
 
 
-        if (StringUtils.notEmp(begin) && StringUtils.notEmp(end) && StringUtils.notEmp(pageNum) && StringUtils.notEmp(pageSize) && StringUtils.notEmp(type)) {
+        if (StringUtils.notEmp(begin) && StringUtils.notEmp(end) && StringUtils.notEmp(pageNum) && StringUtils.notEmp(pageSize) ) {
 
-            vos=proEconShutdownEvent2Service.queryShutdownEvent2(wpId, wtId, description, begin, end, pageNum, pageSize,type);
+            map=proEconShutdownEvent2Service.queryShutdownEvent2(wpId, wtId, description, begin, end, pageNum, pageSize,type,modelId);
         }
 
-        for(ProEconShutdownEvent2 vo:vos.getRecords())
-        {
-            if(StringUtils.notEmp(vo.getWindturbineId()) && CacheContext.wtmap.containsKey(vo.getWindturbineId()))
-            {
-                vo.setCode(CacheContext.wtmap.get(vo.getWindturbineId()).getNemCode());
-            }
-            if(StringUtils.notEmp(vo.getWindturbineId()) && CacheContext.wtmap.containsKey(vo.getWindturbineId()))
-            {
-                vo.setWindturbineName(CacheContext.wtmap.get(vo.getWindturbineId()).getName());
-            }
-        }
-        if (StringUtils.notEmp(vos)) {
 
-            return AjaxResult.successData(AjaxStatus.success.code, vos);
+        if (StringUtils.notEmp(map)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, map);
         } else {
             return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
         }

+ 27 - 0
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/AlarmTsMapper.java

@@ -290,6 +290,33 @@ public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
             "</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 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 stationid = #{stationid}",
+            "<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 ",
+            " order by components  ",
+            "</script>"})
+    List<ProBasicFeatureStat> findCtFeatureStatByComponents( @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,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>" ,

+ 21 - 0
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconShutdownEvent2Mapper.java

@@ -25,6 +25,27 @@ import java.util.List;
  */
 public interface ProEconShutdownEvent2Mapper extends BaseMapper<ProEconShutdownEvent2> {
 
+    @Select({"<script>",
+            "SELECT s.*  as times FROM pro_econ_shutdown_event2 as s,pro_econ_alarm_configuration as a " ,
+            "<where>" ,
+            "  s.warning_id=a.id and s.warning_id is not null   ",
+            "<if test='wpId != null'>",
+            "and a.station_id like #{wpId}",
+            "</if>",
+            "<if test='modelId != null'>",
+            "and  a.model_id=#{modelId}",
+            "</if>",
+            "<if test='type != null'>",
+            "and  s.stop_type_id=#{type}",
+            "</if>",
+            "and s.stop_time &gt;= #{begin}",
+            "and s.stop_time &lt;= #{end}",
+
+            "</where>",
+
+            "</script>"})
+    List<ProEconShutdownEvent2> queryShutdownEvent(@Param("wpId") String wpId, @Param("modelId") String modelId,@Param("begin")Date begin, @Param("end") Date end, @Param("type") String type);
+
 
     @Select({"<script>",
             "SELECT UPPER(t.name) as name,count(*)  as times FROM pro_econ_shutdown_event2 as s,pro_econ_alarm_configuration as a," +

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

@@ -370,7 +370,7 @@ public class AlarmHistoryService   {
             }
             if(CacheContext.alarmMap.containsKey(vo.getAlarmId()))
             {
-                vo.setComponents(CacheContext.alarmMap.get(vo.getAlarmId()).getDescription());
+                vo.setDescription(CacheContext.alarmMap.get(vo.getAlarmId()).getDescription());
             }
 
         }
@@ -898,6 +898,100 @@ public class AlarmHistoryService   {
     }
 
 
+    public List<ProBasicFeatureStat> findCtFeatureStatByComponents(String stationId,String modelId, Date startTime, Date endTime,String components,String deviceType,String alarmIds,String timeType) {
+        List<ProBasicFeatureStat> fsls = 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));
+        }
+        fsls = alarmTsMapper.findCtFeatureStatByComponents(startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId,deviceType);
+
+
+
+        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());
+            }
+
+            if(StringUtils.empty(fs.getTotalSeconds()))
+            {
+                fs.setTotalSeconds(0.0);
+            }
+            if(StringUtils.empty(fs.getAvgSeconds()))
+            {
+                fs.setAvgSeconds(0.0);
+            }
+            if(StringUtils.empty(fs.getMinSeconds()))
+            {
+                fs.setMinSeconds(0.0);
+            }
+            if(StringUtils.empty(fs.getMaxSeconds()))
+            {
+                fs.setMaxSeconds(0.0);
+            }
+            if(StringUtils.empty(fs.getTotal()))
+            {
+                fs.setTotal(0L);
+            }
+
+            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();
+                    fs.setTotalSeconds(times);
+                }else if(AlarmTime.M.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    fs.setTotalSeconds(times);
+                }
+            }else
+            {
+                double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                fs.setTotalSeconds(times);
+            }
+
+        }
+
+        return fsls;
+    }
+
     public List<AlarmStatVo> findCtFeatureStatByWpId(String modelId, Date startTime, Date endTime,String components,String deviceType,String alarmIds,String timeType) {
         List<AlarmStatVo> resultList = new ArrayList<>();
 

+ 5 - 2
alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconShutdownEvent2Service.java

@@ -7,6 +7,7 @@ import com.gyee.alarm.model.vo.ShutdownEventVo;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -18,9 +19,11 @@ import java.util.List;
  */
 public interface IProEconShutdownEvent2Service extends IService<ProEconShutdownEvent2> {
 
-    public IPage<ProEconShutdownEvent2> queryShutdownEvent2(String wpId, String wtId, String description, String begin, String end, Integer pageNum, Integer pageSize,String type) ;
+//    public IPage<ProEconShutdownEvent2> queryShutdownEvent2(String wpId, String wtId, String description, String begin, String end, Integer pageNum, Integer pageSize,String type,String modelId) ;
 
-    public List<ShutdownEventVo> queryShutdownEvent2ByType(String wpId, String modelId, Date begin, Date end);
+    public Map<String,Object> queryShutdownEvent2(String wpId, String wtId, String description, String begin, String end, Integer pageNum, Integer pageSize, String type, String modelId) ;
+
+        public List<ShutdownEventVo> queryShutdownEvent2ByType(String wpId, String modelId, Date begin, Date end);
 
 
     public List<ShutdownEventVo> queryShutdownEvent2ByDay(String wpId,String modelId,Date begin, Date end);

+ 91 - 24
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconShutdownEvent2ServiceImpl.java

@@ -4,6 +4,7 @@ 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.ProEconShutdownEvent2Mapper;
 import com.gyee.alarm.model.auto.ProEconShutdownEvent2;
 import com.gyee.alarm.model.vo.ShutdownEventVo;
@@ -16,8 +17,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * <p>
@@ -32,41 +32,108 @@ public class ProEconShutdownEvent2ServiceImpl extends ServiceImpl<ProEconShutdow
 
     @Resource
     private ProEconShutdownEvent2Mapper proEconShutdownEvent2Mapper;
-    public IPage<ProEconShutdownEvent2> queryShutdownEvent2(String wpId, String wtId,String description, String begin,String end, Integer pageNum, Integer pageSize,String type) {
-        QueryWrapper<ProEconShutdownEvent2> qw = new QueryWrapper<>();
-
-        if (StringUtils.notEmp(wpId)) {
-            qw.eq("winpowerstation_id", wpId);
-        }
-
-        if (StringUtils.notEmp(wtId)) {
-            qw.eq("windturbine_id", wtId);
-        }
-
-        if (StringUtils.notEmp(description)) {
-            qw.like("fault_view", "%"+description+"%");
-        }
+//    public IPage<ProEconShutdownEvent2> queryShutdownEvent2(String wpId, String wtId,String description, String begin,String end, Integer pageNum, Integer pageSize,String type,String modelId) {
+//        QueryWrapper<ProEconShutdownEvent2> qw = new QueryWrapper<>();
+//
+//        if (StringUtils.notEmp(wpId)) {
+//            qw.eq("winpowerstation_id", wpId);
+//        }
+//
+//        if (StringUtils.notEmp(wtId)) {
+//            qw.eq("windturbine_id", wtId);
+//        }
+//
+//        if (StringUtils.notEmp(modelId)) {
+//            qw.eq("windturbine_id", modelId);
+//        }
+//
+//        if (StringUtils.notEmp(description)) {
+//            qw.like("fault_view", "%"+description+"%");
+//        }
+//
+//        if (StringUtils.notEmp(begin) && StringUtils.notEmp(end)) {
+//            try {
+//                Date beginDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(begin);
+//                Date endDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(end);
+//                qw.ge("stop_time", beginDate);
+//                qw.le("stop_time", endDate);
+//            } catch (ParseException e) {
+//                e.printStackTrace();
+//            }
+//        }
+//        qw.eq("stop_type_id", type);
+//        qw.orderByDesc("stop_time");
+//
+//
+//        Page<ProEconShutdownEvent2> page = new Page<>(pageNum, pageSize);
+//        IPage<ProEconShutdownEvent2> InputPage = getBaseMapper().selectPage(page, qw);
+//
+//        return InputPage;
+//    }
+
+    public Map<String,Object> queryShutdownEvent2(String wpId, String wtId, String description, String begin, String end, Integer pageNum, Integer pageSize, String type, String modelId) {
+
+        Map<String,Object> map=new HashMap();
 
         if (StringUtils.notEmp(begin) && StringUtils.notEmp(end)) {
             try {
                 Date beginDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(begin);
                 Date endDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(end);
-                qw.ge("stop_time", beginDate);
-                qw.le("stop_time", endDate);
+                List<ProEconShutdownEvent2> ls=proEconShutdownEvent2Mapper.queryShutdownEvent( wpId, modelId, beginDate,  endDate,type);
+
+                map.put("total",ls.size());
+                List<ProEconShutdownEvent2> vos = paginate(ls, pageNum, pageSize);
+
+
+                for(ProEconShutdownEvent2 vo:vos)
+                {
+                    if(com.gyee.alarm.util.StringUtils.notEmp(vo.getWindturbineId()) && CacheContext.wtmap.containsKey(vo.getWindturbineId()))
+                    {
+                        vo.setCode(CacheContext.wtmap.get(vo.getWindturbineId()).getNemCode());
+
+                        vo.setWindturbineName(CacheContext.wtmap.get(vo.getWindturbineId()).getName());
+
+
+                    }
+                }
+                map.put("result",vos);
+
             } catch (ParseException e) {
                 e.printStackTrace();
             }
+        }else
+        {
+            map.put("total",0);
+            map.put("result",new ArrayList<ProEconShutdownEvent2>());
         }
-        qw.eq("stop_type_id", type);
-        qw.orderByDesc("stop_time");
 
 
-        Page<ProEconShutdownEvent2> page = new Page<>(pageNum, pageSize);
-        IPage<ProEconShutdownEvent2> InputPage = getBaseMapper().selectPage(page, qw);
-
-        return InputPage;
+        return map;
     }
 
+    /**
+     * 对集合进行分页
+     *
+     * @param <T>        集合中元素的类型
+     * @param list       要分页的集合
+     * @param pageNumber 页码,从1开始
+     * @param pageSize   每页显示的元素数量
+     * @return 返回指定页的数据
+     */
+    public static <T> List<T> paginate(List<T> list, int pageNumber, int pageSize) {
+        if (list == null || list.isEmpty() || pageNumber <= 0 || pageSize <= 0) {
+            return new ArrayList<>();
+        }
+
+        // 计算开始和结束的索引
+        int fromIndex = (pageNumber - 1) * pageSize;
+        if (fromIndex >= list.size()) {
+            return new ArrayList<>();
+        }
+
+        int toIndex = Math.min(fromIndex + pageSize, list.size());
+        return new ArrayList<>(list.subList(fromIndex, toIndex));
+    }
 
 
     public  List<ShutdownEventVo> queryShutdownEvent2ByType(String wpId, String modelId, Date begin, Date end)