czt
2 天以前 9bb4d71dc57eee0314c34b536e1faf3b3c61b217
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
package com.fzzy.sys.manager.group;
 
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.domain.Dept;
import com.fzzy.igds.domain.DicArea;
import com.fzzy.igds.service.CoreDeptService;
import com.fzzy.igds.service.DicAreaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Description
 * @Author CZT
 * @Date 2025/12/11 15:48
 */
@Slf4j
@Component
public class GroupManager {
 
    @Resource
    private DicAreaService dicAreaService;
    @Resource
    private CoreDeptService deptService;
 
    /**
     * 获取省及下属市州集合
     *
     * @param areaCode
     * @return
     */
    public List<DicArea> getArea(String areaCode) {
 
        DicArea area = dicAreaService.listDicAreaByCode(areaCode);
        if (null == area) {
            return null;
        }
 
        List<DicArea> list = new ArrayList<>();
        list.add(area);
        if (Constant.AREA_TYPE_1.equals(area.getType())) {
            //市州级别,只查询伊犁
            List<DicArea> children = dicAreaService.listData(null, null, "654000");
            if (null != children && !children.isEmpty()) {
                for (DicArea child : children) {
                    if (Constant.AREA_TYPE_2.equals(child.getType())) {
                        //区县
                        List<DicArea> childrenItem = dicAreaService.listData(child.getCode(), null, null);
                        if (null != childrenItem && !childrenItem.isEmpty()) {
                            list.addAll(childrenItem);
                        }
                    }
                }
                list.addAll(children);
            }
        }
 
        return list;
    }
 
    /**
     * 获取对应省份及下属市州children
     *
     * @param areaCode
     * @return
     */
    public List<DicArea> getAreaAndChild(String areaCode) {
 
        DicArea area = dicAreaService.listDicAreaByCode(areaCode);
        if (null == area) {
            return null;
        }
 
        List<DicArea> list = new ArrayList<>();
        if (Constant.AREA_TYPE_1.equals(area.getType())) {
            //市州级别,只查询伊犁
            List<DicArea> children = dicAreaService.listData(null, null, "654000");
            if (null != children && !children.isEmpty()) {
                for (DicArea child : children) {
                    if (Constant.AREA_TYPE_2.equals(child.getType())) {
                        //区县
                        List<DicArea> childrenItem = dicAreaService.listData(child.getCode(), null, null);
                        if (null != childrenItem && !childrenItem.isEmpty()) {
                            child.setChildren(childrenItem);
                        }
                    }
                }
                area.setChildren(children);
            }
 
        }
        list.add(area);
        return list;
    }
 
    /**
     * 获取组织下所有库区信息
     *
     * @param companyId
     * @return
     */
    public List<Dept> getAllDept(String companyId) {
        return deptService.listDept(null, companyId, null);
    }
}