Explorar el Código

增加webaccess根据大屏参数获取数据的功能

dongjh hace 1 año
padre
commit
31a60c1e55

+ 17 - 4
module-guan/src/main/java/org/jeecg/modules/webaccess/controller/WebAccessController.java

@@ -63,14 +63,27 @@ public class WebAccessController {
     }
 
     /**
-     * 取得历史资料
+     * 获取历史数据
      */
-    @ApiOperation(value = "取得历史资料(webaccess)", notes = "取得历史资料(webaccess)")
+    @ApiOperation(value = "获取历史数据(webaccess)", notes = "获取历史数据(webaccess)")
     @RequestMapping(value = "/getWADataLog", method = RequestMethod.GET)
     public Result getWADataLog() {
         JSONObject jsonObject = webAccessService.generateDataLogObject("2023-12-19 12:00:00", "M", 1, 1000, "0");
-        JSONArray rtn = webAccessService.GetDataLog(jsonObject);
+        JSONObject result = webAccessService.GetDataLog(jsonObject);
+        JSONArray jsonArray = result.getJSONArray("DataLog");
 
-        return Result.OK("获取成功", rtn);
+        return Result.OK("获取成功", jsonArray);
+    }
+
+    /**
+     * 获取点位实时值
+     */
+    @ApiOperation(value = "获取点位实时值(webaccess)", notes = "获取点位实时值(webaccess)")
+    @RequestMapping(value = "/getWATagValue", method = RequestMethod.GET)
+    public Result getWATagValue() {
+        JSONObject result = webAccessService.getDashboardTagNameValues();
+        JSONArray jsonArray = result.getJSONArray("Values");
+
+        return Result.OK("获取成功", jsonArray);
     }
 }

+ 8 - 3
module-guan/src/main/java/org/jeecg/modules/webaccess/entity/GuanDashboardParam.java

@@ -38,11 +38,16 @@ public class GuanDashboardParam {
     @ApiModelProperty(value = "是否获取历史记录")
     private String iflog;
 
-    /**历史记录条数*/
-    @Excel(name = "历史记录条数")
-    @ApiModelProperty(value = "历史记录条数")
+    /**获取历史记录条数*/
+    @Excel(name = "获取历史记录条数")
+    @ApiModelProperty(value = "获取历史记录条数")
     private Integer lognum;
 
+    /**获取历史记录时长(小时)*/
+    @Excel(name = "获取历史记录时长(小时)")
+    @ApiModelProperty(value = "获取历史记录时长")
+    private Integer logduration;
+
     /**创建时间*/
     @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")

+ 1 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/xml/GuanDashboardParamMapper.xml

@@ -9,6 +9,7 @@
         <result property="status"    column="status"    />
         <result property="iflog"    column="iflog"    />
         <result property="lognum"    column="lognum"    />
+        <result property="logduration"    column="logduration"    />
         <result property="createTime"    column="create_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateTime"    column="update_time"    />

+ 59 - 4
module-guan/src/main/java/org/jeecg/modules/webaccess/service/WebAccessService.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.webaccess.service;
 
+import com.alipay.api.domain.DashboardParam;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import org.apache.commons.codec.binary.Base64;
@@ -17,6 +18,8 @@ import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+import javax.swing.plaf.synth.Region;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -34,6 +37,7 @@ public class WebAccessService {
     @Autowired
     private GuanDashboardParamMapper dashboardParamMapper;
 
+    //region <<字典获取webaccess信息>>
     /**
      * 获取webaccess的API信息
      * @param itemtext(group:组合API,single:单独某个信息,login:登录信息)
@@ -57,7 +61,9 @@ public class WebAccessService {
             return "";
         }
     }
+    //endregion
 
+    //region <<webaccess API>>
     /**
      * 登录
      *
@@ -104,17 +110,30 @@ public class WebAccessService {
     }
 
     /**
+     * 取得测点(Tag)的量测值(未解析)
+     *
+     * @param jsonObject
+     * @return
+     */
+    public JSONObject getTagNameValuesNoAnalysis(JSONObject jsonObject) {
+        String paramValues = "";
+        String getTagValueUrl = getDictItemDesc("取得测点的量测值", "group");
+        JSONObject result = httpRequest(getTagValueUrl, jsonObject);
+
+        return result;
+    }
+
+    /**
      * 取得历史资料
      *
      * @param jsonObject
      * @return
      */
-    public JSONArray GetDataLog(JSONObject jsonObject) {
+    public JSONObject GetDataLog(JSONObject jsonObject) {
         String getTagValueUrl = getDictItemDesc("取得历史资料", "group");
         JSONObject result = httpRequest(getTagValueUrl, jsonObject);
-        JSONArray jsonArray = result.getJSONArray("DataLog");
 
-        return jsonArray;
+        return result;
     }
 
     /**
@@ -256,7 +275,9 @@ public class WebAccessService {
 
         return result;
     }
+    //endregion
 
+    //region <<组成webaccess参数信息>>
     /**
      * 组成获取参数值的信息
      * @param tags 参数名
@@ -297,8 +318,9 @@ public class WebAccessService {
 
         return rtn;
     }
+    //endregion
 
-
+    //region <<获取历史记录>>
     /**
      *
      * 生成获取历史记录的参数
@@ -346,4 +368,37 @@ public class WebAccessService {
 
         return rtn;
     }
+    //endregion
+
+    //region <<根据大屏参数设置,获取点位实时值>>
+    /**
+     * 取得测点(Tag)的量测值
+     *
+     * @return
+     */
+    public JSONObject getDashboardTagNameValues() {
+        // 获取大屏参数设置
+        GuanDashboardParam paramat = new GuanDashboardParam();
+        paramat.setStatus("1"); // 状态为启用
+        paramat.setIflog("N"); // 不需要获取历史记录
+        List<GuanDashboardParam> dashboardParamList = dashboardParamMapper.selectAllDashboardParam(paramat);
+
+        // 组合参数信息
+        List<WaLogDTO> tags = new ArrayList<>();
+        if (dashboardParamList != null && dashboardParamList.size() > 0) {
+            for (GuanDashboardParam param : dashboardParamList) {
+                if (param.getTagName() != null && !"".equals(param.getTagName())) {
+                    WaLogDTO tag = new WaLogDTO(param.getTagName());
+                    tags.add(tag);
+                }
+            }
+        }
+        else {
+            return null;
+        }
+        JSONObject waparams = generateGetObject(tags);
+        JSONObject jsonObject = getTagNameValuesNoAnalysis(waparams);
+        return jsonObject;
+    }
+    //endregion
 }