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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
package com.changhong.epc.rely.api.service.impl;
 
import com.alibaba.fastjson.TypeReference;
import com.changhong.epc.bean.PageResult;
import com.changhong.epc.bean.tenant.system.permission.PowerKey;
import com.changhong.epc.constter.base.BaseConst;
import com.changhong.epc.constter.exception.EPCServiceException;
import com.changhong.epc.constter.system.prop.ChangHongProperties;
import com.changhong.epc.constter.system.prop.ChangHongProperties.PassPortName;
import com.changhong.epc.rely.api.bean.*;
import com.changhong.epc.rely.api.service.CscApiService;
import com.changhong.epc.rely.api.tool.CscUtils;
import com.changhong.epc.rely.api.tool.EpcApiHttp;
import com.changhong.epc.rely.api.tool.HttpUtil;
import com.iemsoft.framework.cloud.core.exception.IEMRuntimeException;
import com.iemsoft.framework.cloud.core.thread.ThreadData;
import com.iemsoft.framework.cloud.core.tools.JSONTool;
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
import com.iemsoft.framework.cloud.core.tools.http.Http;
import com.iemsoft.framework.cloud.core.tools.http.IEMHttpException;
import com.iemsoft.framework.cloud.redis.annotation.CacheSave;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheResult;
import lombok.Data;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
 
import java.util.*;
import java.util.function.Predicate;
 
 
/**
 * 云尚行api接口实现
 * @author liush
 *
 */
@Service
@Slf4j
public class CscApiServiceImpl implements CscApiService, BaseConst {
 
    @Autowired
    @Setter
    private ChangHongProperties changHongProperties;
 
    @Override
    @CacheSave(time = 60 * 60 * 24)
    public List<User> getUsers() {
        return EpcApiHttp.post(this, PassPortName.FIND_USERS)
//        return EpcApiHttp.post(this, "http://csza.chfcloud.com/csc-ie-user/rest/json/api/organization/findUserList")
                .addUrlParam(CscUtils.getParam(
                        new ModelMap("flag", 2)
                                .addAttribute("orgCodes", getCompany().getOrgCode())
                        )
                )
                .execute(new TypeReference<Organizations>(){}.getType())
                .map(Organizations::getUsers).orElse(Collections.emptyList());
    }
 
    @Override
    public Optional<User> getUser(Predicate<User> filter) {
        return SpringUtil.getBean(CscApiServiceImpl.class).getUsers()
//        return getUsers()
                .stream().filter(filter).findFirst();
    }
 
    //1.1
    @Override
    public Tenant findTenantCompanys(Integer tenantId) {
        Tenant tenantCompanys;
        try {
            tenantCompanys = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_TENANTCOMPANYS, null)
                        , null
                        , CscUtils.getParam(new ModelMap("tenantId", tenantId))
                        , null,  new TypeReference<Tenant>(){}.getType());
            return tenantCompanys;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_TENANTCOMPANYS, null));
        }
    }
 
    @Override
    public Organization findOneOrgByOrgCode(String orgCode) {
        List<Organization> organizations = findRelationDetail().getOrgs();
        if(ObjectUtil.empty(organizations)){
            return null;
        }
        Organization company = organizations.stream().findFirst().get();
        if(ObjectUtil.empty(company) || ObjectUtil.empty(company.getChildren())){
            return null;
        }
        for(Organization organization : company.getChildren()){
            if(Objects.equals(organization.getCode(), orgCode)){
                return organization;
            }
        }
        return null;
    }
 
    //6.1
