From e0d098be2039f7f961a879d63db6cd3530a37839 Mon Sep 17 00:00:00 2001 From: wenjy Date: Mon, 14 Feb 2022 11:16:11 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E8=AE=BE=E7=BD=AE=E6=8A=A5=E8=AD=A6=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/BaseAlarmInfoController.java | 16 ++- .../templates/base/alarmInfo/add.html | 41 +++++- .../templates/base/alarmInfo/alarmInfo.html | 121 ++++++++++++++---- .../templates/base/alarmInfo/edit.html | 39 +++++- .../system/domain/dto/BaseAlarmInfoDto.java | 14 ++ .../system/mapper/BaseAlarmInfoMapper.java | 5 +- .../system/service/IBaseAlarmInfoService.java | 5 +- .../impl/BaseAlarmInfoServiceImpl.java | 5 +- .../mapper/system/BaseAlarmInfoMapper.xml | 66 ++++++++-- 9 files changed, 260 insertions(+), 52 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseAlarmInfoDto.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseAlarmInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseAlarmInfoController.java index e084f21..5478658 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseAlarmInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseAlarmInfoController.java @@ -1,6 +1,10 @@ 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.BaseAlarmInfoDto; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -50,7 +54,7 @@ public class BaseAlarmInfoController extends BaseController public TableDataInfo list(BaseAlarmInfo baseAlarmInfo) { startPage(); - List list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo); + List list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo); return getDataTable(list); } @@ -63,8 +67,8 @@ public class BaseAlarmInfoController extends BaseController @ResponseBody public AjaxResult export(BaseAlarmInfo baseAlarmInfo) { - List list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo); - ExcelUtil util = new ExcelUtil(BaseAlarmInfo.class); + List list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo); + ExcelUtil util = new ExcelUtil(BaseAlarmInfoDto.class); return util.exportExcel(list, "传感器报警信息数据"); } @@ -86,6 +90,8 @@ public class BaseAlarmInfoController extends BaseController @ResponseBody public AjaxResult addSave(BaseAlarmInfo baseAlarmInfo) { + baseAlarmInfo.setCreateBy(ShiroUtils.getLoginName()); + baseAlarmInfo.setCreateTime(new Date()); return toAjax(baseAlarmInfoService.insertBaseAlarmInfo(baseAlarmInfo)); } @@ -95,7 +101,7 @@ public class BaseAlarmInfoController extends BaseController @GetMapping("/edit/{objId}") public String edit(@PathVariable("objId") Long objId, ModelMap mmap) { - BaseAlarmInfo baseAlarmInfo = baseAlarmInfoService.selectBaseAlarmInfoByObjId(objId); + BaseAlarmInfoDto baseAlarmInfo = baseAlarmInfoService.selectBaseAlarmInfoByObjId(objId); mmap.put("baseAlarmInfo", baseAlarmInfo); return prefix + "/edit"; } @@ -109,6 +115,8 @@ public class BaseAlarmInfoController extends BaseController @ResponseBody public AjaxResult editSave(BaseAlarmInfo baseAlarmInfo) { + baseAlarmInfo.setUpdateBy(ShiroUtils.getLoginName()); + baseAlarmInfo.setUpdateTime(new Date()); return toAjax(baseAlarmInfoService.updateBaseAlarmInfo(baseAlarmInfo)); } diff --git a/ruoyi-admin/src/main/resources/templates/base/alarmInfo/add.html b/ruoyi-admin/src/main/resources/templates/base/alarmInfo/add.html index 477bf18..a4b9bb2 100644 --- a/ruoyi-admin/src/main/resources/templates/base/alarmInfo/add.html +++ b/ruoyi-admin/src/main/resources/templates/base/alarmInfo/add.html @@ -6,6 +6,7 @@
+
@@ -14,8 +15,14 @@
-
+ +
+
+ + +
@@ -47,11 +54,43 @@ focusCleanup: true }); + $(()=>{ + var cp_keynum = "alarmType"; + 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 )); + } + }) + function submitHandler() { if ($.validate.form()) { $.operate.save(prefix + "/add", $('#form-alarmInfo-add').serialize()); } } + + /* 选择报警类型树 */ + function selectAlarmTypeTree() { + var deptId = $.common.isEmpty($("#alarmtypeId").val()) ? "100" : $("#alarmtypeId").val(); + var url = ctx + "base/alarmType/selectAlarmTypeTree/" + 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); + } \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/base/alarmInfo/alarmInfo.html b/ruoyi-admin/src/main/resources/templates/base/alarmInfo/alarmInfo.html index 980d897..eae634a 100644 --- a/ruoyi-admin/src/main/resources/templates/base/alarmInfo/alarmInfo.html +++ b/ruoyi-admin/src/main/resources/templates/base/alarmInfo/alarmInfo.html @@ -2,22 +2,41 @@ + + +
+
+
+
+ 报警类型 +
+
+ + + + +
+
+
+
+
+
+
+ +
+
  • -
  • - - -
  • @@ -55,14 +74,41 @@
