From 634b80fb8fbf2222c09a5740f052d51d624a2d57 Mon Sep 17 00:00:00 2001 From: luyya Date: Thu, 11 Sep 2025 17:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A3=E5=9F=8E=E4=BF=AE=E6=94=B9=E5=8E=BF?= =?UTF-8?q?=E5=88=86=E5=B1=80=E7=99=BB=E5=BD=95=E5=9C=A8=E7=BA=BF=E6=95=B0?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9=E5=92=8C=E5=9B=BE=E4=B8=8A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LocationController.java | 60 ++++++++++++++----- .../service/impl/DeviceRedisServiceImpl.java | 1 + .../resources/mapper/system/SysDeptMapper.xml | 4 +- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/stwzhj-modules/wzhj-location/src/main/java/org/dromara/location/controller/LocationController.java b/stwzhj-modules/wzhj-location/src/main/java/org/dromara/location/controller/LocationController.java index 096da857..e57822ea 100644 --- a/stwzhj-modules/wzhj-location/src/main/java/org/dromara/location/controller/LocationController.java +++ b/stwzhj-modules/wzhj-location/src/main/java/org/dromara/location/controller/LocationController.java @@ -11,6 +11,7 @@ import org.apache.dubbo.config.annotation.DubboReference; import org.dromara.common.core.domain.R; import org.dromara.common.core.utils.RedisConstants; import org.dromara.common.redis.utils.RedisUtils; +import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.system.api.RemoteDeviceService; import org.dromara.system.api.domain.bo.RemoteDeviceBo; import org.dromara.system.api.domain.vo.RemoteDeviceVo; @@ -50,6 +51,8 @@ public class LocationController { * */ @PostMapping("/getAllLocation") public R getAllLocaltion(@RequestBody Map params){ + String userType = LoginHelper.getLoginUser().getUserType(); + String keys = "online_users:"; String key = null; // 在不同条件下赋值 最后根据此key取值 if(CollectionUtils.isEmpty(params)){ @@ -70,20 +73,41 @@ public class LocationController { }else { key = keys +"[1,2,3,4,5,7,8]:*"; } + + list = RedisUtils.searchAndGetKeysValues(key); list.removeAll(Collections.singleton(null)); - if ("1".equals(times)){ - List nearList = new ArrayList<>(); - for (Object o : list) { - JSONObject object = JSONUtil.parseObj(o); - Integer online = object.getInt("online"); - Long gpstime = object.getLong("gpsTime"); - if (1 == online && DateUtil.between(new Date(gpstime),new Date(), DateUnit.SECOND) roleList = new ArrayList<>(); + if (!"341800000000".equals(roleDept)){ //如果不是全市数据权限 根据截取单位 判断包含过滤 + String deptId = deptIdSub(roleDept); + for (Object o : list) { + JSONObject object = JSONUtil.parseObj(o); + String zzjgdm = object.getStr("zzjgdm"); + if (zzjgdm.contains(deptId)){ //341822440000 + roleList.add(o); + } } + }else { //全市数据权限 不用过滤 + roleList.addAll(list); } - return R.ok(nearList); + if ("1".equals(times)){ + List nearList = new ArrayList<>(); + for (Object o : roleList) { + JSONObject object = JSONUtil.parseObj(o); + Integer online = object.getInt("online"); + Long gpstime = object.getLong("gpsTime"); + if (1 == online && DateUtil.between(new Date(gpstime),new Date(), DateUnit.SECOND) nearList = new ArrayList<>(); + if ("1".equals(times)){ + List nearList = new ArrayList<>(); for (Object o : dlist) { JSONObject object = JSONUtil.parseObj(o); Integer online = object.getInt("online"); @@ -200,6 +225,7 @@ public class LocationController { * */ @PostMapping("/getObjByCondition") public R getObjByCondition(@RequestBody Map params){ + String userType = LoginHelper.getLoginUser().getUserType(); if(CollectionUtils.isEmpty(params)){ return R.fail("参数不能为空"); } @@ -210,7 +236,13 @@ public class LocationController { } if (null != params.get("zzjgdm")){ zzjgdms = params.get("zzjgdm").toString(); + }else { + if ("sys_user".equals(userType)){ + String roleDept = LoginHelper.getLoginUser().getManageDeptId(); + zzjgdms = roleDept; + } } + if (null != params.get("type")){ String type = params.get("type").toString(); RemoteDeviceBo device = new RemoteDeviceBo(); @@ -265,14 +297,14 @@ public class LocationController { public String deptIdSub(String zzjgdm){ if (zzjgdm.endsWith("0000000000")){ // 省厅 即全部 - zzjgdm = zzjgdm.substring(0,2)+"*"; + zzjgdm = zzjgdm.substring(0,2); }else if(zzjgdm.endsWith("00000000")){ //地市 - zzjgdm = zzjgdm.substring(0,4)+"*"; + zzjgdm = zzjgdm.substring(0,4); }else if(zzjgdm.endsWith("000000")){ // 分局 - zzjgdm = zzjgdm.substring(0,6)+"*"; + zzjgdm = zzjgdm.substring(0,6); }else{ // 支队 - zzjgdm = zzjgdm.substring(0,8)+"*"; + zzjgdm = zzjgdm.substring(0,8); } return zzjgdm; } diff --git a/stwzhj-modules/wzhj-system/src/main/java/org/dromara/system/service/impl/DeviceRedisServiceImpl.java b/stwzhj-modules/wzhj-system/src/main/java/org/dromara/system/service/impl/DeviceRedisServiceImpl.java index a5a768b8..affea5cf 100644 --- a/stwzhj-modules/wzhj-system/src/main/java/org/dromara/system/service/impl/DeviceRedisServiceImpl.java +++ b/stwzhj-modules/wzhj-system/src/main/java/org/dromara/system/service/impl/DeviceRedisServiceImpl.java @@ -74,6 +74,7 @@ public class DeviceRedisServiceImpl implements IDeviceRedisService { public Long countByZzjgdm(DeviceRedis deviceRedis) { LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.ne(DeviceRedis::getDeviceType,"9"); + lqw.eq(DeviceRedis::getOnline,"1"); String depts = remoteDataScopeService.getDeptAndChild(deviceRedis.getZzjgdm()); lqw.inSql(DeviceRedis::getZzjgdm,depts); return baseMapper.countByzzjgdm(lqw); diff --git a/stwzhj-modules/wzhj-system/src/main/resources/mapper/system/SysDeptMapper.xml b/stwzhj-modules/wzhj-system/src/main/resources/mapper/system/SysDeptMapper.xml index be96c75b..68bab26d 100644 --- a/stwzhj-modules/wzhj-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/stwzhj-modules/wzhj-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -176,7 +176,7 @@ LEFT JOIN (select substring(zzjgdm,1,8) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid =1 group by SUBSTRING(zzjgdm,1,8)) a on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8) - where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id = '340100000000' and dept_id like '340100%' + where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id = '341800000000' and dept_id like '341800%' union @@ -188,7 +188,7 @@ LEFT JOIN (select substring(zzjgdm,1,6) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid =1 group by SUBSTRING(zzjgdm,1,6)) a on SUBSTRING(d.dept_id,1,6) = SUBSTRING(a.zzjgdm,1,6) - where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id = '340100000000' and dept_id not like '340100%' + where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id = '341800000000' and dept_id not like '341800%' union