zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
package com.changhong.epc.demo.controller;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import com.changhong.epc.rely.api.service.CscApiService;
import com.changhong.epc.rely.api.service.workFlow.WorkFlowService;
 
 
 
@RestController
public class TestController {
    
    @Autowired
    private CscApiService cscApiService;
    
    @Resource(name="workFlowServiceImpl")
    private WorkFlowService workFlowServicel;
    
 
    
//    @PostMapping("create")
//    public Map<String,Object> createDef(@RequestBody Map<String,Object> map) throws TimeoutException, IOException {
//    
////        String token = "lisi";
////        workFlowServicel.getUserInfo(token);
//        return workFlowServicel.defineCreate(map);                
//    }
//    
//    @PostMapping("test1")
//    public Tenant test1() {
//        // System.err.println("1111..............\n" + cscApiService.findTenantCompanys());
//        return cscApiService.findTenantCompanys();
//    }
//    
//    @PostMapping("test2")
//    public Organizations test2() {
//        // System.err.println("2222..............\n" + cscApiService.findOrganizationByTenantId());
//        return cscApiService.findOrganizationByTenantId();
//    }
//    
//    @PostMapping("test3")
//    public Company test3() {
//        // System.err.println("3333..............\n" + cscApiService.findSystemList());
//        return cscApiService.findSystemList();
//    }
//    
//    @PostMapping("test5")
//    public Organizations test5() {
//        // System.err.println("5555..............\n" + cscApiService.findOrganizationByCompanyId());
//        return cscApiService.findOrganizationByCompanyId();
//    }
//    
//    @PostMapping("test6")
//    public TenantsAndCompanys test6() {
//        // System.err.println("6666..............\n" + cscApiService.findTenantsAndCompanys());
//        return cscApiService.findTenantsAndCompanys();
//    }
//    
//    @PostMapping("test7")
//    public Organizations test7() {
//        // System.err.println("7777..............\n" + cscApiService.findUserOrgs());
//        return cscApiService.findUserOrgs();
//    }
//    
//    @PostMapping("test13")
//    public Organizations test13() {
//        // System.err.println("13131313..............\n" + cscApiService.findRelationDetail());
//        return cscApiService.findRelationDetail();
//    }
    
    
    //测试通过用户名字的到用户的上级部门和所属部门及用户自己
//    @PostMapping("test12")
//    public Organizations test12() {
//        Organizations orgs = cscApiService.findRelationDetail();
//        
//        Organizations org = new Organizations();
//        Children children = new Children();
//        List<Users> users = new ArrayList<Users>();
//        Users user = new Users();
//        user.setOpenId("893ccd52f0ec4eae");
//        children = test121(orgs.getOrgs(), children, users, user);
//        List<Children> c = new ArrayList<Children>();
//        Children children1 = new Children();
//        Children children2 = new Children();
//        children1 = test123(orgs.getOrgs(), children2, children, children.getParentId());
//        c.add(children1);
//        // System.err.println("cccccc" + c);
//        org.setOrgs(c);
//        return org;
//    }
//    
//    public Children test121(List<Children> list, Children children, List<Users> users, Users user) {
//        
//        if(list != null)
//            for(Children b:list) {
//                
//                if(b.getUsers() != null)
//                for(Users u:b.getUsers()) {
////                    if(u.getName().equals("张婷")){
//                    if(u.getName().equals("郭毅")){
//                        user.setName(u.getName());
//                        users.add(user);
//                        children.setId(b.getParentId());
//                        children.setName(b.getName());
//                        children.setParentId(b.getParentId());
//                        children.setUsers(users);
//                        // System.err.println(children);
//                        
//                        break;
//                    }
//                }
//                // System.err.println(b.getId() + ":" + b.getName() + "....\n");
//                test121(b.getChildren(),children,users, user);
//            }
//        return children;
//    }
//    
//    public Children test123(List<Children> list, Children children1, Children children, String id) {
//        if(list != null)
//            for(Children b:list) {
//                if(id.equals(b.getId())){
//                    children1.setId(b.getId());
//                    children1.setName(b.getName());
//                    List<Children> list1 = new ArrayList<Children>();
//                    list1.add(children);
//                    children1.setChildren(list1);
//                }
//                
//                test123(b.getChildren(), children1, children, id);
//            }
//        return children1;
//    }
//    
    
    
//    @PostMapping("test23")
//    public Organizations test23() {
//        
//        Organizations orgs = cscApiService.findRelationDetail();
//        
//        
//        
//        Organizations org = new Organizations();
//        List<Children> childrenList = new ArrayList<Children>();
//        Children children = new Children();
//        children = test23231(orgs.getOrgs(), childrenList, children);
//        List<Children> c = new ArrayList<Children>();
//        c.add(children);
//        // System.err.println("cccccc" + c);
//        org.setOrgs(c);
//        return org;
//    }
//    
//    public Children test23231(List<Children> list, List<Children> childrenList, Children children) {
//        if(list != null)
//            for(Children b:list) {
////                b.getUsers().clear();
//                // System.err.println(b.getName());
//                test23231(b.getChildren(), childrenList, children);
//            }
//        return children;
//    }
//    
//    @PostMapping("test131")
//    public Organizations getAll() {
//        
//        Organizations orgs = cscApiService.findRelationDetail();
//        
////        Organizations orgs = new Organizations();
////        List<Children> childrenList = new ArrayList<Children>();
//        // System.err.println(orgs.getOrgs());
//        recursionChildren(orgs.getOrgs());
////        orgs.setOrgs(childrenList);
////        // System.err.println("cccccc" + childrenList);
//        return orgs;
//    }
//    
//    public void recursionChildren(List<Children> list) {
//        if(list != null)
//            for(Children children:list) {
//                if(children.getUsers() != null)
//                    children.getUsers().clear();
//                if(children.getPositions() != null)
//                    children.getPositions().clear();
//                // System.err.println(children.getName());
//                recursionChildren(children.getChildren());
//            }
//    }
//    public Children test122(List<Users> users, Children children, Users user) {
//        
//        if(users != null){
//            List<Users> userList = new ArrayList<Users>();
//            Users us = new Users();
//            for(Users u:users) {
//                if(u.getName().equals("张婷")){
////                    children.setId(children.getParentId());
////                    children.setName(children.getName());
////                    // System.err.println(children.getParentId());
//                    us.setName(u.getName());
//                    userList.add(us);
//                    children.setUsers(userList);
//                    // System.err.println(children);
//                    return children;
//                }
//            }
//        }
//        return children;
//    }
//    
//    @Data
//    public class BudgetOrg {
//        private String name;
//        private List<BudgetOrg> budgetOrg;
//        private String code;
//    }
//    
//    @PostMapping("test222")
//    public BudgetOrg test222() {
////        Organizations orgs = cscApiService.findRelationDetail();
//        
//        BudgetOrg a1 = new BudgetOrg();
//        a1.setName("a1");
//        a1.setCode("一级");
//        List<BudgetOrg> l1 = new ArrayList<BudgetOrg>();
//            BudgetOrg b1 = new BudgetOrg();
//            b1.setName("b1");
//            b1.setCode("二级1");
//            List<BudgetOrg> ll1 = new ArrayList<BudgetOrg>();
//                BudgetOrg bb1 = new BudgetOrg();
//                bb1.setName("bb1");
//                bb1.setCode("三级11");
//                List<BudgetOrg> lll1 = new ArrayList<BudgetOrg>();
//                    BudgetOrg bbbb1 = new BudgetOrg();
//                    bbbb1.setName("bbbb1");    
//                    bbbb1.setCode("四级11");
//                    BudgetOrg bbbb2 = new BudgetOrg();
//                    bbbb2.setName("bbbb2");
//                    bbbb2.setCode("四级12");
//                    BudgetOrg bbbb3 = new BudgetOrg();
//                    bbbb3.setName("bbbb3");
//                    bbbb3.setCode("四级13");
//                    lll1.add(bbbb1);
//                    lll1.add(bbbb2);
//                    lll1.add(bbbb3);
//                bb1.setBudgetOrg(lll1);
//                BudgetOrg bb2 = new BudgetOrg();
//                bb2.setName("bb2");
//                bb2.setCode("三级12");
//                BudgetOrg bb3 = new BudgetOrg();
//                bb3.setName("b3");
//                bb3.setCode("三级13");
//                ll1.add(bb1);
//                ll1.add(bb2);
//                ll1.add(bb3);
//                b1.setBudgetOrg(ll1);
//            BudgetOrg b2 = new BudgetOrg();
//            b2.setName("b2");
//            b2.setCode("二级2");
//            List<BudgetOrg> ll2 = new ArrayList<BudgetOrg>();
//                BudgetOrg bbb1 = new BudgetOrg();
//                bbb1.setName("bbb1");
//                bbb1.setCode("三级21");
//                BudgetOrg bbb2 = new BudgetOrg();
//                bbb2.setName("bbb2");
//                bbb2.setCode("三级22");
//                BudgetOrg bbb3 = new BudgetOrg();
//                bbb3.setName("bbb3");
//                bbb3.setCode("三级23");
//                ll2.add(bbb1);
//                ll2.add(bbb2);
//                ll2.add(bbb3);
//                b2.setBudgetOrg(ll2);
//            BudgetOrg b3 = new BudgetOrg();
//            b3.setName("b3");
//            b3.setCode("二级3");
//            l1.add(b1);
//            l1.add(b2);
//            l1.add(b3);
//        a1.setBudgetOrg(l1);
////        // System.err.println(a1);
//        BudgetOrg s = new BudgetOrg();
//        BudgetOrg ss = new BudgetOrg();
//        s = test333(a1.getBudgetOrg(),ss);
//        // System.err.println(s);
//        return s;
//        
//    }
//    
//    public BudgetOrg test333(List<BudgetOrg> list,BudgetOrg ss) {
//        if(list != null) {
//            for(BudgetOrg b:list) {
//                if(b.getCode().equals("四级12")){
//                    ss.setCode(b.getCode());
//                    // System.err.println(ss);
//                    return ss;
//                }
//                test333(b.getBudgetOrg(),ss);
//            }
//            return ss;
//        }
//        return ss;
//    }
//    
//    @PostMapping("test333")
//    public String test333(){
//        String s = new String();
//        s = "s";
//        
//        if(s != null) {
//            String ss = new String();
//            ss =  "s";
//            for(int i = 0; i< 2; i++) {
//                if(s.equals(ss))
//                break;
//            }
//            // System.err.println(s);
//            return s;
//        
//        } else {
//            return null;
//        }
//        
//    }
//    
 
       
 
}