|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+package com.sundot.airport.web.controller.system;
|
|
|
2
|
+
|
|
|
3
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
4
|
+import cn.hutool.core.util.StrUtil;
|
|
|
5
|
+import com.sundot.airport.check.service.ICheckLargeScreenService;
|
|
|
6
|
+import com.sundot.airport.common.core.controller.BaseController;
|
|
|
7
|
+import com.sundot.airport.common.core.domain.AjaxResult;
|
|
|
8
|
+import com.sundot.airport.common.core.domain.BaseLargeScreenQueryParamDto;
|
|
|
9
|
+import com.sundot.airport.common.core.domain.DataPermissionResult;
|
|
|
10
|
+import com.sundot.airport.common.core.domain.SysHomePageDetailDto;
|
|
|
11
|
+import com.sundot.airport.common.core.domain.SysHomePageDetailQueryParamDto;
|
|
|
12
|
+import com.sundot.airport.common.core.domain.SysHomePageRankingDto;
|
|
|
13
|
+import com.sundot.airport.common.core.domain.entity.SysDept;
|
|
|
14
|
+import com.sundot.airport.common.enums.DataPermissionType;
|
|
|
15
|
+import com.sundot.airport.common.enums.DeptType;
|
|
|
16
|
+import com.sundot.airport.common.enums.DeptTypeEnum;
|
|
|
17
|
+import com.sundot.airport.common.enums.HomePageQueryEnum;
|
|
|
18
|
+import com.sundot.airport.common.enums.SourceTypeEnum;
|
|
|
19
|
+import com.sundot.airport.common.exception.ServiceException;
|
|
|
20
|
+import com.sundot.airport.system.service.ISysDeptService;
|
|
|
21
|
+import com.sundot.airport.system.service.ISysLearningGrowthService;
|
|
|
22
|
+import com.sundot.airport.web.core.utils.DataPermissionUtils;
|
|
|
23
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
24
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
25
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
26
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
27
|
+import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
28
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
29
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
30
|
+
|
|
|
31
|
+import java.math.BigDecimal;
|
|
|
32
|
+import java.math.RoundingMode;
|
|
|
33
|
+import java.util.ArrayList;
|
|
|
34
|
+import java.util.Collections;
|
|
|
35
|
+import java.util.List;
|
|
|
36
|
+import java.util.stream.Collectors;
|
|
|
37
|
+
|
|
|
38
|
+/**
|
|
|
39
|
+ * 首页
|
|
|
40
|
+ *
|
|
|
41
|
+ * @author ruoyi
|
|
|
42
|
+ */
|
|
|
43
|
+@RestController
|
|
|
44
|
+@RequestMapping("/system/homePage")
|
|
|
45
|
+public class SysHomePageController extends BaseController {
|
|
|
46
|
+
|
|
|
47
|
+ @Autowired
|
|
|
48
|
+ private ISysDeptService deptService;
|
|
|
49
|
+
|
|
|
50
|
+ @Autowired
|
|
|
51
|
+ private ICheckLargeScreenService checkLargeScreenService;
|
|
|
52
|
+
|
|
|
53
|
+ @Autowired
|
|
|
54
|
+ private ISysLearningGrowthService sysLearningGrowthService;
|
|
|
55
|
+
|
|
|
56
|
+ /**
|
|
|
57
|
+ * 首页-排名
|
|
|
58
|
+ */
|
|
|
59
|
+ @GetMapping("/homePageRanking")
|
|
|
60
|
+ public AjaxResult homePageRanking(BaseLargeScreenQueryParamDto dto) {
|
|
|
61
|
+ SysHomePageRankingDto result = new SysHomePageRankingDto();
|
|
|
62
|
+ result.setCheckLargeScreenHomePageRankingDto(checkLargeScreenService.checkRanking(dto));
|
|
|
63
|
+ return success(result);
|
|
|
64
|
+ }
|
|
|
65
|
+
|
|
|
66
|
+ /**
|
|
|
67
|
+ * 首页-整体
|
|
|
68
|
+ */
|
|
|
69
|
+ @GetMapping("/homePageWhole")
|
|
|
70
|
+ public AjaxResult homePageWhole(BaseLargeScreenQueryParamDto dto, @RequestHeader(value = "X-Request-Source", defaultValue = "mobile") String source) {
|
|
|
71
|
+ List<SysHomePageDetailQueryParamDto> dtoList = new ArrayList<>();
|
|
|
72
|
+ if (StrUtil.equals(SourceTypeEnum.mobile.getCode(), source)) {
|
|
|
73
|
+ DataPermissionResult dataPermission = DataPermissionUtils.getDataPermission(getUserId(), getDeptId(), getLoginUser());
|
|
|
74
|
+ if (DataPermissionType.SELF == dataPermission.getPermissionType()) {
|
|
|
75
|
+ SysHomePageDetailQueryParamDto userDto = new SysHomePageDetailQueryParamDto();
|
|
|
76
|
+ userDto.setId(getUserId());
|
|
|
77
|
+ userDto.setName(getLoginUser().getUser().getNickName());
|
|
|
78
|
+ userDto.setType(HomePageQueryEnum.USER.getCode());
|
|
|
79
|
+ dtoList.add(userDto);
|
|
|
80
|
+ List<SysDept> deptList = deptService.selectAllDept(getDeptId());
|
|
|
81
|
+ SysDept team = deptList.stream().filter(item -> StrUtil.equals(DeptType.TEAMS.getCode(), item.getDeptType())).findFirst().orElse(null);
|
|
|
82
|
+ SysDept department = deptList.stream().filter(item -> StrUtil.equals(DeptType.MANAGER.getCode(), item.getDeptType())).findFirst().orElse(null);
|
|
|
83
|
+ SysDept brigade = deptList.stream().filter(item -> StrUtil.equals(DeptType.BRIGADE.getCode(), item.getDeptType())).findFirst().orElse(null);
|
|
|
84
|
+ SysDept station = deptList.stream().filter(item -> StrUtil.equals(DeptType.STATION.getCode(), item.getDeptType())).findFirst().orElse(null);
|
|
|
85
|
+ if (ObjectUtil.isNotNull(team)) {
|
|
|
86
|
+ SysHomePageDetailQueryParamDto teamDto = new SysHomePageDetailQueryParamDto();
|
|
|
87
|
+ teamDto.setId(team.getDeptId());
|
|
|
88
|
+ teamDto.setName(team.getDeptName());
|
|
|
89
|
+ teamDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
90
|
+ dtoList.add(teamDto);
|
|
|
91
|
+ }
|
|
|
92
|
+ if (ObjectUtil.isNotNull(department)) {
|
|
|
93
|
+ SysHomePageDetailQueryParamDto departmentDto = new SysHomePageDetailQueryParamDto();
|
|
|
94
|
+ departmentDto.setId(department.getDeptId());
|
|
|
95
|
+ departmentDto.setName(department.getDeptName());
|
|
|
96
|
+ departmentDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
97
|
+ dtoList.add(departmentDto);
|
|
|
98
|
+ }
|
|
|
99
|
+ if (ObjectUtil.isNotNull(brigade)) {
|
|
|
100
|
+ SysHomePageDetailQueryParamDto departmentDto = new SysHomePageDetailQueryParamDto();
|
|
|
101
|
+ departmentDto.setId(brigade.getDeptId());
|
|
|
102
|
+ departmentDto.setName(brigade.getDeptName());
|
|
|
103
|
+ departmentDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
104
|
+ dtoList.add(departmentDto);
|
|
|
105
|
+ }
|
|
|
106
|
+ if (ObjectUtil.isNotNull(station)) {
|
|
|
107
|
+ SysHomePageDetailQueryParamDto stationDto = new SysHomePageDetailQueryParamDto();
|
|
|
108
|
+ stationDto.setId(station.getDeptId());
|
|
|
109
|
+ stationDto.setName(station.getDeptName());
|
|
|
110
|
+ stationDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
111
|
+ dtoList.add(stationDto);
|
|
|
112
|
+ }
|
|
|
113
|
+ } else if (DataPermissionType.TEAM == dataPermission.getPermissionType() || DataPermissionType.DEPARTMENT == dataPermission.getPermissionType()) {
|
|
|
114
|
+ List<SysDept> deptList = deptService.selectAllDept(getDeptId());
|
|
|
115
|
+ SysDept team = deptList.stream().filter(item -> StrUtil.equals(DeptType.TEAMS.getCode(), item.getDeptType())).findFirst().orElse(null);
|
|
|
116
|
+ SysDept department = deptList.stream().filter(item -> StrUtil.equals(DeptType.MANAGER.getCode(), item.getDeptType())).findFirst().orElse(null);
|
|
|
117
|
+ SysDept brigade = deptList.stream().filter(item -> StrUtil.equals(DeptType.BRIGADE.getCode(), item.getDeptType())).findFirst().orElse(null);
|
|
|
118
|
+ SysDept station = deptList.stream().filter(item -> StrUtil.equals(DeptType.STATION.getCode(), item.getDeptType())).findFirst().orElse(null);
|
|
|
119
|
+
|
|
|
120
|
+ // 添加班组、科室、大队、站点信息
|
|
|
121
|
+ if (ObjectUtil.isNotNull(team)) {
|
|
|
122
|
+ SysHomePageDetailQueryParamDto teamDto = new SysHomePageDetailQueryParamDto();
|
|
|
123
|
+ teamDto.setId(team.getDeptId());
|
|
|
124
|
+ teamDto.setName(team.getDeptName());
|
|
|
125
|
+ teamDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
126
|
+ dtoList.add(teamDto);
|
|
|
127
|
+ }
|
|
|
128
|
+ if (ObjectUtil.isNotNull(department)) {
|
|
|
129
|
+ SysHomePageDetailQueryParamDto departmentDto = new SysHomePageDetailQueryParamDto();
|
|
|
130
|
+ departmentDto.setId(department.getDeptId());
|
|
|
131
|
+ departmentDto.setName(department.getDeptName());
|
|
|
132
|
+ departmentDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
133
|
+ dtoList.add(departmentDto);
|
|
|
134
|
+ }
|
|
|
135
|
+ if (ObjectUtil.isNotNull(brigade)) {
|
|
|
136
|
+ SysHomePageDetailQueryParamDto departmentDto = new SysHomePageDetailQueryParamDto();
|
|
|
137
|
+ departmentDto.setId(brigade.getDeptId());
|
|
|
138
|
+ departmentDto.setName(brigade.getDeptName());
|
|
|
139
|
+ departmentDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
140
|
+ dtoList.add(departmentDto);
|
|
|
141
|
+ }
|
|
|
142
|
+ if (ObjectUtil.isNotNull(station)) {
|
|
|
143
|
+ SysHomePageDetailQueryParamDto stationDto = new SysHomePageDetailQueryParamDto();
|
|
|
144
|
+ stationDto.setId(station.getDeptId());
|
|
|
145
|
+ stationDto.setName(station.getDeptName());
|
|
|
146
|
+ stationDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
147
|
+ dtoList.add(stationDto);
|
|
|
148
|
+ }
|
|
|
149
|
+ } else if (DataPermissionType.BRIGADE == dataPermission.getPermissionType()) {
|
|
|
150
|
+ SysDept sysDept = deptService.selectDeptById(getDeptId());
|
|
|
151
|
+ SysDept sysDeptStation = deptService.selectDeptById(sysDept.getParentId());
|
|
|
152
|
+ SysHomePageDetailQueryParamDto stationDto = new SysHomePageDetailQueryParamDto();
|
|
|
153
|
+ stationDto.setId(sysDeptStation.getDeptId());
|
|
|
154
|
+ stationDto.setName(sysDeptStation.getDeptName());
|
|
|
155
|
+ stationDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
156
|
+ dtoList.add(stationDto);
|
|
|
157
|
+ SysDept query = new SysDept();
|
|
|
158
|
+ query.setParentId(sysDeptStation.getDeptId());
|
|
|
159
|
+ List<SysDept> deptList = deptService.selectDeptInfoAll(query);
|
|
|
160
|
+ deptList.forEach(item -> {
|
|
|
161
|
+ SysHomePageDetailQueryParamDto departmentDto = new SysHomePageDetailQueryParamDto();
|
|
|
162
|
+ departmentDto.setId(item.getDeptId());
|
|
|
163
|
+ departmentDto.setName(item.getDeptName());
|
|
|
164
|
+ departmentDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
165
|
+ dtoList.add(departmentDto);
|
|
|
166
|
+ });
|
|
|
167
|
+ } else if (DataPermissionType.STATION == dataPermission.getPermissionType()) {
|
|
|
168
|
+ SysDept sysDept = deptService.selectDeptById(getDeptId());
|
|
|
169
|
+ SysHomePageDetailQueryParamDto stationDto = new SysHomePageDetailQueryParamDto();
|
|
|
170
|
+ stationDto.setId(sysDept.getDeptId());
|
|
|
171
|
+ stationDto.setName(sysDept.getDeptName());
|
|
|
172
|
+ stationDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
173
|
+ dtoList.add(stationDto);
|
|
|
174
|
+ SysDept query = new SysDept();
|
|
|
175
|
+ query.setParentId(sysDept.getDeptId());
|
|
|
176
|
+ List<SysDept> deptList = deptService.selectDeptInfoAll(query);
|
|
|
177
|
+ deptList.forEach(item -> {
|
|
|
178
|
+ SysHomePageDetailQueryParamDto departmentDto = new SysHomePageDetailQueryParamDto();
|
|
|
179
|
+ departmentDto.setId(item.getDeptId());
|
|
|
180
|
+ departmentDto.setName(item.getDeptName());
|
|
|
181
|
+ departmentDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
182
|
+ dtoList.add(departmentDto);
|
|
|
183
|
+ });
|
|
|
184
|
+ } else {
|
|
|
185
|
+ List<SysDept> deptListAll = deptService.selectDeptInfoAll(new SysDept());
|
|
|
186
|
+ List<SysDept> SysDeptStation = deptListAll.stream().filter(item -> ObjectUtil.equal(DeptTypeEnum.STATION.getCode(), item.getDeptType())).collect(Collectors.toList());
|
|
|
187
|
+ SysDeptStation.forEach(item -> {
|
|
|
188
|
+ SysDept sysDept = deptService.selectDeptById(item.getDeptId());
|
|
|
189
|
+ SysHomePageDetailQueryParamDto stationDto = new SysHomePageDetailQueryParamDto();
|
|
|
190
|
+ stationDto.setId(sysDept.getDeptId());
|
|
|
191
|
+ stationDto.setName(sysDept.getDeptName());
|
|
|
192
|
+ stationDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
193
|
+ dtoList.add(stationDto);
|
|
|
194
|
+ SysDept query = new SysDept();
|
|
|
195
|
+ query.setParentId(sysDept.getDeptId());
|
|
|
196
|
+ List<SysDept> deptList = deptService.selectDeptInfoAll(query);
|
|
|
197
|
+ deptList.forEach(department -> {
|
|
|
198
|
+ SysHomePageDetailQueryParamDto departmentDto = new SysHomePageDetailQueryParamDto();
|
|
|
199
|
+ departmentDto.setId(department.getDeptId());
|
|
|
200
|
+ departmentDto.setName(department.getDeptName());
|
|
|
201
|
+ departmentDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
202
|
+ dtoList.add(departmentDto);
|
|
|
203
|
+ });
|
|
|
204
|
+ });
|
|
|
205
|
+ }
|
|
|
206
|
+ } else {
|
|
|
207
|
+ List<SysDept> sysDeptList = deptService.selectAllDept(getDeptId());
|
|
|
208
|
+ Collections.reverse(sysDeptList);
|
|
|
209
|
+ SysDept sysDept = sysDeptList.stream().filter(x -> StrUtil.equals(DeptType.STATION.getCode(), x.getDeptType())).findFirst().orElse(null);
|
|
|
210
|
+ if (ObjectUtil.isNull(sysDept)) {
|
|
|
211
|
+ throw new ServiceException("未查询到站级部门信息");
|
|
|
212
|
+ }
|
|
|
213
|
+ SysHomePageDetailQueryParamDto stationDto = new SysHomePageDetailQueryParamDto();
|
|
|
214
|
+ stationDto.setId(sysDept.getDeptId());
|
|
|
215
|
+ stationDto.setName(sysDept.getDeptName());
|
|
|
216
|
+ stationDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
217
|
+ dtoList.add(stationDto);
|
|
|
218
|
+ SysDept query = new SysDept();
|
|
|
219
|
+ query.setParentId(sysDept.getDeptId());
|
|
|
220
|
+ List<SysDept> deptList = deptService.selectDeptInfoAll(query);
|
|
|
221
|
+ deptList.forEach(item -> {
|
|
|
222
|
+ SysHomePageDetailQueryParamDto departmentDto = new SysHomePageDetailQueryParamDto();
|
|
|
223
|
+ departmentDto.setId(item.getDeptId());
|
|
|
224
|
+ departmentDto.setName(item.getDeptName());
|
|
|
225
|
+ departmentDto.setType(HomePageQueryEnum.DEPT.getCode());
|
|
|
226
|
+ dtoList.add(departmentDto);
|
|
|
227
|
+ });
|
|
|
228
|
+ }
|
|
|
229
|
+ dtoList.forEach(item -> {
|
|
|
230
|
+ item.setSpecifiedDate(dto.getSpecifiedDate());
|
|
|
231
|
+ item.setStartDate(dto.getStartDate());
|
|
|
232
|
+ item.setEndDate(dto.getEndDate());
|
|
|
233
|
+ });
|
|
|
234
|
+ List<SysHomePageDetailDto> result = getSysHomePageDetailDtoList(dtoList);
|
|
|
235
|
+ return success(result);
|
|
|
236
|
+ }
|
|
|
237
|
+
|
|
|
238
|
+ /**
|
|
|
239
|
+ * 首页-明细(能力对比)
|
|
|
240
|
+ * 支持班组长角色使用dataSource参数:
|
|
|
241
|
+ * - 如果列表中包含班组数据,且dataSource=individual,则将班组数据替换为班组长个人数据
|
|
|
242
|
+ */
|
|
|
243
|
+ @PostMapping("/homePageDetail")
|
|
|
244
|
+ public AjaxResult homePageDetail(@RequestBody List<SysHomePageDetailQueryParamDto> dtoList) {
|
|
|
245
|
+ List<SysHomePageDetailDto> result = getSysHomePageDetailDtoList(dtoList);
|
|
|
246
|
+ return success(result);
|
|
|
247
|
+ }
|
|
|
248
|
+
|
|
|
249
|
+ /**
|
|
|
250
|
+ * 获取首页-明细
|
|
|
251
|
+ */
|
|
|
252
|
+ private List<SysHomePageDetailDto> getSysHomePageDetailDtoList(List<SysHomePageDetailQueryParamDto> dtoList) {
|
|
|
253
|
+ List<SysHomePageDetailDto> result = new ArrayList<>();
|
|
|
254
|
+ for (SysHomePageDetailQueryParamDto item : dtoList) {
|
|
|
255
|
+ SysHomePageDetailDto resultItem = new SysHomePageDetailDto();
|
|
|
256
|
+ resultItem.setId(item.getId());
|
|
|
257
|
+ resultItem.setName(item.getName());
|
|
|
258
|
+ resultItem.setType(item.getType());
|
|
|
259
|
+ resultItem.setLearningGrowthScore(getLearningGrowthScore(item));
|
|
|
260
|
+ resultItem.setLearningGrowthScoreGraph(resultItem.getLearningGrowthScore().divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP));
|
|
|
261
|
+ resultItem.setCheckPassRate(getCheckPassRate(item));
|
|
|
262
|
+ resultItem.setCheckPassRateGraph(resultItem.getCheckPassRate());
|
|
|
263
|
+ result.add(resultItem);
|
|
|
264
|
+ }
|
|
|
265
|
+ return result;
|
|
|
266
|
+ }
|
|
|
267
|
+
|
|
|
268
|
+ /**
|
|
|
269
|
+ * 获取巡检合格率
|
|
|
270
|
+ */
|
|
|
271
|
+ private BigDecimal getCheckPassRate(SysHomePageDetailQueryParamDto item) {
|
|
|
272
|
+ BaseLargeScreenQueryParamDto dto = new BaseLargeScreenQueryParamDto();
|
|
|
273
|
+ if (StrUtil.equals(HomePageQueryEnum.USER.getCode(), item.getType())) {
|
|
|
274
|
+ dto.setUserId(item.getId());
|
|
|
275
|
+ } else {
|
|
|
276
|
+ dto.setDeptId(item.getId());
|
|
|
277
|
+ }
|
|
|
278
|
+ dto.setSpecifiedDate(item.getSpecifiedDate());
|
|
|
279
|
+ dto.setStartDate(item.getStartDate());
|
|
|
280
|
+ dto.setEndDate(item.getEndDate());
|
|
|
281
|
+ return checkLargeScreenService.checkPassRate(dto);
|
|
|
282
|
+ }
|
|
|
283
|
+
|
|
|
284
|
+ /**
|
|
|
285
|
+ * 获取培训答题平均分
|
|
|
286
|
+ */
|
|
|
287
|
+ private BigDecimal getLearningGrowthScore(SysHomePageDetailQueryParamDto item) {
|
|
|
288
|
+ BaseLargeScreenQueryParamDto dto = new BaseLargeScreenQueryParamDto();
|
|
|
289
|
+ if (StrUtil.equals(HomePageQueryEnum.USER.getCode(), item.getType())) {
|
|
|
290
|
+ dto.setUserId(item.getId());
|
|
|
291
|
+ } else {
|
|
|
292
|
+ dto.setDeptId(item.getId());
|
|
|
293
|
+ }
|
|
|
294
|
+ dto.setSpecifiedDate(item.getSpecifiedDate());
|
|
|
295
|
+ dto.setStartDate(item.getStartDate());
|
|
|
296
|
+ dto.setEndDate(item.getEndDate());
|
|
|
297
|
+ return sysLearningGrowthService.learningGrowthAverage(dto);
|
|
|
298
|
+ }
|
|
|
299
|
+
|
|
|
300
|
+}
|