自动化立体仓库 - WMS系统
Administrator
5 天以前 08b4403ec8d6b69528d161cfcad80b5d64dea76c
src/main/java/com/zy/common/web/BaseController.java
@@ -38,37 +38,14 @@
    private TagService tagService;
    @Autowired
    private NodeService nodeService;
    @Autowired
    private UserLoginService userLoginService;
    protected Node getOriginNode(){
        Node node = nodeService.getTop();
        if (node == null) {
            throw new CoolException("库区数据错误");
        }
        return node;
    }
    protected Long getHostId(){
        if (getUserId() == 9527) {
            return null;
        }
        User user = getUser();
        if (user.getRoleId() == 1) {
            String hostId = String.valueOf(request.getAttribute("hostId"));
            if (Cools.isEmpty(hostId)) {
                UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId()));
                if (userLogin != null) {
                    return userLogin.getHostId();
                }
            }
            return Long.parseLong(hostId);
        } else {
            return user.getHostId();
        }
    }
    protected Long getUserId(){
        if(Cools.isEmpty(request.getAttribute("userId"))){
            return 000L;
        }
        return Long.parseLong(String.valueOf(request.getAttribute("userId")));
    }
@@ -94,11 +71,12 @@
        return tagService.getTop();
    }
    protected <T> void hostEq(EntityWrapper<T> wrapper){
        Long hostId = getHostId();
        if (hostId != null) {
            wrapper.eq("host_id", hostId);
    protected Node getOriginNode(){
        Node node = nodeService.getTop();
        if (node == null) {
            throw new CoolException("库区数据错误");
        }
        return node;
    }
    /**
@@ -184,4 +162,55 @@
            wrapper.like(columns.get(i), condition);
        }
    }
    public static boolean isJSON(String str) {
        if (Cools.isEmpty(str)) {
            return false;
        } else {
            str = str.trim();
            if (str.startsWith("{") && str.endsWith("}")) {
                return true;
            } else if (str.startsWith("[") && str.endsWith("]")) {
                return true;
            } else {
                return false;
            }
        }
    }
    protected <T> void hostEq(EntityWrapper<T> wrapper){
        Long hostId = getHostId();
        if (hostId != null) {
            wrapper.eq("host_id", hostId);
        }
    }
    protected Long getHostId(){
        if (getUserId() == 9527) {
            return null;
        }
        User user = getUser();
        if (user.getRoleId() == 1) {
            String hostId = String.valueOf(request.getAttribute("hostId"));
            if (Cools.isEmpty(hostId)) {
                UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId()));
                if (userLogin != null) {
                    //return userLogin.getHostId();
                    return 1L;
                }
            }
            return Long.parseLong(hostId);
        } else {
            return user.getHostId();
        }
    }
    public static boolean isNumber(String str){
        for (int i = str.length();--i>=0;){
            if (!Character.isDigit(str.charAt(i))){
                return false;
            }
        }
        return true;
    }
}