Forráskód Böngészése

修改大屏展示参数设置
连接webaccess调整

dongjh 1 éve%!(EXTRA string=óta)
szülő
commit
e575d8e8b5

+ 13 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/controller/WebAccessController.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.webaccess.controller;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.base.controller.JeecgController;
@@ -60,4 +61,16 @@ public class WebAccessController {
         }
         return Result.OK("设置成功", sendTagValue);
     }
+
+    /**
+     * 取得历史资料
+     */
+    @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);
+
+        return Result.OK("获取成功", rtn);
+    }
 }

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

@@ -3,9 +3,13 @@ package org.jeecg.modules.webaccess.entity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 @Data
 @TableName("guan_dashboard_param")
@@ -24,9 +28,39 @@ public class GuanDashboardParam {
     @ApiModelProperty(value = "webaccess点名")
     private String tagName;
 
-    /**是否启用:0启用,1未启用*/
-    @Excel(name = "是否启用", width = 50)
-    @ApiModelProperty(value = "是否启用")
+    /**状态:1启用,0禁用*/
+    @Excel(name = "状态(1启用,0禁用)")
+    @ApiModelProperty(value = "状态")
     private String status;
 
+    /**是否获取历史记录:1是,0否*/
+    @Excel(name = "是否获取历史记录(1是,0否)")
+    @ApiModelProperty(value = "是否获取历史记录")
+    private String iflog;
+
+    /**历史记录条数*/
+    @Excel(name = "历史记录条数")
+    @ApiModelProperty(value = "历史记录条数")
+    private Integer lognum;
+
+    /**创建时间*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**修改时间*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+    /**修改人*/
+    @ApiModelProperty(value = "修改人")
+    private String updateBy;
+    /**备注*/
+    @Excel(name = "备注", width = 15)
+    @ApiModelProperty(value = "备注")
+    private String remark;
 }

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

@@ -1,7 +1,16 @@
 package org.jeecg.modules.webaccess.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
 
+import java.util.List;
+
 public interface GuanDashboardParamMapper extends BaseMapper<GuanDashboardParam> {
+    /**
+     * 依据条件获取所有参数
+     * @param dashboardParam
+     * @return
+     */
+    public List<GuanDashboardParam> selectAllDashboardParam(GuanDashboardParam dashboardParam);
 }

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

@@ -2,4 +2,27 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.webaccess.mapper.GuanDashboardParamMapper">
 
+    <resultMap type="org.jeecg.modules.webaccess.entity.GuanDashboardParam" id="GuanDashboardParamResult">
+        <result property="id"    column="id"    />
+        <result property="paramName"    column="param_name"    />
+        <result property="tagName"    column="tag_name"    />
+        <result property="status"    column="status"    />
+        <result property="iflog"    column="iflog"    />
+        <result property="lognum"    column="lognum"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+
+    <select id="selectAllDashboardParam" parameterType="org.jeecg.modules.webaccess.entity.GuanDashboardParam" resultMap="GuanDashboardParamResult">
+        select * from guan_dashboard_param
+        <where>
+            <if test="status != null "> and status = #{status}</if>
+            <if test="iflog != null "> and iflog = #{iflog}</if>
+        </where>
+    </select>
+
 </mapper>

+ 9 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/service/IGuanDashboardParamService.java

@@ -3,5 +3,14 @@ package org.jeecg.modules.webaccess.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
 
+import java.util.List;
+
 public interface IGuanDashboardParamService extends IService<GuanDashboardParam> {
+
+    /**
+     * 依据条件获取所有参数
+     * @param dashboardParam
+     * @return
+     */
+    public List<GuanDashboardParam> selectAllDashboardParam(GuanDashboardParam dashboardParam);
 }

+ 68 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/service/WebAccessService.java

@@ -7,6 +7,8 @@ import org.apache.commons.collections.map.HashedMap;
 import org.jeecg.modules.system.entity.SysDictItem;
 import org.jeecg.modules.system.service.ISysDictItemService;
 import org.jeecg.modules.webaccess.dto.WaLogDTO;
