Commit e593efb0 authored by “yiyousong”'s avatar “yiyousong”
parents bc10b676 3485f2b5
...@@ -117,6 +117,11 @@ public class AuthTokenServiceImpl implements IAuthTokenService { ...@@ -117,6 +117,11 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
cacheService.select(db); cacheService.select(db);
} else { } else {
userStr = cacheService.get(userKey); userStr = cacheService.get(userKey);
//刷新token时间
UserEntity userEntity = JSONObject.parseObject(userStr, UserEntity.class);
if (!ObjectUtils.isEmpty(userEntity)) {
verifyToken(userEntity);
}
} }
if (StringUtils.isNotEmpty(userStr)) { if (StringUtils.isNotEmpty(userStr)) {
UserEntity userEntity = JSONObject.parseObject(userStr, UserEntity.class); UserEntity userEntity = JSONObject.parseObject(userStr, UserEntity.class);
......
...@@ -3,20 +3,15 @@ package com.mortals.xhx.base.system.role.web; ...@@ -3,20 +3,15 @@ package com.mortals.xhx.base.system.role.web;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery; import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* 角色资源权限 * 角色资源权限
* *
...@@ -29,7 +24,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -29,7 +24,6 @@ import javax.servlet.http.HttpServletResponse;
public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAuthService, RoleAuthEntity, Long> { public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAuthService, RoleAuthEntity, Long> {
public RoleAuthController() { public RoleAuthController() {
super.setFormClass(RoleAuthForm.class);
super.setModuleDesc("角色资源权限"); super.setModuleDesc("角色资源权限");
} }
......
/**
* 文件:RoleAuthForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
/**
* <p>Title: 角色资源权限</p>
* <p>Description: RoleAuthForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleAuthForm extends BaseCRUDFormLong<RoleAuthEntity> {
private RoleAuthEntity entity = new RoleAuthEntity();
private RoleAuthQuery query = new RoleAuthQuery();
public RoleAuthForm(){
}
@Override
public RoleAuthEntity getEntity() {
return entity;
}
public void setEntity(RoleAuthEntity entity) {
this.entity = entity;
}
@Override
public RoleAuthQuery getQuery() {
return query;
}
public void setQuery(RoleAuthQuery query) {
this.query = query;
}
}
\ No newline at end of file
...@@ -39,7 +39,6 @@ public class RoleController extends BaseCRUDJsonBodyMappingController<RoleServic ...@@ -39,7 +39,6 @@ public class RoleController extends BaseCRUDJsonBodyMappingController<RoleServic
private RoleUserService roleUserService; private RoleUserService roleUserService;
public RoleController(){ public RoleController(){
super.setFormClass(RoleForm.class);
super.setModuleDesc("角色信息"); super.setModuleDesc("角色信息");
} }
......
/**
* 文件:RoleForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleQuery;
/**
* <p>Title: 角色信息</p>
* <p>Description: RoleForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleForm extends BaseCRUDFormLong<RoleEntity> {
private RoleEntity entity = new RoleEntity();
private RoleQuery query = new RoleQuery();
/** 用户ID */
private Long userId;
public RoleForm(){
}
@Override
public RoleEntity getEntity() {
return entity;
}
public void setEntity(RoleEntity entity) {
this.entity = entity;
}
@Override
public RoleQuery getQuery() {
return query;
}
public void setQuery(RoleQuery query) {
this.query = query;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
}
\ No newline at end of file
...@@ -7,26 +7,22 @@ import com.mortals.framework.ap.SysConstains; ...@@ -7,26 +7,22 @@ import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleEntity; import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleUserEntity; import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.service.RoleService; import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService; import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -49,7 +45,6 @@ public class RoleUserController extends BaseCRUDJsonBodyMappingController<RoleUs ...@@ -49,7 +45,6 @@ public class RoleUserController extends BaseCRUDJsonBodyMappingController<RoleUs
private UserService userService; private UserService userService;
public RoleUserController() { public RoleUserController() {
super.setFormClass(RoleUserForm.class);
super.setModuleDesc("角色用户"); super.setModuleDesc("角色用户");
} }
......
/**
* 文件:RoleUserForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
/**
* <p>Title: 角色用户</p>
* <p>Description: RoleUserForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleUserForm extends BaseCRUDFormLong<RoleUserEntity> {
private RoleUserEntity entity = new RoleUserEntity();
private RoleUserQuery query = new RoleUserQuery();
public RoleUserForm(){
}
@Override
public RoleUserEntity getEntity() {
return entity;
}
public void setEntity(RoleUserEntity entity) {
this.entity = entity;
}
@Override
public RoleUserQuery getQuery() {
return query;
}
public void setQuery(RoleUserQuery query) {
this.query = query;
}
}
\ No newline at end of file
package com.mortals.xhx.module.device.web; package com.mortals.xhx.module.device.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
...@@ -51,17 +50,6 @@ public class DeviceAlarmInfoController extends BaseCRUDJsonBodyMappingController ...@@ -51,17 +50,6 @@ public class DeviceAlarmInfoController extends BaseCRUDJsonBodyMappingController
super.init(model, context); super.init(model, context);
} }
@Override
@UnAuth
public Rest<Object> list(DeviceAlarmInfoEntity query) {
return super.list(query);
}
@Override
@UnAuth
public String info(Long id) {
return super.info(id);
}
@Override @Override
protected void doListBefore(DeviceAlarmInfoEntity query, Map<String, Object> model, Context context) throws AppException { protected void doListBefore(DeviceAlarmInfoEntity query, Map<String, Object> model, Context context) throws AppException {
......
...@@ -83,11 +83,6 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -83,11 +83,6 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
super.setModuleDesc("设备"); super.setModuleDesc("设备");
} }
@Override
@UnAuth
public Rest<Object> list(DeviceEntity query) {
return super.list(query);
}
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
......
...@@ -17,6 +17,8 @@ import com.mortals.xhx.module.area.model.AreaEntity; ...@@ -17,6 +17,8 @@ import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery; import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService; import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.sitestat.model.SitestatEntity;
import com.mortals.xhx.module.sitestat.service.SitestatService;
import com.mortals.xhx.utils.SpringUtils; import com.mortals.xhx.utils.SpringUtils;
import lombok.Data; import lombok.Data;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -119,6 +121,12 @@ public class SiteTreeSelect implements Serializable { ...@@ -119,6 +121,12 @@ public class SiteTreeSelect implements Serializable {
*/ */
private List<SiteTreeSelect> children; private List<SiteTreeSelect> children;
/**
* 站点统计id
*/
private Long siteStatId;
public SiteTreeSelect() { public SiteTreeSelect() {
} }
...@@ -190,6 +198,7 @@ public class SiteTreeSelect implements Serializable { ...@@ -190,6 +198,7 @@ public class SiteTreeSelect implements Serializable {
if ("site".equals(node.getType())) { if ("site".equals(node.getType())) {
//统计当前站点下的所有在线 离线 设备总数。 //统计当前站点下的所有在线 离线 设备总数。
DeviceService deviceService = SpringUtils.getBean(DeviceService.class); DeviceService deviceService = SpringUtils.getBean(DeviceService.class);
SitestatService sitestatService = SpringUtils.getBean(SitestatService.class);
List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().siteId(DataUtil.converStr2Long(node.getId(), -1))); List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().siteId(DataUtil.converStr2Long(node.getId(), -1)));
node.setDeviceTotal(deviceList.size()); node.setDeviceTotal(deviceList.size());
//未激活数量 //未激活数量
...@@ -211,8 +220,13 @@ public class SiteTreeSelect implements Serializable { ...@@ -211,8 +220,13 @@ public class SiteTreeSelect implements Serializable {
.filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue()) .filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue())
.count(); .count();
node.setOfflineTotal(deviceOfflineCount.intValue()); node.setOfflineTotal(deviceOfflineCount.intValue());
}
//设置统计id
SitestatEntity sitestatCache = sitestatService.getExtCache(node.getSiteCode());
if (!ObjectUtils.isEmpty(sitestatCache)) {
node.setSiteStatId(sitestatCache.getId());
}
}
sitePdu.setAreaCode(node.getAreaCode()); sitePdu.setAreaCode(node.getAreaCode());
Rest<Integer> rest = siteFeign.countSitesByArea(sitePdu); Rest<Integer> rest = siteFeign.countSitesByArea(sitePdu);
if (rest.getCode() == YesNoEnum.YES.getValue()) { if (rest.getCode() == YesNoEnum.YES.getValue()) {
...@@ -220,7 +234,7 @@ public class SiteTreeSelect implements Serializable { ...@@ -220,7 +234,7 @@ public class SiteTreeSelect implements Serializable {
} }
JSONArray jsonArray = jsonObject.getJSONArray("children"); JSONArray jsonArray = jsonObject.getJSONArray("children");
List<SiteTreeSelect> children = new ArrayList<>(); List<SiteTreeSelect> children = new ArrayList<>();
if(!ObjectUtils.isEmpty(jsonArray)){ if (!ObjectUtils.isEmpty(jsonArray)) {
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
SiteTreeSelect child = JSON.parseObject(jsonArray.getJSONObject(i).toJSONString(), SiteTreeSelect.class); SiteTreeSelect child = JSON.parseObject(jsonArray.getJSONObject(i).toJSONString(), SiteTreeSelect.class);
children.add(child); children.add(child);
......
package com.mortals.xhx.module.sitestat.service; package com.mortals.xhx.module.sitestat.service;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.sitestat.model.SitestatEntity; import com.mortals.xhx.module.sitestat.model.SitestatEntity;
import java.util.List;
/** /**
* SitestatService * SitestatService
* *
...@@ -14,7 +12,7 @@ import java.util.List; ...@@ -14,7 +12,7 @@ import java.util.List;
* @author zxfei * @author zxfei
* @date 2022-06-27 * @date 2022-06-27
*/ */
public interface SitestatService extends ICRUDService<SitestatEntity,Long>{ public interface SitestatService extends ICRUDCacheService<SitestatEntity,Long> {
String getSiteTree(Context context); String getSiteTree(Context context);
......
...@@ -9,7 +9,7 @@ import com.mortals.framework.exception.AppException; ...@@ -9,7 +9,7 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.xhx.common.code.DeviceStatusEnum; import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.code.PlatformTypeEnum; import com.mortals.xhx.common.code.PlatformTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
...@@ -48,7 +48,7 @@ import static com.mortals.xhx.common.key.ErrorCode.ERROR_TOKEN_EXPIRED_CONTENT; ...@@ -48,7 +48,7 @@ import static com.mortals.xhx.common.key.ErrorCode.ERROR_TOKEN_EXPIRED_CONTENT;
*/ */
@Service("sitestatService") @Service("sitestatService")
@Slf4j @Slf4j
public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, SitestatEntity, Long> implements SitestatService { public class SitestatServiceImpl extends AbstractCRUDCacheServiceImpl<SitestatDao, SitestatEntity, Long> implements SitestatService {
@Autowired @Autowired
private ISiteFeign siteFeign; private ISiteFeign siteFeign;
...@@ -59,6 +59,12 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -59,6 +59,12 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
@Value("${platform.type:cloud}") @Value("${platform.type:cloud}")
private String platFormType;//版本,默认云服务版本 private String platFormType;//版本,默认云服务版本
@Override
protected String getExtKey(SitestatEntity data) {
return data.getSiteCode();
}
/** /**
* 重写带分页的方法 * 重写带分页的方法
* *
...@@ -72,7 +78,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -72,7 +78,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
public Result<SitestatEntity> find(SitestatEntity entity, PageInfo pageInfo, Context context) throws AppException { public Result<SitestatEntity> find(SitestatEntity entity, PageInfo pageInfo, Context context) throws AppException {
Result<SitestatEntity> res = new Result<>(); Result<SitestatEntity> res = new Result<>();
//根据站点查询所以站点子集列表 //根据站点查询所以站点子集列表
Result<SitestatEntity> sitestatsAreaResult = getSitestatEntityResultByArea(entity, pageInfo,context, res); Result<SitestatEntity> sitestatsAreaResult = getSitestatEntityResultByArea(entity, pageInfo, context, res);
if (sitestatsAreaResult != null) return sitestatsAreaResult; if (sitestatsAreaResult != null) return sitestatsAreaResult;
Result<SitestatEntity> sitestatsResult = getSitestatsResult(entity, pageInfo, res); Result<SitestatEntity> sitestatsResult = getSitestatsResult(entity, pageInfo, res);
...@@ -87,7 +93,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -87,7 +93,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
if (ObjectUtils.isEmpty(entity.getSiteId())) return null; if (ObjectUtils.isEmpty(entity.getSiteId())) return null;
if (platFormType.equalsIgnoreCase(PlatformTypeEnum.STANDALONE.getValue())) { if (platFormType.equalsIgnoreCase(PlatformTypeEnum.STANDALONE.getValue())) {
//根据返回的id 筛选列表 //根据返回的id 筛选列表
Map<Long, SitestatEntity> collectMap = this.find(new SitestatEntity(), context).stream().collect(Collectors.toMap(x->x.getSiteId(),y->y,(o,n)->n)); Map<Long, SitestatEntity> collectMap = this.find(new SitestatEntity(), context).stream().collect(Collectors.toMap(x -> x.getSiteId(), y -> y, (o, n) -> n));
List<SitestatEntity> list = this.siteService.find(new SiteQuery().id(entity.getSiteId())).stream().filter(f -> collectMap.containsKey(f.getId())).map(m -> collectMap.get(m.getId())).collect(Collectors.toList()); List<SitestatEntity> list = this.siteService.find(new SiteQuery().id(entity.getSiteId())).stream().filter(f -> collectMap.containsKey(f.getId())).map(m -> collectMap.get(m.getId())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(entity.getSiteName())) { if (!ObjectUtils.isEmpty(entity.getSiteName())) {
list = MemoryPagination.search(entity.getSiteName(), list); list = MemoryPagination.search(entity.getSiteName(), list);
...@@ -103,7 +109,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -103,7 +109,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
// log.info("siteList:{}",JSON.toJSONString(result)); // log.info("siteList:{}",JSON.toJSONString(result));
if (result.getCode() == YesNoEnum.YES.getValue()) { if (result.getCode() == YesNoEnum.YES.getValue()) {
//根据返回的id 筛选列表 //根据返回的id 筛选列表
Map<Long, SitestatEntity> collectMap = this.find(new SitestatEntity(), context).stream().collect(Collectors.toMap(x->x.getSiteId(),y->y,(o,n)->n)); Map<Long, SitestatEntity> collectMap = this.find(new SitestatEntity(), context).stream().collect(Collectors.toMap(x -> x.getSiteId(), y -> y, (o, n) -> n));
List<SitestatEntity> list = result.getData().stream().filter(f -> collectMap.containsKey(f.getId())).map(m -> collectMap.get(m.getId())).collect(Collectors.toList()); List<SitestatEntity> list = result.getData().stream().filter(f -> collectMap.containsKey(f.getId())).map(m -> collectMap.get(m.getId())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(entity.getSiteName())) { if (!ObjectUtils.isEmpty(entity.getSiteName())) {
list = MemoryPagination.search(entity.getSiteName(), list); list = MemoryPagination.search(entity.getSiteName(), list);
...@@ -187,7 +193,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -187,7 +193,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
if (ObjectUtils.isEmpty(entity.getAreaCode())) return null; if (ObjectUtils.isEmpty(entity.getAreaCode())) return null;
if (platFormType.equalsIgnoreCase(PlatformTypeEnum.STANDALONE.getValue())) { if (platFormType.equalsIgnoreCase(PlatformTypeEnum.STANDALONE.getValue())) {
//根据返回的id 筛选列表 todo //根据返回的id 筛选列表 todo
Map<Long, SitestatEntity> collectMap = this.find(new SitestatEntity(), context).stream().collect(Collectors.toMap(x->x.getSiteId(),y->y,(o,n)->n)); Map<Long, SitestatEntity> collectMap = this.find(new SitestatEntity(), context).stream().collect(Collectors.toMap(x -> x.getSiteId(), y -> y, (o, n) -> n));
List<SitestatEntity> list = this.siteService.find(new SiteQuery().id(entity.getSiteId())).stream().filter(f -> collectMap.containsKey(f.getId())).map(m -> collectMap.get(m.getId())).collect(Collectors.toList()); List<SitestatEntity> list = this.siteService.find(new SiteQuery().id(entity.getSiteId())).stream().filter(f -> collectMap.containsKey(f.getId())).map(m -> collectMap.get(m.getId())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(entity.getSiteName())) { if (!ObjectUtils.isEmpty(entity.getSiteName())) {
list = MemoryPagination.search(entity.getSiteName(), list); list = MemoryPagination.search(entity.getSiteName(), list);
...@@ -201,10 +207,10 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -201,10 +207,10 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
List<String> areaCodeList = new ArrayList<>(); List<String> areaCodeList = new ArrayList<>();
sitePdu.setAreaCode(entity.getAreaCode()); sitePdu.setAreaCode(entity.getAreaCode());
Rest<List<SitePdu>> result = siteFeign.getFlatSitesByAreaCode(sitePdu); Rest<List<SitePdu>> result = siteFeign.getFlatSitesByAreaCode(sitePdu);
log.info("areaSiteList:{}",JSON.toJSONString(result)); log.info("areaSiteList:{}", JSON.toJSONString(result));
if (result.getCode() == YesNoEnum.YES.getValue()) { if (result.getCode() == YesNoEnum.YES.getValue()) {
//根据返回的id 筛选列表 //根据返回的id 筛选列表
Map<Long, SitestatEntity> collectMap = this.find(new SitestatEntity(), context).stream().collect(Collectors.toMap(x->x.getSiteId(),y->y,(o,n)->n)); Map<Long, SitestatEntity> collectMap = this.find(new SitestatEntity(), context).stream().collect(Collectors.toMap(x -> x.getSiteId(), y -> y, (o, n) -> n));
List<SitestatEntity> list = result.getData().stream().filter(f -> collectMap.containsKey(f.getId())).map(m -> collectMap.get(m.getId())).collect(Collectors.toList()); List<SitestatEntity> list = result.getData().stream().filter(f -> collectMap.containsKey(f.getId())).map(m -> collectMap.get(m.getId())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(entity.getSiteName())) { if (!ObjectUtils.isEmpty(entity.getSiteName())) {
list = MemoryPagination.search(entity.getSiteName(), list); list = MemoryPagination.search(entity.getSiteName(), list);
...@@ -226,17 +232,13 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -226,17 +232,13 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
public String getSiteTree(Context context) { public String getSiteTree(Context context) {
if (platFormType.equalsIgnoreCase(PlatformTypeEnum.CLOUD.getValue())) { if (platFormType.equalsIgnoreCase(PlatformTypeEnum.CLOUD.getValue())) {
String token = context.getUser().getToken(); String token = context.getUser().getToken();
/* if (!ObjectUtils.isEmpty(token)) {
String resp = siteFeign.siteTree(token);
return resp;
}*/
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<>(); Map<String, Object> model = new HashMap<>();
if (!ObjectUtils.isEmpty(token)) { if (!ObjectUtils.isEmpty(token)) {
String resp = siteFeign.siteTree(token); String resp = siteFeign.siteTree(token);
Rest<String> rest = JSON.parseObject(resp, new TypeReference<Rest<String>>() { Rest<String> rest = JSON.parseObject(resp, new TypeReference<Rest<String>>() {
}); });
if(rest.getCode()==YesNoEnum.YES.getValue()){ if (rest.getCode() == YesNoEnum.YES.getValue()) {
String siteTreeSelectStr = rest.getData(); String siteTreeSelectStr = rest.getData();
JSONObject json = JSON.parseObject(siteTreeSelectStr); JSONObject json = JSON.parseObject(siteTreeSelectStr);
JSONArray jsonArray = json.getJSONArray("siteTree"); JSONArray jsonArray = json.getJSONArray("siteTree");
...@@ -313,7 +315,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si ...@@ -313,7 +315,7 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
public static void main(String[] args) { public static void main(String[] args) {
String siteTreeSelectStr="[{\"areaCode\":\"511500000000\",\"children\":[{\"areaCode\":\"511502000000\",\"children\":[{\"areaCode\":\"511502012000\",\"children\":[{\"areaCode\":\"511502012001\",\"icon\":\"el-icon-wind-power\",\"id\":\"4\",\"isLeaf\":true,\"label\":\"东街站点\",\"latitude\":\"2\",\"longitude\":\"1\",\"siteCode\":\"511502012001-0001\",\"type\":\"site\"}],\"icon\":\"el-icon-place\",\"id\":\"1b01f5486d63467aaa24eafbee797b47\",\"isLeaf\":false,\"label\":\"合江门街道\",\"type\":\"area\"}],\"icon\":\"el-icon-wind-power\",\"id\":\"2\",\"isLeaf\":false,\"label\":\"翠屏区市民中心\",\"latitude\":\"31.467450\",\"longitude\":\"104.679114\",\"siteCode\":\"511502000000-0001\",\"type\":\"site\"},{\"areaCode\":\"511521000000\",\"children\":[],\"icon\":\"el-icon-wind-power\",\"id\":\"3\",\"isLeaf\":false,\"label\":\"徐州区办事处\",\"latitude\":\"28.758065\",\"longitude\":\"104.647877\",\"siteCode\":\"511521000000-0001\",\"type\":\"site\"}],\"icon\":\"el-icon-wind-power\",\"id\":\"1\",\"isLeaf\":false,\"label\":\"四川恒升信达科技有限公司\",\"latitude\":\"30.595081\",\"longitude\":\"104.062983\",\"siteCode\":\"511500000000-0001\",\"type\":\"site\"}]"; String siteTreeSelectStr = "[{\"areaCode\":\"511500000000\",\"children\":[{\"areaCode\":\"511502000000\",\"children\":[{\"areaCode\":\"511502012000\",\"children\":[{\"areaCode\":\"511502012001\",\"icon\":\"el-icon-wind-power\",\"id\":\"4\",\"isLeaf\":true,\"label\":\"东街站点\",\"latitude\":\"2\",\"longitude\":\"1\",\"siteCode\":\"511502012001-0001\",\"type\":\"site\"}],\"icon\":\"el-icon-place\",\"id\":\"1b01f5486d63467aaa24eafbee797b47\",\"isLeaf\":false,\"label\":\"合江门街道\",\"type\":\"area\"}],\"icon\":\"el-icon-wind-power\",\"id\":\"2\",\"isLeaf\":false,\"label\":\"翠屏区市民中心\",\"latitude\":\"31.467450\",\"longitude\":\"104.679114\",\"siteCode\":\"511502000000-0001\",\"type\":\"site\"},{\"areaCode\":\"511521000000\",\"children\":[],\"icon\":\"el-icon-wind-power\",\"id\":\"3\",\"isLeaf\":false,\"label\":\"徐州区办事处\",\"latitude\":\"28.758065\",\"longitude\":\"104.647877\",\"siteCode\":\"511521000000-0001\",\"type\":\"site\"}],\"icon\":\"el-icon-wind-power\",\"id\":\"1\",\"isLeaf\":false,\"label\":\"四川恒升信达科技有限公司\",\"latitude\":\"30.595081\",\"longitude\":\"104.062983\",\"siteCode\":\"511500000000-0001\",\"type\":\"site\"}]";
JSONArray jsonArray = JSON.parseArray(siteTreeSelectStr); JSONArray jsonArray = JSON.parseArray(siteTreeSelectStr);
......
...@@ -54,6 +54,9 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest ...@@ -54,6 +54,9 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
} }
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
super.init(model, context); super.init(model, context);
......
...@@ -55,6 +55,15 @@ Content-Type: application/json ...@@ -55,6 +55,15 @@ Content-Type: application/json
"id": "3" "id": "3"
} }
###设备查看
POST {{baseUrl}}/device/maplist
Accept: application/json
Content-Type: application/json
{
"siteId": 1
}
###设备告警统计查看 ###设备告警统计查看
POST {{baseUrl}}/device/alarm/info/stats POST {{baseUrl}}/device/alarm/info/stats
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment