Commit 0d2e617e authored by hongguangwu's avatar hongguangwu

MVP1.7.12-测试瓜子接口

parent c426ddf2
......@@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TGzEmpInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
......@@ -14,9 +17,11 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
......@@ -76,10 +81,125 @@ public class GzConfig {
return false;
}
public boolean updateGzOfferStatus(RestTemplate restTemplate, Map<String, Object> params) {
String gzBankUrl = appUrl + "/eim-hr-induction/api/hr/induction/open/offer/update-status";
public boolean updateGzOfferStatus(RestTemplate restTemplate, Map<String, Object> params, String sortedParams) {
String gzBankUrl = appUrl + "/eim-hr-induction/api/hr/induction/open/offer/update-status?"+ sortedParams;
// 创建请求头并添加Authorization
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.set("Authorization", "00000000"); // 设置Authorization头
Gson gson = new Gson();
// 创建HttpEntity,包含headers(GET请求没有body,所以为null)
HttpEntity<String> entity = new HttpEntity<>(gson.toJson(params), headers);
// 发送GET请求
String result = restTemplate.exchange(gzBankUrl, HttpMethod.POST, entity, String.class).getBody();
System.out.println(result);
if (result != null && result.contains("code") && result.contains("data")) {
JSONObject resultObject = JSON.parseObject(result);
String code = resultObject.getString("code");
if (Common.isNotNull(code) && "S00000".equals(code)) {
System.out.println("成功");
return true;
}
}
return false;
}
public boolean pushGzEmpInfo(RestTemplate restTemplate, TGzEmpInfo a, String sortedParams) {
String gzBankUrl = appUrl + "/eim-hr-induction/api/hr/induction/open/offer/person-info?"+ sortedParams;
// 创建请求头并添加Authorization
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.set("Authorization", "00000000"); // 设置Authorization头
Gson gson = new Gson();
// 创建HttpEntity,包含headers(GET请求没有body,所以为null)
HttpEntity<String> entity = new HttpEntity<>(gson.toJson(a), headers);
// 发送GET请求
String result = restTemplate.exchange(gzBankUrl, HttpMethod.POST, entity, String.class).getBody();
System.out.println(result);
if (result != null && result.contains("code") && result.contains("data")) {
JSONObject resultObject = JSON.parseObject(result);
String code = resultObject.getString("code");
if (Common.isNotNull(code) && "S00000".equals(code)) {
System.out.println("成功");
return true;
}
}
return false;
}
public boolean pushGzEmpContract(RestTemplate restTemplate, TEmpContactInfo a, String sortedParams) {
String gzBankUrl = appUrl + "/eim-hr-induction/api/hr/induction/open/offer/person-contract?"+ sortedParams;
// 创建请求头并添加Authorization
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.set("Authorization", "00000000"); // 设置Authorization头
Gson gson = new Gson();
// 创建HttpEntity,包含headers(GET请求没有body,所以为null)
HttpEntity<String> entity = new HttpEntity<>(gson.toJson(a), headers);
// 发送GET请求
String result = restTemplate.exchange(gzBankUrl, HttpMethod.POST, entity, String.class).getBody();
System.out.println(result);
if (result != null && result.contains("code") && result.contains("data")) {
JSONObject resultObject = JSON.parseObject(result);
String code = resultObject.getString("code");
if (Common.isNotNull(code) && "S00000".equals(code)) {
System.out.println("成功");
return true;
}
}
return false;
}
public boolean pushGzEmpContractFile(RestTemplate restTemplate, TEmpContactInfo a, String sortedParams) {
String gzBankUrl = appUrl + "/eim-hr-induction/api/hr/induction/open/offer/person-contract?"+ sortedParams;
// 创建请求头并添加Authorization
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.set("Authorization", "00000000"); // 设置Authorization头
Gson gson = new Gson();
// 创建HttpEntity,包含headers(GET请求没有body,所以为null)
HttpEntity<String> entity = new HttpEntity<>(gson.toJson(a), headers);
// 发送GET请求
String result = restTemplate.exchange(gzBankUrl, HttpMethod.POST, entity, String.class).getBody();
System.out.println(result);
if (result != null && result.contains("code") && result.contains("data")) {
JSONObject resultObject = JSON.parseObject(result);
String code = resultObject.getString("code");
if (Common.isNotNull(code) && "S00000".equals(code)) {
System.out.println("成功");
return true;
}
}
return false;
}
public boolean pushGzFileList(RestTemplate restTemplate, List<Map<String, Object>> aList, String sortedParams) {
for (Map<String, Object> a : aList) {
if (pushGzFileOne(restTemplate, a, sortedParams)) {
System.out.println("成功");
}
}
return true;
}
public boolean pushGzFileOne(RestTemplate restTemplate, Map<String, Object> params, String sortedParams) {
String gzBankUrl = appUrl + "/eim-hr-induction/api/hr/induction/open/offer/person-contract?"+ sortedParams;
// 创建请求头并添加Authorization
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.set("Authorization", "00000000"); // 设置Authorization头
Gson gson = new Gson();
// 创建HttpEntity,包含headers(GET请求没有body,所以为null)
......
......@@ -18,10 +18,17 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.yifu.cloud.plus.v1.yifu.archives.config.GzConfig;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpContactInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TGzEmpInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TGzOfferInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpContactInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TGzEmpInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TGzOfferInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.utils.GZSign;
import com.yifu.cloud.plus.v1.yifu.archives.utils.ReturnGz;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
......@@ -30,7 +37,9 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -50,6 +59,9 @@ public class TGzController {
private GzConfig gzConfig;
private final TGzOfferInfoService tGzOfferInfoService;
private final TGzEmpInfoService tGzEmpInfoService;
private final TAttaInfoService tAttaInfoService;
private final TEmpContactInfoService tEmpContactInfoService;
private RestTemplate restTemplate = new RestTemplate();
......@@ -109,6 +121,8 @@ public class TGzController {
params.put("pageSize", pageSize);
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("appsecret", gzConfig.getAppsecret());
params.put("tid", gzConfig.getTid());
GZSign.addSignature(params, gzConfig.getAppkey(), gzConfig.getAppsecret());
params.remove("startTime", startTime);
......@@ -119,9 +133,9 @@ public class TGzController {
}
/**
* @Description: offer状态更新
* @Description: 1、offer状态更新接口;
* @Author: hgw
* @Date: 2025-7-4 17:18:27
* @Date: 2025-7-11 11:11:11
* @return: boolean
**/
@GetMapping("/updateGzOfferStatus")
......@@ -129,15 +143,114 @@ public class TGzController {
, @RequestParam(required = false) String phone, @RequestParam(required = false) String email
, @RequestParam(required = false) String entryDate) {
Map<String, Object> params = new HashMap<>();
params.put("appsecret", gzConfig.getAppsecret());
params.put("tid", gzConfig.getTid());
GZSign.addSignature(params, gzConfig.getAppkey(), gzConfig.getAppsecret());
String sortedParams = GZSign.getEncodeString(params);
params = new HashMap<>();
params.put("bizId", bizId);
params.put("status", status);
params.put("phone", phone);
params.put("email", email);
params.put("entryDate", entryDate);
GZSign.addSignature(params, gzConfig.getAppkey(), gzConfig.getAppsecret());
return gzConfig.updateGzOfferStatus(restTemplate, params, sortedParams);
}
return gzConfig.updateGzOfferStatus(restTemplate, params);
/**
* @Description: 2、员工信息回推接口;
* @Author: hgw
* @Date: 2025-7-11 11:11:11
* @return: boolean
**/
@GetMapping("/pushGzEmpInfo")
public boolean pushGzEmpInfo(@RequestParam(required = false) String gzEmpId) {
Map<String, Object> params = new HashMap<>();
params.put("appsecret", gzConfig.getAppsecret());
params.put("tid", gzConfig.getTid());
GZSign.addSignature(params, gzConfig.getAppkey(), gzConfig.getAppsecret());
String sortedParams = GZSign.getEncodeString(params);
if (Common.isEmpty(gzEmpId)) {
// 653497199507262524 李丽
gzEmpId = "1942036120125800449";
}
TGzEmpInfo a = tGzEmpInfoService.getById(gzEmpId);
return gzConfig.pushGzEmpInfo(restTemplate, a, sortedParams);
}
/**
* @Description: 3、合同信息回推接口;
* @Author: hgw
* @Date: 2025-7-11 11:11:11
* @return: boolean
**/
@GetMapping("/pushGzEmpContract")
public boolean pushGzEmpContract(@RequestParam(required = false) String empContractId) {
Map<String, Object> params = new HashMap<>();
params.put("appsecret", gzConfig.getAppsecret());
params.put("tid", gzConfig.getTid());
GZSign.addSignature(params, gzConfig.getAppkey(), gzConfig.getAppsecret());
String sortedParams = GZSign.getEncodeString(params);
if (Common.isEmpty(empContractId)) {
// 653497199507262524 李丽
empContractId = "1942036120125800449";
}
TEmpContactInfo a = tEmpContactInfoService.getById(empContractId);
return gzConfig.pushGzEmpContract(restTemplate, a, sortedParams);
}
/**
* @Description: 4、合同附件推送接口;
* @Author: hgw
* @Date: 2025-7-11 11:11:11
* @return: boolean
**/
@GetMapping("/pushGzEmpContractFile")
public boolean pushGzEmpContractFile(@RequestParam(required = false) String empContractId) {
Map<String, Object> params = new HashMap<>();
params.put("appsecret", gzConfig.getAppsecret());
params.put("tid", gzConfig.getTid());
GZSign.addSignature(params, gzConfig.getAppkey(), gzConfig.getAppsecret());
String sortedParams = GZSign.getEncodeString(params);
if (Common.isEmpty(empContractId)) {
// 653497199507262524 李丽
empContractId = "1942036120125800449";
}
TGzEmpInfo a = tGzEmpInfoService.getById(empContractId);
return gzConfig.pushGzEmpInfo(restTemplate, a, sortedParams);
}
/**
* @Description: 5:员工文件信息上传接口
* @Author: hgw
* @Date: 2025-7-11 11:11:11
* @return: boolean
**/
@GetMapping("/pushGzEmpInfoFile")
public boolean pushGzEmpInfoFile(@RequestParam(required = false) String gzEmpId) {
Map<String, Object> params = new HashMap<>();
params.put("appsecret", gzConfig.getAppsecret());
params.put("tid", gzConfig.getTid());
GZSign.addSignature(params, gzConfig.getAppkey(), gzConfig.getAppsecret());
String sortedParams = GZSign.getEncodeString(params);
if (Common.isEmpty(gzEmpId)) {
// 653497199507262524 李丽
gzEmpId = "1942036120125800449";
}
List<TAttaInfo> aList = tAttaInfoService.getTAttaInfoListByDoMainId(gzEmpId);
List<Map<String, Object>> attaMapList = new ArrayList<>();
Map<String, Object> attaMap;
TGzEmpInfo tGzEmpInfo;
for (TAttaInfo a : aList) {
tGzEmpInfo = tGzEmpInfoService.getById(a.getDomainId());
if (tGzEmpInfo != null && Common.isNotNull(tGzEmpInfo.getBizId())) {
attaMap = new HashMap<>();
attaMap.put("bizId", tGzEmpInfo.getBizId());
// TODO-文件名称带后缀
attaMap.put("fileName", a.getAttaName());
// TODO-文件数据 Base64
attaMap.put("fileData", null);
attaMapList.add(attaMap);
}
}
return gzConfig.pushGzFileList(restTemplate, attaMapList, sortedParams);
}
......
......@@ -93,7 +93,7 @@ public class GZSign {
* @return
*/
private static String generateSignature(Map<String, Object> params, String appKey, String appSecret) {
if (params == null || params.size() == 0) {
if (params == null ) {
return null;
}
params.put(APP_KEY, appKey);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment