add - 添加传感器信息

main
wenjy 3 years ago
parent 4e3b4523ca
commit c190a65dfa

@ -0,0 +1,166 @@
package com.ruoyi.web.controller.base;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
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.BaseSensorInfo;
import com.ruoyi.system.service.IBaseSensorInfoService;
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;
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";
}
/**
*
*/
@RequiresPermissions("base:sensorInfo:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(BaseSensorInfo baseSensorInfo)
{
startPage();
List<BaseSensorInfoDto> list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
return getDataTable(list);
}
/**
*
* @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<BaseSensorInfo> util = new ExcelUtil<BaseSensorInfo>(BaseSensorInfo.class);
return util.importTemplateExcel("传感器信息");
}
/**
*
* @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<BaseSensorInfo> util = new ExcelUtil<BaseSensorInfo>(BaseSensorInfo.class);
//读取file文件将文件内容转为list集合
List<BaseSensorInfo> baseSensorInfos = util.importExcel(file.getInputStream());
String message = baseSensorInfoService.importMould(baseSensorInfos,updateSupport);
return AjaxResult.success(message);
}
/**
*
*/
@RequiresPermissions("base:sensorInfo:export")
@Log(title = "传感器信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(BaseSensorInfo baseSensorInfo)
{
List<BaseSensorInfoDto> list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
ExcelUtil<BaseSensorInfoDto> util = new ExcelUtil<BaseSensorInfoDto>(BaseSensorInfoDto.class);
return util.exportExcel(list, "传感器信息数据");
}
/**
*
*/
@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)
{
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));
}
}

