CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
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
package com.ld.igds.gis.controller;
 
import com.bstek.bdf2.core.business.IUser;
import com.bstek.bdf2.core.model.DefaultCompany;
import com.bstek.bdf2.core.model.DefaultDept;
import com.ld.igds.common.CoreCommonService;
import com.ld.igds.constant.Constant;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.data.BaseParam;
import com.ld.igds.data.PageResponse;
import com.ld.igds.gis.manager.GisManager;
import com.ld.igds.sys.service.SysCompanyService;
import com.ld.igds.sys.service.SysDeptService;
import com.ld.igds.util.ContextUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
 
/**
 * OA模块的控制层
 */
@RestController
@RequestMapping("basic/gis")
public class GisController {
 
    @Autowired
    private SysCompanyService companyService;
    @Autowired
    private GisManager gisManager;
    @Autowired
    private SysDeptService sysDeptService;
 
 
    /**
     * 集团/公司 调用  地图导航
     *
     * @param companyId
     * @return
     */
    @RequestMapping("/gis-group")
    public ModelAndView gisMap(@RequestParam(value = "companyId", required = false) String companyId) {
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        //获取当前用户的部门
        DefaultDept defaultDept = sysDeptService.loadUserDept(user.getUsername());
        view.addObject("dept", defaultDept);
        //功能模块
        DefaultCompany company = companyService.getCompany(user.getCompanyId());
        view.addObject("model", company.getModel());
        view.setViewName("admin/gis/gis-group");
        return view;
    }
 
    /**
     * 获取子节点
     *
     * @param param
     * @return
     */
    @RequestMapping("/dept-child")
    public PageResponse<DefaultDept> deptChild(@RequestBody BaseParam param) {
        return gisManager.deptChild(param);
    }
 
 
    /**
     * 返回上一层
     *
     * @param param
     * @return
     */
    @RequestMapping("/back-parent")
    public PageResponse<DefaultDept> backParent(@RequestBody BaseParam param) {
        if (param == null) {
            return new PageResponse<DefaultDept>(RespCodeEnum.CODE_1007.getCode(), "参数异常", null);
        }
        if (StringUtils.isEmpty(param.getDeptId())){
            return new PageResponse<DefaultDept>(RespCodeEnum.CODE_1007.getCode(), "参数异常", null);
        }
 
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        DefaultDept dept = sysDeptService.getCacheDept(param.getCompanyId(), param.getDeptId());
        if (dept == null) {
            return new PageResponse<DefaultDept>(RespCodeEnum.CODE_2000.getCode(), "没获取到数据", null);
        }
        param.setDeptId(dept.getParentId());
        return gisManager.deptChild(param);
    }
 
}