瀏覽代碼

矩阵监视

shilin 4 年之前
父節點
當前提交
d3400ad3f7

+ 41 - 0
src/main/java/com/gyee/frame/common/quartz/task/monitor_target_matrixMonitor.java

@@ -0,0 +1,41 @@
+package com.gyee.frame.common.quartz.task;
+
+import com.gyee.frame.service.monitor.MonitorService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ *
+ */
+@Component("monitor_target_matrixMonitor")
+public class monitor_target_matrixMonitor {
+
+	@Autowired
+    private MonitorService monitorService;
+    /**
+     * 无参的任务
+     * @throws Exception 
+     */
+    public void monitor_target_matrixMonitor() throws Exception {
+        monitorService.monitor_target_matrixMonitor();//调用list方法完成对 key :"weatherProphet_1" ,路径"weather/weatherProphet_1"的推送
+        //System.out.println("我已执行");
+    }   
+       
+
+    /**
+     * 有参任务
+     * 目前仅执行常见的数据类型  Integer Long  带L  string  带 ''  bool Double 带 d
+     * @param a
+     * @param b
+     * 
+     */
+    public void runTask2(Integer a,Long b,String c,Boolean d,Double e)
+    {
+    	//List<TsysUser> list=  tsysUserMapper.selectByExample(new TsysUserExample());
+    	//System.err.println("用户查询num:"+list.size());
+        System.out.println("正在执行定时任务,带多个参数的方法"+a+"   "+b+" "+c+"  "+d+" "+e+"执行时间:"+new Date().toLocaleString());
+    }
+
+}

+ 47 - 0
src/main/java/com/gyee/frame/common/spring/InitialRunner.java

@@ -42,6 +42,10 @@ public class InitialRunner implements CommandLineRunner {
     public static List<Windturbine> wtls = new ArrayList<Windturbine>(); // 风电机LIST集合
     public static List<Line> lnls = new ArrayList<Line>(); // 线路LIST集合
 
+    public static Map<String, List<Windturbine>> wp_wtmap = new HashMap<String, List<Windturbine>>();
+    public static Map<String, List<Windturbine>> pj_wtmap = new HashMap<String, List<Windturbine>>();
+    public static Map<String, List<Windturbine>> ln_wtmap = new HashMap<String, List<Windturbine>>();
+
     public static Map<String, Map<String, WindTurbineTestingPointAi>> wtpAimap = new HashMap<String, Map<String, WindTurbineTestingPointAi>>();// 风电机测点AI表
     public static Map<String, Map<String, WindPowerstationTestingPoint>> stationPointmap = new HashMap<String, Map<String, WindPowerstationTestingPoint>>();//场站测点
     @Override
@@ -80,6 +84,49 @@ public class InitialRunner implements CommandLineRunner {
         wtls= windturbineService.selectByExample(windturbineExample);
 
 
+        if(wtls!=null && !wtls.isEmpty()){
+
+            for(int i=0;i<wtls.size();i++){
+
+                Windturbine point=wtls.get(i);
+                if(wp_wtmap.containsKey(point.getWindpowerstationid())){
+                    List<Windturbine> ls=wp_wtmap.get(point.getWindpowerstationid());
+                    ls.add(point);
+                    wp_wtmap.put(point.getWindpowerstationid(),ls);
+                }
+                else{
+                    List<Windturbine> ls =new ArrayList();
+                    ls.add(point);
+                    wp_wtmap.put(point.getWindpowerstationid(),ls);
+                }
+
+                if(pj_wtmap.containsKey(point.getProjectid())){
+                    List<Windturbine> ls=pj_wtmap.get(point.getProjectid());
+                    ls.add(point);
+                    pj_wtmap.put(point.getProjectid(),ls);
+                }
+                else{
+                    List<Windturbine> ls =new ArrayList();
+                    ls.add(point);
+                    pj_wtmap.put(point.getProjectid(),ls);
+                }
+
+
+                if(ln_wtmap.containsKey(point.getLineid())){
+                    List<Windturbine> ls=ln_wtmap.get(point.getLineid());
+                    ls.add(point);
+                    ln_wtmap.put(point.getLineid(),ls);
+                }
+                else{
+                    List<Windturbine> ls =new ArrayList();
+                    ls.add(point);
+                    ln_wtmap.put(point.getLineid(),ls);
+                }
+
+            }
+        }
+
+
         WindPowerstationTestingPointExample windPowerstationTestingPointExample=new WindPowerstationTestingPointExample();
         windPowerstationTestingPointExample.createCriteria().getAllCriteria();
         List<WindPowerstationTestingPoint> wpPointlist= windPowerstationTestingPointService.selectByExample(windPowerstationTestingPointExample);

+ 66 - 0
src/main/java/com/gyee/frame/controller/gen/GyeeMatrixController.java

@@ -0,0 +1,66 @@
+package com.gyee.frame.controller.gen;
+
+import com.gyee.frame.common.base.BaseController;
+import com.gyee.frame.common.domain.AjaxResult;
+import com.gyee.frame.common.spring.InitialRunner;
+import com.gyee.frame.model.auto.Project;
+import com.gyee.frame.model.auto.Windpowerstation;
+import com.gyee.frame.util.StringUtils;
+import io.swagger.annotations.Api;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Controller
+@RequestMapping("GyeeMatrixController")
+@Api(value = "")
+public class GyeeMatrixController extends BaseController{
+	
+
+	@GetMapping("/GyeeMatrixList")
+	@ResponseBody
+	public AjaxResult getMatrixList(String keyid){
+
+		List<Map<String,String>> ls=new ArrayList<>();
+		if(StringUtils.isNotNull(keyid))
+		{
+			if(keyid.equals("0"))
+			{
+				Map<String,String> map=new HashMap<>();
+				for(Windpowerstation wp: InitialRunner.wpls)
+				{
+					map.put("id",wp.getId());
+					map.put("name",wp.getName());
+					ls.add(map);
+				}
+			}else {
+				Map<String,String> map=new HashMap<>();
+				for(Project pj: InitialRunner.pjls)
+				{
+					if(pj.getWindpowerstationid().equals(keyid))
+					{
+						map.put("id",pj.getId());
+						map.put("name",pj.getName());
+						ls.add(map);
+					}
+				}
+			}
+		}
+
+		if(ls.isEmpty()){
+			return AjaxResult.error(500, "无法获取权限");
+			
+		}else{
+			return AjaxResult.successData(200, ls);
+		}
+	}
+	
+
+	
+}

+ 53 - 0
src/main/java/com/gyee/frame/model/custom/MatrixVo.java

@@ -0,0 +1,53 @@
+/**
+ * <p>文件名:	DataVo.java</p>
+ * <p>版权:  </p>
+ * <p>公司:	company Co., Ltd.</p>
+ * <p>项目名:lnly</p>
+ * <p>作者:	刘厦(liusha.information@gmail.com)</p>
+ */
+package com.gyee.frame.model.custom;
+
+/**
+ *
+ */
+
+public class MatrixVo {
+
+    private String id;
+    private String icon;
+    private Double speed;
+    private Double power;
+
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public Double getSpeed() {
+        return speed;
+    }
+
+    public void setSpeed(Double speed) {
+        this.speed = speed;
+    }
+
+    public Double getPower() {
+        return power;
+    }
+
+    public void setPower(Double power) {
+        this.power = power;
+    }
+}

+ 1 - 42
src/main/java/com/gyee/frame/netty/websocket/WebSocketServer.java

@@ -227,48 +227,7 @@ public class WebSocketServer extends SocketTaskUtil {
     public void onError(Session session, Throwable error,@PathParam("pageNumber") String pageNumber,@PathParam("functionNumber") String functionNumber,@PathParam("keyid") String keyid) {
         log.error("发生错误");
 
-        StringBuilder sb=new StringBuilder();
-        sb.append(pageNumber).append("_").append(functionNumber);
-
-        jobkey=String.valueOf(sb);
-        //判断是否有对象编号
-        if(StringUtils.isNotNull(keyid))
-        {
-            sb.append("_").append(keyid);
-        }
-
-        pfkey=String.valueOf(sb);
-
-        if(webSocketMap.containsKey(pfkey))
-        {
-            webSocketMap.remove(pfkey);
-
-        }
-        if(webSocketMapSet.containsKey(pfkey))
-        {
-            CopyOnWriteArraySet<WebSocketServer> set=webSocketMapSet.get(pfkey);
-            set.remove(this);
-        }
-        subOnlineCount();           //在线数减1
-        log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
-        if(funcationNunberMap.containsKey(jobkey))
-        {
-            int fnumber=funcationNunberMap.get(jobkey);
-            if(fnumber>0)
-            {
-                fnumber--;
-            }else {
-                fnumber=0;
-            }
-            funcationNunberMap.put(jobkey,fnumber);
-            if(fnumber==0){
-                this.deleteJob((jobkey));//关闭任务
-                keyidMap=new HashMap<>();
-            }
-        }else  if(getOnlineCount()==0){
-            this.deleteJob((jobkey));//关闭任务
-            keyidMap=new HashMap<>();
-        }
+        log.error(error.getMessage());
     }
 	/**
 	 * 实现服务器主动推送

+ 3 - 0
src/main/java/com/gyee/frame/netty/websocket/config/ConfigDetail.txt

@@ -42,4 +42,7 @@ sisConfigMap->targetdetail_histogram->"pageNumber_8","functionNumber_3"
 23.手环指标推送,指标名称braceletPushTask,包括人员的疲劳度,收缩血压,舒张血压,心跳频率,血氧浓度,步数,经度,纬度
 sisConfigMap->braceletPushTask->"pageNumber_9","functionNumber_1"
 
+24.矩阵监视模块推送,按照场站、期次、线路推送 keyid例如(wp_CL_FDC,pj_CL01_GC,ln_CL01_XL)
+socketConfigMap->monitor_target_matrixMonitor->"pageNumber_4","functionNumber_2","keyid"
+
 

+ 126 - 0
src/main/java/com/gyee/frame/service/monitor/MonitorService.java

@@ -0,0 +1,126 @@
+package com.gyee.frame.service.monitor;
+
+
+import com.gyee.frame.common.spring.Constant;
+import com.gyee.frame.common.spring.InitialRunner;
+import com.gyee.frame.model.auto.WindTurbineTestingPointAi;
+import com.gyee.frame.model.auto.Windturbine;
+import com.gyee.frame.model.custom.MatrixVo;
+import com.gyee.frame.model.custom.PointData;
+import com.gyee.frame.model.enumeration.Messagetype;
+import com.gyee.frame.netty.websocket.WebSocketServer;
+import com.gyee.frame.netty.websocket.util.SocketToolService;
+import com.gyee.frame.util.IRealTimeDataBaseUtil;
+import com.gyee.frame.util.RealTimeDataBaseFactory;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@Service
+public class MonitorService extends SocketToolService {
+
+    private int decimal_digit = 2;
+    private IRealTimeDataBaseUtil mongodb = RealTimeDataBaseFactory.createRealTimeDataBase();
+
+    private void setMatrixValue(List<MatrixVo> vos, Map<String, Map<String, WindTurbineTestingPointAi>> wtpAimap, Windturbine wt) {
+        MatrixVo vo = new MatrixVo();
+        StringBuilder sb = new StringBuilder();
+        vo.setId(wt.getCode());
+        try {
+            //风机状态
+            PointData fjzt_real = mongodb.getRealData(wtpAimap.get(wt.getId()).get(Constant.FJZT).getId());
+            sb.append("00");
+            int fjzt = new BigDecimal(fjzt_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).intValue();
+            vo.setIcon(String.valueOf(sb.append(fjzt)));
+
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+        }
+
+        try {
+            //功率
+            PointData power_real = mongodb.getRealData(wtpAimap.get(wt.getId()).get(Constant.TPOINT_WT_FJGL).getId());
+            double power = new BigDecimal(power_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).doubleValue();
+            vo.setPower(power);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+        }
+
+        try {
+            //风速
+            PointData speed_real = mongodb.getRealData(wtpAimap.get(wt.getId()).get(Constant.TPOINT_WT_FJSSFS).getId());
+            double speed = new BigDecimal(speed_real.getPointValueInDouble()).setScale(decimal_digit, RoundingMode.HALF_EVEN).doubleValue();
+            vo.setSpeed(speed);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+        }
+        vos.add(vo);
+    }
+
+    public void monitor_target_matrixMonitor() throws Exception {
+
+        List<MatrixVo> vos = new ArrayList<>();
+        Map<String, Map<String, WindTurbineTestingPointAi>> wtpAimap = InitialRunner.wtpAimap;
+        String pageNumber = "pageNumber_4";
+        String functionNumber = "functionNumber_2";
+        StringBuilder sb = new StringBuilder();
+        sb.append(pageNumber).append("_").append(functionNumber);
+
+        String jobkey = String.valueOf(sb);
+        Map<String, Set<String>> keyidMap = WebSocketServer.keyidMap;
+        if (keyidMap.containsKey(jobkey)) {
+            Set<String> set = keyidMap.get(jobkey);
+            for (String str : set) {
+
+                if (str.equals("all")) {
+                    continue;
+                }
+                String keyid_title = str.substring(0, 3);
+                String keyid = str.substring(3);
+
+                if (keyid_title.equals("wp_")) {
+
+                    if (InitialRunner.wp_wtmap.containsKey(keyid)) {
+                        List<Windturbine> ls = InitialRunner.wp_wtmap.get(keyid);
+                        if (null != ls && !ls.isEmpty()) {
+                            for (Windturbine wt : ls) {
+                                setMatrixValue(vos, wtpAimap, wt);
+                            }
+                        }
+                    }
+
+                } else if (keyid_title.equals("pj_")) {
+
+                    if (InitialRunner.pj_wtmap.containsKey(keyid)) {
+                        List<Windturbine> ls = InitialRunner.pj_wtmap.get(keyid);
+                        if (null != ls && !ls.isEmpty()) {
+                            for (Windturbine wt : ls) {
+                                setMatrixValue(vos, wtpAimap, wt);
+                            }
+                        }
+                    }
+
+                } else if (keyid_title.equals("ln_")) {
+                    if (InitialRunner.ln_wtmap.containsKey(keyid)) {
+                        List<Windturbine> ls = InitialRunner.ln_wtmap.get(keyid);
+                        if (null != ls && !ls.isEmpty()) {
+                            for (Windturbine wt : ls) {
+                                setMatrixValue(vos, wtpAimap, wt);
+                            }
+                        }
+                    }
+                }
+
+                this.pushToWeb("pageNumber_4", "functionNumber_2", keyid, vos, Messagetype.MESSAGE);
+
+            }
+
+        }
+
+    }
+}

+ 1 - 1
src/test/java/test/SpringbootTest.txt

@@ -54,7 +54,7 @@ public class SpringbootTest {
 			Annotation[]  annotations= method.getAnnotations();
 			
 			for (Annotation annotation : annotations) {
-				System.out.println(annotation.toString());
+			//	System.out.println(annotation.toString());
 				
 				Method[] methods2= annotations.getClass().getDeclaredMethods();
 				for (Method method2 : methods2) {