From c0e9ac907ee658802f68eb4e770942e34e87cfd0 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期五, 25 七月 2025 16:43:50 +0800
Subject: [PATCH] Merge branches 'master' and 'master' of http://120.76.84.145:10101/gitblit/r/java/QianYunTong

---
 UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java |   80 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 72 insertions(+), 8 deletions(-)

diff --git a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
index 6dfe5af..bcc7a30 100644
--- a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
+++ b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/UserUtil.java
@@ -22,6 +22,62 @@
 public class UserUtil {
 	
 	
+	public static void main(String[] args) {
+		List<QYTUserInfo> userInfoByPhone = getUserInfoByPhone("15828353127", "981100006005951");
+		System.out.println(userInfoByPhone);
+	}
+	
+	
+	/**
+	 * 根据手机号码获取人员信息
+	 *
+	 * @param mobile 手机号码
+	 */
+	public static List<QYTUserInfo> getUserInfoByPhone(String mobile) {
+		//请求路径
+		String url = QianYunTongProperties.apiUrl + "/openapi/rest/2.0/queryUserinfoByMobilev2";
+		//私钥文件
+		String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
+		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
+		String appKey = QianYunTongProperties.appkey;//appkey
+		Map<String, String> headers = new HashMap<>();
+		headers.put("Content-Type", "application/json");
+		Map<String, Object> contentMap = new HashMap<String, Object>();
+		Date nowdate = new Date();
+		SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
+		
+		String timeStamp = date.format(nowdate);
+		String messageId = UUID.randomUUID().toString().replaceAll("-", "");
+		contentMap.put(SystemParameterNames.getAppKey(), appKey);
+		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
+		contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
+		contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
+		contentMap.put("content", "{\"list\":[{\"mobile\":\"" + mobile + "\"}]}");
+		log.info("【根据手机号码获取人员信息】请求地址:" + url);
+		log.info("【根据手机号码获取人员信息】请求参数:" + JSON.toJSONString(contentMap));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, contentMap);
+		log.info("【根据手机号码获取人员信息】请求结果:" + result);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【根据手机号码获取人员信息】请求失败:" + result);
+			return null;
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【根据手机号码获取人员信息】失败:" + object.toJSONString());
+			return null;
+		}
+		JSONArray data = object.getJSONObject("data").getJSONArray("list");
+		List<QYTUserInfo> list = new ArrayList<>();
+		for (int i = 0; i < data.size(); i++) {
+			QYTUserInfo userInfo = data.getObject(i, QYTUserInfo.class);
+			list.add(userInfo);
+		}
+		return list;
+	}
+	
 	/**
 	 * 根据手机号码获取人员信息
 	 *
@@ -47,22 +103,27 @@
 		contentMap.put(SystemParameterNames.getMessage_id(), messageId);
 		contentMap.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
 		contentMap.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
-		contentMap.put("content", "{\"mobile\":\"" + mobile + "\",\"enterNum\":\"" + enterNum + "\"}");
-		log.info("【根据手机号和企业编号查询用户信息】请求地址:" + url);
-		log.info("【根据手机号和企业编号查询用户信息】请求参数:" + JSON.toJSONString(contentMap));
+		Map<String, String> map = new HashMap<>();
+		map.put("mobile", mobile);
+		if (null != enterNum) {
+			map.put("enterNum", enterNum);
+		}
+		contentMap.put("content", JSON.toJSONString(map));
+		log.info("【根据手机号码获取人员信息】请求地址:" + url);
+		log.info("【根据手机号码获取人员信息】请求参数:" + JSON.toJSONString(contentMap));
 		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, contentMap);
-		log.info("【根据手机号和企业编号查询用户信息】请求结果:" + result);
+		log.info("【根据手机号码获取人员信息】请求结果:" + result);
 		JSONObject jsonObject = JSON.parseObject(result);
 		String retCode = jsonObject.getString("retCode");
 		if (!"0".equals(retCode)) {
-			log.error("【根据手机号和企业编号查询用户信息】请求失败:" + result);
-			throw new RuntimeException("【根据手机号和企业编号查询用户信息】请求失败:" + result);
+			log.error("【根据手机号码获取人员信息】请求失败:" + result);
+			return null;
 		}
 		JSONObject object = jsonObject.getJSONObject("object");
 		String status = object.getString("status");
 		if (!"0".equals(status)) {
-			log.error("【根据手机号和企业编号查询用户信息】失败:" + object.toJSONString());
-			throw new RuntimeException("【根据手机号和企业编号查询用户信息】失败:" + object.toJSONString());
+			log.error("【根据手机号码获取人员信息】失败:" + object.toJSONString());
+			return null;
 		}
 		JSONArray data = object.getJSONArray("data");
 		List<QYTUserInfo> list = new ArrayList<>();
@@ -211,4 +272,7 @@
 		}
 		return true;
 	}
+	
+	
+	
 }

--
Gitblit v1.7.1