CZT
2023-10-18 c432d5cede4fb9e48234523841d1e7257828d808
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
package com.ld.igds.gis.manager;
 
 
import com.bstek.bdf2.core.business.IDept;
import com.bstek.bdf2.core.model.DefaultDept;
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.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.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
 
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * gis 定位
 */
@Component
public class GisManager {
    @Autowired
    private SysDeptService sysDeptService;
 
    public PageResponse<DefaultDept> deptChild(@RequestBody BaseParam param) {
        //return oAManager.getGpsLocation(companyId);
        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);
        List<DefaultDept> defaultDepts = sysDeptService.loadDeptByParentId(param.getCompanyId(), dept.getId());
        //找到子节点
        List<IDept> childs = defaultDepts.stream().filter(item -> !Constant.YN_N.equals(item.getVal()))
                .collect(Collectors.toList());
        dept.setChildren(childs);
        return new PageResponse<DefaultDept>(RespCodeEnum.CODE_0000, dept);
    }
}