SysDepartController.java
24.5 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
package com.skua.modules.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skua.common.constant.CacheConstant;
import com.skua.core.api.vo.LoginUser;
import com.skua.core.api.vo.Result;
import com.skua.core.api.vo.TransTreeModel;
import com.skua.core.api.vo.TreeData;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.query.QueryGenerator;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.JwtUtil;
import com.skua.core.util.TreeUtils;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.model.DepartIdModel;
import com.skua.modules.system.model.SysDepartTreeModel;
import com.skua.modules.system.service.ISysDepartService;
import com.skua.modules.system.vo.SysDeptUserVO;
import com.skua.modules.system.vo.SysXHDepartVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
* 部门表 前端控制器
*/
@Api(tags="部门管理")
@RestController
@RequestMapping("/sys/sysDepart")
@Slf4j
public class SysDepartController {
@Autowired
private ISysDepartService sysDepartService;
/**
* 查询数据 查出所有部门,并以树结构数据格式响应给前端
*
* @return
*/
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
public Result<List<SysDepartTreeModel>> queryTreeList() {
Result<List<SysDepartTreeModel>> result = new Result<>();
try {
// 从内存中读取
// List<SysDepartTreeModel> list =FindsDepartsChildrenUtil.getSysDepartTreeList();
// if (CollectionUtils.isEmpty(list)) {
// list = sysDepartService.queryTreeList();
// }
List<SysDepartTreeModel> list = sysDepartService.queryTreeList();
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 部门列表
* @return
*/
//@ApiOperation(value="部门列表", notes="部门列表-无分页")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<List<SysDepart>> queryList() {
Result<List<SysDepart>> result = new Result<>();
try {
List<SysDepart> list = sysDepartService.queryList();
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 添加新数据 添加用户新建的部门对象数据,并保存到数据库
*
* @param sysDepart
* @return
*/
@AutoLog(value = "添加部门信息")
@RequestMapping(value = "/add", method = RequestMethod.POST)
@CacheEvict(value= {CacheConstant.DEPART_INFO_CACHE,CacheConstant.DEPART_IDMODEL_CACHE}, allEntries=true)
public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
Result<SysDepart> result = new Result<SysDepart>();
String username = JwtUtil.getUserNameByToken(request);
try {
sysDepart.setCreateBy(username);
sysDepartService.saveDepartData(sysDepart, username);
//清除部门树内存
// FindsDepartsChildrenUtil.clearSysDepartTreeList();
// FindsDepartsChildrenUtil.clearDepartIdModel();
result.success("添加成功!");
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
}
return result;
}
/**
* 编辑数据 编辑部门的部分数据,并保存到数据库
*
* @param sysDepart
* @return
*/
@AutoLog(value = "编辑部门信息")
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
@CacheEvict(value= {CacheConstant.DEPART_INFO_CACHE,CacheConstant.DEPART_IDMODEL_CACHE}, allEntries=true)
public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
String username = JwtUtil.getUserNameByToken(request);
sysDepart.setUpdateBy(username);
Result<SysDepart> result = new Result<SysDepart>();
SysDepart sysDepartEntity = sysDepartService.getById(sysDepart.getId());
if (sysDepartEntity == null) {
result.error500("未找到对应实体");
} else {
boolean ok = sysDepartService.updateDepartDataById(sysDepart, username);
// TODO 返回false说明什么?
if (ok) {
//清除部门树内存
//FindsDepartsChildrenUtil.clearSysDepartTreeList();
//FindsDepartsChildrenUtil.clearDepartIdModel();
result.success("修改成功!");
}
}
return result;
}
/**
* 通过id删除
* @param id
* @return
*/
@AutoLog(value = "删除部门信息")
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.DEPART_INFO_CACHE,CacheConstant.DEPART_IDMODEL_CACHE}, allEntries=true)
public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) {
Result<SysDepart> result = new Result<SysDepart>();
SysDepart sysDepart = sysDepartService.getById(id);
if(sysDepart==null) {
result.error500("未找到对应实体");
}else {
boolean ok = sysDepartService.delete(id);
if(ok) {
//清除部门树内存
//FindsDepartsChildrenUtil.clearSysDepartTreeList();
// FindsDepartsChildrenUtil.clearDepartIdModel();
result.success("删除成功!");
}
}
return result;
}
/**
* 批量删除 根据前端请求的多个ID,对数据库执行删除相关部门数据的操作
*
* @param ids
* @return
*/
@AutoLog(value = "批量删除部门信息")
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.DEPART_INFO_CACHE,CacheConstant.DEPART_IDMODEL_CACHE}, allEntries=true)
public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
Result<SysDepart> result = new Result<SysDepart>();
if (ids == null || "".equals(ids.trim())) {
result.error500("参数不识别!");
} else {
this.sysDepartService.deleteBatchWithChildren(Arrays.asList(ids.split(",")));
result.success("删除成功!");
}
return result;
}
/**
* 查询数据 添加或编辑页面对该方法发起请求,以树结构形式加载所有部门的名称,方便用户的操作
*
* @return
*/
@RequestMapping(value = "/queryIdTree", method = RequestMethod.GET)
public Result<List<DepartIdModel>> queryIdTree() {
// Result<List<DepartIdModel>> result = new Result<List<DepartIdModel>>();
// List<DepartIdModel> idList;
// try {
// idList = FindsDepartsChildrenUtil.wrapDepartIdModel();
// if (idList != null && idList.size() > 0) {
// result.setResult(idList);
// result.setSuccess(true);
// } else {
// sysDepartService.queryTreeList();
// idList = FindsDepartsChildrenUtil.wrapDepartIdModel();
// result.setResult(idList);
// result.setSuccess(true);
// }
// return result;
// } catch (Exception e) {
// log.error(e.getMessage(),e);
// result.setSuccess(false);
// return result;
// }
Result<List<DepartIdModel>> result = new Result<>();
try {
List<DepartIdModel> list = sysDepartService.queryDepartIdTreeList();
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
@RequestMapping(value = "/queryDepartTree", method = RequestMethod.GET)
public Result<List<DepartIdModel>> queryDepartTree() {
Result<List<DepartIdModel>> result = new Result<>();
try {
List<DepartIdModel> list = sysDepartService.queryDepartTree();
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 获取用户所有的厂区列表
* @return
*/
@RequestMapping(value = "/factoryList", method = RequestMethod.GET)
public Result<List<SysDepart>> factoryList() {
Result<List<SysDepart>> result = new Result<>();
try {
List<SysDepart> list = getUserFactoryList(BaseContextHandler.getUserCode());
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 获取子公司列表
* @return
*/
@RequestMapping(value = "/groupList", method = RequestMethod.GET)
public Result<List<SysDepart>> groupList() {
Result<List<SysDepart>> result = new Result<>();
List<SysDepart> list = new ArrayList<>();
list = sysDepartService.getUserGroupList();
result.setResult(list);
result.setSuccess(true);
return result;
}
/*@RequestMapping(value = "/factoryDictList", method = RequestMethod.GET)
public Result<List<CommonDictBean>> factoryDictList() {
Result<List<CommonDictBean>> result = new Result<>();
try {
List<SysDepart> list = getUserFactoryList(BaseContextHandler.getUserCode());
List<CommonDictBean> dictList = new ArrayList<CommonDictBean>();
for(SysDepart sysDepart : list) {
CommonDictBean dict = new CommonDictBean();
dict.setItemCode(sysDepart.getId());
dict.setItemName(sysDepart.getDepartName());
dictList.add(dict);
}
result.setResult(dictList);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}*/
@RequestMapping(value = "/factoryListForMonitor", method = RequestMethod.GET)
public Result<List<SysDepart>> factoryListForMonitor() {
Result<List<SysDepart>> result = new Result<>();
try {
List<SysDepart> list = getUserFactoryListForMonitor(BaseContextHandler.getUserCode());
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
private List<SysDepart> getUserFactoryListForMonitor(String userId) {
List<SysDepart> list = new ArrayList<>();
list = sysDepartService.getUserFactoryListForMonitor(userId);
if(list.size() > 0){
return list;
}else{
return new ArrayList<SysDepart>();
}
}
private List<SysDepart> getUserFactoryList(String userId) {
List<SysDepart> list = new ArrayList<>();
list = sysDepartService.getUserFactoryList(userId);
if(list.size() > 0){
return list;
}else{
return new ArrayList<SysDepart>();
}
}
/**
* <p>
* 部门搜索功能方法,根据关键字模糊搜索相关部门
* </p>
*
* @param keyWord
* @return
*/
@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) {
Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>();
try {
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord);
if (treeList.size() == 0 || treeList == null) {
throw new Exception();
}
result.setSuccess(true);
result.setResult(treeList);
return result;
} catch (Exception e) {
e.fillInStackTrace();
result.setSuccess(false);
result.setMessage("查询失败或没有您想要的任何数据!");
return result;
}
}
/**
* 导出excel
*
* @param request
* @param sysDepart
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
// Step.1 组装查询条件
QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<SysDepart> pageList = sysDepartService.list(queryWrapper);
//按字典排序
Collections.sort(pageList, new Comparator<SysDepart>() {
@Override
public int compare(SysDepart arg0, SysDepart arg1) {
return arg0.getOrgCode().compareTo(arg1.getOrgCode());
}
});
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
// orgCode编码长度
int codeLength = 3;
List<SysDepart> listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepart.class, params);
//按长度排序
Collections.sort(listSysDeparts, new Comparator<SysDepart>() {
@Override
public int compare(SysDepart arg0, SysDepart arg1) {
return arg0.getOrgCode().length() - arg1.getOrgCode().length();
}
});
for (SysDepart sysDepart : listSysDeparts) {
String orgCode = sysDepart.getOrgCode();
if(orgCode.length() > codeLength) {
String parentCode = orgCode.substring(0, orgCode.length()-codeLength);
QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<SysDepart>();
queryWrapper.eq("org_code", parentCode);
try {
SysDepart parentDept = sysDepartService.getOne(queryWrapper);
if(!parentDept.equals(null)) {
sysDepart.setParentId(parentDept.getId());
} else {
sysDepart.setParentId("");
}
}catch (Exception e) {
//没有查找到parentDept
}
}else{
sysDepart.setParentId("");
}
sysDepartService.save(sysDepart);
}
return Result.ok("文件导入成功!数据行数:" + listSysDeparts.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.error("文件导入失败!");
}
/**
* 获取部门人员机构树
* @return
*/
@RequestMapping(value = "/queryDeptAndEmpTreeList", method = RequestMethod.GET)
public Result<List<TreeData>> queryDeptAndEmpTreeList(String factoryId) {
//根据token获取该用户厂id
factoryId = BaseContextHandler.getDeparts();
String orgType = ConvertUtils.getString(BaseContextHandler.get("orgType"));
if(!StringUtils.isEmpty(orgType)) {
factoryId = ConvertUtils.getString(BaseContextHandler.get("realFactoryId"));
}
//获取数据列表
List<SysDeptUserVO> list=sysDepartService.queryDeptAndEmpTreeList(factoryId);
//将业务数据转换为构造树所需的数据结构
List<TransTreeModel> transTreeModels = list.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList());
List<TreeData> treeList=TreeUtils.buildTree(transTreeModels, factoryId);
Result<List<TreeData>> result = new Result<>();
try {
result.setResult(treeList);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 获取部门人员机构树-无数据权限
* @return
*/
@RequestMapping(value = "/queryAllDeptAndEmpTreeList", method = RequestMethod.GET)
public Result<List<TreeData>> queryAllDeptAndEmpTreeList(String factoryId) {
//根据token获取该用户厂id
// factoryId = BaseContextHandler.getDeparts();
// String orgType = ConvertUtils.getString(BaseContextHandler.get("orgType"));
// if(!StringUtils.isEmpty(orgType)) {
// factoryId = ConvertUtils.getString(BaseContextHandler.get("realFactoryId"));
// }
factoryId = "c6d7cb4deeac411cb3384b1b31278596";
//获取数据列表
List<SysDeptUserVO> list=sysDepartService.queryDeptAndEmpTreeList(factoryId);
//将业务数据转换为构造树所需的数据结构
List<TransTreeModel> transTreeModels = list.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList());
List<TreeData> treeList=TreeUtils.buildTree(transTreeModels, factoryId);
Result<List<TreeData>> result = new Result<>();
try {
result.setResult(treeList);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 根据厂ID获取部门人员机构树
* @param factoryId
* @return
*/
@GetMapping(value = "/queryDeptUserTreeList")
public Result<List<TreeData>> queryDeptUserTreeList(String factoryId) {
List<SysDeptUserVO> list=sysDepartService.queryDeptUserTreeList(factoryId);
//将业务数据转换为构造树所需的数据结构
List<TransTreeModel> transTreeModels = list.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList());
List<TreeData> treeList=TreeUtils.buildTree(transTreeModels, "");
Result<List<TreeData>> result = new Result<>();
try {
result.setResult(treeList);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 获取厂区树
* @return
*/
@RequestMapping(value = "/queryFactoryTreeList", method = RequestMethod.GET)
public Result<List<TreeData>> queryFactoryTreeList() {
//获取数据列表
List<SysDeptUserVO> list=sysDepartService.queryFactoryTreeList();
//将业务数据转换为构造树所需的数据结构
List<TransTreeModel> transTreeModels = list.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList());
List<TreeData> treeList=TreeUtils.buildTree(transTreeModels, "");
Result<List<TreeData>> result = new Result<>();
try {
result.setResult(treeList);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 将SysDeptUserVO对象数据填充到TransTreeModel中
* @param sysDeptUserVO
* @return
*/
private TransTreeModel convertToTreeModel(SysDeptUserVO sysDeptUserVO) {
TransTreeModel transTreeModel = new TransTreeModel();
transTreeModel.setId(sysDeptUserVO.getId());
transTreeModel.setPid(sysDeptUserVO.getParentId());
transTreeModel.setTitle(sysDeptUserVO.getTitle());
Map<String,String> map=new HashMap<String,String>();
map.put("nodeType", sysDeptUserVO.getNodeType());
transTreeModel.setMap(map);
return transTreeModel;
}
/**
* 获取片区列表
* @return
*/
@ApiOperation(value="片区列表", notes="片区列表")
@GetMapping(value = "/getAreaList")
public Result<List<SysDepart>> getAreaList() {
Result<List<SysDepart>> result = new Result<List<SysDepart>>();
String areaIds = "";
//片区数据权限
Object orgType = BaseContextHandler.get("orgType");
if(!ConvertUtils.isEmpty(orgType)) {
if(orgType.toString().equals("1")) {
//集团用户
}else if(orgType.toString().equals("2")) {
//片区用户
areaIds = "'"+BaseContextHandler.get("realFactoryId").toString()+"'";
}
}else {
//根据厂站id获取片区id
String factoryId = BaseContextHandler.get("realFactoryId").toString();
areaIds = "'"+sysDepartService.getAreaIdByFactoryId(factoryId)+"'";
}
List<SysDepart> list = sysDepartService.getAreaList(areaIds);
result.setSuccess(true);
result.setResult(list);
return result;
}
@ApiOperation(value="实时数据片区列表", notes="实时数据片区列表")
@GetMapping(value = "/getAreaListForMonitor")
public Result<List<SysDepart>> getAreaListForMonitor() {
Result<List<SysDepart>> result = new Result<List<SysDepart>>();
String areaIds = "";
//片区数据权限
Object orgType = BaseContextHandler.get("orgType");
if(!ConvertUtils.isEmpty(orgType)) {
if(orgType.toString().equals("1")) {
//集团用户
}else if(orgType.toString().equals("2")) {
//片区用户
areaIds = "'"+BaseContextHandler.get("realFactoryId").toString()+"'";
}
}else {
//根据厂站id获取片区id
String factoryId = BaseContextHandler.get("realFactoryId").toString();
areaIds = "'"+sysDepartService.getAreaIdByFactoryId(factoryId)+"'";
}
List<SysDepart> list = sysDepartService.getAreaListForMonitor(areaIds);
result.setSuccess(true);
result.setResult(list);
return result;
}
/**
* 根据片区ID获取水厂数据
* @param areaId
* @return
*/
@ApiOperation(value="根据片区id获取水厂列表", notes="根据片区id获取水厂列表")
@GetMapping(value = "/queryDepartListByAreaId")
public Result<List<SysDepart>> queryDepartListByAreaId(String areaId) {
List<SysDepart> list=sysDepartService.queryDepartListByAreaId(areaId);
Result<List<SysDepart>> result = new Result<>();
try {
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* <pre>
* 西汇根据片区ID获取水厂数据
* </pre>
* @param areaId
* @author WeiChen Wu,2022/04/21 15:05
* @Description:
*/
@ApiOperation(value="西汇根据片区id获取水厂列表", notes="西汇根据片区id获取水厂列表")
@GetMapping(value = "/queryDepartListByAreaIdXH")
public Result<List<SysXHDepartVO>> queryXHDepartListByAreaId(String areaId) {
List<SysXHDepartVO> list=sysDepartService.queryXHDepartListByAreaId(areaId);
Result<List<SysXHDepartVO>> result = new Result<>();
try {
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return result;
}
/**
* 获取厂区列表
* @return
*/
@ApiOperation(value="厂区列表", notes="厂区列表")
@GetMapping(value = "getFactoryList")
public Result<List<SysDepart>> getFactoryList() {
Result<List<SysDepart>> result = new Result<List<SysDepart>>();
List<SysDepart> list = sysDepartService.getFactoryList();
result.setSuccess(true);
result.setResult(list);
return result;
}
/**
* 获取集团列表
* @return
*/
@ApiOperation(value="集团列表", notes="集团列表")
@GetMapping(value = "getJtList")
public Result<List<SysDepart>> getJtList() {
Result<List<SysDepart>> result = new Result<List<SysDepart>>();
List<SysDepart> list = sysDepartService.getJtList();
result.setSuccess(true);
result.setResult(list);
return result;
}
/**
* 获取APP端厂区列表
* @return
*/
@GetMapping(value = "getAppFactoryList")
public Result<List<SysDepart>> getAppFactoryList() {
Result<List<SysDepart>> result = new Result<List<SysDepart>>();
List<SysDepart> list = sysDepartService.getFactoryList();
result.setSuccess(true);
result.setResult(list);
return result;
}
/**
* 获取公司列表
* @return
*/
@GetMapping(value = "getCmpyList")
public Result<List<SysDepart>> getCmpyList() {
Result<List<SysDepart>> result = new Result<List<SysDepart>>();
List<SysDepart> list = sysDepartService.getCmpyList();
result.setSuccess(true);
result.setResult(list);
return result;
}
/**
* 首页底图获取公司列表
* @return
*/
@GetMapping(value = "getList")
public Result<List<Map<String,Object>>> getList() {
Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
List<Map<String,Object>> list = sysDepartService.getList();
result.setSuccess(true);
result.setResult(list);
return result;
}
}