//    @CacheSave(time = 60 * 60 * 24, tenant = false, company = false)
    public TenantsAndCompanys findTenantsAndCompanys() {
        TenantsAndCompanys tenantsAndCompanys;
        try {
            tenantsAndCompanys = HttpUtil.post(
//                    "http://csza.chfcloud.com/csc-ie-user/rest/json/api/user/findTenantsAndCompanys"
                    changHongProperties.getPassUrl(PassPortName.FIND_USER_TENANTSANDCOMPANYS, null)
                        , null, CscUtils.getParam(new ModelMap("openId",ThreadData.get(OPEN_ID)))
                        , null,  new TypeReference<TenantsAndCompanys>(){}.getType());
            if(tenantsAndCompanys==null){
                return null;
            }
            return tenantsAndCompanys;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new EPCServiceException(N0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_USER_TENANTSANDCOMPANYS, null));
        }
    }
 
    //9.0
    @Override
    public Organizations getOrgsOfTree(String code) {
        Organizations organizations = null;
        try {
            organizations = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.GET_USER_ORGSOFTREE, null)
                        , null, CscUtils.getParam(new ModelMap("code", code)) //ThreadData.get(TENANT_ID) 应该传入的参数
                        , null,  new TypeReference<Organizations>(){}.getType());
            return organizations;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_ORGANIZATION, null));
        }
        
    }
 
    //13.1
    @CacheResult
    @Override
    public Organizations findRelationDetail() {
        // System.out.println("公司Id:是"+ThreadData.get(COMPANY_ID));
        
        Organizations orgs;
        try {
            orgs = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.FIND_ORGANIZATION_RELATIONDETAIL, null)
                        , null, CscUtils.getParam(new ModelMap("companyId", ThreadData.get(COMPANY_ID)))
                        , null,  new TypeReference<Organizations>(){}.getType());
            return orgs;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_ORGANIZATION_RELATIONDETAIL, null));
        }
    }
 
    @Override
    public Map<String, Object> orderAccount(Map<String, Object> map) {
        Map<String, Object> orgs = new HashMap<String,Object>();
        try { 
            orgs = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.ORDER_ORDERACCOUNT, null)
                        , null, CscUtils.getParam(map)
                        , null,  new TypeReference<Map<String,Object>>(){}.getType());
            //findSystemList();
            // System.err.println(orgs);
            return orgs;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.ORDER_ORDERACCOUNT, null));
