add - 添加传感器信息
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,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 2022年02月11日 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);
|
||||
}
|
||||
}
|
@ -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…
Reference in New Issue