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.vo.*;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
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 javax.crypto.Cipher;
|
import javax.crypto.spec.SecretKeySpec;
|
import java.util.Base64;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.UUID;
|
|
import static cn.huge.base.common.utils.AesUtils.KEY_ALGORITHM;
|
|
@Slf4j
|
@Service
|
public class GridCompanyService {
|
@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 R<GridCompanyDTO> getCompanyList(@RequestBody GridCompanyVo gridCompanyVo) throws Exception {
|
HeadVo headVo = initHeadVo();
|
GridCompanyRequestVo requestVo = new GridCompanyRequestVo();
|
requestVo.setHeadVo(headVo);
|
requestVo.setBodyVo(gridCompanyVo);
|
log.info("xsd:{}", JSON.toJSONString(requestVo));
|
log.info("xsd:{}", gridUrl + "/sbss/unit/getList");
|
String s = null;
|
try {
|
s = HttpClientUtils.httpPostRaw(gridUrl + "/sbss/unit/getList", 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) {
|
GridCompanyDTO data = object.getObject("data", GridCompanyDTO.class);
|
List<GridCompanyDTO.UnitDTO> records = data.getRecords();
|
for(GridCompanyDTO.UnitDTO item :records){
|
item.setLegalRepresent(AesUtils.decrypt(item.getLegalRepresent(),"eb4KhdJRyDwS4ndTBc2NTDNaSEP6KbwQ"));
|
|
}
|
return R.ok(data);
|
} else {
|
return R.fail("获取企业信息失败");
|
}
|
}
|
|
public HeadVo initHeadVo() {
|
HeadVo headVo = new HeadVo();
|
headVo.setUsername(userName);
|
headVo.setPassword(passWord);
|
headVo.setRequestId(UUID.randomUUID().toString());
|
headVo.setSource("string");
|
return headVo;
|
}
|
|
}
|