forked from gzzfw/backEnd/gz-dyh

liyj
2024-09-21 99de75de811efed36da1d37bcf5442ae96384f6e
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
package cn.huge.module.grid.service;
 
import cn.huge.base.common.bo.R;
import cn.huge.base.common.utils.AesUtils;
import cn.huge.base.common.utils.HttpClientUtils;
import cn.huge.module.grid.domain.dto.GridCompanyDTO;
import cn.huge.module.grid.domain.dto.GridOrgDTO;
import cn.huge.module.grid.domain.vo.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
 
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
 
@Slf4j
@Service
public class GridOrgService {
    @Value("${grid.url:http://219.137.166.84:8061}")
    private String gridUrl;
    @Value("${grid.username:mtxt0011}")
    private String userName;
    @Value("${grid.password}")
    private String passWord;
 
    public HeadVo initHeadVo() {
        HeadVo headVo = new HeadVo();
        headVo.setUsername(userName);
        headVo.setPassword(passWord);
        headVo.setRequestId(UUID.randomUUID().toString());
        headVo.setSource("string");
        return headVo;
    }
 
    public R<GridOrgDTO> getOrgList(GridOrgVo gridOrgVo) {
        HeadVo headVo = initHeadVo();
        GridOrgRequestVo requestVo = new GridOrgRequestVo();
        requestVo.setHeadVo(headVo);
        requestVo.setBodyVo(gridOrgVo);
        log.info("xsd:{}", JSON.toJSONString(requestVo));
        log.info("xsd:{}", gridUrl + "/sys/getOrgList");
        String s = null;
        try {
            s = HttpClientUtils.httpPostRaw(gridUrl + "/sys/getOrgList", JSON.toJSONString(requestVo), new HashMap<>(), "utf-8");
        } catch (Exception e) {
            log.info("xsderror:{}", e);
            throw new RuntimeException(e);
        }
        log.info("xsd:{}", s);
        JSONObject object = JSONObject.parseObject(s);
        if (object.getInteger("code") != null && object.getInteger("code") == 0) {
            GridOrgDTO data = object.getObject("data", GridOrgDTO.class);
            return R.ok(data);
        } else {
            return R.fail("获取企业信息失败");
        }
    }
}