Browse Source

增加大屏展示参数设置
连接webaccess调整

dongjh 1 year ago
parent
commit
56fdbd162f

+ 11 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysDictItemMapper.java

@@ -23,4 +23,15 @@ public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
      */
     @Select("SELECT * FROM sys_dict_item WHERE DICT_ID = #{mainId} order by sort_order asc, item_value asc")
     public List<SysDictItem> selectItemsByMainId(String mainId);
+
+    /**
+     * 通过字典code和字典项名称查询字典项
+     * @param dictcode 字典code
+     * @param itemtext 字典项名称
+     * @return
+     */
+    @Select("SELECT * FROM sys_dict_item " +
+            "WHERE dict_id in (select id from sys_dict where dict_code= #{dictcode}) and item_text = #{itemtext} " +
+            "limit 1")
+    public SysDictItem selectItemsByDictcodeAndItemtext(String dictcode, String itemtext);
 }

+ 8 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysDictItemService.java

@@ -21,4 +21,12 @@ public interface ISysDictItemService extends IService<SysDictItem> {
      * @return
      */
     public List<SysDictItem> selectItemsByMainId(String mainId);
+
+    /**
+     * 通过字典code和字典项名称查询字典项
+     * @param dictcode 字典code
+     * @param itemtext 字典项名称
+     * @return
+     */
+    public SysDictItem selectItemsByDictcodeAndItemtext(String dictcode, String itemtext);
 }

+ 11 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDictItemServiceImpl.java

@@ -27,4 +27,15 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
     public List<SysDictItem> selectItemsByMainId(String mainId) {
         return sysDictItemMapper.selectItemsByMainId(mainId);
     }
+
+    /**
+     * 通过字典code和字典项名称查询字典项
+     * @param dictcode 字典code
+     * @param itemtext 字典项名称
+     * @return
+     */
+    @Override
+    public SysDictItem selectItemsByDictcodeAndItemtext(String dictcode, String itemtext){
+        return sysDictItemMapper.selectItemsByDictcodeAndItemtext(dictcode, itemtext);
+    }
 }

+ 6 - 0
jeecg-module-system/jeecg-system-start/pom.xml

@@ -24,6 +24,12 @@
             <artifactId>jeecg-module-demo</artifactId>
             <version>${jeecgboot.version}</version>
         </dependency>
+        <!-- 固安模块 -->
+        <dependency>
+            <groupId>org.jeecgframework.boot</groupId>
+            <artifactId>module-guan</artifactId>
+            <version>${jeecgboot.version}</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 2 - 5
module-guan/pom.xml

@@ -12,14 +12,11 @@
     <artifactId>module-guan</artifactId>
 
     <dependencies>
+        <!-- SYSTEM 系统管理模块 -->
         <dependency>
             <groupId>org.jeecgframework.boot</groupId>
             <artifactId>jeecg-system-biz</artifactId>
-        </dependency>
-        <!-- websocket -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-websocket</artifactId>
+            <version>${jeecgboot.version}</version>
         </dependency>
         <dependency>
             <groupId>org.jeecgframework.boot</groupId>

+ 141 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/controller/GuanDashboardParamController.java

@@ -0,0 +1,141 @@
+package org.jeecg.modules.webaccess.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
+import org.jeecg.modules.webaccess.service.IGuanDashboardParamService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+
+@Api(tags = "大屏参数")
+@RestController
+@RequestMapping("/guan/dashboardparam")
+public class GuanDashboardParamController extends JeecgController<GuanDashboardParam, IGuanDashboardParamService> {
+
+    @Autowired
+    private IGuanDashboardParamService guanDashboardParamService;
+
+    @ApiOperation(value = "大屏参数", notes = "大屏参数")
+    @GetMapping(value = "/list")
+    public Result<IPage<GuanDashboardParam>> queryList(GuanDashboardParam guanDashboardParam,
+                                                       @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+                                                       @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+                                                       HttpServletRequest req) {
+        QueryWrapper<GuanDashboardParam> queryWrapper = QueryGenerator.initQueryWrapper(guanDashboardParam, req.getParameterMap());
+        Page<GuanDashboardParam> page = new Page<GuanDashboardParam>(pageNo, pageSize);
+        IPage<GuanDashboardParam> pageList = guanDashboardParamService.page(page, queryWrapper);
+        return Result.OK(pageList);
+    }
+
+    /**
+     *   添加
+     *
+     * @param guanDashboardParam
+     * @return
+     */
+    @AutoLog(value = "大屏参数-添加")
+    @ApiOperation(value="大屏参数-添加", notes="大屏参数-添加")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody GuanDashboardParam guanDashboardParam) {
+        guanDashboardParamService.save(guanDashboardParam);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     *  编辑
+     *
+     * @param guanDashboardParam
+     * @return
+     */
+    @AutoLog(value = "大屏参数-编辑")
+    @ApiOperation(value="大屏参数-编辑", notes="大屏参数-编辑")
+    //@RequiresPermissions("org.jeecg.modules:dashboard_param:edit")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+    public Result<String> edit(@RequestBody GuanDashboardParam guanDashboardParam) {
+        guanDashboardParamService.updateById(guanDashboardParam);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     *   通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "大屏参数-通过id删除")
+    @ApiOperation(value="大屏参数-通过id删除", notes="大屏参数-通过id删除")
+    //@RequiresPermissions("org.jeecg.modules:dashboard_param:delete")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+        guanDashboardParamService.removeById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     *  批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "大屏参数-批量删除")
+    @ApiOperation(value="大屏参数-批量删除", notes="大屏参数-批量删除")
+    //@RequiresPermissions("org.jeecg.modules:dashboard_param:deleteBatch")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+        this.guanDashboardParamService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("批量删除成功!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value="大屏参数-通过id查询", notes="大屏参数-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<GuanDashboardParam> queryById(@RequestParam(name="id",required=true) String id) {
+        GuanDashboardParam guanDashboardParam = guanDashboardParamService.getById(id);
+        if(guanDashboardParam==null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(guanDashboardParam);
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param guanDashboardParam
+     */
+    //@RequiresPermissions("org.jeecg.modules:dashboard_param:exportXls")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, GuanDashboardParam guanDashboardParam) {
+        return super.exportXls(request, guanDashboardParam, GuanDashboardParam.class, "大屏参数表");
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    //@RequiresPermissions("org.jeecg.modules:dashboard_param:importExcel")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, GuanDashboardParam.class);
+    }
+}

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

