1.1.3 监控单元Controller修改

dev
zhouhy 1 year ago
parent cd2bee6833
commit 9e3c755ed2

@ -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
###

@ -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<HwMonitorUnit> hwMonitorUnits){
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.
* */
@GetMapping("/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;
}
/**
*
* @param monitorUnitId id
*/
@PostMapping("/selectDeviceModeFunctionByFunctionType")
public Map<String, Map<String, Object>> selectDeviceModeFunctionByFunctionType(Long monitorUnitId){
startPage();
Map<String, Map<String, Object>> maps = hwDeviceService.selectDeviceModeFunctionByFunctionType(monitorUnitId);
return maps;
}
//
/**
*
* @param deviceId id
* */
@PostMapping("/getHistoryData")
public TableDataInfo getHistoryData(Long deviceId){
startPage();
List<Map<String, Object>> historyData = hwDeviceService.getHistoryData(deviceId);
return getDataTable(historyData);
}
/**
*
* */
@GetMapping("/monitorPercentage")
public TableDataInfo monitorPercentage(){
List<HwMonitorUnitVo> maps = hwMonitorUnitService.selectMonitorPercentage();
return getDataTable(maps);
}
/**
*
* */
@GetMapping("/allNums")
public AllNumsVo allNums(){
AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums();
return allNumsVos;
}
/**
*
* */
@GetMapping("/sceneAllNums")
public TableDataInfo sceneAllNums(){
List<AllNumsVo> allNumsVos = hwMonitorUnitService.selectSenceAllNums();
return getDataTable(allNumsVos);
}
/**
*
* */
@PostMapping("/limitSubMonitorUnit")
public TableDataInfo limitSubMonitorUnit(){
startPage();
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitService.selectLimitSubMonitorUnit();
return getDataTable(hwMonitorUnits);
}
/**
*
*/
@GetMapping("/alarmStats")
public TableDataInfo alarmStats(){
List<AlarmStatsVo> 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<EleMonitorDeviceSumVo> 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<Map<String, Object>> 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<HwScene> hwScenes = hwSceneService.selectHwSceneByTenantId(tenantId);
hwScenes.get(0).setDefaultFlag("1");
return getDataTable(hwScenes);
}
}

@ -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<HwMonitorUnit> list = hwMonitorUnitService.selectHwMonitorUnitList(hwMonitorUnit);
return getDataTable(list);
}
/**
*
* @param hwMonitorUnits
* @return list
* @throws
* */
@PostMapping("/treeList")
public TableDataInfo treeList(List<HwMonitorUnit> hwMonitorUnits){
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.
* */
@GetMapping("/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;
}
/**
*
* @param monitorUnitId id
*/
@PostMapping("/selectDeviceModeFunctionByFunctionType")
public Map<String, Map<String, Object>> selectDeviceModeFunctionByFunctionType(Long monitorUnitId){
startPage();
Map<String, Map<String, Object>> maps = hwDeviceService.selectDeviceModeFunctionByFunctionType(monitorUnitId);
return maps;
}
//
/**
*
* @param deviceId id
* */
@PostMapping("/getHistoryData")
public TableDataInfo getHistoryData(Long deviceId){
startPage();
List<Map<String, Object>> historyData = hwDeviceService.getHistoryData(deviceId);
return getDataTable(historyData);
}
/**
*
* */
@GetMapping("/monitorPercentage")
public TableDataInfo monitorPercentage(){
List<HwMonitorUnitVo> maps = hwMonitorUnitService.selectMonitorPercentage();
return getDataTable(maps);
}
/**
*
* */
@GetMapping("/allNums")
public AllNumsVo allNums(){
AllNumsVo allNumsVos = hwMonitorUnitService.selectAllNums();
return allNumsVos;
}
/**
*
* */
@GetMapping("/sceneAllNums")
public TableDataInfo sceneAllNums(){
List<AllNumsVo> allNumsVos = hwMonitorUnitService.selectSenceAllNums();
return getDataTable(allNumsVos);
}
/**
*
* */
@PostMapping("/limitSubMonitorUnit")
public TableDataInfo limitSubMonitorUnit(){
startPage();
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitService.selectLimitSubMonitorUnit();
return getDataTable(hwMonitorUnits);
}
/**
*
*/
@GetMapping("/alarmStats")
public TableDataInfo alarmStats(){
List<AlarmStatsVo> 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<EleMonitorDeviceSumVo> 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<Map<String, Object>> list= hwMonitorUnitService.selectLatestDataByTags(monitorUnitId);
// return getDataTable(list);
// }
/**
*
*/

@ -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<HwScene> list = hwSceneService.selectHwSceneList(hwScene);
List<HwSceneVo> 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;
}
}
}

