diff --git a/.idea/httpRequests/http-requests-log.http b/.idea/httpRequests/http-requests-log.http index ec4c717..ab74258 100644 --- a/.idea/httpRequests/http-requests-log.http +++ b/.idea/httpRequests/http-requests-log.http @@ -1,3 +1,70 @@ +GET http://localhost:9601/monitorPlatform/monitorPercentage + +<> 2023-09-13T042534.200.json + +### + +GET http://localhost:9601/monitorPlatform/monitorPercentage + +<> 2023-09-13T041522.200.json + +### + +GET http://localhost:9601/monitorPlatform/monitorUnitPercentage + +<> 2023-09-13T041504.200.json + +### + +GET http://localhost:9601/monitorPlatform/monitorUnitPercentage + +<> 2023-09-13T035712.200.json + +### + +POST http://localhost:9601/monitorPlatform/selectDeviceByDeviceModeByMonitorUnitId +{21321321}: + +<> 2023-09-13T035612.400.html + +### + +GET http://localhost:9601/monitorPlatform/monitorUnitPercentage + +<> 2023-09-13T035551.200.json + +### + +GET http://localhost:9601/monitorPlatform/monitorUnitPercentage + +<> 2023-09-13T035541.200.json + +### + +POST http://localhost:9601/monitorPlatform/treeList + +<> 2023-09-13T035533.200.json + +### + +GET http://localhost:9601/tenant/list + +<> 2023-09-11T045735.200.json + +### + +GET http://localhost:9601/monitorUnit/alarmStats + +<> 2023-09-11T045659.200.json + +### + +POST http://localhost:9601/monitorUnit/SelectSecne + +<> 2023-09-11T045623.200.json + +### + POST http://localhost/monitorUnit/getDeviceOperations } @@ -994,333 +1061,3 @@ Accept-Encoding: br,deflate,gzip,x-gzip ### -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_4", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 0 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693589999996 - } - ] -} - -<> 2023-09-05T142413.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_4", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 1 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693589999906 - } - ] -} - -<> 2023-09-05T142405.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_4", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 1 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693389999906 - } - ] -} - -<> 2023-09-05T142353.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_3", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 1 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693579949106 - } - ] -} - -<> 2023-09-05T142336.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_3", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 0 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693379949106 - } - ] -} - -<> 2023-09-05T142320.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_3", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 0 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693279949106 - } - ] -} - -<> 2023-09-05T142305.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_2", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 0 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693376368166 - } - ] -} - -<> 2023-09-05T142258.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_2", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 1 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693276368166 - } - ] -} - -<> 2023-09-05T142242.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_2", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 1 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693176368166 - } - ] -} - -<> 2023-09-05T142237.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_2", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 1 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693176268166 - } - ] -} - -<> 2023-09-05T142233.200.json - -### - -POST http://localhost:9602/tdengine/insertTable -Content-Type: application/json -Content-Length: 293 -Connection: Keep-Alive -User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8) -Accept-Encoding: br,deflate,gzip,x-gzip - -{ - "databaseName": "db_scene_1", - "tableName": "t_ds_2", - "schemaFields": [ - { - "fieldName": "onlineStatus", - "fieldValue": 0 - }, - { - "fieldName": "deviceType", - "fieldValue": 1 - }, - { - "fieldName": "ts", - "fieldValue": 1693176168166 - } - ] -} - -<> 2023-09-05T142218.200.json - -### - diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java index ab5d1be..497a52d 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java @@ -1,9 +1,224 @@ 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.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; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +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.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 static com.ruoyi.common.core.utils.PageUtils.startPage; @RestController @RequestMapping("/monitorPlatform") -public class HwMonitorPlatformController { +public class HwMonitorPlatformController extends BaseController { + + @Autowired + private IHwMonitorUnitService hwMonitorUnitService; + @Autowired + private IHwDeviceService hwDeviceService; + @Autowired + private IHwSceneService hwSceneService; + @Autowired + private IHwElectronicFenceService hwElectronicFenceService; + + + /** + * 树状获取监控单元列表 + * @param hwMonitorUnits 监控单元对象 + * @return list + * @throws + * */ + @PostMapping("/treeList") + public TableDataInfo treeList(List hwMonitorUnits){ + List list = hwMonitorUnitService.selectTreeList(hwMonitorUnits); + return getDataTable(list); + + } +// /** +// * +// * 选择场景 +// * @param sceneModeId 场景id +// * @return +// */ +// +// @PostMapping("/selectHwSceneBySceneModeId") +// public TableDataInfo selectHwSceneBySceneModeId(Long sceneModeId){ +// List hwScenes = hwSceneService.selectHwSceneBySceneModeId(sceneModeId); +// return getDataTable(hwScenes); +// } + /** + * 查询3. 设备各类型占所有设备数量百分比饼状图(左下角) + * */ + @GetMapping("/monitorUnitPercentage") + public TableDataInfo monitorUnitPercentage(){ + List maps = hwDeviceService.selectDeviceModeNameVo(); + return getDataTable(maps); + } + // + /** + * 获取有开关属性的设备 + * @param monitorUnitId 监控单元id + * */ + @PostMapping("/selectDeviceByDeviceModeByMonitorUnitId") + public Map> selectDeviceByDeviceModeByMonitorUnitId(Long monitorUnitId){ + startPage(); + Map> maps = hwDeviceService.selectDeviceByDeviceModeByMonitorUnitId(monitorUnitId); + return maps; + } + /** + * 获取直采变量的设备 + * @param monitorUnitId 监控单元id + */ + @PostMapping("/selectDeviceModeFunctionByFunctionType") + public Map> selectDeviceModeFunctionByFunctionType(Long monitorUnitId){ + startPage(); + Map> maps = hwDeviceService.selectDeviceModeFunctionByFunctionType(monitorUnitId); + return maps; + } + // + /** + * 设备历史数据 + * @param deviceId 设备id + * */ + @PostMapping("/getHistoryData") + public TableDataInfo getHistoryData(Long deviceId){ + startPage(); + List> historyData = hwDeviceService.getHistoryData(deviceId); + return getDataTable(historyData); + } + /** + * 查询区域数量站场景区总数百分比 + * */ + @GetMapping("/monitorPercentage") + public TableDataInfo monitorPercentage(){ + List maps = hwMonitorUnitService.selectMonitorPercentage(); + return getDataTable(maps); + } + /** + *  展示总的设备数量和总的监控单元数量 + * */ + @GetMapping("/allNums") + public AllNumsVo allNums(){ + AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums(); + + return allNumsVos; + } + /** + *  按场景展示总的设备数量和总的监控单元数量 + * */ + @GetMapping("/sceneAllNums") + public TableDataInfo sceneAllNums(){ + List allNumsVos = hwMonitorUnitService.selectSenceAllNums(); + + return getDataTable(allNumsVos); + } + /** + * 分页获取最子集监控单元列表 + * */ + @PostMapping("/limitSubMonitorUnit") + public TableDataInfo limitSubMonitorUnit(){ + startPage(); + List hwMonitorUnits = hwMonitorUnitService.selectLimitSubMonitorUnit(); + return getDataTable(hwMonitorUnits); + } + /** + * 监控单元报警统计 + */ + @GetMapping("/alarmStats") + public TableDataInfo alarmStats(){ + List alarmStatsVos = hwMonitorUnitService.selectAlarmStats(); + return getDataTable(alarmStatsVos); + } + /** + * 获取最子级监控单元数量、设备数量和在线设备数量 + * @param sceneId 场景id + * */ + @PostMapping("/SubDevice") + public SubDeviceSumVo subDevice(Long sceneId){ + SubDeviceSumVo subDeviceSumVos = hwMonitorUnitService.selectSubDeviceSum(sceneId); + + return subDeviceSumVos; + } + /** + * 按电子围栏定位显示其下设备数量,以及报警的设备数量。 + * @param sceneId + * */ + @PostMapping("/ElectronicNumVo") + public TableDataInfo ElectronicNumVo(Long sceneId){ + List eleMonitorDeviceSumVos = hwElectronicFenceService.selectEleTypeNums(sceneId); + return getDataTable(eleMonitorDeviceSumVos); + } + /** + * 获取监控单元详细信息 + * @param monitorUnitId + * */ + @PostMapping("/selectMonitorUnitSub") + //ok + public HwMonitorUnit selectMonitorUnitSub(Long monitorUnitId){ + HwMonitorUnit hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId); + + return hwMonitorUnits; + } + /** + * 2. 设备实时在运数量曲线图 + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @param sceneId 场景id + * */ + @PostMapping("/getDeviceOperations") + public Integer selectTdengine(String beginTime,String endTime,Long sceneId){ + int ints = hwMonitorUnitService.selectTdengine(beginTime,endTime,sceneId); + return ints; + } + /** + * 设备汇总 + * */ + @PostMapping("/selectLatestDataByTags") + public TableDataInfo selectLatestDataByTags(Long monitorUnitId){ + List> list= hwMonitorUnitService.selectLatestDataByTags(monitorUnitId); + return getDataTable(list); + } + /** + * 场景选择 + * ,id=0 可以返回所有,其他根据id过滤,默认标识 + * + * */ + @PostMapping("/SelectSecne") + public TableDataInfo SelectSecneByUser(){ + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + Long tenantId = sysUser.getTenantId(); + List hwScenes = hwSceneService.selectHwSceneByTenantId(tenantId); + hwScenes.get(0).setDefaultFlag("1"); + return getDataTable(hwScenes); + } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java index 27505b5..bcca3ba 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorUnitController.java @@ -13,6 +13,9 @@ 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; @@ -64,163 +67,8 @@ public class HwMonitorUnitController extends BaseController List list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit); return getDataTable(list); } - /** - * 树状获取监控单元列表 - * @param hwMonitorUnits 监控单元对象 - * @return list - * @throws - * */ - @PostMapping("/treeList") - public TableDataInfo treeList(List hwMonitorUnits){ - List list = hwMonitorUnitService.selectTreeList(hwMonitorUnits); - return getDataTable(list); - } -// /** -// * -// * 选择场景 -// * @param sceneModeId 场景id -// * @return -// */ -// -// @PostMapping("/selectHwSceneBySceneModeId") -// public TableDataInfo selectHwSceneBySceneModeId(Long sceneModeId){ -// List hwScenes = hwSceneService.selectHwSceneBySceneModeId(sceneModeId); -// return getDataTable(hwScenes); -// } - /** - * 查询3. 设备各类型占所有设备数量百分比饼状图(左下角) - * */ - @GetMapping("/monitorUnitPercentage") - public TableDataInfo monitorUnitPercentage(){ - List maps = hwDeviceService.selectDeviceModeNameVo(); - return getDataTable(maps); - } - // - /** - * 获取有开关属性的设备 - * @param monitorUnitId 监控单元id - * */ - @PostMapping("/selectDeviceByDeviceModeByMonitorUnitId") - public Map> selectDeviceByDeviceModeByMonitorUnitId(Long monitorUnitId){ - startPage(); - Map> maps = hwDeviceService.selectDeviceByDeviceModeByMonitorUnitId(monitorUnitId); - return maps; - } - /** - * 获取直采变量的设备 - * @param monitorUnitId 监控单元id - */ - @PostMapping("/selectDeviceModeFunctionByFunctionType") - public Map> selectDeviceModeFunctionByFunctionType(Long monitorUnitId){ - startPage(); - Map> maps = hwDeviceService.selectDeviceModeFunctionByFunctionType(monitorUnitId); - return maps; - } - // - /** - * 设备历史数据 - * @param deviceId 设备id - * */ - @PostMapping("/getHistoryData") - public TableDataInfo getHistoryData(Long deviceId){ - startPage(); - List> historyData = hwDeviceService.getHistoryData(deviceId); - return getDataTable(historyData); - } - /** - * 查询区域数量站场景区总数百分比 - * */ - @GetMapping("/monitorPercentage") - public TableDataInfo monitorPercentage(){ - List maps = hwMonitorUnitService.selectMonitorPercentage(); - return getDataTable(maps); -} - /** - *  展示总的设备数量和总的监控单元数量 - * */ - @GetMapping("/allNums") - public AllNumsVo allNums(){ - AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums(); - - return allNumsVos; - } - /** - *  按场景展示总的设备数量和总的监控单元数量 - * */ - @GetMapping("/sceneAllNums") - public TableDataInfo sceneAllNums(){ - List allNumsVos = hwMonitorUnitService.selectSenceAllNums(); - - return getDataTable(allNumsVos); - } - /** - * 分页获取最子集监控单元列表 - * */ - @PostMapping("/limitSubMonitorUnit") - public TableDataInfo limitSubMonitorUnit(){ - startPage(); - List hwMonitorUnits = hwMonitorUnitService.selectLimitSubMonitorUnit(); - return getDataTable(hwMonitorUnits); - } - /** - * 监控单元报警统计 - */ - @GetMapping("/alarmStats") - public TableDataInfo alarmStats(){ - List alarmStatsVos = hwMonitorUnitService.selectAlarmStats(); - return getDataTable(alarmStatsVos); - } - /** - * 获取最子级监控单元数量、设备数量和在线设备数量 - * @param sceneId 场景id - * */ - @PostMapping("/SubDevice") - public SubDeviceSumVo subDevice(Long sceneId){ - SubDeviceSumVo subDeviceSumVos = hwMonitorUnitService.selectSubDeviceSum(sceneId); - - return subDeviceSumVos; - } - /** - * 按电子围栏定位显示其下设备数量,以及报警的设备数量。 - * @param sceneId - * */ - @PostMapping("/ElectronicNumVo") - public TableDataInfo ElectronicNumVo(Long sceneId){ - List eleMonitorDeviceSumVos = hwElectronicFenceService.selectEleTypeNums(sceneId); - return getDataTable(eleMonitorDeviceSumVos); - } - /** - * 获取监控单元详细信息 - * @param monitorUnitId - * */ - @PostMapping("/selectMonitorUnitSub") - //ok - public HwMonitorUnit selectMonitorUnitSub(Long monitorUnitId){ - HwMonitorUnit hwMonitorUnits = hwMonitorUnitService.selectHwMonitorUnitByMonitorUnitId(monitorUnitId); - - return hwMonitorUnits; - } - /** - * 2. 设备实时在运数量曲线图 - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @param sceneId 场景id - * */ - @PostMapping("/getDeviceOperations") - public Integer selectTdengine(String beginTime,String endTime,Long sceneId){ - int ints = hwMonitorUnitService.selectTdengine(beginTime,endTime,sceneId); - return ints; - } - /** - * 通过tde获取各设备最新的一条信息 - * */ -// @PostMapping("/selectLatestDataByTags") -// public TableDataInfo selectLatestDataByTags(Long monitorUnitId){ -// List> list= hwMonitorUnitService.selectLatestDataByTags(monitorUnitId); -// return getDataTable(list); -// } /** * 导出监控单元列表 */ diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwSceneController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwSceneController.java index a2a88bb..80e8d0a 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwSceneController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwSceneController.java @@ -1,13 +1,21 @@ package com.ruoyi.business.controller; +import java.math.BigDecimal; import java.util.List; import java.io.IOException; import java.util.Locale; +import java.util.UUID; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.business.domain.HwSceneMode; +import com.ruoyi.business.domain.VO.HwSceneVo; +import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.i18n.utils.MessageUtils; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.model.LoginUser; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.validation.annotation.Validated; @@ -51,10 +59,10 @@ public class HwSceneController extends BaseController */ @RequiresPermissions("business:scene:list") @GetMapping("/list") - public TableDataInfo list(HwScene hwScene) + public TableDataInfo list(HwSceneVo hwScene) { startPage(); - List list = hwSceneService.selectHwSceneList(hwScene); + List list = hwSceneService.selectHwSceneList2(hwScene); return getDataTable(list); } @@ -88,8 +96,10 @@ public class HwSceneController extends BaseController @RequiresPermissions("business:scene:add") @Log(title = "场景信息", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody @Validated HwScene hwScene) + public AjaxResult add(@RequestBody HwScene hwScene) { + +// System.out.println(hwScene); return toAjax(hwSceneService.insertHwScene(hwScene)); } @@ -101,6 +111,9 @@ public class HwSceneController extends BaseController @PutMapping public AjaxResult edit(@RequestBody HwScene hwScene) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + hwScene.setUpdateBy(sysUser.getNickName()); return toAjax(hwSceneService.updateHwScene(hwScene)); } @@ -114,4 +127,20 @@ public class HwSceneController extends BaseController { return toAjax(hwSceneService.deleteHwSceneBySceneIds(sceneIds)); } + @GetMapping("/isAdmin") + public Boolean isAdmin(){ + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); +// System.out.println(sysUser.getUserName()); + if (sysUser.getUserName().equals("admin")){ +// System.out.println("true"); + return true; + }else { + return false; + } + } + + } + + diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java index 2a5c99e..c375d39 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwTenantController.java @@ -1,8 +1,13 @@ package com.ruoyi.business.controller; +import java.util.ArrayList; import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; + +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; @@ -24,7 +29,7 @@ import com.ruoyi.common.core.web.page.TableDataInfo; /** * 租户信息Controller - * + * * @author xins * @date 2023-09-04 */ @@ -42,8 +47,11 @@ public class HwTenantController extends BaseController @GetMapping("/list") public TableDataInfo list(HwTenant hwTenant) { + List list = new ArrayList(); startPage(); - List list = hwTenantService.selectHwTenantList(hwTenant); + //todo 放到add中 + + list = hwTenantService.selectHwTenantList(hwTenant); return getDataTable(list); } @@ -78,6 +86,10 @@ public class HwTenantController extends BaseController @PostMapping public AjaxResult add(@RequestBody HwTenant hwTenant) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + hwTenant.setIsRegister("0"); + hwTenant.setCreateBy(sysUser.getNickName()); return toAjax(hwTenantService.insertHwTenant(hwTenant)); } @@ -88,7 +100,10 @@ public class HwTenantController extends BaseController @Log(title = "租户信息", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody HwTenant hwTenant) - { + {LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + + hwTenant.setUpdateBy(sysUser.getNickName()); return toAjax(hwTenantService.updateHwTenant(hwTenant)); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/DeviceModeVo.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/DeviceModeVo.java index a1886ac..597d10b 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/DeviceModeVo.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/DeviceModeVo.java @@ -8,7 +8,8 @@ package com.ruoyi.business.domain.VO; */ public class DeviceModeVo { - public String monitorUnitTypeName; +// public String monitorUnitTypeName; + public String deviceModeName; public Integer sum; @@ -20,16 +21,12 @@ public class DeviceModeVo { return percentage; } - public void setPercentage(Double percentage) { - this.percentage = percentage; - } - - public String getMonitorUnitTypeName() { - return monitorUnitTypeName; + public String getDeviceModeName() { + return deviceModeName; } - public void setMonitorUnitTypeName(String monitorUnitTypeName) { - this.monitorUnitTypeName = monitorUnitTypeName; + public void setDeviceModeName(String deviceModeName) { + this.deviceModeName = deviceModeName; } public Integer getSum() { @@ -48,12 +45,17 @@ public class DeviceModeVo { this.err = err; } + public void setPercentage(Double percentage) { + this.percentage = percentage; + } + @Override public String toString() { - return "HwMonitorUnitTypeVo{" + - "monitorUnitTypeName='" + monitorUnitTypeName + '\'' + + return "DeviceModeVo{" + + ", deviceModeName='" + deviceModeName + '\'' + ", sum=" + sum + ", err=" + err + + ", percentage=" + percentage + '}'; } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java index 3cb3497..917cc85 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwSceneMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.business.mapper; import java.util.List; import com.ruoyi.business.domain.HwScene; +import com.ruoyi.business.domain.VO.HwSceneVo; /** * 场景信息Mapper接口 @@ -19,6 +20,8 @@ public interface HwSceneMapper */ public HwScene selectHwSceneBySceneId(Long sceneId); public List selectHwSceneBySceneModeId(Long sceneModeId); + public List selectHwSceneByTenantId0(Long tenantId); + public List selectHwSceneByTenantIdNot0(Long tenantId); /** @@ -28,6 +31,9 @@ public interface HwSceneMapper * @return 场景信息集合 */ public List selectHwSceneList(HwScene hwScene); + List selectHwSceneVoList(HwSceneVo hwScene); + void updateDefaultFlag(Long tenantId); + /** * 新增场景信息 diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwTenantMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwTenantMapper.java index fe96e2f..1d8c3db 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwTenantMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwTenantMapper.java @@ -5,23 +5,25 @@ import com.ruoyi.business.domain.HwTenant; /** * 租户信息Mapper接口 - * + * * @author xins * @date 2023-09-04 */ -public interface HwTenantMapper +public interface HwTenantMapper { /** * 查询租户信息 - * + * * @param tenantId 租户信息主键 * @return 租户信息 */ public HwTenant selectHwTenantByTenantId(Long tenantId); + + /** * 查询租户信息列表 - * + * * @param hwTenant 租户信息 * @return 租户信息集合 */ @@ -29,7 +31,7 @@ public interface HwTenantMapper /** * 新增租户信息 - * + * * @param hwTenant 租户信息 * @return 结果 */ @@ -37,7 +39,7 @@ public interface HwTenantMapper /** * 修改租户信息 - * + * * @param hwTenant 租户信息 * @return 结果 */ @@ -45,7 +47,7 @@ public interface HwTenantMapper /** * 删除租户信息 - * + * * @param tenantId 租户信息主键 * @return 结果 */ @@ -53,7 +55,7 @@ public interface HwTenantMapper /** * 批量删除租户信息 - * + * * @param tenantIds 需要删除的数据主键集合 * @return 结果 */ diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwMonitorUnitService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwMonitorUnitService.java index eb21539..8ce773d 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwMonitorUnitService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwMonitorUnitService.java @@ -73,10 +73,10 @@ public interface IHwMonitorUnitService * @return*/ public int selectTdengine(String beginTime,String endTime,Long sceneId); /** - * 通过tde获取最新的一条信息 + * 设备汇总 * * @return*/ -// public List> selectLatestDataByTags(Long monitorUnitId); + public List> selectLatestDataByTags(Long monitorUnitId); /** diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneModeService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneModeService.java index 2563f57..09dc109 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneModeService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneModeService.java @@ -5,15 +5,15 @@ import com.ruoyi.business.domain.HwSceneMode; /** * 场景类型Service接口 - * + * * @author YINQ * @date 2023-08-31 */ -public interface IHwSceneModeService +public interface IHwSceneModeService { /** * 查询场景类型 - * + * * @param sceneModeId 场景类型主键 * @return 场景类型 */ @@ -21,7 +21,7 @@ public interface IHwSceneModeService /** * 查询场景类型列表 - * + * * @param hwSceneMode 场景类型 * @return 场景类型集合 */ @@ -29,7 +29,7 @@ public interface IHwSceneModeService /** * 新增场景类型 - * + * * @param hwSceneMode 场景类型 * @return 结果 */ @@ -37,7 +37,7 @@ public interface IHwSceneModeService /** * 修改场景类型 - * + * * @param hwSceneMode 场景类型 * @return 结果 */ @@ -45,7 +45,7 @@ public interface IHwSceneModeService /** * 批量删除场景类型 - * + * * @param sceneModeIds 需要删除的场景类型主键集合 * @return 结果 */ @@ -53,7 +53,7 @@ public interface IHwSceneModeService /** * 删除场景类型信息 - * + * * @param sceneModeId 场景类型主键 * @return 结果 */ diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneService.java index c3eb04a..f65da07 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwSceneService.java @@ -2,6 +2,7 @@ package com.ruoyi.business.service; import java.util.List; import com.ruoyi.business.domain.HwScene; +import com.ruoyi.business.domain.VO.HwSceneVo; /** * 场景信息Service接口 @@ -19,8 +20,11 @@ public interface IHwSceneService */ public HwScene selectHwSceneBySceneId(Long sceneId); - //选择场景 + public List selectHwSceneBySceneModeId(Long sceneModeId); + + //场景选择 + List selectHwSceneByTenantId(Long tenantId); /** * 查询场景信息列表 * @@ -28,6 +32,8 @@ public interface IHwSceneService * @return 场景信息集合 */ public List selectHwSceneList(HwScene hwScene); + public List selectHwSceneList2(HwSceneVo hwScene); + /** * 新增场景信息 diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index d349de9..d92516c 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -81,7 +81,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService } } DeviceModeVo hwMonitorUnitTypeVo = new DeviceModeVo(); - hwMonitorUnitTypeVo.setMonitorUnitTypeName("其他"); + hwMonitorUnitTypeVo.setDeviceModeName("其他"); hwMonitorUnitTypeVo.setSum(value); Integer sums = 0; for (int i = 0; i < list.size();i++){ diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java index dbdda67..e851f7f 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorUnitServiceImpl.java @@ -229,20 +229,20 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService //网关子设备数+非网关设备数(getDeviceType()!=1) } -// @Override -// public List> selectLatestDataByTags(Long monitorUnitId) { -// List> latestData = new ArrayList>; -// List 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(monitorUnitId); -// tdSelectDto.set -// latestData = (List>) remoteTdEgineService.getLatestData(tdSelectDto); -// } -// return latestData; -// } + @Override + public List> selectLatestDataByTags(Long monitorUnitId) { + List> latestData = new ArrayList>(); + List 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()); + + latestData = (List>) remoteTdEgineService.getLatestDataByTags(tdSelectDto); + } + return latestData; + } //todo SysDeptServiceImpl类中的递归方法recursionFn(以实现) @Override diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java index 30bbceb..28881c2 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwSceneServiceImpl.java @@ -1,7 +1,18 @@ package com.ruoyi.business.service.impl; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; + +import com.ruoyi.business.domain.HwSceneMode; +import com.ruoyi.business.domain.VO.HwSceneVo; import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.model.LoginUser; +import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.business.mapper.HwSceneMapper; @@ -19,6 +30,9 @@ public class HwSceneServiceImpl implements IHwSceneService { @Autowired private HwSceneMapper hwSceneMapper; + @Autowired + private RedisService redisService; + /** * 查询场景信息 @@ -39,6 +53,15 @@ public class HwSceneServiceImpl implements IHwSceneService return hwScenes; } + @Override + public List selectHwSceneByTenantId(Long tenantId) { + if (tenantId == 0){ + return hwSceneMapper.selectHwSceneByTenantId0(tenantId); + } + else + return hwSceneMapper.selectHwSceneByTenantIdNot0(tenantId); + + } /** @@ -53,6 +76,12 @@ public class HwSceneServiceImpl implements IHwSceneService return hwSceneMapper.selectHwSceneList(hwScene); } + @Override + public List selectHwSceneList2(HwSceneVo hwScene) { + return hwSceneMapper.selectHwSceneVoList(hwScene); + } + + /** * 新增场景信息 * @@ -62,7 +91,32 @@ public class HwSceneServiceImpl implements IHwSceneService @Override public int insertHwScene(HwScene hwScene) { + if(hwScene.getDefaultFlag() == "1"){ + hwSceneMapper.updateDefaultFlag(hwScene.getTenantId()); + } + hwScene.setDefaultFlag("1"); + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + hwScene.setSceneStatus("1"); + Long lon = new Long(10); + hwScene.setSceneId(lon); + hwScene.setCreateBy(sysUser.getNickName()); + + if (hwScene.getPreserveTime()==null){ + hwScene.setPreserveTime(new BigDecimal(90)); + } + if (hwScene.getTestPreserveTime()==null){ + hwScene.setTestPreserveTime(new BigDecimal(30)); + } + String randomKey = RandomStringUtils.random(12, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"); + String randomSecret = RandomStringUtils.random(16,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"); + hwScene.setModeKey(randomKey); + hwScene.setModeSecret(randomSecret); hwScene.setCreateTime(DateUtils.getNowDate()); + List list = new ArrayList(); + list.add(hwScene); + redisService.setCacheList(hwScene.getSceneId()+"",list); + return hwSceneMapper.insertHwScene(hwScene); } @@ -75,7 +129,14 @@ public class HwSceneServiceImpl implements IHwSceneService @Override public int updateHwScene(HwScene hwScene) { + if(hwScene.getDefaultFlag() == "1"){ + hwSceneMapper.updateDefaultFlag(hwScene.getTenantId()); + } + hwScene.setDefaultFlag("1"); hwScene.setUpdateTime(DateUtils.getNowDate()); + List list = new ArrayList(); + list.add(hwScene); + redisService.setCacheList(hwScene.getSceneId()+"",list); return hwSceneMapper.updateHwScene(hwScene); } @@ -88,6 +149,11 @@ public class HwSceneServiceImpl implements IHwSceneService @Override public int deleteHwSceneBySceneIds(Long[] sceneIds) { + List list = new ArrayList<>(); + for (int i = 0; i < sceneIds.length;i++){ + list.add(sceneIds[i]); + } + redisService.deleteObject(sceneIds+""); return hwSceneMapper.deleteHwSceneBySceneIds(sceneIds); } @@ -100,6 +166,7 @@ public class HwSceneServiceImpl implements IHwSceneService @Override public int deleteHwSceneBySceneId(Long sceneId) { + redisService.deleteObject(sceneId+""); return hwSceneMapper.deleteHwSceneBySceneId(sceneId); } } diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml index 458ddd8..d01a5f2 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwSceneMapper.xml @@ -26,11 +26,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + + + + + + + + + + + + + + + select scene_id, scene_name, tenant_id, scene_mode_id, scene_pic, default_flag, scene_status, auth_mode, mode_account, mode_key, mode_secret, preserve_time, test_preserve_time, remark, create_by, create_time, update_by, update_time, scene_environment, scene_field from hw_scene + - + + insert into hw_scene @@ -103,7 +152,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{sceneField}, - + + update hw_scene + set default_flag = '0' + where tenant_id = #{tenantId} + update hw_scene @@ -131,11 +184,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from hw_scene where scene_id = #{sceneId} + update hw_scene set scene_status = '9' where scene_id = #{sceneId} - delete from hw_scene where scene_id in + update hw_scene set scene_status = '9' where scene_id = in #{sceneId} diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwTenantMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwTenantMapper.xml index 3c3f0a3..5015283 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwTenantMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwTenantMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -31,12 +31,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - + insert into hw_tenant @@ -119,13 +119,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from hw_tenant where tenant_id = #{tenantId} - +UPDATE hw_tenant t1,sys_user t2 + set t1.tenant_status = '9', t2.del_flag = '2' + where t1.tenant_id = t2.tenant_id and t1.tenant_id=#{tenantId} - delete from hw_tenant where tenant_id in + UPDATE hw_tenant t1,sys_user t2 + set t1.tenant_status = '9', t2.del_flag = '2' + where t1.tenant_id = t2.tenant_id and t1.tenant_id in #{tenantId} - \ No newline at end of file + diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/mqtt/client/config/MqttConfiguration.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/mqtt/client/config/MqttConfiguration.java index 7f9b9ce..9e9431a 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/mqtt/client/config/MqttConfiguration.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/mqtt/client/config/MqttConfiguration.java @@ -129,7 +129,7 @@ public class MqttConfiguration { if (topic.startsWith(dataTopicFilter.replace("#",""))) { dataProcessService.processBusinessData(payloadString, imagePath, imagePatterns); } else if (topic.equals(deviceStatusTopic)) { - deviceStatusService.handleDeviceStatus(); + deviceStatusService.handleDeviceStatus(payloadString,clientId); } } }); diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/IDeviceStatusService.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/IDeviceStatusService.java index 99f5a34..6d4bcd0 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/IDeviceStatusService.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/IDeviceStatusService.java @@ -9,5 +9,5 @@ package com.ruoyi.dataprocess.service; */ public interface IDeviceStatusService { - public void handleDeviceStatus(); + public void handleDeviceStatus(String payloadString,String clientId); } diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DeviceStatusServiceImpl.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DeviceStatusServiceImpl.java index c90474f..bdf19dc 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DeviceStatusServiceImpl.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DeviceStatusServiceImpl.java @@ -1,27 +1,73 @@ package com.ruoyi.dataprocess.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.constant.TdEngineConstants; +import com.ruoyi.dataprocess.domain.HwDevice; +import com.ruoyi.dataprocess.mapper.HwDeviceMapper; import com.ruoyi.dataprocess.service.IDeviceStatusService; import com.ruoyi.tdengine.api.RemoteTdEngineService; +import com.ruoyi.tdengine.api.domain.TdField; +import com.ruoyi.tdengine.api.domain.TdTableVo; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * @Description: 设备状态处理服务 * @ClassName: DeviceStatusServiceImpl - * @Author : xins - * @Date :2023-09-04 15:31 + * @Author : xins + * @Date :2023-09-04 15:31 * @Version :1.0 */ @Service public class DeviceStatusServiceImpl implements IDeviceStatusService { + @Autowired + private HwDeviceMapper hwDeviceMapper; + @Resource private RemoteTdEngineService remoteTdEngineService; @Override - public void handleDeviceStatus(){ + public void handleDeviceStatus(String payloadString, String clientId) { + System.out.println("ddd:" + payloadString); +// ddd:{"msg":"设备设备连接状态信息","deviceType":"edge","connectStatus":1, +// "statusTime":1694506127199,"deviceCode":"hw-data-process-1"} + JSONObject json = JSON.parseObject(payloadString); + String deviceCode = json.getString("deviceCode"); + if (clientId.equals(deviceCode)) { //校验是不是自己,如果是自己则不记录状态,返回即可。 + return; + } + HwDevice hwDevice = hwDeviceMapper.selectHwDeviceByDeviceCode(deviceCode); + if (hwDevice != null) { + Long deviceId = hwDevice.getDeviceId(); + TdTableVo tdTableVo = new TdTableVo(); + tdTableVo.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME); + tdTableVo.setTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_TABLE_NAME_PREFIX + deviceId); + + List schemaFields = new ArrayList<>(); + TdField onlineStatusField = new TdField(); + onlineStatusField.setFieldName("onlineStatus"); + onlineStatusField.setFieldValue(json.getInteger("connectStatus")); + schemaFields.add(onlineStatusField); + + TdField deviceTypeField = new TdField(); + deviceTypeField.setFieldName("deviceType"); + deviceTypeField.setFieldValue(json.getString("deviceType")); + schemaFields.add(deviceTypeField); + + TdField tsField = new TdField(); + tsField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME); + tsField.setFieldValue(json.getLong("statusTime")); + schemaFields.add(tsField); + + tdTableVo.setSchemaFields(schemaFields); - System.out.println("handleDeviceStatus"); + this.remoteTdEngineService.insertTable(tdTableVo); + } } } diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 036b7c9..220da83 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -36,7 +36,9 @@ "url": "https://gitee.com/y_project/RuoYi-Cloud.git" }, "dependencies": { + "@amap/amap-jsapi-loader": "^1.0.1", "@riophae/vue-treeselect": "0.4.0", + "Vue-i18n": "npm:vue-i18n@^8.26.7", "axios": "0.24.0", "clipboard": "2.0.8", "core-js": "3.25.3", @@ -48,6 +50,8 @@ "js-beautify": "1.13.0", "js-cookie": "3.0.1", "jsencrypt": "3.0.0-rc.1", + "less": "^4.2.0", + "less-loader": "5.0.0", "nprogress": "0.2.0", "quill": "1.3.7", "screenfull": "5.0.2", @@ -56,9 +60,9 @@ "vue-count-to": "1.0.13", "vue-cropper": "0.5.5", "vue-i18n": "8.26.7", - "Vue-i18n": "npm:vue-i18n@^8.26.7", "vue-meta": "2.4.0", "vue-router": "3.4.9", + "vue-seamless-scroll": "^1.1.23", "vuedraggable": "2.24.3", "vuex": "3.6.0" }, diff --git a/ruoyi-ui/src/assets/board/GPS/bg.jpg b/ruoyi-ui/src/assets/board/GPS/bg.jpg new file mode 100644 index 0000000..9e7ab74 Binary files /dev/null and b/ruoyi-ui/src/assets/board/GPS/bg.jpg differ diff --git a/ruoyi-ui/src/assets/board/GPS/green.png b/ruoyi-ui/src/assets/board/GPS/green.png new file mode 100644 index 0000000..bb67576 Binary files /dev/null and b/ruoyi-ui/src/assets/board/GPS/green.png differ diff --git a/ruoyi-ui/src/assets/board/GPS/red.png b/ruoyi-ui/src/assets/board/GPS/red.png new file mode 100644 index 0000000..c89cb5a Binary files /dev/null and b/ruoyi-ui/src/assets/board/GPS/red.png differ diff --git a/ruoyi-ui/src/assets/board/common/bg1.png b/ruoyi-ui/src/assets/board/common/bg1.png new file mode 100644 index 0000000..987361f Binary files /dev/null and b/ruoyi-ui/src/assets/board/common/bg1.png differ diff --git a/ruoyi-ui/src/assets/board/common/subheadClick.png b/ruoyi-ui/src/assets/board/common/subheadClick.png new file mode 100644 index 0000000..939f44a Binary files /dev/null and b/ruoyi-ui/src/assets/board/common/subheadClick.png differ diff --git a/ruoyi-ui/src/assets/board/common/subheadClick1.png b/ruoyi-ui/src/assets/board/common/subheadClick1.png new file mode 100644 index 0000000..7e0d246 Binary files /dev/null and b/ruoyi-ui/src/assets/board/common/subheadClick1.png differ diff --git a/ruoyi-ui/src/assets/board/index/bg.jpg b/ruoyi-ui/src/assets/board/index/bg.jpg new file mode 100644 index 0000000..98b320c Binary files /dev/null and b/ruoyi-ui/src/assets/board/index/bg.jpg differ diff --git a/ruoyi-ui/src/assets/board/index/container.png b/ruoyi-ui/src/assets/board/index/container.png new file mode 100644 index 0000000..5de951d Binary files /dev/null and b/ruoyi-ui/src/assets/board/index/container.png differ diff --git a/ruoyi-ui/src/assets/board/senso/bg.jpg b/ruoyi-ui/src/assets/board/senso/bg.jpg new file mode 100644 index 0000000..17ec684 Binary files /dev/null and b/ruoyi-ui/src/assets/board/senso/bg.jpg differ diff --git a/ruoyi-ui/src/assets/board/senso/icon.png b/ruoyi-ui/src/assets/board/senso/icon.png new file mode 100644 index 0000000..7467489 Binary files /dev/null and b/ruoyi-ui/src/assets/board/senso/icon.png differ diff --git a/ruoyi-ui/src/assets/board/senso/iconBg.png b/ruoyi-ui/src/assets/board/senso/iconBg.png new file mode 100644 index 0000000..987361f Binary files /dev/null and b/ruoyi-ui/src/assets/board/senso/iconBg.png differ diff --git a/ruoyi-ui/src/assets/board/senso/iconBottom.png b/ruoyi-ui/src/assets/board/senso/iconBottom.png new file mode 100644 index 0000000..9915ec9 Binary files /dev/null and b/ruoyi-ui/src/assets/board/senso/iconBottom.png differ diff --git a/ruoyi-ui/src/assets/board/senso/itemBg.png b/ruoyi-ui/src/assets/board/senso/itemBg.png new file mode 100644 index 0000000..56ad201 Binary files /dev/null and b/ruoyi-ui/src/assets/board/senso/itemBg.png differ diff --git a/ruoyi-ui/src/assets/board/smartScene/bg.jpg b/ruoyi-ui/src/assets/board/smartScene/bg.jpg new file mode 100644 index 0000000..3061895 Binary files /dev/null and b/ruoyi-ui/src/assets/board/smartScene/bg.jpg differ diff --git a/ruoyi-ui/src/assets/board/smartScene/device.png b/ruoyi-ui/src/assets/board/smartScene/device.png new file mode 100644 index 0000000..5de951d Binary files /dev/null and b/ruoyi-ui/src/assets/board/smartScene/device.png differ diff --git a/ruoyi-ui/src/components/BoardTopNav/index.vue b/ruoyi-ui/src/components/BoardTopNav/index.vue new file mode 100644 index 0000000..963e374 --- /dev/null +++ b/ruoyi-ui/src/components/BoardTopNav/index.vue @@ -0,0 +1,80 @@ + + + + diff --git a/ruoyi-ui/src/components/Charts/Chart.vue b/ruoyi-ui/src/components/Charts/Chart.vue new file mode 100644 index 0000000..0899129 --- /dev/null +++ b/ruoyi-ui/src/components/Charts/Chart.vue @@ -0,0 +1,35 @@ + + + diff --git a/ruoyi-ui/src/lang/index.js b/ruoyi-ui/src/lang/index.js index e580add..8e6c7a3 100644 --- a/ruoyi-ui/src/lang/index.js +++ b/ruoyi-ui/src/lang/index.js @@ -22,7 +22,7 @@ const messages = { const i18n = new VueI18n({ // 设置语言 选项 en_US | zh_CN - locale: Cookies.get('language') || 'en_US', + locale: Cookies.get('language') || 'zh_CN', // 设置文本内容 messages }) diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js index c8b8883..fea469d 100644 --- a/ruoyi-ui/src/main.js +++ b/ruoyi-ui/src/main.js @@ -1,4 +1,6 @@ import Vue from 'vue' +import less from 'less' +import AMapLoader from "@amap/amap-jsapi-loader"; import Cookies from 'js-cookie' @@ -61,9 +63,18 @@ Vue.component('FileUpload', FileUpload) Vue.component('ImageUpload', ImageUpload) Vue.component('ImagePreview', ImagePreview) + +AMapLoader.load({ + 'key': '268909dc36fd438908a64ebe057bfb17', + 'version': '2.0', + 'plugins': ['AMap.Scale','AMap.GeoJSON'] +}).then((AMap) => { + Vue.use(AMap) +}) Vue.use(directive) Vue.use(plugins) Vue.use(VueMeta) +Vue.use(less) DictData.install() /** diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index a1be94d..248170e 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -87,7 +87,38 @@ export const constantRoutes = [ meta: { title: '个人中心', icon: 'user' } } ] - } + }, + + { + path: '/board1', + component: () => import('@/views/board/index'), + name: 'Index', + meta: { title: '1', icon: 'dashboard', affix: true } + }, + { + path: '/board2', + component: () => import('@/views/board/equipmentMonitoring'), + name: 'Index', + meta: { title: '2', icon: 'dashboard', affix: true } + }, + { + path: '/board3', + component: () => import('@/views/board/GPS'), + name: 'Index', + meta: { title: '3', icon: 'dashboard', affix: true } + }, + { + path: '/board4', + component: () => import('@/views/board/senso'), + name: 'Index', + meta: { title: '4', icon: 'dashboard', affix: true } + }, + { + path: '/board5', + component: () => import('@/views/board/smartScene'), + name: 'Index', + meta: { title: '5', icon: 'dashboard', affix: true } + }, ] // 动态路由,基于用户权限动态去加载 diff --git a/ruoyi-ui/src/views/board/GPS/index.vue b/ruoyi-ui/src/views/board/GPS/index.vue new file mode 100644 index 0000000..2d622c6 --- /dev/null +++ b/ruoyi-ui/src/views/board/GPS/index.vue @@ -0,0 +1,385 @@ + + + + diff --git a/ruoyi-ui/src/views/board/equipmentMonitoring/index.vue b/ruoyi-ui/src/views/board/equipmentMonitoring/index.vue new file mode 100644 index 0000000..127c182 --- /dev/null +++ b/ruoyi-ui/src/views/board/equipmentMonitoring/index.vue @@ -0,0 +1,35 @@ + + + + diff --git a/ruoyi-ui/src/views/board/index/index.vue b/ruoyi-ui/src/views/board/index/index.vue new file mode 100644 index 0000000..e986fc9 --- /dev/null +++ b/ruoyi-ui/src/views/board/index/index.vue @@ -0,0 +1,604 @@ + + + + diff --git a/ruoyi-ui/src/views/board/senso/index.vue b/ruoyi-ui/src/views/board/senso/index.vue new file mode 100644 index 0000000..7defe0e --- /dev/null +++ b/ruoyi-ui/src/views/board/senso/index.vue @@ -0,0 +1,464 @@ + + + + diff --git a/ruoyi-ui/src/views/board/smartScene/index.vue b/ruoyi-ui/src/views/board/smartScene/index.vue new file mode 100644 index 0000000..58048b4 --- /dev/null +++ b/ruoyi-ui/src/views/board/smartScene/index.vue @@ -0,0 +1,509 @@ + + + +