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("根据结算主体和费用科目获取合同信息") @ApiOperation("根据结算主体和费用科目获取合同信息")
@GetMapping(value = "/contractManageApi/getInfoByCustomerAndSecondSubjectCode") @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("查询失败"); return AjaxResult.error("查询失败");
} }
@Override
public AjaxResult getInfoByCustomerAndSecondSubjectCode(String settlementCustomersCode, Integer contractType, String firstSubjectCode) {
return null;
}
@Override @Override
public AjaxResult getInfoByCustomer2(String settlementCustomersCode, Integer contractType, Long topOrganizationId) { public AjaxResult getInfoByCustomer2(String settlementCustomersCode, Integer contractType, Long topOrganizationId) {
return AjaxResult.error("查询失败"); return AjaxResult.error("查询失败");
@@ -949,7 +949,7 @@ public class ContractManageApplicationService {
return resultContract; 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(); ContractManageDO queryParam = new ContractManageDO();
queryParam.setNowDateString(DateUtil.format(new Date(),"yyyy-MM-dd")); queryParam.setNowDateString(DateUtil.format(new Date(),"yyyy-MM-dd"));
queryParam.setFirstSubjectCode(firstSubjectCode); queryParam.setFirstSubjectCode(firstSubjectCode);
if (!ObjectUtil.isNull(loginUser)) { queryParam.setOrganizationId(organizationId);
queryParam.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); queryParam.setTopOrganizationId(topOrganizationId);
}else {
queryParam.setTopOrganizationId(topOrganizationId);
}
List<ContractManagePO> contractManagePOList = contractManageDomainService.queryList(queryParam); List<ContractManagePO> contractManagePOList = contractManageDomainService.queryList(queryParam);
List<ContractManagePO> contractManagePOs = contractManagePOList.stream() List<ContractManagePO> contractManagePOs = contractManagePOList.stream()
.filter(item -> item.getSettlementCustomersCode().equals(settlementCustomersCode) .filter(item -> item.getSettlementCustomersCode().equals(settlementCustomersCode)
@@ -162,9 +162,9 @@ public class ContractManageApi extends BaseController{
@ApiOperation("根据结算主体和费用科目获取合同信息") @ApiOperation("根据结算主体和费用科目获取合同信息")
@GetMapping(value = "/getInfoByCustomerAndSecondSubjectCode") @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("根据结算主体获取合同信息") @ApiOperation("根据结算主体获取合同信息")
@@ -17,101 +17,99 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectContractManagePo1"> <sql id="selectContractManagePo1">
<where> <where>
<if test="createByName != null and createByName != ''"> <if test="createByName != null and createByName != ''">
and a.create_by_name like concat('%', #{createByName}, '%') and create_by_name like concat('%', #{createByName}, '%')
</if> </if>
<if test="updateByName != null and updateByName != ''"> <if test="updateByName != null and updateByName != ''">
and a.update_by_name like concat('%', #{updateByName}, '%') and update_by_name like concat('%', #{updateByName}, '%')
</if> </if>
<if test="topOrganizationId != null "> <if test="topOrganizationId != null ">
and a.top_organization_id = #{topOrganizationId} and top_organization_id = #{topOrganizationId}
</if> </if>
<if test="organizationId != null "> <if test="organizationId != null ">
and a.organization_id = #{organizationId} and organization_id = #{organizationId}
</if> </if>
<if test="organizationName != null and organizationName != ''"> <if test="organizationName != null and organizationName != ''">
and a.organization_name like concat('%', #{organizationName}, '%') and organization_name like concat('%', #{organizationName}, '%')
</if> </if>
<if test="contractNumber != null and contractNumber != ''"> <if test="contractNumber != null and contractNumber != ''">
and a.contract_number = #{contractNumber} and contract_number = #{contractNumber}
</if> </if>
<if test="contractName != null and contractName != ''"> <if test="contractName != null and contractName != ''">
and a.contract_name like concat('%', #{contractName}, '%') and contract_name like concat('%', #{contractName}, '%')
</if> </if>
<if test="commonContractFlag != null "> <if test="commonContractFlag != null ">
and a.common_contract_flag = #{commonContractFlag} and common_contract_flag = #{commonContractFlag}
</if> </if>
<if test="contractType != null "> <if test="contractType != null ">
and a.contract_type = #{contractType} and contract_type = #{contractType}
</if> </if>
<if test="contractState != null "> <if test="contractState != null ">
and a.contract_state = #{contractState} and contract_state = #{contractState}
</if> </if>
<if test="signingUnit != null and signingUnit != ''"> <if test="signingUnit != null and signingUnit != ''">
and a.signing_unit = #{signingUnit} and asigning_unit = #{signingUnit}
</if> </if>
<if test="settlementCustomers != null and settlementCustomers != ''"> <if test="settlementCustomers != null and settlementCustomers != ''">
and a.settlement_customers = #{settlementCustomers} and settlement_customers = #{settlementCustomers}
</if> </if>
<if test="settlementCustomersId != null "> <if test="settlementCustomersId != null ">
and a.settlement_customers_id = #{settlementCustomersId} and settlement_customers_id = #{settlementCustomersId}
</if> </if>
<if test="settlementCustomersCode != null and settlementCustomersCode != ''"> <if test="settlementCustomersCode != null and settlementCustomersCode != ''">
and a.settlement_customers_code = #{settlementCustomersCode} and settlement_customers_code = #{settlementCustomersCode}
</if> </if>
<if test="ourIdentity != null "> <if test="ourIdentity != null ">
and a.our_identity = #{ourIdentity} and our_identity = #{ourIdentity}
</if> </if>
<if test="accountingPeriod != null "> <if test="accountingPeriod != null ">
and a.accounting_period = #{accountingPeriod} and accounting_period = #{accountingPeriod}
</if> </if>
<if test="signingDate != null "> <if test="signingDate != null ">
and a.signing_date = #{signingDate} and signing_date = #{signingDate}
</if> </if>
<if test="effectiveDate != null "> <if test="effectiveDate != null ">
and a.effective_date = #{effectiveDate} and effective_date = #{effectiveDate}
</if> </if>
<if test="expirationDate != null "> <if test="expirationDate != null ">
and a.expiration_date = #{expirationDate} and expiration_date = #{expirationDate}
</if> </if>
<if test="contractOriginalUrl != null and contractOriginalUrl != ''"> <if test="contractOriginalUrl != null and contractOriginalUrl != ''">
and a.contract_original_url = #{contractOriginalUrl} and contract_original_url = #{contractOriginalUrl}
</if> </if>
<if test="integrityAgreementUrl != null and integrityAgreementUrl != ''"> <if test="integrityAgreementUrl != null and integrityAgreementUrl != ''">
and a.integrity_agreement_url = #{integrityAgreementUrl} and integrity_agreement_url = #{integrityAgreementUrl}
</if> </if>
<if test="securityProtocolUrl != null and securityProtocolUrl != ''"> <if test="securityProtocolUrl != null and securityProtocolUrl != ''">
and a.security_protocol_url = #{securityProtocolUrl} and security_protocol_url = #{securityProtocolUrl}
</if> </if>
<if test="otherAttachmentsUrl != null and otherAttachmentsUrl != ''"> <if test="otherAttachmentsUrl != null and otherAttachmentsUrl != ''">
and a.other_attachments_url = #{otherAttachmentsUrl} and other_attachments_url = #{otherAttachmentsUrl}
</if> </if>
<if test="ourSinged != null and ourSinged != ''"> <if test="ourSinged != null and ourSinged != ''">
and a.our_singed = #{ourSinged} and our_singed = #{ourSinged}
</if> </if>
<if test="ourSingedPhone != null and ourSingedPhone != ''"> <if test="ourSingedPhone != null and ourSingedPhone != ''">
and a.our_singed_phone = #{ourSingedPhone} and our_singed_phone = #{ourSingedPhone}
</if> </if>
<if test="ourOperator != null and ourOperator != ''"> <if test="ourOperator != null and ourOperator != ''">
and a.our_operator = #{ourOperator} and our_operator = #{ourOperator}
</if> </if>
<if test="ourOperatorPhone != null and ourOperatorPhone != ''"> <if test="ourOperatorPhone != null and ourOperatorPhone != ''">
and a.our_operator_phone = #{ourOperatorPhone} and our_operator_phone = #{ourOperatorPhone}
</if> </if>
<if test="theySinged != null and theySinged != ''"> <if test="theySinged != null and theySinged != ''">
and a.they_singed = #{theySinged} and they_singed = #{theySinged}
</if> </if>
<if test="theySingedPhone != null and theySingedPhone != ''"> <if test="theySingedPhone != null and theySingedPhone != ''">
and a.they_singed_phone = #{theySingedPhone} and they_singed_phone = #{theySingedPhone}
</if> </if>
<if test="theyOperator != null and theyOperator != ''"> <if test="theyOperator != null and theyOperator != ''">
and a.they_operator = #{theyOperator} and they_operator = #{theyOperator}
</if> </if>
<if test="theyOperatorPhone != null and theyOperatorPhone != ''"> <if test="theyOperatorPhone != null and theyOperatorPhone != ''">
and a.they_operator_phone = #{theyOperatorPhone} and they_operator_phone = #{theyOperatorPhone}
</if>
<if test="firstSubjectCode != null and firstSubjectCode != ''">
and b.FIRST_SUBJECT_CODE = #{firstSubjectCode}
</if> </if>
</where> </where>
</sql> </sql>
@@ -136,72 +134,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="common_where"> <sql id="common_where">
<if test="contractManageDO.contractNumber != null and contractManageDO.contractNumber != ''"> <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>
<if test="contractManageDO.originalContractNumber != null and contractManageDO.originalContractNumber != ''"> <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>
<if test="contractManageDO.commonContractFlag != null"> <if test="contractManageDO.commonContractFlag != null">
and common_contract_flag = #{contractManageDO.commonContractFlag} and a.common_contract_flag = #{contractManageDO.commonContractFlag}
</if> </if>
<if test="contractManageDO.contractType != null"> <if test="contractManageDO.contractType != null">
and contract_type = #{contractManageDO.contractType} and a.contract_type = #{contractManageDO.contractType}
</if> </if>
<if test="contractManageDO.settlementCustomers != null and contractManageDO.settlementCustomers != '' " > <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>
<if test="contractManageDO.settlementCustomersCode != null"> <if test="contractManageDO.settlementCustomersCode != null">
and settlement_customers_code = #{contractManageDO.settlementCustomersCode} and a.settlement_customers_code = #{contractManageDO.settlementCustomersCode}
</if> </if>
<if test="contractManageDO.signingUnit != null and contractManageDO.signingUnit != ''"> <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>
<if test="contractManageDO.contractName != null and contractManageDO.contractName != ''"> <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>
<if test="contractManageDO.contractState != null"> <if test="contractManageDO.contractState != null">
and contract_state = #{contractManageDO.contractState} and a.contract_state = #{contractManageDO.contractState}
</if> </if>
<if test="contractManageDO.signingDateStart != null and contractManageDO.signingDateStart != ''"> <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>
<if test="contractManageDO.signingDateEnd != null and contractManageDO.signingDateEnd != ''"> <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>
<if test="contractManageDO.effectiveDateStart != null and contractManageDO.effectiveDateStart != ''"> <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>
<if test="contractManageDO.effectiveDateEnd != null and contractManageDO.effectiveDateEnd != ''"> <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>
<if test="contractManageDO.expirationDateStart != null and contractManageDO.expirationDateStart != ''"> <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>
<if test="contractManageDO.expirationDateEnd != null and contractManageDO.expirationDateEnd != ''"> <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>
<!-- 时间段重叠判断:只有当已有合同与传入的有效期真正有交集时才算冲突 <!-- 时间段重叠判断:只有当已有合同与传入的有效期真正有交集时才算冲突
条件:已有合同开始日期 <= 新合同结束日期 且 已有合同结束日期 >= 新合同开始日期 --> 条件:已有合同开始日期 <= 新合同结束日期 且 已有合同结束日期 >= 新合同开始日期 -->
<if test="contractManageDO.effectiveDateString != null and contractManageDO.effectiveDateString != '' <if test="contractManageDO.effectiveDateString != null and contractManageDO.effectiveDateString != ''
and contractManageDO.expirationDateString != null and contractManageDO.expirationDateString != ''"> and contractManageDO.expirationDateString != null and contractManageDO.expirationDateString != ''">
AND ( AND (
date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateString} date_format(a.effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateString}
AND date_format(expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateString} AND date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.effectiveDateString}
) )
</if> </if>
<if test="contractManageDO.nowDateString != null and contractManageDO.nowDateString != ''"> <if test="contractManageDO.nowDateString != null and contractManageDO.nowDateString != ''">
AND ( AND (
date_format(expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.nowDateString} date_format(a.expiration_date,'%Y-%m-%d') <![CDATA[>=]]> #{contractManageDO.nowDateString}
AND date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.nowDateString} AND date_format(a.effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.nowDateString}
) )
</if> </if>
<if test="contractManageDO.organizationId != null"> <if test="contractManageDO.organizationId != null">
and organization_id = #{contractManageDO.organizationId} and a.organization_id = #{contractManageDO.organizationId}
</if> </if>
<if test="contractManageDO.topOrganizationId != null"> <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> </if>
</sql> </sql>
@@ -484,7 +484,7 @@ public class BusinessDocumentApplicationService {
if(businessDocumentDO.getBelongModuleCode().equals(BelongModuleCode.WMS.getCode())){ if(businessDocumentDO.getBelongModuleCode().equals(BelongModuleCode.WMS.getCode())){
contractType = 1; 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")))) { if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("合同信息未找到"); throw new ServiceException("合同信息未找到");
} }