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 d9fc5e3..781104c 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 @@ -39,6 +39,13 @@ public class HwDictConstants { public static final String DEVICE_STATUS_PUBLISH = "1";//设备状态:已发布 public static final String DEVICE_STATUS_TEST = "0";//设备状态:已发布 public static final String DEVICE_STATUS_DELETE = "9";//设备状态:已发布 + + public static final String DEVICE_ACTIVE_STATUS_INACTIVE = "0";//设备激活状态:未激活 + public static final String DEVICE_ACTIVE_STATUS_ACTIVE = "1";//设备激活状态:激活 + + public static final String DEVICE_ONLINE_STATUS_ONLINE = "1";//在线状态 + public static final String DEVICE_ONLINE_STATUS_OFFLINE = "0"; //离线状态 + public static final String FENCE_TYPE_DEVICE = "1";//电子围栏规则类型,设备 public static final String FENCE_TYPE_MONITOR_UNIT = "2";//电子围栏规则类型,监控单元 public static final String FENCE_TYPE_SCENE = "3";//电子围栏规则类型,场景 @@ -83,8 +90,6 @@ public class HwDictConstants { SCENE_MODE_ROUTER_MAP.put(SCENE_MODE_GPS, ROUTER_GPS); } - public static final String DEVICE_ONLINE_STATUS_ONLINE = "1";//在线状态 - public static final String DEVICE_ONLINE_STATUS_OFFLINE = "0"; //离线状态 public static final String ALARM_HANDLE_STATUS_YES = "1";//已处理 public static final String ALARM_HANDLE_STATUS_NO = "0";//未处理 diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java index 53eef7f..62e35dd 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java @@ -117,7 +117,6 @@ public class DataProcessServiceImpl implements IDataProcessService { */ key = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key) == null ? key : TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key); - System.out.println(key + "---" + value); if (value instanceof String) { String valueStr = (String) value; @@ -157,13 +156,10 @@ public class DataProcessServiceImpl implements IDataProcessService { } } - System.out.println(databaseName + "---" + tableName); tdTableVo.setDatabaseName(databaseName); tdTableVo.setTableName(tableName); tdTableVo.setSchemaFields(schemaFields); - System.out.println("longtitude:" + longitude + "latit:" + latitude); - final R insertResult = this.remoteTdEngineService.insertTable(tdTableVo); if (insertResult.getCode() == ResultEnums.SUCCESS.getCode()) { logger.info("Insert data result: {}", insertResult.getMsg()); @@ -189,20 +185,16 @@ public class DataProcessServiceImpl implements IDataProcessService { * @date 2023-09-04 14:04 */ private void checkElectronicFence(Long deviceId, Long tenantId, Long monitorUnitId, Long sceneId, Object longitude, Object latitude, Long ts) { - List hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesByDeviceId(deviceId); - if (StringUtils.isEmpty(hwElectronicFences)) { - System.out.println("---------"); - hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesByMonitorUnitId(monitorUnitId); - } - if (StringUtils.isEmpty(hwElectronicFences)) { - hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesBySceneId(sceneId); - System.out.println("---------33333"); - } + //根据设备ID、监控单元ID和场景ID获取所有的电子围栏配置。(目前先只支持场景) +// List hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesByDeviceId(deviceId); +// hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesByMonitorUnitId(monitorUnitId); + List hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesBySceneId(sceneId); if (StringUtils.isNotEmpty(hwElectronicFences)) { for (HwElectronicFence hwElectronicFence : hwElectronicFences) { HwFenceArea queryFenceArea = new HwFenceArea(); queryFenceArea.setElectronicFenceId(hwElectronicFence.getElectronicFenceId()); + //获取电子围栏下配置的区域列表 List fenceAreas = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea); String effectiveTimeFlag = hwElectronicFence.getEffectiveTimeFlag(); String triggerStatus = hwElectronicFence.getTriggerStatus(); @@ -212,6 +204,7 @@ public class DataProcessServiceImpl implements IDataProcessService { if (effectiveTimeFlag.equals(HwDictConstants.EFFECTIVE_TIME_FLAG_LONG)) { String areaShapeFlag = fenceArea.getAreaShapeFlag(); String areaRange = fenceArea.getAreaRange(); + //多边形处理 if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) { LocationVo polygonVo = new LocationVo(); polygonVo.setMarkerType(LocationVo.MARKER_TYPE_POLYGON); @@ -237,9 +230,8 @@ public class DataProcessServiceImpl implements IDataProcessService { } else if (triggerStatus.equals(HwDictConstants.ELECTRONIC_FENCE_TRIGGER_STATUS_ENTRY) && isWithin) {//如果电子围栏配置是入界,而此设备入界则报警 isAlarmed = true; } - System.out.println("iswithin" + isWithin); - } else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) { + } else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) {//圆形处理 String[] areaRangeArr = areaRange.split(","); String longitudeStr = areaRangeArr[0]; String latitudeStr = areaRangeArr[1]; @@ -276,10 +268,7 @@ public class DataProcessServiceImpl implements IDataProcessService { } }); } - - } - } } 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 2a1fe09..462f849 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 @@ -2,6 +2,7 @@ package com.ruoyi.dataprocess.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.constant.HwDictConstants; import com.ruoyi.common.core.constant.TdEngineConstants; import com.ruoyi.dataprocess.domain.HwDevice; import com.ruoyi.dataprocess.mapper.HwDeviceMapper; @@ -14,6 +15,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -50,12 +52,12 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService { List schemaFields = new ArrayList<>(); TdField onlineStatusField = new TdField(); - onlineStatusField.setFieldName("onlineStatus"); + onlineStatusField.setFieldName(TdEngineConstants.ST_TAG_ONLINESTATUS); onlineStatusField.setFieldValue(json.getInteger("connectStatus")); schemaFields.add(onlineStatusField); TdField deviceTypeField = new TdField(); - deviceTypeField.setFieldName("deviceType"); + deviceTypeField.setFieldName(TdEngineConstants.ST_TAG_DEVICETYPE); deviceTypeField.setFieldValue(json.getString("deviceType")); schemaFields.add(deviceTypeField); @@ -69,7 +71,14 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService { this.remoteTdEngineService.insertTable(tdTableVo); //更新设备当前状态信息 - hwDevice.setOnlineStatus(String.valueOf(json.getInteger("connectStatus"))); + String connectStatus = String.valueOf(json.getInteger("connectStatus")); + hwDevice.setOnlineStatus(connectStatus); + //判断如果是否是第一次连接,更新激活状态和激活时间。 + if (hwDevice.getActiveStatus().equals(HwDictConstants.DEVICE_ACTIVE_STATUS_INACTIVE)) { + hwDevice.setActiveStatus(HwDictConstants.DEVICE_ACTIVE_STATUS_ACTIVE); + hwDevice.setActiveTime(new Date()); + } + hwDeviceMapper.updateHwDevice(hwDevice); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java index 9f70fb4..cc0d60f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java @@ -165,6 +165,7 @@ public class SysUserController extends BaseController { AjaxResult ajax = AjaxResult.success(); SysRole querySysRole = new SysRole(); querySysRole.setTenantId(tenantId); + SysPost post = new SysPost(); post.setTenantId(tenantId); List roles = roleService.selectRoleAll(querySysRole); @@ -213,7 +214,7 @@ public class SysUserController extends BaseController { LoginUser loginUser = SecurityUtils.getLoginUser(); SysUser loginSysUser = loginUser.getSysUser(); //如果不是admin的租户,则就保存为登录用户的租户id,如果是adimin,则需要保存admin在创建时选择的租户ID - if(!loginSysUser.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)){ + if (!loginSysUser.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) { user.setTenantId(loginSysUser.getTenantId()); } @@ -313,7 +314,7 @@ public class SysUserController extends BaseController { @GetMapping("/deptTree") public AjaxResult deptTree(SysDept dept) { - System.out.println("ddddd:"+dept.getTenantId()); + System.out.println("ddddd:" + dept.getTenantId()); return success(deptService.selectDeptTreeList(dept)); } @@ -340,16 +341,16 @@ public class SysUserController extends BaseController { @PostMapping("/deleteUsersByTenantId/{tenantId}") public R deleteUsersByTenantId(@PathVariable Long tenantId) { Long[] userIds = userService.getUserIdsByTenantId(tenantId); - if(userIds.length == 0) { + if (userIds.length == 0) { return R.ok(); } if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) { return R.fail("当前用户不能删除"); } - try{ + try { userService.deleteUserByIds(userIds); return R.ok(); - }catch(Exception e){ + } catch (Exception e) { return R.fail(e.getMessage()); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 7bd3d01..6c1666f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -12,10 +12,7 @@ import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.domain.SysRoleDept; import com.ruoyi.system.domain.SysRoleMenu; import com.ruoyi.system.domain.SysUserRole; -import com.ruoyi.system.mapper.SysRoleDeptMapper; -import com.ruoyi.system.mapper.SysRoleMapper; -import com.ruoyi.system.mapper.SysRoleMenuMapper; -import com.ruoyi.system.mapper.SysUserRoleMapper; +import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.ISysRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -42,6 +39,8 @@ public class SysRoleServiceImpl implements ISysRoleService { @Autowired private SysRoleDeptMapper roleDeptMapper; + @Autowired + private SysUserMapper userMapper; /** * 根据条件分页查询角色数据 * @@ -63,7 +62,11 @@ public class SysRoleServiceImpl implements ISysRoleService { @Override public List selectRolesByUserId(Long userId) { List userRoles = roleMapper.selectRolePermissionByUserId(userId); - List roles = selectRoleAll(); + SysUser user = userMapper.selectUserById(userId); + Long tenantId = user.getTenantId(); + SysRole querySysRole = new SysRole(); + querySysRole.setTenantId(tenantId); + List roles = this.selectRoleAll(querySysRole); for (SysRole role : roles) { for (SysRole userRole : userRoles) { if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) { diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index a1b797e..954672e 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -312,7 +312,7 @@ :key="item.roleId" :label="item.roleName" :value="item.roleId" - :disabled="item.roleId != 3 && form.tenantId !== undefined && form.tenantId !==0" + :disabled="item.roleId != 3 && form.tenantId !== undefined && form.tenantId !==1" > @@ -603,6 +603,8 @@ export default { roleIds: [], tenantId: undefined }; + this.roleOptions = []; + this.postOptions = []; this.resetForm("form"); }, /** 搜索按钮操作 */