From b3e202f71cc1643984a4c28fcdb7ee38b75c7c0a Mon Sep 17 00:00:00 2001 From: wenjy Date: Tue, 8 Mar 2022 17:59:10 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E9=98=88=E5=80=BC=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/BaseSensorInfoController.java | 326 +++++++++++------- .../main/resources/static/ruoyi/js/ry-ui.js | 20 ++ .../templates/base/sensorInfo/sensorInfo.html | 2 + .../base/sensorInfo/setAlarmParam.html | 163 +++++++++ .../src/main/resources/templates/login.html | 4 +- .../templates/section/transformer-detail.html | 8 +- .../ruoyi/system/domain/BaseAlarmInfo.java | 6 +- .../system/domain/dto/BaseSensorInfoDto.java | 8 + 8 files changed, 404 insertions(+), 133 deletions(-) create mode 100644 ruoyi-admin/src/main/resources/templates/base/sensorInfo/setAlarmParam.html diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java index 6d0447c..dd3eb07 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java @@ -1,10 +1,16 @@ package com.ruoyi.web.controller.base; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import com.alibaba.fastjson.JSONArray; +import com.mysql.cj.xdevapi.JsonArray; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.system.domain.BaseAlarmInfo; +import com.ruoyi.system.domain.dto.BaseAlarmInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto; +import com.ruoyi.system.service.IBaseAlarmInfoService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -26,143 +32,215 @@ import org.springframework.web.multipart.MultipartFile; /** * 传感器信息Controller - * + * * @author wenjy * @date 2022-02-07 */ @Controller @RequestMapping("/base/sensorInfo") -public class BaseSensorInfoController extends BaseController -{ - private String prefix = "base/sensorInfo"; - - @Autowired - private IBaseSensorInfoService baseSensorInfoService; - - @RequiresPermissions("base:sensorInfo:view") - @GetMapping() - public String sensorInfo() - { - return prefix + "/sensorInfo"; - } +public class BaseSensorInfoController extends BaseController { + private String prefix = "base/sensorInfo"; - /** - * 查询传感器信息列表 - */ - @RequiresPermissions("base:sensorInfo:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(BaseSensorInfo baseSensorInfo) - { - startPage(); - List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); - return getDataTable(list); - } + @Autowired private IBaseSensorInfoService baseSensorInfoService; - /** - * 导入模板下载 - * @author WenJY - * @date 2022/2/11 10:12 - * @return com.ruoyi.common.core.domain.AjaxResult - */ - @RequiresPermissions("base:sensorInfo:importTemplate") - @GetMapping("/importTemplate") - @ResponseBody - public AjaxResult importTemplate() { - ExcelUtil util = new ExcelUtil(BaseSensorInfo.class); - return util.importTemplateExcel("传感器信息"); - } + @Autowired + private IBaseAlarmInfoService baseAlarmInfoService; - /** - * 导入传感器信息 - * @author WenJY - * @date 2022/2/11 10:12 - * @param file - * @param updateSupport - * @return com.ruoyi.common.core.domain.AjaxResult - */ - @RequiresPermissions("base:sensorInfo:import") - @PostMapping("/importData") - @ResponseBody - public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { - ExcelUtil util = new ExcelUtil(BaseSensorInfo.class); - //读取file文件将文件内容转为list集合 - List baseSensorInfos = util.importExcel(file.getInputStream()); - String message = baseSensorInfoService.importMould(baseSensorInfos,updateSupport); - return AjaxResult.success(message); - } + @RequiresPermissions("base:sensorInfo:view") + @GetMapping() + public String sensorInfo() { + return prefix + "/sensorInfo"; + } - /** - * 导出传感器信息列表 - */ - @RequiresPermissions("base:sensorInfo:export") - @Log(title = "传感器信息", businessType = BusinessType.EXPORT) - @PostMapping("/export") - @ResponseBody - public AjaxResult export(BaseSensorInfo baseSensorInfo) - { - List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); - ExcelUtil util = new ExcelUtil(BaseSensorInfoDto.class); - return util.exportExcel(list, "传感器信息数据"); - } + /** 查询传感器信息列表 */ + @RequiresPermissions("base:sensorInfo:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(BaseSensorInfo baseSensorInfo) { + startPage(); + List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + return getDataTable(list); + } - /** - * 新增传感器信息 - */ - @GetMapping("/add") - public String add() - { - return prefix + "/add"; - } + /** + * 导入模板下载 + * + * @author WenJY + * @date 2022/2/11 10:12 + * @return com.ruoyi.common.core.domain.AjaxResult + */ + @RequiresPermissions("base:sensorInfo:importTemplate") + @GetMapping("/importTemplate") + @ResponseBody + public AjaxResult importTemplate() { + ExcelUtil util = new ExcelUtil(BaseSensorInfo.class); + return util.importTemplateExcel("传感器信息"); + } - /** - * 新增保存传感器信息 - */ - @RequiresPermissions("base:sensorInfo:add") - @Log(title = "传感器信息", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(BaseSensorInfo baseSensorInfo) - { - baseSensorInfo.setCreateBy(ShiroUtils.getLoginName()); - baseSensorInfo.setCreateTime(new Date()); - return toAjax(baseSensorInfoService.insertBaseSensorInfo(baseSensorInfo)); - } + /** + * 导入传感器信息 + * + * @author WenJY + * @date 2022/2/11 10:12 + * @param file + * @param updateSupport + * @return com.ruoyi.common.core.domain.AjaxResult + */ + @RequiresPermissions("base:sensorInfo:import") + @PostMapping("/importData") + @ResponseBody + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { + ExcelUtil util = new ExcelUtil(BaseSensorInfo.class); + // 读取file文件将文件内容转为list集合 + List baseSensorInfos = util.importExcel(file.getInputStream()); + String message = baseSensorInfoService.importMould(baseSensorInfos, updateSupport); + return AjaxResult.success(message); + } - /** - * 修改传感器信息 - */ - @GetMapping("/edit/{objId}") - public String edit(@PathVariable("objId") Long objId, ModelMap mmap) - { - BaseSensorInfoDto baseSensorInfo = baseSensorInfoService.selectBaseSensorInfoByObjId(objId); - mmap.put("baseSensorInfo", baseSensorInfo); - return prefix + "/edit"; - } + /** 导出传感器信息列表 */ + @RequiresPermissions("base:sensorInfo:export") + @Log(title = "传感器信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(BaseSensorInfo baseSensorInfo) { + List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + ExcelUtil util = new ExcelUtil(BaseSensorInfoDto.class); + return util.exportExcel(list, "传感器信息数据"); + } - /** - * 修改保存传感器信息 - */ - @RequiresPermissions("base:sensorInfo:edit") - @Log(title = "传感器信息", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(BaseSensorInfo baseSensorInfo) - { - baseSensorInfo.setUpdateBy(ShiroUtils.getLoginName()); - baseSensorInfo.setUpdateTime(new Date()); - return toAjax(baseSensorInfoService.updateBaseSensorInfo(baseSensorInfo)); - } + /** 新增传感器信息 */ + @GetMapping("/add") + public String add() { + return prefix + "/add"; + } + + /** 新增保存传感器信息 */ + @RequiresPermissions("base:sensorInfo:add") + @Log(title = "传感器信息", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(BaseSensorInfo baseSensorInfo) { + baseSensorInfo.setCreateBy(ShiroUtils.getLoginName()); + baseSensorInfo.setCreateTime(new Date()); + return toAjax(baseSensorInfoService.insertBaseSensorInfo(baseSensorInfo)); + } + + /** 修改传感器信息 */ + @GetMapping("/edit/{objId}") + public String edit(@PathVariable("objId") Long objId, ModelMap mmap) { + BaseSensorInfoDto baseSensorInfo = baseSensorInfoService.selectBaseSensorInfoByObjId(objId); + mmap.put("baseSensorInfo", baseSensorInfo); + return prefix + "/edit"; + } + + /** 修改保存传感器信息 */ + @RequiresPermissions("base:sensorInfo:edit") + @Log(title = "传感器信息", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(BaseSensorInfo baseSensorInfo) { + baseSensorInfo.setUpdateBy(ShiroUtils.getLoginName()); + baseSensorInfo.setUpdateTime(new Date()); + return toAjax(baseSensorInfoService.updateBaseSensorInfo(baseSensorInfo)); + } - /** - * 删除传感器信息 - */ - @RequiresPermissions("base:sensorInfo:remove") - @Log(title = "传感器信息", businessType = BusinessType.DELETE) - @PostMapping( "/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(baseSensorInfoService.deleteBaseSensorInfoByObjIds(ids)); + /** 设置传感器阈值 */ + @GetMapping("/set/{objId}") + public String set(@PathVariable("objId") Long objId, ModelMap mmap) { + BaseSensorInfoDto baseSensorInfo = baseSensorInfoService.selectBaseSensorInfoByObjId(objId); + mmap.put("baseSensorInfo", baseSensorInfo); + return prefix + "/setAlarmParam"; + } + + /** 保存传感器阈值 */ + @RequiresPermissions("base:sensorInfo:set") + @Log(title = "传感器信息", businessType = BusinessType.UPDATE) + @PostMapping("/set") + @ResponseBody + public AjaxResult setSave(BaseSensorInfoDto baseSensorInfo) { + int paramLength = baseSensorInfo.getParamCode().length; + + try{ + for(int i=0;i json = new ArrayList(); + json.add(new JsonRootBean("p-01","温度","A2001")); + json.add(new JsonRootBean("p-02","湿度","A2002")); + AjaxResult ajax=new AjaxResult(); + ajax.put("code", 200); + ajax.put("value",json); + return ajax; + } } + +/** + * Auto-generated: 2022-03-08 16:13:42 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +class JsonRootBean { + + public JsonRootBean() { + } + + public JsonRootBean(String paramId, String paramName, String paramCode) { + this.paramId = paramId; + this.paramName = paramName; + this.paramCode = paramCode; + } + + private String paramId; + private String paramName; + private String paramCode; + + public String getParamId() { + return paramId; + } + + public void setParamId(String paramId) { + this.paramId = paramId; + } + + public String getParamName() { + return paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public String getParamCode() { + return paramCode; + } + + public void setParamCode(String paramCode) { + this.paramCode = paramCode; + } +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index 50ce20d..eda1e75 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -1172,6 +1172,26 @@ var table = { } return url; }, + // 设置参数 + setParam: function(id) { + table.set(); + $.modal.open("设置" + table.options.modalName, $.operate.setParamUrl(id)); + }, + // 设置参数访问地址 + setParamUrl: function(id) { + var url = "/404.html"; + if ($.common.isNotEmpty(id)) { + url = table.options.setParamUrl.replace("{id}", id); + } else { + var id = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId); + if (id.length == 0) { + $.modal.alertWarning("请至少选择一条记录"); + return; + } + url = table.options.setParamUrl.replace("{id}", id); + } + return url; + }, // 保存信息 刷新表格 save: function(url, data, callback) { var config = { diff --git a/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html index 51c5b9c..b1693d7 100644 --- a/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html +++ b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html @@ -127,6 +127,7 @@ removeUrl: prefix + "/remove", exportUrl: prefix + "/export", importUrl: prefix + "/importData", + setParamUrl: prefix + "/set/{id}", importTemplateUrl: prefix + "/importTemplate", modalName: "传感器信息", columns: [{ @@ -209,6 +210,7 @@ align: 'center', formatter: function(value, row, index) { var actions = []; + actions.push('设置阈值 '); actions.push('编辑 '); actions.push('删除'); return actions.join(''); diff --git a/ruoyi-admin/src/main/resources/templates/base/sensorInfo/setAlarmParam.html b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/setAlarmParam.html new file mode 100644 index 0000000..710b361 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/setAlarmParam.html @@ -0,0 +1,163 @@ + + + + + + + + + +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+ +

设置阈值参数

+
+
+ +
+
+ +
+ + +
+
+
+
+ +
+
+ + +
+ + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/login.html b/ruoyi-admin/src/main/resources/templates/login.html index e71a6a7..c61f2e2 100644 --- a/ruoyi-admin/src/main/resources/templates/login.html +++ b/ruoyi-admin/src/main/resources/templates/login.html @@ -37,8 +37,8 @@

用户登录

- - + +
diff --git a/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html b/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html index a43a9d7..707c217 100644 --- a/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html +++ b/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html @@ -598,13 +598,13 @@ tags: ['2'], nodes: [ { - text: 'Child 1', - href: '#child1', + text: '1#变压器', + href: '#1#变压器', tags: ['0'], }, { - text: 'Child 2', - href: '#child2', + text: '2#变压器', + href: '#2#变压器', tags: ['0'] } ] diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmInfo.java index 5a7b174..3b67766 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmInfo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmInfo.java @@ -33,7 +33,7 @@ public class BaseAlarmInfo extends BaseEntity /** 阈值(最小) */ @Excel(name = "阈值(最小)") - private String minValue; + private BigDecimal minValue; /** 是否启用 */ @Excel(name = "是否启用") @@ -75,12 +75,12 @@ public class BaseAlarmInfo extends BaseEntity { return maxValue; } - public void setMinValue(String minValue) + public void setMinValue(BigDecimal minValue) { this.minValue = minValue; } - public String getMinValue() + public BigDecimal getMinValue() { return minValue; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java index 397f05e..44a69aa 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java @@ -3,6 +3,8 @@ package com.ruoyi.system.domain.dto; import com.ruoyi.system.domain.BaseSensorInfo; import lombok.Data; +import java.math.BigDecimal; + /** * @author WenJY * @date 2022年02月11日 8:54 @@ -10,4 +12,10 @@ import lombok.Data; @Data public class BaseSensorInfoDto extends BaseSensorInfo { private String monitorunitName; + + private String[] paramCode; + + private BigDecimal[] maxValue; + + private BigDecimal[] minValue; }