2 Incheckningar f1cf99bf84 ... 17b93eada5

Upphovsman SHA1 Meddelande Datum
  wangjiawen 17b93eada5 Merge branch 'master' of http://49.4.49.126:3000/Gyee_web/Gyee_sis_phone 4 år sedan
  wangjiawen c3b0172516 统一编码引入 4 år sedan

+ 18 - 14
src/main/java/com/gyee/frame/service/app/targetdetail/TargetdetailService.java

@@ -1,8 +1,5 @@
 package com.gyee.frame.service.app.targetdetail;
 
-import com.gyee.frame.common.conf.redis.CacheContext;
-import com.gyee.frame.model.auto.Weatherfh;
-import com.gyee.frame.model.auto.WeatherfhExample;
 import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.model.enumeration.Messagetype;
 import com.gyee.frame.netty.websocket.util.SocketToolService;
@@ -11,7 +8,8 @@ import com.gyee.frame.util.mongodb.IMongodbUtil;
 import com.gyee.frame.util.mongodb.MongodbUtilImpl;
 import org.springframework.stereotype.Service;
 
-import java.text.ParseException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -27,16 +25,18 @@ public class TargetdetailService extends SocketToolService {
     public static Map<String,String> targetdetail_target_pointMap = new HashMap<>();
     public static Map<String,String> targetdetail_curve_pointMap = new HashMap<>();
     public static Map<String,String> targetdetail_histogram_pointMap = new HashMap<>();
-
+    IMongodbUtil mongodb = new MongodbUtilImpl();
+    private double decimal(int num,double value){
+        return new BigDecimal(value).setScale(num, RoundingMode.HALF_EVEN).doubleValue();
+    }
     public void targetdetail_target() throws Exception {
         Set set = targetdetail_target_pointMap.keySet();
         Iterator<String>  it =  set.iterator();
-        IMongodbUtil mongodb = new MongodbUtilImpl();
         Map<String,Double> pointDataMap = new HashMap();
         while(it.hasNext()){
             String ip = it.next();
             PointData real=mongodb.getRealData(targetdetail_target_pointMap.get(ip));
-            double pointValueInDouble = real.getPointValueInDouble();
+            double pointValueInDouble =this.decimal(2,real.getPointValueInDouble()) ;
             pointDataMap.put(ip,pointValueInDouble);
         }
 
@@ -46,7 +46,6 @@ public class TargetdetailService extends SocketToolService {
     public void targetdetail_curve() throws Exception {
         Set set = targetdetail_curve_pointMap.keySet();
         Iterator<String>  it =  set.iterator();
-        IMongodbUtil mongodb = new MongodbUtilImpl();
         Map<String,List<PointData>> pointDataMap = new HashMap();
         while(it.hasNext()) {
             String ip = it.next();
@@ -57,10 +56,11 @@ public class TargetdetailService extends SocketToolService {
             Date beginTime = sdf1.parse(sdf1.format(nowTime));
             Long count = (endTime.getTime() - beginTime.getTime()) / 1000L / 3600L;
             List<PointData> ls = mongodb.getHistoryDatasSnap(targetdetail_curve_pointMap.get(ip),
-                    beginTime.getTime() / 1000, endTime.getTime() / 1000,
-                    (long) count, 3600L);
+                    beginTime.getTime() / 1000, endTime.getTime() / 1000 + 3600L,
+                    (long) count+1, 3600L);
             for (int i = 0; i < ls.size(); i++) {
                 ls.get(i).setPointTime(ls.get(i).getPointTime() - 3600);
+                ls.get(i).setPointValueInDouble(this.decimal(2,ls.get(i).getPointValueInDouble()));
             }
             if(ls.size()>0) {
                 ls.remove(0);
@@ -79,7 +79,6 @@ public class TargetdetailService extends SocketToolService {
     public void targetdetail_histogram() throws Exception {
         Set set = targetdetail_histogram_pointMap.keySet();
         Iterator<String>  it =  set.iterator();
-        IMongodbUtil mongodb = new MongodbUtilImpl();
         Map<String,List<PointData>> pointDataMap = new HashMap();
         while(it.hasNext()) {
             String ip = it.next();
@@ -89,12 +88,15 @@ public class TargetdetailService extends SocketToolService {
             Date beginTime = DateUtils.addDays(endTime, -7);
 //查看历史快照数据
             List<PointData> ls = mongodb.getHistoryDatasSnap(targetdetail_histogram_pointMap.get(ip),
-                    beginTime.getTime() / 1000, endTime.getTime() / 1000,
-                    7L, 3600 * 24L);
+                    beginTime.getTime() / 1000, endTime.getTime() / 1000 + 3600L*24,
+                    8L, 3600 * 24L);
             for (int i = 0; i < ls.size(); i++) {
                 ls.get(i).setPointTime(ls.get(i).getPointTime() - 24 * 3600);
+                ls.get(i).setPointValueInDouble(this.decimal(2,ls.get(i).getPointValueInDouble()));
+            }
+            if(ls.size()>0) {
+                ls.remove(0);
             }
-            ls.remove(0);
             pointDataMap.put(ip,ls);
         }
 
@@ -103,4 +105,6 @@ public class TargetdetailService extends SocketToolService {
         }*/
         this.pushToWeb("pageNumber_8","functionNumber_3",pointDataMap, Messagetype.MESSAGE);
     }
+
+
 }

+ 83 - 56
src/main/java/com/gyee/frame/service/app/windpowerstationdetail/WindpowerstationdetailService.java

@@ -1,16 +1,13 @@
 package com.gyee.frame.service.app.windpowerstationdetail;
 
-import cn.hutool.core.bean.BeanUtil;
 import com.gyee.frame.common.spring.Constant;
 import com.gyee.frame.common.spring.InitialRunner;
+import com.gyee.frame.common.spring.SpringUtils;
 import com.gyee.frame.model.auto.WindPowerstationTestingPoint;
 import com.gyee.frame.model.auto.Windpowerstation;
 import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.model.enumeration.Messagetype;
 import com.gyee.frame.netty.websocket.util.SocketToolService;
-import com.gyee.frame.util.BeanUtils;
-import com.gyee.frame.util.DateUtils;
-import com.gyee.frame.util.StringUtils;
 import com.gyee.frame.util.mongodb.IMongodbUtil;
 import com.gyee.frame.util.mongodb.MongodbUtilImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,8 +15,6 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -49,67 +44,99 @@ public class WindpowerstationdetailService extends SocketToolService {
         Map<String,Map<String,Double>> windpowerstationpointDataMap = new HashMap();
         IMongodbUtil mongodb = new MongodbUtilImpl();
 
-            for(Windpowerstation windpowerstation:wpls){
-                Map<String,Double> pointDataMap = new HashMap();
-                double rfdl = 99;
-                double aqts = 99;
-                double swdl = 99;
-                double ycfdl = 99;
-                double zjrl = 99;
-
-                try {
-                    //日发电量
-                    PointData rfdl_real = mongodb.getRealData(stationPointmap.get(windpowerstation.getId()).get(Constant.TPOINT_ALL_RFDL).getCode());
-                    rfdl = new BigDecimal(rfdl_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).doubleValue();
-                }catch (Exception e){
-                    System.out.println(e.getMessage());
-                }
+        for(Windpowerstation windpowerstation:wpls){
+            Map<String,Double> pointDataMap = new HashMap();
+            double rfdl = 0;
+            double aqts = 0;
+            double swdl = 0;
+            double ycfdl = 0;
+            double zjrl = 0;
+
+            try {
+                //日发电量
+                PointData rfdl_real = mongodb.getRealData(stationPointmap.get(windpowerstation.getId()).get(Constant.TPOINT_ALL_RFDL).getCode());
+                rfdl = new BigDecimal(rfdl_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).doubleValue();
+            }catch (Exception e){
+                System.out.println(e.getMessage());
+            }
 
-                try {
-                    //安全天数
-                    PointData aqts_real = mongodb.getRealData(stationPointmap.get(windpowerstation.getId()).get(Constant.TPOINT_AQTS).getCode());
-                    aqts = new BigDecimal(aqts_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).doubleValue();
-                }catch (Exception e){
-                    System.out.println(e.getMessage());
-                }
+            try {
+                //安全天数
+                PointData aqts_real = mongodb.getRealData(stationPointmap.get(windpowerstation.getId()).get(Constant.TPOINT_AQTS).getCode());
+                aqts = new BigDecimal(aqts_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).doubleValue();
+            }catch (Exception e){
+                System.out.println(e.getMessage());
+            }
 
 
-                try{
-                    //上网电量
-                    PointData swdl_real=mongodb.getRealData(stationPointmap.get(windpowerstation.getId()).get(Constant.TPOINT_WP_SWDL).getCode());
-                    swdl = new BigDecimal(swdl_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).doubleValue();
-                }catch (Exception e){
-                    System.out.println(e.getMessage());
-                }
+            try{
+                //上网电量
+                PointData swdl_real=mongodb.getRealData(stationPointmap.get(windpowerstation.getId()).get(Constant.TPOINT_WP_SWDL).getCode());
+                swdl = new BigDecimal(swdl_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).doubleValue();
+            }catch (Exception e){
+                System.out.println(e.getMessage());
+            }
 
-                //预测发电量
-                ycfdl = swdl+12;
-                //装机容量
-                try{
-                    //上网电量
-                    if(windpowerstation.getCapacity()==null){
-                        List<Windpowerstation> wps = InitialRunner.wpls;
-                        for(Windpowerstation windpowerstationinner:wps){
-                            zjrl = zjrl + windpowerstationinner.getCapacity();
-                        }
-                    }else{
-                        zjrl = windpowerstation.getCapacity();
+            //预测发电量
+            try{
+                if(windpowerstation.getId().equalsIgnoreCase("0")){
+                    List<Windpowerstation> wps = InitialRunner.wpls;
+                    for(Windpowerstation windpowerstationinner:wps){
+                        ycfdl = ycfdl + 12;
                     }
+                }else{
+                    ycfdl = 6;
+                }
+            }
+            catch(Exception e){
+                System.out.printf(e.getMessage());
+            }
 
-                }catch (Exception e){
-                    System.out.println(e.getMessage());
+            //装机容量
+            try{
+                if(windpowerstation.getCapacity()==null){
+                    List<Windpowerstation> wps = InitialRunner.wpls;
+                    for(Windpowerstation windpowerstationinner:wps){
+                        zjrl = zjrl + windpowerstationinner.getCapacity();
+                    }
+                }else{
+                    zjrl = windpowerstation.getCapacity();
                 }
-                pointDataMap.put("rfdl",rfdl);
-                pointDataMap.put("aqts",aqts);
-                pointDataMap.put("swdl",swdl);
-                pointDataMap.put("ycfdl",ycfdl);
-                pointDataMap.put("zjrl",zjrl);
-                windpowerstationpointDataMap.put(windpowerstation.getId(),pointDataMap);
+
+            }catch (Exception e){
+                System.out.println(e.getMessage());
             }
+            pointDataMap.put("rfdl",rfdl);
+            pointDataMap.put("aqts",aqts);
+            pointDataMap.put("swdl",swdl);
+            pointDataMap.put("ycfdl",ycfdl);
+            pointDataMap.put("zjrl",zjrl);
+            windpowerstationpointDataMap.put(windpowerstation.getId(),pointDataMap);
+        }
 
 
         this.pushToWeb("pageNumber_7","functionNumber_1",windpowerstationpointDataMap, Messagetype.MESSAGE);
     }
 
-
+/*    double  focastpower(String name){
+        ForecastwindspeedamendedService forecastwindspeedamendedService= SpringUtils.getBean("forecastwindspeedamendedService");
+
+        ForecastwindspeedamendedExample forecastwindspeedamendedExample=new ForecastwindspeedamendedExample();
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        Date begin=c.getTime();
+        c.add(Calendar.DAY_OF_MONTH,1);
+        Date end=c.getTime();
+        forecastwindspeedamendedExample.createCriteria().andWpidEqualTo(name).andRecodedateBetween(begin,end);
+        List<Forecastwindspeedamended> wtls = forecastwindspeedamendedService.selectByExample(forecastwindspeedamendedExample);
+        double tmp = 0;
+        for(Forecastwindspeedamended wt:wtls)
+        {
+            tmp = tmp + wt.getDaypower().doubleValue()+wt.getNightpower().doubleValue();
+        }
+        return tmp;
+    }*/
 }