宣城修改县分局登录在线数不对和图上数据全部展示问题

ds-xuancheng
luyya 2025-09-11 17:47:23 +08:00
parent 57f6441457
commit 634b80fb8f
3 changed files with 49 additions and 16 deletions

View File

@ -11,6 +11,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.core.utils.RedisConstants; import org.dromara.common.core.utils.RedisConstants;
import org.dromara.common.redis.utils.RedisUtils; 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.RemoteDeviceService;
import org.dromara.system.api.domain.bo.RemoteDeviceBo; import org.dromara.system.api.domain.bo.RemoteDeviceBo;
import org.dromara.system.api.domain.vo.RemoteDeviceVo; import org.dromara.system.api.domain.vo.RemoteDeviceVo;
@ -50,6 +51,8 @@ public class LocationController {
* */ * */
@PostMapping("/getAllLocation") @PostMapping("/getAllLocation")
public R getAllLocaltion(@RequestBody Map<String,Object> params){ public R getAllLocaltion(@RequestBody Map<String,Object> params){
String userType = LoginHelper.getLoginUser().getUserType();
String keys = "online_users:"; String keys = "online_users:";
String key = null; // 在不同条件下赋值 最后根据此key取值 String key = null; // 在不同条件下赋值 最后根据此key取值
if(CollectionUtils.isEmpty(params)){ if(CollectionUtils.isEmpty(params)){
@ -70,20 +73,41 @@ public class LocationController {
}else { }else {
key = keys +"[1,2,3,4,5,7,8]:*"; key = keys +"[1,2,3,4,5,7,8]:*";
} }
list = RedisUtils.searchAndGetKeysValues(key); list = RedisUtils.searchAndGetKeysValues(key);
list.removeAll(Collections.singleton(null)); list.removeAll(Collections.singleton(null));
if ("1".equals(times)){
List<Object> nearList = new ArrayList<>(); if ("sys_user".equals(userType)){ //如果是系统用户 根据权限过滤自己单位下的数据
for (Object o : list) { String roleDept = LoginHelper.getLoginUser().getManageDeptId();
JSONObject object = JSONUtil.parseObj(o); List<Object> roleList = new ArrayList<>();
Integer online = object.getInt("online"); if (!"341800000000".equals(roleDept)){ //如果不是全市数据权限 根据截取单位 判断包含过滤
Long gpstime = object.getLong("gpsTime"); String deptId = deptIdSub(roleDept);
if (1 == online && DateUtil.between(new Date(gpstime),new Date(), DateUnit.SECOND)<pointTime){ for (Object o : list) {
nearList.add(o); 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<Object> 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)<pointTime){
nearList.add(o);
}
}
return R.ok(nearList);
}
return R.ok(roleList);
} }
return R.ok(list); return R.ok(list);
} }
@ -125,7 +149,8 @@ public class LocationController {
dlist.addAll(matchedObjects); dlist.addAll(matchedObjects);
} }
JSONArray.toJSONString(dlist); JSONArray.toJSONString(dlist);
if ("1".equals(times)){ List<Object> nearList = new ArrayList<>(); if ("1".equals(times)){
List<Object> nearList = new ArrayList<>();
for (Object o : dlist) { for (Object o : dlist) {
JSONObject object = JSONUtil.parseObj(o); JSONObject object = JSONUtil.parseObj(o);
Integer online = object.getInt("online"); Integer online = object.getInt("online");
@ -200,6 +225,7 @@ public class LocationController {
* */ * */
@PostMapping("/getObjByCondition") @PostMapping("/getObjByCondition")
public R getObjByCondition(@RequestBody Map<String,Object> params){ public R getObjByCondition(@RequestBody Map<String,Object> params){
String userType = LoginHelper.getLoginUser().getUserType();
if(CollectionUtils.isEmpty(params)){ if(CollectionUtils.isEmpty(params)){
return R.fail("参数不能为空"); return R.fail("参数不能为空");
} }
@ -210,7 +236,13 @@ public class LocationController {
} }
if (null != params.get("zzjgdm")){ if (null != params.get("zzjgdm")){
zzjgdms = params.get("zzjgdm").toString(); zzjgdms = params.get("zzjgdm").toString();
}else {
if ("sys_user".equals(userType)){
String roleDept = LoginHelper.getLoginUser().getManageDeptId();
zzjgdms = roleDept;
}
} }
if (null != params.get("type")){ if (null != params.get("type")){
String type = params.get("type").toString(); String type = params.get("type").toString();
RemoteDeviceBo device = new RemoteDeviceBo(); RemoteDeviceBo device = new RemoteDeviceBo();
@ -265,14 +297,14 @@ public class LocationController {
public String deptIdSub(String zzjgdm){ public String deptIdSub(String zzjgdm){
if (zzjgdm.endsWith("0000000000")){ // 省厅 即全部 if (zzjgdm.endsWith("0000000000")){ // 省厅 即全部
zzjgdm = zzjgdm.substring(0,2)+"*"; zzjgdm = zzjgdm.substring(0,2);
}else if(zzjgdm.endsWith("00000000")){ //地市 }else if(zzjgdm.endsWith("00000000")){ //地市
zzjgdm = zzjgdm.substring(0,4)+"*"; zzjgdm = zzjgdm.substring(0,4);
}else if(zzjgdm.endsWith("000000")){ // 分局 }else if(zzjgdm.endsWith("000000")){ // 分局
zzjgdm = zzjgdm.substring(0,6)+"*"; zzjgdm = zzjgdm.substring(0,6);
}else{ // 支队 }else{ // 支队
zzjgdm = zzjgdm.substring(0,8)+"*"; zzjgdm = zzjgdm.substring(0,8);
} }
return zzjgdm; return zzjgdm;
} }

View File

@ -74,6 +74,7 @@ public class DeviceRedisServiceImpl implements IDeviceRedisService {
public Long countByZzjgdm(DeviceRedis deviceRedis) { public Long countByZzjgdm(DeviceRedis deviceRedis) {
LambdaQueryWrapper<DeviceRedis> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DeviceRedis> lqw = new LambdaQueryWrapper<>();
lqw.ne(DeviceRedis::getDeviceType,"9"); lqw.ne(DeviceRedis::getDeviceType,"9");
lqw.eq(DeviceRedis::getOnline,"1");
String depts = remoteDataScopeService.getDeptAndChild(deviceRedis.getZzjgdm()); String depts = remoteDataScopeService.getDeptAndChild(deviceRedis.getZzjgdm());
lqw.inSql(DeviceRedis::getZzjgdm,depts); lqw.inSql(DeviceRedis::getZzjgdm,depts);
return baseMapper.countByzzjgdm(lqw); return baseMapper.countByzzjgdm(lqw);

View File

@ -176,7 +176,7 @@
LEFT JOIN 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 (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) 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 union
@ -188,7 +188,7 @@
LEFT JOIN 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 (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) 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 union
<!--派出所等三级四级机构--> <!--派出所等三级四级机构-->