【数据资产】
数据港接口调用
Showing
4 changed files
with
64 additions
and
10 deletions
| ... | @@ -21,4 +21,6 @@ public class DataPortConfig { | ... | @@ -21,4 +21,6 @@ public class DataPortConfig { |
| 21 | private String requestUri; | 21 | private String requestUri; |
| 22 | private String operatorRegisterUri; | 22 | private String operatorRegisterUri; |
| 23 | private String enterpriseRegisterUri; | 23 | private String enterpriseRegisterUri; |
| 24 | private String operatorUpdateUri; | ||
| 25 | private String enterpriseUpdateUri; | ||
| 24 | } | 26 | } | ... | ... |
| ... | @@ -4,7 +4,8 @@ import com.csbr.cloud.common.entity.CsbrUpdate; | ... | @@ -4,7 +4,8 @@ import com.csbr.cloud.common.entity.CsbrUpdate; |
| 4 | import com.csbr.cloud.common.response.CommonRes; | 4 | import com.csbr.cloud.common.response.CommonRes; |
| 5 | import com.csbr.cloud.workflow.domain.dto.callback.BizCallbackDTO; | 5 | import com.csbr.cloud.workflow.domain.dto.callback.BizCallbackDTO; |
| 6 | import com.csbr.qingcloud.portal.domain.vo.*; | 6 | import com.csbr.qingcloud.portal.domain.vo.*; |
| 7 | import com.csbr.qingcloud.portal.mybatis.entity.MfEnterprise; | 7 | import com.csbr.qingcloud.portal.mybatis.entity.MfEnterpriseChangeApprove; |
| 8 | import com.csbr.qingcloud.portal.mybatis.service.MfEnterpriseChangeApproveService; | ||
| 8 | import com.csbr.qingcloud.portal.mybatis.service.MfEnterpriseService; | 9 | import com.csbr.qingcloud.portal.mybatis.service.MfEnterpriseService; |
| 9 | import com.csbr.qingcloud.portal.service.DataPortService; | 10 | import com.csbr.qingcloud.portal.service.DataPortService; |
| 10 | import com.csbr.qingcloud.portal.service.DemandService; | 11 | import com.csbr.qingcloud.portal.service.DemandService; |
| ... | @@ -136,13 +137,16 @@ public class DemandController { | ... | @@ -136,13 +137,16 @@ public class DemandController { |
| 136 | private MfEnterpriseService mfEnterpriseService; | 137 | private MfEnterpriseService mfEnterpriseService; |
| 137 | 138 | ||
| 138 | @Resource | 139 | @Resource |
| 140 | private MfEnterpriseChangeApproveService mfEnterpriseChangeApproveService; | ||
| 141 | |||
| 142 | @Resource | ||
| 139 | private DataPortService dataPortService; | 143 | private DataPortService dataPortService; |
| 140 | 144 | ||
| 141 | @GetMapping("/test") | 145 | @GetMapping("/test") |
| 142 | public CommonRes getToken(@RequestParam String guid) { | 146 | public CommonRes getToken(@RequestParam String guid) { |
| 143 | MfEnterprise entity = mfEnterpriseService.getById(guid); | 147 | MfEnterpriseChangeApprove entity = mfEnterpriseChangeApproveService.getById(guid); |
| 144 | dataPortService.operatorRegister(entity); | 148 | dataPortService.enterpriseUpdate(entity); |
| 145 | dataPortService.enterpriseRegister(entity); | 149 | dataPortService.operatorUpdate(entity); |
| 146 | return CommonRes.success(Boolean.TRUE); | 150 | return CommonRes.success(Boolean.TRUE); |
| 147 | } | 151 | } |
| 148 | 152 | ... | ... |
| ... | @@ -2,6 +2,7 @@ package com.csbr.qingcloud.portal.service.impl; | ... | @@ -2,6 +2,7 @@ package com.csbr.qingcloud.portal.service.impl; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.csbr.cloud.common.enums.RedisKeyEnum; | 4 | import com.csbr.cloud.common.enums.RedisKeyEnum; |
| 5 | import com.csbr.cloud.common.util.CsbrBeanUtil; | ||
| 5 | import com.csbr.cloud.distributelock.util.RedisUtil; | 6 | import com.csbr.cloud.distributelock.util.RedisUtil; |
| 6 | import com.csbr.qingcloud.portal.config.DataPortConfig; | 7 | import com.csbr.qingcloud.portal.config.DataPortConfig; |
| 7 | import com.csbr.qingcloud.portal.domain.vo.dataPort.EnterpriseRegisterRQVO; | 8 | import com.csbr.qingcloud.portal.domain.vo.dataPort.EnterpriseRegisterRQVO; |
| ... | @@ -16,7 +17,6 @@ import jakarta.annotation.Resource; | ... | @@ -16,7 +17,6 @@ import jakarta.annotation.Resource; |
| 16 | import lombok.extern.slf4j.Slf4j; | 17 | import lombok.extern.slf4j.Slf4j; |
| 17 | import org.apache.commons.lang3.ObjectUtils; | 18 | import org.apache.commons.lang3.ObjectUtils; |
| 18 | import org.apache.commons.lang3.StringUtils; | 19 | import org.apache.commons.lang3.StringUtils; |
| 19 | import org.jetbrains.annotations.NotNull; | ||
| 20 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 21 | 21 | ||
| 22 | import java.text.SimpleDateFormat; | 22 | import java.text.SimpleDateFormat; |
| ... | @@ -43,26 +43,41 @@ public class DataPortServiceImpl implements DataPortService { | ... | @@ -43,26 +43,41 @@ public class DataPortServiceImpl implements DataPortService { |
| 43 | @Resource | 43 | @Resource |
| 44 | private RedisUtil redisUtil; | 44 | private RedisUtil redisUtil; |
| 45 | 45 | ||
| 46 | @Resource | ||
| 47 | private CsbrBeanUtil csbrBeanUtil; | ||
| 48 | |||
| 46 | @Override | 49 | @Override |
| 47 | public void operatorRegister(MfEnterprise entity) { | 50 | public void operatorRegister(MfEnterprise entity) { |
| 51 | log.info("======经办人用户注册开始======"); | ||
| 48 | OperatorRegisterRQVO operatorRegisterRQVO = beforeOperator(entity); | 52 | OperatorRegisterRQVO operatorRegisterRQVO = beforeOperator(entity); |
| 49 | dataPortConnectUtil.postByAuthKey(operatorRegisterRQVO, dataPortConfig.getOperatorRegisterUri()); | 53 | dataPortConnectUtil.postByAuthKey(operatorRegisterRQVO, dataPortConfig.getOperatorRegisterUri()); |
| 54 | log.info("======经办人用户注册结束======"); | ||
| 50 | } | 55 | } |
| 51 | 56 | ||
| 52 | @Override | 57 | @Override |
| 53 | public void operatorUpdate(MfEnterpriseChangeApprove entity) { | 58 | public void operatorUpdate(MfEnterpriseChangeApprove entity) { |
| 54 | 59 | log.info("======经办人用户更新开始======"); | |
| 60 | MfEnterprise mfEnterprise = csbrBeanUtil.convert(entity, MfEnterprise.class); | ||
| 61 | OperatorRegisterRQVO operatorRegisterRQVO = beforeOperator(mfEnterprise); | ||
| 62 | dataPortConnectUtil.postByAuthKey(operatorRegisterRQVO, dataPortConfig.getOperatorUpdateUri()); | ||
| 63 | log.info("======经办人用户更新结束======"); | ||
| 55 | } | 64 | } |
| 56 | 65 | ||
| 57 | @Override | 66 | @Override |
| 58 | public void enterpriseRegister(MfEnterprise entity) { | 67 | public void enterpriseRegister(MfEnterprise entity) { |
| 68 | log.info("======法人用户注册开始======"); | ||
| 59 | EnterpriseRegisterRQVO enterpriseRegisterRQVO = beforeEnterprise(entity); | 69 | EnterpriseRegisterRQVO enterpriseRegisterRQVO = beforeEnterprise(entity); |
| 60 | dataPortConnectUtil.postByAuthKey(enterpriseRegisterRQVO, dataPortConfig.getEnterpriseRegisterUri()); | 70 | dataPortConnectUtil.postByAuthKey(enterpriseRegisterRQVO, dataPortConfig.getEnterpriseRegisterUri()); |
| 71 | log.info("======法人用户注册结束======"); | ||
| 61 | } | 72 | } |
| 62 | 73 | ||
| 63 | @Override | 74 | @Override |
| 64 | public void enterpriseUpdate(MfEnterpriseChangeApprove entity) { | 75 | public void enterpriseUpdate(MfEnterpriseChangeApprove entity) { |
| 65 | 76 | log.info("======法人用户更新开始======"); | |
| 77 | MfEnterprise mfEnterprise = csbrBeanUtil.convert(entity, MfEnterprise.class); | ||
| 78 | EnterpriseRegisterRQVO enterpriseRegisterRQVO = beforeEnterprise(mfEnterprise); | ||
| 79 | dataPortConnectUtil.postByAuthKey(enterpriseRegisterRQVO, dataPortConfig.getEnterpriseUpdateUri()); | ||
| 80 | log.info("======法人用户更新结束======"); | ||
| 66 | } | 81 | } |
| 67 | 82 | ||
| 68 | /** | 83 | /** |
| ... | @@ -90,7 +105,7 @@ public class DataPortServiceImpl implements DataPortService { | ... | @@ -90,7 +105,7 @@ public class DataPortServiceImpl implements DataPortService { |
| 90 | operatorRegisterRQVO.setEnterpriseCode(entity.getSocialCreditCode()); | 105 | operatorRegisterRQVO.setEnterpriseCode(entity.getSocialCreditCode()); |
| 91 | OperatorSubordinateRQVO operatorSubordinateRQVO = new OperatorSubordinateRQVO(); | 106 | OperatorSubordinateRQVO operatorSubordinateRQVO = new OperatorSubordinateRQVO(); |
| 92 | operatorSubordinateRQVO.setEnterpriseName(entity.getTenantName()); | 107 | operatorSubordinateRQVO.setEnterpriseName(entity.getTenantName()); |
| 93 | operatorSubordinateRQVO.setBusinessLicense(getUrl(entity.getBusinessLicenseJson())); | 108 | operatorSubordinateRQVO.setBusinessLicense(getName(entity.getBusinessLicenseJson())); |
| 94 | operatorRegisterRQVO.setExtendInfo(operatorSubordinateRQVO); | 109 | operatorRegisterRQVO.setExtendInfo(operatorSubordinateRQVO); |
| 95 | return operatorRegisterRQVO; | 110 | return operatorRegisterRQVO; |
| 96 | } | 111 | } |
| ... | @@ -129,7 +144,7 @@ public class DataPortServiceImpl implements DataPortService { | ... | @@ -129,7 +144,7 @@ public class DataPortServiceImpl implements DataPortService { |
| 129 | extendInfo.setBusinessScope(entity.getBusinessLicenseScope()); | 144 | extendInfo.setBusinessScope(entity.getBusinessLicenseScope()); |
| 130 | extendInfo.setIndustryCategory(industryDicMap.get(entity.getIndustry())); | 145 | extendInfo.setIndustryCategory(industryDicMap.get(entity.getIndustry())); |
| 131 | extendInfo.setIndustryCategory2(industryDicMap.get(entity.getIndustrySmallcode())); | 146 | extendInfo.setIndustryCategory2(industryDicMap.get(entity.getIndustrySmallcode())); |
| 132 | extendInfo.setBusinessLicense(getUrl(entity.getBusinessLicenseJson())); | 147 | extendInfo.setBusinessLicense(getName(entity.getBusinessLicenseJson())); |
| 133 | enterpriseRegisterRQVO.setExtendInfo(extendInfo); | 148 | enterpriseRegisterRQVO.setExtendInfo(extendInfo); |
| 134 | return enterpriseRegisterRQVO; | 149 | return enterpriseRegisterRQVO; |
| 135 | } | 150 | } |
| ... | @@ -157,4 +172,14 @@ public class DataPortServiceImpl implements DataPortService { | ... | @@ -157,4 +172,14 @@ public class DataPortServiceImpl implements DataPortService { |
| 157 | } | 172 | } |
| 158 | return JSON.parseObject(businessLicenseJson).getString("url"); | 173 | return JSON.parseObject(businessLicenseJson).getString("url"); |
| 159 | } | 174 | } |
| 175 | |||
| 176 | private String getName(String businessLicenseJson) { | ||
| 177 | if (StringUtils.isEmpty(businessLicenseJson)) { | ||
| 178 | return null; | ||
| 179 | } | ||
| 180 | if (businessLicenseJson.contains("[")) { | ||
| 181 | return JSON.parseArray(businessLicenseJson).getJSONObject(0).getString("name"); | ||
| 182 | } | ||
| 183 | return JSON.parseObject(businessLicenseJson).getString("name"); | ||
| 184 | } | ||
| 160 | } | 185 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -103,7 +103,7 @@ public class DataPortConnectUtil { | ... | @@ -103,7 +103,7 @@ public class DataPortConnectUtil { |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | /** | 105 | /** |
| 106 | * 调用数据港接口 | 106 | * 调用数据港接口(authKey调用) |
| 107 | * @return | 107 | * @return |
| 108 | */ | 108 | */ |
| 109 | public Object postByAuthKey(Object obj, String uri) { | 109 | public Object postByAuthKey(Object obj, String uri) { |
| ... | @@ -125,4 +125,27 @@ public class DataPortConnectUtil { | ... | @@ -125,4 +125,27 @@ public class DataPortConnectUtil { |
| 125 | return dataPortRes.getData(); | 125 | return dataPortRes.getData(); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | /** | ||
| 129 | * 调用数据港接口(Authorization调用) | ||
| 130 | * @return | ||
| 131 | */ | ||
| 132 | public Object postByAuthorization(Object obj, String uri) { | ||
| 133 | HttpHeaders headers = new HttpHeaders(); | ||
| 134 | headers.set("Content-Type", "application/json"); | ||
| 135 | headers.set("Authorization", getToken()); | ||
| 136 | |||
| 137 | HttpEntity<Object> request = new HttpEntity<>(obj, headers); | ||
| 138 | DataPortRes dataPortRes = restTemplate.postForObject( | ||
| 139 | dataPortConfig.getRequestUri() + uri | ||
| 140 | , request, DataPortRes.class); | ||
| 141 | |||
| 142 | if (ObjectUtils.isEmpty(dataPortRes)) { | ||
| 143 | throw new CsbrSystemException(SystemError.DATA_GET_ERROR, "调用数据港接口失败."); | ||
| 144 | } | ||
| 145 | if (200 != dataPortRes.getCode() && 201 != dataPortRes.getCode()) { | ||
| 146 | throw new CsbrSystemException(SystemError.DATA_GET_ERROR, dataPortRes.getMessage()); | ||
| 147 | } | ||
| 148 | return dataPortRes.getData(); | ||
| 149 | } | ||
| 150 | |||
| 128 | } | 151 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment