Browse Source

修改mtbf和mttr数据源为shutdownevent

xieshengjie 3 years ago
parent
commit
fbca5efeae

+ 2 - 1
cache/src/main/resources/application.yml

@@ -9,8 +9,8 @@ spring:
     allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
   #redis集群
   redis:
+#    host: 49.4.50.80
     host: 10.155.32.4
-#    host: 127.0.0.1
     port: 6379
     timeout: 100000
     #    集群环境打开下面注释,单机不需要打开
@@ -36,6 +36,7 @@ spring:
     driver-class-name: oracle.jdbc.OracleDriver
     #外网
     url: jdbc:oracle:thin:@192.168.1.105:1521:gdnxfd
+#    url: jdbc:oracle:thin:@49.4.50.80:1521:gdnxfd
     #    url: jdbc:oracle:thin:@172.168.1.14:1521:gdnxfd
     username: nxfdprod
     password: gdnxfd123

+ 57 - 43
gradeevaluation/src/main/java/com/gyee/gradeevaluation/service/mttrmtbf/MTTRMTBFTaskService.java

@@ -250,24 +250,29 @@ public class MTTRMTBFTaskService {
             infodayQw.le("recorddate",monthLast);
             List<Windpowerinfoday> indodayList = windpowerinfodayService.list(infodayQw);
 
-            //取出所有故障的snapid
-            QueryWrapper<Faultsnap> snapQw = new QueryWrapper<>();
-            snapQw.eq("category1","FJ").eq("category2","GZ");
-            List<Faultsnap> snapList = faultsnapService.list(snapQw);
-            Map<BigDecimal,Faultsnap> snapMap = new HashMap<>();
-            snapList.stream().forEach(i->{
-                snapMap.put(i.getId(),i);
-            });
-
-            List<BigDecimal> snapids = faultsnapService.list(snapQw).stream().map(i -> i.getId()).collect(Collectors.toList());
-
-            //取出一月故障流水记录
-            QueryWrapper<Faulthistory> historyQw = new QueryWrapper<>();
-//            historyQw.like("faulttime",date);
-//            Date addDay = DateUtils.addDays(date, 1);
-            historyQw.ge("faulttime",monthFirst).le("faulttime",monthLast);
-            historyQw.in("snapid",snapids);
-            List<Faulthistory> historyList = faulthistoryService.list(historyQw);
+            QueryWrapper<Shutdownevent> shutdowneventQueryWrapper = new QueryWrapper<>();
+            Date addDay = DateUtils.addDays(date, 1);
+            shutdowneventQueryWrapper.ge("stoptime",monthFirst).lt("stoptime",addDay);
+            List<Shutdownevent> historyList = shutdowneventService.list(shutdowneventQueryWrapper);
+
+//            //取出所有故障的snapid
+//            QueryWrapper<Faultsnap> snapQw = new QueryWrapper<>();
+//            snapQw.eq("category1","FJ").eq("category2","GZ");
+//            List<Faultsnap> snapList = faultsnapService.list(snapQw);
+//            Map<BigDecimal,Faultsnap> snapMap = new HashMap<>();
+//            snapList.stream().forEach(i->{
+//                snapMap.put(i.getId(),i);
+//            });
+//
+//            List<BigDecimal> snapids = faultsnapService.list(snapQw).stream().map(i -> i.getId()).collect(Collectors.toList());
+//
+//            //取出一月故障流水记录
+//            QueryWrapper<Faulthistory> historyQw = new QueryWrapper<>();
+////            historyQw.like("faulttime",date);
+////            Date addDay = DateUtils.addDays(date, 1);
+//            historyQw.ge("faulttime",monthFirst).le("faulttime",monthLast);
+//            historyQw.in("snapid",snapids);
+//            List<Faulthistory> historyList = faulthistoryService.list(historyQw);
             double fdFaulttime = 0;
             long fdFaultcount = 0;
             double fdWthours = 0;
@@ -284,7 +289,7 @@ public class MTTRMTBFTaskService {
                 if (StringUtils.isNotNull(windpowerinfodayList)){
                     faulttime = windpowerinfodayList.stream().mapToDouble(Windpowerinfoday::getFaulttime).sum();
                 }
-                long faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getStationid().equals(windpowerstation.getId())).count();
+                long faultcount = historyList.stream().filter(i -> i.getWindpowerstationid().equals(windpowerstation.getId())).count();
                 zFaulttime += faulttime;
                 zFaultcount += faultcount;
                 zWthours += BigDecimalUtils.multiply(BigDecimalUtils.multiply(windpowerstation.getQuantity(),new BigDecimal(24),2),new BigDecimal(getDays(DateUtils.toDate1(monthFirst),DateUtils.toDate1(monthLast)).size()),2).doubleValue();
@@ -315,7 +320,7 @@ public class MTTRMTBFTaskService {
                 if (StringUtils.isNotNull(windpowerinfodayList)){
                     faulttime = windpowerinfodayList.stream().mapToDouble(Windpowerinfoday::getFaulttime).sum();
                 }
-                long faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getProjectid().equals(project.getId())).count();
+                long faultcount = historyList.stream().filter(i -> i.getProjectid().equals(project.getId())).count();
 
                 Wpmttrandmtbmonth w = new Wpmttrandmtbmonth();
                 w.setId(StringUtils.getUUID());
@@ -336,7 +341,8 @@ public class MTTRMTBFTaskService {
                 if (StringUtils.isNotNull(windpowerinfodayList)){
                     faulttime = windpowerinfodayList.stream().mapToDouble(Windpowerinfoday::getFaulttime).sum();
                 }
-                long faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getLineid().equals(line.getId())).count();
+//                long faultcount = historyList.stream().filter(i -> i.().equals(line.getId())).count();
+                long faultcount = historyList.stream().filter(i -> CacheContext.wmap.get(i.getWindturbineid()).getLineid().equals(line.getId())).count();
 
 
                 Wpmttrandmtbmonth w = new Wpmttrandmtbmonth();
@@ -367,7 +373,8 @@ public class MTTRMTBFTaskService {
                 if (first.isPresent()){
                     faulttime = first.get().getFaulttime();
                 }
-                double faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getWindturbineid().equals(windturbine.getId())).count();
+//                double faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getWindturbineid().equals(windturbine.getId())).count();
+                double faultcount = historyList.stream().filter(i -> i.getWindturbineid().equals(windturbine.getId())).count();
                 Wtmttrandmtbfmonth w = new Wtmttrandmtbfmonth();
                 w.setId(StringUtils.getUUID());
                 w.setWtid(windturbine.getId());
@@ -440,24 +447,30 @@ public class MTTRMTBFTaskService {
             infodayQw.le("recorddate",yearLast);
             List<Windpowerinfoday> indodayList = windpowerinfodayService.list(infodayQw);
 
-            //取出所有故障的snapid
-            QueryWrapper<Faultsnap> snapQw = new QueryWrapper<>();
-            snapQw.eq("category1","FJ").eq("category2","GZ");
-            List<Faultsnap> snapList = faultsnapService.list(snapQw);
-            Map<BigDecimal,Faultsnap> snapMap = new HashMap<>();
-            snapList.stream().forEach(i->{
-                snapMap.put(i.getId(),i);
-            });
 
-            List<BigDecimal> snapids = faultsnapService.list(snapQw).stream().map(i -> i.getId()).collect(Collectors.toList());
+            QueryWrapper<Shutdownevent> shutdowneventQueryWrapper = new QueryWrapper<>();
+            Date addDay = DateUtils.addDays(date, 1);
+            shutdowneventQueryWrapper.ge("stoptime",yearFirst).lt("stoptime",addDay);
+            List<Shutdownevent> historyList = shutdowneventService.list(shutdowneventQueryWrapper);
 
-            //取出一年故障流水记录
-            QueryWrapper<Faulthistory> historyQw = new QueryWrapper<>();
-//            historyQw.like("faulttime",date);
-//            Date addDay = DateUtils.addDays(date, 1);
-            historyQw.ge("faulttime",yearFirst).le("faulttime",yearLast);
-            historyQw.in("snapid",snapids);
-            List<Faulthistory> historyList = faulthistoryService.list(historyQw);
+//            //取出所有故障的snapid
+//            QueryWrapper<Faultsnap> snapQw = new QueryWrapper<>();
+//            snapQw.eq("category1","FJ").eq("category2","GZ");
+//            List<Faultsnap> snapList = faultsnapService.list(snapQw);
+//            Map<BigDecimal,Faultsnap> snapMap = new HashMap<>();
+//            snapList.stream().forEach(i->{
+//                snapMap.put(i.getId(),i);
+//            });
+//
+//            List<BigDecimal> snapids = faultsnapService.list(snapQw).stream().map(i -> i.getId()).collect(Collectors.toList());
+//
+//            //取出一年故障流水记录
+//            QueryWrapper<Faulthistory> historyQw = new QueryWrapper<>();
+////            historyQw.like("faulttime",date);
+////            Date addDay = DateUtils.addDays(date, 1);
+//            historyQw.ge("faulttime",yearFirst).le("faulttime",yearLast);
+//            historyQw.in("snapid",snapids);
+//            List<Faulthistory> historyList = faulthistoryService.list(historyQw);
             double fdFaulttime = 0;
             long fdFaultcount = 0;
             double fdWthours = 0;
@@ -476,7 +489,7 @@ public class MTTRMTBFTaskService {
                 if (StringUtils.isNotNull(windpowerinfodayList)){
                     faulttime = windpowerinfodayList.stream().mapToDouble(Windpowerinfoday::getFaulttime).sum();
                 }
-                long faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getStationid().equals(windpowerstation.getId())).count();
+                long faultcount = historyList.stream().filter(i -> i.getWindpowerstationid().equals(windpowerstation.getId())).count();
                 zFaulttime += faulttime;
                 zFaultcount += faultcount;
                 zWthours += BigDecimalUtils.multiply(BigDecimalUtils.multiply(windpowerstation.getQuantity(),new BigDecimal(24),2),new BigDecimal(size),2).doubleValue();
@@ -506,7 +519,7 @@ public class MTTRMTBFTaskService {
                 if (StringUtils.isNotNull(windpowerinfodayList)){
                     faulttime = windpowerinfodayList.stream().mapToDouble(Windpowerinfoday::getFaulttime).sum();
                 }
-                long faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getProjectid().equals(project.getId())).count();
+                long faultcount = historyList.stream().filter(i -> i.getProjectid().equals(project.getId())).count();
 
                 Wpmttrandmtbfyear w = new Wpmttrandmtbfyear();
                 w.setId(StringUtils.getUUID());
@@ -526,8 +539,8 @@ public class MTTRMTBFTaskService {
                 if (StringUtils.isNotNull(windpowerinfodayList)){
                     faulttime = windpowerinfodayList.stream().mapToDouble(Windpowerinfoday::getFaulttime).sum();
                 }
-                long faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getLineid().equals(line.getId())).count();
-
+//                long faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getLineid().equals(line.getId())).count();
+                long faultcount = historyList.stream().filter(i -> CacheContext.wmap.get(i.getWindturbineid()).getLineid().equals(line.getId())).count();
 
                 Wpmttrandmtbfyear w = new Wpmttrandmtbfyear();
                 w.setId(StringUtils.getUUID());
@@ -558,7 +571,8 @@ public class MTTRMTBFTaskService {
                 if (first.isPresent()){
                     faulttime = first.get().getFaulttime();
                 }
-                double faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getWindturbineid().equals(windturbine.getId())).count();
+//                double faultcount = historyList.stream().filter(i -> snapMap.get(i.getSnapid()).getWindturbineid().equals(windturbine.getId())).count();
+                double faultcount = historyList.stream().filter(i -> i.getWindturbineid().equals(windturbine.getId())).count();
                 Wtmttrandmtbfyear w = new Wtmttrandmtbfyear();
                 w.setId(StringUtils.getUUID());
                 w.setWtid(windturbine.getId());

+ 1 - 1
gradeevaluation/src/main/java/com/gyee/gradeevaluation/util/DateUtils.java

@@ -478,7 +478,7 @@ public class DateUtils {
         int month = getMonth(date);
         int year = getYear(date);
         calendar.set(Calendar.YEAR, year);
-        calendar.set(Calendar.MONTH, month);
+        calendar.set(Calendar.MONTH, month-1);
         calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
         Date currYearFirst = calendar.getTime();
         return currYearFirst;

+ 5 - 4
gradeevaluation/src/test/java/com/gyee/gradeevaluation/GradeevaluationApplicationTests.java

@@ -47,10 +47,11 @@ class GradeevaluationApplicationTests {
 
 //        specificService.saveWindpowerspecificinfoday("2021-08-01","2021-08-04");
 //        quartService.saveWindturbineinfodaytop3("2021-10-01","2021-10-13");
-        quartService.saveEvaluationSub("2021-10-01","2021-10-13");
-        quartService.saveEvaluationMain("2021-10-01","2021-10-13");
-//        mttrmtbfTaskService.saveWpMttrAndMtbMonth(date,date);
-//        mttrmtbfTaskService.saveWpMttrAndMtbfYear(date,date);
+//        quartService.saveEvaluationSub("2021-10-01","2021-10-13");
+//        quartService.saveEvaluationMain("2021-10-01","2021-10-13");
+        mttrmtbfTaskService.saveWpMttrAndMtbfDay(date,date);
+        mttrmtbfTaskService.saveWpMttrAndMtbMonth(date,date);
+        mttrmtbfTaskService.saveWpMttrAndMtbfYear(date,date);
     }
 
     @Test