From c190a65dfa1c7f6077dcfd8ce799654ae53da899 Mon Sep 17 00:00:00 2001 From: wenjy Date: Fri, 11 Feb 2022 10:25:28 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E6=B7=BB=E5=8A=A0=E4=BC=A0=E6=84=9F?= =?UTF-8?q?=E5=99=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/BaseSensorInfoController.java | 166 +++++++++++ .../templates/base/sensorInfo/add.html | 132 +++++++++ .../templates/base/sensorInfo/edit.html | 118 ++++++++ .../templates/base/sensorInfo/sensorInfo.html | 279 ++++++++++++++++++ .../ruoyi/system/domain/BaseSensorInfo.java | 188 ++++++++++++ .../system/domain/dto/BaseSensorInfoDto.java | 13 + .../system/mapper/BaseSensorInfoMapper.java | 62 ++++ .../service/IBaseSensorInfoService.java | 72 +++++ .../impl/BaseSensorInfoServiceImpl.java | 160 ++++++++++ .../impl/BaseSensorTypeServiceImpl.java | 13 +- .../mapper/system/BaseSensorInfoMapper.xml | 171 +++++++++++ 11 files changed, 1373 insertions(+), 1 deletion(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java create mode 100644 ruoyi-admin/src/main/resources/templates/base/sensorInfo/add.html create mode 100644 ruoyi-admin/src/main/resources/templates/base/sensorInfo/edit.html create mode 100644 ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseSensorInfo.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseSensorInfoMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseSensorInfoService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorInfoServiceImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/system/BaseSensorInfoMapper.xml diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java new file mode 100644 index 0000000..9867f9d --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java @@ -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 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 util = new ExcelUtil(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 util = new ExcelUtil(BaseSensorInfo.class); + //读取file文件将文件内容转为list集合 + List baseSensorInfos = util.importExcel(file.getInputStream()); + String message = baseSensorInfoService.importMould(baseSensorInfos,updateSupport); + return AjaxResult.success(message); + } + + /** + * 导出传感器信息列表 + */ + @RequiresPermissions("base:sensorInfo:export") + @Log(title = "传感器信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(BaseSensorInfo baseSensorInfo) + { + List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + ExcelUtil util = new ExcelUtil(BaseSensorInfoDto.class); + return util.exportExcel(list, "传感器信息数据"); + } + + /** + * 新增传感器信息 + */ + @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)); + } +} diff --git a/ruoyi-admin/src/main/resources/templates/base/sensorInfo/add.html b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/add.html new file mode 100644 index 0000000..4d14a78 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/add.html @@ -0,0 +1,132 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/base/sensorInfo/edit.html b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/edit.html new file mode 100644 index 0000000..d4f3c0e --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/edit.html @@ -0,0 +1,118 @@ + + + + + + +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html new file mode 100644 index 0000000..18d430e --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html @@ -0,0 +1,279 @@ + + + + + + + + +
+
+
+
+ 监控单元 +
+
+ + + + +
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseSensorInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseSensorInfo.java new file mode 100644 index 0000000..f5b0503 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseSensorInfo.java @@ -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(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java new file mode 100644 index 0000000..397f05e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseSensorInfoDto.java @@ -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; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseSensorInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseSensorInfoMapper.java new file mode 100644 index 0000000..938f108 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseSensorInfoMapper.java @@ -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 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); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseSensorInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseSensorInfoService.java new file mode 100644 index 0000000..ed90b3a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseSensorInfoService.java @@ -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 selectBaseSensorInfoList(BaseSensorInfo baseSensorInfo); + + /** + * 导入传感器信息 + * @author WenJY + * @date 2022/2/11 9:59 + * @param baseSensorInfos + * @param updateSupport + * @return java.lang.String + */ + public String importMould(List 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); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorInfoServiceImpl.java new file mode 100644 index 0000000..f1cd90c --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorInfoServiceImpl.java @@ -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 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 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 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("
" + 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("
" + successNum + "、 " + baseSensorInfo.getSensorId() +"、 " + baseSensorInfo.getSensorName() + " 更新成功"); + } else { + failureNum++; + failureMsg.append("
" + failureNum + "、 " + baseSensorInfo.getSensorId() +"、 " + baseSensorInfo.getSensorName() + " 已存在"); + } + } catch (Exception e) { + failureNum++; + String msg = "
" + 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); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorTypeServiceImpl.java index 39eafb9..79da26a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorTypeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorTypeServiceImpl.java @@ -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 + */ + public List getSensorType() + { + return baseSensorTypeMapper.selectBaseSensorTypeList(new BaseSensorType()); + } + /** * 导入传感器类型信息 * @author WenJY diff --git a/ruoyi-system/src/main/resources/mapper/system/BaseSensorInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BaseSensorInfoMapper.xml new file mode 100644 index 0000000..812d83e --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/BaseSensorInfoMapper.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + insert into base_sensor_info + + 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, + + + #{EdgeId}, + #{sensorId}, + #{sensorName}, + #{sensorType}, + #{sensorStatus}, + #{monitorunitId}, + #{sensorLocation}, + #{sensorAddress}, + #{orderNum}, + #{enableFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update base_sensor_info + + EdgeId = #{EdgeId}, + Sensor_Id = #{sensorId}, + Sensor_Name = #{sensorName}, + Sensor_Type = #{sensorType}, + Sensor_Status = #{sensorStatus}, + MonitorUnit_Id = #{monitorunitId}, + Sensor_Location = #{sensorLocation}, + Sensor_Address = #{sensorAddress}, + Order_Num = #{orderNum}, + Enable_Flag = #{enableFlag}, + Create_By = #{createBy}, + Create_Time = #{createTime}, + Update_By = #{updateBy}, + Update_Time = #{updateTime}, + + where ObjId = #{objId} + + + + delete from base_sensor_info where ObjId = #{objId} + + + + delete from base_sensor_info where ObjId in + + #{objId} + + + + \ No newline at end of file