@@ -11,6 +11,7 @@ import org.jeecg.modules.webaccess.service.WebAccessService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
@@ -20,7 +21,7 @@ import java.util.List;
 @RestController
 @RequestMapping("/datacoll/webaccess")
 @Slf4j
-public class WebAccessController extends JeecgController {
+public class WebAccessController {
 
     @Autowired
     private WebAccessService webAccessService;
@@ -29,7 +30,7 @@ public class WebAccessController extends JeecgController {
      * 获取设备参数值(webaccess)
      */
     @ApiOperation(value = "获取设备参数值(webaccess)", notes = "获取设备参数值(webaccess)")
-    @GetMapping("/getWATagNameValues")
+    @RequestMapping(value = "/getWATagNameValues", method = RequestMethod.GET)
     public Result getWATagNameValues(String tagName) {
         List<WaLogDTO> tags = new ArrayList<>();
         WaLogDTO tag = new WaLogDTO(tagName);
@@ -44,7 +45,7 @@ public class WebAccessController extends JeecgController {
      * 设置设备参数值(webaccess)
      */
     @ApiOperation(value = "设置设备参数值(webaccess)", notes = "设置设备参数值(webaccess)")
-    @GetMapping("/setWATagNameValues")
+    @RequestMapping(value = "/setWATagNameValues", method = RequestMethod.GET)
     public Result setTagNameValues(String tagName, Integer tagValue) {
         List<WaLogDTO> tags = new ArrayList<>();
         WaLogDTO tag = new WaLogDTO(tagName, new Float(tagValue));
@@ -57,6 +58,6 @@ public class WebAccessController extends JeecgController {
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
-        return Result.OK(sendTagValue);
+        return Result.OK("设置成功", sendTagValue);
     }
 }

+ 32 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/entity/GuanDashboardParam.java

@@ -0,0 +1,32 @@
+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 io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+@Data
+@TableName("guan_dashboard_param")
+public class GuanDashboardParam {
+    /**主键*/
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+
+    /**大屏参数名称*/
+    @Excel(name = "大屏参数名称", width = 50)
+    @ApiModelProperty(value = "大屏参数名称")
+    private String paramName;
+
+    /**webaccess点名*/
+    @Excel(name = "webaccess点名", width = 50)
+    @ApiModelProperty(value = "webaccess点名")
+    private String tagName;
+
+    /**是否启用:0启用,1未启用*/
+    @Excel(name = "是否启用", width = 50)
+    @ApiModelProperty(value = "是否启用")
+    private String status;
+
+}

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

@@ -0,0 +1,7 @@
+package org.jeecg.modules.webaccess.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
+
+public interface GuanDashboardParamMapper extends BaseMapper<GuanDashboardParam> {
+}

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

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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">
+
+</mapper>

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

@@ -0,0 +1,7 @@
+package org.jeecg.modules.webaccess.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
+
+public interface IGuanDashboardParamService extends IService<GuanDashboardParam> {
+}

+ 36 - 19
module-guan/src/main/java/org/jeecg/modules/webaccess/service/WebAccessService.java

@@ -4,6 +4,8 @@ import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import org.apache.commons.codec.binary.Base64;
 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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
@@ -24,8 +26,32 @@ public class WebAccessService {
     @Autowired
     private RestTemplate restTemplate;
 
-//    @Autowired
-//    private ISysConfigService configService;
+    @Autowired
+    private ISysDictItemService sysDictItemService;
+
+    /**
+     * 获取webaccess的API信息
+     * @param itemtext(group:组合API,single:单独某个信息,login:登录信息)
+     * @return
+     */
+    private String getDictItemDesc(String itemtext, String type) {
+        SysDictItem uriIictItem = sysDictItemService.selectItemsByDictcodeAndItemtext("webaccess", "webaccess地址");
+        SysDictItem projIictItem = sysDictItemService.selectItemsByDictcodeAndItemtext("webaccess", "webaccess工程名");
+        SysDictItem dictItem = sysDictItemService.selectItemsByDictcodeAndItemtext("webaccess", itemtext);
+
+        if ("group".equals(type)) {
+            return uriIictItem.getDescription() + "/" + dictItem.getDescription() + "/" + projIictItem.getDescription();
+        }
+        else if ("single".equals(type)) {
+            return dictItem.getDescription();
+        }
+        else if ("login".equals(type)) {
+            return uriIictItem.getDescription() + "/" + dictItem.getDescription();
+        }
+        else {
+            return "";
+        }
+    }
 
     /**
      * 登录
@@ -33,9 +59,7 @@ public class WebAccessService {
      * @return
      */
     public JSONObject login() {
-        String paramValues = "";
-//        String url = configService.selectConfigByKey("ems.webaccess.login");;
-        String url = "";
+        String url = getDictItemDesc("登录地址", "login");
         JSONObject result = httpRequest(url, null);
         return result;
     }
@@ -46,8 +70,7 @@ public class WebAccessService {
      * @return
      */
     public JSONObject tagList() {
-//        String getTagValueUrl = configService.selectConfigByKey("ems.webaccess.GetTagList");
-        String getTagValueUrl = "";
+        String getTagValueUrl = getDictItemDesc("取得所有测点列表", "group");
         JSONObject result = httpRequest(getTagValueUrl, null);
 
         return result;
@@ -61,8 +84,7 @@ public class WebAccessService {
      */
     public String getTagNameValues(JSONObject jsonObject) {
         String paramValues = "";
-//        String getTagValueUrl = configService.selectConfigByKey("ems.webaccess.GetTagValue");
-        String getTagValueUrl = "";
+        String getTagValueUrl = getDictItemDesc("取得测点的量测值", "group");
         JSONObject result = httpRequest(getTagValueUrl, jsonObject);
         JSONArray jsonArray = result.getJSONArray("Values");
 
@@ -96,10 +118,8 @@ public class WebAccessService {
             JSONObject itemInfor = JSONObject.fromObject(item);
             map.put(itemInfor.getString("Name"), itemInfor.getDouble("Value"));
         }
-//        String getTagValueUrl = configService.selectConfigByKey("ems.webaccess.GetTagValue");
-//        String setTagValueUrl = configService.selectConfigByKey("ems.webaccess.SetTagValue");
-        String getTagValueUrl = "";
-        String setTagValueUrl = "";
+        String getTagValueUrl = getDictItemDesc("取得测点的量测值", "group");
+        String setTagValueUrl = getDictItemDesc("更改测点的量测值", "group");
 
         JSONObject result = httpRequest(setTagValueUrl, jsonObject);
         Thread.sleep(500);
@@ -153,10 +173,8 @@ public class WebAccessService {
             JSONObject itemInfor = JSONObject.fromObject(item);
             map.put(itemInfor.getString("Name"), itemInfor.getString("Value"));
         }
-//        String getTagValueTextUrl = configService.selectConfigByKey("ems.webaccess.GetTagValueText");
-//        String setTagValueTextUrl = configService.selectConfigByKey("ems.webaccess.SetTagValueText");
-        String getTagValueTextUrl = "";
-        String setTagValueTextUrl = "";
+        String getTagValueTextUrl = getDictItemDesc("取得文字测点的量测值", "group");
+        String setTagValueTextUrl = getDictItemDesc("更改文字测点的量测值", "group");
 
         JSONObject result = httpRequest(setTagValueTextUrl, jsonObject);
 
@@ -197,8 +215,7 @@ public class WebAccessService {
      * @return
      */
     private JSONObject httpRequest(String url, JSONObject jsonObject) {
-//        String plainCreds = configService.selectConfigByKey("ems.webaccess.AccountPwd");
-        String plainCreds = "";
+        String plainCreds = getDictItemDesc("登录信息", "single");
         byte[] plainCredsBytes = plainCreds.getBytes();
         byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes);
         String base64Creds = new String(base64CredsBytes);

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

@@ -0,0 +1,11 @@
+package org.jeecg.modules.webaccess.service.impl;
+
+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.stereotype.Service;
+
+@Service
+public class GuanDashboardParamServiceImpl extends ServiceImpl<GuanDashboardParamMapper, GuanDashboardParam> implements IGuanDashboardParamService {
+}

+ 7 - 0
pom.xml

@@ -209,6 +209,13 @@
 				<artifactId>jeecg-boot-starter-shardingsphere</artifactId>
 				<version>${jeecgboot.version}</version>
 			</dependency>
+			<!--固安模块-->
+			<dependency>
+				<groupId>org.jeecgframework.boot</groupId>
+				<artifactId>module-guan</artifactId>
+				<version>${jeecgboot.version}</version>
+			</dependency>
+
 			<dependency>
 				<groupId>org.hibernate</groupId>
 				<artifactId>hibernate-core</artifactId>