| | |
| | | import com.open.common.util.OpenApiClient; |
| | | import com.open.common.util.SystemParameterNames; |
| | | import com.supersavedriving.driver.modular.system.util.SpringContextsUtil; |
| | | import com.supersavedriving.driver.modular.system.util.qianyuntong.model.*; |
| | | import com.supersavedriving.driver.modular.system.util.qianyuntong.model.CheckEnterExist; |
| | | import com.supersavedriving.driver.modular.system.util.qianyuntong.model.EnterpriseInfo; |
| | | import com.supersavedriving.driver.modular.system.util.qianyuntong.model.ModifyEnterpriseInfoRequest; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | |
| | | |
| | | private static QianYunTongConfig qianYunTongConfig = SpringContextsUtil.getBean(QianYunTongConfig.class).getQianYunTongConfig(); |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | // CheckEnterExist checkEnterNameExist = checkEnterNameExist("黔南云码通数字产业运营有限公司"); |
| | | // System.err.println(checkEnterNameExist); |
| | | |
| | | CreateEnterpriseRequest request = new CreateEnterpriseRequest(); |
| | | request.setName("成都喜望科技有限公司"); |
| | | request.setNickName("成都喜望"); |
| | | request.setIndustry_code("123456"); |
| | | request.setMobile("15828353127"); |
| | | CreateEnterprise enterprise = EnterpriseUtil.createEnterprise(request); |
| | | System.out.println(enterprise); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据社会信用代码判断企业是否已存在 |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建企业 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static CreateEnterprise createEnterprise(CreateEnterpriseRequest request) { |
| | | //请求路径 |
| | | String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/createEnterprise"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath(); |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = qianYunTongConfig.getAppkey();//appkey |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | map.put(SystemParameterNames.getAppKey(), appKey); |
| | | map.put(SystemParameterNames.getMessage_id(), messageId); |
| | | map.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName()); |
| | | map.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus()); |
| | | map.put("content", new Gson().toJson(request)); |
| | | |
| | | log.info("【创建企业】请求地址:" + url); |
| | | log.info("【创建企业】请求参数:" + JSON.toJSONString(map)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map); |
| | | log.info("【创建企业】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【创建企业】请求失败:" + result); |
| | | throw new RuntimeException("【创建企业】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【创建企业】请求失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【创建企业】请求失败:" + object.toJSONString()); |
| | | } |
| | | return object.getObject("data", CreateEnterprise.class); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除企业信息 |
| | | * |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | CheckEnterExist checkEnterExist = EnterpriseUtil.checkEnterNameExist("成都喜望科技有限公司"); |
| | | System.out.println(checkEnterExist); |
| | | } |
| | | |
| | | /** |
| | | * 创建企业 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static CreateEnterprise createEnterprise(CreateEnterpriseRequest request) { |
| | | //请求路径 |
| | | String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/createEnterprise"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath(); |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = qianYunTongConfig.getAppkey();//appkey |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUID.randomUUID().toString().replaceAll("-", ""); |
| | | map.put(SystemParameterNames.getAppKey(), appKey); |
| | | map.put(SystemParameterNames.getMessage_id(), messageId); |
| | | map.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName()); |
| | | map.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus()); |
| | | map.put("content", new Gson().toJson(request)); |
| | | |
| | | log.info("【创建企业】请求地址:" + url); |
| | | log.info("【创建企业】请求参数:" + JSON.toJSONString(map)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, map); |
| | | log.info("【创建企业】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String retCode = jsonObject.getString("retCode"); |
| | | if (!"0".equals(retCode)) { |
| | | log.error("【创建企业】请求失败:" + result); |
| | | throw new RuntimeException("【创建企业】请求失败:" + result); |
| | | } |
| | | JSONObject object = jsonObject.getJSONObject("object"); |
| | | String status = object.getString("status"); |
| | | if (!"0".equals(status)) { |
| | | log.error("【创建企业】请求失败:" + object.toJSONString()); |
| | | throw new RuntimeException("【创建企业】请求失败:" + object.toJSONString()); |
| | | } |
| | | return object.getObject("data", CreateEnterprise.class); |
| | | } |
| | | } |