Commit dd9f1b35 authored by 赵啸非's avatar 赵啸非

修改设备站点名称

parent b9e1d94f
package com.mortals.xhx.base.login.interceptor;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.xhx.base.framework.config.InterceptorConfig;
import com.mortals.framework.ap.CookieService;
import com.mortals.framework.ap.SysConstains;
......@@ -13,9 +14,12 @@ import com.mortals.framework.web.interceptor.BaseInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
@Order(1)
@Component
public class AuthJsonInterceptor extends BaseInterceptor {
......@@ -35,6 +39,15 @@ public class AuthJsonInterceptor extends BaseInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
try {
if(handler instanceof HandlerMethod){
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
if (annotation != null) {
//取消校验
return true;
}
}
String uri = request.getServletPath();
if (config.needCheckAuth(uri)) {
boolean auth = this.checkAuth(request, uri, config.getSecurityKey());
......
......@@ -363,6 +363,11 @@ public class LoginController extends BaseCRUDJsonController<UserService, UserFor
return userEntity.getSiteId();
}
@Override
public String getSiteIds() {
return null;
}
@Override
public Long getCustomerJoinId() {
return null;
......
......@@ -320,6 +320,12 @@ public class UserEntity extends UserEntityExt implements IUser {
public Long getSiteId() {
return this.siteId;
}
@Override
public String getSiteIds() {
return null;
}
/**
* 设置 站点id
* @param siteId
......
package com.mortals.xhx.module.device.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DeviceOnlineStatusEnum;
......@@ -53,6 +55,28 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
super.setModuleDesc("设备");
}
@GetMapping("stat")
@UnAuth
public String stat() {
Map<String, Object> model = new HashMap();
JSONObject ret = new JSONObject();
ret.put("code", VALUE_RESULT_SUCCESS);
ret.put("msg", "统计成功!");
try {
List<DeviceEntity> deviceEntityList = this.service.find(new DeviceQuery());
Map<Boolean, Long> collect = deviceEntityList.stream().collect(Collectors.partitioningBy(item -> (item.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.在线.getValue()), Collectors.counting()));
model.put("totalCount", deviceEntityList.size());
model.put("onlineCount", collect.get(true));
model.put("offlineCount", collect.get(false));
model.put("warnCount", 0);
ret.put(KEY_RESULT_DATA, model);
} catch (Exception e) {
ret.put("code", VALUE_RESULT_FAILURE);
doException(request, "统计", model, e);
}
return ret.toJSONString();
}
@Override
protected void doListBefore(HttpServletRequest request, HttpServletResponse response, DeviceForm form, Map<String, Object> model, Context context) throws AppException {
form.getQuery().setOrderColList(new ArrayList<OrderCol>() {
......@@ -69,7 +93,7 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
this.addDict(model, "deviceOnlineStatus", paramService.getParamBySecondOrganize("Device", "deviceOnlineStatus"));
this.addDict(model, "status", paramService.getParamBySecondOrganize("Device", "status"));
this.addDict(model, "deviceFirmId", firmService.find(new FirmQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getFirmName())));
this.addDict(model, "deviceSource", paramService.getParamBySecondOrganize("Device","deviceSource"));
this.addDict(model, "deviceSource", paramService.getParamBySecondOrganize("Device", "deviceSource"));
Map<Boolean, Long> collect = this.service.find(new DeviceQuery()).stream().collect(Collectors.partitioningBy(item -> (item.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.在线.getValue()), Collectors.counting()));
model.put("onlineCount", collect.get(true));
model.put("offlineCount", collect.get(false));
......
###设备列表
GET {{baseUrl}}/device/stat
Content-Type: application/json
{}
###设备列表
POST {{baseUrl}}/device/list
Content-Type: application/json
......
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