|
@@ -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);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|