自动化立体仓库 - WMS系统
#
zjj
2024-11-08 d6ccd5253bd826e9b112c5d39b193d6d45a74725
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package com.zy.common.utils;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.zy.system.entity.User;
import com.zy.system.service.UserService;
import org.springframework.stereotype.Component;
 
/**
 * @author pang.jiabao
 * @description 根据角色区分不同库显示不同库存
 * @createDate 2024/11/3 14:11
 */
@Component
public class RoleUtils {
    /**
     * 以角色继承角色显示出指定库信息按堆垛机限制
     */
    public static <T> String outRole(Long userId) {
        // super账号
        if (userId == 9527) {
            return "all";
        }
 
        UserService userService = SpringUtils.getBean(UserService.class);
        User user = userService.selectById(userId);
        String roleName = user.getRoleName();
 
        // 管理员角色
        if (Cools.isEmpty(roleName)) {
 
        } else if (roleName.equals("管理员")) {
            return "all";
        }
 
        // 其他角色看继承角色
        String roleLeaderCode = user.getRoleLeaderCode();
        if (Cools.isEmpty(roleLeaderCode)) {
 
        } else if (roleLeaderCode.equals("stacker_hangar")) { // 堆垛机库
            return "stacker_hangar";
        } else if (roleLeaderCode.equals("four_directional_library")) { // 四向库
            return "four_directional_library";
        } else if (roleLeaderCode.equals("ctu_library")) { // ctu库
            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号堆垛机
        }
 
    }
 
    /**
     * 以角色继承角色显示出指定库信息按库位限制
     */
    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排
        }
    }
 
 
    /**
     * 以角色继承角色显示出指定库信息按托盘码限制
     */
    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
        }
    }
 
}