Browse Source

代码修改

wangchangsheng 2 years ago
parent
commit
9bedbc32a5

+ 28 - 3
web/monitor-web-sxjn/src/main/java/com/gyee/frame/controller/peranalysis/PointPerSis.java

@@ -2,6 +2,7 @@ package com.gyee.frame.controller.peranalysis;
 
 import com.gyee.frame.common.conf.AjaxStatus;
 import com.gyee.frame.common.domain.AjaxResult;
+import com.gyee.frame.model.auto.Freedom;
 import com.gyee.frame.model.custom.PointPerSisVo;
 import com.gyee.frame.service.peranalysis.PointPerSisService;
 import io.swagger.annotations.Api;
@@ -22,7 +23,7 @@ public class PointPerSis {
 
     /**
      * 测点曲线分析
-     * @param station
+     * @param wtid
      * @param beginDate
      * @param endDate
      * @param interval
@@ -32,7 +33,7 @@ public class PointPerSis {
     @CrossOrigin(origins = "*", maxAge = 3600)
     @GetMapping(value = "/getPointPerSisList")
     public AjaxResult getPointPerSisList(
-            @RequestParam(value = "station",required = true)String station,
+            @RequestParam(value = "wtid",required = true)String wtid,
             @RequestParam(value = "beginDate",required = true)Long beginDate,
             @RequestParam(value = "endDate",required = true)Long endDate,
             @RequestParam(value = "interval",required = true)Integer interval,
@@ -40,7 +41,31 @@ public class PointPerSis {
 
     ){
         try {
-            List<PointPerSisVo> list =  pointPerSisService.freedomList(station,beginDate,endDate,interval,uniformcodes);
+            List<PointPerSisVo> list =  pointPerSisService.freedomList(wtid,beginDate,endDate,interval,uniformcodes);
+
+            if (null != list){
+                return AjaxResult.successData(AjaxStatus.success.code, list);
+            }else {
+                return AjaxResult.successData(AjaxStatus.error.code, "操作失败");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.successData(AjaxStatus.error.code, "系统异常");
+        }
+    }
+
+
+    /**
+     * 获取测点
+     * @return
+     */
+    @CrossOrigin(origins = "*", maxAge = 3600)
+    @GetMapping(value = "/getpoints")
+    public AjaxResult getpoints(
+
+    ){
+        try {
+            List<Freedom>  list =  pointPerSisService.points();
 
             if (null != list){
                 return AjaxResult.successData(AjaxStatus.success.code, list);

+ 0 - 11
web/monitor-web-sxjn/src/main/java/com/gyee/frame/model/custom/InitVo.java

@@ -1,11 +0,0 @@
-package com.gyee.frame.model.custom;
-
-import lombok.Data;
-
-@Data
-public class InitVo {
-
-    private String wtid;
-
-    private String wtname;
-}

+ 9 - 0
web/monitor-web-sxjn/src/main/java/com/gyee/frame/model/custom/PointPerSisVo.java

@@ -2,6 +2,15 @@ package com.gyee.frame.model.custom;
 
 import lombok.Data;
 
+import java.util.List;
+import java.util.Map;
+
 @Data
 public class PointPerSisVo {
+
+    private String wtid;
+
+    private Map<String, List<PointData>> pointDataMap;
+
+
 }

+ 10 - 14
web/monitor-web-sxjn/src/main/java/com/gyee/frame/service/peranalysis/ElePerAnalysisService.java

@@ -8,8 +8,8 @@ import com.gyee.frame.model.auto.ProjectplanPG;
 import com.gyee.frame.model.auto.Windpowerinfoday;
 import com.gyee.frame.model.auto.WindpowerstationPG;
 import com.gyee.frame.model.auto.Windpowerstationpointnew;
+import com.gyee.frame.model.custom.DNAVal;
 import com.gyee.frame.model.custom.ElePerAnalysisVo;
-import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.service.*;
 import com.gyee.frame.util.IRealTimeDataBaseUtil;
 import com.gyee.frame.util.RealTimeDataBaseFactory;
@@ -65,31 +65,27 @@ public class ElePerAnalysisService {
             ElePerAnalysisVo vo = new ElePerAnalysisVo();
             vo.setId(wp.getId());
             vo.setName(wp.getName());
-
+            // 获得测点
+            String[] points = new String[2];
             if (null != stringMapMap) {
-                String fs = stringMapMap.get("YPJFS").getCode();//月平局风速
+                points[0]= stringMapMap.get("YPJFS").getCode();//月平局风速
                 calendar.setTime(endDate);
                 calendar.add(Calendar.SECOND, -2);
                 long newend = calendar.getTimeInMillis() / 1000;
-                calendar.add(Calendar.SECOND, -1);
-                long newbing = calendar.getTimeInMillis() / 1000;
-                List<PointData> fss = realApiUtil.getHistoryDatasSnap(fs, newbing, newend, 1l, 1L);
-                String yfdl = stringMapMap.get("YFDL").getCode();//发电量
-                List<PointData> yfdls = realApiUtil.getHistoryDatasSnap(yfdl, newbing, newend, 1l, 1L);
-                if (!fss.isEmpty() && !yfdl.isEmpty()) {
-                    vo.setFs(fss.get(0).getPointValueInDouble());
-                    vo.setGeneration(yfdls.get(0).getPointValueInDouble());
+                points[0] = stringMapMap.get("YFDL").getCode();//发电量
+
+                DNAVal[] jkvalues = realApiUtil.getHistMatrix(points, newend);
+                if (null != jkvalues && jkvalues.length>0) {
+                    vo.setFs(jkvalues[0].DValue);
+                    vo.setGeneration(jkvalues[1].DValue);
                 }
                 vo.setGeneratingcapacity(Double.valueOf(pgList.get(0).getGeneratingcapacity()));
             }
 
             List<Windpowerinfoday> windpowerinfodayList = windpowerinfodayService.getWindpowerinfodayList2(station, beginDate, endDate);
             Double runhourssum = windpowerinfodayList.stream().filter(n -> null!=n.getRunhours()).mapToDouble(Windpowerinfoday::getRunhours).sum();
-//            Double runhourssum = windpowerinfodayList.stream().collect(Collectors.summingDouble(Windpowerinfoday::getRunhours));
             Double stophourssum = windpowerinfodayList.stream().filter(n->null!= n.getStophours()).mapToDouble(Windpowerinfoday::getStophours).sum();
-//            Double stophourssum = windpowerinfodayList.stream().collect(Collectors.summingDouble(Windpowerinfoday::getStophours));
             Double faulthourssum = windpowerinfodayList.stream().filter(n->null!= n.getFaulthours()).mapToDouble(Windpowerinfoday::getFaulthours).sum();
-//            Double faulthourssum = windpowerinfodayList.stream().collect(Collectors.summingDouble(Windpowerinfoday::getFaulthours));
             vo.setRunhours(runhourssum);
             vo.setStophours(stophourssum);
             vo.setFaulthours(faulthourssum);

+ 21 - 37
web/monitor-web-sxjn/src/main/java/com/gyee/frame/service/peranalysis/PointPerSisService.java

@@ -3,10 +3,8 @@ package com.gyee.frame.service.peranalysis;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.gyee.frame.common.cache.IGlobalCache;
-import com.gyee.frame.common.spring.InitialRunner;
 import com.gyee.frame.model.auto.Freedom;
 import com.gyee.frame.model.auto.Windpowerstationpointnew;
-import com.gyee.frame.model.custom.InitVo;
 import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.model.custom.PointPerSisVo;
 import com.gyee.frame.util.*;
@@ -27,54 +25,40 @@ public class PointPerSisService {
 
     IRealTimeDataBaseUtil realApiUtil = RealTimeDataBaseFactory.createRealTimeDataBase();
 
-    public List<PointPerSisVo> freedomList(String station, Long beginDate, Long endDate, Integer interval, String uniformcodes) throws Exception {
+    public List<PointPerSisVo> freedomList(String wtid, Long beginDate, Long endDate, Integer interval, String uniformcodes) throws Exception {
         List<PointPerSisVo> vos = new ArrayList<>();
 
         {
-            String[] codes = uniformcodes.split(",");
 
-            String wpString = (String) (globalCache.get(station));
+            String[] wtids = wtid.split(",");
+            for (String w : wtids) {
+                String[] codes = uniformcodes.split(",");
 
-            Map<String, Windpowerstationpointnew> windturbinetestingpointaiMap = JSONObject.parseObject(wpString, new TypeReference<Map<String, Windpowerstationpointnew>>() {
-            });
+                String wpString = (String) (globalCache.get(w));
 
+                Map<String, Windpowerstationpointnew> windturbinetestingpointaiMap = JSONObject.parseObject(wpString, new TypeReference<Map<String, Windpowerstationpointnew>>() {
+                });
 
-            List<Object> resultList = new ArrayList<>();
+                PointPerSisVo vo = new PointPerSisVo();
+                vo.setWtid(w);
 
-            Map<String, List<PointData>> pointDataMap = new HashMap<>();
-            for (int i = 0; i < codes.length; i++) {
-                Windpowerstationpointnew windturbinetestingpointai = windturbinetestingpointaiMap.get(StringUtils.upperCase(codes[i]));
-                if (StringUtils.isNotNull(windturbinetestingpointai)) {
-                    try {
-                        List<PointData> historyDatas = realApiUtil.getHistoryDatasSnap(windturbinetestingpointai, beginDate / 1000, endDate / 1000, null, interval * 60l);
-                        pointDataMap.put(codes[i], historyDatas);
-                    } catch (Exception e) {
-                        e.printStackTrace();
+                Map<String, List<PointData>> pointDataMap = new HashMap<>();
+                for (int i = 0; i < codes.length; i++) {
+                    Windpowerstationpointnew windturbinetestingpointai = windturbinetestingpointaiMap.get(StringUtils.upperCase(codes[i]));
+                    if (StringUtils.isNotNull(windturbinetestingpointai)) {
+                        try {
+                            List<PointData> historyDatas = realApiUtil.getHistoryDatasSnap(windturbinetestingpointai, beginDate / 1000, endDate / 1000, null, interval * 60l);
+                            pointDataMap.put(codes[i], historyDatas);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
                     }
                 }
 
+                vo.setPointDataMap(pointDataMap);
+                vos.add(vo);
             }
 
-            List<PointData> pointData = pointDataMap.get(codes[0]);
-            if (StringUtils.isNotNull(pointData)) {
-                for (int i = 0; i < pointData.size(); i++) {
-                    InitVo initVo = new InitVo();
-                    initVo.setWtid(station);
-                    initVo.setWtname(InitialRunner.wtmap.get(station).getCode());
-                    LinkedHashMap addMap = new LinkedHashMap();
-                    LinkedHashMap addValMap = new LinkedHashMap();
-
-                    addMap.put("time", Class.forName("java.lang.Long"));
-                    addValMap.put("time", pointData.get(i).getPointTime() * 1000);
-
-                    for (int j = 0; j < codes.length; j++) {
-                        addMap.put(StringUtils.upperCase(codes[j]), Class.forName("java.lang.Double"));
-                        addValMap.put(StringUtils.upperCase(codes[j]), DoubleUtils.keepPrecision(pointDataMap.get(codes[j]).get(i).getPointValueInDouble(), 2));
-                    }
-                    Object o = new ClassUtil().dynamicClass(initVo, addMap, addValMap);
-                    resultList.add(o);
-                }
-            }
             return vos;
 
         }

+ 0 - 62
web/monitor-web-sxjn/src/main/java/com/gyee/frame/util/ClassUtil.java

@@ -1,62 +0,0 @@
-package com.gyee.frame.util;
-
-
-import com.gyee.common.vo.analysis.DynamicBean;
-import java.beans.BeanInfo;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Set;
-
-/**
- * @ClassName : ClassUtil
- * @Author : xieshengjie
- * @Date: 2021/3/8 17:16
- * @Description : 动态添加属性
- */
-public class ClassUtil {
-    /**
-     *
-     * @param object   旧的对象带值
-     * @param addMap   动态需要添加的属性和属性类型
-     * @param addValMap  动态需要添加的属性和属性值
-     * @return  新的对象
-     * @throws Exception
-     */
-    public static Object dynamicClass(Object object, LinkedHashMap addMap, LinkedHashMap addValMap) throws Exception {
-        LinkedHashMap returnMap = new LinkedHashMap();
-        LinkedHashMap typeMap = new LinkedHashMap();
-
-
-        Class<?> type = object.getClass();
-        BeanInfo beanInfo = Introspector.getBeanInfo(type);
-        PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
-        for (int i = 0; i < propertyDescriptors.length; i++) {
-            PropertyDescriptor descriptor = propertyDescriptors[i];
-            String propertyName = descriptor.getName();
-            if (!propertyName.equals("class")) {
-                Method readMethod = descriptor.getReadMethod();
-                Object result = readMethod.invoke(object);
-                //可以判断为 NULL不赋值
-                returnMap.put(propertyName, result);
-                typeMap.put(propertyName, descriptor.getPropertyType());
-            }
-        }
-
-        returnMap.putAll(addValMap);
-        typeMap.putAll(addMap);
-        //map转换成实体对象
-        DynamicBean bean = new DynamicBean(typeMap);
-        //赋值
-        Set keys = typeMap.keySet();
-        for (Iterator it = keys.iterator(); it.hasNext(); ) {
-            String key = (String) it.next();
-            bean.setValue(key, returnMap.get(key));
-        }
-        Object obj = bean.getObject();
-        return obj;
-    }
-
-}