+import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
+import org.jeecg.modules.webaccess.mapper.GuanDashboardParamMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
@@ -29,6 +31,9 @@ public class WebAccessService {
     @Autowired
     private ISysDictItemService sysDictItemService;
 
+    @Autowired
+    private GuanDashboardParamMapper dashboardParamMapper;
+
     /**
      * 获取webaccess的API信息
      * @param itemtext(group:组合API,single:单独某个信息,login:登录信息)
@@ -99,6 +104,20 @@ public class WebAccessService {
     }
 
     /**
+     * 取得历史资料
+     *
+     * @param jsonObject
+     * @return
+     */
+    public JSONArray GetDataLog(JSONObject jsonObject) {
+        String getTagValueUrl = getDictItemDesc("取得历史资料", "group");
+        JSONObject result = httpRequest(getTagValueUrl, jsonObject);
+        JSONArray jsonArray = result.getJSONArray("DataLog");
+
+        return jsonArray;
+    }
+
+    /**
      * 更改测点(Tag)的量测值
      *
      * @param jsonObject
@@ -278,4 +297,53 @@ public class WebAccessService {
 
         return rtn;
     }
+
+
+    /**
+     *
+     * 生成获取历史记录的参数
+     *
+     * {
+     *   "StartTime":"字符串内容",  -- 起始时间,格式为 yyyy-mm-dd HH:MM:SS。
+     *   "IntervalType":"字符串内容", -- 查询之时间单位,S:秒,M:分,H:时,D:日。
+     *   "Interval":数值, -- 每笔数据之间隔时间,以 IntervalType 为单位。
+     *   "Records":数值, -- 欲查询之每个点的数据笔数。
+     *   "Tags":[{
+     *     "Name":"字符串内容", -- 测点名称。
+     *     "DataType":"字符串内容" -- 数据型态,0 - Last,1-Min,2 - Max,3 - Avg。
+     *   }]
+     * }
+     * @param StartTime 起始时间,格式为 yyyy-mm-dd HH:MM:SS。
+     * @param IntervalType 查询之时间单位,S:秒,M:分,H:时,D:日。
+     * @param Interval 每笔数据之间隔时间,以 IntervalType 为单位。
+     * @param Records 欲查询之每个点的数据笔数。
+     * @param DataType 数据型态,0 - Last,1-Min,2 - Max,3 - Avg。
+     * @return
+     */
+    public JSONObject generateDataLogObject(String StartTime, String IntervalType, Integer Interval, Integer Records, String DataType) {
+        JSONArray list = new JSONArray();
+        JSONObject rtn = new JSONObject();
+
+        // 获取大屏参数设置
+        GuanDashboardParam paramat = new GuanDashboardParam();
+        paramat.setStatus("1"); // 状态为启用
+        paramat.setIflog("Y"); // 需要获取历史记录
+        List<GuanDashboardParam> dashboardParamList = dashboardParamMapper.selectAllDashboardParam(paramat);
+
+        rtn.put("StartTime", StartTime);
+        rtn.put("IntervalType", IntervalType);
+        rtn.put("Interval", Interval);
+        rtn.put("Records", Records);
+        if (dashboardParamList != null && dashboardParamList.size() > 0) {
+            for (GuanDashboardParam param : dashboardParamList) {
+                JSONObject sub = new JSONObject();
+                sub.put("Name", param.getTagName());
+                sub.put("DataType", DataType);
+                list.add(sub);
+            }
+        }
+        rtn.put("Tags", list);
+
+        return rtn;
+    }
 }

+ 17 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/service/impl/GuanDashboardParamServiceImpl.java

@@ -4,8 +4,25 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
 import org.jeecg.modules.webaccess.mapper.GuanDashboardParamMapper;
 import org.jeecg.modules.webaccess.service.IGuanDashboardParamService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class GuanDashboardParamServiceImpl extends ServiceImpl<GuanDashboardParamMapper, GuanDashboardParam> implements IGuanDashboardParamService {
+
+    @Autowired
+    private GuanDashboardParamMapper dashboardParamMapper;
+
+
+    /**
+     * 依据条件获取所有参数
+     * @param dashboardParam
+     * @return
+     */
+    @Override
+    public List<GuanDashboardParam> selectAllDashboardParam(GuanDashboardParam dashboardParam) {
+        return dashboardParamMapper.selectAllDashboardParam(dashboardParam);
+    }
 }