@ -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<HwTenant> list = new ArrayList<HwTenant>();
startPage();
List<HwTenant> 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));
}

@ -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 +
'}';
}
}

@ -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<HwScene> selectHwSceneBySceneModeId(Long sceneModeId);
public List<HwScene> selectHwSceneByTenantId0(Long tenantId);
public List<HwScene> selectHwSceneByTenantIdNot0(Long tenantId);
/**
@ -28,6 +31,9 @@ public interface HwSceneMapper
* @return
*/
public List<HwScene> selectHwSceneList(HwScene hwScene);
List<HwSceneVo> selectHwSceneVoList(HwSceneVo hwScene);
void updateDefaultFlag(Long tenantId);
/**
*

@ -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
*/

@ -73,10 +73,10 @@ public interface IHwMonitorUnitService
* @return*/
public int selectTdengine(String beginTime,String endTime,Long sceneId);
/**
* tde
*
*
* @return*/
// public List<Map<String, Object>> selectLatestDataByTags(Long monitorUnitId);
public List<Map<String, Object>> selectLatestDataByTags(Long monitorUnitId);
/**

@ -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
*/

@ -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<HwScene> selectHwSceneBySceneModeId(Long sceneModeId);
//场景选择
List<HwScene> selectHwSceneByTenantId(Long tenantId);
/**
*
*
@ -28,6 +32,8 @@ public interface IHwSceneService
* @return
*/
public List<HwScene> selectHwSceneList(HwScene hwScene);
public List<HwSceneVo> selectHwSceneList2(HwSceneVo hwScene);
/**
*

@ -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++){

@ -229,20 +229,20 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService
//网关子设备数+非网关设备数getDeviceType()=1
}
// @Override
// public List<Map<String, Object>> selectLatestDataByTags(Long monitorUnitId) {
// List<Map<String, Object>> latestData = new ArrayList<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(monitorUnitId);
// tdSelectDto.set
// latestData = (List<Map<String, Object>>) remoteTdEgineService.getLatestData(tdSelectDto);
// }
// return latestData;
// }
@Override
public List<Map<String, Object>> selectLatestDataByTags(Long monitorUnitId) {
List<Map<String, Object>> latestData = new ArrayList<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());
latestData = (List<Map<String, Object>>) remoteTdEgineService.getLatestDataByTags(tdSelectDto);
}
return latestData;
}
//todo SysDeptServiceImpl类中的递归方法recursionFn(以实现)
@Override

@ -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<HwScene> 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<HwSceneVo> 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<HwScene> list = new ArrayList<HwScene>();
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<HwScene> list = new ArrayList<HwScene>();
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<Long> 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);
}
}

@ -26,11 +26,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="sceneEnvironment" column="scene_environment" />
<result property="sceneField" column="scene_field" />
</resultMap>
<resultMap type="HwSceneVo" id="HwSceneVoResult">
<result property="sceneId" column="scene_id" />
<result property="sceneName" column="scene_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="sceneModeId" column="scene_mode_id" />
<result property="sceneModeName" column="scene_mode_name" />
<result property="scenePic" column="scene_pic" />
<result property="defaultFlag" column="default_flag" />
<result property="sceneStatus" column="scene_status" />
<result property="authMode" column="auth_mode" />
<result property="modeAccount" column="mode_account" />
<result property="modeKey" column="mode_key" />
<result property="modeSecret" column="mode_secret" />
<result property="preserveTime" column="preserve_time" />
<result property="testPreserveTime" column="test_preserve_time" />
<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="sceneEnvironment" column="scene_environment" />
<result property="sceneField" column="scene_field" />
<result property="contactName" column="contact_name" />
<result property="contactPhone" column="contact_phone" />
</resultMap>
<sql id="selectHwSceneVo">
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
</sql>
<select id="selectHwSceneVoList" parameterType="HwSceneVo" resultMap="HwSceneVoResult">
select a.*,b.tenant_name,c.scene_mode_name from hw_scene as a
left join hw_tenant as b on a.tenant_id = b.tenant_id
left join hw_scene_mode as c on a.scene_mode_id = c.scene_mode_id
<where>
<if test="sceneName != null and sceneName != ''"> and a.scene_name like concat('%', #{sceneName}, '%')</if>
<if test="contactName != null and contactName != ''"> and b.contact_name like concat('%', #{contactName}, '%')</if>
<if test="contactPhone != null and contactPhone != ''"> and b.contact_phone like concat('%', #{contactPhone}, '%')</if>
<if test="sceneModeId != null and sceneModeId != ''"> and a.scene_mode_id = #{sceneModeId}</if>
<if test="defaultFlag != null and defaultFlag != ''"> and a.default_flag = #{defaultFlag}</if>
<if test="tenantId != null and tenantId != ''"> and a.tenant_id = #{tenantId}</if>
</where>
</select>
<select id="selectHwSceneList" parameterType="HwScene" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
<where>
@ -50,13 +89,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sceneField != null and sceneField != ''"> and scene_field = #{sceneField}</if>
</where>
</select>
<select id="selectHwSceneByTenantId0" parameterType="Long" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
where order by update_time desc
</select>
<select id="selectHwSceneByTenantIdNot0" parameterType="Long" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
where tenant_id = #{tenantId}
and
order by update_time desc
</select>
<select id="selectHwSceneBySceneId" parameterType="Long" resultMap="HwSceneResult">
<include refid="selectHwSceneVo"/>
where scene_id = #{sceneId}
</select>
<select id="selectHwSceneBySceneModeId" parameterType="Long" resultMap="HwSceneResult">
select * from hw_scene_mode where scene_mode_id = #{SceneModeId}
<include refid="selectHwSceneVo"/>
from hw_scene_mode where scene_mode_id = #{SceneModeId}
</select>
<insert id="insertHwScene" parameterType="HwScene" useGeneratedKeys="true" keyProperty="sceneId">
insert into hw_scene
@ -103,7 +152,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sceneField != null">#{sceneField},</if>
</trim>
</insert>
<update id="updateDefaultFlag" parameterType="Long">
update hw_scene
set default_flag = '0'
where tenant_id = #{tenantId}
</update>
<update id="updateHwScene" parameterType="HwScene">
update hw_scene
<trim prefix="SET" suffixOverrides=",">
@ -131,11 +184,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteHwSceneBySceneId" parameterType="Long">
delete from hw_scene where scene_id = #{sceneId}
update hw_scene set scene_status = '9' where scene_id = #{sceneId}
</delete>
<delete id="deleteHwSceneBySceneIds" parameterType="String">
delete from hw_scene where scene_id in
update hw_scene set scene_status = '9' where scene_id = in
<foreach item="sceneId" collection="array" open="(" separator="," close=")">
#{sceneId}
</foreach>

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwTenantMapper">
<resultMap type="HwTenant" id="HwTenantResult">
<result property="tenantId" column="tenant_id" />
<result property="tenantType" column="tenant_type" />
@ -31,12 +31,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHwTenantList" parameterType="HwTenant" resultMap="HwTenantResult">
<include refid="selectHwTenantVo"/>
<where>
<where>
<if test="tenantType != null and tenantType != ''"> and tenant_type = #{tenantType}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="tenantIndustry != null "> and tenant_industry = #{tenantIndustry}</if>
<if test="contactName != null and contactName != ''"> and contact_name like concat('%', #{contactName}, '%')</if>
<if test="contactPhone != null and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
<if test="contactPhone != null and contactPhone != ''"> and contact_phone like concat ('%', #{contactPhone}, '%')</if>
<if test="email != null and email != ''"> and email = #{email}</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="contactAddress != null and contactAddress != ''"> and contact_address = #{contactAddress}</if>
@ -46,12 +46,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tenantField != null and tenantField != ''"> and tenant_field = #{tenantField}</if>
</where>
</select>
<select id="selectHwTenantByTenantId" parameterType="Long" resultMap="HwTenantResult">
<include refid="selectHwTenantVo"/>
where tenant_id = #{tenantId}
</select>
<insert id="insertHwTenant" parameterType="HwTenant" useGeneratedKeys="true" keyProperty="tenantId">
insert into hw_tenant
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -119,13 +119,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteHwTenantByTenantId" parameterType="Long">
delete from hw_tenant where tenant_id = #{tenantId}
</delete>
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>
<delete id="deleteHwTenantByTenantIds" parameterType="String">
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
<foreach item="tenantId" collection="array" open="(" separator="," close=")">
#{tenantId}
</foreach>
</delete>
</mapper>
</mapper>

Loading…
Cancel
Save