CZT
2023-09-14 db72a27d10fdc4de0926fb8c7cc411ec0d4ea51b
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
package com.ld.igds.sys;
 
import com.bstek.bdf2.core.model.DefaultDept;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.sys.service.SysDeptService;
import com.ld.igds.util.ContextUtil;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.*;
 
/**
 * 
 * @author Andy
 *
 */
@Component("deptPR")
public class DeptPR {
    
    @Autowired
    private SysDeptService sysDeptService;
 
    /**
     * 单位类型
     * ${dorado.getDataProvider("deptPR#triggerCompanyType").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerCompanyType() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        list.add(new DicTrigger("1", "粮食仓储企业"));
        list.add(new DicTrigger("11", "中央直属储备粮库"));
        list.add(new DicTrigger("12", "中谷粮油集团"));
        list.add(new DicTrigger("13", "省级储备粮库"));
        list.add(new DicTrigger("14", "地市级储备粮库"));
        list.add(new DicTrigger("15", "县级储备粮库"));
        list.add(new DicTrigger("19", "其他仓储企业"));
        list.add(new DicTrigger("2", "粮食购销企业"));
        list.add(new DicTrigger("3", "粮食加工企业"));
        list.add(new DicTrigger("4", "粮食设备制造企业"));
        list.add(new DicTrigger("9", "其他粮食企业"));
 
        return list;
    }
 
    /**
     * 单位性质
     * ${dorado.getDataProvider("deptPR#triggerNature").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerNature() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        list.add(new DicTrigger("1", "国有企业"));
        list.add(new DicTrigger("2", "民营企业"));
        list.add(new DicTrigger("3", "事业单位"));
        list.add(new DicTrigger("9", "其他内资企业"));
        list.add(new DicTrigger("10", "港澳台商投资企业"));
        list.add(new DicTrigger("11", "外商投资企业"));
 
        return list;
    }
 
    /**
     * 库区产权
     * ${dorado.getDataProvider("deptPR#triggerPropertyRight").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerPropertyRight() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        list.add(new DicTrigger("1", "自有"));
        list.add(new DicTrigger("2", "租赁"));
        list.add(new DicTrigger("9", "其他"));
 
        return list;
    }
 
    /**
     * 是否代储
     * ${dorado.getDataProvider("deptPR#triggerActingReserve").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerActingReserve() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        list.add(new DicTrigger("1", "是"));
        list.add(new DicTrigger("0", "否"));
 
        return list;
    }
 
    /**
     * 
     * 更新分库的部门信息,存放到缓存中
     */
    @Expose
    public List<DefaultDept> flushSubDeptCache() {
        String companyId = ContextUtil.getCompanyId();
        return sysDeptService.flushDeptCache(companyId);
    }
 
    /**
     * ${dorado.getDataProvider("deptPR#loadParents").getResult()}
     * 获取分库列表,父编码为组织编码
     * 
     * @return
     */
    @DataProvider
    public List<DefaultDept> loadParents() {
        return sysDeptService.getCacheDept(ContextUtil.getCompanyId());
    }
 
    /**
     * deptPR#loadDepts
     * 
     * @param parentId
     * @return
     * @throws Exception
     */
    @DataProvider
    public List<DefaultDept> loadDepts(String parentId) throws Exception {
        return sysDeptService.loadDeptByParentId(parentId, ContextUtil.getCompanyId());
    }
 
    /**
     * deptPR#saveDepts
     * 
     * @param depts
     */
    @DataResolver
    public void saveDepts(Collection<DefaultDept> depts) {
        String companyId = ContextUtil.getCompanyId();
        sysDeptService.saveDept(depts, companyId);
        flushSubDeptCache();
    }
 
    @Expose
    public int countChildren(String parentId) {
        return sysDeptService.countChildren(parentId);
    }
}