Browse Source

优化后台计算算法

shilin 1 year ago
parent
commit
40999e42cb

+ 1 - 0
realtime/failurestatistics-server/src/main/java/com/gyee/failurestatistics/mapper/auto/ProEconFailureStatisticMainMapper.java

@@ -42,6 +42,7 @@ public interface ProEconFailureStatisticMainMapper extends BaseMapper<ProEconFai
 
     public List<EventVo> getCountMap(@Param(value = "beginDate")Date beginDate, @Param(value = "endDate")Date endDate);
 
+
     @Select(" select t.id,t.windturbine_id,t.warning_id,w.chinese_text warnDesc,t.stop_time,t.start_time,t.stop_hours,t.loss_power from pro_econ_shutdown_event t ,pro_econ_warning w,pro_basic_equipment b WHERE  " +
             "               cast(t.warning_id as integer )=w.edna_value and t.windturbine_id=b.id  and t.stop_time>=#{beginDate} and t.stop_time<=#{endDate}  order by t.windturbine_id,t.start_time desc  ")
 

+ 67 - 43
realtime/failurestatistics-server/src/main/java/com/gyee/failurestatistics/service/ParttemperatureService.java

@@ -35,13 +35,10 @@ public class ParttemperatureService {
     SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
 
-
     public void deleteParttemperaturemain(Date recodedate) {
         proEconPartTemperatureMainService.deleteParttemperaturemain(recodedate);
     }
 
-    
-
     public int insertParttemperaturemain(ProEconPartTemperatureMain po) {
 
         return proEconPartTemperatureMainService.insertParttemperaturemain(po);
@@ -76,7 +73,6 @@ public class ParttemperatureService {
                 // 初始化当日数据
                 statticsData(cal,endDate, beginDate, wtls,codeParentmap, codenamemap);
 
-
             }
 
         }
@@ -99,29 +95,35 @@ public class ParttemperatureService {
                 Map<String, Double> wdmap = getWdValue(wt, ContantXk.AI074, endDate, beginDate, map);
 
 
-                Map<String, Double> cLXSRZYW1map = getPartTargetValue(wt, ContantXk.AI042, endDate, beginDate, map,63,0);
-                Map<String, Double> cLXSRZYW2map = getPartTargetValue(wt, ContantXk.AI043, endDate, beginDate, map,63,0);
-                Map<String, Double> cLXRKYWmap = getPartTargetValue(wt, ContantXk.AI038, endDate, beginDate, map,63,0);
-                Map<String, Double> cLXYWmap = getPartTargetValue(wt, ContantXk.AI039, endDate, beginDate, map,60,0);
+                Map<String, Double> cLXSRZYW1map = getPartTargetValue(wt, ContantXk.AI042, endDate, beginDate, map,72,0);
+                Map<String, Double> cLXSRZYW2map = getPartTargetValue(wt, ContantXk.AI043, endDate, beginDate, map,72,0);
+                Map<String, Double> cLXRKYWmap = getPartTargetValue(wt, ContantXk.AI038, endDate, beginDate, map,72,0);
+                Map<String, Double> cLXYWmap = getPartTargetValue(wt, ContantXk.AI039, endDate, beginDate, map,72,0);
 
-                Map<String, Double> fDJZCWDAmap = getPartTargetValue(wt, ContantXk.AI092, endDate, beginDate, map,45,0);
-                Map<String, Double> fDJZCWDBmap = getPartTargetValue(wt, ContantXk.AI062, endDate, beginDate, map,45,0);
+                Map<String, Double> fDJZCWDAmap = getPartTargetValue(wt, ContantXk.AI092, endDate, beginDate, map,60,0);
+                Map<String, Double> fDJZCWDBmap = getPartTargetValue(wt, ContantXk.AI062, endDate, beginDate, map,60,0);
                 Map<String, Double> fDJUXYZWDmap = getPartTargetValue(wt, ContantXk.AI004, endDate, beginDate, map,110,0);
                 Map<String, Double> fDJVXYZWDmap = getPartTargetValue(wt, ContantXk.AI006, endDate, beginDate, map,110,0);
                 Map<String, Double> fDJWXYZWDmap = getPartTargetValue(wt, ContantXk.AI008, endDate, beginDate, map,110,0);
-                Map<String, Double> fDJLQFWDmap = getPartTargetValue(wt, ContantXk.AI059, endDate, beginDate, map,50,0);
+                Map<String, Double> fDJLQFWDmap = getPartTargetValue(wt, ContantXk.AI059, endDate, beginDate, map,60,0);
 
-                Map<String, Double> bJDRQWDmap = getPartTargetValue(wt, ContantXk.AI050, endDate, beginDate, map,35,0);
-                Map<String, Double> bJDRDYmap = getPartTargetValue(wt, ContantXk.AI076, endDate, beginDate, map,70,0);
-                Map<String, Double> bJDLQWDmap = getPartTargetValue(wt, ContantXk.AI020, endDate, beginDate, map,50,0);
-                Map<String, Double> bJDJWDmap = getPartTargetValue(wt, ContantXk.AI045, endDate, beginDate, map,50,0);
-                Map<String, Double> bJKZGWDmap = getPartTargetValue(wt, ContantXk.AI029, endDate, beginDate, map,45,0);
+                Map<String, Double> bJDRQWDmap = getPartTargetValue(wt, ContantXk.AI050, endDate, beginDate, map,45,0);
+                Map<String, Double> bJDRDYmap = getPartTargetValue(wt, ContantXk.AI076, endDate, beginDate, map,81,0);
+                Map<String, Double> bJDLQWDmap = getPartTargetValue(wt, ContantXk.AI020, endDate, beginDate, map,60,0);
+                Map<String, Double> bJDJWDmap = getPartTargetValue(wt, ContantXk.AI045, endDate, beginDate, map,60,0);
+                Map<String, Double> bJKZGWDmap = getPartTargetValue(wt, ContantXk.AI029, endDate, beginDate, map,48,0);
 
-                Map<String, Double> tDGWDmap = getPartTargetValue(wt, ContantXk.AI085, endDate, beginDate, map,35,0);
-                Map<String, Double> tDJGWDmap = getPartTargetValue(wt, ContantXk.AI099, endDate, beginDate, map,35,0);
+                Map<String, Double> tDGWDmap = getPartTargetValue(wt, ContantXk.AI085, endDate, beginDate, map,45,0);
+                Map<String, Double> tDJGWDmap = getPartTargetValue(wt, ContantXk.AI099, endDate, beginDate, map,45,0);
 
+                Map<String, Map<String, Integer>> pointmap =new TreeMap<>();
+
+                intial(pointmap,"0-20");
+                intial(pointmap,"21-40");
+                intial(pointmap,"41-60");
+                intial(pointmap,"61-80");
+                intial(pointmap,"81-100");
 
-                Map<String, Map<String, Integer>> pointmap =new HashMap<>();
                 if (!wdmap.isEmpty()  ) {
 
                     Set<Map.Entry<String, Double>> wdset = wdmap.entrySet();
@@ -220,39 +222,66 @@ public class ParttemperatureService {
         }
     }
 
+    private static void intial(Map<String, Map<String, Integer>> pointmap,String trange) {
+        Map<String, Integer> initalmap=new HashMap<>();
+        initalmap.put(ContantXk.AI042,0);
+        initalmap.put(ContantXk.AI043,0);
+        initalmap.put(ContantXk.AI038,0);
+        initalmap.put(ContantXk.AI039,0);
+        initalmap.put(ContantXk.AI092,0);
+        initalmap.put(ContantXk.AI062,0);
+        initalmap.put(ContantXk.AI004,0);
+        initalmap.put(ContantXk.AI006,0);
+        initalmap.put(ContantXk.AI008,0);
+        initalmap.put(ContantXk.AI059,0);
+        initalmap.put(ContantXk.AI050,0);
+        initalmap.put(ContantXk.AI076,0);
+        initalmap.put(ContantXk.AI020,0);
+        initalmap.put(ContantXk.AI045,0);
+        initalmap.put(ContantXk.AI029,0);
+        initalmap.put(ContantXk.AI085,0);
+        initalmap.put(ContantXk.AI099,0);
+        pointmap.put(trange,initalmap);
+    }
+
     private void setPointValues(String code,Map<String, Double> valuemap, Map<String, Map<String, Integer>> pointmap, Map.Entry<String, Double> wdentry) {
 
         if(StringUtils.notEmp(valuemap))
         {
-            String wdkey=getPoStringInfo(wdentry.getValue());
 
-            if(pointmap.containsKey(wdkey))
+            if(wdentry.getValue() <=100 && wdentry.getValue()>0)
             {
-                Map<String, Integer> pmap=pointmap.get(wdkey);
+                String wdkey=getPoStringInfo(wdentry.getValue());
 
-                if(pmap.containsKey(code))
+                if(pointmap.containsKey(wdkey))
                 {
-                    int num=pmap.get(code);
+                    Map<String, Integer> pmap=pointmap.get(wdkey);
+
+                    if(pmap.containsKey(code))
+                    {
+                        int num=pmap.get(code);
+
+                        num=num+setPointValue(wdentry.getKey(), valuemap);
+                        pmap.put(code, num);
+                        pointmap.put(wdkey, pmap);
+                    }else
+                    {
+                        int num=0;
+                        num=num+setPointValue(wdentry.getKey(), valuemap);
+                        pmap.put(code, num);
+                        pointmap.put(wdkey, pmap);
+                    }
 
-                    num=num+setPointValue(wdentry.getKey(), valuemap);
-                    pmap.put(code, num);
-                    pointmap.put(wdkey, pmap);
                 }else
                 {
+                    Map<String, Integer> pmap=new HashMap<>();
                     int num=0;
                     num=num+setPointValue(wdentry.getKey(), valuemap);
                     pmap.put(code, num);
                     pointmap.put(wdkey, pmap);
                 }
-
-            }else
-            {
-                Map<String, Integer> pmap=new HashMap<>();
-                int num=0;
-                num=num+setPointValue(wdentry.getKey(), valuemap);
-                pmap.put(code, num);
-                pointmap.put(wdkey, pmap);
             }
+
         }
 
     }
@@ -261,13 +290,8 @@ public class ParttemperatureService {
         StringBuilder sb = new StringBuilder();
         int num =0;
         int WDSTEP = 20;
-        if (value < 0) {
-            num = (int) value / WDSTEP;
-            sb.append((num - 1) * WDSTEP).append("-").append(num * WDSTEP);
-        } else {
-            num = (int) value / WDSTEP;
-            sb.append(num * WDSTEP).append("-").append((num + 1) * WDSTEP);
-        }
+        num = (int) value / WDSTEP;
+        sb.append(num * WDSTEP).append("-").append((num + 1) * WDSTEP);
         return String.valueOf(sb);
     }
 
@@ -391,7 +415,7 @@ public class ParttemperatureService {
 
     private Map<String, Double> getWdValue(ProBasicEquipment wt, String code, Date endDate, Date beginDate, Map<String, ProBasicEquipmentPoint> map) throws Exception {
 
-        Map<String, Double> resultmap = new TreeMap<String, Double>();
+        Map<String, Double> resultmap = new TreeMap<>();
 
         if (map.containsKey(code)) {
             ProBasicEquipmentPoint point = map.get(code);

+ 7 - 4
realtime/failurestatistics-server/src/test/java/FailuresTest.java

@@ -1,4 +1,7 @@
 import com.gyee.failurestatistics.FailurestatisticsMain;
+import com.gyee.failurestatistics.service.FailurestatisticsService;
+import com.gyee.failurestatistics.service.ParttemperatureService;
+import com.gyee.failurestatistics.util.SpringUtils;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
@@ -10,9 +13,9 @@ public class FailuresTest {
         SpringApplication.run(FailurestatisticsMain.class, args);
 
 
-////
-//        FailurestatisticsService failurestatisticsService= SpringUtils.getBean("failurestatisticsService");
 //
+        FailurestatisticsService failurestatisticsService= SpringUtils.getBean("failurestatisticsService");
+
 //        failurestatisticsService.deleteFailurestatisticsmain(DateUtils.truncate(new Date()));
 //        failurestatisticsService.saveFailurestatisticsmain();
 //
@@ -31,8 +34,8 @@ public class FailuresTest {
 //        partstatisticsService.savePartstatisticsmain();
 
 
-//        ParttemperatureService parttemperatureService= SpringUtils.getBean("parttemperatureService");
-//        parttemperatureService.saveParttemperaturestattics();
+        ParttemperatureService parttemperatureService= SpringUtils.getBean("parttemperatureService");
+        parttemperatureService.saveParttemperaturestattics();
 //        System.out.println("test!");
     }
 }