:fix: HCS合同推送相对方单位类型按客商档案内部组织优先判定

This commit is contained in:
刘泉佳
2026-10-21 18:56:37 +08:00
parent 26c9a32c6b
commit 0a1324f90d
3 changed files with 59 additions and 12 deletions
@@ -524,29 +524,56 @@ public class HcsContractSyncSupport {
} }
/** /**
* signer 相对方(签署方):甲/乙双方,甲方 fdType=inner(内部主体),乙方 fdType=supplier(外部相对方) * signer 相对方(签署方):甲/乙双方。fdType 档案优先:客商档案为内部组织(customerKind=internal/内部组织)
* 的一方为我方签约主体传 inner,另一方传 customer(外部相对方,2026-10-14 联调口径);
* 双方均非内部组织或查不到档案时按合同类别推定(承运商合同甲=inner,客户合同乙=inner,其余 customer);
* 丙方(三方合同)TMS 无签约主体字段来源,暂不支持
*/ */
private List<HcsSignerDTO> buildSigners(ContractManage contractManage) { private List<HcsSignerDTO> buildSigners(ContractManage contractManage) {
List<HcsSignerDTO> signers = new ArrayList<>(); List<HcsSignerDTO> signers = new ArrayList<>();
// 甲方相对方:fdStanding=甲,内部主体 fdType=inner(编号按名称反查,反查不到留空,§9-U6) // 甲乙方各反查一次客商档案,编号与内部组织判定共用查询结果
signers.add(signer("甲", HcsConstant.SIGNER_FD_TYPE_INNER, contractManage.getPartyA())); CustomerArchive partyAArchive = queryCustomerArchive(contractManage.getPartyA());
// 乙方相对方:fdStanding=乙,外部相对方 fdType=supplier CustomerArchive partyBArchive = queryCustomerArchive(contractManage.getPartyB());
signers.add(signer("乙", HcsConstant.SIGNER_FD_TYPE_SUPPLIER, contractManage.getPartyB())); boolean partyAInternal = isInternalCustomer(partyAArchive);
boolean partyBInternal = isInternalCustomer(partyBArchive);
String partyAType;
String partyBType;
if (partyAInternal || partyBInternal) {
// 档案命中:内部组织一方=我方签约主体(inner),外部一方统一 customer
partyAType = partyAInternal ? HcsConstant.SIGNER_FD_TYPE_INNER : HcsConstant.SIGNER_FD_TYPE_CUSTOMER;
partyBType = partyBInternal ? HcsConstant.SIGNER_FD_TYPE_INNER : HcsConstant.SIGNER_FD_TYPE_CUSTOMER;
} else if ("承运商合同".equals(contractManage.getContractCategory())) {
// 兜底:档案未命中内部组织,按类别推定——我方为付款/发包方,签约主体在甲方
partyAType = HcsConstant.SIGNER_FD_TYPE_INNER;
partyBType = HcsConstant.SIGNER_FD_TYPE_CUSTOMER;
} else if ("客户合同".equals(contractManage.getContractCategory())) {
// 兜底:我方为收款/承运方,签约主体在乙方
partyAType = HcsConstant.SIGNER_FD_TYPE_CUSTOMER;
partyBType = HcsConstant.SIGNER_FD_TYPE_INNER;
} else {
// 兜底:其他类别双方统一 customer(2026-10-14 联调口径)
partyAType = HcsConstant.SIGNER_FD_TYPE_CUSTOMER;
partyBType = HcsConstant.SIGNER_FD_TYPE_CUSTOMER;
}
// 甲方相对方:fdStanding=甲(编号按名称反查,反查不到留空,§9-U6)
signers.add(signer("甲", partyAType, contractManage.getPartyA(), partyAArchive));
// 乙方相对方:fdStanding=乙
signers.add(signer("乙", partyBType, contractManage.getPartyB(), partyBArchive));
return signers; return signers;
} }
/** /**
* 单个相对方:甲方传 fdType=inner(内部主体),乙方传 fdType=supplier(外部相对方) * 单个相对方:fdType 由签约主体落位规则决定(我方主体 inner,外部相对方 customer)
*/ */
private HcsSignerDTO signer(String fdStanding, String fdType, String partyName) { private HcsSignerDTO signer(String fdStanding, String fdType, String partyName, CustomerArchive customerArchive) {
HcsSignerDTO signer = new HcsSignerDTO(); HcsSignerDTO signer = new HcsSignerDTO();
// 签署地位:甲 / 乙 // 签署地位:甲 / 乙
signer.setFdStanding(fdStanding); signer.setFdStanding(fdStanding);
// 相对方名称:TMS 甲乙方名称 // 相对方名称:TMS 甲乙方名称
signer.setFdName(partyName); signer.setFdName(partyName);
// 相对方编号:按名称反查 CustomerArchive 客商编码,反查不到留空(§9-U6) // 相对方编号:按名称反查 CustomerArchive 客商编码,反查不到留空(§9-U6)
signer.setFdNumber(queryCustomerCode(partyName)); signer.setFdNumber(customerArchive == null ? null : customerArchive.getCustomerCode());
// 单位类型:甲方 inner 内部主体 / 乙方 supplier 外部相对方 // 单位类型:inner 内部主体(我方签约主体)/ customer 外部相对方
signer.setFdType(fdType); signer.setFdType(fdType);
return signer; return signer;
} }
@@ -649,14 +676,30 @@ public class HcsContractSyncSupport {
* 按名称反查客商编码(照 KingdeeApBillSyncSupport#queryCustomerCode 惯例,查不到返回 null) * 按名称反查客商编码(照 KingdeeApBillSyncSupport#queryCustomerCode 惯例,查不到返回 null)
*/ */
private String queryCustomerCode(String partyName) { private String queryCustomerCode(String partyName) {
CustomerArchive customerArchive = queryCustomerArchive(partyName);
return customerArchive == null ? null : customerArchive.getCustomerCode();
}
/**
* 按名称反查客商档案(全称或简称精确匹配,查不到返回 null)
*/
private CustomerArchive queryCustomerArchive(String partyName) {
if (StringUtil.isBlank(partyName)) { if (StringUtil.isBlank(partyName)) {
return null; return null;
} }
CustomerArchive customerArchive = customerArchiveMapper.selectOne(Wrappers.<CustomerArchive>lambdaQuery() return customerArchiveMapper.selectOne(Wrappers.<CustomerArchive>lambdaQuery()
.and(wrapper -> wrapper.eq(CustomerArchive::getFullName, partyName).or().eq(CustomerArchive::getShortName, partyName)) .and(wrapper -> wrapper.eq(CustomerArchive::getFullName, partyName).or().eq(CustomerArchive::getShortName, partyName))
.eq(CustomerArchive::getIsDeleted, 0) .eq(CustomerArchive::getIsDeleted, 0)
.last("limit 1")); .last("limit 1"));
return customerArchive == null ? null : customerArchive.getCustomerCode(); }
/**
* 内部组织客商判定(集团内我方签约主体,档案登记 customerKind=internal/内部组织)
*/
private boolean isInternalCustomer(CustomerArchive customerArchive) {
return customerArchive != null
&& (HcsSyncConstant.CUSTOMER_KIND_INTERNAL.equals(customerArchive.getCustomerKind())
|| "内部组织".equals(customerArchive.getCustomerKind()));
} }
/** /**
@@ -56,4 +56,8 @@ public class HcsConstant {
* signer 相对方单位类型:乙方=supplier(外部相对方) * signer 相对方单位类型:乙方=supplier(外部相对方)
*/ */
public static final String SIGNER_FD_TYPE_SUPPLIER = "supplier"; public static final String SIGNER_FD_TYPE_SUPPLIER = "supplier";
/**
* signer 相对方单位类型:客户=customer
*/
public static final String SIGNER_FD_TYPE_CUSTOMER = "customer";
} }
@@ -54,7 +54,7 @@ public class HcsSignerDTO implements Serializable {
*/ */
private String fdNumber; private String fdNumber;
/** /**
* 单位类型:甲方=inner(内部主体),乙方=supplier(外部相对方) * 单位类型:我方签约主体=inner(内部主体,客商档案内部组织),外部相对方=customer
*/ */
private String fdType; private String fdType;
/** /**