若依微服务1.2.0版本

监控平台所有方法重写
dev 1.2.0
xins 1 year ago
parent d7b20bc371
commit d75aa67860

@ -4,8 +4,11 @@ import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.business.domain.HwMonitorUnit;
import com.ruoyi.business.domain.VO.DeviceModeVo;
import com.ruoyi.business.domain.VO.HwMonitorUnitVo;
import com.ruoyi.business.service.IHwMonitorUnitService;
import com.ruoyi.system.api.domain.SysDept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -38,6 +41,8 @@ public class HwDeviceController extends BaseController
@Autowired
private IHwDeviceService hwDeviceService;
@Autowired
private IHwMonitorUnitService hwMonitorUnitService;
/**
*
*/
@ -108,4 +113,16 @@ public class HwDeviceController extends BaseController
{
return toAjax(hwDeviceService.deleteHwDeviceByDeviceIds(deviceIds));
}
/**
*
*/
@RequiresPermissions("business:device:list")
@GetMapping("/monitorUnitTree")
public AjaxResult monitorUnitTree(HwMonitorUnit monitorUnit)
{
return success(hwMonitorUnitService.selectMonitorTreeList(monitorUnit));
}
}

@ -26,7 +26,7 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
* Controller
*
* @author xins
* @date 2023-09-04
* @date 2023-09-15
*/
@RestController
@RequestMapping("/electronicFence")

