change - 智慧場景告警單元統計

main
wenjy 3 years ago
parent 95aa19d43f
commit 15325511c4

@ -5,7 +5,9 @@ import java.util.List;
import java.util.UUID;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
import com.ruoyi.system.domain.dto.BaseAlarmModuleDto;
import com.ruoyi.system.service.IBaseMonitorunitInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -39,6 +41,9 @@ public class BaseAlarmModuleController extends BaseController
@Autowired
private IBaseAlarmModuleService baseAlarmModuleService;
@Autowired
private IBaseMonitorunitInfoService baseMonitorunitInfoService;
@RequiresPermissions("base:alarmModule:view")
@GetMapping()
public String alarmModule()
@ -91,6 +96,16 @@ public class BaseAlarmModuleController extends BaseController
@ResponseBody
public AjaxResult addSave(BaseAlarmModule baseAlarmModule)
{
if(!baseAlarmModule.getMonitorunitId().isEmpty()){
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setMonitorunitType(baseAlarmModule.getMonitorunitId());
List<BaseMonitorunitInfo> baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(baseMonitorunitInfo);
if(baseMonitorunitInfos.size() > 0){
baseAlarmModule.setMonitorunitId(baseMonitorunitInfos.get(0).getMonitorunitType());
}
}
baseAlarmModule.setAlarmmoduleId(UUID.randomUUID().toString());
baseAlarmModule.setCreatedBy(ShiroUtils.getLoginName());
baseAlarmModule.setCreatedTime(new Date());
@ -117,6 +132,14 @@ public class BaseAlarmModuleController extends BaseController
@ResponseBody
public AjaxResult editSave(BaseAlarmModule baseAlarmModule)
{
if(!baseAlarmModule.getMonitorunitId().isEmpty()){
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setMonitorunitId(baseAlarmModule.getMonitorunitId());
List<BaseMonitorunitInfo> baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(baseMonitorunitInfo);
if(baseMonitorunitInfos.size() > 0){
baseAlarmModule.setMonitorunitId(baseMonitorunitInfos.get(0).getMonitorunitType());
}
}
baseAlarmModule.setUpdatedBy(ShiroUtils.getLoginName());
baseAlarmModule.setUpdatedTime(new Date());
return toAjax(baseAlarmModuleService.updateBaseAlarmModule(baseAlarmModule));

@ -1,19 +1,20 @@
package com.ruoyi.web.controller.iot;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.system.domain.BaseAlarmModule;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.dto.BaseAlarmModuleDto;
import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import com.ruoyi.system.service.IBaseAlarmModuleService;
import com.ruoyi.system.service.IBaseMonitorunitInfoService;
import com.ruoyi.system.service.IBaseSensorInfoService;
import com.ruoyi.system.service.IRecordAlarmService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@ -33,6 +34,12 @@ public class WisdomScenarioContorller {
@Autowired private IBaseSensorInfoService baseSensorInfoService;
@Autowired
private IBaseAlarmModuleService baseAlarmModuleService;
@Autowired
private IRecordAlarmService recordAlarmService;
/**
* :
*
@ -102,7 +109,29 @@ public class WisdomScenarioContorller {
return JSONArray.toJSONString(collect);
}
/**
*
* @author WenJY
* @date 2022/3/26 20:51
* @param monitorUnitId
* @return java.lang.String
*/
@GetMapping("/getAlarmModule")
@ResponseBody
public String getAlarmModule(String monitorUnitId){
return null;
List<BaseAlarmModuleDto> baseAlarmModuleDtos = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
if(baseAlarmModuleDtos.size() < 6){
List<BaseAlarmModuleDto> info = new ArrayList<>();
for (int i = 0;i<6-baseAlarmModuleDtos.size();i++){
info.add(new BaseAlarmModuleDto());
}
baseAlarmModuleDtos.addAll(baseAlarmModuleDtos.size()-1,info);
}
String result = JSONArray.toJSONString(baseAlarmModuleDtos);
return result;
}
}

@ -235,10 +235,6 @@
<script>
let inf = `<span>设备高温</span></br><span>5</span>`;
$("#access").html("");
$("#access").append(inf);
function getParams(key) {
var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
@ -248,6 +244,38 @@
return null;
};
//获取告警单元
$(() => {
$.ajax({
url: "/iot/wisdomScenario/getAlarmModule?monitorUnitId=" + getParams("id"),
type: "get",
dataType: 'JSON',
success: (res) => {
$("#access").html("");
$("#access").append(`<span>${res[0].alarmmoduleText}</span></br><span>${res[0].alarmModuleAmount}</span>`);
$("#running").html("");
$("#running").append(`<span>${res[1].alarmmoduleText}</span></br><span>${res[1].alarmModuleAmount}</span>`);
$("#standby").html("");
$("#standby").append(`<span>${res[2].alarmmoduleText}</span></br><span>${res[2].alarmModuleAmount}</span>`);
$("#failure").html("");
$("#failure").append(`<span>${res[3].alarmmoduleText}</span></br><span>${res[3].alarmModuleAmount}</span>`);
$("#repairing").html("");
$("#repairing").append(`<span>${res[4].alarmmoduleText}</span></br><span>${res[4].alarmModuleAmount}</span>`);
$("#communication-failure").html("");
$("#communication-failure").append(`<span>${res[5].alarmmoduleText}</span></br><span>${res[5].alarmModuleAmount}</span>`);
},
error: () => {
console.log("失败");
}
})
});
//获取监控单元、传感器数量
$(() => {
$.ajax({
@ -303,8 +331,6 @@
dataType: 'JSON',
success: function (result) {
console.log(result);
datas = result;
let dataCount = datas.length;//总数据条数

@ -17,6 +17,13 @@ public class BaseAlarmModule extends BaseEntity
{
private static final long serialVersionUID = 1L;
public BaseAlarmModule() {
}
public BaseAlarmModule(String monitorunitId) {
this.monitorunitId = monitorunitId;
}
/** 主键标识 */
private Long objId;

@ -13,4 +13,6 @@ public class BaseAlarmModuleDto extends BaseAlarmModule {
private String monitorunitName;
private String alarmTypeName;
private String alarmModuleAmount;
}

@ -59,4 +59,14 @@ public interface BaseAlarmModuleMapper
* @return
*/
public int deleteBaseAlarmModuleByObjIds(String[] objIds);
/**
*
* @author WenJY
* @date 2022/3/26 20:40
* @param baseAlarmModule
* @return java.util.List<com.ruoyi.system.domain.dto.BaseAlarmModuleDto>
*/
public List<BaseAlarmModuleDto> selectAlarmModuleAmountList(BaseAlarmModule baseAlarmModule);
}

@ -59,4 +59,14 @@ public interface IBaseAlarmModuleService
* @return
*/
public int deleteBaseAlarmModuleByObjId(String objId);
/**
*
* @author WenJY
* @date 2022/3/26 20:40
* @param baseAlarmModule
* @return java.util.List<com.ruoyi.system.domain.dto.BaseAlarmModuleDto>
*/
public List<BaseAlarmModuleDto> selectAlarmModuleAmountList(BaseAlarmModule baseAlarmModule);
}

@ -93,4 +93,16 @@ public class BaseAlarmModuleServiceImpl implements IBaseAlarmModuleService
{
return baseAlarmModuleMapper.deleteBaseAlarmModuleByObjId(objId);
}
/**
*
* @author WenJY
* @date 2022/3/26 20:40
* @param baseAlarmModule
* @return java.util.List<com.ruoyi.system.domain.dto.BaseAlarmModuleDto>
*/
@Override
public List<BaseAlarmModuleDto> selectAlarmModuleAmountList(BaseAlarmModule baseAlarmModule) {
return baseAlarmModuleMapper.selectAlarmModuleAmountList(baseAlarmModule);
}
}

@ -126,4 +126,15 @@
</foreach>
</delete>
<select id="selectAlarmModuleAmountList" parameterType="BaseAlarmModule" resultMap="BaseAlarmModuleDtoResult">
select t1.AlarmModule_Text,count(t4.Alarm_Value) as alarmModuleAmount from base_alarm_module t1
left join base_monitorunit_info t2 on t2.MonitorUnit_Type = t1.MonitorUnit_Id
left join base_sensor_info t3 on t2.MonitorUnit_Id = t3.MonitorUnit_Id
left join record_alarm t4 on t3.Sensor_Id = t4.Sensor_Id and t1.AlarmType_Id = t4.AlarmType_Id
<where>
<if test="monitorunitId != null and monitorunitId != ''">and t1.MonitorUnit_Id = #{monitorunitId}</if>
</where>
group by t1.AlarmModule_Text
</select>
</mapper>
Loading…
Cancel
Save