|
|
@@ -7,13 +7,12 @@ import javax.servlet.http.HttpServletResponse;
|
|
7
|
7
|
|
|
8
|
8
|
import cn.hutool.core.collection.CollUtil;
|
|
9
|
9
|
import cn.hutool.core.util.StrUtil;
|
|
10
|
|
-import com.sundot.airport.common.core.domain.entity.SysRole;
|
|
|
10
|
+import com.sundot.airport.common.core.domain.DataPermissionResult;
|
|
11
|
11
|
import com.sundot.airport.common.core.domain.entity.SysUser;
|
|
12
|
12
|
import com.sundot.airport.common.enums.CheckRecordStatusEnum;
|
|
13
|
|
-import com.sundot.airport.common.enums.RoleTypeEnum;
|
|
14
|
13
|
import com.sundot.airport.common.enums.SourceTypeEnum;
|
|
15
|
|
-import com.sundot.airport.common.utils.SecurityUtils;
|
|
16
|
14
|
import com.sundot.airport.system.service.ISysUserService;
|
|
|
15
|
+import com.sundot.airport.web.core.utils.DataPermissionUtils;
|
|
17
|
16
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
18
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
19
|
18
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -54,40 +53,27 @@ public class CheckRecordController extends BaseController {
|
|
54
|
53
|
@PreAuthorize("@ss.hasPermi('check:checkRecord:list')")
|
|
55
|
54
|
@GetMapping("/list")
|
|
56
|
55
|
public TableDataInfo list(CheckRecord checkRecord, @RequestHeader(value = "X-Request-Source", defaultValue = "mobile") String source) {
|
|
|
56
|
+ DataPermissionResult dataPermission = DataPermissionUtils.getDataPermission(getUserId(), getDeptId(), getLoginUser());
|
|
57
|
57
|
List<CheckRecord> list;
|
|
58
|
|
- List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
|
|
59
|
|
- if (CollUtil.isEmpty(roles)) {
|
|
60
|
|
- return getDataTable(Collections.emptyList());
|
|
61
|
|
- }
|
|
62
|
|
- List<String> roleKeyList = roles.stream().map(SysRole::getRoleKey).collect(Collectors.toList());
|
|
63
|
58
|
if (StrUtil.equals(SourceTypeEnum.mobile.getCode(), source)) {
|
|
64
|
59
|
startPage();
|
|
65
|
60
|
list = checkRecordService.selectCheckRecordList(checkRecord);
|
|
66
|
61
|
} else if (StrUtil.equals(SourceTypeEnum.web.getCode(), source)) {
|
|
67
|
|
- if (roleKeyList.contains(RoleTypeEnum.admin.getCode())) {
|
|
68
|
|
-
|
|
69
|
|
- } else if (roleKeyList.contains(RoleTypeEnum.test.getCode()) || roleKeyList.contains(RoleTypeEnum.zhijianke.getCode())) {
|
|
70
|
|
-
|
|
71
|
|
- } else if (roleKeyList.contains(RoleTypeEnum.jingli.getCode()) || roleKeyList.contains(RoleTypeEnum.xingzheng.getCode())) {
|
|
72
|
|
- Long deptId = SecurityUtils.getLoginUser().getDeptId();
|
|
73
|
|
- List<SysUser> sysUserList = sysUserService.selectUserByDeptId(deptId);
|
|
74
|
|
- if (CollUtil.isEmpty(sysUserList)) {
|
|
75
|
|
- return getDataTable(Collections.emptyList());
|
|
76
|
|
- }
|
|
77
|
|
- List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).distinct().collect(Collectors.toList());
|
|
78
|
|
- checkRecord.setQueryCheckerIdList(userIdList);
|
|
79
|
|
- } else if (roleKeyList.contains(RoleTypeEnum.kezhang.getCode())) {
|
|
80
|
|
- Long deptId = SecurityUtils.getLoginUser().getDeptId();
|
|
81
|
|
- List<SysUser> sysUserList = sysUserService.selectUserByDeptId(deptId);
|
|
82
|
|
- if (CollUtil.isEmpty(sysUserList)) {
|
|
|
62
|
+ switch (dataPermission.getPermissionType()) {
|
|
|
63
|
+ case ALL:
|
|
|
64
|
+ case STATION:
|
|
|
65
|
+ break;
|
|
|
66
|
+ case BRIGADE:
|
|
|
67
|
+ case DEPARTMENT:
|
|
|
68
|
+ List<SysUser> sysUserList = sysUserService.selectUserByDeptId(dataPermission.getValue());
|
|
|
69
|
+ if (CollUtil.isEmpty(sysUserList)) {
|
|
|
70
|
+ return getDataTable(Collections.emptyList());
|
|
|
71
|
+ }
|
|
|
72
|
+ List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).distinct().collect(Collectors.toList());
|
|
|
73
|
+ checkRecord.setQueryCheckerIdList(userIdList);
|
|
|
74
|
+ break;
|
|
|
75
|
+ default:
|
|
83
|
76
|
return getDataTable(Collections.emptyList());
|
|
84
|
|
- }
|
|
85
|
|
- List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).distinct().collect(Collectors.toList());
|
|
86
|
|
- checkRecord.setQueryCheckerIdList(userIdList);
|
|
87
|
|
- } else if (roleKeyList.contains(RoleTypeEnum.banzuzhang.getCode())) {
|
|
88
|
|
- return getDataTable(Collections.emptyList());
|
|
89
|
|
- } else {
|
|
90
|
|
- return getDataTable(Collections.emptyList());
|
|
91
|
77
|
}
|
|
92
|
78
|
startPage();
|
|
93
|
79
|
list = checkRecordService.selectCheckRecordList(checkRecord);
|
|
|
@@ -104,35 +90,24 @@ public class CheckRecordController extends BaseController {
|
|
104
|
90
|
@Log(title = "检查记录", businessType = BusinessType.EXPORT)
|
|
105
|
91
|
@PostMapping("/export")
|
|
106
|
92
|
public void export(HttpServletResponse response, CheckRecord checkRecord) {
|
|
|
93
|
+ DataPermissionResult dataPermission = DataPermissionUtils.getDataPermission(getUserId(), getDeptId(), getLoginUser());
|
|
107
|
94
|
List<CheckRecord> list = Collections.emptyList();
|
|
108
|
|
- List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
|
|
109
|
|
- if (CollUtil.isNotEmpty(roles)) {
|
|
110
|
|
- List<String> roleKeyList = roles.stream().map(SysRole::getRoleKey).collect(Collectors.toList());
|
|
111
|
|
- if (roleKeyList.contains(RoleTypeEnum.admin.getCode())) {
|
|
112
|
|
- list = checkRecordService.selectCheckRecordList(checkRecord);
|
|
113
|
|
- } else if (roleKeyList.contains(RoleTypeEnum.test.getCode()) || roleKeyList.contains(RoleTypeEnum.zhijianke.getCode())) {
|
|
|
95
|
+ switch (dataPermission.getPermissionType()) {
|
|
|
96
|
+ case ALL:
|
|
|
97
|
+ case STATION:
|
|
114
|
98
|
list = checkRecordService.selectCheckRecordList(checkRecord);
|
|
115
|
|
- } else if (roleKeyList.contains(RoleTypeEnum.jingli.getCode()) || roleKeyList.contains(RoleTypeEnum.xingzheng.getCode())) {
|
|
116
|
|
- Long deptId = SecurityUtils.getLoginUser().getDeptId();
|
|
117
|
|
- List<SysUser> sysUserList = sysUserService.selectUserByDeptId(deptId);
|
|
118
|
|
- if (CollUtil.isNotEmpty(sysUserList)) {
|
|
119
|
|
- List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).distinct().collect(Collectors.toList());
|
|
120
|
|
- checkRecord.setQueryCheckerIdList(userIdList);
|
|
121
|
|
- list = checkRecordService.selectCheckRecordList(checkRecord);
|
|
122
|
|
- }
|
|
123
|
|
- } else if (roleKeyList.contains(RoleTypeEnum.kezhang.getCode())) {
|
|
124
|
|
- Long deptId = SecurityUtils.getLoginUser().getDeptId();
|
|
125
|
|
- List<SysUser> sysUserList = sysUserService.selectUserByDeptId(deptId);
|
|
|
99
|
+ break;
|
|
|
100
|
+ case BRIGADE:
|
|
|
101
|
+ case DEPARTMENT:
|
|
|
102
|
+ List<SysUser> sysUserList = sysUserService.selectUserByDeptId(dataPermission.getValue());
|
|
126
|
103
|
if (CollUtil.isNotEmpty(sysUserList)) {
|
|
127
|
104
|
List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).distinct().collect(Collectors.toList());
|
|
128
|
105
|
checkRecord.setQueryCheckerIdList(userIdList);
|
|
129
|
106
|
list = checkRecordService.selectCheckRecordList(checkRecord);
|
|
130
|
107
|
}
|
|
131
|
|
- } else if (roleKeyList.contains(RoleTypeEnum.banzuzhang.getCode())) {
|
|
132
|
|
- list = Collections.emptyList();
|
|
133
|
|
- } else {
|
|
134
|
|
- list = Collections.emptyList();
|
|
135
|
|
- }
|
|
|
108
|
+ break;
|
|
|
109
|
+ default:
|
|
|
110
|
+ break;
|
|
136
|
111
|
}
|
|
137
|
112
|
ExcelUtil<CheckRecord> util = new ExcelUtil<CheckRecord>(CheckRecord.class);
|
|
138
|
113
|
util.exportExcel(response, list, "检查记录数据");
|