From 5c3f1aec4bcfe1506d065ccb55f5f660d4436b46 Mon Sep 17 00:00:00 2001 From: xins Date: Tue, 19 Sep 2023 16:05:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=A5=E4=BE=9D=E5=BE=AE=E6=9C=8D=E5=8A=A11.?= =?UTF-8?q?2.5=201=E3=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/constant/HwDictConstants.java | 2 + .../controller/HwDeviceController.java | 10 + .../controller/HwDeviceModeController.java | 28 ++- .../ruoyi/business/domain/HwDeviceMode.java | 20 ++ .../business/mapper/HwDeviceModeMapper.java | 8 + .../service/IHwDeviceModeService.java | 9 + .../business/service/IHwSceneService.java | 2 + .../service/impl/HwDeviceModeServiceImpl.java | 13 ++ .../service/impl/HwSceneServiceImpl.java | 77 ++++--- .../mapper/business/HwDeviceModeMapper.xml | 28 +++ ruoyi-ui/src/api/business/device.js | 10 +- ruoyi-ui/src/api/business/deviceMode.js | 18 +- ruoyi-ui/src/router/index.js | 28 +++ .../business/deviceMode/editDeviceMode.vue | 196 +++++++++++++++++- .../src/views/business/deviceMode/index.vue | 102 ++++----- .../electronicFence/editElectronicFence.vue | 148 +++++++++++++ .../views/business/electronicFence/index.vue | 15 +- 17 files changed, 605 insertions(+), 109 deletions(-) create mode 100644 ruoyi-ui/src/views/business/electronicFence/editElectronicFence.vue diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/HwDictConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/HwDictConstants.java index a4cd2a4..0d098d1 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/HwDictConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/HwDictConstants.java @@ -56,4 +56,6 @@ public class HwDictConstants { public static final String REDIS_KEY_DEVICE_INFO = "hw_device_info";//保存设备用户名和密码等信息的redis的key + public static final String DEVICE_MODE_STATUS_NORMAL = "1";//设备模型正常状态 + } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java index 7f70dca..594a038 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java @@ -144,6 +144,16 @@ public class HwDeviceController extends BaseController return success(hwSceneService.selectHwSceneList(scene)); } + @RequiresPermissions("business:device:list") + @GetMapping("/getEditedScenes") + public AjaxResult getEditedScenes(HwScene scene) + { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + scene.setTenantId(user.getTenantId()); + return success(hwSceneService.selectHwSceneList4Select(scene)); + } + /** * 获取监控单元树列表 */ diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java index 82875b6..cd47dca 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java @@ -8,6 +8,9 @@ import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; import com.ruoyi.business.domain.HwDeviceModeFunction; +import com.ruoyi.business.domain.HwScene; +import com.ruoyi.business.service.IHwSceneService; +import com.ruoyi.common.core.constant.HwDictConstants; import com.ruoyi.common.core.constant.SecurityConstants; import com.ruoyi.common.core.context.SecurityContextHolder; import com.ruoyi.common.security.utils.SecurityUtils; @@ -44,6 +47,9 @@ public class HwDeviceModeController extends BaseController { @Autowired private IHwDeviceModeService hwDeviceModeService; + @Autowired + private IHwSceneService hwSceneService; + /** * 查询设备模型列表 */ @@ -51,7 +57,8 @@ public class HwDeviceModeController extends BaseController { @GetMapping("/list") public TableDataInfo list(HwDeviceMode hwDeviceMode) { startPage(); - List list = hwDeviceModeService.selectHwDeviceModeList(hwDeviceMode); + hwDeviceMode.setDeviceModeStatus(HwDictConstants.DEVICE_MODE_STATUS_NORMAL); + List list = hwDeviceModeService.selectHwDeviceModeJoinList(hwDeviceMode); return getDataTable(list); } @@ -91,6 +98,10 @@ public class HwDeviceModeController extends BaseController { @Log(title = "设备模型", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody HwDeviceMode hwDeviceMode) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + hwDeviceMode.setTenantId(user.getTenantId()); + hwDeviceMode.setCreateBy(user.getUserName()); return toAjax(hwDeviceModeService.insertHwDeviceMode(hwDeviceMode)); } @@ -114,4 +125,19 @@ public class HwDeviceModeController extends BaseController { return toAjax(hwDeviceModeService.deleteHwDeviceModeByDeviceModeIds(deviceModeIds)); } + @RequiresPermissions("business:deviceMode:list") + @GetMapping("/getScenes") + public AjaxResult getScenes(HwScene scene) { + return success(hwSceneService.selectHwSceneList(scene)); + } + + @RequiresPermissions("business:deviceMode:list") + @GetMapping("/getEditedScenes") + public AjaxResult getEditedScenes(HwScene scene) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getSysUser(); + scene.setTenantId(user.getTenantId()); + return success(hwSceneService.selectHwSceneList4Select(scene)); + } + } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDeviceMode.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDeviceMode.java index e995a90..59e0759 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDeviceMode.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDeviceMode.java @@ -63,6 +63,10 @@ public class HwDeviceMode extends BaseEntity @Excel(name = "预留字段") private String deviceModeField; + private String tenantName; + + private String sceneName; + /** 设备模型功能信息 */ private List hwDeviceModeFunctionList; @@ -185,6 +189,22 @@ public class HwDeviceMode extends BaseEntity this.hwDeviceModeFunctionList = hwDeviceModeFunctionList; } + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public String getSceneName() { + return sceneName; + } + + public void setSceneName(String sceneName) { + this.sceneName = sceneName; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java index e1db335..bd3f146 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java @@ -135,4 +135,12 @@ public interface HwDeviceModeMapper */ public List selectDeviceModeParametersByModeFunctionId(Long modeFunctionId); + + /** + * 查询设备模型列表,Join租户和场景 + * + * @param hwDeviceMode 设备模型 + * @return 设备模型集合 + */ + public List selectHwDeviceModeJoinList(HwDeviceMode hwDeviceMode); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java index 7642fcd..d3d9477 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java @@ -6,6 +6,7 @@ import java.util.Map; import com.ruoyi.business.domain.HwDeviceMode; import com.ruoyi.business.domain.HwDeviceModeFunction; import com.ruoyi.business.domain.HwDeviceModeParameter; +import com.ruoyi.common.datascope.annotation.DataScope; /** * 设备模型Service接口 @@ -99,4 +100,12 @@ public interface IHwDeviceModeService */ public Map> selectDeviceModeParametersByModeFunctionId(Long modeFunctionId); + /** + * 查询设备模型列表,Join租户和场景 + * + * @param hwDeviceMode 设备模型 + * @return 设备模型 + */ + + public List selectHwDeviceModeJoinList(HwDeviceMode hwDeviceMode); } 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 093021d..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 @@ -23,6 +23,8 @@ public interface IHwSceneService public List selectHwSceneBySceneModeId(Long sceneModeId); + //场景选择 + List selectHwSceneByTenantId(Long tenantId); /** * 查询场景信息列表 * diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java index 72800c6..55e04aa 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java @@ -115,6 +115,7 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { } }); + hwDeviceMode.setCreateTime(DateUtils.getNowDate()); hwDeviceMode.setCreateBy(SecurityUtils.getUsername()); int rows = hwDeviceModeMapper.insertHwDeviceMode(hwDeviceMode); @@ -324,6 +325,18 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { return hwDeviceModeParametersMap; } + /** + * 查询设备模型列表,Join租户和场景 + * + * @param hwDeviceMode 设备模型 + * @return 设备模型 + */ + @Override + @DataScope(tenantAlias = "hdm") + public List selectHwDeviceModeJoinList(HwDeviceMode hwDeviceMode) { + return hwDeviceModeMapper.selectHwDeviceModeJoinList(hwDeviceMode); + } + /** * @param: hwDeviceModeFunction * @description 在编辑设备模型添加功能或者编辑功能时判断属性值 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 3969905..2354536 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 @@ -7,9 +7,7 @@ import java.util.List; import com.ruoyi.business.domain.HwSceneMode; import com.ruoyi.business.domain.VO.HwSceneVo; -import com.ruoyi.common.core.constant.HwDictConstants; import com.ruoyi.common.core.utils.DateUtils; -import com.ruoyi.common.datascope.annotation.DataScope; import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.SysUser; @@ -28,7 +26,8 @@ import com.ruoyi.business.service.IHwSceneService; * @date 2023-08-23 */ @Service -public class HwSceneServiceImpl implements IHwSceneService { +public class HwSceneServiceImpl implements IHwSceneService +{ @Autowired private HwSceneMapper hwSceneMapper; @Autowired @@ -42,7 +41,8 @@ public class HwSceneServiceImpl implements IHwSceneService { * @return 场景信息 */ @Override - public HwScene selectHwSceneBySceneId(Long sceneId) { + public HwScene selectHwSceneBySceneId(Long sceneId) + { return hwSceneMapper.selectHwSceneBySceneId(sceneId); } @@ -53,6 +53,17 @@ 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); + + } + + /** * 查询场景信息列表 * @@ -60,25 +71,21 @@ public class HwSceneServiceImpl implements IHwSceneService { * @return 场景信息 */ @Override - @DataScope(tenantAlias = "hs") - public List selectHwSceneList(HwScene hwScene) { - List scenes = hwSceneMapper.selectHwSceneList(hwScene); - boolean defaultFlag = false; - for (HwScene scene : scenes) { - if (defaultFlag) { - scene.setDefaultFlag(HwDictConstants.DEVICE_DEFAULT_FLAG_NO); - } else { - if (scene.getDefaultFlag().equalsIgnoreCase(HwDictConstants.DEVICE_DEFAULT_FLAG_YES)) { - defaultFlag = true; - } - } - } - return scenes; + public List selectHwSceneList(HwScene hwScene) + { + return hwSceneMapper.selectHwSceneList(hwScene); } @Override public List selectHwSceneList2(HwSceneVo hwScene) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + if (sysUser.getUserName().equals("admin")) return hwSceneMapper.selectHwSceneVoList(hwScene); + else + { + return hwSceneMapper.selectHwSceneVoListByTenantId(sysUser.getTenantId()); + } } @@ -89,9 +96,10 @@ public class HwSceneServiceImpl implements IHwSceneService { * @return 结果 */ @Override - public int insertHwScene(HwScene hwScene) { - if (hwScene.getDefaultFlag() == "1") { - hwSceneMapper.updateDefaultFlag(hwScene.getTenantId()); + public int insertHwScene(HwScene hwScene) + { + if(hwScene.getDefaultFlag() == "1"){ + hwSceneMapper.updateDefaultFlag(hwScene.getTenantId()); } hwScene.setDefaultFlag("1"); LoginUser loginUser = SecurityUtils.getLoginUser(); @@ -101,20 +109,20 @@ public class HwSceneServiceImpl implements IHwSceneService { hwScene.setSceneId(lon); hwScene.setCreateBy(sysUser.getNickName()); - if (hwScene.getPreserveTime() == null) { + if (hwScene.getPreserveTime()==null){ hwScene.setPreserveTime(new BigDecimal(90)); } - if (hwScene.getTestPreserveTime() == null) { + if (hwScene.getTestPreserveTime()==null){ hwScene.setTestPreserveTime(new BigDecimal(30)); } String randomKey = RandomStringUtils.random(12, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"); - String randomSecret = RandomStringUtils.random(16, "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); + redisService.setCacheList(hwScene.getSceneId()+"",list); return hwSceneMapper.insertHwScene(hwScene); } @@ -126,15 +134,16 @@ public class HwSceneServiceImpl implements IHwSceneService { * @return 结果 */ @Override - public int updateHwScene(HwScene hwScene) { - if (hwScene.getDefaultFlag() == "1") { + 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); + redisService.setCacheList(hwScene.getSceneId()+"",list); return hwSceneMapper.updateHwScene(hwScene); } @@ -145,12 +154,13 @@ public class HwSceneServiceImpl implements IHwSceneService { * @return 结果 */ @Override - public int deleteHwSceneBySceneIds(Long[] sceneIds) { + public int deleteHwSceneBySceneIds(Long[] sceneIds) + { List list = new ArrayList<>(); - for (int i = 0; i < sceneIds.length; i++) { + for (int i = 0; i < sceneIds.length;i++){ list.add(sceneIds[i]); } - redisService.deleteObject(sceneIds + ""); + redisService.deleteObject(sceneIds+""); return hwSceneMapper.deleteHwSceneBySceneIds(sceneIds); } @@ -161,8 +171,9 @@ public class HwSceneServiceImpl implements IHwSceneService { * @return 结果 */ @Override - public int deleteHwSceneBySceneId(Long sceneId) { - redisService.deleteObject(sceneId + ""); + public int deleteHwSceneBySceneId(Long sceneId) + { + redisService.deleteObject(sceneId+""); return hwSceneMapper.deleteHwSceneBySceneId(sceneId); } } diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml index dd765c6..3c0780e 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml @@ -22,6 +22,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -91,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ${params.tenantDataScope} + order by device_mode_id desc + + + + \ No newline at end of file diff --git a/ruoyi-ui/src/api/business/device.js b/ruoyi-ui/src/api/business/device.js index ac9c932..21adee4 100644 --- a/ruoyi-ui/src/api/business/device.js +++ b/ruoyi-ui/src/api/business/device.js @@ -45,7 +45,7 @@ export function delDevice(deviceId) { } -// 查询场景信息列表供选择使用(例如下拉列表) +// 查询场景信息列表供查询页面选择使用(例如下拉列表) export function getScenes(query) { return request({ url: '/business/device/getScenes', @@ -54,6 +54,14 @@ export function getScenes(query) { }) } +// 查询场景信息列表供编辑页面选择使用(例如下拉列表) +export function getEditedScenes(query) { + return request({ + url: '/business/device/getEditedScenes', + method: 'get', + params: query + }) +} // 查询监控单元树 export function getMonitorTree(sceneId) { diff --git a/ruoyi-ui/src/api/business/deviceMode.js b/ruoyi-ui/src/api/business/deviceMode.js index 7226b19..d44e6c8 100644 --- a/ruoyi-ui/src/api/business/deviceMode.js +++ b/ruoyi-ui/src/api/business/deviceMode.js @@ -43,6 +43,20 @@ export function delDeviceMode(deviceModeId) { }) } +// 查询场景信息列表供插叙页面选择使用(例如下拉列表) +export function getScenes(query) { + return request({ + url: '/business/deviceMode/getScenes', + method: 'get', + params: query + }) +} - - +// 查询场景信息列表供编辑页面选择使用(例如下拉列表) +export function getEditedScenes(query) { + return request({ + url: '/business/deviceMode/getEditedScenes', + method: 'get', + params: query + }) +} diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index 7045646..83d8778 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -232,6 +232,34 @@ export const dynamicRoutes = [ meta: { title: '修改设备模型', activeMenu: '/business/deviceMode' } } ] + }, + { + path: '/electronicFence/fence-add', + component: Layout, + hidden: true, + permissions: ['business:electronicFence:add'], + children: [ + { + path: 'index', + component: () => import('@/views/business/electronicFence/editElectronicFence'), + name: 'ModeAdd', + meta: { title: '添加电子围栏', activeMenu: '/business/electronicFence' } + } + ] + }, + { + path: '/electronicFence/fence-edit', + component: Layout, + hidden: true, + permissions: ['business:electronicFence:edit'], + children: [ + { + path: 'index/:electronicFenceId(\\d+)', + component: () => import('@/views/business/electronicFence/editElectronicFence'), + name: 'ModeEdit', + meta: { title: '修改电子围栏', activeMenu: '/business/electronicFence' } + } + ] } ] diff --git a/ruoyi-ui/src/views/business/deviceMode/editDeviceMode.vue b/ruoyi-ui/src/views/business/deviceMode/editDeviceMode.vue index a0239be..d3a5e07 100644 --- a/ruoyi-ui/src/views/business/deviceMode/editDeviceMode.vue +++ b/ruoyi-ui/src/views/business/deviceMode/editDeviceMode.vue @@ -62,6 +62,52 @@ + + + + + + + + +
+ 请上传 + + + 的文件 +
+ + + + +
+
+ + @@ -302,8 +348,7 @@ diff --git a/ruoyi-ui/src/views/business/deviceMode/index.vue b/ruoyi-ui/src/views/business/deviceMode/index.vue index 8d674d1..42d2da4 100644 --- a/ruoyi-ui/src/views/business/deviceMode/index.vue +++ b/ruoyi-ui/src/views/business/deviceMode/index.vue @@ -9,55 +9,36 @@ @keyup.enter.native="handleQuery" /> - - - - - - - + + - - - - + + + - + + + @@ -106,13 +87,18 @@ - - - - - - - + + + + + + + +