add - 设备参数维护

main
wenjy 3 years ago
parent 334922aa46
commit c4e0a7c130

@ -0,0 +1,136 @@
package com.ruoyi.web.controller.base;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BaseDeviceParam;
import com.ruoyi.system.service.IBaseDeviceParamService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* Controller
*
* @author WenJY
* @date 2022-03-24
*/
@Controller
@RequestMapping("/base/deviceParam")
public class BaseDeviceParamController extends BaseController
{
private String prefix = "base/deviceParam";
@Autowired
private IBaseDeviceParamService baseDeviceParamService;
@RequiresPermissions("base:deviceParam:view")
@GetMapping()
public String deviceParam()
{
return prefix + "/deviceParam";
}
/**
*
*/
@RequiresPermissions("base:deviceParam:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(BaseDeviceParam baseDeviceParam)
{
startPage();
List<BaseDeviceParam> list = baseDeviceParamService.selectBaseDeviceParamList(baseDeviceParam);
return getDataTable(list);
}
@PostMapping("/getParams")
@ResponseBody
public String getDeviceParams(String deviceId) {
List<BaseDeviceParam> baseDeviceParams = baseDeviceParamService.selectBaseDeviceParamList(new BaseDeviceParam(deviceId, 0L));
return JSONArray.toJSONString(baseDeviceParams);
}
/**
*
*/
@RequiresPermissions("base:deviceParam:export")
@Log(title = "设备参数", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(BaseDeviceParam baseDeviceParam)
{
List<BaseDeviceParam> list = baseDeviceParamService.selectBaseDeviceParamList(baseDeviceParam);
ExcelUtil<BaseDeviceParam> util = new ExcelUtil<BaseDeviceParam>(BaseDeviceParam.class);
return util.exportExcel(list, "设备参数数据");
}
/**
*
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
*
*/
@RequiresPermissions("base:deviceParam:add")
@Log(title = "设备参数", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(BaseDeviceParam baseDeviceParam)
{
return toAjax(baseDeviceParamService.insertBaseDeviceParam(baseDeviceParam));
}
/**
*
*/
@GetMapping("/edit/{ObjId}")
public String edit(@PathVariable("ObjId") Long ObjId, ModelMap mmap)
{
BaseDeviceParam baseDeviceParam = baseDeviceParamService.selectBaseDeviceParamByObjId(ObjId);
mmap.put("baseDeviceParam", baseDeviceParam);
return prefix + "/edit";
}
/**
*
*/
@RequiresPermissions("base:deviceParam:edit")
@Log(title = "设备参数", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(BaseDeviceParam baseDeviceParam)
{
return toAjax(baseDeviceParamService.updateBaseDeviceParam(baseDeviceParam));
}
/**
*
*/
@RequiresPermissions("base:deviceParam:remove")
@Log(title = "设备参数", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(baseDeviceParamService.deleteBaseDeviceParamByObjIds(ids));
}
}

@ -5,7 +5,12 @@ import java.util.List;
import java.util.UUID;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.BaseAlarmInfo;
import com.ruoyi.system.domain.BaseDeviceParam;
import com.ruoyi.system.domain.dto.BaseAlarmInfoDto;
import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import com.ruoyi.system.service.IBaseDeviceParamService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -28,172 +33,200 @@ import org.springframework.web.multipart.MultipartFile;
/**
* Controller
*
*
* @author wenjy
* @date 2022-01-27
*/
@Controller
@RequestMapping("/base/monitorUnitInfo")
public class BaseMonitorunitInfoController extends BaseController
{
private String prefix = "base/monitorUnitInfo";
@Autowired
private IBaseMonitorunitInfoService baseMonitorunitInfoService;
@RequiresPermissions("base:monitorUnitInfo:view")
@GetMapping()
public String monitorUnitInfo()
{
return prefix + "/monitorUnitInfo";
public class BaseMonitorunitInfoController extends BaseController {
private String prefix = "base/monitorUnitInfo";
@Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService;
@Autowired private IBaseDeviceParamService baseDeviceParamService;
@RequiresPermissions("base:monitorUnitInfo:view")
@GetMapping()
public String monitorUnitInfo() {
return prefix + "/monitorUnitInfo";
}
/** 查询监控单元信息树列表 */
@RequiresPermissions("base:monitorUnitInfo:list")
@PostMapping("/list")
@ResponseBody
public List<BaseMonitorunitInfoDto> list(BaseMonitorunitInfo baseMonitorunitInfo) {
List<BaseMonitorunitInfoDto> list =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
return list;
}
/**
*
*
* @author WenJY
* @date 2022/2/7 9:57
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@RequiresPermissions("base:monitorUnitInfo:importTemplate")
@GetMapping("/importTemplate")
@ResponseBody
public AjaxResult importTemplate() {
ExcelUtil<BaseMonitorunitInfo> util =
new ExcelUtil<BaseMonitorunitInfo>(BaseMonitorunitInfo.class);
return util.importTemplateExcel("监控单元信息");
}
/**
*
*
* @author WenJY
* @date 2022/2/7 9:58
* @param file
* @param updateSupport
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@RequiresPermissions("base:monitorUnitInfo:importData")
@PostMapping("/importData")
@ResponseBody
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<BaseMonitorunitInfo> util =
new ExcelUtil<BaseMonitorunitInfo>(BaseMonitorunitInfo.class);
// 读取file文件将文件内容转为list集合
List<BaseMonitorunitInfo> baseMonitorunitInfoList = util.importExcel(file.getInputStream());
String message = baseMonitorunitInfoService.importMould(baseMonitorunitInfoList, updateSupport);
return AjaxResult.success(message);
}
/** 导出监控单元信息列表 */
@RequiresPermissions("base:monitorUnitInfo:export")
@Log(title = "监控单元信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(BaseMonitorunitInfo baseMonitorunitInfo) {
List<BaseMonitorunitInfo> list =
baseMonitorunitInfoService.selectBaseMonitorunitInfoList(baseMonitorunitInfo);
ExcelUtil<BaseMonitorunitInfo> util =
new ExcelUtil<BaseMonitorunitInfo>(BaseMonitorunitInfo.class);
return util.exportExcel(list, "监控单元信息数据");
}
/** 新增监控单元信息 */
@GetMapping(value = {"/add/{ObjId}", "/add/"})
public String add(@PathVariable(value = "ObjId", required = false) Long ObjId, ModelMap mmap) {
if (StringUtils.isNotNull(ObjId)) {
mmap.put(
"baseMonitorunitInfo",
baseMonitorunitInfoService.selectBaseMonitorunitInfoByObjId(ObjId));
}
/**
*
*/
@RequiresPermissions("base:monitorUnitInfo:list")
@PostMapping("/list")
@ResponseBody
public List<BaseMonitorunitInfoDto> list(BaseMonitorunitInfo baseMonitorunitInfo)
{
List<BaseMonitorunitInfoDto> list = baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
return list;
}
/**
*
* @author WenJY
* @date 2022/2/7 9:57
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@RequiresPermissions("base:monitorUnitInfo:importTemplate")
@GetMapping("/importTemplate")
@ResponseBody
public AjaxResult importTemplate() {
ExcelUtil<BaseMonitorunitInfo> util = new ExcelUtil<BaseMonitorunitInfo>(BaseMonitorunitInfo.class);
return util.importTemplateExcel("监控单元信息");
}
/**
*
* @author WenJY
* @date 2022/2/7 9:58
* @param file
* @param updateSupport
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@RequiresPermissions("base:monitorUnitInfo:importData")
@PostMapping("/importData")
@ResponseBody
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<BaseMonitorunitInfo> util = new ExcelUtil<BaseMonitorunitInfo>(BaseMonitorunitInfo.class);
//读取file文件将文件内容转为list集合
List<BaseMonitorunitInfo> baseMonitorunitInfoList = util.importExcel(file.getInputStream());
String message = baseMonitorunitInfoService.importMould(baseMonitorunitInfoList,updateSupport);
return AjaxResult.success(message);
}
/**
*
*/
@RequiresPermissions("base:monitorUnitInfo:export")
@Log(title = "监控单元信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(BaseMonitorunitInfo baseMonitorunitInfo)
{
List<BaseMonitorunitInfo> list = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(baseMonitorunitInfo);
ExcelUtil<BaseMonitorunitInfo> util = new ExcelUtil<BaseMonitorunitInfo>(BaseMonitorunitInfo.class);
return util.exportExcel(list, "监控单元信息数据");
}
/**
*
*/
@GetMapping(value = { "/add/{ObjId}", "/add/" })
public String add(@PathVariable(value = "ObjId", required = false) Long ObjId, ModelMap mmap)
{
if (StringUtils.isNotNull(ObjId))
{
mmap.put("baseMonitorunitInfo", baseMonitorunitInfoService.selectBaseMonitorunitInfoByObjId(ObjId));
}
return prefix + "/add";
}
/**
*
*/
@RequiresPermissions("base:monitorUnitInfo:add")
@Log(title = "监控单元信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(BaseMonitorunitInfo baseMonitorunitInfo)
{
baseMonitorunitInfo.setMonitorunitId(UUID.randomUUID().toString());
baseMonitorunitInfo.setCreateBy(ShiroUtils.getLoginName());
baseMonitorunitInfo.setCreateTime(new Date());
return toAjax(baseMonitorunitInfoService.insertBaseMonitorunitInfo(baseMonitorunitInfo));
}
/**
*
*/
@GetMapping("/edit/{ObjId}")
public String edit(@PathVariable("ObjId") Long ObjId, ModelMap mmap)
{
BaseMonitorunitInfo baseMonitorunitInfo = baseMonitorunitInfoService.selectBaseMonitorunitInfoByObjId(ObjId);
mmap.put("baseMonitorunitInfo", baseMonitorunitInfo);
return prefix + "/edit";
}
/**
*
*/
@RequiresPermissions("base:monitorUnitInfo:edit")
@Log(title = "监控单元信息", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(BaseMonitorunitInfo baseMonitorunitInfo)
{
baseMonitorunitInfo.setUpdateBy(ShiroUtils.getLoginName());
baseMonitorunitInfo.setUpdateTime(new Date());
return toAjax(baseMonitorunitInfoService.updateBaseMonitorunitInfo(baseMonitorunitInfo));
return prefix + "/add";
}
/** 新增保存监控单元信息 */
@RequiresPermissions("base:monitorUnitInfo:add")
@Log(title = "监控单元信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(BaseMonitorunitInfo baseMonitorunitInfo) {
baseMonitorunitInfo.setMonitorunitId(UUID.randomUUID().toString());
baseMonitorunitInfo.setCreateBy(ShiroUtils.getLoginName());
baseMonitorunitInfo.setCreateTime(new Date());
return toAjax(baseMonitorunitInfoService.insertBaseMonitorunitInfo(baseMonitorunitInfo));
}
/** 修改监控单元信息 */
@GetMapping("/edit/{ObjId}")
public String edit(@PathVariable("ObjId") Long ObjId, ModelMap mmap) {
BaseMonitorunitInfo baseMonitorunitInfo =
baseMonitorunitInfoService.selectBaseMonitorunitInfoByObjId(ObjId);
mmap.put("baseMonitorunitInfo", baseMonitorunitInfo);
return prefix + "/edit";
}
/** 修改保存监控单元信息 */
@RequiresPermissions("base:monitorUnitInfo:edit")
@Log(title = "监控单元信息", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(BaseMonitorunitInfo baseMonitorunitInfo) {
baseMonitorunitInfo.setUpdateBy(ShiroUtils.getLoginName());
baseMonitorunitInfo.setUpdateTime(new Date());
return toAjax(baseMonitorunitInfoService.updateBaseMonitorunitInfo(baseMonitorunitInfo));
}
/** 设置设备参数 */
@GetMapping("/set/{objId}")
public String set(@PathVariable("objId") Long objId, ModelMap mmap) {
BaseMonitorunitInfo baseMonitorunitInfo =
baseMonitorunitInfoService.selectBaseMonitorunitInfoByObjId(objId);
mmap.put("baseMonitorunitInfo", baseMonitorunitInfo);
mmap.put(
"baseDeviceParams",
baseDeviceParamService.selectBaseDeviceParamList(
new BaseDeviceParam(baseMonitorunitInfo.getMonitorunitId(), 0L)));
return prefix + "/setDeviceParam";
}
/** 保存传感器阈值 */
@RequiresPermissions("base:monitorUnitInfo:set")
@PostMapping("/set")
@ResponseBody
public AjaxResult setSave(BaseMonitorunitInfoDto baseMonitorunitInfoDto) {
try {
BaseDeviceParam[] deviceParams = baseMonitorunitInfoDto.getDeviceParams();
List<BaseDeviceParam> baseDeviceParams =
baseDeviceParamService.selectBaseDeviceParamList(
new BaseDeviceParam(baseMonitorunitInfoDto.getMonitorunitId(), 0L));
if (baseDeviceParams.size() > 0) {
baseDeviceParams.forEach(
x -> {
baseDeviceParamService.deleteBaseDeviceParamByObjId(x.getObjId());
});
}
for (BaseDeviceParam deviceParam : deviceParams) {
deviceParam.setDeviceId(baseMonitorunitInfoDto.getMonitorunitId());
deviceParam.setCreateBy(ShiroUtils.getLoginName());
deviceParam.setCreateTime(new Date());
deviceParam.setEnableFlag(baseMonitorunitInfoDto.getEnableFlag());
baseDeviceParamService.insertBaseDeviceParam(deviceParam);
}
return AjaxResult.success();
} catch (Exception ex) {
return AjaxResult.error(ex.getMessage());
}
/**
*
*/
@RequiresPermissions("base:monitorUnitInfo:remove")
@Log(title = "监控单元信息", businessType = BusinessType.DELETE)
@GetMapping("/remove/{ObjId}")
@ResponseBody
public AjaxResult remove(@PathVariable("ObjId") Long ObjId)
{
return toAjax(baseMonitorunitInfoService.deleteBaseMonitorunitInfoByObjId(ObjId));
}
/**
*
*/
@GetMapping(value = { "/selectMonitorUnitInfoTree/{ObjId}", "/selectMonitorUnitInfoTree/" })
public String selectMonitorUnitInfoTree(@PathVariable(value = "ObjId", required = false) String ObjId, ModelMap mmap)
{
if (StringUtils.isNotNull(ObjId))
{
/*mmap.put("baseMonitorunitInfo", baseMonitorunitInfoService.selectBaseMonitorunitInfoByObjId(ObjId));*/
mmap.put("baseMonitorunitInfo",baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo(ObjId)).get(0));
}
return prefix + "/tree";
}
/**
*
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
{
List<Ztree> ztrees = baseMonitorunitInfoService.selectBaseMonitorunitInfoTree();
return ztrees;
}
/** 删除 */
@RequiresPermissions("base:monitorUnitInfo:remove")
@Log(title = "监控单元信息", businessType = BusinessType.DELETE)
@GetMapping("/remove/{ObjId}")
@ResponseBody
public AjaxResult remove(@PathVariable("ObjId") Long ObjId) {
return toAjax(baseMonitorunitInfoService.deleteBaseMonitorunitInfoByObjId(ObjId));
}
/** 选择监控单元信息树 */
@GetMapping(value = {"/selectMonitorUnitInfoTree/{ObjId}", "/selectMonitorUnitInfoTree/"})
public String selectMonitorUnitInfoTree(
@PathVariable(value = "ObjId", required = false) String ObjId, ModelMap mmap) {
if (StringUtils.isNotNull(ObjId)) {
/*mmap.put("baseMonitorunitInfo", baseMonitorunitInfoService.selectBaseMonitorunitInfoByObjId(ObjId));*/
mmap.put(
"baseMonitorunitInfo",
baseMonitorunitInfoService
.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo(ObjId))
.get(0));
}
return prefix + "/tree";
}
/** 加载监控单元信息树列表 */
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData() {
List<Ztree> ztrees = baseMonitorunitInfoService.selectBaseMonitorunitInfoTree();
return ztrees;
}
}

@ -6,12 +6,12 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://121.36.58.109:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Haiwei123456
# url: jdbc:mysql://localhost:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://121.36.58.109:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: root
# password: Haiwei123456
url: jdbc:mysql://localhost:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: root
# 从库数据源
slave:
# 从数据源开关/默认关闭

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增设备参数')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-deviceParam-add">
<div class="form-group">
<label class="col-sm-3 control-label">设备标识:</label>
<div class="col-sm-8">
<input name="deviceId" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">参数标题:</label>
<div class="col-sm-8">
<input name="paramTitle" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">参数值:</label>
<div class="col-sm-8">
<input name="paramValue" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否启用:</label>
<div class="col-sm-8">
<select name="enableFlag" class="form-control m-b" th:with="type=${@dict.getType('enable_flag')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "base/deviceParam"
$("#form-deviceParam-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-deviceParam-add').serialize());
}
}
</script>
</body>
</html>

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('设备参数列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>设备标识:</label>
<input type="text" name="deviceId"/>
</li>
<li>
<label>参数标题:</label>
<input type="text" name="paramTitle"/>
</li>
<li>
<label>参数值:</label>
<input type="text" name="paramValue"/>
</li>
<li>
<label>是否启用:</label>
<select name="enableFlag" th:with="type=${@dict.getType('enable_flag')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="base:deviceParam:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="base:deviceParam:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="base:deviceParam:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="base:deviceParam:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('base:deviceParam:edit')}]];
var removeFlag = [[${@permission.hasPermi('base:deviceParam:remove')}]];
var enableFlagDatas = [[${@dict.getType('enable_flag')}]];
var prefix = ctx + "base/deviceParam";
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "设备参数",
columns: [{
checkbox: true
},
{
field: 'ObjId',
title: '主键标识',
visible: false
},
{
field: 'deviceId',
title: '设备标识'
},
{
field: 'paramTitle',
title: '参数标题'
},
{
field: 'paramValue',
title: '参数值'
},
{
field: 'enableFlag',
title: '是否启用',
formatter: function(value, row, index) {
return $.table.selectDictLabel(enableFlagDatas, value);
}
},
{
field: 'createBy',
title: '创建人'
},
{
field: 'createTime',
title: '创建时间'
},
{
field: 'updateBy',
title: '更新人'
},
{
field: 'updateTime',
title: '更新时间'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.ObjId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.ObjId + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
</body>
</html>

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改设备参数')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-deviceParam-edit" th:object="${baseDeviceParam}">
<input name="ObjId" th:field="*{ObjId}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">设备标识:</label>
<div class="col-sm-8">
<input name="deviceId" th:field="*{deviceId}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">参数标题:</label>
<div class="col-sm-8">
<input name="paramTitle" th:field="*{paramTitle}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">参数值:</label>
<div class="col-sm-8">
<input name="paramValue" th:field="*{paramValue}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否启用:</label>
<div class="col-sm-8">
<select name="enableFlag" class="form-control m-b" th:with="type=${@dict.getType('enable_flag')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{enableFlag}"></option>
</select>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "base/deviceParam";
$("#form-deviceParam-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-deviceParam-edit').serialize());
}
}
</script>
</body>
</html>

@ -104,6 +104,7 @@
exportUrl: prefix + "/export",
importUrl: prefix + "/importData",
importTemplateUrl: prefix + "/importTemplate",
setParamUrl: prefix + "/set/{id}",
modalName: "监控单元信息",
columns: [{
field: 'selectItem',
@ -176,6 +177,7 @@
align: 'left',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.setParam(\'' + row.objId + '\')"><i class="fa fa-edit"></i>设备参数</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.objId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.objId + '\')"><i class="fa fa-plus"></i>新增</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.objId + '\')"><i class="fa fa-remove"></i>删除</a>');

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('设备参数')"/>
<th:block th:include="include :: select2-css"/>
<th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-device-param" th:object="${baseMonitorunitInfo}">
<input name="objId" th:field="*{objId}" type="hidden">
<input name="monitorunitId" type="hidden" th:field="*{monitorunitId}" id="monitorunitId"/>
<div class="form-group">
<label class="col-sm-3 control-label">监控单元:</label>
<div class="col-sm-8">
<input name="monitorunitName" th:field="*{monitorunitName}" class="form-control" type="text"
readonly="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否启用:</label>
<div class="col-sm-8">
<select name="enableFlag" id="enableFlag" class="form-control m-b"
th:with="type=${@dict.getType('enable_flag')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<h4 class="form-header h4">设备参数</h4>
<div class="row">
<div class="col-sm-12">
<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i>
</button>
<button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus">
删除</i></button>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-suggest-js"/>
<th:block th:include="include :: bootstrap-typeahead-js"/>
<th:block th:include="include :: select2-js"/>
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script th:inline="javascript">
var prefix = ctx + "base/monitorUnitInfo";
$("#form-sensorInfo-edit").validate({
focusCleanup: true
});
$(function () {
let data = [[${baseDeviceParams}]];
// 初始化数据, 可以由后台传过来
var options = {
data: data,
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [{
checkbox: true
},
{
field: 'index',
align: 'center',
title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
var columnId = $.common.sprintf("<input type='hidden' name='deviceParams[%s].id' value='%s'>", index, row.id);
return columnIndex + $.table.serialNumber(index) + columnId;
}
},
{
field: 'paramTitle',
align: 'center',
title: '参数名',
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='deviceParams[%s].paramTitle' value='%s'>", index, value);
return html;
}
},
{
field: 'paramValue',
align: 'center',
title: '参数值',
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='deviceParams[%s].paramValue' value='%s'>", index, value);
return html;
}
}]
};
$.table.init(options);
});
function addColumn() {
var row = {
name: "",
paramTitle: "",
paramValue: "",
}
sub.addColumn(row);
}
/* 主子表-提交 */
function submitHandler(index, layero) {
var data = $("#form-device-param").serializeArray();
$.operate.save(prefix + "/set", data);
}
</script>
</body>
</html>

@ -0,0 +1,105 @@
package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* base_device_param
*
* @author WenJY
* @date 2022-03-24
*/
public class BaseDeviceParam extends BaseEntity
{
private static final long serialVersionUID = 1L;
public BaseDeviceParam() {
}
public BaseDeviceParam(String deviceId, Long enableFlag) {
this.deviceId = deviceId;
this.enableFlag = enableFlag;
}
/** 主键标识 */
private Long ObjId;
/** 设备标识 */
@Excel(name = "设备标识")
private String deviceId;
/** 参数标题 */
@Excel(name = "参数标题")
private String paramTitle;
/** 参数值 */
@Excel(name = "参数值")
private String paramValue;
/** 是否启用 */
@Excel(name = "是否启用")
private Long enableFlag;
public void setObjId(Long ObjId)
{
this.ObjId = ObjId;
}
public Long getObjId()
{
return ObjId;
}
public void setDeviceId(String deviceId)
{
this.deviceId = deviceId;
}
public String getDeviceId()
{
return deviceId;
}
public void setParamTitle(String paramTitle)
{
this.paramTitle = paramTitle;
}
public String getParamTitle()
{
return paramTitle;
}
public void setParamValue(String paramValue)
{
this.paramValue = paramValue;
}
public String getParamValue()
{
return paramValue;
}
public void setEnableFlag(Long enableFlag)
{
this.enableFlag = enableFlag;
}
public Long getEnableFlag()
{
return enableFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("ObjId", getObjId())
.append("deviceId", getDeviceId())
.append("paramTitle", getParamTitle())
.append("paramValue", getParamValue())
.append("enableFlag", getEnableFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -1,5 +1,6 @@
package com.ruoyi.system.domain.dto;
import com.ruoyi.system.domain.BaseDeviceParam;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
import lombok.Data;
@ -21,4 +22,6 @@ public class BaseMonitorunitInfoDto extends BaseMonitorunitInfo {
private int value;
private String unitUrl;
private BaseDeviceParam[] deviceParams;
}

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.BaseDeviceParam;
/**
* Mapper
*
* @author WenJY
* @date 2022-03-24
*/
public interface BaseDeviceParamMapper
{
/**
*
*
* @param ObjId
* @return
*/
public BaseDeviceParam selectBaseDeviceParamByObjId(Long ObjId);
/**
*
*
* @param baseDeviceParam
* @return
*/
public List<BaseDeviceParam> selectBaseDeviceParamList(BaseDeviceParam baseDeviceParam);
/**
*
*
* @param baseDeviceParam
* @return
*/
public int insertBaseDeviceParam(BaseDeviceParam baseDeviceParam);
/**
*
*
* @param baseDeviceParam
* @return
*/
public int updateBaseDeviceParam(BaseDeviceParam baseDeviceParam);
/**
*
*
* @param ObjId
* @return
*/
public int deleteBaseDeviceParamByObjId(Long ObjId);
/**
*
*
* @param ObjIds
* @return
*/
public int deleteBaseDeviceParamByObjIds(String[] ObjIds);
}

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.BaseDeviceParam;
/**
* Service
*
* @author WenJY
* @date 2022-03-24
*/
public interface IBaseDeviceParamService
{
/**
*
*
* @param ObjId
* @return
*/
public BaseDeviceParam selectBaseDeviceParamByObjId(Long ObjId);
/**
*
*
* @param baseDeviceParam
* @return
*/
public List<BaseDeviceParam> selectBaseDeviceParamList(BaseDeviceParam baseDeviceParam);
/**
*
*
* @param baseDeviceParam
* @return
*/
public int insertBaseDeviceParam(BaseDeviceParam baseDeviceParam);
/**
*
*
* @param baseDeviceParam
* @return
*/
public int updateBaseDeviceParam(BaseDeviceParam baseDeviceParam);
/**
*
*
* @param ObjIds
* @return
*/
public int deleteBaseDeviceParamByObjIds(String ObjIds);
/**
*
*
* @param ObjId
* @return
*/
public int deleteBaseDeviceParamByObjId(Long ObjId);
}

@ -0,0 +1,97 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BaseDeviceParamMapper;
import com.ruoyi.system.domain.BaseDeviceParam;
import com.ruoyi.system.service.IBaseDeviceParamService;
import com.ruoyi.common.core.text.Convert;
/**
* Service
*
* @author WenJY
* @date 2022-03-24
*/
@Service
public class BaseDeviceParamServiceImpl implements IBaseDeviceParamService
{
@Autowired
private BaseDeviceParamMapper baseDeviceParamMapper;
/**
*
*
* @param ObjId
* @return
*/
@Override
public BaseDeviceParam selectBaseDeviceParamByObjId(Long ObjId)
{
return baseDeviceParamMapper.selectBaseDeviceParamByObjId(ObjId);
}
/**
*
*
* @param baseDeviceParam
* @return
*/
@Override
public List<BaseDeviceParam> selectBaseDeviceParamList(BaseDeviceParam baseDeviceParam)
{
return baseDeviceParamMapper.selectBaseDeviceParamList(baseDeviceParam);
}
/**
*
*
* @param baseDeviceParam
* @return
*/
@Override
public int insertBaseDeviceParam(BaseDeviceParam baseDeviceParam)
{
baseDeviceParam.setCreateTime(DateUtils.getNowDate());
return baseDeviceParamMapper.insertBaseDeviceParam(baseDeviceParam);
}
/**
*
*
* @param baseDeviceParam
* @return
*/
@Override
public int updateBaseDeviceParam(BaseDeviceParam baseDeviceParam)
{
baseDeviceParam.setUpdateTime(DateUtils.getNowDate());
return baseDeviceParamMapper.updateBaseDeviceParam(baseDeviceParam);
}
/**
*
*
* @param ObjIds
* @return
*/
@Override
public int deleteBaseDeviceParamByObjIds(String ObjIds)
{
return baseDeviceParamMapper.deleteBaseDeviceParamByObjIds(Convert.toStrArray(ObjIds));
}
/**
*
*
* @param ObjId
* @return
*/
@Override
public int deleteBaseDeviceParamByObjId(Long ObjId)
{
return baseDeviceParamMapper.deleteBaseDeviceParamByObjId(ObjId);
}
}

@ -0,0 +1,87 @@
<?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="com.ruoyi.system.mapper.BaseDeviceParamMapper">
<resultMap type="BaseDeviceParam" id="BaseDeviceParamResult">
<result property="ObjId" column="ObjId" />
<result property="deviceId" column="Device_Id" />
<result property="paramTitle" column="Param_Title" />
<result property="paramValue" column="Param_Value" />
<result property="enableFlag" column="Enable_Flag" />
<result property="createBy" column="Create_By" />
<result property="createTime" column="Create_Time" />
<result property="updateBy" column="Update_By" />
<result property="updateTime" column="Update_Time" />
</resultMap>
<sql id="selectBaseDeviceParamVo">
select ObjId, Device_Id, Param_Title, Param_Value, Enable_Flag, Create_By, Create_Time, Update_By, Update_Time from base_device_param
</sql>
<select id="selectBaseDeviceParamList" parameterType="BaseDeviceParam" resultMap="BaseDeviceParamResult">
<include refid="selectBaseDeviceParamVo"/>
<where>
<if test="deviceId != null and deviceId != ''"> and Device_Id = #{deviceId}</if>
<if test="paramTitle != null and paramTitle != ''"> and Param_Title = #{paramTitle}</if>
<if test="enableFlag != null "> and Enable_Flag = #{enableFlag}</if>
</where>
</select>
<select id="selectBaseDeviceParamByObjId" parameterType="Long" resultMap="BaseDeviceParamResult">
<include refid="selectBaseDeviceParamVo"/>
where ObjId = #{ObjId}
</select>
<insert id="insertBaseDeviceParam" parameterType="BaseDeviceParam" useGeneratedKeys="true" keyProperty="ObjId">
insert into base_device_param
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">Device_Id,</if>
<if test="paramTitle != null">Param_Title,</if>
<if test="paramValue != null">Param_Value,</if>
<if test="enableFlag != null">Enable_Flag,</if>
<if test="createBy != null">Create_By,</if>
<if test="createTime != null">Create_Time,</if>
<if test="updateBy != null">Update_By,</if>
<if test="updateTime != null">Update_Time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="paramTitle != null">#{paramTitle},</if>
<if test="paramValue != null">#{paramValue},</if>
<if test="enableFlag != null">#{enableFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateBaseDeviceParam" parameterType="BaseDeviceParam">
update base_device_param
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">Device_Id = #{deviceId},</if>
<if test="paramTitle != null">Param_Title = #{paramTitle},</if>
<if test="paramValue != null">Param_Value = #{paramValue},</if>
<if test="enableFlag != null">Enable_Flag = #{enableFlag},</if>
<if test="createBy != null">Create_By = #{createBy},</if>
<if test="createTime != null">Create_Time = #{createTime},</if>
<if test="updateBy != null">Update_By = #{updateBy},</if>
<if test="updateTime != null">Update_Time = #{updateTime},</if>
</trim>
where ObjId = #{ObjId}
</update>
<delete id="deleteBaseDeviceParamByObjId" parameterType="Long">
delete from base_device_param where ObjId = #{ObjId}
</delete>
<delete id="deleteBaseDeviceParamByObjIds" parameterType="String">
delete from base_device_param where ObjId in
<foreach item="ObjId" collection="array" open="(" separator="," close=")">
#{ObjId}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save