自动化立体仓库 - WMS系统
zc
3 天以前 5c269fc28196cbc4d98ed9d18e354b58868a5b49
src/main/java/com/zy/common/utils/RoleUtils.java
@@ -14,14 +14,13 @@
 */
@Component
public class RoleUtils {
    /**
     * 以角色继承角色显示出指定库信息按堆垛机限制
     */
    public static <T> void addRoleWrapperByCrn(Long userId, EntityWrapper<T> wrapper) {
    public static <T> String outRole(Long userId) {
        // super账号
        if (userId == 9527) {
            return;
            return "all";
        }
        UserService userService = SpringUtils.getBean(UserService.class);
@@ -30,22 +29,59 @@
        // 管理员角色
        if (Cools.isEmpty(roleName)) {
            wrapper.eq("1", 0);
        } else if (roleName.equals("管理员")) {
            return;
            return "all";
        }
        // 其他角色看继承角色
        String roleLeaderCode = user.getRoleLeaderCode();
        if (Cools.isEmpty(roleLeaderCode)) {
            wrapper.eq("1", 0);
        } else if (roleLeaderCode.equals("stacker_hangar")) { // 堆垛机库
            wrapper.le("crn_no", 4); // 限制1~4号堆垛机
            return "stacker_hangar";
        } else if (roleLeaderCode.equals("four_directional_library")) { // 四向库
            wrapper.eq("crn_no", 7); // 限制7号堆垛机
            return "four_directional_library";
        } else if (roleLeaderCode.equals("ctu_library")) { // ctu库
            wrapper.in("crn_no", 8, 9); //限制8,9号堆垛机
            return "ctu_library";
        }
        return "all";
    }
    /**
     * 以角色继承角色显示出指定库信息按堆垛机限制
     */
    public static <T> void addRoleWrapperByCrn(Long userId, EntityWrapper<T> wrapper) {
        // super账号
//        if (userId == 9527) {
//            return;
//        }
//
//        UserService userService = SpringUtils.getBean(UserService.class);
//        User user = userService.selectById(userId);
//        String roleName = user.getRoleName();
//
//        // 管理员角色
//        if (Cools.isEmpty(roleName)) {
//            wrapper.eq("1", 0);
//        } else if (roleName.equals("管理员")) {
//            return;
//        }
//
//        // 其他角色看继承角色
//        String roleLeaderCode = user.getRoleLeaderCode();
//        if (Cools.isEmpty(roleLeaderCode)) {
//            wrapper.eq("1", 0);
//        } else if (roleLeaderCode.equals("stacker_hangar")) { // 堆垛机库
//            wrapper.le("crn_no", 4); // 限制1~4号堆垛机
//        } else if (roleLeaderCode.equals("four_directional_library")) { // 四向库
//            wrapper.eq("crn_no", 7); // 限制7号堆垛机
//        } else if (roleLeaderCode.equals("ctu_library")) { // ctu库
//            wrapper.in("crn_no", 8, 9); //限制8,9号堆垛机
//        }
    }
@@ -54,33 +90,33 @@
     */
    public static <T> void addRoleWrapperByLocNo(Long userId, EntityWrapper<T> wrapper) {
        // super账号
        if (userId == 9527) {
            return;
        }
        UserService userService = SpringUtils.getBean(UserService.class);
        User user = userService.selectById(userId);
        String roleName = user.getRoleName();
        // 管理员角色
        if (Cools.isEmpty(roleName)) {
            wrapper.eq("1", 0);
            return;
        } else if (roleName.equals("管理员")) {
            return;
        }
        // 其他角色看继承角色
        String roleLeaderCode = user.getRoleLeaderCode();
        if (Cools.isEmpty(roleLeaderCode)) {
            wrapper.eq("1", 0);
        } else if (roleLeaderCode.equals("stacker_hangar")) { // 堆垛机库
            wrapper.addFilter("LEFT(loc_no,2)<=16"); // 限制1~16排
        } else if (roleLeaderCode.equals("four_directional_library")) { // 四向库
            wrapper.addFilter("LEFT(loc_no,2)>=17 and LEFT(loc_no,2)<=37"); // 限制17~37排
        } else if (roleLeaderCode.equals("ctu_library")) { // ctu库
            wrapper.addFilter("LEFT(loc_no,2)>=38"); //限制38~53排
        }
//        if (userId == 9527) {
//            return;
//        }
//
//        UserService userService = SpringUtils.getBean(UserService.class);
//        User user = userService.selectById(userId);
//        String roleName = user.getRoleName();
//
//        // 管理员角色
//        if (Cools.isEmpty(roleName)) {
//            wrapper.eq("1", 0);
//            return;
//        } else if (roleName.equals("管理员")) {
//            return;
//        }
//
//        // 其他角色看继承角色
//        String roleLeaderCode = user.getRoleLeaderCode();
//        if (Cools.isEmpty(roleLeaderCode)) {
//            wrapper.eq("1", 0);
//        } else if (roleLeaderCode.equals("stacker_hangar")) { // 堆垛机库
//            wrapper.addFilter("LEFT(loc_no,2)<=16"); // 限制1~16排
//        } else if (roleLeaderCode.equals("four_directional_library")) { // 四向库
//            wrapper.addFilter("LEFT(loc_no,2)>=17 and LEFT(loc_no,2)<=37"); // 限制17~37排
//        } else if (roleLeaderCode.equals("ctu_library")) { // ctu库
//            wrapper.addFilter("LEFT(loc_no,2)>=38"); //限制38~53排
//        }
    }
@@ -89,34 +125,34 @@
     */
    public static <T> void addRoleWrapperByBarcode(Long userId, EntityWrapper<T> wrapper) {
        // super账号
        if (userId == 9527) {
            return;
        }
        UserService userService = SpringUtils.getBean(UserService.class);
        User user = userService.selectById(userId);
        String roleName = user.getRoleName();
        // 管理员角色
        if (Cools.isEmpty(roleName)) {
            wrapper.eq("1", 0);
            return;
        } else if (roleName.equals("管理员")) {
            return;
        }
        // 其他角色看继承角色
        String roleLeaderCode = user.getRoleLeaderCode();
        if (Cools.isEmpty(roleLeaderCode)) {
            wrapper.eq("1", 0);
        } else if (roleLeaderCode.equals("stacker_hangar")) { // 堆垛机库
            // TODO 堆垛机开头未确认
//            wrapper.addFilter("LEFT(zpallet,3) =''"); // 限制
        } else if (roleLeaderCode.equals("four_directional_library")) { // 四向库
            wrapper.addFilter("LEFT(zpallet,3) ='SXK'"); // 限制SXK
        } else if (roleLeaderCode.equals("ctu_library")) { // ctu库
            wrapper.addFilter("LEFT(zpallet,3) ='CTU'"); //限制CTU
        }
//        if (userId == 9527) {
//            return;
//        }
//
//        UserService userService = SpringUtils.getBean(UserService.class);
//        User user = userService.selectById(userId);
//        String roleName = user.getRoleName();
//
//        // 管理员角色
//        if (Cools.isEmpty(roleName)) {
//            wrapper.eq("1", 0);
//            return;
//        } else if (roleName.equals("管理员")) {
//            return;
//        }
//
//        // 其他角色看继承角色
//        String roleLeaderCode = user.getRoleLeaderCode();
//        if (Cools.isEmpty(roleLeaderCode)) {
//            wrapper.eq("1", 0);
//        } else if (roleLeaderCode.equals("stacker_hangar")) { // 堆垛机库
//            // TODO 堆垛机开头未确认
////            wrapper.addFilter("LEFT(zpallet,3) =''"); // 限制
//        } else if (roleLeaderCode.equals("four_directional_library")) { // 四向库
//            wrapper.addFilter("LEFT(zpallet,3) ='SXK'"); // 限制SXK
//        } else if (roleLeaderCode.equals("ctu_library")) { // ctu库
//            wrapper.addFilter("LEFT(zpallet,3) ='CTU'"); //限制CTU
//        }
    }
}