cuijian
2023-08-19 bdd0875d4b13a3f1ef472f64d4b6a95e0ef64b22
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
package org.jeecg.modules.base.service.impl;
 
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.system.vo.SelectTreeModel;
import org.jeecg.modules.base.entity.WarehouseClient;
import org.jeecg.modules.base.mapper.WarehouseClientMapper;
import org.jeecg.modules.base.service.IWarehouseClientService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.mapper.SysDepartMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Description: 仓库服务对象
 * @Author: jeecg-boot
 * @Date:   2022-11-07
 * @Version: V1.0
 */
@Service
@Transactional
public class WarehouseClientServiceImpl extends ServiceImpl<WarehouseClientMapper, WarehouseClient> implements IWarehouseClientService {
 
    @Autowired
    private WarehouseClientMapper warehouseClientMapper;
    @Autowired
    private SysDepartMapper sysDepartMapper;
 
    @Override
    public List<WarehouseClient> selectByMainId(String mainId) {
        return warehouseClientMapper.selectByMainId(mainId);
    }
 
    @Override
    public List<SelectTreeModel> getDepartTreeByEnterpriseId(String enterpriseId) {
        return loadDepartTreeByParentId(enterpriseId);
    }
 
    @Override
    public List<SysDepart> getDepartListByParentId(List<String> parentIds) {
        List<SysDepart> list = sysDepartMapper.getDepartListByParentId(parentIds);
        List<String> list1 = new ArrayList<>();
        for(SysDepart sysDepart:list){
            list1.add(sysDepart.getId());
        }
        List<SysDepart> list2 = new ArrayList<>();
        if(list1.size()!=0){
            list2 = getDepartListByParentId(list1);
            list.addAll(list2);
        }
        return list;
    }
 
 
    public  List<SelectTreeModel> loadDepartTreeByParentId(String parentId){
        List<SelectTreeModel> list = sysDepartMapper.getDepartTreeByParentId(parentId);
        if(list.size()!=0){
            for(SelectTreeModel selectTreeModel:list){
                selectTreeModel.setChildren(loadDepartTreeByParentId(selectTreeModel.getKey()));
            }
        }
        return list;
    }
 
 
}