//            e.printStackTrace();
        }
    }
 
    @Override
    public Object orderRuleCheck(String orderCode) {
         try {
            Object asd = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.ORDER_RULE_CHECK, null)
                        ,null, CscUtils.getCloudParam(new ModelMap("orderCode", orderCode)) 
                        , null, new TypeReference<String>(){}.getType());
            // System.out.println(JSONTool.toJson(asd));
            return asd;
        } catch (Exception e) {
             log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.REST_TENANT_BILLDATA_BILLCORRECT, null));
        }
    }
 
    //16.0
    @Override
    public Object getOrderPic(String orderCode) {
        try {
            Object pic = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.GET_ORDERPIC, null)
                       ,null, CscUtils.getCloudParam(new ModelMap("orderCode",orderCode))
                       , null, new TypeReference<Object>(){}.getType());
            // System.err.println(JSONTool.toJson(pic));
            return pic;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.GET_ORDERPIC, null)); 
        }
    }
 
    @Override
    public Map<String, Object> orderTypeDefineList(Map<String, Object> reqData) {
        Map<String, Object> managementData = null;
        try { 
            managementData = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.GET_ORDER_TYPEDEFINELIST, null)
                        , null, CscUtils.getCloudParam(reqData)
                        , null,  new TypeReference<Map<String,Object>>(){}.getType());
            // System.err.println(managementData);
            return managementData;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.GET_ORDER_TYPEDEFINELIST, null));
        }
    }
 
    @Override
    public Map<String, Object> busTypeByComp(Map<String, Object> reqData) {
        Map<String,Object> appointData = null;
        try {
            appointData = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.GET_BUS_TYPEBYCOMP, null)
                        , null, CscUtils.getCloudParam(reqData)
                        , null,  new TypeReference<Map<String,Object>>(){}.getType());
            // System.err.println(appointData);
            if(!Objects.equals(appointData.get("rspCode"), "000000")){
                throw new IEMRuntimeException(Objects.toString(appointData.get("rspDesc")));
            }
            return appointData;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.GET_BUS_TYPEBYCOMP, null));
        }
    }
 
    @Override
    public Tenant getTenantAndCompany(Integer tenantId) {
        return findTenantCompanys(tenantId);
 
    }
    
    @Override
    public Tenant getTenantAndCompany(Integer tenantId,Integer companyId) {
        return getTenantAndCompany(tenantId, company ->Objects.equals(company.getId(), companyId));
    }
 
    public Tenant getTenantAndCompany(Integer tenantId, CompareCompany compareCompany){
        Tenant tenant = getTenantAndCompany(tenantId);
        if(ObjectUtil.empty(tenant) || ObjectUtil.empty(tenant.getCompanys())){
            return tenant;
        }
        for(Company comp : tenant.getCompanys()){
            if(compareCompany.equ(comp)){
                return new Tenant(tenant, comp);
            }
        }
        return new Tenant(tenant, null);
    }
    
    /**
     * 获取主数据定义
     */
    @Override
    public List<Map> getTenantDefine(Map<String, Object> map) {
        Map<String,Object> appointData = null;
        try {
            appointData = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.GET_TENANT_DEFINEMASTER, null)
                        , null, CscUtils.getCloudParam(map)
                        , null,  new TypeReference<Map<String,Object>>(){}.getType());
            // System.err.println("获取主数据定义:"+appointData);
            Map<String,Object> define = JSONTool.toObj(JSONTool.toJson(appointData.get("data")),Map.class);
            return JSONTool.toList(JSONTool.toJson(define.get("rows")),Map.class);
             
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.GET_TENANT_DEFINEMASTER, null));
        }
    }
    
    /**
     * 获取主数据元素
     */
    @Override
    public List<Map> getTenantEle(Map<String, Object> map) {
        Map<String,Object> appointData = null;
        try {
            appointData = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.GET_TENANT_ELEMASTER, null)
                        , null, CscUtils.getCloudParam(map)
                        , null,  new TypeReference<Map<String,Object>>(){}.getType());
            // System.err.println("获取主数据元素:"+JSONTool.toJson(appointData));
            return JSONTool.toList(JSONTool.toJson(appointData.get("data")),Map.class);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.GET_TENANT_ELEMASTER, null));
        }
    }
    
    /**
     * 获取主数据value
     */
    @Override
    public List<Map> getTenantValue(Map<String, Object> map) {
        Map<String,Object> appointData = null;
        try {
            appointData = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.GET_TENANT_VALUEMASTER, null)
                        , null, CscUtils.getCloudParam(map)
                        , null,  new TypeReference<Map<String,Object>>(){}.getType());
            // System.err.println("获取主数据值:"+JSONTool.toJson(appointData));
            return JSONTool.toList(JSONTool.toJson(appointData.get("data")),Map.class);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.GET_TENANT_VALUEMASTER, null));
        }
    }
 
    /**
     * 向租户云单添加人员
     */
    @Override
    public int addUserInfo(Map<String,Object> map) {
        // System.out.println("入参:"+JSONTool.toJson(map));
        //默认参数
        map.put("platFrom","费用云系统");
        Map<String,Object> res = null;
        try {
            res = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.ADD_USER_USERTOCSC, null)
                        , null, CscUtils.getCloudParam(map)
                        , null,  new TypeReference<Map<String,Object>>(){}.getType());
            // System.out.println("返回结果:"+JSONTool.toJson(res));
            return 1;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.GET_TENANT_VALUEMASTER, null));
        }
    }
 
    @Override
    public Company getCompany() {
        return findTenantsAndCompanys().getCompany();
    }
 
    @Override
    public PowerKey getSubCompanySystem(Integer companyId) {
        return Http.post(changHongProperties.getYsx()+"/csc-ie-user/rest/json/api/tenant/findSubCompanySystem", SubCompanyResult.class)
                .addUrlParam(
                        CscUtils.getParam(
                                new ModelMap("companyId", companyId)
                                        .addAttribute("appKey", changHongProperties.getPermissionAppKey())
                        )
                )
                .execute(SubCompanyResult.class)
                .map(SubCompanyResult::getPremission)
                .orElse(null);
    }
 
    public static void main(String... args){
        CscApiService a = new CscApiServiceImpl(){
            {
                setChangHongProperties(new ChangHongProperties(){
                    {
                        setYsx("http://csza.chfcloud.com");
//                        setPermissionAppKey("951176a2b1fc4862ae997a5e80fc71ed");
                        setCscPrivateKey("fa5e4cca8dc79ad8aa333e867b2ecb10");
                        setCscId("1000000");
                    }
                });
            }
        };
//        System.out.println(JSONTool.toJson(a.getSubCompanySystem(439)));
        a.initTenant(100000001);
    }
 
    @Data
    public static class SubCompanyResult{
        private PowerKey premission;
    }
 
    @Override
    public PageResult<Tenant> getTenants(Tenant tenant) {
 
//        return new PageResult<>(
//                Arrays.asList(
//                        new Tenant(){
//                            {
//                                setId(1);
//                                setCode("1001");
//                                setName("租户1");
//                            }
//                        },
//                        new Tenant(){
//                            {
//                                setId(2);
//                                setCode("1002");
//                                setName("租户2");
//                            }
//                        },
//                        new Tenant(){
//                            {
//                                setId(3);
//                                setCode("1003");
//                                setName("租户3");
//                            }
//                        },
//                        new Tenant(){
//                            {
//                                setId(4);
//                                setCode("1004");
//                                setName("租户4");
//                            }
//                        },
//                        new Tenant(){
//                            {
//                                setId(5);
//                                setCode("1005");
//                                setName("租户5");
//                            }
//                        }
//                )
//        );
 
        return (PageResult<Tenant>)Http.post(changHongProperties.getYsx()+"/csc-ie-user/rest/json/api/tenant/findTenantsPage", CscResult.class)
                .addUrlParam(CscUtils.getParam(
                        new ModelMap("name", tenant.getName())
                        .addAttribute("pageNum", tenant.getPageNum())
                        .addAttribute("pageSize", tenant.getPageSize())
                ))
                .execute(new TypeReference<CscResult<PageResult<Tenant>>>(){}.getType())
                .map(CscResult::getData)
                .orElse(new PageResult<>());
//        return (PageResult<Tenant>)Http.post(changHongProperties.getYsx()+"/csc-ie-user/rest/json/api/tenant/findTenants", CscResult.class)
//                .addUrlParam(CscUtils.getParam(new ModelMap()))
//                .execute(new TypeReference<CscResult<PageResult<Tenant>>>(){}.getType())
//                .map(CscResult::getData)
//                .orElse(null);
    }
 
    @Override
    public PageResult<Company> getCompanys(Company company){
//        return new PageResult<>(
//                Arrays.asList(
//                        new Company(){
//                            {
//                                setId(new Random().nextInt(1000));
//                                setCode(company.getTenantId()+"1001");
//                                setName("公司"+getCode());
//                            }
//                        },
//                        new Company(){
//                            {
//                                setId(new Random().nextInt(1000));
//                                setCode(company.getTenantId()+"1002");
//                                setName("公司"+getCode());
//                            }
//                        },
//                        new Company(){
//                            {
//                                setId(new Random().nextInt(1000));
//                                setCode(company.getTenantId()+"1003");
//                                setName("公司"+getCode());
//                            }
//                        },
//                        new Company(){
//                            {
//                                setId(new Random().nextInt(1000));
//                                setCode(company.getTenantId()+"1004");
//                                setName("公司"+getCode());
//                            }
//                        },
//                        new Company(){
//                            {
//                                setId(new Random().nextInt(1000));
//                                setCode(company.getTenantId()+"1005");
//                                setName("公司"+getCode());
//                            }
//                        }
//                )
//        );
 
        return (PageResult<Company>)Http.post(changHongProperties.getYsx()+"/csc-ie-user/rest/json/api/tenant/findCompanysPage", CscResult.class)
                .addUrlParam(CscUtils.getParam(
                        new ModelMap("tenantId", company.getTenantId())
                                .addAttribute("name", company.getName())
                                .addAttribute("pageNum", company.getPageNum())
                                .addAttribute("pageSize", company.getPageSize())
                ))
                .execute(new TypeReference<CscResult<PageResult<Company>>>(){}.getType())
                .map(CscResult::getData)
                .orElse(new PageResult<>());
    }
 
    @Override
    public void initTenant(Integer tenantId) {
        Map<String, Object> res =
            Http.post(changHongProperties.getYsx()+"/csc-ie-api/rest/json/fyyTenantInit", Map.class)
                .addUrlParam(CscUtils.getParam(
                        new ModelMap("tenantId", tenantId)
//                        new ModelMap("tenantCode", "R00002")
                        , changHongProperties.getCscId()
                        , changHongProperties.getCscPrivateKey()
                ))
                .execute(Map.class)
                .orElse(new ModelMap());
        if("000000".equals(res.get("rspCode"))){
            throw new IEMHttpException(Objects.toString(res.get("rspDesc")));
        }
    }
 
    @Override
    public int updateUserName(Map<String,Object> userInfo) {
        userInfo.put("openId",ThreadData.get(OPEN_ID));
        int i = -1;
        Map<String,Object> res = null;
        try {
            res = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.UPDATE_USERINFO,
                    new ModelMap("token", ThreadData.get(TOKEN))
                            .addAttribute("livemode", changHongProperties.getSsoLivemode()))
                    , null, null
                    , userInfo,  new TypeReference<Map<String,Object>>(){}.getType());
            // System.out.println("返回结果:"+JSONTool.toJson(res));
            if(res != null && res.get("result")!=null){
                i = "200".equals(JSONTool.toObj(JSONTool.toJson(res.get("result")),Map.class).get("code"))?1:-1;
            }
            return i;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.UPDATE_USERINFO, null));
        }
    }
 
    @Override
    @Cacheable
    public TenantsAndCompanys findTenantAndOrg() {
        return Http.post(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_TENANTANDORG, null), TenantsAndCompanys.class)
                .addUrlParam(CscUtils.getParam(new ModelMap()))
                .execute(new TypeReference<TenantsAndCompanys>(){}.getType())
                .orElse(new TenantsAndCompanys());
    }
 
    /**
     * 自动创单
     */
    @Override
    public Map<String, Object> orderAccountFyy(Map<String, Object> map) {
        try {
            return HttpUtil.post(changHongProperties.getPassUrl(PassPortName.JSON_ORDER_ORDERACCOUNTFYY, null)
                    ,null, CscUtils.getParam(map)
                    , null,  new TypeReference<Map<String,Object>>(){}.getType());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002)
                    .setchildIEMExc(changHongProperties.getPassUrl(PassPortName.JSON_ORDER_ORDERACCOUNTFYY, null))
                    .addSuper(e);
        }
    }
 
    /**
     * 创建订单
     */
    @Override
    public String addOrder(Map<String, Object> map) {
        Map<String,Object> maps = null;
        try {
            maps = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.JSON_ORDER_ADDORDER, null)
                    ,null, CscUtils.getParam(map)
                    , null,  new TypeReference<Map<String,Object>>(){}.getType());
            log.debug("云上行返回数据:"+ JSONTool.toJson(maps));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_TENANTANDORG, null));
        }
        String res = Objects.toString(maps.get("orderCode"),null);
        return res!=null?res:null;
    }
 
    @Override
    public String getOrgVersion() {
        Map<String,Object> maps;
        try {
            maps = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.FIND_ORGANIZATION_VERSION, null)
                    ,null, CscUtils.getParam(new ModelMap("companyId",ThreadData.get(COMPANY_ID)))
                    , null,  new TypeReference<Map<String,Object>>(){}.getType());
            log.debug("云上行返回数据:"+ JSONTool.toJson(maps));
            if(maps == null){
                return "";
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.FIND_TENANT_TENANTANDORG, null));
        }
        return Objects.toString(maps.get("version"),"");
    }
 
    @Override
    public Map<String, Object> backRule(Map<String, Object> billInfo) {
        Map<String,Object> maps;
        try {
            maps = HttpUtil.post(changHongProperties.getPassUrl(PassPortName.ORDER_BACKRULE, null)
                    ,null, CscUtils.getParam(billInfo)
                    , null,  new TypeReference<Map<String,Object>>(){}.getType());
            log.debug("云上行返回数据:"+ JSONTool.toJson(maps));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new IEMRuntimeException(C0002).setchildIEMExc(changHongProperties.getPassUrl(PassPortName.ORDER_BACKRULE, null));
        }
        return maps;
    }
 
    @Override
    public List<Company> getCompanyOrgs(Integer tenantId) {
        return Http.post(changHongProperties.getYsx() + "/csc-ie-user/rest/json/api/tenant/findCompanysAndOrg", CscResult.class)
                .addUrlParam(CscUtils.getParam(new ModelMap("tenantId", tenantId)))
                .execute(new TypeReference<CscResult>(){}.getType())
                .map(CscResult::getCompanys)
                .orElse(Collections.EMPTY_LIST);
    }
 
}