Commit 52625439 authored by hongguangwu's avatar hongguangwu

MVP1.7.16-法大大

parent 89af8b27
package com.yifu.cloud.plus.v1.yifu.archives.config;
import com.fasc.open.api.bean.base.BaseRes;
import com.fasc.open.api.bean.common.OpenId;
import com.fasc.open.api.exception.ApiException;
import com.fasc.open.api.v5_1.client.OpenApiClient;
import com.fasc.open.api.v5_1.client.ServiceClient;
import com.fasc.open.api.v5_1.client.TemplateClient;
import com.fasc.open.api.v5_1.req.template.GetSignTemplateListReq;
import com.fasc.open.api.v5_1.req.template.SignTemplateListFilterInfo;
import com.fasc.open.api.v5_1.res.service.AccessTokenRes;
import com.fasc.open.api.v5_1.res.template.SignTemplateListInfo;
import com.fasc.open.api.v5_1.res.template.SignTemplateListRes;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @Author: hgw
* @Date: 2025-9-25 14:24:53
* @return: 企业法大大专业版配置
**/
@Configuration
@Data
@Slf4j
public class FascConfig {
@Value("${fasc.appId}")
private String appId;
@Value("${fasc.appSecret}")
private String appSecret;
@Value("${fasc.appUrl}")
private String appUrl;
@Value("${fasc.openId}")
private String openId;
/*@Autowired
private RedisTemplate redisTemplate;
*//*public static void main(String[] args) throws ApiException {
String appId = "80003662";
String appSecret = "DXREUVHOLEFJMWLGYFGF1JKID8YCEDWZ";
OpenApiClient openApiClient = new OpenApiClient(appId, appSecret, "https://uat-api.fadada.com/api/v5");
ServiceClient serviceClient = new ServiceClient(openApiClient);
BaseRes<AccessTokenRes> res = serviceClient.getAccessToken();
String token = null;
if (res != null && res.isSuccess() && res.getData() != null && res.getData().getAccessToken() != null) {
token = res.getData().getAccessToken();
}
System.out.println(token);
}*//*
*//**
* @Description: 获取token
* @Author: huyc
* @Date: 2023/7/28 14:46
* @return: java.lang.String
**//*
public String getFascToken(OpenApiClient openApiClient) throws ApiException {
String tokenKey = CacheConstants.FASC_ACCOSS_TOKEN;
Object wxToken = redisTemplate.opsForValue().get(tokenKey);
if (null != wxToken) {
return String.valueOf(wxToken);
}
if (openApiClient == null) {
openApiClient = new OpenApiClient(appId, appSecret, appUrl);
}
ServiceClient serviceClient = new ServiceClient(openApiClient);
BaseRes<AccessTokenRes> res = serviceClient.getAccessToken();
String token = null;
if (res != null && res.isSuccess() && res.getData() != null && res.getData().getAccessToken() != null) {
token = res.getData().getAccessToken();
}
if (Common.isEmpty(token)) {
throw new CheckedException("获取法大大专业版token失败");
}
redisTemplate.opsForValue().set(tokenKey, token);
redisTemplate.expire(tokenKey, 3600, TimeUnit.SECONDS);
return token;
}
*//**
* @Author: hgw
* @Date: 2025-9-25 14:11:06
* @Description: 移除法大大专业版accossToken
* @return: java.lang.String
**//*
public void removeFascToken() {
redisTemplate.delete(CacheConstants.FASC_ACCOSS_TOKEN);
}
public List<SignTemplateListInfo> getTemplateList(String templateName) throws ApiException {
OpenApiClient openApiClient = new OpenApiClient(appId, appSecret, appUrl);
TemplateClient templateClient = new TemplateClient(openApiClient) ;
String accessToken = this.getFascToken(openApiClient);
GetSignTemplateListReq getSignTemplateListReq = new GetSignTemplateListReq() ;
getSignTemplateListReq.setListPageNo(1) ;
getSignTemplateListReq.setListPageSize(100) ;
OpenId ownerId = new OpenId() ;
ownerId.setIdType(CacheConstants.FASC_ID_TYPE) ;
ownerId.setOpenId(openId) ;
getSignTemplateListReq.setOwnerId(ownerId) ;
SignTemplateListFilterInfo signTemplateListFilterInfo = new SignTemplateListFilterInfo();
if (Common.isNotNull(templateName)) {
// 签署任务模板名称,如果传了该参数,会根据名称模糊匹配查询,长度最大100个字符。
signTemplateListFilterInfo.setSignTemplateName(templateName) ;
} else {
signTemplateListFilterInfo.setSignTemplateName("") ;
}
getSignTemplateListReq.setListFilter(signTemplateListFilterInfo) ;
getSignTemplateListReq.setAccessToken(accessToken) ;
BaseRes<SignTemplateListRes> res = templateClient.getSignTemplateList(getSignTemplateListReq) ;
List<SignTemplateListInfo> list = null;
if (res != null && res.isSuccess() && res.getData() != null && res.getData().getSignTemplates() != null
&& !res.getData().getSignTemplates().isEmpty()) {
list = res.getData().getSignTemplates();
if (res.getData().getListPageCount() != null ) {
int listPageCount = res.getData().getListPageCount();
// 超过1页的循环查询
if (listPageCount > 1) {
for (int i=2; i<=listPageCount; i++) {
getSignTemplateListReq.setListPageNo(i) ;
res = templateClient.getSignTemplateList(getSignTemplateListReq) ;
if (res.getData().getSignTemplates() != null && !res.getData().getSignTemplates().isEmpty()) {
list.addAll(res.getData().getSignTemplates());
}
}
}
}
}
return list;
}*/
}
package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.alibaba.fastjson.JSON;
import com.fasc.open.api.exception.ApiException;
import com.yifu.cloud.plus.v1.yifu.archives.config.FddConfigProperties;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddReqLog;
import com.yifu.cloud.plus.v1.yifu.archives.service.*;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* @auther huyc
* @date 2022/6/29
*/
@RestController
@RequestMapping("/fasc")
@Tag(name = "法大大专业版接口")
@Slf4j
@EnableConfigurationProperties(FddConfigProperties.class)
public class FascController {
@Autowired
private FascService fascService;
@Autowired
private FddReqLogService reqLogService;
@Autowired
private FddPersonAccountService fddPersonAccountService;
@Autowired
private FddContractInfoService fddContractInfoService;
@Autowired
private FddCompanyInfoService fddCompanyInfoService;
@Autowired
private FddContractAttachInfoService fddContractAttachInfoService;
@Autowired
private TEmployeeContractInfoService employeeContractInfoService;
/**
* @param templateName 签署任务模板名称,如果传了该参数,会根据名称模糊匹配查询,长度最大100个字符。
* @Description: 获取模板
* @Author: hgw
* @Date: 2025/9/26 16:21
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "获取模板")
@PostMapping("/getTemplate" )
public R<String> getTemplate(@RequestParam(required = false) String templateName) throws ApiException {
return fascService.getTemplate(templateName);
}
/**
* 保存请求参数日志
*
* @param request
*/
private void saveReqLog(HttpServletRequest request) {
Map<String, String[]> parameterMap = request.getParameterMap();
FddReqLog fddReqLog = new FddReqLog();
fddReqLog.setResData(JSON.toJSONString(parameterMap));
fddReqLog.setMethodName(Thread.currentThread().getStackTrace()[1].getMethodName());
fddReqLog.setClassName(Thread.currentThread().getStackTrace()[1].getClassName());
reqLogService.save(fddReqLog);
}
//验证签名
public void checkSign(HttpServletRequest request) throws Exception {
/* Map<String, String> paraMap = new HashMap<>(8);
paraMap.put(GlobalConstants.FDD_APPID, request.getHeader(GlobalConstants.FDD_APPID));
paraMap.put(GlobalConstants.FDD_SIGN_TYPE, request.getHeader(GlobalConstants.FDD_SIGN_TYPE));
paraMap.put(GlobalConstants.FDD_TIMESTAMP, request.getHeader(GlobalConstants.FDD_TIMESTAMP));
paraMap.put(GlobalConstants.FDD_NONCE, request.getHeader(GlobalConstants.FDD_NONCE));
paraMap.put(FDD_EVENT, request.getHeader(FDD_EVENT));
String fddBizContent = request.getParameter(FDD_BIZ_CONTENT);
paraMap.put(FDD_BIZ_CONTENT, fddBizContent);
//得到排序后的字符串,FddCryptUtil为法大大提供得签名工具类
String sortParam = FddCryptUtil.sortParameters(paraMap);
//计算之后得到签名 该签名需要放到请求头
String signature = FddCryptUtil.sign(sortParam, request.getHeader(GlobalConstants.FDD_TIMESTAMP), fddConfigProperties.getAppKey());
if (StringUtils.equals(signature, request.getHeader(GlobalConstants.FDD_API_SIGN))) {
FddReqLog fddReqLog = new FddReqLog();
paraMap.put(GlobalConstants.FDD_TIMESTAMP, request.getHeader(GlobalConstants.FDD_TIMESTAMP));
fddReqLog.setReqData(signature);
fddReqLog.setResData(JSON.toJSONString(paraMap));
fddReqLog.setMethodName(Thread.currentThread().getStackTrace()[1].getMethodName());
fddReqLog.setClassName(Thread.currentThread().getStackTrace()[1].getClassName());
reqLogService.save(fddReqLog);
return;
}*/
throw new CheckedException("签名异常");
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fasc.open.api.exception.ApiException;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
/**
* 法大大合同与员工合同信息
*
* @author fxj
* @date 2022-06-29 16:21:51
*/
public interface FascService extends IService<FddContractInfo> {
// 获取模板
R<String> getTemplate(String templateName) throws ApiException;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasc.open.api.exception.ApiException;
import com.fasc.open.api.v5_1.res.template.DocumentInfo;
import com.fasc.open.api.v5_1.res.template.SignTemplateListInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.FddContractInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.FddContractInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.FascService;
import com.yifu.cloud.plus.v1.yifu.archives.utils.FascUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 法大大合同与员工合同信息
* @author fxj
* @date 2022-06-29 16:21:51
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContractInfo> implements FascService {
@Autowired
private FascUtil fascUtil;
@Override
public R<String> getTemplate(String templateName) throws ApiException {
// templateName 签署任务模板名称
List<SignTemplateListInfo> list = fascUtil.getTemplateList(templateName);
if (list != null && !list.isEmpty()) {
List<DocumentInfo> listDetail = fascUtil.getTemplateDetailList(list);
// TODO-存表里
}
return R.ok();
}
}
package com.yifu.cloud.plus.v1.yifu.archives.utils;
import com.fasc.open.api.bean.base.BaseRes;
import com.fasc.open.api.bean.common.OpenId;
import com.fasc.open.api.exception.ApiException;
import com.fasc.open.api.v5_1.client.OpenApiClient;
import com.fasc.open.api.v5_1.client.ServiceClient;
import com.fasc.open.api.v5_1.client.TemplateClient;
import com.fasc.open.api.v5_1.req.template.GetSignTemplateListReq;
import com.fasc.open.api.v5_1.req.template.SignTemplateDetailReq;
import com.fasc.open.api.v5_1.req.template.SignTemplateListFilterInfo;
import com.fasc.open.api.v5_1.res.service.AccessTokenRes;
import com.fasc.open.api.v5_1.res.template.DocumentInfo;
import com.fasc.open.api.v5_1.res.template.SignTemplateDetailRes;
import com.fasc.open.api.v5_1.res.template.SignTemplateListInfo;
import com.fasc.open.api.v5_1.res.template.SignTemplateListRes;
import com.yifu.cloud.plus.v1.yifu.archives.config.FascConfig;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @Author: hgw
* @Date: 2025-9-25 14:24:53
* @return: 企业法大大专业版配置
**/
@Component
public class FascUtil {
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private FascConfig fascConfig;
/**
* @Description: 获取token
* @Author: huyc
* @Date: 2023/7/28 14:46
* @return: java.lang.String
**/
public String getFascToken(OpenApiClient openApiClient) throws ApiException {
String tokenKey = CacheConstants.FASC_ACCOSS_TOKEN;
Object wxToken = redisTemplate.opsForValue().get(tokenKey);
if (null != wxToken) {
return String.valueOf(wxToken);
}
if (openApiClient == null) {
openApiClient = new OpenApiClient(fascConfig.getAppId(), fascConfig.getAppSecret(), fascConfig.getAppUrl());
}
ServiceClient serviceClient = new ServiceClient(openApiClient);
BaseRes<AccessTokenRes> res = serviceClient.getAccessToken();
String token = null;
if (res != null && res.isSuccess() && res.getData() != null && res.getData().getAccessToken() != null) {
token = res.getData().getAccessToken();
}
if (Common.isEmpty(token)) {
throw new CheckedException("获取法大大专业版token失败");
}
redisTemplate.opsForValue().set(tokenKey, token);
redisTemplate.expire(tokenKey, 3600, TimeUnit.SECONDS);
return token;
}
/**
* @Author: hgw
* @Date: 2025-9-25 14:11:06
* @Description: 移除法大大专业版accossToken
* @return: java.lang.String
**/
public void removeFascToken() {
redisTemplate.delete(CacheConstants.FASC_ACCOSS_TOKEN);
}
public List<SignTemplateListInfo> getTemplateList(String templateName) throws ApiException {
OpenApiClient openApiClient = new OpenApiClient(fascConfig.getAppId(), fascConfig.getAppSecret(), fascConfig.getAppUrl());
TemplateClient templateClient = new TemplateClient(openApiClient) ;
String accessToken = this.getFascToken(openApiClient);
GetSignTemplateListReq getSignTemplateListReq = new GetSignTemplateListReq() ;
getSignTemplateListReq.setListPageNo(1) ;
getSignTemplateListReq.setListPageSize(100) ;
OpenId ownerId = new OpenId() ;
ownerId.setIdType(CacheConstants.FASC_ID_TYPE) ;
ownerId.setOpenId(fascConfig.getOpenId()) ;
getSignTemplateListReq.setOwnerId(ownerId) ;
SignTemplateListFilterInfo signTemplateListFilterInfo = new SignTemplateListFilterInfo();
if (Common.isNotNull(templateName)) {
// 签署任务模板名称,如果传了该参数,会根据名称模糊匹配查询,长度最大100个字符。
signTemplateListFilterInfo.setSignTemplateName(templateName) ;
} else {
signTemplateListFilterInfo.setSignTemplateName("") ;
}
getSignTemplateListReq.setListFilter(signTemplateListFilterInfo) ;
getSignTemplateListReq.setAccessToken(accessToken) ;
BaseRes<SignTemplateListRes> res = templateClient.getSignTemplateList(getSignTemplateListReq) ;
List<SignTemplateListInfo> list = null;
if (res != null && res.isSuccess() && res.getData() != null && res.getData().getSignTemplates() != null
&& !res.getData().getSignTemplates().isEmpty()) {
list = res.getData().getSignTemplates();
if (res.getData().getListPageCount() != null ) {
int listPageCount = res.getData().getListPageCount();
// 超过1页的循环查询
if (listPageCount > 1) {
for (int i=2; i<=listPageCount; i++) {
getSignTemplateListReq.setListPageNo(i) ;
res = templateClient.getSignTemplateList(getSignTemplateListReq) ;
if (res.getData().getSignTemplates() != null && !res.getData().getSignTemplates().isEmpty()) {
list.addAll(res.getData().getSignTemplates());
}
}
}
}
}
return list;
}
public List<DocumentInfo> getTemplateDetailList(List<SignTemplateListInfo> templateList) throws ApiException {
OpenApiClient openApiClient = new OpenApiClient(fascConfig.getAppId(), fascConfig.getAppSecret(), fascConfig.getAppUrl());
TemplateClient templateClient = new TemplateClient(openApiClient) ;
String accessToken = this.getFascToken(openApiClient);
OpenId openId = new OpenId() ;
openId.setIdType(CacheConstants.FASC_ID_TYPE) ;
openId.setOpenId(fascConfig.getOpenId()) ;
List<DocumentInfo> list = null;
if (templateList != null && !templateList.isEmpty()) {
// 调用查询模板详情接口
SignTemplateDetailReq signTemplateDetailReq;
BaseRes<SignTemplateDetailRes> res;
for (SignTemplateListInfo signTemplateListInfo : templateList) {
if (signTemplateListInfo != null && signTemplateListInfo.getSignTemplateId() != null) {
signTemplateDetailReq = new SignTemplateDetailReq() ;
signTemplateDetailReq.setOwnerId(openId) ;
signTemplateDetailReq.setSignTemplateId(signTemplateListInfo.getSignTemplateId()) ;
signTemplateDetailReq.setAccessToken(accessToken) ;
res = templateClient.getSignTemplateDetail(signTemplateDetailReq) ;
if (res != null && res.isSuccess() && res.getData() != null && res.getData().getDocs() != null
&& !res.getData().getDocs().isEmpty()) {
if (list == null) {
list = new ArrayList<>();
}
list.addAll(res.getData().getDocs());
}
}
}
}
return list;
}
}
...@@ -45,4 +45,11 @@ gz: ...@@ -45,4 +45,11 @@ gz:
tid: c2da1d84e9bd4a30b6be5ecd209096fb tid: c2da1d84e9bd4a30b6be5ecd209096fb
appUrl: https://eim-busin-api-test-jwtys.guazi.com appUrl: https://eim-busin-api-test-jwtys.guazi.com
#法大大专业版fasc配置
fasc:
appId: 80003662
appSecret: DXREUVHOLEFJMWLGYFGF1JKID8YCEDWZ
appUrl: https://uat-api.fadada.com/api/v5
openId: ebcd6e2e0eb2401b9ca9239e78fad203
...@@ -198,6 +198,10 @@ public interface CacheConstants { ...@@ -198,6 +198,10 @@ public interface CacheConstants {
String HCM_CHU_CHAI_SIGN = "HCM_CHU_CHAI_SIGN"; String HCM_CHU_CHAI_SIGN = "HCM_CHU_CHAI_SIGN";
public static final String WX_ACCOSS_TOKEN = "WX_ACCOSS_TOKEN"; public static final String WX_ACCOSS_TOKEN = "WX_ACCOSS_TOKEN";
// 法大大专业版token的KEY
String FASC_ACCOSS_TOKEN = "FASC_ACCOSS_TOKEN";
// 如果idType为corp:代表应用系统上的企业用户,主体方是openCorpId所指定的企业
String FASC_ID_TYPE = "corp";
/** /**
* 登录用户最近一次选择的收入证明单位名称 * 登录用户最近一次选择的收入证明单位名称
......
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