Pu Zhibing
2025-06-12 82118a47410c89e1d9751b3fa7814cc97c3b16da
DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/EmployeeUtil.java
@@ -34,27 +34,34 @@
      String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
      //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
      String appKey = QianYunTongProperties.appkey;//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");
      SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
      
      String timeStamp = date.format(nowdate);
      String messageId = UUID.randomUUID().toString().replaceAll("-","");
      request.put(SystemParameterNames.getAppKey(), appKey);
      request.put(SystemParameterNames.getMessage_id(), messageId);
      request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
      request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
      request.put("content", content);
      log.info("【企业增加员工】请求参数:" + JSON.toJSONString(request));
      String result = OpenApiClient.sendCommonHttpRequst(url,headers,"POST",skprivateKeyFile,timeStamp,request);
      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", JSON.toJSONString(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 status = jsonObject.getString("status");
      if(!"0".equals(status)){
      String retCode = jsonObject.getString("retCode");
      if (!"0".equals(retCode)) {
         log.error("【企业增加员工】请求失败:" + result);
         return false;
         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;
   }
@@ -72,27 +79,34 @@
      String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
      //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
      String appKey = QianYunTongProperties.appkey;//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");
      SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
      
      String timeStamp = date.format(nowdate);
      String messageId = UUID.randomUUID().toString().replaceAll("-","");
      request.put(SystemParameterNames.getAppKey(), appKey);
      request.put(SystemParameterNames.getMessage_id(), messageId);
      request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
      request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
      request.put("content", content);
      log.info("【企业修改员工信息】请求参数:" + JSON.toJSONString(request));
      String result = OpenApiClient.sendCommonHttpRequst(url,headers,"POST",skprivateKeyFile,timeStamp,request);
      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", JSON.toJSONString(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 status = jsonObject.getString("status");
      if(!"0".equals(status)){
      String retCode = jsonObject.getString("retCode");
      if (!"0".equals(retCode)) {
         log.error("【企业修改员工信息】请求失败:" + result);
         return false;
         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;
   }
@@ -110,27 +124,35 @@
      String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
      //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
      String appKey = QianYunTongProperties.appkey;//appkey
      String content="";//业务参数
      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");
      SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
      
      String timeStamp = date.format(nowdate);
      String messageId = UUID.randomUUID().toString().replaceAll("-","");
      request.put(SystemParameterNames.getAppKey(), appKey);
      request.put(SystemParameterNames.getMessage_id(), messageId);
      request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
      request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
      request.put("content", content);
      log.info("【企业删除人员】请求参数:" + JSON.toJSONString(request));
      String result = OpenApiClient.sendCommonHttpRequst(url,headers,"POST",skprivateKeyFile,timeStamp,request);
      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", JSON.toJSONString(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 status = jsonObject.getString("status");
      if(!"0".equals(status)){
      String retCode = jsonObject.getString("retCode");
      if (!"0".equals(retCode)) {
         log.error("【企业删除人员】请求失败:" + result);
         return false;
         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;
   }
@@ -148,29 +170,36 @@
      String skprivateKeyFile = QianYunTongProperties.privateKeyPath;
      //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密
      String appKey = QianYunTongProperties.appkey;//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");
      SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
      
      String timeStamp = date.format(nowdate);
      String messageId = UUID.randomUUID().toString().replaceAll("-","");
      request.put(SystemParameterNames.getAppKey(), appKey);
      request.put(SystemParameterNames.getMessage_id(), messageId);
      request.put(SystemParameterNames.getUserName(), QianYunTongProperties.userName);
      request.put(SystemParameterNames.getStatus(), QianYunTongProperties.status);
      request.put("content", content);
      log.info("【根据员工ID获取人员信息】请求参数:" + JSON.toJSONString(request));
      String result = OpenApiClient.sendCommonHttpRequst(url,headers,"GET",skprivateKeyFile,timeStamp,request);
      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", JSON.toJSONString(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 status = jsonObject.getString("status");
      if(!"0".equals(status)){
      String retCode = jsonObject.getString("retCode");
      if (!"0".equals(retCode)) {
         log.error("【根据员工ID获取人员信息】请求失败:" + result);
         return null;
         throw new RuntimeException("【根据员工ID获取人员信息】请求失败:" + result);
      }
      StaffNodeInfo staffNodeInfo = jsonObject.getObject("data", StaffNodeInfo.class);
      JSONObject object = jsonObject.getJSONObject("object");
      String status = object.getString("status");
      if (!"0".equals(status)) {
         log.error("【根据员工ID获取人员信息】失败:" + object.toJSONString());
         throw new RuntimeException("【根据员工ID获取人员信息】失败:" + object.toJSONString());
      }
      StaffNodeInfo staffNodeInfo = jsonObject.getObject("object", StaffNodeInfo.class);
      return staffNodeInfo;
   }
}