Commit aaf141e5 by 杨林龙

增加用户组织判断

1 parent fb0a1297
......@@ -40,6 +40,13 @@ public class HomeController {
@Autowired
private HomeService homeService;
@GetMapping("/authuserorg")
@ApiOperation(value = "用户组织鉴权")
public R<Map<String, Boolean>> authUserOrg() {
Map<String, Boolean> authUserOrgMap = homeService.authUserOrg();
return R.ok().data(authUserOrgMap);
}
@GetMapping("/getdevicenumber")
@ApiOperation(value = "查询首页统计数据")
public R<Map<String, Object>> getDeviceNumber() {
......
......@@ -15,6 +15,7 @@ import com.glsx.plat.common.utils.DateUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -50,6 +51,16 @@ public class HomeService {
private static final String PARSE_PATTERN = "yyyy-MM-dd";
public Map<String, Boolean> authUserOrg() {
Map<String, Boolean> authUserOrgMap = Maps.newHashMap();
// 判断用户是否是仲利组织
String zhongLiTenantId = PropertiesUtils.getProperty("zhongli.tenant.id");
if (StringUtils.isNotEmpty(zhongLiTenantId) && ShieldContextHolder.getTenantId() == Long.parseLong(zhongLiTenantId)) {
authUserOrgMap.put("isZhongLi", true);
}
return authUserOrgMap;
}
public Map<String, Object> getDeviceNumber() {
Map<String, Object> returnMap = new HashMap<>();
......@@ -69,16 +80,8 @@ public class HomeService {
int bindNumForToday = bindNumMap.get("bindNumForToday").intValue();
returnMap.put("bindNumForToday", bindNumForToday);
String userIdStr = PropertiesUtils.getProperty("guangqi.userId");
List<String> userIds = new ArrayList<>(Arrays.asList(userIdStr.split(",")));
Long loginUserId = ShieldContextHolder.getUserId();
// 广汽的离线和绑定单独计算
long offlineTime = 0L;
if (userIds.contains(String.valueOf(loginUserId))) {
offlineTime = Constants.OFFLINE_TIME_GQ;
} else {
offlineTime = Constants.OFFLINE_TIME_OTHER;
}
// 设备离线计算时间
long offlineTime = Constants.OFFLINE_TIME_OTHER;
//设备离线数 获取该账户权限下 所以设备号集合
List<String> sns = vehicleMapper.getAllDeviceSnByAuth();
......@@ -88,6 +91,12 @@ public class HomeService {
List<String> offlineSnList = Arrays.asList(offlineSnStr.split(","));
// 从所有设备列表中 去掉不计算离线的设备列表
sns.removeAll(offlineSnList);
// 仲利组织下显示白名单车辆数量
String zhongLiTenantId = PropertiesUtils.getProperty("zhongli.tenant.id");
if (StringUtils.isNotEmpty(zhongLiTenantId) && ShieldContextHolder.getTenantId() == Long.parseLong(zhongLiTenantId)) {
// 仲利用户显示不计算设备离线数
returnMap.put("offlineSnNum", offlineSnList.size());
}
}
// 调用警情微服务查询老E盾库中设备离线数量
......@@ -104,8 +113,6 @@ public class HomeService {
String offlineRate = numberFormat.format((float) offlineNumber / (float) allActiveNumber * 100);
returnMap.put("onlineRate", onlineRate);
returnMap.put("offlineRate", offlineRate);
// 仲利用户显示不计算设备离线数
returnMap.put("offlineSnNum", 0);
return returnMap;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!