Przeglądaj źródła

修正功率曲线数据推送

shilin 5 lat temu
rodzic
commit
8ac1df8ecb

+ 96 - 32
src/main/java/com/gyee/frame/service/app/index/IndexDetailService.java

@@ -90,44 +90,108 @@ public class IndexDetailService extends SocketToolService{
 
             Calendar cal = Calendar.getInstance();
             //理论功率
-            WindPowerStationTestingPoint2 ycgl1 = map.get(ycPoints[0]);
-            Date tempdate = null;
-            if (num > 0) {
-                List<PointData> datas = mongodb.getHistoryDatasSnap(ycgl1, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 3600L);
-
-                for (int j = 0; j < datas.size(); j++) {
-
-                    vos.get(j).setTime(datas.get(j).getPointTime() * 1000);
-                    vos.get(j).setValue1(StringUtils.round(datas.get(j).getPointValueInDouble(), 2));
-                    if (j == datas.size() - 1) {
-                        tempdate = new Date(datas.get(j).getPointTime() * 1000);
-                        cal.setTime(tempdate);
-                    }
-                }
-                int subresult = 0;
-                int total = 0;
-                if (length > datas.size()) {
-                    subresult = length - datas.size();
-                    if (subresult >= 8) {
-                        subresult = 8;
-                    }
-                    for (int i = 0; i < subresult; i++) {
-                        cal.add(Calendar.MINUTE, 30);
-                        vos.get(datas.size() + i).setTime(cal.getTime().getTime());
-                        WindPowerStationTestingPoint2 ycgl = map.get(ycPoints2[i]);
-                        vos.get(datas.size() + i).setValue1(StringUtils.round(mongodb.getRealData(ycgl).getPointValueInDouble(), 2));
-                    }
-                    total = datas.size() + subresult;
-                    subresult = length - (total);
+            if (!windpowerstation.getId().equals("0") && !windpowerstation.getId().equals("-1") && !windpowerstation.getId().equals("-2")) {
 
-                    if (subresult > 0)
+                // /////////////////////////////////////////////
+                WindPowerStationTestingPoint2 ycgl1 = map.get(ycPoints[0]);
+                Date tempdate = null;
+                if (num > 0) {
+                    List<PointData> datas = mongodb.getHistoryDatasSnap(ycgl1, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 3600L);
+
+                    for (int j = 0; j < datas.size(); j++) {
+
+                        vos.get(j).setTime(datas.get(j).getPointTime() * 1000);
+                        vos.get(j).setValue1(StringUtils.round(datas.get(j).getPointValueInDouble(), 2));
+                        if (j == datas.size() - 1) {
+                            tempdate = new Date(datas.get(j).getPointTime() * 1000);
+                            cal.setTime(tempdate);
+                        }
+                    }
+                    int subresult = 0;
+                    int total = 0;
+                    if (length > datas.size()) {
+                        subresult = length - datas.size();
+                        if (subresult >= 8) {
+                            subresult = 8;
+                        }
                         for (int i = 0; i < subresult; i++) {
                             cal.add(Calendar.MINUTE, 30);
-                            vos.get(total + i).setTime(cal.getTime().getTime());
-                            vos.get(total + i).setValue1(null);
+                            vos.get(datas.size() + i).setTime(cal.getTime().getTime());
+                            WindPowerStationTestingPoint2 ycgl = map.get(ycPoints2[i]);
+                            vos.get(datas.size() + i).setValue1(StringUtils.round(mongodb.getRealData(ycgl).getPointValueInDouble(), 2));
                         }
+                        total = datas.size() + subresult;
+                        subresult = length - (total);
+
+                        if (subresult > 0)
+                            for (int i = 0; i < subresult; i++) {
+                                cal.add(Calendar.MINUTE, 30);
+                                vos.get(total + i).setTime(cal.getTime().getTime());
+                                vos.get(total + i).setValue1(null);
+                            }
+                    }
+                    for (int k = 0; k < vos.size(); k++) {
+                        vos.get(k).setValue7(48.0);
+                    }
+                }
+            } else {
+                List<Windpowerstation> stations = new ArrayList<Windpowerstation>();
+                if (windpowerstation.getId().equals("") || windpowerstation.getId().equals("0")) {
+                    for (Windpowerstation station : InitialRunner.wpls) {
+                        stations.add(station);
+                    }
                 }
+                for (Windpowerstation station : stations) {
+
+                    Map<String, WindPowerStationTestingPoint2> wpmap = stationPointmap.get(station.getId());
+                    Date tempdate = null;
+                    if (num > 0) {
+                        WindPowerStationTestingPoint2 ycgl1 = wpmap.get(ycPoints[0]);
+
+                        if(null !=ycgl1)
+                        {
+                            List<PointData> datas = mongodb.getHistoryDatasSnap(ycgl1, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 3600L);
+                            if(datas.isEmpty())
+                            {
+                                continue;
+                            }
+                            for (int j = 0; j < datas.size(); j++) {
 
+                                vos.get(j).setTime(datas.get(j).getPointTime() * 1000);
+                                vos.get(j).setValue1(StringUtils.round(vos.get(j).getValue1() + datas.get(j).getPointValueInDouble(), 2));
+                                if (j == datas.size() - 1) {
+                                    tempdate = new Date(datas.get(j).getPointTime() * 1000);
+                                    cal.setTime(tempdate);
+                                }
+                            }
+                            int subresult = 0;
+                            int total = 0;
+                            if (length > datas.size()) {
+                                subresult = length - datas.size();
+                                if (subresult >= 8) {
+                                    subresult = 8;
+                                }
+                                for (int i = 0; i < subresult; i++) {
+                                    cal.add(Calendar.MINUTE, 30);
+                                    vos.get(datas.size() + i).setTime(cal.getTime().getTime());
+                                    WindPowerStationTestingPoint2 ycgl = wpmap.get(ycPoints2[i]);
+                                    vos.get(datas.size() + i).setValue1(StringUtils.round(vos.get(datas.size() + i).getValue1() + mongodb.getRealData(ycgl).getPointValueInDouble(), 2));
+                                }
+                                total = datas.size() + subresult;
+                                subresult = length - (total);
+
+                                if (subresult > 0)
+                                    for (int i = 0; i < subresult; i++) {
+                                        cal.add(Calendar.MINUTE, 30);
+                                        vos.get(total + i).setTime(cal.getTime().getTime());
+                                        vos.get(total + i).setValue1(null);
+                                    }
+                            }
+
+                        }
+
+                    }
+                }
             }
             
             WindPowerStationTestingPoint2 gdsjgl = InitialRunner.stationPointmap.get("-2").get(Constant.TPOINT_WP_SJGL);