From 050653ca01cb77c17a0c12abcdf47aa2da184fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 24 Feb 2025 15:14:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E7=A5=A8=E6=8D=AE=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbs8/client/AccountManagementClient.java | 20 +- .../cbs8/client/BillManagementClient.java | 57 +++ .../remote/cbs8/request/GetDtaRequest.java | 108 +++++ .../remote/cbs8/response/GetDtaResponse.java | 440 ++++++++++++++++++ .../engine/salary/timer/CBS8GetDtaJob.java | 85 ++++ .../timer/CBS8GetTransactionDetailJob.java | 2 + 6 files changed, 708 insertions(+), 4 deletions(-) create mode 100644 src/com/engine/salary/remote/cbs8/client/BillManagementClient.java create mode 100644 src/com/engine/salary/remote/cbs8/request/GetDtaRequest.java create mode 100644 src/com/engine/salary/remote/cbs8/response/GetDtaResponse.java create mode 100644 src/com/engine/salary/timer/CBS8GetDtaJob.java diff --git a/src/com/engine/salary/remote/cbs8/client/AccountManagementClient.java b/src/com/engine/salary/remote/cbs8/client/AccountManagementClient.java index 68a00dd9d..579c68574 100644 --- a/src/com/engine/salary/remote/cbs8/client/AccountManagementClient.java +++ b/src/com/engine/salary/remote/cbs8/client/AccountManagementClient.java @@ -4,6 +4,7 @@ import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.remote.cbs8.request.GetTransactionDetailRequest; import com.engine.salary.remote.cbs8.response.GetTransactionDetailResponse; import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryI18nUtil; import lombok.extern.slf4j.Slf4j; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; @@ -12,11 +13,12 @@ import org.apache.http.impl.client.HttpClients; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.util.Objects; @Slf4j public class AccountManagementClient extends CBS8BaseClient { - public String transactionDetailQuery(GetTransactionDetailRequest requestParam) throws IOException { + public GetTransactionDetailResponse transactionDetailQuery(GetTransactionDetailRequest requestParam) throws IOException { String url = host + "/openapi/account/openapi/v1/transaction-detail/query"; @@ -34,14 +36,24 @@ public class AccountManagementClient extends CBS8BaseClient { String req = new String(finalResponseData, StandardCharsets.UTF_8); GetTransactionDetailResponse getTransactionDetailResponse = JsonUtil.parseBean(req, GetTransactionDetailResponse.class); log.info(url + "\n" + JsonUtil.toJsonString(getTransactionDetailResponse)); + + if (Objects.isNull(getTransactionDetailResponse)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156449, "服务异常")); + } + if (!"0".equals(getTransactionDetailResponse.getCode())) { + throw new SalaryRunTimeException(getTransactionDetailResponse.getMsg()); + } + if (getTransactionDetailResponse.getData() == null) { + throw new SalaryRunTimeException("未获取数据"); + } + + return getTransactionDetailResponse; + } catch (IOException ignored) { throw new SalaryRunTimeException("网络连接失败或超时!"); } finally { client.close(); } - - return ""; - } } diff --git a/src/com/engine/salary/remote/cbs8/client/BillManagementClient.java b/src/com/engine/salary/remote/cbs8/client/BillManagementClient.java new file mode 100644 index 000000000..f0b30a97c --- /dev/null +++ b/src/com/engine/salary/remote/cbs8/client/BillManagementClient.java @@ -0,0 +1,57 @@ +package com.engine.salary.remote.cbs8.client; + +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.remote.cbs8.request.GetDtaRequest; +import com.engine.salary.remote.cbs8.response.GetDtaResponse; +import com.engine.salary.util.JsonUtil; +import com.engine.salary.util.SalaryI18nUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +@Slf4j +public class BillManagementClient extends CBS8BaseClient { + + public GetDtaResponse dtaQuery(GetDtaRequest requestParam) throws IOException { + String url = host + "/openapi/draft/openapi/v1/dta/query"; + + CloseableHttpClient client = HttpClients.custom() + // 禁止HttpClient自动解压缩 + .disableContentCompression() + .build(); + + String requestData = JsonUtil.toJsonString(requestParam); + log.info(url + "\n" + requestData); + + HttpPost httpPost = setupRequest(url, requestData); + try (CloseableHttpResponse response = client.execute(httpPost)) { + byte[] finalResponseData = handleResponse(response); + String req = new String(finalResponseData, StandardCharsets.UTF_8); + GetDtaResponse getDtaResponse = JsonUtil.parseBean(req, GetDtaResponse.class); + log.info(url + "\n" + JsonUtil.toJsonString(getDtaResponse)); + + if (Objects.isNull(getDtaResponse)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156449, "服务异常")); + } + if (!"0".equals(getDtaResponse.getCode())) { + throw new SalaryRunTimeException(getDtaResponse.getMsg()); + } + if (getDtaResponse.getData() == null) { + throw new SalaryRunTimeException("未获取数据"); + } + + return getDtaResponse; + } catch (IOException ignored) { + throw new SalaryRunTimeException("网络连接失败或超时!"); + } finally { + client.close(); + } + } + +} diff --git a/src/com/engine/salary/remote/cbs8/request/GetDtaRequest.java b/src/com/engine/salary/remote/cbs8/request/GetDtaRequest.java new file mode 100644 index 000000000..cf3970895 --- /dev/null +++ b/src/com/engine/salary/remote/cbs8/request/GetDtaRequest.java @@ -0,0 +1,108 @@ +package com.engine.salary.remote.cbs8.request; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +public class GetDtaRequest extends CBS8BaseRequest { + /** + * 出票日期起 格式为yyyy-mm-dd,出票日期起止不允许一边有值一边无值,日期间隔最大为一年 + */ + private String issueDateStart; + /** + * 出票日期止 格式为yyyy-mm-dd,出票日期起止不允许一边有值一边无值,日期间隔最大为一年 + */ + private String issueDateEnd; + /** + * 到期日期起 格式为yyyy-mm-dd,到期日期起止不允许一边有值一边无值,日期间隔最大为一年 + */ + private String dueDateStart; + /** + * 到期日期止 格式为yyyy-mm-dd,到期日期起止不允许一边有值一边无值,日期间隔最大为一年 + */ + private String dueDateEnd; + /** + * 票据种类 AC01-银承,AC02-商承 + */ + private String billType; + /** + * 票据来源 多选。1-直联交易,2-台账交易,3-台账登记,4-挑票同步,5-任务同步 + */ + private List draftSourceList; + /** + * 持票银行类型 多选。见附录4.1.1.银行类型枚举 + */ + private List holdBankTypeList; + /** + * 持票人单位编码 多选。填在cbs系统公共设置>基础信息>组织机构维护的单位编码 + */ + private List displayHoldOrganizationCodeList; + /** + * 持票人账号 多选。 + */ + private List holdAccountList; + /** + * 持票签收日期起 格式为yyyy-mm-dd,持票签收日期起止不允许一边有值一边无值,日期间隔最大为一年 + */ + private String holdSignDateStart; + /** + * 持票签收日期止 格式为yyyy-mm-dd,持票签收日期起止不允许一边有值一边无值,日期间隔最大为一年 + */ + private String holdSignDateEnd; + /** + * 系统票据编号 + */ + private String draftNbr; + /** + * 票据(包)号 + */ + private String billNbr; + + /** + * 票据金额起 大于等于0,最多为两位小数且整数位上限为13位。票据金额起止不允许一边有值一边无值。单位(元) + */ + private BigDecimal billAmountStart; + + /** + * 票据金额止 大于等于0,最多为两位小数且整数位上限为13位。票据金额起止不允许一边有值一边无值。单位(元) + */ + private BigDecimal billAmountEnd; + + /** + * 子票区间起 子票区间起止不允许一边有值一边无值,最多12位 + */ + private String subBillIntervalStart; + /** + * 子票区间止 子票区间起止不允许一边有值一边无值,最多12位 + */ + private String subBillIntervalEnd; + /** + * 系统票据类型 多选。按附录4.1.3票据类型-票据状态-流通标志级联关系表选择后按顺序填写。系统票据类型枚举见附录4.1.3。票据状态枚举见附录4.1.4。流通标志枚举见附录4.1.5。 + */ + private List billVarietyList; + /** + * 票据状态 + */ + private List billStsList; + /** + * 流通标志 + */ + private List billTrsStsList; + /** + * 库存状态 1-已入库,2-已出库。 为空时默认查询全部数据 + */ + private String stockFlag; + /** + * 出库方式 0-空,2-背书,3-质押,4-解质,5-贴现,6-分包,7-结清, 8-作废。 为空时默认查询全部数据 + */ + private String outInvType; + /** + * 记录状态 NOR-正常,USE-占用,DEL-删除 SUC-完成。为空时默认查询全部数据 + */ + private String lockFlag; + +} diff --git a/src/com/engine/salary/remote/cbs8/response/GetDtaResponse.java b/src/com/engine/salary/remote/cbs8/response/GetDtaResponse.java new file mode 100644 index 000000000..c2c92c61c --- /dev/null +++ b/src/com/engine/salary/remote/cbs8/response/GetDtaResponse.java @@ -0,0 +1,440 @@ +package com.engine.salary.remote.cbs8.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +public class GetDtaResponse extends CBS8BaseResponse { + /** + * 返回数据 + */ + private Body data; + + @Data + public static class Body { + /** + * 明细列表 + */ + private List list; + } + + @Data + public static class Detail { + /** + * 系统票据编号 + */ + private String draftNbr; + /** + * 父系统票据编号 + */ + private String fatDraftNbr; + /** + * 系统票据类型 系统票据类型枚举见附录4.1.3。 + */ + private String billVariety; + /** + * 票据(包)号 + */ + private String billNbr; + /** + * 是否可分包 0-未分包 1-已分包 + */ + private String splitFlag; + /** + * 子票区间起 + */ + private String subBillIntervalStart; + /** + * 子票区间止 + */ + private String subBillIntervalEnd; + /** + * 子票区间 + */ + private String subBillInterval; + + /** + * 票据金额 大于等于0,最多为两位小数且整数位上限为13位。单位(元) + */ + private BigDecimal billAmount; + + /** + * 票据种类 AC01-银承,AC02-商承 + */ + private String billType; + /** + * 出票日期 格式为yyyy-mm-dd + */ + private Date issueDate; + /** + * 到期日期 格式为yyyy-mm-dd + */ + private Date dueDate; + /** + * 票面收票日期 第一手收票人签收日期,格式为yyyy-mm-dd + */ + private Date receiptDate; + /** + * 持票签收日期 票据签收日期,格式为yyyy-mm-dd + */ + private Date holdSignDate; + /** + * 票面不得转让标记 EM00-可转让,EM01-不可转让 + */ + private String trfFlag; + /** + * 背书不得转让标记 EM00-可转让,EM01-不可转让 + */ + private String endorsementTransferFlg; + /** + * 票据状态 票据状态枚举见附录4.1.4 + */ + private String billSts; + /** + * 流通标志 流通标志枚举见附录4.1.5。 + */ + private String billTrsSts; + /** + * 库存状态 0-未入库,1-已入库,2-已出库 + */ + private String stockFlag; + /** + * 出库方式 0-空,2-背书,3-质押,4-解质,5-贴现,6-分包,7-结清, 8-作废 + */ + private String outInvType; + /** + * 风险状态 RS00-非风险票据 RS01-挂失止付 RS02-公示催告 RS03-司法冻结 RS05-争议票据 RS06-除权判决 + */ + private String riskFlag; + /** + * 记录状态 NOR-正常,USE-占用,DEL-删除 SUC-完成 + */ + private String lockFlag; + /** + * 票据来源 + * 1-直联交易 + * 2-系统交易 + * 3-台账登记 + * 4-挑票同步 + * 5-任务同步 + */ + private String draftSource; + /** + * 承兑人类型 RC00-银行(02), RC01-企业(00) ,RC02- 人民银行(01),RC03 -被代理行(A1),RC04-被代理财务公司(A2), RC05-财务公司(03), RC06-证券公司(03) ,RC07-基金公司(03) + */ + private String acceptorType; + /** + * 是否出票保证 1-是,0-否 + */ + private String drawerEnsureFlag; + /** + * 是否承兑保证 1-是,0-否 + */ + private String acceptorEnsureFlag; + /** + * 是否背书保证 1-是,0-否 + */ + private String backEnsureFlag; + /** + * 出票人名称 + */ + private String drawerName; + /** + * 出票人是否内部企业 1-是,0-否 + */ + private String drawerInternalFlag; + /** + * 出票人单位名称 + */ + private String drawerOrganizationName; + /** + * 出票人单位编码 + */ + private String displayDrawerOrganizationCode; + /** + * 出票人是否客商企业 1-是,0-否 + */ + private String drawerCustomerFlg; + /** + * 出票人客商名称 + */ + private String drawerCustomerName; + /** + * 出票人客商编号 填在cbs系统公共设置>基础信息>客商管理>客商信息管理维护的客商编号 + */ + private String drawerCustomerNbr; + /** + * 出票人账户名称 + */ + private String drawerAccountName; + /** + * 出票人账号 + */ + private String drawerAccount; + /** + * 出票人开户行名称 + */ + private String drawerBrnName; + /** + * 出票人联行号 + */ + private String drawerInterbankNbr; + /** + * 收款人名称 + */ + private String payeeName; + /** + * 收款人是否内部企业 1-是,0-否 + */ + private String payeeInternalFlag; + /** + * 收款人单位名称 + */ + private String payeeOrganizationName; + /** + * 收款人单位编码 + */ + private String displayPayeeOrganizationCode; + /** + * 收款人是否客商企业 1-是,0-否 + */ + private String payeeCustomerFlag; + /** + * 收款人客商名称 + */ + private String payeeCustomerName; + /** + * 收款人客商编号 填在cbs系统公共设置>基础信息>客商管理>客商信息管理维护的客商编号 + */ + private String payeeCustomerNbr; + /** + * 收款人账户名称 + */ + private String payeeAccountName; + /** + * 收款人账号 + */ + private String payeeAccount; + /** + * 收款人联行号 + */ + private String payeeInterbankNbr; + /** + * 收款人开户行名称 + */ + private String payeeBrnName; + /** + * 承兑人名称 + */ + private String acceptorName; + /** + * 承兑人是否内部企业 1-是,0-否 + */ + private String acceptorInternalFlag; + /** + * 承兑人单位名称 + */ + private String acceptorOrganizationName; + /** + * 承兑人单位编码 + */ + private String displayAcceptorOrganizationCode; + /** + * 承兑人是否客商企业 1-是,0-否 + */ + private String acceptorCustomerFlg; + /** + * 承兑人客商名称 + */ + private String acceptorCustomerName; + /** + * 承兑人客商编号 填在cbs系统公共设置>基础信息>客商管理>客商信息管理维护的客商编号 + */ + private String acceptorCustomerNbr; + /** + * 承兑人账户名称 + */ + private String acceptorAccountName; + /** + * 承兑人账号 + */ + private String acceptorAccount; + /** + * 承兑人开户行名称 + */ + private String acceptorBrnName; + /** + * 承兑人联行号 + */ + private String acceptorInterbankNbr; + /** + * 到期无条件支付委托/承诺 + */ + private String expireUnconditionalPay; + /** + * 承兑日期 格式为yyyy-mm-dd + */ + private Date acceptorDate; + /** + * 出票人评级主体 + */ + private String drawerRateSubject; + /** + * 出票人信用等级 信用等级枚举见附录4.1.7。 + */ + private String drawerCreditRating; + /** + * 出票人评级到期日 格式为yyyy-mm-dd + */ + private Date drawerRateDueDate; + /** + * 承兑人评级主体 + */ + private String acceptorRateSubject; + /** + * 承兑人信用等级 信用等级枚举见附录4.1.7。 + */ + private String acceptorCreditRating; + /** + * 承兑人评级到期日 格式为yyyy-mm-dd + */ + private Date acceptorRateDueDate; + /** + * 持票人名称 + */ + private String holdName; + /** + * 持票人单位名称 + */ + private String holdOrganizationName; + /** + * 持票人单位编码 + */ + private String displayHoldOrganizationCode; + /** + * 持票人账户名称 + */ + private String holdAccountName; + /** + * 持票人银行类型 见附录4.1.1.银行类型枚举 + */ + private String holdBankType; + /** + * 持票人账号 + */ + private String holdAccount; + /** + * 持票人开户行名称 + */ + private String holdBrnName; + /** + * 持票人联行号 + */ + private String holdInterbankNbr; + /** + * 前手名称 + */ + private String preName; + /** + * 前手是否内部企业 1-是,0-否 + */ + private String preInternalFlag; + /** + * 前手单位名称 + */ + private String preOrganizationName; + /** + * 前手单位编码 + */ + private String displayPreOrganizationCode; + /** + * 前手是否客商企业 1-是,0-否 + */ + private String preCustomerFlag; + /** + * 前手客商名称 + */ + private String preCustomerName; + /** + * 前手客商编号 填在cbs系统公共设置>基础信息>客商管理>客商信息管理维护的客商编号 + */ + private String preCustomerNbr; + /** + * 前手账户名称 + */ + private String preAccountName; + /** + * 前手账号 + */ + private String preAccount; + /** + * 前手开户行名称 + */ + private String preBrnName; + /** + * 前手联行号 + */ + private String preInterbankNbr; + /** + * 后手名称 + */ + private String nextName; + /** + * 后手是否内部企业 1-是,0-否 + */ + private String nextInternalFlag; + /** + * 后手单位名称 + */ + private String nextOrganizationName; + /** + * 后手单位编码 + */ + private String displayNextOrganizationCode; + /** + * 后手是否客商企业 1-是,0-否 + */ + private String nextCustomerFlag; + /** + * 后手客商名称 + */ + private String nextCustomerName; + /** + * 后手客商编号 填在cbs系统公共设置>基础信息>客商管理>客商信息管理维护的客商编号 + */ + private String nextCustomerNbr; + /** + * 后手账户名称 + */ + private String nextAccountName; + /** + * 后手账号 + */ + private String nextAccount; + /** + * 后手开户行名称 + */ + private String nextBrnName; + /** + * 后手联行号 + */ + private String nextInterbankNbr; + /** + * 签收方式 1-收票签收,2-背书签收 + */ + private String signMethod; + /** + * 同步状态 + * INIT-未同步 + * ING-同步中 + * SUC-同步完成 + * FAL-同步失败 + */ + private String asyncStatus; + } +} diff --git a/src/com/engine/salary/timer/CBS8GetDtaJob.java b/src/com/engine/salary/timer/CBS8GetDtaJob.java new file mode 100644 index 000000000..ef30ca304 --- /dev/null +++ b/src/com/engine/salary/timer/CBS8GetDtaJob.java @@ -0,0 +1,85 @@ +package com.engine.salary.timer; + +import cn.hutool.core.util.StrUtil; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.hrm.HrmSnapshotMapper; +import com.engine.salary.remote.cbs8.client.BillManagementClient; +import com.engine.salary.remote.cbs8.request.GetDtaRequest; +import com.engine.salary.remote.cbs8.response.GetDtaResponse; +import com.engine.salary.util.db.MapperProxyFactory; +import lombok.extern.slf4j.Slf4j; +import weaver.hrm.User; +import weaver.interfaces.schedule.BaseCronJob; + +import java.time.LocalDate; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 获取CBS票据信息 + *

Copyright: Copyright (c) 2024

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Slf4j +public class CBS8GetDtaJob extends BaseCronJob { + + /** + * 出票日期起 格式为yyyy-mm-dd,出票日期起止不允许一边有值一边无值,日期间隔最大为一年 + */ + private String issueDateStart; + /** + * 出票日期止 格式为yyyy-mm-dd,出票日期起止不允许一边有值一边无值,日期间隔最大为一年 + */ + private String issueDateEnd; + + /** + * 持票人单位编码 多选。填在cbs系统公共设置>基础信息>组织机构维护的单位编码 + */ + private String displayHoldOrganizationCodeList; + /** + * 持票人账号 多选。 + */ + private String holdAccountList; + + + private HrmSnapshotMapper getHrmSnapshotMapper() { + return MapperProxyFactory.getProxy(HrmSnapshotMapper.class); + } + + @Override + public void execute() { + User user = new User(); + user.setUid(1); + user.setLoginid("sysadmin"); + + try { + GetDtaRequest requestParam = new GetDtaRequest(); + requestParam.setCurrentPage(1); + requestParam.setPageSize(1000); + + if (StrUtil.isNotBlank(issueDateStart) && StrUtil.isNotBlank(issueDateEnd)) { + requestParam.setIssueDateStart(issueDateStart); + requestParam.setIssueDateEnd(issueDateEnd); + } else { + String nowDate = LocalDate.now().toString(); + requestParam.setIssueDateStart(nowDate); + requestParam.setIssueDateEnd(nowDate); + } + requestParam.setDisplayHoldOrganizationCodeList(Arrays.stream(displayHoldOrganizationCodeList.split(",")).collect(Collectors.toList())); + requestParam.setHoldAccountList(Arrays.stream(holdAccountList.split(",")).collect(Collectors.toList())); + + BillManagementClient bailManagementClient = new BillManagementClient(); + GetDtaResponse getDtaResponse = bailManagementClient.dtaQuery(requestParam); + + List list = getDtaResponse.getData().getList(); + + } catch (Exception e) { + log.error("获取CBS票据信息失败", e); + throw new SalaryRunTimeException("获取CBS票据信息失败," + e.getMessage(), e); + } + } +} diff --git a/src/com/engine/salary/timer/CBS8GetTransactionDetailJob.java b/src/com/engine/salary/timer/CBS8GetTransactionDetailJob.java index 1f7e5b53d..7d23e311b 100644 --- a/src/com/engine/salary/timer/CBS8GetTransactionDetailJob.java +++ b/src/com/engine/salary/timer/CBS8GetTransactionDetailJob.java @@ -1,6 +1,7 @@ package com.engine.salary.timer; import cn.hutool.core.util.StrUtil; +import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.hrm.HrmSnapshotMapper; import com.engine.salary.remote.cbs8.client.AccountManagementClient; import com.engine.salary.remote.cbs8.request.GetTransactionDetailRequest; @@ -76,6 +77,7 @@ public class CBS8GetTransactionDetailJob extends BaseCronJob { accountManagementClient.transactionDetailQuery(requestParam); } catch (Exception e) { log.error("获取CBS交易信息失败", e); + throw new SalaryRunTimeException("获取CBS交易信息失败," + e.getMessage(), e); } } }