+
+ + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/base/alarmInfo/edit.html b/ruoyi-admin/src/main/resources/templates/base/alarmInfo/edit.html index c7ebfef..9ea4396 100644 --- a/ruoyi-admin/src/main/resources/templates/base/alarmInfo/edit.html +++ b/ruoyi-admin/src/main/resources/templates/base/alarmInfo/edit.html @@ -7,17 +7,29 @@
+
- + +
+
+
+ +
+
- +
- + +
+ + +
+
@@ -53,6 +65,27 @@ $.operate.save(prefix + "/edit", $('#form-alarmInfo-edit').serialize()); } } + + /* 选择报警类型树 */ + function selectAlarmTypeTree() { + var deptId = $.common.isEmpty($("#alarmtypeId").val()) ? "100" : $("#alarmtypeId").val(); + var url = ctx + "base/alarmType/selectAlarmTypeTree/" + 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); + } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseAlarmInfoDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseAlarmInfoDto.java new file mode 100644 index 0000000..523b83c --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseAlarmInfoDto.java @@ -0,0 +1,14 @@ +package com.ruoyi.system.domain.dto; + +import com.ruoyi.system.domain.BaseAlarmInfo; +import lombok.Data; + +/** + * @author WenJY + * @date 2022年02月14日 10:42 + */ +@Data +public class BaseAlarmInfoDto extends BaseAlarmInfo { + private String sensorName; + private String alarmTypeName; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseAlarmInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseAlarmInfoMapper.java index cab31ea..99b7b9c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseAlarmInfoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseAlarmInfoMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.BaseAlarmInfo; +import com.ruoyi.system.domain.dto.BaseAlarmInfoDto; /** * 传感器报警信息Mapper接口 @@ -17,7 +18,7 @@ public interface BaseAlarmInfoMapper * @param objId 传感器报警信息主键 * @return 传感器报警信息 */ - public BaseAlarmInfo selectBaseAlarmInfoByObjId(Long objId); + public BaseAlarmInfoDto selectBaseAlarmInfoByObjId(Long objId); /** * 查询传感器报警信息列表 @@ -25,7 +26,7 @@ public interface BaseAlarmInfoMapper * @param baseAlarmInfo 传感器报警信息 * @return 传感器报警信息集合 */ - public List selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo); + public List selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo); /** * 新增传感器报警信息 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseAlarmInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseAlarmInfoService.java index 07bc57d..8e8cc29 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseAlarmInfoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseAlarmInfoService.java @@ -2,6 +2,7 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.system.domain.BaseAlarmInfo; +import com.ruoyi.system.domain.dto.BaseAlarmInfoDto; /** * 传感器报警信息Service接口 @@ -17,7 +18,7 @@ public interface IBaseAlarmInfoService * @param objId 传感器报警信息主键 * @return 传感器报警信息 */ - public BaseAlarmInfo selectBaseAlarmInfoByObjId(Long objId); + public BaseAlarmInfoDto selectBaseAlarmInfoByObjId(Long objId); /** * 查询传感器报警信息列表 @@ -25,7 +26,7 @@ public interface IBaseAlarmInfoService * @param baseAlarmInfo 传感器报警信息 * @return 传感器报警信息集合 */ - public List selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo); + public List selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo); /** * 新增传感器报警信息 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseAlarmInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseAlarmInfoServiceImpl.java index f734d1e..841ca59 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseAlarmInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseAlarmInfoServiceImpl.java @@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl; import java.util.List; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.domain.dto.BaseAlarmInfoDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.BaseAlarmInfoMapper; @@ -28,7 +29,7 @@ public class BaseAlarmInfoServiceImpl implements IBaseAlarmInfoService * @return 传感器报警信息 */ @Override - public BaseAlarmInfo selectBaseAlarmInfoByObjId(Long objId) + public BaseAlarmInfoDto selectBaseAlarmInfoByObjId(Long objId) { return baseAlarmInfoMapper.selectBaseAlarmInfoByObjId(objId); } @@ -40,7 +41,7 @@ public class BaseAlarmInfoServiceImpl implements IBaseAlarmInfoService * @return 传感器报警信息 */ @Override - public List selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo) + public List selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo) { return baseAlarmInfoMapper.selectBaseAlarmInfoList(baseAlarmInfo); } diff --git a/ruoyi-system/src/main/resources/mapper/system/BaseAlarmInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BaseAlarmInfoMapper.xml index 4fb7f44..349e09b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/BaseAlarmInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/BaseAlarmInfoMapper.xml @@ -17,28 +17,66 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + + + + select ObjId, Sensor_Id, AlarmType_Id, Max_Value, Min_Value, Enable_Flag, Create_By, Create_Time, Update_By, Update_Time from base_alarm_info - + + select t1.ObjId, + t1.Sensor_Id, + t3.Sensor_Name, + t1.AlarmType_Id, + t2.AlarmType_Name, + t1.Max_Value, + t1.Min_Value, + t1.Enable_Flag, + t1.Create_By, + t1.Create_Time, + t1.Update_By, + t1.Update_Time + from base_alarm_info t1 + left join base_alarm_type t2 on t1.AlarmType_Id = t2.alarmType_Id + left join base_sensor_info t3 on t1.Sensor_Id = t3.Sensor_Id - and Sensor_Id = #{sensorId} - and AlarmType_Id = #{alarmtypeId} - and Max_Value = #{maxValue} - and Min_Value = #{minValue} - and Enable_Flag = #{enableFlag} - and Create_By = #{createBy} - and Create_Time = #{createTime} - and Update_By = #{updateBy} - and Update_Time = #{updateTime} + and t1.Sensor_Id = #{sensorId} + and t1.AlarmType_Id = #{alarmtypeId} - + + select t1.ObjId, + t1.Sensor_Id, + t3.Sensor_Name, + t1.AlarmType_Id, + t2.AlarmType_Name, + t1.Max_Value, + t1.Min_Value, + t1.Enable_Flag, + t1.Create_By, + t1.Create_Time, + t1.Update_By, + t1.Update_Time + from base_alarm_info t1 + left join base_alarm_type t2 on t1.AlarmType_Id = t2.alarmType_Id + left join base_sensor_info t3 on t1.Sensor_Id = t3.Sensor_Id + where t1.ObjId = #{objId}