@ -0,0 +1,132 @@
<!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-sensorInfo-add">
<input name="monitorunitId" type="hidden" id="treeId"/>
<div class="form-group">
<label class="col-sm-3 control-label">edgeId</label>
<div class="col-sm-8">
<input name="EdgeId" 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="sensorId" 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="sensorName" 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="sensorType" class="form-control m-b"
th:with="type=${@sensorTypeService.getSensorType()}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.sensortypeName}"
th:value="${dict.sensortypeId}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">传感器状态:</label>
<div class="col-sm-8">
<select name="sensorStatus" class="form-control m-b"
th:with="type=${@dict.getType('base_sensor_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">所属监控单元:</label>
<div class="col-sm-8">
<div class="input-group">
<input class="form-control" type="text" name="treeName" onclick="selectMonitorTree()" id="treeName">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">传感器位置:</label>
<div class="col-sm-8">
<input name="sensorLocation" 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="sensorAddress" 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="orderNum" 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/sensorInfo"
$("#form-sensorInfo-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-sensorInfo-add').serialize());
}
}
/* 选择监控单元树 */
function selectMonitorTree() {
var deptId = $.common.isEmpty($("#monitorUnitId").val()) ? "100" : $("#monitorUnitId").val();
var url = ctx + "base/monitorUnitInfo/selectMonitorUnitInfoTree/" + deptId;
var options = {
title: '选择部门',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var tree = layero.find("iframe")[0].contentWindow.$._tree;
var body = $.modal.getChildFrame(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
$.modal.close(index);
}
$(()=>{
var cp_keynum = "key_num";
var str = localStorage.getItem(cp_keynum);
var num = JSON.parse(str);
if(num != null) {
$("#treeId").val(num.cp_num_value.substring(0, num.cp_num_value.indexOf('/')));
$("#treeName").val(num.cp_num_value.substring(num.cp_num_value.indexOf('/')+1,num.cp_num_value.length ));
}
})
</script>
</body>
</html>

@ -0,0 +1,118 @@
<!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-sensorInfo-edit" th:object="${baseSensorInfo}">
<input name="objId" th:field="*{objId}" type="hidden">
<input name="monitorunitId" type="hidden" th:field="*{monitorunitId}" id="treeId"/>
<div class="form-group">
<label class="col-sm-3 control-label">edgeId</label>
<div class="col-sm-8">
<input name="EdgeId" th:field="*{EdgeId}" 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="sensorId" th:field="*{sensorId}" 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="sensorName" th:field="*{sensorName}" 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="sensorType" class="form-control m-b" th:with="type=${@sensorTypeService.getSensorType()}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.sensortypeName}" th:value="${dict.sensortypeId}" th:field="*{sensorType}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">传感器状态:</label>
<div class="col-sm-8">
<select name="sensorStatus" class="form-control m-b" th:with="type=${@dict.getType('base_sensor_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sensorStatus}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">所属监控单元:</label>
<div class="col-sm-8">
<div class="input-group">
<input class="form-control" type="text" name="treeName" onclick="selectMonitorTree()" id="treeName" th:field="*{monitorunitName}">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">传感器位置:</label>
<div class="col-sm-8">
<input name="sensorLocation" th:field="*{sensorLocation}" 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="sensorAddress" th:field="*{sensorAddress}" 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="orderNum" th:field="*{orderNum}" 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/sensorInfo";
$("#form-sensorInfo-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-sensorInfo-edit').serialize());
}
}
/* 选择监控单元树 */
function selectMonitorTree() {
var deptId = $.common.isEmpty($("#monitorUnitId").val()) ? "100" : $("#monitorUnitId").val();
var url = ctx + "base/monitorUnitInfo/selectMonitorUnitInfoTree/" + deptId;
var options = {
title: '选择部门',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var tree = layero.find("iframe")[0].contentWindow.$._tree;
var body = $.modal.getChildFrame(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
$.modal.close(index);
}
</script>
</body>
</html>

@ -0,0 +1,279 @@
<!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('传感器信息列表')" />
<th:block th:include="include :: layout-latest-css" />
<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
<div class="ui-layout-west">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 监控单元
</div>
<div class="box-tools pull-right">
<a type="button" class="btn btn-box-tool" href="#" onclick="monitorUnitInfo()" title="监控单元"><i class="fa fa-edit"></i></a>
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i></button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
<div class="ui-layout-center">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<input id="monitorunitId" type="hidden" name="monitorunitId"/>
<div class="select-list">
<ul>
<li>
<label>名称:</label>
<input type="text" name="sensorName"/>
</li>
<li>
<label>类型:</label>
<select name="sensorType"
th:with="type=${@sensorTypeService.getSensorType()}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.sensortypeName}"
th:value="${dict.sensortypeId}"></option>
</select>
</li>
<li>
<label>状态:</label>
<select name="sensorStatus" th:with="type=${@dict.getType('base_sensor_status')}">
<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:sensorInfo:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="base:sensorInfo:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="base:sensorInfo:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-info" onclick="$.table.importExcel() " shiro:hasPermission="base:sensorInfo:import">
<i class="fa fa-upload"></i> 导入
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="base:sensorInfo: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>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('base:sensorInfo:edit')}]];
var removeFlag = [[${@permission.hasPermi('base:sensorInfo:remove')}]];
var sensorStatusDatas = [[${@dict.getType('base_sensor_status')}]];
var enableFlagDatas = [[${@dict.getType('enable_flag')}]];
var prefix = ctx + "base/sensorInfo";
$(()=>{
if(typeof(Storage) == 'undefined'){
alert('对不起,您的浏览器不支持 web 存储。')
}
});
$(function() {
var panehHidden = false;
if ($(this).width() < 769) {
panehHidden = true;
}
$('body').layout({ initClosed: panehHidden, west__size: 185 });
// 回到顶部绑定
if ($.fn.toTop !== undefined) {
var opt = {
win:$('.ui-layout-center'),
doc:$('.ui-layout-center')
};
$('#scroll-up').toTop(opt);
}
querySensorList();
queryMonitorTree();
});
function querySensorList() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
importUrl: prefix + "/importData",
importTemplateUrl: prefix + "/importTemplate",
modalName: "传感器信息",
columns: [{
checkbox: true
},
{
field: 'objId',
title: '主键标识',
visible: false
},
{
field: 'edgeId',
title: 'edgeId'
},
{
field: 'sensorId',
title: '传感器编号'
},
{
field: 'sensorName',
title: '传感器名称'
},
{
field: 'sensorType',
title: '传感器类型'
},
{
field: 'sensorStatus',
title: '传感器状态',
formatter: function(value, row, index) {
return $.table.selectDictLabel(sensorStatusDatas, value);
}
},
{
field: 'monitorunitName',
title: '监控单元'
},
{
field: 'sensorLocation',
title: '传感器位置'
},
{
field: 'sensorAddress',
title: '传感器地址(网络地址)'
},
{
field: 'orderNum',
title: '排序字段'
},
{
field: 'enableFlag',
title: '是否启用',
align: 'left',
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);
}
function queryMonitorTree()
{
var url = ctx + "base/monitorUnitInfo/treeData";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
$("#monitorunitId").val(treeNode.id);
$.table.search();
var num = new Object;
num.cp_keynum ="key_num";
num.cp_num_value = treeNode.id+"/"+treeNode.name;
var str = JSON.stringify(num); // 将对象转换为字符串
localStorage.setItem(num.cp_keynum,str);
}
}
$('#btnExpand').click(function() {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function() {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function() {
queryMonitorTree();
});
function monitorUnitInfo() {
var url = ctx + "base/monitorUnitInfo";
$.modal.openTab("监控单元", url);
}
</script>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
<form enctype="multipart/form-data" class="mt20 mb10">
<div class="col-xs-offset-1">
<input type="file" id="file" name="file"/>
<div class="mt10 pt5">
<input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据
&nbsp; <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i
class="fa fa-file-excel-o"></i> 下载模板</a>
</div>
<font color="red" class="pull-left mt10">
提示仅允许导入“xls”或“xlsx”格式文件
</font>
</div>
</form>
</script>
</body>
</html>

@ -0,0 +1,188 @@
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_sensor_info
*
* @author wenjy
* @date 2022-02-07
*/
public class BaseSensorInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
public BaseSensorInfo() {
}
public BaseSensorInfo(String sensorId) {
this.sensorId = sensorId;
}
/** 主键标识 */
private Long objId;
/** edgeId */
@Excel(name = "edgeId")
private String EdgeId;
/** 传感器编号 */
@Excel(name = "传感器编号")
private String sensorId;
/** 传感器名称 */
@Excel(name = "传感器名称")
private String sensorName;
/** 传感器类型 */
@Excel(name = "传感器类型")
private String sensorType;
/** 传感器状态 */
@Excel(name = "传感器状态")
private Long sensorStatus;
/** 所属监控单元 */
@Excel(name = "所属监控单元")
private String monitorunitId;
/** 传感器位置 */
@Excel(name = "传感器位置")
private String sensorLocation;
/** 传感器地址(网络地址) */
@Excel(name = "传感器地址(网络地址)")
private String sensorAddress;
/** 排序字段 */
@Excel(name = "排序字段")
private Long orderNum;
/** 是否启用 */
@Excel(name = "是否启用")
private Long enableFlag;
public void setObjId(Long objId)
{
this.objId = objId;
}
public Long getObjId()
{
return objId;
}
public void setEdgeId(String EdgeId)
{
this.EdgeId = EdgeId;
}
public String getEdgeId()
{
return EdgeId;
}
public void setSensorId(String sensorId)
{
this.sensorId = sensorId;
}
public String getSensorId()
{
return sensorId;
}
public void setSensorName(String sensorName)
{
this.sensorName = sensorName;
}
public String getSensorName()
{
return sensorName;
}
public void setSensorType(String sensorType)
{
this.sensorType = sensorType;
}
public String getSensorType()
{
return sensorType;
}
public void setSensorStatus(Long sensorStatus)
{
this.sensorStatus = sensorStatus;
}
public Long getSensorStatus()
{
return sensorStatus;
}
public void setMonitorunitId(String monitorunitId)
{
this.monitorunitId = monitorunitId;
}
public String getMonitorunitId()
{
return monitorunitId;
}
public void setSensorLocation(String sensorLocation)
{
this.sensorLocation = sensorLocation;
}
public String getSensorLocation()
{
return sensorLocation;
}
public void setSensorAddress(String sensorAddress)
{
this.sensorAddress = sensorAddress;
}
public String getSensorAddress()
{
return sensorAddress;
}
public void setOrderNum(Long orderNum)
{
this.orderNum = orderNum;
}
public Long getOrderNum()
{
return orderNum;
}
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("EdgeId", getEdgeId())
.append("sensorId", getSensorId())
.append("sensorName", getSensorName())
.append("sensorType", getSensorType())
.append("sensorStatus", getSensorStatus())
.append("monitorunitId", getMonitorunitId())
.append("sensorLocation", getSensorLocation())
.append("sensorAddress", getSensorAddress())
.append("orderNum", getOrderNum())
.append("enableFlag", getEnableFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -0,0 +1,13 @@
package com.ruoyi.system.domain.dto;
import com.ruoyi.system.domain.BaseSensorInfo;
import lombok.Data;
/**
* @author WenJY
* @date 20220211 8:54
*/
@Data
public class BaseSensorInfoDto extends BaseSensorInfo {
private String monitorunitName;
}

@ -0,0 +1,62 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
/**
* Mapper
*
* @author wenjy
* @date 2022-02-07
*/
public interface BaseSensorInfoMapper
{
/**
*
*
* @param objId
* @return
*/
public BaseSensorInfoDto selectBaseSensorInfoByObjId(Long objId);
/**
*
*
* @param baseSensorInfo
* @return
*/
public List<BaseSensorInfoDto> selectBaseSensorInfoList(BaseSensorInfo baseSensorInfo);
/**
*
*
* @param baseSensorInfo
* @return
*/
public int insertBaseSensorInfo(BaseSensorInfo baseSensorInfo);
/**
*
*
* @param baseSensorInfo
* @return
*/
public int updateBaseSensorInfo(BaseSensorInfo baseSensorInfo);
/**
*
*
* @param objId
* @return
*/
public int deleteBaseSensorInfoByObjId(Long objId);
/**
*
*
* @param objIds
* @return
*/
public int deleteBaseSensorInfoByObjIds(String[] objIds);
}

@ -0,0 +1,72 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
/**
* Service
*
* @author wenjy
* @date 2022-02-07
*/
public interface IBaseSensorInfoService
{
/**
*
*
* @param objId
* @return
*/
public BaseSensorInfoDto selectBaseSensorInfoByObjId(Long objId);
/**
*
*
* @param baseSensorInfo
* @return
*/
public List<BaseSensorInfoDto> selectBaseSensorInfoList(BaseSensorInfo baseSensorInfo);
/**
*
* @author WenJY
* @date 2022/2/11 9:59
* @param baseSensorInfos
* @param updateSupport
* @return java.lang.String
*/
public String importMould(List<BaseSensorInfo> baseSensorInfos, boolean updateSupport);
/**
*
*
* @param baseSensorInfo
* @return
*/
public int insertBaseSensorInfo(BaseSensorInfo baseSensorInfo);
/**
*
*
* @param baseSensorInfo
* @return
*/
public int updateBaseSensorInfo(BaseSensorInfo baseSensorInfo);
/**
*
*
* @param objIds
* @return
*/
public int deleteBaseSensorInfoByObjIds(String objIds);
/**
*
*
* @param objId
* @return
*/
public int deleteBaseSensorInfoByObjId(Long objId);
}

@ -0,0 +1,160 @@
package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BaseSensorInfoMapper;
import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.service.IBaseSensorInfoService;
import com.ruoyi.common.core.text.Convert;
/**
* Service
*
* @author wenjy
* @date 2022-02-07
*/
@Service
public class BaseSensorInfoServiceImpl implements IBaseSensorInfoService
{
@Autowired
private BaseSensorInfoMapper baseSensorInfoMapper;
/**
*
*
* @param objId
* @return
*/
@Override
public BaseSensorInfoDto selectBaseSensorInfoByObjId(Long objId)
{
return baseSensorInfoMapper.selectBaseSensorInfoByObjId(objId);
}
/**
*
*
* @param baseSensorInfo
* @return
*/
@Override
public List<BaseSensorInfoDto> selectBaseSensorInfoList(BaseSensorInfo baseSensorInfo)
{
return baseSensorInfoMapper.selectBaseSensorInfoList(baseSensorInfo);
}
/**
*
* @author WenJY
* @date 2022/2/11 10:06
* @param baseSensorInfos
* @param updateSupport
* @return java.lang.String
*/
@Override
public String importMould(List<BaseSensorInfo> baseSensorInfos, boolean updateSupport) {
if (StringUtils.isNull(baseSensorInfos) || baseSensorInfos.size() == 0) {
throw new BusinessException("导入标准数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (BaseSensorInfo baseSensorInfo : baseSensorInfos) {
try {
List<BaseSensorInfoDto> baseSensorInfoDtoList =
baseSensorInfoMapper.selectBaseSensorInfoList(
new BaseSensorInfo(baseSensorInfo.getSensorId()));
if (baseSensorInfoDtoList.size() == 0) {
baseSensorInfo.setCreateBy(ShiroUtils.getLoginName());
baseSensorInfo.setCreateTime(new Date());
baseSensorInfoMapper.insertBaseSensorInfo(baseSensorInfo);
successNum++;
successMsg.append("<br/>" + successNum + "、 " + baseSensorInfo.getSensorId() +"、 " + baseSensorInfo.getSensorName() + " 导入成功");
} else if (updateSupport) {
for (BaseSensorInfoDto baseSensorInfoDto : baseSensorInfoDtoList) {
baseSensorInfo.setObjId(baseSensorInfoDto.getObjId());
baseSensorInfo.setUpdateBy(ShiroUtils.getLoginName());
baseSensorInfo.setUpdateTime(new Date());
baseSensorInfoMapper.updateBaseSensorInfo(baseSensorInfo);
successNum++;
}
successMsg.append("<br/>" + successNum + "、 " + baseSensorInfo.getSensorId() +"、 " + baseSensorInfo.getSensorName() + " 更新成功");
} else {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、 " + baseSensorInfo.getSensorId() +"、 " + baseSensorInfo.getSensorName() + " 已存在");
}
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、标准: " + baseSensorInfo.getSensorId() +"、 " + baseSensorInfo.getSensorName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new BusinessException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
/**
*
*
* @param baseSensorInfo
* @return
*/
@Override
public int insertBaseSensorInfo(BaseSensorInfo baseSensorInfo)
{
baseSensorInfo.setCreateTime(DateUtils.getNowDate());
return baseSensorInfoMapper.insertBaseSensorInfo(baseSensorInfo);
}
/**
*
*
* @param baseSensorInfo
* @return
*/
@Override
public int updateBaseSensorInfo(BaseSensorInfo baseSensorInfo)
{
baseSensorInfo.setUpdateTime(DateUtils.getNowDate());
return baseSensorInfoMapper.updateBaseSensorInfo(baseSensorInfo);
}
/**
*
*
* @param objIds
* @return
*/
@Override
public int deleteBaseSensorInfoByObjIds(String objIds)
{
return baseSensorInfoMapper.deleteBaseSensorInfoByObjIds(Convert.toStrArray(objIds));
}
/**
*
*
* @param objId
* @return
*/
@Override
public int deleteBaseSensorInfoByObjId(Long objId)
{
return baseSensorInfoMapper.deleteBaseSensorInfoByObjId(objId);
}
}

@ -21,7 +21,7 @@ import com.ruoyi.common.core.text.Convert;
* @author wenjy
* @date 2022-02-07
*/
@Service
@Service("sensorTypeService")
public class BaseSensorTypeServiceImpl implements IBaseSensorTypeService
{
@Autowired
@ -51,6 +51,17 @@ public class BaseSensorTypeServiceImpl implements IBaseSensorTypeService
return baseSensorTypeMapper.selectBaseSensorTypeList(baseSensorType);
}
/**
*
* @author WenJY
* @date 2022/2/10 14:52
* @return java.util.List<com.ruoyi.system.domain.BaseSensorType>
*/
public List<BaseSensorType> getSensorType()
{
return baseSensorTypeMapper.selectBaseSensorTypeList(new BaseSensorType());
}
/**
*
* @author WenJY

@ -0,0 +1,171 @@
<?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.BaseSensorInfoMapper">
<resultMap type="BaseSensorInfo" id="BaseSensorInfoResult">
<result property="objId" column="ObjId" />
<result property="edgeId" column="EdgeId" />
<result property="sensorId" column="Sensor_Id" />
<result property="sensorName" column="Sensor_Name" />
<result property="sensorType" column="Sensor_Type" />
<result property="sensorStatus" column="Sensor_Status" />
<result property="monitorunitId" column="MonitorUnit_Id" />
<result property="sensorLocation" column="Sensor_Location" />
<result property="sensorAddress" column="Sensor_Address" />
<result property="orderNum" column="Order_Num" />
<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>
<resultMap type="BaseSensorInfoDto" id="BaseSensorInfoDtoResult">
<result property="objId" column="ObjId" />
<result property="edgeId" column="EdgeId" />
<result property="sensorId" column="Sensor_Id" />
<result property="sensorName" column="Sensor_Name" />
<result property="sensorType" column="Sensor_Type" />
<result property="sensorStatus" column="Sensor_Status" />
<result property="monitorunitId" column="MonitorUnit_Id" />
<result property="sensorLocation" column="Sensor_Location" />
<result property="sensorAddress" column="Sensor_Address" />
<result property="orderNum" column="Order_Num" />
<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" />
<result property="monitorunitName" column="MonitorUnit_Name" />
</resultMap>
<sql id="selectBaseSensorInfoVo">
select ObjId, EdgeId, Sensor_Id, Sensor_Name, Sensor_Type, Sensor_Status, MonitorUnit_Id, Sensor_Location, Sensor_Address, Order_Num, Enable_Flag, Create_By, Create_Time, Update_By, Update_Time from base_sensor_info
</sql>
<select id="selectBaseSensorInfoList" parameterType="BaseSensorInfo" resultMap="BaseSensorInfoDtoResult">
select t1.ObjId,
t1.EdgeId,
t1.Sensor_Id,
t1.Sensor_Name,
t1.Sensor_Type,
t1.Sensor_Status,
t1.MonitorUnit_Id,
t2.MonitorUnit_Name,
t1.Sensor_Location,
t1.Sensor_Address,
t1.Order_Num,
t1.Enable_Flag,
t1.Create_By,
t1.Create_Time,
t1.Update_By,
t1.Update_Time
from base_sensor_info t1
left join base_monitorunit_info t2 on t1.MonitorUnit_Id = t2.MonitorUnit_Id
<where>
<if test="EdgeId != null and EdgeId != ''"> and t1.EdgeId = #{EdgeId}</if>
<if test="sensorId != null and sensorId != ''"> and t1.Sensor_Id = #{sensorId}</if>
<if test="sensorName != null and sensorName != ''"> and t1.Sensor_Name like concat('%', #{sensorName}, '%')</if>
<if test="sensorType != null and sensorType != ''"> and t1.Sensor_Type = #{sensorType}</if>
<if test="sensorStatus != null "> and t1.Sensor_Status = #{sensorStatus}</if>
<if test="monitorunitId != null and monitorunitId != ''"> and t1.MonitorUnit_Id = #{monitorunitId}</if>
<if test="sensorLocation != null and sensorLocation != ''"> and t1.Sensor_Location = #{sensorLocation}</if>
<if test="sensorAddress != null and sensorAddress != ''"> and t1.Sensor_Address = #{sensorAddress}</if>
<if test="orderNum != null "> and t1.Order_Num = #{orderNum}</if>
<if test="enableFlag != null "> and t1.Enable_Flag = #{enableFlag}</if>
</where>
</select>
<select id="selectBaseSensorInfoByObjId" parameterType="Long" resultMap="BaseSensorInfoDtoResult">
select t1.ObjId,
t1.EdgeId,
t1.Sensor_Id,
t1.Sensor_Name,
t1.Sensor_Type,
t1.Sensor_Status,
t1.MonitorUnit_Id,
t2.MonitorUnit_Name,
t1.Sensor_Location,
t1.Sensor_Address,
t1.Order_Num,
t1.Enable_Flag,
t1.Create_By,
t1.Create_Time,
t1.Update_By,
t1.Update_Time
from base_sensor_info t1
left join base_monitorunit_info t2 on t1.MonitorUnit_Id = t2.MonitorUnit_Id
where t1.ObjId = #{objId}
</select>
<insert id="insertBaseSensorInfo" parameterType="BaseSensorInfo" useGeneratedKeys="true" keyProperty="objId">
insert into base_sensor_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="EdgeId != null">EdgeId,</if>
<if test="sensorId != null">Sensor_Id,</if>
<if test="sensorName != null">Sensor_Name,</if>
<if test="sensorType != null">Sensor_Type,</if>
<if test="sensorStatus != null">Sensor_Status,</if>
<if test="monitorunitId != null">MonitorUnit_Id,</if>
<if test="sensorLocation != null">Sensor_Location,</if>
<if test="sensorAddress != null">Sensor_Address,</if>
<if test="orderNum != null">Order_Num,</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="EdgeId != null">#{EdgeId},</if>
<if test="sensorId != null">#{sensorId},</if>
<if test="sensorName != null">#{sensorName},</if>
<if test="sensorType != null">#{sensorType},</if>
<if test="sensorStatus != null">#{sensorStatus},</if>
<if test="monitorunitId != null">#{monitorunitId},</if>
<if test="sensorLocation != null">#{sensorLocation},</if>
<if test="sensorAddress != null">#{sensorAddress},</if>
<if test="orderNum != null">#{orderNum},</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="updateBaseSensorInfo" parameterType="BaseSensorInfo">
update base_sensor_info
<trim prefix="SET" suffixOverrides=",">
<if test="EdgeId != null">EdgeId = #{EdgeId},</if>
<if test="sensorId != null">Sensor_Id = #{sensorId},</if>
<if test="sensorName != null">Sensor_Name = #{sensorName},</if>
<if test="sensorType != null">Sensor_Type = #{sensorType},</if>
<if test="sensorStatus != null">Sensor_Status = #{sensorStatus},</if>
<if test="monitorunitId != null">MonitorUnit_Id = #{monitorunitId},</if>
<if test="sensorLocation != null">Sensor_Location = #{sensorLocation},</if>
<if test="sensorAddress != null">Sensor_Address = #{sensorAddress},</if>
<if test="orderNum != null">Order_Num = #{orderNum},</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="deleteBaseSensorInfoByObjId" parameterType="Long">
delete from base_sensor_info where ObjId = #{objId}
</delete>
<delete id="deleteBaseSensorInfoByObjIds" parameterType="String">
delete from base_sensor_info where ObjId in
<foreach item="objId" collection="array" open="(" separator="," close=")">
#{objId}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save