瀏覽代碼

增加演示参数

xusl 1 年之前
父節點
當前提交
d9103fd58d
共有 1 個文件被更改,包括 149 次插入22 次删除
  1. 149 22
      ipfcst/ipfcst-reportquery/src/main/java/com/jiayue/ipfcst/service/DashboardService.java

+ 149 - 22
ipfcst/ipfcst-reportquery/src/main/java/com/jiayue/ipfcst/service/DashboardService.java

@@ -164,6 +164,7 @@ public class DashboardService extends BaseService {
     Map<String, String> uploadFileMap = new HashMap();
     Map<String, String> dataexchangeMap = new HashMap();
     Map<String, String> callBackMap = new HashMap();
+    String demo = super.getSysParameter("demo", "1");
 
     try {
 //      URL url = new URL("https://localhost:9001/consoleOpenInterface/getChannelStatus");
@@ -234,7 +235,12 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(fileParseTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(fileParseTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(dataexchangeMap.get(String.valueOf(fileParseTunnelInfo.getId())) != null ? dataexchangeMap.get(String.valueOf(fileParseTunnelInfo.getId())) : "0");
+      }
       uploadObjectStatusDto.setTips("");
       dataexchangeList.add(uploadObjectStatusDto);
     }
@@ -242,7 +248,13 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(gather104TcpTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(gather104TcpTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(dataexchangeMap.get(String.valueOf(gather104TcpTunnelInfo.getId())) != null ? dataexchangeMap.get(String.valueOf(gather104TcpTunnelInfo.getId())) : "0");
+      }
+
       uploadObjectStatusDto.setTips("本地IP:" + gather104TcpTunnelInfo.getSelfIp() + " 本地端口:" + gather104TcpTunnelInfo.getSelfPort() + " 远端IP:" + gather104TcpTunnelInfo.getRemoteIp() + " 远端端口:" + gather104TcpTunnelInfo.getRemotePort());
       dataexchangeList.add(uploadObjectStatusDto);
     }
@@ -251,7 +263,13 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(gatherModbusRtuWithTcpServerTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(gatherModbusRtuWithTcpServerTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(dataexchangeMap.get(String.valueOf(gatherModbusRtuWithTcpServerTunnelInfo.getId())) != null ? dataexchangeMap.get(String.valueOf(gatherModbusRtuWithTcpServerTunnelInfo.getId())) : "0");
+      }
+
       uploadObjectStatusDto.setTips("本地IP:" + gatherModbusRtuWithTcpServerTunnelInfo.getSelfIp() + " 本地端口:" + gatherModbusRtuWithTcpServerTunnelInfo.getSelfPort() + " 远端IP:" + gatherModbusRtuWithTcpServerTunnelInfo.getRemoteIp() );
       dataexchangeList.add(uploadObjectStatusDto);
     }
@@ -259,7 +277,13 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(gatherCdtRtuTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(gatherCdtRtuTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(dataexchangeMap.get(String.valueOf(gatherCdtRtuTunnelInfo.getId())) != null ? dataexchangeMap.get(String.valueOf(gatherCdtRtuTunnelInfo.getId())) : "0");
+      }
+
       uploadObjectStatusDto.setTips("串口名称:" + gatherCdtRtuTunnelInfo.getSerialName());
       dataexchangeList.add(uploadObjectStatusDto);
     }
@@ -267,7 +291,13 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(gatherModbusRtuTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(gatherModbusRtuTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(dataexchangeMap.get(String.valueOf(gatherModbusRtuTunnelInfo.getId())) != null ? dataexchangeMap.get(String.valueOf(gatherModbusRtuTunnelInfo.getId())) : "0");
+      }
+
       uploadObjectStatusDto.setTips("串口名称:" + gatherModbusRtuTunnelInfo.getSerialName());
       dataexchangeList.add(uploadObjectStatusDto);
     }
@@ -275,7 +305,12 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(gatherModbusTcpTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(gatherModbusTcpTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else {
+        uploadObjectStatusDto.setChannelStatus(dataexchangeMap.get(String.valueOf(gatherModbusTcpTunnelInfo.getId())) != null ? dataexchangeMap.get(String.valueOf(gatherModbusTcpTunnelInfo.getId())) : "0");
+      }
       uploadObjectStatusDto.setTips("本地IP:" + gatherModbusTcpTunnelInfo.getSelfIp() + " 本地端口:" + gatherModbusTcpTunnelInfo.getSelfPort() + " 远端IP:" + gatherModbusTcpTunnelInfo.getRemoteIp() + " 远端端口:" + gatherModbusTcpTunnelInfo.getRemotePort());
       dataexchangeList.add(uploadObjectStatusDto);
     }
@@ -298,7 +333,12 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(sender104TcpTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(sender104TcpTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(callBackMap.get(String.valueOf(sender104TcpTunnelInfo.getId())) != null ? callBackMap.get(String.valueOf(sender104TcpTunnelInfo.getId())) : "0");
+      }
       uploadObjectStatusDto.setTips("本地IP:" + sender104TcpTunnelInfo.getSelfIp() + " 本地端口:" + sender104TcpTunnelInfo.getSelfPort());
       callBackList.add(uploadObjectStatusDto);
     }
@@ -306,7 +346,12 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(senderCdtRtuTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(senderCdtRtuTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(callBackMap.get(String.valueOf(senderCdtRtuTunnelInfo.getId())) != null ? callBackMap.get(String.valueOf(senderCdtRtuTunnelInfo.getId())) : "0");
+      }
       uploadObjectStatusDto.setTips("串口名称:" + senderCdtRtuTunnelInfo.getSerialName());
       callBackList.add(uploadObjectStatusDto);
     }
@@ -314,7 +359,12 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(senderModbusRtuTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(senderModbusRtuTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(callBackMap.get(String.valueOf(senderModbusRtuTunnelInfo.getId())) != null ? callBackMap.get(String.valueOf(senderModbusRtuTunnelInfo.getId())) : "0");
+      }
       uploadObjectStatusDto.setTips("串口名称:" + senderModbusRtuTunnelInfo.getSerialName());
       callBackList.add(uploadObjectStatusDto);
     }
@@ -322,7 +372,12 @@ public class DashboardService extends BaseService {
       ChannelStatusDto uploadObjectStatusDto = new ChannelStatusDto();
       uploadObjectStatusDto.setChannelId(String.valueOf(senderModbusTcpTunnelInfo.getId()));
       uploadObjectStatusDto.setChannelName(senderModbusTcpTunnelInfo.getTunnelName());
-      uploadObjectStatusDto.setChannelStatus("1");
+      if ("1".equals(demo)){
+        uploadObjectStatusDto.setChannelStatus("1");
+      }
+      else{
+        uploadObjectStatusDto.setChannelStatus(callBackMap.get(String.valueOf(senderModbusTcpTunnelInfo.getId())) != null ? callBackMap.get(String.valueOf(senderModbusTcpTunnelInfo.getId())) : "0");
+      }
       uploadObjectStatusDto.setTips("本地IP:" + senderModbusTcpTunnelInfo.getSelfIp() + " 本地端口:" + senderModbusTcpTunnelInfo.getSelfPort());
       callBackList.add(uploadObjectStatusDto);
     }
@@ -362,7 +417,13 @@ public class DashboardService extends BaseService {
         // 针对海南上报打包特殊情况,允许上报对象下没有通道,也让对象状态为绿色
         uploadObjectStatusDto.setChannelStatus("1");
       } else {
-        uploadObjectStatusDto.setChannelStatus(objectStatusMap.get(String.valueOf(uploadObject.getId())) != null ? "1" : "1");
+        if ("1".equals(demo)){
+          uploadObjectStatusDto.setChannelStatus(objectStatusMap.get(String.valueOf(uploadObject.getId())) != null ? "1" : "1");
+        }
+        else{
+          uploadObjectStatusDto.setChannelStatus(objectStatusMap.get(String.valueOf(uploadObject.getId())) != null ? "1" : "0");
+        }
+
       }
 
       uploadList.add(uploadObjectStatusDto);
@@ -374,7 +435,13 @@ public class DashboardService extends BaseService {
         if ("1".equals(channelStatusDetailMap.get("" + uploadFileChannel.getId()))) {
           statusColor = "00CC66";
         } else {
-          statusColor = "00CC66";
+          if ("1".equals(demo)){
+            statusColor = "00CC66";
+          }
+          else{
+            statusColor = "FF0033";
+          }
+
         }
         tips = tips + uploadFileChannel.getChannelName() + " 状态:" + "<span style=\"border-radius:50%;height:10px;width:10px;display:inline-block;background:#" + statusColor + "\"></span>" + "&nbsp;&nbsp;" + "远端IP:" + uploadFileChannel.getRemoteIp() + " 远端端口:" + uploadFileChannel.getRemotePort();
         if (!"ftp".equals(uploadObject.getUploadProtocolEnum().getCode()) && !"sftp".equals(uploadObject.getUploadProtocolEnum().getCode())) {
@@ -432,8 +499,22 @@ public class DashboardService extends BaseService {
 
     // 短期一期
     List<FileAnalysisRecord> dqList1 = fileAnalysisRecordList.stream().filter(w -> "DQ".equals(w.getFileType())).collect(Collectors.toList());
-    String dqStatus1 = "1";
-    String dqTips1 = "最后解析光伏短期时间:" + DateFormatUtils.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
+    String dqStatus1 = "";
+    String dqTips1 = "";
+    if ("1".equals(demo)){
+      dqStatus1 = "1";
+      dqTips1 = "最后解析光伏短期时间:" + DateFormatUtils.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
+    }
+    else{
+      dqStatus1 = "0";
+      if (dqList1.size() > 0) {
+        dqList1.sort(Comparator.comparing(FileAnalysisRecord::getCreateTime).reversed());
+        dqStatus1 = dqList1.get(0).getFileStatus();
+        dqTips1 = "最后解析光伏短期时间:" + DateFormatUtils.format(dqList1.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
+      } else {
+        dqTips1 = "今日未解析过光伏短期文件";
+      }
+    }
 
     ChannelStatusDto dqAnalysisDto1 = new ChannelStatusDto();
     dqAnalysisDto1.setChannelId("DQ");
@@ -443,8 +524,22 @@ public class DashboardService extends BaseService {
     analysisList.add(dqAnalysisDto1);
     // NWP一期
     List<FileAnalysisRecord> nwpList1 = fileAnalysisRecordList.stream().filter(w -> "NWP".equals(w.getFileType())).collect(Collectors.toList());
-    String nwpStatus1 = "1";
-    String nwpTips1 = "最后解析光伏NWP时间:" + DateFormatUtils.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
+    String nwpStatus1 = "";
+    String nwpTips1 = "";
+    if ("1".equals(demo)){
+      nwpStatus1 = "1";
+      nwpTips1 = "最后解析光伏NWP时间:" + DateFormatUtils.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
+    }
+    else{
+      nwpStatus1 = "0";
+      if (nwpList1.size() > 0) {
+        nwpList1.sort(Comparator.comparing(FileAnalysisRecord::getCreateTime).reversed());
+        nwpStatus1 = nwpList1.get(0).getFileStatus();
+        nwpTips1 = "最后解析光伏NWP时间:" + DateFormatUtils.format(nwpList1.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
+      } else {
+        nwpTips1 = "今日未解析过光伏NWP文件";
+      }
+    }
 
     ChannelStatusDto nwpAnalysisDto1 = new ChannelStatusDto();
     nwpAnalysisDto1.setChannelId("NWP");
@@ -455,8 +550,22 @@ public class DashboardService extends BaseService {
 
     // 短期二期
     List<FileAnalysisRecord> dqList2 = fileAnalysisRecordList.stream().filter(w -> "DQ1".equals(w.getFileType())).collect(Collectors.toList());
-    String dqStatus2 = "1";
-    String dqTips2 = "最后解析风电短期时间:" + DateFormatUtils.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
+    String dqStatus2 = "";
+    String dqTips2 = "";
+    if ("1".equals(demo)){
+      dqStatus2 = "1";
+      dqTips2 = "最后解析风电短期时间:" + DateFormatUtils.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
+    }
+    else{
+      dqStatus2 = "0";
+      if (dqList2.size() > 0) {
+        dqList2.sort(Comparator.comparing(FileAnalysisRecord::getCreateTime).reversed());
+        dqStatus2 = dqList2.get(0).getFileStatus();
+        dqTips2 = "最后解析风电短期时间:" + DateFormatUtils.format(dqList2.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
+      } else {
+        dqTips2 = "今日未解析过风电短期文件";
+      }
+    }
 
 
     ChannelStatusDto dqAnalysisDto2 = new ChannelStatusDto();
@@ -467,8 +576,23 @@ public class DashboardService extends BaseService {
     analysisList.add(dqAnalysisDto2);
     // NWP二期
     List<FileAnalysisRecord> nwpList2 = fileAnalysisRecordList.stream().filter(w -> "NWP1".equals(w.getFileType())).collect(Collectors.toList());
-    String nwpStatus2 = "1";
-    String nwpTips2 = "最后解析风电NWP时间:" + DateFormatUtils.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
+    String nwpStatus2 = "";
+    String nwpTips2 = "";
+    if ("1".equals(demo)){
+      nwpStatus2 = "1";
+      nwpTips2 = "最后解析风电NWP时间:" + DateFormatUtils.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss");
+    }
+    else{
+      nwpStatus2 = "0";
+      if (nwpList2.size() > 0) {
+        nwpList2.sort(Comparator.comparing(FileAnalysisRecord::getCreateTime).reversed());
+        nwpStatus2 = nwpList2.get(0).getFileStatus();
+        nwpTips2 = "最后解析风电NWP时间:" + DateFormatUtils.format(nwpList2.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
+      } else {
+        nwpTips2 = "今日未解析过风电NWP文件";
+      }
+    }
+
 
     ChannelStatusDto nwpAnalysisDto2 = new ChannelStatusDto();
     nwpAnalysisDto2.setChannelId("NWP1");
@@ -793,8 +917,11 @@ public class DashboardService extends BaseService {
     }else {
       rateB = normalB.divide(shouldB, 2, BigDecimal.ROUND_UP);
     }
-
-    return new BigDecimal("1");
+    String demo = super.getSysParameter("demo", "1");
+    if ("1".equals(demo)) {
+      rateB = new BigDecimal("1");
+    }
+    return rateB;
   }
 
   /**