Commit 07a89c5f authored by huyuchen's avatar huyuchen

工行接口

parent b546e08e
package com.yifu.cloud.plus.v1.ekp.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
/**
* @auther huyc
* @date 2024/5/24
* 聚富通基本配置
*/
@RefreshScope
@ConfigurationProperties(prefix = "icbc")
@Data
public class IcbcConfigProperties {
/**
* @Description: 聚富通分配的接入id
**/
private String appId;
/**
* @Description: 聚富通分配的应用方私钥
**/
private String appPrivateKey;
/**
* @Description: 指定环境请求url
**/
private String serverUrl;
/**
* @Description: 网关公钥
**/
private String apigwPublicKey;
/**
* @Description: 应用方加密串
**/
private String aesKey;
/**
* @Description: 企业编号
**/
private String companyNo;
/**
* 异步通知地址
*/
private String notifyUrl="/fdd/notifyUrl";
}
package com.yifu.cloud.plus.v1.ekp.controller;
import com.yifu.cloud.plus.v1.ekp.service.IcbcTransactionFlowIssueService;
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.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 聚富通代发工资相关
*
* @author huyc
* @date 2024-05-23 10:24:12
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/icbcIssue" )
@Tag(name = "聚富通代发工资相关")
public class IcbcTransactionFlowIssueController {
private final IcbcTransactionFlowIssueService icbcTransactionFlowIssueService;
/**
* 聚富通代发工资确认提交
*
* @param
* @param
* @return
*/
@Operation(summary = "聚富通代发工资确认提交接口", description = "聚富通代发工资确认提交接口")
@PostMapping("/submit")
public R submitIcbcTransactionFlow() {
return icbcTransactionFlowIssueService.submitIcbcTransactionFlow();
}
/**
* 代发工资明细查询
*
* @param
* @param
* @return
*/
@Operation(summary = "代发工资明细查询", description = "代发工资明细查询")
@PostMapping("/page")
public R selectIcbcTransactionFlowInfo() {
return icbcTransactionFlowIssueService.selectIcbcTransactionFlowInfo();
}
}
package com.yifu.cloud.plus.v1.ekp.controller;
import com.yifu.cloud.plus.v1.ekp.service.IcbcTransactionFlowQueryService;
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.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 聚富通到账通知交易流水查询
*
* @author huyc
* @date 2024-05-23 10:24:12
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/icbcQuery" )
@Tag(name = "聚富通到账通知交易流水查询")
public class IcbcTransactionFlowQueryController {
private final IcbcTransactionFlowQueryService icbcTransactionFlowQueryService;
/**
* 交易流水查询
*
* @param
* @return
*/
@Operation(summary = "交易流水查询", description = "交易流水查询")
@PostMapping("/page")
public R getIcbcTransactionFlow() {
return icbcTransactionFlowQueryService.getIcbcTransactionFlow();
}
/**
* 预订单接口
*
* @param
* @return
*/
@Operation(summary = "预订单接口", description = "预订单接口")
@PostMapping("/save")
public R saveIcbcManagerCard() {
return icbcTransactionFlowQueryService.saveIcbcManagerCard();
}
}
package com.yifu.cloud.plus.v1.ekp.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.ekp.entity.EkpSocialInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
/**
* 聚富通代发工资相关
*
* @author huyc
* @date 2024-05-24 10:55:24
*/
public interface IcbcTransactionFlowIssueService extends IService<EkpSocialInfo> {
R submitIcbcTransactionFlow();
R selectIcbcTransactionFlowInfo();
}
package com.yifu.cloud.plus.v1.ekp.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.ekp.entity.EkpSocialInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
/**
* 聚富通到账通知交易流水查询
*
* @author huyc
* @date 2024-05-23 11:21:56
*/
public interface IcbcTransactionFlowQueryService extends IService<EkpSocialInfo> {
R getIcbcTransactionFlow();
R saveIcbcManagerCard();
}
package com.yifu.cloud.plus.v1.ekp.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.icbc.api.DefaultIcbcClient;
import com.icbc.api.IcbcApiException;
import com.icbc.api.IcbcConstants;
import com.icbc.api.UiIcbcClient;
import com.icbc.api.request.JftApiPayrollQueryDetailRequestV1;
import com.icbc.api.request.JftUiPayrollComfirmSubmitRequestV1;
import com.icbc.api.response.JftApiPayrollQueryDetailResponseV1;
import com.yifu.cloud.plus.v1.ekp.config.IcbcConfigProperties;
import com.yifu.cloud.plus.v1.ekp.entity.EkpSocialInfo;
import com.yifu.cloud.plus.v1.ekp.mapper.EkpSocialInfoMapper;
import com.yifu.cloud.plus.v1.ekp.service.IcbcTransactionFlowIssueService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Service;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* 聚富通到账通知交易流水查询
*
* @author huyc
* @date 2024-05-23 11:21:56
*/
@Log4j2
@Service
@RequiredArgsConstructor
@EnableConfigurationProperties(IcbcConfigProperties.class)
public class IcbcTransactionFlowIssueServiceImpl extends ServiceImpl<EkpSocialInfoMapper, EkpSocialInfo> implements IcbcTransactionFlowIssueService {
@Autowired
private IcbcConfigProperties icbcConfigProperties;
public R submitIcbcTransactionFlow() {
UiIcbcClient client = new UiIcbcClient(icbcConfigProperties.getAppId(), IcbcConstants.SIGN_TYPE_RSA2, icbcConfigProperties.getAppPrivateKey(),
IcbcConstants.CHARSET_UTF8);
JftUiPayrollComfirmSubmitRequestV1 request = new JftUiPayrollComfirmSubmitRequestV1();
request.setServiceUrl("https://apipcs3.dccnet.com.cn/ui/jft/ui/payroll/comfirmsubmit/V1");
JftUiPayrollComfirmSubmitRequestV1.JjftUiPayrolComfirmSubmitRequestV1BizV1 bizContent =
new JftUiPayrollComfirmSubmitRequestV1.JjftUiPayrolComfirmSubmitRequestV1BizV1();
bizContent.setAppId(icbcConfigProperties.getAppId());
//HR系统名称
bizContent.setAppName("HRO");
//企业编号
bizContent.setOutVendorId(icbcConfigProperties.getCompanyNo());
//操作类型:1-受理 2-审核
bizContent.setOprType("1");
bizContent.setTotalAmt("1000");
bizContent.setTotalCount("1");
bizContent.setAppSerialno("21900");
bizContent.setLocalFilepath("D:/icbcFile/955888_21900_0_20240524.xls");
bizContent.setFileMdcode(getMdCode("D:/icbcFile/955888_21900_0_20240524.xls"));
bizContent.setFileType("1");
bizContent.setNotifyUrl(null);
bizContent.setAppRemark("备注");
bizContent.setBusinessType(null);
bizContent.setFileCheckSign(null);
request.setBizContent(bizContent);
try {
String result = client.buildPostForm(request);
if (Common.isNotNull(result)) {
return R.ok();
}
} catch (IcbcApiException e) {
e.printStackTrace();
return R.failed();
}
return R.ok();
}
public R selectIcbcTransactionFlowInfo() {
DefaultIcbcClient client = new DefaultIcbcClient(icbcConfigProperties.getAppId(), IcbcConstants.SIGN_TYPE_RSA2,
icbcConfigProperties.getAppPrivateKey(), IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON,
icbcConfigProperties.getApigwPublicKey(), IcbcConstants.ENCRYPT_TYPE_AES, icbcConfigProperties.getAesKey(), null, null);
JftApiPayrollQueryDetailRequestV1 request = new JftApiPayrollQueryDetailRequestV1();
request.setServiceUrl("https://apipcs3.dccnet.com.cn/api/jft/api/payroll/querydetail/V1");
JftApiPayrollQueryDetailRequestV1.JftApiPayrollQueryDetailRequestV1Biz bizContent = new
JftApiPayrollQueryDetailRequestV1.JftApiPayrollQueryDetailRequestV1Biz();
bizContent.setAppId(icbcConfigProperties.getAppId());
bizContent.setOutVendorId(icbcConfigProperties.getCompanyNo());
bizContent.setType("2");
//批次号,appSerialno为空时,必输
bizContent.setAppBatserialno("21900");
//内部批次号,组成规则:批次号-顺序号,appBatserialno为空时必输
// bizContent.setAppSerialno("230921");
bizContent.setStartId("0");
bizContent.setEndId("10");
request.setBizContent(bizContent);
try {
JftApiPayrollQueryDetailResponseV1 responseV1 = client.execute(request);
if (Common.isNotNull(responseV1)) {
return R.ok();
}
} catch (IcbcApiException e) {
e.printStackTrace();
return R.failed();
}
return R.ok();
}
public String getMdCode(String filePath) {
try {
MessageDigest md5Digest = MessageDigest.getInstance("MD5");
byte[] buffer = new byte[8192];
try (FileInputStream fis = new FileInputStream(filePath)) {
int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) {
md5Digest.update(buffer, 0, bytesRead);
}
}
byte[] md5Bytes = md5Digest.digest();
// Convert the byte to hex format
StringBuilder result = new StringBuilder();
for (byte md5Byte : md5Bytes) {
result.append(Integer.toString((md5Byte & 0xff) + 0x100, 16).substring(1));
}
return result.toString();
} catch (NoSuchAlgorithmException | IOException e) {
//Handle the exception according to your requirements
e.printStackTrace();
return null;
}
}
}
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