This commit is contained in:
王奎兴
2026-07-02 15:59:58 +08:00
parent b178e79c8f
commit 01ec70e3c2
6 changed files with 69 additions and 66 deletions
@@ -359,7 +359,7 @@ public interface SystemServiceFeign {
@ApiOperation("根据结算主体和费用科目获取合同信息")
@GetMapping(value = "/contractManageApi/getInfoByCustomerAndSecondSubjectCode")
public AjaxResult getInfoByCustomerAndSecondSubjectCode(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("firstSubjectCode") String firstSubjectCode);
public AjaxResult getInfoByCustomerAndSecondSubjectCode(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("firstSubjectCode") String firstSubjectCode,@RequestParam("topOrganizationId") Long topOrganizationId,@RequestParam("organizationId") Long organizationId);
/**
* 根据结算主体获取合同信息
@@ -284,6 +284,11 @@ public class RemoteSystemFeignFallbackFactory implements FallbackFactory<SystemS
return AjaxResult.error("查询失败");
}
@Override
public AjaxResult getInfoByCustomerAndSecondSubjectCode(String settlementCustomersCode, Integer contractType, String firstSubjectCode) {
return null;
}
@Override
public AjaxResult getInfoByCustomer2(String settlementCustomersCode, Integer contractType, Long topOrganizationId) {
return AjaxResult.error("查询失败");
@@ -310,4 +315,4 @@ public class RemoteSystemFeignFallbackFactory implements FallbackFactory<SystemS
}
};
}
}
}
@@ -949,7 +949,7 @@ public class ContractManageApplicationService {
return resultContract;
}
public ContractManagePO getInfoByCustomerAndSecondSubjectCode(String settlementCustomersCode,Integer contractType, Long topOrganizationId,String firstSubjectCode) {
public ContractManagePO getInfoByCustomerAndSecondSubjectCode(String settlementCustomersCode,Integer contractType, Long topOrganizationId, Long organizationId,String firstSubjectCode) {
/*
首先根据合同类型(仓储、运输、其他),以及结算客户,查询合同信息
如果传了结算主体,则根据结算主体以及当前时间查询有效的特殊合同,如果特殊合同没有,则查询通用合同
@@ -967,11 +967,8 @@ public class ContractManageApplicationService {
ContractManageDO queryParam = new ContractManageDO();
queryParam.setNowDateString(DateUtil.format(new Date(),"yyyy-MM-dd"));
queryParam.setFirstSubjectCode(firstSubjectCode);
if (!ObjectUtil.isNull(loginUser)) {
queryParam.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}else {
queryParam.setTopOrganizationId(topOrganizationId);
}
queryParam.setOrganizationId(organizationId);
queryParam.setTopOrganizationId(topOrganizationId);
List<ContractManagePO> contractManagePOList = contractManageDomainService.queryList(queryParam);
List<ContractManagePO> contractManagePOs = contractManagePOList.stream()
.filter(item -> item.getSettlementCustomersCode().equals(settlementCustomersCode)
@@ -162,9 +162,9 @@ public class ContractManageApi extends BaseController{
@ApiOperation("根据结算主体和费用科目获取合同信息")
@GetMapping(value = "/getInfoByCustomerAndSecondSubjectCode")
public AjaxResult getInfoByCustomerAndSecondSubjectCode(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("firstSubjectCode") String firstSubjectCode)
public AjaxResult getInfoByCustomerAndSecondSubjectCode(@RequestParam("settlementCustomersCode") String settlementCustomersCode,@RequestParam("contractType") Integer contractType,@RequestParam("firstSubjectCode") String firstSubjectCode,@RequestParam("topOrganizationId") Long topOrganizationId,@RequestParam("organizationId") Long organizationId)
{
return AjaxResult.success(contractManageApplicationService.getInfoByCustomerAndSecondSubjectCode(settlementCustomersCode,contractType,null,firstSubjectCode));
return AjaxResult.success(contractManageApplicationService.getInfoByCustomerAndSecondSubjectCode(settlementCustomersCode,contractType,topOrganizationId,organizationId,firstSubjectCode));
}
@ApiOperation("根据结算主体获取合同信息")
@@ -17,101 +17,99 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectContractManagePo1">
<where>
<if test="createByName != null and createByName != ''">
and a.create_by_name like concat('%', #{createByName}, '%')
and create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and a.update_by_name like concat('%', #{updateByName}, '%')
and update_by_name like concat('%', #{updateByName}, '%')
</if>
<if test="topOrganizationId != null ">
and a.top_organization_id = #{topOrganizationId}
and top_organization_id = #{topOrganizationId}
</if>
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
and organization_id = #{organizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and a.organization_name like concat('%', #{organizationName}, '%')
and organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="contractNumber != null and contractNumber != ''">
and a.contract_number = #{contractNumber}
and contract_number = #{contractNumber}
</if>
<if test="contractName != null and contractName != ''">
and a.contract_name like concat('%', #{contractName}, '%')
and contract_name like concat('%', #{contractName}, '%')
</if>
<if test="commonContractFlag != null ">
and a.common_contract_flag = #{commonContractFlag}
and common_contract_flag = #{commonContractFlag}
</if>
<if test="contractType != null ">
and a.contract_type = #{contractType}
and contract_type = #{contractType}
</if>
<if test="contractState != null ">
and a.contract_state = #{contractState}
and contract_state = #{contractState}
</if>
<if test="signingUnit != null and signingUnit != ''">
and a.signing_unit = #{signingUnit}
and asigning_unit = #{signingUnit}
</if>
<if test="settlementCustomers != null and settlementCustomers != ''">
and a.settlement_customers = #{settlementCustomers}
and settlement_customers = #{settlementCustomers}
</if>
<if test="settlementCustomersId != null ">
and a.settlement_customers_id = #{settlementCustomersId}
and settlement_customers_id = #{settlementCustomersId}
</if>
<if test="settlementCustomersCode != null and settlementCustomersCode != ''">
and a.settlement_customers_code = #{settlementCustomersCode}
and settlement_customers_code = #{settlementCustomersCode}
</if>
<if test="ourIdentity != null ">
and a.our_identity = #{ourIdentity}
and our_identity = #{ourIdentity}
</if>
<if test="accountingPeriod != null ">
and a.accounting_period = #{accountingPeriod}
and accounting_period = #{accountingPeriod}
</if>
<if test="signingDate != null ">
and a.signing_date = #{signingDate}
and signing_date = #{signingDate}
</if>
<if test="effectiveDate != null ">
and a.effective_date = #{effectiveDate}
and effective_date = #{effectiveDate}
</if>
<if test="expirationDate != null ">
and a.expiration_date = #{expirationDate}
and expiration_date = #{expirationDate}
</if>
<if test="contractOriginalUrl != null and contractOriginalUrl != ''">
and a.contract_original_url = #{contractOriginalUrl}
and contract_original_url = #{contractOriginalUrl}
</if>
<if test="integrityAgreementUrl != null and integrityAgreementUrl != ''">
and a.integrity_agreement_url = #{integrityAgreementUrl}
and integrity_agreement_url = #{integrityAgreementUrl}
</if>
<if test="securityProtocolUrl != null and securityProtocolUrl != ''">
and a.security_protocol_url = #{securityProtocolUrl}
and security_protocol_url = #{securityProtocolUrl}
</if>
<if test="otherAttachmentsUrl != null and otherAttachmentsUrl != ''">
and a.other_attachments_url = #{otherAttachmentsUrl}
and other_attachments_url = #{otherAttachmentsUrl}
</if>
<if test="ourSinged != null and ourSinged != ''">
and a.our_singed = #{ourSinged}
and our_singed = #{ourSinged}
</if>
<if test="ourSingedPhone != null and ourSingedPhone != ''">
and a.our_singed_phone = #{ourSingedPhone}
and our_singed_phone = #{ourSingedPhone}
</if>
<if test="ourOperator != null and ourOperator != ''">
and a.our_operator = #{ourOperator}
and our_operator = #{ourOperator}
</if>
<if test="ourOperatorPhone != null and ourOperatorPhone != ''">
and a.our_operator_phone = #{ourOperatorPhone}
and our_operator_phone = #{ourOperatorPhone}
</if>
<if test="theySinged != null and theySinged != ''">
and a.they_singed = #{theySinged}
and they_singed = #{theySinged}
</if>
<if test="theySingedPhone != null and theySingedPhone != ''">
and a.they_singed_phone = #{theySingedPhone}
and they_singed_phone = #{theySingedPhone}
</if>
<if test="theyOperator != null and theyOperator != ''">
and a.they_operator = #{theyOperator}
and they_operator = #{theyOperator}
</if>
<if test="theyOperatorPhone != null and theyOperatorPhone != ''">
and a.they_operator_phone = #{theyOperatorPhone}
</if>
<if test="firstSubjectCode != null and firstSubjectCode != ''">
and b.FIRST_SUBJECT_CODE = #{firstSubjectCode}
and they_operator_phone = #{theyOperatorPhone}
</if>
</where>
</sql>
@@ -136,72 +134,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="common_where">
<if test="contractManageDO.contractNumber != null and contractManageDO.contractNumber != ''">
and contract_number like concat('%', #{contractManageDO.contractNumber}, '%')
and a.contract_number like concat('%', #{contractManageDO.contractNumber}, '%')
</if>
<if test="contractManageDO.originalContractNumber != null and contractManageDO.originalContractNumber != ''">
and original_contract_number like concat('%', #{contractManageDO.originalContractNumber}, '%')
and a.original_contract_number like concat('%', #{contractManageDO.originalContractNumber}, '%')
</if>
<if test="contractManageDO.commonContractFlag != null">
and common_contract_flag = #{contractManageDO.commonContractFlag}
and a.common_contract_flag = #{contractManageDO.commonContractFlag}
</if>
<if test="contractManageDO.contractType != null">
and contract_type = #{contractManageDO.contractType}
and a.contract_type = #{contractManageDO.contractType}
</if>
<if test="contractManageDO.settlementCustomers != null and contractManageDO.settlementCustomers != '' " >
and settlement_customers like concat('%', #{contractManageDO.settlementCustomers}, '%')
and a.settlement_customers like concat('%', #{contractManageDO.settlementCustomers}, '%')
</if>
<if test="contractManageDO.settlementCustomersCode != null">
and settlement_customers_code = #{contractManageDO.settlementCustomersCode}
and a.settlement_customers_code = #{contractManageDO.settlementCustomersCode}
</if>
<if test="contractManageDO.signingUnit != null and contractManageDO.signingUnit != ''">
and signing_unit like concat('%', #{contractManageDO.signingUnit}, '%')
and a.signing_unit like concat('%', #{contractManageDO.signingUnit}, '%')
</if>
<if test="contractManageDO.contractName != null and contractManageDO.contractName != ''">
and contract_name like concat('%', #{contractManageDO.contractName}, '%')
and a.contract_name like concat('%', #{contractManageDO.contractName}, '%')
</if>
<if test="contractManageDO.contractState != null">
and contract_state = #{contractManageDO.contractState}
and a.contract_state = #{contractManageDO.contractState}
</if>
<if test="contractManageDO.signingDateStart != null and contractManageDO.signingDateStart != ''">
AND date_format(signing_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.signingDateStart}
AND date_format(a.signing_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.signingDateStart}
</if>
<if test="contractManageDO.signingDateEnd != null and contractManageDO.signingDateEnd != ''">
AND date_format(signing_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.signingDateEnd}
AND date_format(a.signing_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.signingDateEnd}
</if>
<if test="contractManageDO.effectiveDateStart != null and contractManageDO.effectiveDateStart != ''">
AND date_format(effective_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateStart}
AND date_format(a.effective_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateStart}
</if>
<if test="contractManageDO.effectiveDateEnd != null and contractManageDO.effectiveDateEnd != ''">
AND date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.effectiveDateEnd}
AND date_format(a.effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.effectiveDateEnd}
</if>
<if test="contractManageDO.expirationDateStart != null and contractManageDO.expirationDateStart != ''">
AND date_format(expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.expirationDateStart}
AND date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.expirationDateStart}
</if>
<if test="contractManageDO.expirationDateEnd != null and contractManageDO.expirationDateEnd != ''">
AND date_format(expiration_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateEnd}
AND date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateEnd}
</if>
<!-- 时间段重叠判断:只有当已有合同与传入的有效期真正有交集时才算冲突
条件:已有合同开始日期 <= 新合同结束日期 且 已有合同结束日期 >= 新合同开始日期 -->
<if test="contractManageDO.effectiveDateString != null and contractManageDO.effectiveDateString != ''
and contractManageDO.expirationDateString != null and contractManageDO.expirationDateString != ''">
AND (
date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateString}
AND date_format(expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateString}
date_format(a.effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateString}
AND date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateString}
)
</if>
<if test="contractManageDO.nowDateString != null and contractManageDO.nowDateString != ''">
AND (
date_format(expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.nowDateString}
AND date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.nowDateString}
date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.nowDateString}
AND date_format(a.effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.nowDateString}
)
</if>
<if test="contractManageDO.organizationId != null">
and organization_id = #{contractManageDO.organizationId}
and a.organization_id = #{contractManageDO.organizationId}
</if>
<if test="contractManageDO.topOrganizationId != null">
and top_organization_id = #{contractManageDO.topOrganizationId}
and a.top_organization_id = #{contractManageDO.topOrganizationId}
</if>
<if test="contractManageDO.firstSubjectCode != null and contractManageDO.firstSubjectCode != ''">
and b.FIRST_SUBJECT_CODE = #{contractManageDO.firstSubjectCode}
</if>
</sql>
@@ -484,7 +484,7 @@ public class BusinessDocumentApplicationService {
if(businessDocumentDO.getBelongModuleCode().equals(BelongModuleCode.WMS.getCode())){
contractType = 1;
}
AjaxResult ajaxResult = systemServiceFeign.getInfoByCustomerAndOrganizationId(businessDocumentDO.getSettlementCustomersCode(),contractType,businessDocumentDO.getTopOrganizationId(),businessDocumentDO.getOrganizationId());
AjaxResult ajaxResult = systemServiceFeign.getInfoByCustomerAndSecondSubjectCode(businessDocumentDO.getSettlementCustomersCode(),contractType,businessDocumentDO.getFirstSubjectCode(),businessDocumentDO.getTopOrganizationId(),businessDocumentDO.getOrganizationId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("合同信息未找到");
}