From 74f8b8074a2fb391b5363b4dca5f99bf31993430 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 11 八月 2025 22:22:07 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/QYTDriving

---
 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EmployeeUtil.java |  234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 234 insertions(+), 0 deletions(-)

diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EmployeeUtil.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EmployeeUtil.java
new file mode 100644
index 0000000..5c83c87
--- /dev/null
+++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/qianyuntong/EmployeeUtil.java
@@ -0,0 +1,234 @@
+package com.supersavedriving.driver.modular.system.util.qianyuntong;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.open.common.util.OpenApiClient;
+import com.open.common.util.SystemParameterNames;
+import com.supersavedriving.driver.modular.system.util.ResultUtil;
+import com.supersavedriving.driver.modular.system.util.SpringContextsUtil;
+import com.supersavedriving.driver.modular.system.util.qianyuntong.model.*;
+import lombok.extern.slf4j.Slf4j;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * 企业员工工具类
+ *
+ * @author zhibing.pu
+ * @Date 2025/6/6 16:17
+ */
+@Slf4j
+public class EmployeeUtil {
+	
+	private static QianYunTongConfig qianYunTongConfig = SpringContextsUtil.getBean(QianYunTongConfig.class).getQianYunTongConfig();
+	
+	public static void main(String[] args) {
+		SaveStaffNodeRequest request = new SaveStaffNodeRequest();
+		request.setMobile("15828353127");
+		request.setEntercode("981100006005951");
+		request.setEmpName("蒲");
+		request.setEmpNickname("蒲");
+		request.setLoginNo("15828353125");
+		request.setEmpSex("男");
+		request.setMphone("15828353125");
+		request.setEmail("15828353125@qyt.com");
+		request.setDeptId(0);
+		request.setPositionId(1);
+		request.setSuperLevel(0);
+		request.setHideMobile(0);
+		ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request);
+		System.out.println(resultUtil.getData());
+	}
+	
+	
+	/**
+	 * 企业增加员工
+	 *
+	 * @param request
+	 * @return
+	 */
+	public static ResultUtil<SaveStaffNode> saveStaffNode(SaveStaffNodeRequest request) {
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/saveStaffNode";
+		//私钥文件
+		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> 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(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		contentMap.put("content", new Gson().toJson(request));
+		log.info("【企业增加员工】请求地址:" + url);
+		log.info("【企业增加员工】请求参数:" + JSON.toJSONString(contentMap));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap);
+		log.info("【企业增加员工】请求结果:" + result);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【企业增加员工】请求失败:" + result);
+			String retMsg = jsonObject.getString("retMsg");
+			retMsg = retMsg.substring(retMsg.indexOf("{"));
+			jsonObject = JSON.parseObject(retMsg);
+			return ResultUtil.error("【企业增加员工】请求失败:" + jsonObject.getString("msg"));
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【企业增加员工】失败:" + object.toJSONString());
+			return ResultUtil.error("【企业增加员工】失败:" + object.getString("desc"));
+		}
+		SaveStaffNode saveStaffNode = object.getObject("data", SaveStaffNode.class);
+		return ResultUtil.success(saveStaffNode);
+	}
+	
+	
+	/**
+	 * 企业修改员工信息
+	 * @param request
+	 * @return
+	 */
+	public static Boolean editStaffNode(EditStaffNodeRequest request){
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/editStaffNode";
+		//私钥文件
+		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> 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(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		contentMap.put("content", new Gson().toJson(request));
+		log.info("【企业修改员工信息】请求地址:" + url);
+		log.info("【企业修改员工信息】请求参数:" + JSON.toJSONString(contentMap));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap);
+		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 true;
+	}
+	
+	
+	/**
+	 * 企业删除人员
+	 * @param request
+	 * @return
+	 */
+	public static Boolean ecrmDeleteStafNode(DeleteStafNodeRequest request){
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/ecrmDeleteStafNode";
+		//私钥文件
+		String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath();
+		//注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
+		String appKey = qianYunTongConfig.getAppkey();//appkey
+		String content = "";//业务参数
+		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(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		contentMap.put("content", new Gson().toJson(request));
+		log.info("【企业删除人员】请求地址:" + url);
+		log.info("【企业删除人员】请求参数:" + JSON.toJSONString(contentMap));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap);
+		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 true;
+	}
+	
+	
+	/**
+	 * 根据员工ID获取人员信息
+	 * @param request
+	 * @return
+	 */
+	public static StaffNodeInfo getStaffNode(GetStaffNodeRequest request){
+		//请求路径
+		String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/getStaffNode";
+		//私钥文件
+		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> 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(), qianYunTongConfig.getUserName());
+		contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus());
+		contentMap.put("content", new Gson().toJson(request));
+		log.info("【根据员工ID获取人员信息】请求地址:" + url);
+		log.info("【根据员工ID获取人员信息】请求参数:" + JSON.toJSONString(contentMap));
+		String result = OpenApiClient.sendCommonHttpRequst(url, headers, "GET", skprivateKeyFile, timeStamp, contentMap);
+		log.info("【根据员工ID获取人员信息】请求结果:" + result);
+		JSONObject jsonObject = JSON.parseObject(result);
+		String retCode = jsonObject.getString("retCode");
+		if (!"0".equals(retCode)) {
+			log.error("【根据员工ID获取人员信息】请求失败:" + result);
+			return null;
+		}
+		JSONObject object = jsonObject.getJSONObject("object");
+		String status = object.getString("status");
+		if (!"0".equals(status)) {
+			log.error("【根据员工ID获取人员信息】失败:" + object.toJSONString());
+			return null;
+		}
+		StaffNodeInfo staffNodeInfo = object.getObject("data", StaffNodeInfo.class);
+		return staffNodeInfo;
+	}
+}

--
Gitblit v1.7.1