From 55132b44cd49f2a312a8fb2523ffda35a7485fd7 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 09 十月 2025 16:07:08 +0800 Subject: [PATCH] 提交代码 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EnterpriseUtil.java | 119 +++++++++++++++++++++++++++-------------------------------- 1 files changed, 55 insertions(+), 64 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EnterpriseUtil.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EnterpriseUtil.java index 21cf980..8510099 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EnterpriseUtil.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EnterpriseUtil.java @@ -5,8 +5,10 @@ import com.google.gson.Gson; import com.open.common.util.OpenApiClient; import com.open.common.util.SystemParameterNames; -import com.supersavedriving.user.modular.system.util.SpringContextsUtil; -import com.supersavedriving.user.modular.system.util.qianyuntong.model.*; +import com.supersavedriving.driver.modular.system.util.SpringContextsUtil; +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; @@ -26,20 +28,6 @@ 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); - - } /** * 根据社会信用代码判断企业是否已存在 @@ -219,54 +207,6 @@ 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); - } - - /** * 删除企业信息 * @@ -313,4 +253,55 @@ } 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); + } } -- Gitblit v1.7.1