@ -1,34 +1,20 @@
package com.ruoyi.business.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.business.domain.HwScene;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.business.domain.*;
import com.ruoyi.business.domain.VO.*;
import com.ruoyi.business.mapper.HwSceneMapper;
import com.ruoyi.business.service.IHwDeviceService;
import com.ruoyi.business.service.IHwElectronicFenceService;
import com.ruoyi.business.service.IHwSceneService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.HwMonitorUnit;
import com.ruoyi.business.service.IHwMonitorUnitService;
import com.ruoyi.business.service.*;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import static com.ruoyi.common.core.utils.PageUtils.startPage;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/monitorPlatform")
@ -39,197 +25,294 @@ public class HwMonitorPlatformController extends BaseController {
@Autowired
private IHwDeviceService hwDeviceService;
@Autowired
private IHwDeviceModeService hwDeviceModeService;
@Autowired
private IHwSceneService hwSceneService;
@Autowired
private IHwElectronicFenceService hwElectronicFenceService;
@Autowired
private IHwAlarmInfoService hwAlarmInfoService;
@Autowired
private IHwMonitorPlatformService hwMonitorPlatformService;
/**
*
* @param hwMonitorUnits
* @return list
* @throws
* */
@GetMapping("/treeList")
public TableDataInfo treeList(){
HwMonitorUnit hwMonitorUnit = new HwMonitorUnit();
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit);
List<HwMonitorUnit> list = hwMonitorUnitService.selectTreeList(hwMonitorUnits);
return getDataTable(list);
}
// /**
// *
// * 选择场景
// * @param sceneModeId 场景id
// * @return
// */
//
// @PostMapping("/selectHwSceneBySceneModeId")
// public TableDataInfo selectHwSceneBySceneModeId(Long sceneModeId){
// List<HwScene> hwScenes = hwSceneService.selectHwSceneBySceneModeId(sceneModeId);
// return getDataTable(hwScenes);
// }
/**
* 3.
* */
* 3.
*/
@GetMapping("/monitorUnitPercentage")
public TableDataInfo monitorUnitPercentage(){
public TableDataInfo monitorUnitPercentage() {
List<DeviceModeVo> maps = hwDeviceService.selectDeviceModeNameVo();
return getDataTable(maps);
}
//
/**
*
* @param monitorUnitId id
* */
@PostMapping("/selectDeviceByDeviceModeByMonitorUnitId")
public Map<String, Map<String, Object>> selectDeviceByDeviceModeByMonitorUnitId(Long monitorUnitId){
startPage();
Map<String, Map<String, Object>> maps = hwDeviceService.selectDeviceByDeviceModeByMonitorUnitId(monitorUnitId);
return maps;
/**
* ()
*/
@GetMapping("/monitorPercentage")
public TableDataInfo monitorPercentage() {
List<HwMonitorUnitVo> maps = hwMonitorUnitService.selectMonitorPercentage();
return getDataTable(maps);
}
/**
*
* @param monitorUnitId id
*
*/
@PostMapping("/selectDeviceModeFunctionByFunctionType")
public Map<String, Map<String, Object>> selectDeviceModeFunctionByFunctionType(Long monitorUnitId){
startPage();
@GetMapping("/allNums")
public AllNumsVo allNums() {
AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums(null);
Map<String, Map<String, Object>> maps = hwDeviceService.selectDeviceModeFunctionByFunctionType(monitorUnitId);
return maps;
return allNumsVos;
}
//
/**
*
* @param deviceId id
* */
@PostMapping("/getHistoryData")
public TableDataInfo getHistoryData(Long deviceId){
* @return TableDataInfo
* @param: hwAlarmInfo
* @description
* @author xins
* @date 2023-09-15 11:03
*/
@GetMapping("/getAlarmInfos")
public TableDataInfo getAlarmInfos(HwAlarmInfo hwAlarmInfo) {
startPage();
List<Map<String, Object>> historyData = hwDeviceService.getHistoryData(deviceId);
return getDataTable(historyData);
}
/**
*
* 1-
* */
@GetMapping("/monitorPercentage")
public TableDataInfo monitorPercentage(){
List<HwMonitorUnitVo> maps = hwMonitorUnitService.selectMonitorPercentage();
return getDataTable(maps);
List<HwAlarmInfo> alarmInfos = hwAlarmInfoService.selectHwAlarmInfoList(hwAlarmInfo);
return getDataTable(alarmInfos);
}
/**
*
* */
@GetMapping("/allNums")
public AllNumsVo allNums(){
AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums();
* 2. 线()
*
* @param sceneId id
*/
@GetMapping("/getDeviceOperations/{sceneId}")
public AjaxResult selectDeviceStatus(@PathVariable("sceneId") Long sceneId) {
JSONObject data = new JSONObject();
data.put("10-01", 10);
data.put("10-02", 20);
data.put("10-03", 30);
data.put("10-04", 40);
data.put("10-05", 16);
return allNumsVos;
return AjaxResult.success(data);
}
/**
*
* */
@GetMapping("/sceneAllNums")
public TableDataInfo sceneAllNums(){
List<AllNumsVo> allNumsVos = hwMonitorUnitService.selectSenceAllNums();
return getDataTable(allNumsVos);
*/
@GetMapping("/sceneAllNums/{sceneId}")
public AllNumsVo sceneAllNums(@PathVariable("sceneId") Long sceneId) {
AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums(sceneId);
return allNumsVos;
}
/**
*
* */
@PostMapping("/limitSubMonitorUnit")
public TableDataInfo limitSubMonitorUnit(){
* ()
*/
@GetMapping("/limitSubMonitorUnit/{sceneId}")
public TableDataInfo limitSubMonitorUnit(@PathVariable("sceneId") Long sceneId) {
//todo sceneid should be
startPage();
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitService.selectLimitSubMonitorUnit();
return getDataTable(hwMonitorUnits);
}
@GetMapping("/getAlarmCountGroupAlarmType/{sceneId}")
public AjaxResult getAlarmCountGroupAlarmType(@PathVariable("sceneId") Long sceneId) {
return success(hwAlarmInfoService.selectAlarmsByAlarmType(sceneId));
}
/**
* ()
*
* @param sceneId
*/
@GetMapping("/ElectronicNumVo/{sceneId}")
public AjaxResult ElectronicNumVo(@PathVariable("sceneId") Long sceneId) {
// {
// type:'多边形',
// children:[{
// latitude:'',
// longtitude:''
// }]
// }
// {
// type:'圆形',
// centerpoint:{
// 'lantitude':,
// 'longtitude':,
// }
// }
// }
return success(hwElectronicFenceService.selectEleTypeNums(sceneId));
}
/**
*
*/
@GetMapping("/alarmStats")
public TableDataInfo alarmStats(){
List<AlarmStatsVo> alarmStatsVos = hwMonitorUnitService.selectAlarmStats();
return getDataTable(alarmStatsVos);
@GetMapping("/alarmStats/{sceneId}")
public AjaxResult alarmStats(@PathVariable("sceneId") Long sceneId) {
List<AlarmStatsVo> alarmStatsVos = hwMonitorUnitService.selectAlarmStats(sceneId);
return success(alarmStatsVos);
}
/**
* 线
*
* @param sceneId id
* */
@PostMapping("/SubDevice")
public SubDeviceSumVo subDevice(Long sceneId){
*/
@GetMapping("/subDevice/{sceneId}")
public SubDeviceSumVo subDevice(@PathVariable("sceneId") Long sceneId) {
SubDeviceSumVo subDeviceSumVos = hwMonitorUnitService.selectSubDeviceSum(sceneId);
return subDeviceSumVos;
}
/**
*
* @param sceneId
* */
@PostMapping("/ElectronicNumVo")
public TableDataInfo ElectronicNumVo(Long sceneId){
* ()
*
* @param sceneId ID
* @return list
* @throws
*/
@GetMapping("/treeList{sceneId}")
public TableDataInfo treeList(@PathVariable("sceneId") Long sceneId) {
HwMonitorUnit hwMonitorUnit = new HwMonitorUnit();
hwMonitorUnit.setSceneId(sceneId);
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit);
List<HwMonitorUnit> list = hwMonitorUnitService.selectTreeList(hwMonitorUnits);
return getDataTable(list);
List<EleMonitorDeviceSumVo> eleMonitorDeviceSumVos = hwElectronicFenceService.selectEleTypeNums(sceneId);
return getDataTable(eleMonitorDeviceSumVos);
}
// /**
// *
// * 选择场景
// * @param sceneModeId 场景id
// * @return
// */
//
// @PostMapping("/selectHwSceneBySceneModeId")
// public TableDataInfo selectHwSceneBySceneModeId(Long sceneModeId){
// List<HwScene> hwScenes = hwSceneService.selectHwSceneBySceneModeId(sceneModeId);
// return getDataTable(hwScenes);
// }
//
/**
*
* @param monitorUnitId
* */
@PostMapping("/selectMonitorUnitSub")
//ok
public AjaxResult selectMonitorUnitSub(Long monitorUnitId){
*/
// @RequiresPermissions("business:monitorUnit:query")
@GetMapping(value = "/getMonitorById/{monitorUnitId}")
public AjaxResult getMonitorById(@PathVariable("monitorUnitId") Long monitorUnitId) {
return success(hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId));
}
HwMonitorUnit hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId);
/**
* ID
*
* @param monitorUnitId id
*/
@GetMapping("/selectDevicesByMonitorUnitId/{monitorUnitId}/{sceneId}")
public AjaxResult selectDeviceByDeviceModeByMonitorUnitId(@PathVariable("monitorUnitId") Long monitorUnitId,
@PathVariable("sceneId") Long sceneId) {
HwDevice queryHwDevice = new HwDevice();
queryHwDevice.setMonitorUnitId(monitorUnitId);
queryHwDevice.setSceneId(sceneId);
return AjaxResult.success(monitorUnitId);
return success(hwDeviceService.getDevicesByMonitor(queryHwDevice));
}
/**
* 2. 线
* @param beginTime
* @param endTime
* @param sceneId id
* */
@PostMapping("/getDeviceOperations")
public R<Map<Object, Integer>> selectTdengine(String beginTime,String endTime,Long sceneId){
* @description ID
* @author xins
* @date 2023-09-16 12:44
*/
@PostMapping("/getDeviceModesBySceneId")
public AjaxResult getDeviceModesBySceneId(@RequestBody HwDeviceMode queryHwDeviceMode) {
return success(hwDeviceModeService.selectHwDeviceModeList(queryHwDeviceMode));
}
Map<Object, Integer> objectIntegerMap = hwMonitorUnitService.selectTdengine(beginTime, endTime, sceneId);
return R.ok(objectIntegerMap);
/**
* @return AjaxResult
* @param: monitorUnitId
* @description
* @author xins
* @date 2023-09-16 12:45
*/
@PostMapping("/selectLatestDataByDeviceMode")
public AjaxResult selectLatestDataByDeviceMode(@Validated @RequestBody DeviceLatestDataVo deviceLatestData) {
JSONObject returnObj = new JSONObject();
List<Map<String, Object>> latestDataMaps = hwMonitorPlatformService.selectLatestDataByTags(deviceLatestData);
List<DeviceDataColumnVo> deviceDataColumnVos = this.getDeviceDataColumns(latestDataMaps);
TableDataInfo tableDataInfo = getDataTable(latestDataMaps);
returnObj.put("deviceDataColumns", deviceDataColumnVos);
returnObj.put("latestData", tableDataInfo);
return success(returnObj);
}
@GetMapping("/getDeviceInfo/{deviceId}")
public AjaxResult getDeviceInfo(@PathVariable("deviceId") Long deviceId){
HwDevice device = hwDeviceService.selectHwDeviceJoinByDeviceId(deviceId);
return success(device);
}
@GetMapping("/getLinkDevices/{deviceId}")
public AjaxResult getLinkDevices(@PathVariable("deviceId")Long deviceId){
return success(hwDeviceService.selectLinkDeviceList(deviceId));
}
/**
*
* */
@PostMapping("/selectLatestDataByTags")
public R<Map<String, Map<String, Object>>>selectLatestDataByTags(Long monitorUnitId){
* @return AjaxResult
* @param: deviceHistoryData
* @description
* @author xins
* @date 2023-09-16 15:15
*/
@PostMapping("/getHistoryData")
public AjaxResult getHistoryData(@Validated @RequestBody DeviceHistoryDataVo deviceHistoryData) {
// startPage();
JSONObject returnObj = new JSONObject();
List<Map<String, Object>> historyDataMaps = hwMonitorPlatformService.getHistoryData(deviceHistoryData);
List<DeviceDataColumnVo> deviceDataColumnVos = this.getDeviceDataColumns(historyDataMaps);
TableDataInfo tableDataInfo = getDataTable(historyDataMaps);
returnObj.put("deviceDataColumns", deviceDataColumnVos);
returnObj.put("historyData", tableDataInfo);
return success(returnObj);
}
R<Map<String, Map<String, Object>>> mapR = hwMonitorUnitService.selectLatestDataByTags(monitorUnitId);
return mapR;
private List<DeviceDataColumnVo> getDeviceDataColumns(List<Map<String, Object>> latestDataMaps){
List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<DeviceDataColumnVo>();
if (latestDataMaps != null && latestDataMaps.size() > 0) {
Map<String, Object> latestDataMap = latestDataMaps.get(0);
for (Map.Entry<String, Object> entry : latestDataMap.entrySet()) {
DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo();
String columnKey = entry.getKey();
deviceDataColumnVo.setColumnKey(columnKey);
deviceDataColumnVo.setColumnName(TdEngineConstants.DEVICE_DATA_COLUMN_MAP.get(columnKey) == null
? columnKey : TdEngineConstants.DEVICE_DATA_COLUMN_MAP.get(columnKey));
deviceDataColumnVos.add(deviceDataColumnVo);
}
}
return deviceDataColumnVos;
}
/**
*
* id=0 id
*
* */
@PostMapping("/SelectSecne")
public TableDataInfo SelectSecneByUser(){
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
Long tenantId = sysUser.getTenantId();
List<HwScene> hwScenes = hwSceneService.selectHwSceneByTenantId(tenantId);
if (hwScenes.size()!=0){
hwScenes.get(0).setDefaultFlag("1");}
return getDataTable(hwScenes);
}
/**
*
* alarminfo
* */
*/
@GetMapping("/selectSecnes")
public AjaxResult selectSecnes(HwScene scene) {
List<HwScene> hwScenes = hwSceneService.selectHwSceneList(scene);
return success(hwScenes);
}
}

@ -1,21 +1,8 @@
package com.ruoyi.business.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.business.domain.HwScene;
import com.ruoyi.business.domain.VO.*;
import com.ruoyi.business.mapper.HwSceneMapper;
import com.ruoyi.business.service.IHwDeviceService;
import com.ruoyi.business.service.IHwElectronicFenceService;
import com.ruoyi.business.service.IHwSceneService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -33,13 +20,12 @@ import com.ruoyi.business.service.IHwMonitorUnitService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author YINQ
* @date 2023-08-31
*
* @author xins
* @date 2023-09-14
*/
@RestController
@RequestMapping("/monitorUnit")
@ -47,28 +33,18 @@ public class HwMonitorUnitController extends BaseController
{
@Autowired
private IHwMonitorUnitService hwMonitorUnitService;
@Autowired
private IHwDeviceService hwDeviceService;
@Autowired
private IHwSceneService hwSceneService;
@Autowired
private IHwElectronicFenceService hwElectronicFenceService;
/**
*
*/
@RequiresPermissions("business:monitorUnit:list")
@GetMapping("/list")
public TableDataInfo list(HwMonitorUnit hwMonitorUnit)
public AjaxResult list(HwMonitorUnit hwMonitorUnit)
{
startPage();
List<HwMonitorUnit> list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit);
return getDataTable(list);
return success(list);
}
/**
*
*/
@ -92,7 +68,6 @@ public class HwMonitorUnitController extends BaseController
return success(hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId));
}
/**
*
*/
@ -125,9 +100,4 @@ public class HwMonitorUnitController extends BaseController
{
return toAjax(hwMonitorUnitService.deleteHwMonitorUnitByMonitorUnitIds(monitorUnitIds));
}
}

@ -140,7 +140,13 @@ public class HwSceneController extends BaseController
}
}
/**
* 使
*/
@GetMapping("/getScenes")
public AjaxResult getScenes(HwScene hwScene) {
return success(hwSceneService.selectHwSceneList(hwScene));
}
}

@ -0,0 +1,316 @@
package com.ruoyi.business.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* hw_alarm_info
*
* @author xins
* @date 2023-09-15
*/
public class HwAlarmInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private Long alarmInfoId;
/**
* 123线4
*/
@Excel(name = "报警信息类型", readConverterExp = "1=、设备报警2、监控单元报警3、离线报警4、电子围栏")
private String alarmInfoType;
/**
* 1alarm_rulealarm_rule_id
* 3hw_offline_ruleoffline_rule_id
* 4hw_electronic_fenceelectronic_fence_id
*/
@Excel(name = "报警信息类型")
private Long alarmReleatedId;
/**
* IDhw_devicedevice_id
*/
@Excel(name = "报警设备ID关联hw_device表的device_id字段")
private Long deviceId;
/**
* Idhw_monitor_unitmonitor_unit_id
*/
@Excel(name = "所属监控单元Id关联表hw_monitor_unit字段monitor_unit_id")
private Long monitorUnitId;
/**
* IDhw_tenanttenant_id
*/
@Excel(name = "租户ID关联hw_tenant的tenant_id")
private Long tenantId;
/**
* IDhw_scenescene_id
*/
@Excel(name = "所属场景ID关联hw_scene的scene_id")
private Long sceneId;
/**
* hw_alarm_levelalarm_level_id123
*/
@Excel(name = "报警级别关联hw_alarm_level的字段alarm_level_id报警信息类型为1、2和3时保存")
private Long alarmLevelId;
/**
* hw_alarm_typealarm_type_id12
*/
@Excel(name = "报警类型关联hw_alarm_type的字段alarm_type_id报警信息类型为1和2时保存")
private Long alarmTypeId;
/**
* ID
*/
@Excel(name = "设备模型功能ID")
private Long modeFunctionId;
/**
*
*/
@Excel(name = "功能名称")
private String functionName;
/**
*
*/
@Excel(name = "标识符")
private String functionIdentifier;
/**
* ,
*/
@Excel(name = "最新的值,如果是电子围栏则存经度,纬度")
private String functionValue;
/**
* 1234
*/
@Excel(name = "触发状态", readConverterExp = "1=、出界2、入界3、双向")
private String triggerStatus;
/**
* 0 1
*/
@Excel(name = "处理状态", readConverterExp = "0=、未处理,1=、已处理")
private String handleStatus;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "实际报警时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date alarmTime;
/**
*
*/
@Excel(name = "预留字段")
private String alarmInfoField;
private String monitorUnitName;
private String alarmLevelName;
private String alarmTypeName;
public void setAlarmInfoId(Long alarmInfoId) {
this.alarmInfoId = alarmInfoId;
}
public Long getAlarmInfoId() {
return alarmInfoId;
}
public void setAlarmInfoType(String alarmInfoType) {
this.alarmInfoType = alarmInfoType;
}
public String getAlarmInfoType() {
return alarmInfoType;
}
public void setAlarmReleatedId(Long alarmReleatedId) {
this.alarmReleatedId = alarmReleatedId;
}
public Long getAlarmReleatedId() {
return alarmReleatedId;
}
public void setDeviceId(Long deviceId) {
this.deviceId = deviceId;
}
public Long getDeviceId() {
return deviceId;
}
public void setMonitorUnitId(Long monitorUnitId) {
this.monitorUnitId = monitorUnitId;
}
public Long getMonitorUnitId() {
return monitorUnitId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public Long getTenantId() {
return tenantId;
}
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
public Long getSceneId() {
return sceneId;
}
public void setAlarmLevelId(Long alarmLevelId) {
this.alarmLevelId = alarmLevelId;
}
public Long getAlarmLevelId() {
return alarmLevelId;
}
public void setAlarmTypeId(Long alarmTypeId) {
this.alarmTypeId = alarmTypeId;
}
public Long getAlarmTypeId() {
return alarmTypeId;
}
public void setModeFunctionId(Long modeFunctionId) {
this.modeFunctionId = modeFunctionId;
}
public Long getModeFunctionId() {
return modeFunctionId;
}
public void setFunctionName(String functionName) {
this.functionName = functionName;
}
public String getFunctionName() {
return functionName;
}
public void setFunctionIdentifier(String functionIdentifier) {
this.functionIdentifier = functionIdentifier;
}
public String getFunctionIdentifier() {
return functionIdentifier;
}
public void setFunctionValue(String functionValue) {
this.functionValue = functionValue;
}
public String getFunctionValue() {
return functionValue;
}
public void setTriggerStatus(String triggerStatus) {
this.triggerStatus = triggerStatus;
}
public String getTriggerStatus() {
return triggerStatus;
}
public void setHandleStatus(String handleStatus) {
this.handleStatus = handleStatus;
}
public String getHandleStatus() {
return handleStatus;
}
public void setAlarmTime(Date alarmTime) {
this.alarmTime = alarmTime;
}
public Date getAlarmTime() {
return alarmTime;
}
public void setAlarmInfoField(String alarmInfoField) {
this.alarmInfoField = alarmInfoField;
}
public String getAlarmInfoField() {
return alarmInfoField;
}
public String getMonitorUnitName() {
return monitorUnitName;
}
public void setMonitorUnitName(String monitorUnitName) {
this.monitorUnitName = monitorUnitName;
}
public String getAlarmLevelName() {
return alarmLevelName;
}
public void setAlarmLevelName(String alarmLevelName) {
this.alarmLevelName = alarmLevelName;
}
public String getAlarmTypeName() {
return alarmTypeName;
}
public void setAlarmTypeName(String alarmTypeName) {
this.alarmTypeName = alarmTypeName;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("alarmInfoId", getAlarmInfoId())
.append("alarmInfoType", getAlarmInfoType())
.append("alarmReleatedId", getAlarmReleatedId())
.append("deviceId", getDeviceId())
.append("monitorUnitId", getMonitorUnitId())
.append("tenantId", getTenantId())
.append("sceneId", getSceneId())
.append("alarmLevelId", getAlarmLevelId())
.append("alarmTypeId", getAlarmTypeId())
.append("modeFunctionId", getModeFunctionId())
.append("functionName", getFunctionName())
.append("functionIdentifier", getFunctionIdentifier())
.append("functionValue", getFunctionValue())
.append("triggerStatus", getTriggerStatus())
.append("handleStatus", getHandleStatus())
.append("alarmTime", getAlarmTime())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("alarmInfoField", getAlarmInfoField())
.append("monitorUnitName", getMonitorUnitName())
.append("alarmLevelName", getAlarmLevelName())
.append("alarmTypeName", getAlarmTypeName())
.toString();
}
}

@ -0,0 +1,168 @@
package com.ruoyi.business.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* hw_alarm_level
*
* @author xins
* @date 2023-09-15
*/
public class HwAlarmLevel extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 报警级别ID */
private Long alarmLevelId;
/** 报警级别名称 */
@Excel(name = "报警级别名称")
private String alarmLevelName;
/** 租户ID关联hw_tenant的tenant_id */
@Excel(name = "租户ID关联hw_tenant的tenant_id")
private Long tenantId;
/** 所属场景关联hw_scene表的scene_id字段 */
@Excel(name = "所属场景关联hw_scene表的scene_id字段")
private Long sceneId;
/** 语言code,关联表hw_language的language_code字段 */
@Excel(name = "语言code,关联表hw_language的language_code字段")
private String languageCode;
/** 通用标识10 */
@Excel(name = "通用标识", readConverterExp = "1=0否")
private String commonFlag;
/** 严重程度(数字越大,级别越高) */
@Excel(name = "严重程度", readConverterExp = "数=字越大,级别越高")
private Long levelNumber;
/** 状态1、正常9、删除 */
@Excel(name = "状态", readConverterExp = "1=、正常9、删除")
private String levelStatus;
/** 默认通知方式1、邮箱2、短信3、钉钉4、微信公众号5、企业微信多个保存用,隔开。 */
@Excel(name = "默认通知方式", readConverterExp = "1=、邮箱2、短信3、钉钉4、微信公众号5、企业微信")
private String defaultNotifyMode;
/** 预留字段 */
@Excel(name = "预留字段")
private String alarmLevelField;
public void setAlarmLevelId(Long alarmLevelId)
{
this.alarmLevelId = alarmLevelId;
}
public Long getAlarmLevelId()
{
return alarmLevelId;
}
public void setAlarmLevelName(String alarmLevelName)
{
this.alarmLevelName = alarmLevelName;
}
public String getAlarmLevelName()
{
return alarmLevelName;
}
public void setTenantId(Long tenantId)
{
this.tenantId = tenantId;
}
public Long getTenantId()
{
return tenantId;
}
public void setSceneId(Long sceneId)
{
this.sceneId = sceneId;
}
public Long getSceneId()
{
return sceneId;
}
public void setLanguageCode(String languageCode)
{
this.languageCode = languageCode;
}
public String getLanguageCode()
{
return languageCode;
}
public void setCommonFlag(String commonFlag)
{
this.commonFlag = commonFlag;
}
public String getCommonFlag()
{
return commonFlag;
}
public void setLevelNumber(Long levelNumber)
{
this.levelNumber = levelNumber;
}
public Long getLevelNumber()
{
return levelNumber;
}
public void setLevelStatus(String levelStatus)
{
this.levelStatus = levelStatus;
}
public String getLevelStatus()
{
return levelStatus;
}
public void setDefaultNotifyMode(String defaultNotifyMode)
{
this.defaultNotifyMode = defaultNotifyMode;
}
public String getDefaultNotifyMode()
{
return defaultNotifyMode;
}
public void setAlarmLevelField(String alarmLevelField)
{
this.alarmLevelField = alarmLevelField;
}
public String getAlarmLevelField()
{
return alarmLevelField;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("alarmLevelId", getAlarmLevelId())
.append("alarmLevelName", getAlarmLevelName())
.append("tenantId", getTenantId())
.append("sceneId", getSceneId())
.append("languageCode", getLanguageCode())
.append("commonFlag", getCommonFlag())
.append("levelNumber", getLevelNumber())
.append("levelStatus", getLevelStatus())
.append("defaultNotifyMode", getDefaultNotifyMode())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("alarmLevelField", getAlarmLevelField())
.toString();
}
}

@ -0,0 +1,154 @@
package com.ruoyi.business.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* hw_alarm_type
*
* @author xins
* @date 2023-09-15
*/
public class HwAlarmType extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 报警类型ID */
private Long alarmTypeId;
/** 报警类型名称 */
@Excel(name = "报警类型名称")
private String alarmTypeName;
/** 租户ID关联hw_tenant的tenant_id */
@Excel(name = "租户ID关联hw_tenant的tenant_id")
private Long tenantId;
/** 所属场景关联hw_scene表的scene_id字段 */
@Excel(name = "所属场景关联hw_scene表的scene_id字段")
private Long sceneId;
/** 语言code,关联表hw_language的language_code字段 */
@Excel(name = "语言code,关联表hw_language的language_code字段")
private String languageCode;
/** 通用标识10 */
@Excel(name = "通用标识", readConverterExp = "1=0否")
private String commonFlag;
/** 处理方式1、云端处理2终端上报 */
@Excel(name = "处理方式", readConverterExp = "1=、云端处理2终端上报")
private String handleMode;
/** 状态1、正常9、删除 */
@Excel(name = "状态", readConverterExp = "1=、正常9、删除")
private String typeStatus;
/** 预留字段 */
@Excel(name = "预留字段")
private String alarmTypeField;
public void setAlarmTypeId(Long alarmTypeId)
{
this.alarmTypeId = alarmTypeId;
}
public Long getAlarmTypeId()
{
return alarmTypeId;
}
public void setAlarmTypeName(String alarmTypeName)
{
this.alarmTypeName = alarmTypeName;
}
public String getAlarmTypeName()
{
return alarmTypeName;
}
public void setTenantId(Long tenantId)
{
this.tenantId = tenantId;
}
public Long getTenantId()
{
return tenantId;
}
public void setSceneId(Long sceneId)
{
this.sceneId = sceneId;
}
public Long getSceneId()
{
return sceneId;
}
public void setLanguageCode(String languageCode)
{
this.languageCode = languageCode;
}
public String getLanguageCode()
{
return languageCode;
}
public void setCommonFlag(String commonFlag)
{
this.commonFlag = commonFlag;
}
public String getCommonFlag()
{
return commonFlag;
}
public void setHandleMode(String handleMode)
{
this.handleMode = handleMode;
}
public String getHandleMode()
{
return handleMode;
}
public void setTypeStatus(String typeStatus)
{
this.typeStatus = typeStatus;
}
public String getTypeStatus()
{
return typeStatus;
}
public void setAlarmTypeField(String alarmTypeField)
{
this.alarmTypeField = alarmTypeField;
}
public String getAlarmTypeField()
{
return alarmTypeField;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("alarmTypeId", getAlarmTypeId())
.append("alarmTypeName", getAlarmTypeName())
.append("tenantId", getTenantId())
.append("sceneId", getSceneId())
.append("languageCode", getLanguageCode())
.append("commonFlag", getCommonFlag())
.append("handleMode", getHandleMode())
.append("typeStatus", getTypeStatus())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("alarmTypeField", getAlarmTypeField())
.toString();
}
}

@ -114,6 +114,8 @@ public class HwDevice extends BaseEntity
@Excel(name = "在线状态", readConverterExp = "1=、在线0、离线")
private String onlineStatus;
private String monitorUnitName;
public void setDeviceId(Long deviceId)
{
this.deviceId = deviceId;
@ -331,6 +333,14 @@ public class HwDevice extends BaseEntity
return onlineStatus;
}
public String getMonitorUnitName() {
return monitorUnitName;
}
public void setMonitorUnitName(String monitorUnitName) {
this.monitorUnitName = monitorUnitName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -1,5 +1,6 @@
package com.ruoyi.business.domain;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
@ -9,7 +10,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* hw_electronic_fence
*
* @author xins
* @date 2023-09-04
* @date 2023-09-15
*/
public class HwElectronicFence extends BaseEntity
{
@ -70,6 +71,9 @@ public class HwElectronicFence extends BaseEntity
@Excel(name = "预留字段")
private String fenceField;
/** 电子围栏目标信息 */
private List<HwFenceTarget> hwFenceTargetList;
public void setElectronicFenceId(Long electronicFenceId)
{
this.electronicFenceId = electronicFenceId;
@ -197,6 +201,16 @@ public class HwElectronicFence extends BaseEntity
return fenceField;
}
public List<HwFenceTarget> getHwFenceTargetList()
{
return hwFenceTargetList;
}
public void setHwFenceTargetList(List<HwFenceTarget> hwFenceTargetList)
{
this.hwFenceTargetList = hwFenceTargetList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -219,6 +233,7 @@ public class HwElectronicFence extends BaseEntity
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("fenceField", getFenceField())
.append("hwFenceTargetList", getHwFenceTargetList())
.toString();
}
}

@ -9,7 +9,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* hw_fence_target
*
* @author xins
* @date 2023-09-04
* @date 2023-09-15
*/
public class HwFenceTarget extends BaseEntity
{

@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.system.api.domain.SysDept;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
@ -63,6 +64,9 @@ public class HwMonitorUnit extends BaseEntity
private String monitorUnitField;
private List<HwMonitorUnit> child = new ArrayList<HwMonitorUnit>();
/** 子部门 */
private List<HwMonitorUnit> children = new ArrayList<HwMonitorUnit>();
public List<HwMonitorUnit> getChild() {
return child;
}
@ -71,6 +75,14 @@ public class HwMonitorUnit extends BaseEntity
this.child = child;
}
public List<HwMonitorUnit> getChildren() {
return children;
}
public void setChildren(List<HwMonitorUnit> children) {
this.children = children;
}
public void setMonitorUnitId(Long monitorUnitId)
{
this.monitorUnitId = monitorUnitId;
@ -174,22 +186,22 @@ public class HwMonitorUnit extends BaseEntity
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("monitorUnitId", getMonitorUnitId())
.append("monitorUnitName", getMonitorUnitName())
.append("sceneId", getSceneId())
.append("parentId", getParentId())
.append("monitorUnitTypeId", getMonitorUnitTypeId())
.append("areaId", getAreaId())
.append("monitorAddress", getMonitorAddress())
.append("monitorPic", getMonitorPic())
.append("preserveTime", getPreserveTime())
.append("remark", getRemark())
.append("monitorUnitStatus", getMonitorUnitStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("monitorUnitField", getMonitorUnitField())
.toString();
}
}
.append("monitorUnitId", getMonitorUnitId())
.append("monitorUnitName", getMonitorUnitName())
.append("sceneId", getSceneId())
.append("parentId", getParentId())
.append("monitorUnitTypeId", getMonitorUnitTypeId())
.append("areaId", getAreaId())
.append("monitorAddress", getMonitorAddress())
.append("monitorPic", getMonitorPic())
.append("preserveTime", getPreserveTime())
.append("remark", getRemark())
.append("monitorUnitStatus", getMonitorUnitStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("monitorUnitField", getMonitorUnitField())
.toString();
}
}

@ -0,0 +1,39 @@
package com.ruoyi.business.domain.VO;
/**
* @Description: VO
* @ClassName: AlarmTypeVo
* @Author : xins
* @Date :2023-09-15 13:10
* @Version :1.0
*/
public class AlarmTypeVo {
private Long alarmTypeId;
private String alarmTypeName;
private Integer alarmCount;
public Long getAlarmTypeId() {
return alarmTypeId;
}
public void setAlarmTypeId(Long alarmTypeId) {
this.alarmTypeId = alarmTypeId;
}
public String getAlarmTypeName() {
return alarmTypeName;
}
public void setAlarmTypeName(String alarmTypeName) {
this.alarmTypeName = alarmTypeName;
}
public Integer getAlarmCount() {
return alarmCount;
}
public void setAlarmCount(Integer alarmCount) {
this.alarmCount = alarmCount;
}
}

@ -0,0 +1,18 @@
package com.ruoyi.business.domain.VO;
import lombok.Data;
/**
* @Description:
* @ClassName: DeviceDataColumnVo
* @Author : xins
* @Date :2023-09-16 16:20
* @Version :1.0
*/
@Data
public class DeviceDataColumnVo {
private String columnName;
private String columnKey;
}

@ -0,0 +1,37 @@
package com.ruoyi.business.domain.VO;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @Description:
* @ClassName: DeviceLatestDataVo
* @Author : xins
* @Date :2023-09-16 14:46
* @Version :1.0
*/
@Data
public class DeviceHistoryDataVo {
@NotNull(message="sceneId cannot be null")
private Long sceneId;
@NotNull(message="deviceId cannot be null")
private Long deviceId;
private int limit;
//指定从第几条之后输出例如limit 2,5输出第3行到第7行的数据
private int offset;
//过滤条件:开始时间
private long startTime;
//过滤条件:结束时间
private long endTime;
}

@ -0,0 +1,43 @@
package com.ruoyi.business.domain.VO;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @Description:
* @ClassName: DeviceLatestDataVo
* @Author : xins
* @Date :2023-09-16 14:46
* @Version :1.0
*/
@Data
public class DeviceLatestDataVo {
@NotNull(message="sceneId cannot be null")
private Long sceneId;
@NotNull(message="deviceModeId cannot be null")
private Long deviceModeId;
private int limit;
//指定从第几条之后输出例如limit 2,5输出第3行到第7行的数据
private int offset;
/**
* timestamp
*/
private String firstFieldName;
//过滤条件:开始时间
private long startTime;
//过滤条件:结束时间
private long endTime;
private String deviceCode;
private String deviceName;
}

@ -15,9 +15,9 @@ public class DeviceModeVo {
public Integer err;
public Double percentage;
public String percentage;
public Double getPercentage() {
public String getPercentage() {
return percentage;
}
@ -45,7 +45,7 @@ public class DeviceModeVo {
this.err = err;
}
public void setPercentage(Double percentage) {
public void setPercentage(String percentage) {
this.percentage = percentage;
}

@ -0,0 +1,89 @@
package com.ruoyi.business.domain.VO;
import java.util.List;
public class ElectronicFenceVo {
public Integer deviceCount;
public Integer abnormalCount;
public String areaShapeFlag;//1多边形2圆形
public AreaPoint centerPoint;//圆形中心点
public List<AreaPoint> areaPoints;//多边型点
public Double radius;
public Integer getDeviceCount() {
return deviceCount;
}
public void setDeviceCount(Integer deviceCount) {
this.deviceCount = deviceCount;
}
public Integer getAbnormalCount() {
return abnormalCount;
}
public void setAbnormalCount(Integer abnormalCount) {
this.abnormalCount = abnormalCount;
}
public String getAreaShapeFlag() {
return areaShapeFlag;
}
public void setAreaShapeFlag(String areaShapeFlag) {
this.areaShapeFlag = areaShapeFlag;
}
public AreaPoint getCenterPoint() {
return centerPoint;
}
public void setCenterPoint(AreaPoint centerPoint) {
this.centerPoint = centerPoint;
}
public List<AreaPoint> getAreaPoints() {
return areaPoints;
}
public void setAreaPoints(List<AreaPoint> areaPoints) {
this.areaPoints = areaPoints;
}
public Double getRadius() {
return radius;
}
public void setRadius(Double radius) {
this.radius = radius;
}
public static class AreaPoint{
private Double longitude;
private Double latitude;
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
}
}

@ -0,0 +1,37 @@
package com.ruoyi.business.domain.VO;
import java.util.List;
import java.util.Map;
public class HwDeviceVo {
private String deviceType;//1、开关属性控制属性2、只有采集属性
private String deviceName;
private List<Map<String, Object>> deviceDataMaps;
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public List<Map<String, Object>> getDeviceDataMaps() {
return deviceDataMaps;
}
public void setDeviceDataMaps(List<Map<String, Object>> deviceDataMaps) {
this.deviceDataMaps = deviceDataMaps;
}
}

@ -9,26 +9,26 @@ package com.ruoyi.business.domain.VO;
public class HwMonitorUnitVo {
public String sceneName;
public String sceneId;
public Long sceneId;
public Integer sum;
public Integer err;
public Double percentage;
public String percentage;
public Double getPercentage() {
public String getPercentage() {
return percentage;
}
public void setPercentage(Double percentage) {
public void setPercentage(String percentage) {
this.percentage = percentage;
}
public String getSceneId() {
public Long getSceneId() {
return sceneId;
}
public void setSceneId(String sceneId) {
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}

@ -7,42 +7,33 @@ package com.ruoyi.business.domain.VO;
* @Date: 2023-09-04 13:42
*/
public class SubDeviceSumVo {
private String SubSum;
private Integer SubSum;
private String DeviceNum;
private Integer DeviceNum;
private String OnlineDeviceNum;
private Integer OnlineDeviceNum;
public String getSubSum() {
public Integer getSubSum() {
return SubSum;
}
public void setSubSum(String subSum) {
public void setSubSum(Integer subSum) {
SubSum = subSum;
}
public String getDeviceNum() {
public Integer getDeviceNum() {
return DeviceNum;
}
public void setDeviceNum(String deviceNum) {
public void setDeviceNum(Integer deviceNum) {
DeviceNum = deviceNum;
}
public String getOnlineDeviceNum() {
public Integer getOnlineDeviceNum() {
return OnlineDeviceNum;
}
public void setOnlineDeviceNum(String onlineDeviceNum) {
public void setOnlineDeviceNum(Integer onlineDeviceNum) {
OnlineDeviceNum = onlineDeviceNum;
}
@Override
public String toString() {
return "SubDeviceSumVo{" +
"SubSum='" + SubSum + '\'' +
", DeviceNum='" + DeviceNum + '\'' +
", OnlineDeviceNum='" + OnlineDeviceNum + '\'' +
'}';
}
}

@ -0,0 +1,70 @@
package com.ruoyi.business.domain.VO;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.business.domain.HwMonitorUnit;
/**
* Treeselect
*
* @author ruoyi
*/
public class TreeSelectVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private Long id;
/**
*
*/
private String label;
/**
*
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelectVo> children;
public TreeSelectVo() {
}
public TreeSelectVo(HwMonitorUnit monitorUnit) {
this.id = monitorUnit.getMonitorUnitId();
this.label = monitorUnit.getMonitorUnitName();
// this.children = monitorUnit.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List<TreeSelectVo> getChildren() {
return children;
}
public void setChildren(List<TreeSelectVo> children) {
this.children = children;
}
}

@ -0,0 +1,65 @@
package com.ruoyi.business.mapper;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmInfo;
import com.ruoyi.business.domain.VO.AlarmTypeVo;
/**
* Mapper
*
* @author xins
* @date 2023-09-15
*/
public interface HwAlarmInfoMapper
{
/**
*
*
* @param alarmInfoId
* @return
*/
public HwAlarmInfo selectHwAlarmInfoByAlarmInfoId(Long alarmInfoId);
/**
*
*
* @param hwAlarmInfo
* @return
*/
public List<HwAlarmInfo> selectHwAlarmInfoList(HwAlarmInfo hwAlarmInfo);
/**
*
*
* @param hwAlarmInfo
* @return
*/
public int insertHwAlarmInfo(HwAlarmInfo hwAlarmInfo);
/**
*
*
* @param hwAlarmInfo
* @return
*/
public int updateHwAlarmInfo(HwAlarmInfo hwAlarmInfo);
/**
*
*
* @param alarmInfoId
* @return
*/
public int deleteHwAlarmInfoByAlarmInfoId(Long alarmInfoId);
/**
*
*
* @param alarmInfoIds
* @return
*/
public int deleteHwAlarmInfoByAlarmInfoIds(Long[] alarmInfoIds);
public List<AlarmTypeVo> selectAlarmsByAlarmType(Long sceneId);
}

@ -0,0 +1,61 @@
package com.ruoyi.business.mapper;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmLevel;
/**
* Mapper
*
* @author xins
* @date 2023-09-15
*/
public interface HwAlarmLevelMapper
{
/**
*
*
* @param alarmLevelId
* @return
*/
public HwAlarmLevel selectHwAlarmLevelByAlarmLevelId(Long alarmLevelId);
/**
*
*
* @param hwAlarmLevel
* @return
*/
public List<HwAlarmLevel> selectHwAlarmLevelList(HwAlarmLevel hwAlarmLevel);
/**
*
*
* @param hwAlarmLevel
* @return
*/
public int insertHwAlarmLevel(HwAlarmLevel hwAlarmLevel);
/**
*
*
* @param hwAlarmLevel
* @return
*/
public int updateHwAlarmLevel(HwAlarmLevel hwAlarmLevel);
/**
*
*
* @param alarmLevelId
* @return
*/
public int deleteHwAlarmLevelByAlarmLevelId(Long alarmLevelId);
/**
*
*
* @param alarmLevelIds
* @return
*/
public int deleteHwAlarmLevelByAlarmLevelIds(Long[] alarmLevelIds);
}

@ -0,0 +1,61 @@
package com.ruoyi.business.mapper;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmType;
/**
* Mapper
*
* @author xins
* @date 2023-09-15
*/
public interface HwAlarmTypeMapper
{
/**
*
*
* @param alarmTypeId
* @return
*/
public HwAlarmType selectHwAlarmTypeByAlarmTypeId(Long alarmTypeId);
/**
*
*
* @param hwAlarmType
* @return
*/
public List<HwAlarmType> selectHwAlarmTypeList(HwAlarmType hwAlarmType);
/**
*
*
* @param hwAlarmType
* @return
*/
public int insertHwAlarmType(HwAlarmType hwAlarmType);
/**
*
*
* @param hwAlarmType
* @return
*/
public int updateHwAlarmType(HwAlarmType hwAlarmType);
/**
*
*
* @param alarmTypeId
* @return
*/
public int deleteHwAlarmTypeByAlarmTypeId(Long alarmTypeId);
/**
*
*
* @param alarmTypeIds
* @return
*/
public int deleteHwAlarmTypeByAlarmTypeIds(Long[] alarmTypeIds);
}

@ -72,4 +72,12 @@ public interface HwDeviceMapper
* @return
*/
public int deleteHwDeviceByDeviceIds(Long[] deviceIds);
public int getOnlineDeviceNum(Long sceneId);
public HwDevice selectHwDeviceJoinByDeviceId(Long deviceId);
public List<HwDevice> selectLinkedDevices(Long deviceId);
}

@ -75,4 +75,10 @@ public interface HwElectronicFenceMapper
* @return
*/
public int deleteHwElectronicFenceByElectronicFenceIds(Long[] electronicFenceIds);
public int selectDeviceCount(Long electronicFenceId);
public int selectDeviceCountByMonitorUnit(Long electronicFenceId);
public int selectDeviceCountByScene(Long sceneId);
}

@ -33,20 +33,20 @@ public interface HwMonitorUnitMapper
public List<AllNumsVo> selectsum();
//查询id与name的结果集
List<HwMonitorUnitVo> selectSceneNameById();
String selectSubSetNums();
Integer selectSubSetNums(Long sceneId);
/**
*
* */
public List<HwMonitorUnit> selectLimitSubMonitorUnit();
Integer selectReleatedDeviceIdNums(Long deviceCode);
String selectDeviceNums();
Integer selectDeviceNums(Long sceneId);
Integer selectSubDeviceSum(Long sceneId);
/**
*
* */
public List<AlarmStatsVo> selectAlarmStats();
public List<AlarmStatsVo> selectAlarmStats(Long sceneId);
/**
* 线
* */
@ -112,4 +112,13 @@ public interface HwMonitorUnitMapper
* @return
*/
public int deleteHwMonitorUnitByMonitorUnitIds(Long[] monitorUnitIds);
}
/**
* join
*
* @param hwMonitorUnit
* @return
*/
public List<HwMonitorUnit> selectHwMonitorUnitListJoinScene(HwMonitorUnit hwMonitorUnit);
}

@ -0,0 +1,71 @@
package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.HwAlarmInfo;
import com.ruoyi.business.domain.VO.AlarmTypeVo;
/**
* Service
*
* @author xins
* @date 2023-09-15
*/
public interface IHwAlarmInfoService
{
/**
*
*
* @param alarmInfoId
* @return
*/
public HwAlarmInfo selectHwAlarmInfoByAlarmInfoId(Long alarmInfoId);
/**
*
*
* @param hwAlarmInfo
* @return
*/
public List<HwAlarmInfo> selectHwAlarmInfoList(HwAlarmInfo hwAlarmInfo);
/**
*
*
* @param hwAlarmInfo
* @return
*/
public int insertHwAlarmInfo(HwAlarmInfo hwAlarmInfo);
/**
*
*
* @param hwAlarmInfo
* @return
*/
public int updateHwAlarmInfo(HwAlarmInfo hwAlarmInfo);
/**
*
*
* @param alarmInfoIds
* @return
*/
public int deleteHwAlarmInfoByAlarmInfoIds(Long[] alarmInfoIds);
/**
*
*
* @param alarmInfoId
* @return
*/
public int deleteHwAlarmInfoByAlarmInfoId(Long alarmInfoId);
/**
* @param: sceneId
* @description
* @author xins
* @date 2023-09-15 13:20
* @return List<AlarmTypeVo>
*/
public List<AlarmTypeVo> selectAlarmsByAlarmType(Long sceneId);
}

@ -5,6 +5,7 @@ import java.util.Map;
import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.VO.DeviceModeVo;
import com.ruoyi.business.domain.VO.HwDeviceVo;
import com.ruoyi.business.domain.VO.HwMonitorUnitVo;
@ -24,14 +25,19 @@ public interface IHwDeviceService
*/
public HwDevice selectHwDeviceByDeviceId(Long deviceId);
/**
*
*
* @param deviceId
* @return
*/
public HwDevice selectHwDeviceJoinByDeviceId(Long deviceId);
/**
* 3.
* */
public List<DeviceModeVo> selectDeviceModeNameVo();
public Map<String, Map<String, Object>> selectDeviceByDeviceModeByMonitorUnitId(Long monitorUnitId);
public Map<String, Map<String, Object>> selectDeviceModeFunctionByFunctionType(Long monitorUnitId);
public List<Map<String, Object>> getHistoryData(Long deviceId);
/**
*
*
@ -40,6 +46,14 @@ public interface IHwDeviceService
*/
public List<HwDevice> selectHwDeviceList(HwDevice hwDevice);
/**
*
*
* @param deviceId
* @return
*/
public List<HwDevice> selectLinkDeviceList(Long deviceId);
/**
*
*
@ -71,4 +85,14 @@ public interface IHwDeviceService
* @return
*/
public int deleteHwDeviceByDeviceId(Long deviceId);
/**
* @return Map<String,List<HwDeviceVo>>
* @description
* @author xins
* @date 2023-09-15 16:59
*/
public Map<String,List<HwDeviceVo>> getDevicesByMonitor(HwDevice queryHwDevice);
}

@ -3,6 +3,7 @@ package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.HwElectronicFence;
import com.ruoyi.business.domain.VO.EleMonitorDeviceSumVo;
import com.ruoyi.business.domain.VO.ElectronicFenceVo;
import com.ruoyi.business.domain.VO.ElectronicNumVo;
/**
@ -24,7 +25,7 @@ public interface IHwElectronicFenceService
*
* */
public List<HwElectronicFence> selectElectronicByScene(Long sceneId);
List<EleMonitorDeviceSumVo> selectEleTypeNums(Long sceneId);
public List<ElectronicFenceVo> selectEleTypeNums(Long sceneId);
/**
*
*

@ -0,0 +1,35 @@
package com.ruoyi.business.service;
import com.ruoyi.business.domain.VO.DeviceHistoryDataVo;
import com.ruoyi.business.domain.VO.DeviceLatestDataVo;
import java.util.List;
import java.util.Map;
/**
* @Description:
* @ClassName: IHwMonitorPlatformService
* @Author : xins
* @Date :2023-09-16 14:49
* @Version :1.0
*/
public interface IHwMonitorPlatformService {
/**
* @param: deviceLatestDataVo
* @description
* @author xins
* @date 2023-09-16 14:49
* @return List<Map<Object>>
*/
public List<Map<String, Object>> selectLatestDataByTags(DeviceLatestDataVo deviceLatestDataVo);
/**
* @param: deviceHistoryDataVo
* @description
* @author xins
* @date 2023-09-16 15:14
* @return List<Map<Object>>
*/
public List<Map<String, Object>> getHistoryData(DeviceHistoryDataVo deviceHistoryDataVo);
}

@ -2,6 +2,7 @@ package com.ruoyi.business.service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.ruoyi.business.domain.HwMonitorUnit;
import com.ruoyi.business.domain.VO.*;
@ -30,8 +31,8 @@ public interface IHwMonitorUnitService
/**
*
* */
public AllNumsVo selectAllNums();
public List<AllNumsVo> selectSenceAllNums();
public AllNumsVo selectAllNums(Long sceneId);
// public List<AllNumsVo> selectSenceAllNums();
/**
*
@ -48,7 +49,7 @@ public interface IHwMonitorUnitService
/**
*
* */
public List<AlarmStatsVo> selectAlarmStats();
public List<AlarmStatsVo> selectAlarmStats(Long sceneId);
/**
*
*
@ -61,10 +62,7 @@ public interface IHwMonitorUnitService
* 线
* */
public SubDeviceSumVo selectSubDeviceSum(Long sceneId);
/**
*
* */
public Integer selectElectronicNum(Long sceneId);
/**
*
* */
@ -73,19 +71,9 @@ public interface IHwMonitorUnitService
*
* */
public HwMonitorUnit selectHwmonitorUnitSub(Long monitorUnitId);
/**
* tdengine
*
* @return*/
public Map<Object, Integer> selectTdengine(String beginTime, String endTime, Long sceneId);
/**
*
*
* @return*/
public R<Map<String, Map<String, Object>>> selectLatestDataByTags(Long monitorUnitId);
/**
/**
*
*
* @param hwMonitorUnit
@ -116,4 +104,29 @@ public interface IHwMonitorUnitService
* @return
*/
public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId);
}
/**
*
*
* @param hwMonitorUnit
* @return
*/
public List<TreeSelectVo> selectMonitorTreeList(HwMonitorUnit hwMonitorUnit);
/**
*
*
* @param hwMonitorUnits
* @return
*/
public List<TreeSelectVo> buildMonitorUnitTreeSelect(List<HwMonitorUnit> hwMonitorUnits);
/**
*
*
* @param hwMonitorUnits
* @return
*/
public List<HwMonitorUnit> buildMonitorUnitTree(List<HwMonitorUnit> hwMonitorUnits);
}

@ -0,0 +1,136 @@
package com.ruoyi.business.service.impl;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.ruoyi.business.domain.HwAlarmType;
import com.ruoyi.business.domain.VO.AlarmTypeVo;
import com.ruoyi.business.mapper.HwAlarmTypeMapper;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwAlarmInfoMapper;
import com.ruoyi.business.domain.HwAlarmInfo;
import com.ruoyi.business.service.IHwAlarmInfoService;
/**
* Service
*
* @author xins
* @date 2023-09-15
*/
@Service
public class HwAlarmInfoServiceImpl implements IHwAlarmInfoService {
@Autowired
private HwAlarmInfoMapper hwAlarmInfoMapper;
@Autowired
private HwAlarmTypeMapper hwAlarmTypeMapper;
/**
*
*
* @param alarmInfoId
* @return
*/
@Override
public HwAlarmInfo selectHwAlarmInfoByAlarmInfoId(Long alarmInfoId) {
return hwAlarmInfoMapper.selectHwAlarmInfoByAlarmInfoId(alarmInfoId);
}
/**
*
*
* @param hwAlarmInfo
* @return
*/
@Override
public List<HwAlarmInfo> selectHwAlarmInfoList(HwAlarmInfo hwAlarmInfo) {
return hwAlarmInfoMapper.selectHwAlarmInfoList(hwAlarmInfo);
}
/**
*
*
* @param hwAlarmInfo
* @return
*/
@Override
public int insertHwAlarmInfo(HwAlarmInfo hwAlarmInfo) {
hwAlarmInfo.setCreateTime(DateUtils.getNowDate());
return hwAlarmInfoMapper.insertHwAlarmInfo(hwAlarmInfo);
}
/**
*
*
* @param hwAlarmInfo
* @return
*/
@Override
public int updateHwAlarmInfo(HwAlarmInfo hwAlarmInfo) {
hwAlarmInfo.setUpdateTime(DateUtils.getNowDate());
return hwAlarmInfoMapper.updateHwAlarmInfo(hwAlarmInfo);
}
/**
*
*
* @param alarmInfoIds
* @return
*/
@Override
public int deleteHwAlarmInfoByAlarmInfoIds(Long[] alarmInfoIds) {
return hwAlarmInfoMapper.deleteHwAlarmInfoByAlarmInfoIds(alarmInfoIds);
}
/**
*
*
* @param alarmInfoId
* @return
*/
@Override
public int deleteHwAlarmInfoByAlarmInfoId(Long alarmInfoId) {
return hwAlarmInfoMapper.deleteHwAlarmInfoByAlarmInfoId(alarmInfoId);
}
/**
* @return List<AlarmTypeVo>
* @param: sceneId
* @description
* @author xins
* @date 2023-09-15 13:20
*/
@Override
public List<AlarmTypeVo> selectAlarmsByAlarmType(Long sceneId) {
List<AlarmTypeVo> list = hwAlarmInfoMapper.selectAlarmsByAlarmType(sceneId);
HwAlarmType queryAlarmType = new HwAlarmType();
queryAlarmType.setSceneId(sceneId);
List<HwAlarmType> alarmTypes = hwAlarmTypeMapper.selectHwAlarmTypeList(queryAlarmType);
Map<Long, HwAlarmType> alarmTypeMap = alarmTypes.stream()
.collect(Collectors.toMap(HwAlarmType::getAlarmTypeId, alarmType -> alarmType));
list.stream().forEach(alarmType -> {
alarmType.setAlarmTypeName(alarmTypeMap.get(alarmType.getAlarmTypeId()) == null ? ""
: alarmTypeMap.get(alarmType.getAlarmTypeId()).getAlarmTypeName());
alarmTypeMap.remove(alarmType.getAlarmTypeId());
});
Set<Long> alarmTypeIds = alarmTypeMap.keySet();
for (Long alarmTypeId : alarmTypeIds) {
HwAlarmType alarmType = alarmTypeMap.get(alarmTypeId);
AlarmTypeVo alarmTypeVo = new AlarmTypeVo();
alarmTypeVo.setAlarmTypeId(alarmType.getAlarmTypeId());
alarmTypeVo.setAlarmTypeName(alarmType.getAlarmTypeName());
alarmTypeVo.setAlarmCount(0);
list.add(alarmTypeVo);
}
return list;
}
}

@ -8,6 +8,7 @@ import com.ruoyi.business.mapper.HwDeviceMapper;
import com.ruoyi.business.mapper.HwDeviceModeFunctionMapper;
import com.ruoyi.business.mapper.HwDeviceModeMapper;
import com.ruoyi.business.service.IHwDeviceModeService;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.domain.R;
@ -146,6 +147,14 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
@Transactional
@Override
public int deleteHwDeviceModeByDeviceModeIds(Long[] deviceModeIds) {
for (Long deviceModeId : deviceModeIds) {
HwDevice queryDevice = new HwDevice();
queryDevice.setDeviceModeId(deviceModeId);
List<HwDevice> deviceList = hwDeviceMapper.selectHwDeviceList(queryDevice);
if (deviceList != null && !deviceList.isEmpty()) {
throw new ServiceException("该设备模型下存在设备,不能删除");
}
}
hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeIds(deviceModeIds);
return hwDeviceModeMapper.deleteHwDeviceModeByDeviceModeIds(deviceModeIds);
}
@ -408,7 +417,11 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
tdSuperTableVo.setFirstFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
tdSuperTableVo.setSchemaFields(schemaFields);
tdSuperTableVo.setTagsFields(tagFields);
this.remoteTdEngineService.createSuperTable(tdSuperTableVo);
R<?> tdReturnMsg = this.remoteTdEngineService.createSuperTable(tdSuperTableVo);
if(tdReturnMsg.getCode() != Constants.SUCCESS){//抛出异常,回滚事务
throw new RuntimeException(tdReturnMsg.getMsg());
}
}
private void addTdSuperTableColumn(HwDeviceModeFunction hwDeviceModeFunction) {
@ -430,7 +443,10 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
tdSuperTableVo.setDatabaseName(dbName);
tdSuperTableVo.setSuperTableName(superTableName);
tdSuperTableVo.setField(schemaField);
this.remoteTdEngineService.addSuperTableColumn(tdSuperTableVo);
R<?> tdReturnMsg = this.remoteTdEngineService.addSuperTableColumn(tdSuperTableVo);
if(tdReturnMsg.getCode() != Constants.SUCCESS){//抛出异常,回滚事务
throw new RuntimeException(tdReturnMsg.getMsg());
}
}
}
@ -448,7 +464,10 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
tdSuperTableVo.setSuperTableName(superTableName);
tdSuperTableVo.setField(schemaField);
this.remoteTdEngineService.dropColumnForSuperTable(tdSuperTableVo);
R<?> tdReturnMsg =this.remoteTdEngineService.dropColumnForSuperTable(tdSuperTableVo);
if(tdReturnMsg.getCode() != Constants.SUCCESS){//抛出异常,回滚事务
throw new RuntimeException(tdReturnMsg.getMsg());
}
}
}

@ -4,11 +4,18 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.VO.DeviceModeVo;
import com.ruoyi.business.domain.VO.HwDeviceVo;
import com.ruoyi.business.mapper.HwDeviceModeFunctionMapper;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.enums.DataTypeEnums;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.NumberUtils;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.TdHistorySelectDto;
import com.ruoyi.tdengine.api.domain.TdSelectDto;
@ -25,11 +32,12 @@ import com.ruoyi.business.service.IHwDeviceService;
* @date 2023-08-24
*/
@Service
public class HwDeviceServiceImpl implements IHwDeviceService
{
public class HwDeviceServiceImpl implements IHwDeviceService {
@Autowired
private HwDeviceMapper hwDeviceMapper;
@Autowired
private HwDeviceModeFunctionMapper hwDevieModeFunctionMapper;
@Autowired
private RemoteTdEngineService remoteTdEgineService;
/**
@ -39,11 +47,21 @@ public class HwDeviceServiceImpl implements IHwDeviceService
* @return
*/
@Override
public HwDevice selectHwDeviceByDeviceId(Long deviceId)
{
public HwDevice selectHwDeviceByDeviceId(Long deviceId) {
return hwDeviceMapper.selectHwDeviceByDeviceId(deviceId);
}
/**
* ,
*
* @param deviceId
* @return
*/
@Override
public HwDevice selectHwDeviceJoinByDeviceId(Long deviceId) {
return hwDeviceMapper.selectHwDeviceJoinByDeviceId(deviceId);
}
/**
*
*
@ -51,11 +69,21 @@ public class HwDeviceServiceImpl implements IHwDeviceService
* @return
*/
@Override
public List<HwDevice> selectHwDeviceList(HwDevice hwDevice)
{
public List<HwDevice> selectHwDeviceList(HwDevice hwDevice) {
return hwDeviceMapper.selectHwDeviceList(hwDevice);
}
/**
*
*
* @param deviceId
* @return
*/
@Override
public List<HwDevice> selectLinkDeviceList(Long deviceId) {
return hwDeviceMapper.selectLinkedDevices(deviceId);
}
/**
*
*
@ -63,94 +91,52 @@ public class HwDeviceServiceImpl implements IHwDeviceService
* @return
*/
@Override
public int insertHwDevice(HwDevice hwDevice)
{
public int insertHwDevice(HwDevice hwDevice) {
hwDevice.setCreateTime(DateUtils.getNowDate());
return hwDeviceMapper.insertHwDevice(hwDevice);
}
/**
* 3.
* */
*/
@Override
public List<DeviceModeVo> selectDeviceModeNameVo() {
List<DeviceModeVo> list = hwDeviceMapper.selectDeviceModeNameVo();
Integer value = 0;
if (list.size() > 10) {
for (int i = 9; i < list.size(); i++) {
if (list.get(i).sum==null){
if (list.get(i).sum == null) {
list.get(i).sum = 0;
}
value = value + list.get(i).sum;
}
}
DeviceModeVo hwMonitorUnitTypeVo = new DeviceModeVo();
hwMonitorUnitTypeVo.setDeviceModeName("其他");
hwMonitorUnitTypeVo.setSum(value);
// DeviceModeVo hwMonitorUnitTypeVo = new DeviceModeVo();
// hwMonitorUnitTypeVo.setDeviceModeName("其他");
// hwMonitorUnitTypeVo.setSum(value);
Integer sums = 0;
for (int i = 0; i < list.size();i++){
if (list.get(i).sum==null){
for (int i = 0; i < list.size(); i++) {
if (list.get(i).sum == null) {
list.get(i).sum = 0;
}
sums = sums+list.get(i).sum;
}
for (int i=0;i<list.size();i++){
list.get(i).setPercentage((double) (list.get(i).getSum()/sums));
sums = sums + list.get(i).sum;
}
if (list.size() > 10) {
list.add(10, hwMonitorUnitTypeVo);
return list.subList(0, 10);
} else {
return list;
for (int i = 0; i < list.size(); i++) {
list.get(i).setPercentage(NumberUtils.getPercentage(list.get(i).getSum(), sums));
System.out.println(list.get(i).toString());
}
}
//获取有开关属性的设备
@Override
public Map<String, Map<String, Object>> selectDeviceByDeviceModeByMonitorUnitId(Long monitorUnitId){
List<HwDevice> hwDevices = hwDeviceMapper.selectDeviceByDeviceModeByMonitorUnitId(monitorUnitId);//todo 根据监控单元(已解决)
TdSelectDto tdSelectDto = new TdSelectDto();
Map<String, Map<String, Object>> latestDataByTags = new HashMap<String, Map<String,Object>>();
for (int i = 0; i < hwDevices.size(); i++){
String s = hwDeviceMapper.selectDeviceByDeviceModeByDeviceModeFunction(hwDevices.get(i).getDeviceId());
if (s!=null&&s!=""){
tdSelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
tdSelectDto.setSuperTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME);
tdSelectDto.setTagsName(hwDevices.get(i).getDeviceCode());
latestDataByTags = (Map<String, Map<String, Object>>) remoteTdEgineService.getLatestDataByTags(tdSelectDto);
}
//todo 根据获取的device通过devicemodeid获取devicemode再根据devicemodeid获取devicemodefunction已解决
// todo 然后根据devicemodefunction中的datatype为8的是bool的(以解决)
}
return latestDataByTags;
}
//查询直采变量属性的设备
@Override
public Map<String, Map<String, Object>> selectDeviceModeFunctionByFunctionType(Long monitorUnitId) {
List<HwDevice> hwDevices = hwDeviceMapper.selectDeviceByDeviceModeByMonitorUnitId(monitorUnitId);//todo 根据监控单元(已解决)
TdSelectDto tdSelectDto = new TdSelectDto();
Map<String, Map<String, Object>> latestDataByTags = new HashMap<String, Map<String,Object>>();
for (int i = 0; i < hwDevices.size(); i++){
String s = hwDeviceMapper.selectDeviceModeFunctionByFunctionType(hwDevices.get(i).getDeviceId());
if (s!=null&&s!=""){
tdSelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
tdSelectDto.setSuperTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME);
tdSelectDto.setTagsName(hwDevices.get(i).getDeviceCode());
latestDataByTags = (Map<String, Map<String, Object>>) remoteTdEgineService.getLatestDataByTags(tdSelectDto);
}}
return latestDataByTags;
}
@Override
public List<Map<String, Object>> getHistoryData(Long deviceId) {
TdHistorySelectDto tdHistorySelectDto = new TdHistorySelectDto();
tdHistorySelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
tdHistorySelectDto.setTableName(TdEngineConstants.getDeviceDataTableName(deviceId));
tdHistorySelectDto.setOrderByFieldName(tdHistorySelectDto.getFirstFieldName());
tdHistorySelectDto.setSort(TdEngineConstants.DEFAULT_ORDER_BY_MODE);
List<Map<String, Object>> historyData = (List<Map<String, Object>>) remoteTdEgineService.getHistoryData(tdHistorySelectDto);
return historyData;
return list;
// if (list.size() > 10) {
// list.add(10, hwMonitorUnitTypeVo);
// return list.subList(0, 10);
// } else {
// return list;
// }
}
/**
*
*
@ -158,8 +144,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService
* @return
*/
@Override
public int updateHwDevice(HwDevice hwDevice)
{
public int updateHwDevice(HwDevice hwDevice) {
hwDevice.setUpdateTime(DateUtils.getNowDate());
return hwDeviceMapper.updateHwDevice(hwDevice);
}
@ -171,8 +156,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService
* @return
*/
@Override
public int deleteHwDeviceByDeviceIds(Long[] deviceIds)
{
public int deleteHwDeviceByDeviceIds(Long[] deviceIds) {
return hwDeviceMapper.deleteHwDeviceByDeviceIds(deviceIds);
}
@ -183,8 +167,70 @@ public class HwDeviceServiceImpl implements IHwDeviceService
* @return
*/
@Override
public int deleteHwDeviceByDeviceId(Long deviceId)
{
public int deleteHwDeviceByDeviceId(Long deviceId) {
return hwDeviceMapper.deleteHwDeviceByDeviceId(deviceId);
}
/**
* @return Map<String,List<HwDeviceVo>>
* @description
* @author xins
* @date 2023-09-15 16:59
*/
@Override
public Map<String,List<HwDeviceVo>> getDevicesByMonitor(HwDevice queryHwDevice) {
Map<String,List<HwDeviceVo>> devicesMap = new HashMap<String,List<HwDeviceVo>>();
List<HwDeviceVo> controlDeviceVos = new ArrayList<HwDeviceVo>();
List<HwDeviceVo> acquisitionDeviceVos = new ArrayList<HwDeviceVo>();
Long sceneId = queryHwDevice.getSceneId();
String databaseName = TdEngineConstants.getDatabaseName(sceneId);
List<HwDevice> hwDevices = hwDeviceMapper.selectHwDeviceList(queryHwDevice);
hwDevices.forEach(hwDevice -> {
Long deviceId = hwDevice.getDeviceId();
String tableName = TdEngineConstants.getDeviceDataTableName(deviceId);
TdSelectDto tdSelectDto = new TdSelectDto();
tdSelectDto.setDatabaseName(databaseName);
tdSelectDto.setTableName(tableName);
List<Map<String, Object>> deviceLatestDataMapList = (List<Map<String, Object>>) this.remoteTdEgineService.getLatestData(tdSelectDto).getData();
HwDeviceModeFunction queryDeviceModeFunction = new HwDeviceModeFunction();
queryDeviceModeFunction.setDeviceModeId(hwDevice.getDeviceModeId());
List<HwDeviceModeFunction> deviceModeFunctions = hwDevieModeFunctionMapper.selectHwDeviceModeFunctionList(queryDeviceModeFunction);
List<HwDeviceModeFunction> dds = deviceModeFunctions.stream()
.filter(dmf -> dmf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)
&& dmf.getDataType() != null && String.valueOf(dmf.getDataType()).equals(String.valueOf(DataTypeEnums.TINYINT.getDataCode()))).collect(Collectors.toList());
HwDeviceVo hwDeviceVo = new HwDeviceVo();
hwDeviceVo.setDeviceName(hwDevice.getDeviceName());
if (dds != null && dds.size() > 0) {
hwDeviceVo.setDeviceType(HwDictConstants.CONTROL_DEVICE);
HwDeviceModeFunction dd = dds.get(0);
List<Map<String, Object>> ddValueMapList = new ArrayList<Map<String, Object>>();
Map<String, Object> ddValueMap = new HashMap<String, Object>();
deviceLatestDataMapList.forEach(deviceLatestDataMap -> {
ddValueMap.put(dd.getFunctionIdentifier(), deviceLatestDataMap.get(dd.getFunctionIdentifier()) == null
? 0 : deviceLatestDataMap.get(dd.getFunctionIdentifier()));
});
ddValueMapList.add(ddValueMap);
hwDeviceVo.setDeviceDataMaps(ddValueMapList);
controlDeviceVos.add(hwDeviceVo);
} else {
hwDeviceVo.setDeviceType(HwDictConstants.ACQUISITION_DEVICE);
hwDeviceVo.setDeviceDataMaps(deviceLatestDataMapList);
acquisitionDeviceVos.add(hwDeviceVo);
}
});
devicesMap.put(HwDictConstants.CONTROL_DEVICE_NAME, controlDeviceVos);
devicesMap.put(HwDictConstants.ACQUISITION_DEVICE_NAME, acquisitionDeviceVos);
return devicesMap;
}
}

@ -3,7 +3,13 @@ package com.ruoyi.business.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.business.domain.HwFenceTarget;
import com.ruoyi.business.domain.VO.EleMonitorDeviceSumVo;
import com.ruoyi.business.domain.VO.ElectronicFenceVo;
import com.ruoyi.business.mapper.HwFenceTargetMapper;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -18,11 +24,13 @@ import com.ruoyi.business.service.IHwElectronicFenceService;
* @date 2023-09-04
*/
@Service
public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService
{
public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
@Autowired
private HwElectronicFenceMapper hwElectronicFenceMapper;
@Autowired
private HwFenceTargetMapper hwFenceTargetMapper;
/**
*
*
@ -30,8 +38,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService
* @return
*/
@Override
public HwElectronicFence selectHwElectronicFenceByElectronicFenceId(Long electronicFenceId)
{
public HwElectronicFence selectHwElectronicFenceByElectronicFenceId(Long electronicFenceId) {
return hwElectronicFenceMapper.selectHwElectronicFenceByElectronicFenceId(electronicFenceId);
}
@ -41,114 +48,58 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService
}
@Override
public List<EleMonitorDeviceSumVo> selectEleTypeNums(Long sceneId) {
List<Integer> list = hwElectronicFenceMapper.selectEleTypeBySceneId(sceneId);
list.stream().forEach(v->{});
List<EleMonitorDeviceSumVo> voList = new ArrayList<EleMonitorDeviceSumVo>();
if (list.size()==1){
if (list.get(0)==1){
//电子围栏下只有设备
voList = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId);
return voList;
}
else if (list.get(0)==2){
//电子围栏下只有监控单元
voList = hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId);
return voList;
}
else if (list.get(0)==3){
//电子围栏下只有场景
Integer integer = hwElectronicFenceMapper.selectEleOnlyScene(sceneId);
EleMonitorDeviceSumVo eleMonitorDeviceSumVo = new EleMonitorDeviceSumVo();
eleMonitorDeviceSumVo.setSceneId(sceneId);
eleMonitorDeviceSumVo.setSum(integer);
voList.add(eleMonitorDeviceSumVo);
return voList;
}
}
else if (list.size()==2){
if (list.get(0)+list.get(1)==3){
//设备与监控单元
List<EleMonitorDeviceSumVo> devices = new ArrayList<>();
List<EleMonitorDeviceSumVo> monitor = new ArrayList<>();
//查询场景下的所有设备根据电子围栏分组,在查询场景下的所有监控单元以及下面的设备按电子围栏分组
//shebei
devices = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId);
//jiankongdanyuan
monitor = hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId);
for (int i=0; i<devices.size(); i++){
for (int j = 0;j<monitor.size();j++){
if(devices.get(i).getElectronicFenceId()==monitor.get(j).getElectronicFenceId()){
monitor.get(j).setSum(monitor.get(j).getSum()-devices.get(i).getSum());
voList.addAll(devices);
voList.addAll(monitor);
}
}
}
return voList;
}
else if (list.get(0)+list.get(1)==4){
//设备与场景
List<EleMonitorDeviceSumVo> devices = new ArrayList<>();
devices = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId);
Integer aLong = hwElectronicFenceMapper.selectEleOnlyScene(sceneId);
for (int i = 0; i < devices.size();i++){
aLong = aLong-devices.get(i).getSum();
}
EleMonitorDeviceSumVo eleMonitorDeviceSumVo = new EleMonitorDeviceSumVo();
eleMonitorDeviceSumVo.setSceneId(sceneId);
eleMonitorDeviceSumVo.setSum(aLong);
voList.add(eleMonitorDeviceSumVo);
voList.addAll(devices);
return voList;
}
else if (list.get(0)+list.get(1)==5){
//场景与监控单元
List<EleMonitorDeviceSumVo> monitor = new ArrayList<>();
monitor=hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId);
Integer aLong = hwElectronicFenceMapper.selectEleOnlyScene(sceneId);
for (int i = 0;i<monitor.size();i++){
aLong = aLong-monitor.get(i).getSum();
public List<ElectronicFenceVo> selectEleTypeNums(Long sceneId) {
List<ElectronicFenceVo> electronicFenceVos = new ArrayList<ElectronicFenceVo>();
HwElectronicFence queryElectronicFence = new HwElectronicFence();
queryElectronicFence.setSceneId(sceneId);
List<HwElectronicFence> electronicFenceList = hwElectronicFenceMapper.selectHwElectronicFenceList(queryElectronicFence);
electronicFenceList.forEach(electronicFence -> {
ElectronicFenceVo e = new ElectronicFenceVo();
String fenceType = electronicFence.getFenceType();
String areaShapeFlag = electronicFence.getAreaShapeFlag();
String areaRange = electronicFence.getAreaRange();
Integer deviceCount = 0;
if (fenceType.equals(HwDictConstants.FENCE_TYPE_DEVICE)
|| fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) {
deviceCount = hwElectronicFenceMapper.selectDeviceCount(electronicFence.getElectronicFenceId());
}
if (fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) {
deviceCount = hwElectronicFenceMapper.selectDeviceCountByMonitorUnit(electronicFence.getElectronicFenceId());
} else if (fenceType.equals(HwDictConstants.FENCE_TYPE_SCENE)) {
deviceCount = hwElectronicFenceMapper.selectDeviceCountByScene(electronicFence.getSceneId());
}
if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) {
String[] areaRangeArr = areaRange.split("_");
List<ElectronicFenceVo.AreaPoint> points = new ArrayList<ElectronicFenceVo.AreaPoint>();
for (String areaR : areaRangeArr) {
String[] areaRArr = areaR.split(",");
ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint();
p.setLongitude(Double.valueOf(areaRArr[0]));
p.setLatitude(Double.valueOf(areaRArr[1]));
points.add(p);
}
EleMonitorDeviceSumVo eleMonitorDeviceSumVo = new EleMonitorDeviceSumVo();
eleMonitorDeviceSumVo.setSceneId(sceneId);
eleMonitorDeviceSumVo.setSum(aLong);
voList.add(eleMonitorDeviceSumVo);
voList.addAll(monitor);
return voList;
}
}else if (list.size()==3){
List<EleMonitorDeviceSumVo> devices = new ArrayList<>();
List<EleMonitorDeviceSumVo> monitor = new ArrayList<>();
//shebei
devices = hwElectronicFenceMapper.selectSumsFromMonitorByElectronicFence(sceneId);
//jiankongdanyuan
monitor = hwElectronicFenceMapper.selectEleOnlyMonitorBySceneId(sceneId);
Integer aLong = hwElectronicFenceMapper.selectEleOnlyScene(sceneId);
for (int i=0; i<devices.size(); i++){
for (int j = 0;j<monitor.size();j++){
if(devices.get(i).getElectronicFenceId()==monitor.get(j).getElectronicFenceId()){
monitor.get(j).setSum(monitor.get(j).getSum()-devices.get(i).getSum());
}
}
}
for (int i=0; i<monitor.size(); i++){
aLong = aLong - monitor.get(i).getSum();
}
for (int i = 0;i<devices.size();i++){
aLong = aLong-devices.get(i).getSum();
}
EleMonitorDeviceSumVo eleMonitorDeviceSumVo = new EleMonitorDeviceSumVo();
eleMonitorDeviceSumVo.setSceneId(sceneId);
eleMonitorDeviceSumVo.setSum(aLong);
voList.add(eleMonitorDeviceSumVo);
voList.addAll(devices);
voList.addAll(monitor);
}
return voList;
e.setAreaPoints(points);
} else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) {
String[] areaRangeArr = areaRange.split(",");
ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint();
p.setLongitude(Double.valueOf(areaRangeArr[0]));
p.setLatitude(Double.valueOf(areaRangeArr[1]));
e.setCenterPoint(p);
e.setRadius(Double.valueOf(areaRangeArr[2]));
}
e.setAbnormalCount(2);//todo 异常数量获取
e.setAreaShapeFlag(areaShapeFlag);
e.setDeviceCount(deviceCount);
electronicFenceVos.add(e);
});
return electronicFenceVos;
}
/**
@ -158,8 +109,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService
* @return
*/
@Override
public List<HwElectronicFence> selectHwElectronicFenceList(HwElectronicFence hwElectronicFence)
{
public List<HwElectronicFence> selectHwElectronicFenceList(HwElectronicFence hwElectronicFence) {
return hwElectronicFenceMapper.selectHwElectronicFenceList(hwElectronicFence);
}
@ -170,8 +120,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService
* @return
*/
@Override
public int insertHwElectronicFence(HwElectronicFence hwElectronicFence)
{
public int insertHwElectronicFence(HwElectronicFence hwElectronicFence) {
hwElectronicFence.setCreateTime(DateUtils.getNowDate());
return hwElectronicFenceMapper.insertHwElectronicFence(hwElectronicFence);
}
@ -183,8 +132,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService
* @return
*/
@Override
public int updateHwElectronicFence(HwElectronicFence hwElectronicFence)
{
public int updateHwElectronicFence(HwElectronicFence hwElectronicFence) {
hwElectronicFence.setUpdateTime(DateUtils.getNowDate());
return hwElectronicFenceMapper.updateHwElectronicFence(hwElectronicFence);
}
@ -196,8 +144,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService
* @return
*/
@Override
public int deleteHwElectronicFenceByElectronicFenceIds(Long[] electronicFenceIds)
{
public int deleteHwElectronicFenceByElectronicFenceIds(Long[] electronicFenceIds) {
return hwElectronicFenceMapper.deleteHwElectronicFenceByElectronicFenceIds(electronicFenceIds);
}
@ -208,8 +155,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService
* @return
*/
@Override
public int deleteHwElectronicFenceByElectronicFenceId(Long electronicFenceId)
{
public int deleteHwElectronicFenceByElectronicFenceId(Long electronicFenceId) {
return hwElectronicFenceMapper.deleteHwElectronicFenceByElectronicFenceId(electronicFenceId);
}
}

@ -0,0 +1,86 @@
package com.ruoyi.business.service.impl;
import com.ruoyi.business.domain.VO.DeviceDataColumnVo;
import com.ruoyi.business.domain.VO.DeviceHistoryDataVo;
import com.ruoyi.business.domain.VO.DeviceLatestDataVo;
import com.ruoyi.business.service.IHwMonitorPlatformService;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.TdHistorySelectDto;
import com.ruoyi.tdengine.api.domain.TdSuperTableSelectVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Description:
* @ClassName: HwMonitorPlatformServiceImpl
* @Author : xins
* @Date :2023-09-16 14:50
* @Version :1.0
*/
@Service
public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
@Resource
private RemoteTdEngineService remoteTdEngineService;
/**
* @return List<Map < Object>>
* @param: deviceLatestDataVo
* @description
* @author xins
* @date 2023-09-16 14:49
*/
@Override
public List<Map<String, Object>> selectLatestDataByTags(DeviceLatestDataVo deviceLatestDataVo) {
TdSuperTableSelectVo tdSuperTableSelectVo = new TdSuperTableSelectVo();
String databaseName = TdEngineConstants.getDatabaseName(deviceLatestDataVo.getSceneId());
String superTableName = TdEngineConstants.getSupertTableName(deviceLatestDataVo.getDeviceModeId());
tdSuperTableSelectVo.setDatabaseName(databaseName);
tdSuperTableSelectVo.setSuperTableName(superTableName);
tdSuperTableSelectVo.setGroupByTagsName(TdEngineConstants.ST_TAG_DEVICEID);
if (deviceLatestDataVo.getStartTime() != 0 || deviceLatestDataVo.getEndTime() != 0) {
tdSuperTableSelectVo.setFirstFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
}
tdSuperTableSelectVo.setDeviceCode(deviceLatestDataVo.getDeviceCode());
tdSuperTableSelectVo.setDeviceName(deviceLatestDataVo.getDeviceName());
tdSuperTableSelectVo.setStartTime(deviceLatestDataVo.getStartTime());
tdSuperTableSelectVo.setEndTime(deviceLatestDataVo.getEndTime());
tdSuperTableSelectVo.setOffset(deviceLatestDataVo.getOffset());
tdSuperTableSelectVo.setLimit(deviceLatestDataVo.getLimit());
return this.remoteTdEngineService.getLatestDataByTags(tdSuperTableSelectVo).getData();
}
/**
* @param: deviceHistoryDataVo
* @description
* @author xins
* @date 2023-09-16 15:14
* @return List<Map<Object>>
*/
@Override
public List<Map<String, Object>> getHistoryData(DeviceHistoryDataVo deviceHistoryDataVo) {
TdHistorySelectDto tdHistorySelectDto = new TdHistorySelectDto();
tdHistorySelectDto.setDatabaseName(TdEngineConstants.getDatabaseName(deviceHistoryDataVo.getSceneId()));
tdHistorySelectDto.setTableName(TdEngineConstants.getDeviceDataTableName(deviceHistoryDataVo.getDeviceId()));
tdHistorySelectDto.setOrderByFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
tdHistorySelectDto.setSort(TdEngineConstants.DEFAULT_ORDER_BY_MODE);
if (deviceHistoryDataVo.getStartTime() != 0 || deviceHistoryDataVo.getEndTime() != 0) {
tdHistorySelectDto.setFirstFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
}
tdHistorySelectDto.setStartTime(deviceHistoryDataVo.getStartTime());
tdHistorySelectDto.setEndTime(deviceHistoryDataVo.getEndTime());
tdHistorySelectDto.setOffset(deviceHistoryDataVo.getOffset());
tdHistorySelectDto.setLimit(deviceHistoryDataVo.getLimit());
return this.remoteTdEngineService.getHistoryData(tdHistorySelectDto).getData();
}
}

@ -1,29 +1,33 @@
package com.ruoyi.business.service.impl;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import com.ruoyi.business.domain.HwAlarmInfo;
import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.HwMonitorUnit;
import com.ruoyi.business.domain.VO.*;
import com.ruoyi.business.mapper.HwAlarmInfoMapper;
import com.ruoyi.business.mapper.HwDeviceMapper;
import com.ruoyi.business.mapper.HwElectronicFenceMapper;
import com.ruoyi.business.mapper.HwMonitorUnitMapper;
import com.ruoyi.business.service.IHwMonitorUnitService;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.NumberUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.DeviceStatus;
import com.ruoyi.tdengine.api.domain.TdSelectDto;
import com.ruoyi.tdengine.api.domain.TdSuperTableSelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwMonitorUnitMapper;
import com.ruoyi.business.domain.HwMonitorUnit;
import com.ruoyi.business.service.IHwMonitorUnitService;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* Service
@ -32,8 +36,7 @@ import com.ruoyi.business.service.IHwMonitorUnitService;
* @date 2023-08-31
*/
@Service
public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
{
public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService {
@Autowired
private HwMonitorUnitMapper hwMonitorUnitMapper;
@Autowired
@ -42,8 +45,8 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
private RemoteTdEngineService remoteTdEgineService;
@Autowired
private HwDeviceMapper hwDeviceMapper;
@Autowired
private HwAlarmInfoMapper hwAlarmInfoMapper;
/**
*
@ -52,106 +55,106 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
* @return
*/
@Override
public HwMonitorUnit selectHwMonitorUnitByMonitorUnitId(Long monitorUnitId)
{
public HwMonitorUnit selectHwMonitorUnitByMonitorUnitId(Long monitorUnitId) {
return hwMonitorUnitMapper.selectHwMonitorUnitByMonitorUnitId(monitorUnitId);
}
/**
*
* */
*/
@Override
public List<HwMonitorUnitVo> selectMonitorPercentage() {
// HwMonitorUnit queryMonitorUnit = new HwMonitorUnit();
// List<HwMonitorUnit> list = hwMonitorUnitMapper.selectHwMonitorUnitListJoinScene(queryMonitorUnit);
// Map<Long, List<HwMonitorUnit>> monitorUnitMap = list.stream()
// .collect(Collectors.groupingBy(HwMonitorUnit::getSceneId));
// List<HwMonitorUnitVo> monitorUnitVoList = new ArrayList<>();
//
//
// Set<Long> keys = monitorUnitMap.keySet();
// for(Long key:keys){
// Integer value = monitorUnitMap.get(key);
// System.out.println(key+"\t"+value);
// }
List<HwMonitorUnitVo> list = hwMonitorUnitMapper.selectMonitorPercentage();
List<HwMonitorUnitVo> hwScenes = hwMonitorUnitMapper.selectSceneNameById();
int count = hwScenes.size();
if (list.size()<=hwScenes.size()) {
count = list.size();
}
for (int i = 0; i < count; i++) {
for (int j = 0;j<count;j++){
if (list.get(i).getSceneId().equals(hwScenes.get(i).getSceneId())){
list.get(i).setSceneName(hwScenes.get(i).getSceneName());
list.stream().forEach(l -> {
for (int i = 0; i < hwScenes.size(); i++) {
if (l.getSceneId().equals(hwScenes.get(i).getSceneId())) {
l.setSceneName(hwScenes.get(i).getSceneName());
}
}
}
});
Integer value = 0;
//
Integer sums = 0;
if (list.size()>5){
for (int i = 4; i < list.size(); i++){
if (list.get(i).sum==null){
list.get(i).sum = 0;
}
value = value+list.get(i).sum;
}
}
for (int i = 0; i < list.size();i++){
if (list.get(i).sum==null){
// if (list.size() > 5) {
// for (int i = 4; i < list.size(); i++) {//这是剩下的总数
// if (list.get(i).sum == null) {
// list.get(i).sum = 0;
// }
// value = value + list.get(i).sum;
// }
// }
for (int i = 0; i < list.size(); i++) {
if (list.get(i).sum == null) {
list.get(i).sum = 0;
}
sums = sums+list.get(i).sum;
sums = sums + list.get(i).sum;
}
for (int i=0;i<list.size();i++){
list.get(i).setPercentage((double) (list.get(i).getSum()/sums));
for (int i = 0; i < list.size(); i++) {
HwMonitorUnitVo hwMonitorUnitVo = list.get(i);
hwMonitorUnitVo.setPercentage(NumberUtils.getPercentage(list.get(i).getSum(), sums));
Long sceneId = hwMonitorUnitVo.getSceneId();
HwAlarmInfo queryAlarmInfo = new HwAlarmInfo();
queryAlarmInfo.setSceneId(sceneId);
List<HwAlarmInfo> alarmInfos = hwAlarmInfoMapper.selectHwAlarmInfoList(queryAlarmInfo);
Integer alarmInfoSize = alarmInfos == null ? 0 : alarmInfos.size();
hwMonitorUnitVo.setErr(alarmInfoSize);
}
HwMonitorUnitVo hwMonitorUnitVo = new HwMonitorUnitVo();
hwMonitorUnitVo.setSceneName("其他");
hwMonitorUnitVo.setSum(value);
if (list.size()>5){
list.add(5,hwMonitorUnitVo);
return list.subList(0,5);
}
else {
return list;
}
// HwMonitorUnitVo hwMonitorUnitVo = new HwMonitorUnitVo();
// hwMonitorUnitVo.setSceneName("其他");
// hwMonitorUnitVo.setSum(value);
// if (list.size() > 5) {
// list.add(5, hwMonitorUnitVo);
// return list.subList(0, 5);
// } else {
// return list;
// }
return list;
}
//获取总的设备数量与监控单元数量
@Override
public AllNumsVo selectAllNums() {
public AllNumsVo selectAllNums(Long sceneId) {
//监控单元
String monitor = hwMonitorUnitMapper.selectSubSetNums();
String integer = hwMonitorUnitMapper.selectDeviceNums();
System.out.println(monitor+" dsaas "+integer);
Integer monitor1 = 0;
Integer monitor2 = 0;
Integer monitor = hwMonitorUnitMapper.selectSubSetNums(sceneId) == null ? 0
: hwMonitorUnitMapper.selectSubSetNums(sceneId);
Integer integer = hwMonitorUnitMapper.selectDeviceNums(sceneId) == null ? 0
: hwMonitorUnitMapper.selectDeviceNums(sceneId);
AllNumsVo vo = new AllNumsVo();
if (monitor == null){
monitor1 = 0;
}
else {
monitor1 = Integer.valueOf(monitor);
}
if (integer == null){
monitor2 = 0;
}
else {
monitor2 = Integer.valueOf(integer);
}
vo.setSubSum(monitor1);
vo.setSum(monitor2);
vo.setSubSum(monitor);
vo.setSum(integer);
return vo;
}
@Override
public List<AllNumsVo> selectSenceAllNums() {
List<AllNumsVo> allNumsVos = hwMonitorUnitMapper.selectAllNums();
List<AllNumsVo> allNums = hwMonitorUnitMapper.selectsum();
for (int i=0;i< allNums.size();i++){
for (int j=0;j< allNums.size();j++){
if (allNums.get(i).getSceneId().equals(allNumsVos.get(i).getSceneId())){
allNums.get(i).setSubSum(allNumsVos.get(i).getSubSum());
}
}
}
return allNums;
}
// @Override
// public List<AllNumsVo> selectSenceAllNums() {
// List<AllNumsVo> allNumsVos = hwMonitorUnitMapper.selectAllNums();
// List<AllNumsVo> allNums = hwMonitorUnitMapper.selectsum();
// for (int i = 0; i < allNums.size(); i++) {
// for (int j = 0; j < allNums.size(); j++) {
// if (allNums.get(i).getSceneId().equals(allNumsVos.get(i).getSceneId())) {
// allNums.get(i).setSubSum(allNumsVos.get(i).getSubSum());
// }
// }
// }
// return allNums;
// }
@Override
public List<HwMonitorUnit> selectLimitSubMonitorUnit() {
@ -161,8 +164,8 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
}
@Override
public List<AlarmStatsVo> selectAlarmStats() {
return hwMonitorUnitMapper.selectAlarmStats();
public List<AlarmStatsVo> selectAlarmStats(Long sceneId) {
return hwMonitorUnitMapper.selectAlarmStats(sceneId);
}
@ -173,155 +176,72 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
* @return
*/
@Override
public List<HwMonitorUnit> selectHwMonitorUnitList(HwMonitorUnit hwMonitorUnit)
{
public List<HwMonitorUnit> selectHwMonitorUnitList(HwMonitorUnit hwMonitorUnit) {
return hwMonitorUnitMapper.selectHwMonitorUnitList(hwMonitorUnit);
}
@Override
public SubDeviceSumVo selectSubDeviceSum(Long sceneId) {
int SubSum = hwMonitorUnitMapper.selectSubDeviceSum(sceneId);
List<HwDevice> hwDevices = hwDeviceMapper.selectDeviceNum(sceneId);
int onlineDevice = 0;
for (int i = 0;i<hwDevices.size();i++){
if (hwDevices.get(i).getActiveStatus().equals("1")&&hwDevices.get(i).getDeviceStatus().equals("1")){
onlineDevice = onlineDevice+1;
}
}
AllNumsVo numsVo = selectAllNums(sceneId);
int onlineDeviceNum = hwDeviceMapper.getOnlineDeviceNum(sceneId);
SubDeviceSumVo subDeviceSumVo = new SubDeviceSumVo();
subDeviceSumVo.setSubSum(String.valueOf(SubSum));
subDeviceSumVo.setDeviceNum(String.valueOf(hwDevices.size()));
subDeviceSumVo.setOnlineDeviceNum(String.valueOf(onlineDevice));
subDeviceSumVo.setSubSum(numsVo.getSubSum());//监控单元数量
subDeviceSumVo.setDeviceNum(numsVo.getSum());//设备数量
subDeviceSumVo.setOnlineDeviceNum(onlineDeviceNum);//在线设备数量
return subDeviceSumVo;
}
//todo 电子围栏
@Override
public Integer selectElectronicNum(Long sceneId) {
List<Long> longs = hwMonitorUnitMapper.selectEleInScene(sceneId);
return null;
}
@Override
public HwMonitorUnit selectHwmonitorUnitSub(Long monitorUnitId) {
return hwMonitorUnitMapper.selectHwMonitorUnitByMonitorUnitId(monitorUnitId);
return hwMonitorUnitMapper.selectHwMonitorUnitByMonitorUnitId(monitorUnitId);
}
//todo SysDeptServiceImpl类中的递归方法recursionFn(以实现)
@Override
// 加一个begintime参数endtime参数 stream时间戳 从开始时间0点开始结束时间23.59.59结束
public Map<Object, Integer> selectTdengine(String beginTime, String endTime, Long sceneId) {
DeviceStatus queryDeviceStatus = new DeviceStatus();
Map<String, Object> params = queryDeviceStatus.getParams();
DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA);
System.out.println(ofPattern);
LocalDate parse = LocalDate.parse(beginTime, ofPattern);
long begintime = parse.atStartOfDay().toInstant(ZoneOffset.of("+8")).toEpochMilli();
DateTimeFormatter ofPattern1 = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA);
LocalDate parse1 = LocalDate.parse(endTime, ofPattern);
long endtime = LocalDateTime.of(parse1, LocalTime.MAX).toInstant(ZoneOffset.of("+8")).toEpochMilli();
params.put("beginTime",begintime);
params.put("endTime", endtime);
queryDeviceStatus.setParams(params);
if (sceneId != null) {
queryDeviceStatus.setSceneId(sceneId);
public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> returnList = new ArrayList<>();
List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList());
List<HwMonitorUnit> treeList = new ArrayList<>();
for (HwMonitorUnit hwMonitorUnit : hwMonitorUnits) {
if (!tempList.contains(hwMonitorUnit.getParentId()))
recursionFn(hwMonitorUnits, hwMonitorUnit);
returnList.add(hwMonitorUnit);
}
int sum = 0;
int values[] = new int[10];
Map<Object,Integer> valuesMap = new HashMap<>();
//todo 使用id(以解决)
//map key时间戳value List<DeviceStatus> 对象
R<?> r = remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
Map<Long, List<DeviceStatus>> deviceStatusMap = (Map<Long, List<DeviceStatus>>) r.getData();
List<DeviceStatus> list = (List<DeviceStatus>) remoteTdEgineService.getOnlineDevicesGroupByDay(queryDeviceStatus);
Set<Long> longs = deviceStatusMap.keySet();
for (Object key:longs){
List<DeviceStatus> deviceStatuses = deviceStatusMap.get(key);
for (int i=0;i<deviceStatuses.size();i++){
if (deviceStatuses.get(i).getDeviceType()==1){
sum=sum+hwMonitorUnitMapper.selectReleatedDeviceIdNums(list.get(i).getDeviceId());
}
else {
sum = sum+1;
}
valuesMap.put(key,sum);
for (int i = 0; i < returnList.size(); i++) {
if (returnList.get(i).getParentId() == null) {
treeList.add(returnList.get(i));
}
}
return valuesMap;
//设备类型==网关 根据releated_device_id = 网关设备设备id查询个数
//网关子设备数+非网关设备数getDeviceType()=1
return treeList;
}
@Override
public R<Map<String, Map<String, Object>>> selectLatestDataByTags(Long monitorUnitId) {
//
R<Map<String, Map<String, Object>>> latestDataByTags = new R<Map<String,Map<String, Object>>>();
List<HwDevice> hwDevices = hwDeviceMapper.selectDeviceByMonitorId(monitorUnitId);
TdSelectDto tdSelectDto = new TdSelectDto();
for (int i = 0; i < hwDevices.size(); i++){
tdSelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
tdSelectDto.setTableName(TdEngineConstants.getDeviceDataTableName(hwDevices.get(i).getDeviceId()));
tdSelectDto.setTagsName(hwDevices.get(i).getDeviceCode());
latestDataByTags = remoteTdEgineService.getLatestDataByTags(tdSelectDto);
}
return latestDataByTags;
}
//todo SysDeptServiceImpl类中的递归方法recursionFn(以实现)
@Override
public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> returnList = new ArrayList<>();
List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList());
List<HwMonitorUnit> treeList = new ArrayList<>();
for (HwMonitorUnit hwMonitorUnit:hwMonitorUnits){
if (!tempList.contains(hwMonitorUnit.getParentId()))
recursionFn(hwMonitorUnits,hwMonitorUnit);
returnList.add(hwMonitorUnit);
}
for (int i = 0; i < returnList.size(); i++){
if (returnList.get(i).getParentId()==null){
treeList.add(returnList.get(i));
}
}
return treeList;
}
private void recursionFn(List<HwMonitorUnit> list, HwMonitorUnit t)
{
private void recursionFn(List<HwMonitorUnit> list, HwMonitorUnit t) {
// 得到子节点列表
List<HwMonitorUnit> childList = getChildList(list, t);
t.setChild(childList);
for (HwMonitorUnit tChild : childList)
{
if (hasChild(list, tChild))
{
for (HwMonitorUnit tChild : childList) {
if (hasChild(list, tChild)) {
recursionFn(list, tChild);
}
}
}
private List<HwMonitorUnit> getChildList(List<HwMonitorUnit> list, HwMonitorUnit t)
{
private List<HwMonitorUnit> getChildList(List<HwMonitorUnit> list, HwMonitorUnit t) {
List<HwMonitorUnit> tlist = new ArrayList<HwMonitorUnit>();
Iterator<HwMonitorUnit> it = list.iterator();
while (it.hasNext())
{
while (it.hasNext()) {
HwMonitorUnit n = (HwMonitorUnit) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getMonitorUnitId().longValue())
{
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getMonitorUnitId().longValue()) {
tlist.add(n);
}
}
return tlist;
}
private boolean hasChild(List<HwMonitorUnit> list, HwMonitorUnit t)
{
private boolean hasChild(List<HwMonitorUnit> list, HwMonitorUnit t) {
return getChildList(list, t).size() > 0 ? true : false;
}
@ -332,8 +252,7 @@ public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
* @return
*/
@Override
public int insertHwMonitorUnit(HwMonitorUnit hwMonitorUnit)
{
public int insertHwMonitorUnit(HwMonitorUnit hwMonitorUnit) {
hwMonitorUnit.setCreateTime(DateUtils.getNowDate());
return hwMonitorUnitMapper.insertHwMonitorUnit(hwMonitorUnit);
}
@ -345,8 +264,7 @@ public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
* @return
*/
@Override
public int updateHwMonitorUnit(HwMonitorUnit hwMonitorUnit)
{
public int updateHwMonitorUnit(HwMonitorUnit hwMonitorUnit) {
hwMonitorUnit.setUpdateTime(DateUtils.getNowDate());
return hwMonitorUnitMapper.updateHwMonitorUnit(hwMonitorUnit);
}
@ -358,8 +276,7 @@ public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
* @return
*/
@Override
public int deleteHwMonitorUnitByMonitorUnitIds(Long[] monitorUnitIds)
{
public int deleteHwMonitorUnitByMonitorUnitIds(Long[] monitorUnitIds) {
return hwMonitorUnitMapper.deleteHwMonitorUnitByMonitorUnitIds(monitorUnitIds);
}
@ -370,28 +287,91 @@ public List<HwMonitorUnit> selectTreeList(List<HwMonitorUnit> hwMonitorUnits) {
* @return
*/
@Override
public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId)
{
public int deleteHwMonitorUnitByMonitorUnitId(Long monitorUnitId) {
return hwMonitorUnitMapper.deleteHwMonitorUnitByMonitorUnitId(monitorUnitId);
}
}
//remoteTdEngineSevice.getOnlineDevicesGroupByDay方法获取
// 参数实例:
// // params.put("beginTime", beginTime);
//// params.put("endTime", endTime);
//// queryDeviceStatus.setParams(params);
//// if (sceneId != null) {
//// queryDeviceStatus.setSceneId(sceneId);
//// }
//
// 这是IDEA参数传的参数Content-Type: application/json
// {
// "params": { "beginTime":1666666666666,"endTime":1766666666666 }
//
// }
//
// 如果在IDEA测试可以{
// "params": {"databaseName":"db_scene_1","superTableName":"st_ds_1",
// "beginTime":1666666666666,"endTime":1766666666666 }
// }
/**
*
*
* @param hwMonitorUnit
* @return
*/
@Override
public List<TreeSelectVo> selectMonitorTreeList(HwMonitorUnit hwMonitorUnit) {
List<HwMonitorUnit> hwMonitorUnits = this.selectHwMonitorUnitList(hwMonitorUnit);
return buildMonitorUnitTreeSelect(hwMonitorUnits);
}
/**
*
*
* @param hwMonitorUnits
* @return
*/
@Override
public List<TreeSelectVo> buildMonitorUnitTreeSelect(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> monitorUnitTrees = buildMonitorUnitTree(hwMonitorUnits);
return monitorUnitTrees.stream().map(TreeSelectVo::new).collect(Collectors.toList());
}
/**
*
*
* @param hwMonitorUnits
* @return
*/
@Override
public List<HwMonitorUnit> buildMonitorUnitTree(List<HwMonitorUnit> hwMonitorUnits) {
List<HwMonitorUnit> returnList = new ArrayList<HwMonitorUnit>();
List<Long> tempList = hwMonitorUnits.stream().map(HwMonitorUnit::getMonitorUnitId).collect(Collectors.toList());
for (HwMonitorUnit monitorUnit : hwMonitorUnits) {
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(monitorUnit.getParentId())) {
recursionFn1(hwMonitorUnits, monitorUnit);
returnList.add(monitorUnit);
}
}
if (returnList.isEmpty()) {
returnList = hwMonitorUnits;
}
return returnList;
}
/**
*
*/
private void recursionFn1(List<HwMonitorUnit> list, HwMonitorUnit t) {
// 得到子节点列表
List<HwMonitorUnit> childList = getChildList1(list, t);
t.setChildren(childList);
for (HwMonitorUnit tChild : childList) {
if (hasChild1(list, tChild)) {
recursionFn1(list, tChild);
}
}
}
/**
*
*/
private List<HwMonitorUnit> getChildList1(List<HwMonitorUnit> list, HwMonitorUnit t) {
List<HwMonitorUnit> tlist = new ArrayList<HwMonitorUnit>();
Iterator<HwMonitorUnit> it = list.iterator();
while (it.hasNext()) {
HwMonitorUnit n = (HwMonitorUnit) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getMonitorUnitId().longValue()) {
tlist.add(n);
}
}
return tlist;
}
/**
*
*/
private boolean hasChild1(List<HwMonitorUnit> list, HwMonitorUnit t) {
return getChildList1(list, t).size() > 0 ? true : false;
}
}

@ -0,0 +1,168 @@
<?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.business.mapper.HwAlarmInfoMapper">
<resultMap type="HwAlarmInfo" id="HwAlarmInfoResult">
<result property="alarmInfoId" column="alarm_info_id" />
<result property="alarmInfoType" column="alarm_info_type" />
<result property="alarmReleatedId" column="alarm_releated_id" />
<result property="deviceId" column="device_id" />
<result property="monitorUnitId" column="monitor_unit_id" />
<result property="tenantId" column="tenant_id" />
<result property="sceneId" column="scene_id" />
<result property="alarmLevelId" column="alarm_level_id" />
<result property="alarmTypeId" column="alarm_type_id" />
<result property="modeFunctionId" column="mode_function_id" />
<result property="functionName" column="function_name" />
<result property="functionIdentifier" column="function_identifier" />
<result property="functionValue" column="function_value" />
<result property="triggerStatus" column="trigger_status" />
<result property="handleStatus" column="handle_status" />
<result property="alarmTime" column="alarm_time" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="alarmInfoField" column="alarm_info_field" />
<result property="monitorUnitName" column="monitor_unit_name" />
<result property="alarmLevelName" column="alarm_level_name" />
<result property="alarmTypeName" column="alarm_type_name" />
</resultMap>
<resultMap type="AlarmTypeVo" id="AlarmTypeVoResult">
<result property="alarmCount" column="alarm_count" />
<result property="alarmTypeId" column="alarm_type_id" />
<result property="alarmTypeName" column="alarm_type_name" />
</resultMap>
<sql id="selectHwAlarmInfoVo">
select hai.alarm_info_id, hai.alarm_info_type, hai.alarm_releated_id, hai.device_id,
hai.monitor_unit_id, hai.tenant_id, hai.scene_id, hai.alarm_level_id,
hai.alarm_type_id, hai.mode_function_id, hai.function_name, hai.function_identifier,
hai.function_value, hai.trigger_status, hai.handle_status, hai.alarm_time,
hai.create_time, hai.update_by, hai.update_time, hai.alarm_info_field,
hmu.monitor_unit_name,hal.alarm_level_name,hat.alarm_type_name
from hw_alarm_info hai left join hw_monitor_unit hmu on hai.monitor_unit_id = hmu.monitor_unit_id
left join hw_alarm_level hal on hai.alarm_level_id=hal.alarm_level_id
left join hw_alarm_type hat on hai.alarm_type_id=hat.alarm_type_id
</sql>
<select id="selectHwAlarmInfoList" parameterType="HwAlarmInfo" resultMap="HwAlarmInfoResult">
<include refid="selectHwAlarmInfoVo"/>
<where>
<if test="alarmInfoType != null and alarmInfoType != ''"> and alarm_info_type = #{alarmInfoType}</if>
<if test="alarmReleatedId != null "> and alarm_releated_id = #{alarmReleatedId}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="monitorUnitId != null "> and monitor_unit_id = #{monitorUnitId}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and hai.scene_id = #{sceneId}</if>
<if test="alarmLevelId != null "> and alarm_level_id = #{alarmLevelId}</if>
<if test="alarmTypeId != null "> and alarm_type_id = #{alarmTypeId}</if>
<if test="modeFunctionId != null "> and mode_function_id = #{modeFunctionId}</if>
<if test="functionName != null and functionName != ''"> and function_name like concat('%', #{functionName}, '%')</if>
<if test="functionIdentifier != null and functionIdentifier != ''"> and function_identifier = #{functionIdentifier}</if>
<if test="functionValue != null and functionValue != ''"> and function_value = #{functionValue}</if>
<if test="triggerStatus != null and triggerStatus != ''"> and trigger_status = #{triggerStatus}</if>
<if test="handleStatus != null and handleStatus != ''"> and handle_status = #{handleStatus}</if>
<if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>
<if test="alarmInfoField != null and alarmInfoField != ''"> and alarm_info_field = #{alarmInfoField}</if>
</where>
</select>
<select id="selectHwAlarmInfoByAlarmInfoId" parameterType="Long" resultMap="HwAlarmInfoResult">
<include refid="selectHwAlarmInfoVo"/>
where alarm_info_id = #{alarmInfoId}
</select>
<insert id="insertHwAlarmInfo" parameterType="HwAlarmInfo" useGeneratedKeys="true" keyProperty="alarmInfoId">
insert into hw_alarm_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alarmInfoType != null and alarmInfoType != ''">alarm_info_type,</if>
<if test="alarmReleatedId != null">alarm_releated_id,</if>
<if test="deviceId != null">device_id,</if>
<if test="monitorUnitId != null">monitor_unit_id,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneId != null">scene_id,</if>
<if test="alarmLevelId != null">alarm_level_id,</if>
<if test="alarmTypeId != null">alarm_type_id,</if>
<if test="modeFunctionId != null">mode_function_id,</if>
<if test="functionName != null">function_name,</if>
<if test="functionIdentifier != null">function_identifier,</if>
<if test="functionValue != null">function_value,</if>
<if test="triggerStatus != null">trigger_status,</if>
<if test="handleStatus != null and handleStatus != ''">handle_status,</if>
<if test="alarmTime != null">alarm_time,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="alarmInfoField != null">alarm_info_field,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alarmInfoType != null and alarmInfoType != ''">#{alarmInfoType},</if>
<if test="alarmReleatedId != null">#{alarmReleatedId},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="monitorUnitId != null">#{monitorUnitId},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="alarmLevelId != null">#{alarmLevelId},</if>
<if test="alarmTypeId != null">#{alarmTypeId},</if>
<if test="modeFunctionId != null">#{modeFunctionId},</if>
<if test="functionName != null">#{functionName},</if>
<if test="functionIdentifier != null">#{functionIdentifier},</if>
<if test="functionValue != null">#{functionValue},</if>
<if test="triggerStatus != null">#{triggerStatus},</if>
<if test="handleStatus != null and handleStatus != ''">#{handleStatus},</if>
<if test="alarmTime != null">#{alarmTime},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="alarmInfoField != null">#{alarmInfoField},</if>
</trim>
</insert>
<update id="updateHwAlarmInfo" parameterType="HwAlarmInfo">
update hw_alarm_info
<trim prefix="SET" suffixOverrides=",">
<if test="alarmInfoType != null and alarmInfoType != ''">alarm_info_type = #{alarmInfoType},</if>
<if test="alarmReleatedId != null">alarm_releated_id = #{alarmReleatedId},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="monitorUnitId != null">monitor_unit_id = #{monitorUnitId},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="alarmLevelId != null">alarm_level_id = #{alarmLevelId},</if>
<if test="alarmTypeId != null">alarm_type_id = #{alarmTypeId},</if>
<if test="modeFunctionId != null">mode_function_id = #{modeFunctionId},</if>
<if test="functionName != null">function_name = #{functionName},</if>
<if test="functionIdentifier != null">function_identifier = #{functionIdentifier},</if>
<if test="functionValue != null">function_value = #{functionValue},</if>
<if test="triggerStatus != null">trigger_status = #{triggerStatus},</if>
<if test="handleStatus != null and handleStatus != ''">handle_status = #{handleStatus},</if>
<if test="alarmTime != null">alarm_time = #{alarmTime},</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>
<if test="alarmInfoField != null">alarm_info_field = #{alarmInfoField},</if>
</trim>
where alarm_info_id = #{alarmInfoId}
</update>
<delete id="deleteHwAlarmInfoByAlarmInfoId" parameterType="Long">
delete from hw_alarm_info where alarm_info_id = #{alarmInfoId}
</delete>
<delete id="deleteHwAlarmInfoByAlarmInfoIds" parameterType="String">
delete from hw_alarm_info where alarm_info_id in
<foreach item="alarmInfoId" collection="array" open="(" separator="," close=")">
#{alarmInfoId}
</foreach>
</delete>
<select id="selectAlarmsByAlarmType" parameterType="Long" resultMap="AlarmTypeVoResult">
SELECT count(*) as alarm_count,alarm_type_id from hw_alarm_info
where scene_id = #{sceneId} group by alarm_type_id;
</select>
</mapper>

@ -0,0 +1,116 @@
<?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.business.mapper.HwAlarmLevelMapper">
<resultMap type="HwAlarmLevel" id="HwAlarmLevelResult">
<result property="alarmLevelId" column="alarm_level_id" />
<result property="alarmLevelName" column="alarm_level_name" />
<result property="tenantId" column="tenant_id" />
<result property="sceneId" column="scene_id" />
<result property="languageCode" column="language_code" />
<result property="commonFlag" column="common_flag" />
<result property="levelNumber" column="level_number" />
<result property="levelStatus" column="level_status" />
<result property="defaultNotifyMode" column="default_notify_mode" />
<result property="remark" column="remark" />
<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="alarmLevelField" column="alarm_level_field" />
</resultMap>
<sql id="selectHwAlarmLevelVo">
select alarm_level_id, alarm_level_name, tenant_id, scene_id, language_code, common_flag, level_number, level_status, default_notify_mode, remark, create_by, create_time, update_by, update_time, alarm_level_field from hw_alarm_level
</sql>
<select id="selectHwAlarmLevelList" parameterType="HwAlarmLevel" resultMap="HwAlarmLevelResult">
<include refid="selectHwAlarmLevelVo"/>
<where>
<if test="alarmLevelName != null and alarmLevelName != ''"> and alarm_level_name like concat('%', #{alarmLevelName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="languageCode != null and languageCode != ''"> and language_code = #{languageCode}</if>
<if test="commonFlag != null and commonFlag != ''"> and common_flag = #{commonFlag}</if>
<if test="levelNumber != null "> and level_number = #{levelNumber}</if>
<if test="levelStatus != null and levelStatus != ''"> and level_status = #{levelStatus}</if>
<if test="defaultNotifyMode != null and defaultNotifyMode != ''"> and default_notify_mode = #{defaultNotifyMode}</if>
<if test="alarmLevelField != null and alarmLevelField != ''"> and alarm_level_field = #{alarmLevelField}</if>
</where>
</select>
<select id="selectHwAlarmLevelByAlarmLevelId" parameterType="Long" resultMap="HwAlarmLevelResult">
<include refid="selectHwAlarmLevelVo"/>
where alarm_level_id = #{alarmLevelId}
</select>
<insert id="insertHwAlarmLevel" parameterType="HwAlarmLevel" useGeneratedKeys="true" keyProperty="alarmLevelId">
insert into hw_alarm_level
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alarmLevelName != null and alarmLevelName != ''">alarm_level_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneId != null">scene_id,</if>
<if test="languageCode != null">language_code,</if>
<if test="commonFlag != null and commonFlag != ''">common_flag,</if>
<if test="levelNumber != null">level_number,</if>
<if test="levelStatus != null and levelStatus != ''">level_status,</if>
<if test="defaultNotifyMode != null">default_notify_mode,</if>
<if test="remark != null">remark,</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>
<if test="alarmLevelField != null">alarm_level_field,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alarmLevelName != null and alarmLevelName != ''">#{alarmLevelName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="languageCode != null">#{languageCode},</if>
<if test="commonFlag != null and commonFlag != ''">#{commonFlag},</if>
<if test="levelNumber != null">#{levelNumber},</if>
<if test="levelStatus != null and levelStatus != ''">#{levelStatus},</if>
<if test="defaultNotifyMode != null">#{defaultNotifyMode},</if>
<if test="remark != null">#{remark},</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>
<if test="alarmLevelField != null">#{alarmLevelField},</if>
</trim>
</insert>
<update id="updateHwAlarmLevel" parameterType="HwAlarmLevel">
update hw_alarm_level
<trim prefix="SET" suffixOverrides=",">
<if test="alarmLevelName != null and alarmLevelName != ''">alarm_level_name = #{alarmLevelName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="languageCode != null">language_code = #{languageCode},</if>
<if test="commonFlag != null and commonFlag != ''">common_flag = #{commonFlag},</if>
<if test="levelNumber != null">level_number = #{levelNumber},</if>
<if test="levelStatus != null and levelStatus != ''">level_status = #{levelStatus},</if>
<if test="defaultNotifyMode != null">default_notify_mode = #{defaultNotifyMode},</if>
<if test="remark != null">remark = #{remark},</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>
<if test="alarmLevelField != null">alarm_level_field = #{alarmLevelField},</if>
</trim>
where alarm_level_id = #{alarmLevelId}
</update>
<delete id="deleteHwAlarmLevelByAlarmLevelId" parameterType="Long">
delete from hw_alarm_level where alarm_level_id = #{alarmLevelId}
</delete>
<delete id="deleteHwAlarmLevelByAlarmLevelIds" parameterType="String">
delete from hw_alarm_level where alarm_level_id in
<foreach item="alarmLevelId" collection="array" open="(" separator="," close=")">
#{alarmLevelId}
</foreach>
</delete>
</mapper>

@ -0,0 +1,111 @@
<?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.business.mapper.HwAlarmTypeMapper">
<resultMap type="HwAlarmType" id="HwAlarmTypeResult">
<result property="alarmTypeId" column="alarm_type_id" />
<result property="alarmTypeName" column="alarm_type_name" />
<result property="tenantId" column="tenant_id" />
<result property="sceneId" column="scene_id" />
<result property="languageCode" column="language_code" />
<result property="commonFlag" column="common_flag" />
<result property="handleMode" column="handle_mode" />
<result property="typeStatus" column="type_status" />
<result property="remark" column="remark" />
<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="alarmTypeField" column="alarm_type_field" />
</resultMap>
<sql id="selectHwAlarmTypeVo">
select alarm_type_id, alarm_type_name, tenant_id, scene_id, language_code, common_flag, handle_mode, type_status, remark, create_by, create_time, update_by, update_time, alarm_type_field from hw_alarm_type
</sql>
<select id="selectHwAlarmTypeList" parameterType="HwAlarmType" resultMap="HwAlarmTypeResult">
<include refid="selectHwAlarmTypeVo"/>
<where>
<if test="alarmTypeName != null and alarmTypeName != ''"> and alarm_type_name like concat('%', #{alarmTypeName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="languageCode != null and languageCode != ''"> and language_code = #{languageCode}</if>
<if test="commonFlag != null and commonFlag != ''"> and common_flag = #{commonFlag}</if>
<if test="handleMode != null and handleMode != ''"> and handle_mode = #{handleMode}</if>
<if test="typeStatus != null and typeStatus != ''"> and type_status = #{typeStatus}</if>
<if test="alarmTypeField != null and alarmTypeField != ''"> and alarm_type_field = #{alarmTypeField}</if>
</where>
</select>
<select id="selectHwAlarmTypeByAlarmTypeId" parameterType="Long" resultMap="HwAlarmTypeResult">
<include refid="selectHwAlarmTypeVo"/>
where alarm_type_id = #{alarmTypeId}
</select>
<insert id="insertHwAlarmType" parameterType="HwAlarmType" useGeneratedKeys="true" keyProperty="alarmTypeId">
insert into hw_alarm_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alarmTypeName != null and alarmTypeName != ''">alarm_type_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="sceneId != null">scene_id,</if>
<if test="languageCode != null">language_code,</if>
<if test="commonFlag != null and commonFlag != ''">common_flag,</if>
<if test="handleMode != null and handleMode != ''">handle_mode,</if>
<if test="typeStatus != null and typeStatus != ''">type_status,</if>
<if test="remark != null">remark,</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>
<if test="alarmTypeField != null">alarm_type_field,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alarmTypeName != null and alarmTypeName != ''">#{alarmTypeName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="sceneId != null">#{sceneId},</if>
<if test="languageCode != null">#{languageCode},</if>
<if test="commonFlag != null and commonFlag != ''">#{commonFlag},</if>
<if test="handleMode != null and handleMode != ''">#{handleMode},</if>
<if test="typeStatus != null and typeStatus != ''">#{typeStatus},</if>
<if test="remark != null">#{remark},</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>
<if test="alarmTypeField != null">#{alarmTypeField},</if>
</trim>
</insert>
<update id="updateHwAlarmType" parameterType="HwAlarmType">
update hw_alarm_type
<trim prefix="SET" suffixOverrides=",">
<if test="alarmTypeName != null and alarmTypeName != ''">alarm_type_name = #{alarmTypeName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="languageCode != null">language_code = #{languageCode},</if>
<if test="commonFlag != null and commonFlag != ''">common_flag = #{commonFlag},</if>
<if test="handleMode != null and handleMode != ''">handle_mode = #{handleMode},</if>
<if test="typeStatus != null and typeStatus != ''">type_status = #{typeStatus},</if>
<if test="remark != null">remark = #{remark},</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>
<if test="alarmTypeField != null">alarm_type_field = #{alarmTypeField},</if>
</trim>
where alarm_type_id = #{alarmTypeId}
</update>
<delete id="deleteHwAlarmTypeByAlarmTypeId" parameterType="Long">
delete from hw_alarm_type where alarm_type_id = #{alarmTypeId}
</delete>
<delete id="deleteHwAlarmTypeByAlarmTypeIds" parameterType="String">
delete from hw_alarm_type where alarm_type_id in
<foreach item="alarmTypeId" collection="array" open="(" separator="," close=")">
#{alarmTypeId}
</foreach>
</delete>
</mapper>

@ -34,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deviceField" column="device_field" />
<result property="tenantId" column="tenant_id" />
<result property="onlineStatus" column="online_status" />
<result property="monitorUnitName" column="monitor_unit_name" />
</resultMap>
<!--以下为监控平台接口所用-->
@ -219,4 +220,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{deviceId}
</foreach>
</delete>
<select id="getOnlineDeviceNum" parameterType="Long">
select count(*) as count from hw_device where
scene_id = #{sceneId} and device_status=1 and online_status=1
</select>
<sql id="selectHwDeviceJoinVo">
select hd.device_code,hd.device_name, hd.device_status,hd.online_status, hd.device_pic,hd.active_time,
hmu.monitor_unit_name
from hw_device hd left join hw_monitor_unit hmu on hd.monitor_unit_id = hmu.monitor_unit_id </sql>
<select id="selectHwDeviceJoinByDeviceId" parameterType="Long" resultMap="HwDeviceResult">
<include refid="selectHwDeviceJoinVo"/>
where hd.device_id = #{deviceId}
</select>
<select id="selectLinkedDevices" parameterType="Long" resultMap="HwDeviceResult">
<include refid="selectHwDeviceJoinVo"/>
where exists (select 1 from hw_alarm_rule har where har.link_device_id=hd.device_id
and har.device_id = #{deviceId})
</select>
</mapper>

@ -32,6 +32,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="sum" column="sum"/>
</resultMap>
<resultMap id="HwElectronicFenceHwFenceTargetResult" type="HwElectronicFence" extends="HwElectronicFenceResult">
<collection property="hwFenceTargetList" notNullColumn="sub_target_id" javaType="java.util.List" resultMap="HwFenceTargetResult" />
</resultMap>
<resultMap type="HwFenceTarget" id="HwFenceTargetResult">
<result property="electronicFenceId" column="sub_electronic_fence_id" />
<result property="targetType" column="sub_target_type" />
<result property="targetId" column="sub_target_id" />
</resultMap>
<sql id="selectHwElectronicFenceVo">
select electronic_fence_id, electronic_fence_name, scene_id, fence_type, effective_time_flag, time_zone, effective_time, trigger_status, area_shape_flag, area_range, fence_push_flag, fence_push_content, fence_recover_content, remark, create_by, create_time, update_by, update_time, fence_field from hw_electronic_fence
</sql>
@ -130,9 +140,12 @@ GROUP BY
</where>
</select>
<select id="selectHwElectronicFenceByElectronicFenceId" parameterType="Long" resultMap="HwElectronicFenceResult">
<include refid="selectHwElectronicFenceVo"/>
where electronic_fence_id = #{electronicFenceId}
<select id="selectHwElectronicFenceByElectronicFenceId" parameterType="Long" resultMap="HwElectronicFenceHwFenceTargetResult">
select a.electronic_fence_id, a.electronic_fence_name, a.scene_id, a.fence_type, a.effective_time_flag, a.time_zone, a.effective_time, a.trigger_status, a.area_shape_flag, a.area_range, a.fence_push_flag, a.fence_push_content, a.fence_recover_content, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.fence_field,
b.electronic_fence_id as sub_electronic_fence_id, b.target_type as sub_target_type, b.target_id as sub_target_id
from hw_electronic_fence a
left join hw_fence_target b on b.electronic_fence_id = a.electronic_fence_id
where a.electronic_fence_id = #{electronicFenceId}
</select>
<insert id="insertHwElectronicFence" parameterType="HwElectronicFence" useGeneratedKeys="true" keyProperty="electronicFenceId">
@ -214,4 +227,25 @@ GROUP BY
#{electronicFenceId}
</foreach>
</delete>
<select id="selectDeviceCount" parameterType="Long">
select count(*) as count
from hw_fence_target a where a.electronic_fence_id = #{electronicFenceId}
</select>
<select id="selectDeviceCountByMonitorUnit" parameterType="Long">
select count(*) as count
from hw_device hd where hd.device_status=1 and exists (select 1 from hw_fence_target a
where hd.monitor_unit_id = a.target_id
and a.electronic_fence_id = #{electronicFenceId})
</select>
<select id="selectDeviceCountByScene" parameterType="Long">
select count(*) as count
from hw_device hd where hd.device_status=1 and hd.scene_id = #{sceneId}
</select>
</mapper>

@ -1,7 +1,7 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwMonitorUnitMapper">
<resultMap type="HwMonitorUnit" id="HwMonitorUnitResult">
<result property="monitorUnitId" column="monitor_unit_id" />
@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="monitorUnitField" column="monitor_unit_field" />
<result property="sceneName" column="scene_name" />
</resultMap>
<resultMap type="HwMonitorUnitVo" id="HwMonitorUnitVoResult" >
<result property="sceneName" column="scene_name"/>
@ -59,18 +60,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectHwMonitorUnitVo">
select monitor_unit_id, monitor_unit_name, scene_id, parent_id, monitor_unit_type_id, area_id, monitor_address, monitor_pic, preserve_time, remark, monitor_unit_status, create_by, create_time, update_by, update_time, monitor_unit_field from hw_monitor_unit
</sql>
<sql id="selectHwMonitorUnitJoinScene">
select hmu.monitor_unit_id, hmu.monitor_unit_name, hmu.scene_id, hmu.parent_id,
hmu.monitor_unit_type_id, hmu.area_id, hmu.monitor_address, hmu.monitor_pic,
hmu.preserve_time, hmu.monitor_unit_status, hc.scene_name
from hw_monitor_unit hmu left join hw_scene hc on hmu.scene_id = hc.scene_id
</sql>
<select id="selectHaveEleDevice" parameterType="Long" resultMap="MonitorUnitNumVoResult">
SELECT monitor_unit_id,count(*) as num from hw_device where monitor_unit_id
= (select monitor_unit_id from hw_monitor_unit where monitor_unit_id =
(select target_id from hw_fence_target where target_type = '2'and
electronic_fence_id = (select electronic_fence_id from hw_electronic_fence
where scene_id = #{sceneId}) )) GROUP BY monitor_unit_id
= (select monitor_unit_id from hw_monitor_unit where monitor_unit_id =
(select target_id from hw_fence_target where target_type = '2'and
electronic_fence_id = (select electronic_fence_id from hw_electronic_fence
where scene_id = #{sceneId}) )) GROUP BY monitor_unit_id
</select>
<select id="selectMonitorUnitHaveEle" parameterType="Long" resultMap="MonitorUnitNumVoResult">
select monitor_unit_id,count(*) as num from hw_device where
monitor_unit_id = (select target_id from hw_fence_target where
target_type = '2'and electronic_fence_id =
(select electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}) )
monitor_unit_id = (select target_id from hw_fence_target where
target_type = '2'and electronic_fence_id =
(select electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}) )
GROUP BY monitor_unit_id
</select>
<select id="selectHwMonitorUnitList" parameterType="HwMonitorUnit" resultMap="HwMonitorUnitResult">
@ -96,25 +106,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--查询最子集监控单元以场景进行分组-->
<select id="selectAllNums" resultMap="AllNumsVoResult">
select scene_id,count(*) as sub_sum from
(select monitor_unit_id,scene_id from hw_monitor_unit
where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null))as temp
(select monitor_unit_id,scene_id from hw_monitor_unit
where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id
</select>
<select id="selectSubSetNums" resultType="String">
<select id="selectSubSetNums" resultType="Integer">
select count(*)from hw_monitor_unit
where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null)
select count(*)from hw_monitor_unit
where monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null)
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
</select>
<select id="selectDeviceNums" resultType="String">
<select id="selectDeviceNums" resultType="Integer">
select count(*) as sum from hw_device
where device_status = '1'
where device_status = '1'
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
</select>
<!-- 通过场景分组,查询设备数量 todo 已解决 -->
<!-- 通过场景分组,查询设备数量 todo 已解决 -->
<select id="selectsum" resultMap="AllNumsVoResult">
select scene_id,count(*) as sum from hw_device
where device_status = '1'GROUP BY scene_id
select scene_id,count(*) as sum from hw_device
where device_status = '1'GROUP BY scene_id
</select>
<!-- 通过id查询子集并返回-->
<!-- 通过id查询子集并返回-->
<select id="selectHwMonitorUnitByParent" parameterType="Long" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
where parent_id = #{monitorUnitId}
@ -123,11 +135,11 @@ where device_status = '1'GROUP BY scene_id
select count(*) from hw_device where releated_device_id = #{deviceId}
</select>
<!-- 查询该监控单元是否为最小单元-->
<!-- 查询该监控单元是否为最小单元-->
<select id="selectHwMonitorUnitIsParent" parameterType="Long" resultType="String">
SELECT count(*) from hw_monitor_unit where parent_id = #{monitorUnitId} GROUP BY parent_id
SELECT count(*) from hw_monitor_unit where parent_id = #{monitorUnitId} GROUP BY parent_id
</select>
<!-- todo 查询最小单元详细信息根据主键 byid 已解决-->
<!-- todo 查询最小单元详细信息根据主键 byid 已解决-->
<select id="selectHwmonitorUnitSub" resultType="Long" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
where monitor_unit_id = #{monitorUnitId}
@ -136,50 +148,50 @@ where device_status = '1'GROUP BY scene_id
<select id="selectSceneNameById" resultMap="HwMonitorUnitVoResult">
select scene_id,scene_name from hw_scene
</select>
<!-- 分页查询在impl实现分页-->
<!-- 分页查询在impl实现分页-->
<select id="selectLimitSubMonitorUnit" resultMap="HwMonitorUnitResult">
select * from hw_monitor_unit where monitor_unit_id
not in (select parent_id from hw_monitor_unit where parent_id is not null)
not in (select parent_id from hw_monitor_unit where parent_id is not null)
</select>
<!-- 查询最子集监控单元使用sceneid进行分组-->
<!-- 查询最子集监控单元使用sceneid进行分组-->
<select id="selectMonitorPercentage" resultMap="HwMonitorUnitVoResult">
select scene_id,count(*) as sum from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id order by sum desc
select scene_id,count(*) as sum from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp
GROUP BY scene_id order by sum desc
</select>
<!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字-->
<!-- 先通过报警信息表查询报警的监控单元id与数量在查询监控单元的名字-->
<select id="selectAlarmStats" resultMap="AlarmStatsResult">
select b.monitor_unit_id,b.monitor_unit_name,sum from
(select monitor_unit_id,count(*)as sum from hw_alarm_info GROUP BY monitor_unit_id
)as a left join hw_monitor_unit b on a.monitor_unit_id = b.monitor_unit_id order BY sum
select b.monitor_unit_id,b.monitor_unit_name,sum from
(select monitor_unit_id,count(*)as sum from hw_alarm_info where scene_id = #{sceneId} GROUP BY monitor_unit_id
)as a left join hw_monitor_unit b on a.monitor_unit_id = b.monitor_unit_id order BY sum
</select>
<!-- sub_sum 最子集监控单元数量device_num 设备数量 online_device_num在线设备数量 todo 传一个sceneid 监控单元和设备数量拆开查询 设备拿全部在后端判断 orderby 主键 -->
<!-- sub_sum 最子集监控单元数量device_num 设备数量 online_device_num在线设备数量 todo 传一个sceneid 监控单元和设备数量拆开查询 设备拿全部在后端判断 orderby 主键 -->
<select id="selectSubDeviceSum" parameterType="Long" resultType="Integer">
select count(*) from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp where scene_id = #{sceneId}
select count(*) from (select monitor_unit_id,scene_id
from hw_monitor_unit where monitor_unit_id not in
(select parent_id from hw_monitor_unit where parent_id is not null))as temp where scene_id = #{sceneId}
</select>
<!-- 先查询监控单元/设备的总量与报警未处理数量再通过场景id与电子围栏相连接-->
<!-- 先查询监控单元/设备的总量与报警未处理数量再通过场景id与电子围栏相连接-->
<select id="selectElectronicNum" resultMap="ElectronicNumVoResult">
select a.electronic_fence_id,a.electronic_fence_name,a.area_shape_flag,a.area_range,a.fence_type,b.num,b.alarm_num
from hw_electronic_fence as a left join ( select scene_id,count(*)as num,count(case when handle_status = '0' then 1 end ) as alarm_num from hw_alarm_info GROUP BY scene_id) as b on a.scene_id = b.scene_id
</select>
<select id="selectEleInScene" parameterType="Long" resultType="List">
select electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}
select electronic_fence_id from hw_electronic_fence where scene_id = #{sceneId}
</select>
<select id="selectEleType2" parameterType="Long" resultType="String">
select count(*) from hw_device where monitor_unit_id = (select target_id from hw_fence_target where target_type='2' and electronic_fence_id = #{electronicFenceId})
</select>
select count(*) from hw_device where monitor_unit_id = (select target_id from hw_fence_target where target_type='2' and electronic_fence_id = #{electronicFenceId})
</select>
<select id="selectEleType3" parameterType="Long" resultType="String">
select count(*) from hw_device where scene_id = #{sceneId}
</select>
<select id="selectDeviceType2Nums" parameterType="Long" resultType="Integer">
select count(*) from hw_device
where scene_id = #{sceneId}and device_type = '2' GROUP BY device_id
select count(*) from hw_device
where scene_id = #{sceneId}and device_type = '2' GROUP BY device_id
</select>
<insert id="insertHwMonitorUnit" parameterType="HwMonitorUnit" useGeneratedKeys="true" keyProperty="monitorUnitId">
insert into hw_monitor_unit
@ -199,7 +211,7 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="monitorUnitField != null">monitor_unit_field,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="monitorUnitName != null and monitorUnitName != ''">#{monitorUnitName},</if>
<if test="sceneId != null">#{sceneId},</if>
@ -216,7 +228,7 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="monitorUnitField != null">#{monitorUnitField},</if>
</trim>
</trim>
</insert>
<update id="updateHwMonitorUnit" parameterType="HwMonitorUnit">
@ -251,4 +263,23 @@ select count(*) from hw_device where monitor_unit_id = (select target_id from hw
#{monitorUnitId}
</foreach>
</delete>
</mapper>
<select id="selectHwMonitorUnitListJoinScene" parameterType="HwMonitorUnit" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitJoinScene"/>
<where>
hmu.monitor_unit_id not in (select parent_id from hw_monitor_unit where parent_id is not null)
<if test="monitorUnitName != null and monitorUnitName != ''"> and monitor_unit_name like concat('%', #{monitorUnitName}, '%')</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="monitorUnitTypeId != null "> and monitor_unit_type_id = #{monitorUnitTypeId}</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="monitorAddress != null and monitorAddress != ''"> and monitor_address = #{monitorAddress}</if>
<if test="monitorPic != null and monitorPic != ''"> and monitor_pic = #{monitorPic}</if>
<if test="preserveTime != null "> and preserve_time = #{preserveTime}</if>
<if test="monitorUnitStatus != null "> and monitor_unit_status = #{monitorUnitStatus}</if>
<if test="monitorUnitField != null and monitorUnitField != ''"> and monitor_unit_field = #{monitorUnitField}</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save