BMS合同管理生效状态修改
This commit is contained in:
+27
-5
@@ -164,11 +164,25 @@ public class ContractManageApplicationService {
|
|||||||
* 处理数据
|
* 处理数据
|
||||||
*/
|
*/
|
||||||
private void handleData(ContractManageDO contractManageDO) {
|
private void handleData(ContractManageDO contractManageDO) {
|
||||||
//根据合同生效时间判断合同是否生效
|
// 如果前端未传合同状态,则根据生效/到期时间自动计算;
|
||||||
if (DateUtil.compare(contractManageDO.getEffectiveDate(), new Date()) > 0) {
|
// 如果前端已经传了 contractState,则尊重前端值
|
||||||
contractManageDO.setContractState(2);
|
if (contractManageDO.getContractState() == null) {
|
||||||
} else {
|
// 合同状态(1-未生效,2-使用中,3-已过期,4-已作废)
|
||||||
contractManageDO.setContractState(1);
|
Date now = DateUtil.beginOfDay(new Date());
|
||||||
|
Date effectiveDate = contractManageDO.getEffectiveDate();
|
||||||
|
Date expirationDate = contractManageDO.getExpirationDate();
|
||||||
|
if (effectiveDate != null && expirationDate != null) {
|
||||||
|
if (DateUtil.compare(now, effectiveDate) < 0) {
|
||||||
|
// 当前时间早于生效日期:未生效
|
||||||
|
contractManageDO.setContractState(1);
|
||||||
|
} else if (DateUtil.compare(now, expirationDate) > 0) {
|
||||||
|
// 当前时间晚于到期日期:已过期
|
||||||
|
contractManageDO.setContractState(3);
|
||||||
|
} else {
|
||||||
|
// 生效日期 <= 当前时间 <= 到期日期:使用中
|
||||||
|
contractManageDO.setContractState(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotEmpty(contractManageDO.getSettlementCustomersCode())){
|
if(StringUtils.isNotEmpty(contractManageDO.getSettlementCustomersCode())){
|
||||||
AjaxResult ajaxResult = bmsServiceFeign.getCustomersInfoByCode(contractManageDO.getSettlementCustomersCode());
|
AjaxResult ajaxResult = bmsServiceFeign.getCustomersInfoByCode(contractManageDO.getSettlementCustomersCode());
|
||||||
@@ -190,11 +204,19 @@ public class ContractManageApplicationService {
|
|||||||
* @param contractManageDO
|
* @param contractManageDO
|
||||||
*/
|
*/
|
||||||
private void checkContract(ContractManageDO contractManageDO) {
|
private void checkContract(ContractManageDO contractManageDO) {
|
||||||
|
// 通用/特殊合同的唯一性应在“同一组织”内生效,不同组织之间互不影响
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (ObjectUtil.isNull(loginUser) || loginUser.getUserPo() == null) {
|
||||||
|
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||||
|
}
|
||||||
ContractManageDO commonQueryParam = new ContractManageDO();
|
ContractManageDO commonQueryParam = new ContractManageDO();
|
||||||
commonQueryParam.setContractType(contractManageDO.getContractType());
|
commonQueryParam.setContractType(contractManageDO.getContractType());
|
||||||
commonQueryParam.setSettlementCustomersCode(contractManageDO.getSettlementCustomersCode());
|
commonQueryParam.setSettlementCustomersCode(contractManageDO.getSettlementCustomersCode());
|
||||||
commonQueryParam.setEffectiveDateString(DateUtil.format(contractManageDO.getEffectiveDate(),"yyyy-MM-dd"));
|
commonQueryParam.setEffectiveDateString(DateUtil.format(contractManageDO.getEffectiveDate(),"yyyy-MM-dd"));
|
||||||
commonQueryParam.setExpirationDateString(DateUtil.format(contractManageDO.getExpirationDate(),"yyyy-MM-dd"));
|
commonQueryParam.setExpirationDateString(DateUtil.format(contractManageDO.getExpirationDate(),"yyyy-MM-dd"));
|
||||||
|
// 按当前登录人的组织维度进行唯一性校验:不同组织下的通用/特殊合同互不影响
|
||||||
|
commonQueryParam.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||||
|
commonQueryParam.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
//通用合同
|
//通用合同
|
||||||
if(contractManageDO.getCommonContractFlag()==1){
|
if(contractManageDO.getCommonContractFlag()==1){
|
||||||
commonQueryParam.setCommonContractFlag(1);
|
commonQueryParam.setCommonContractFlag(1);
|
||||||
|
|||||||
@@ -178,11 +178,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<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(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.effectiveDateString}
|
date_format(effective_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateString}
|
||||||
OR date_format(expiration_date,'%Y-%m-%d') <![CDATA[<=]]> #{contractManageDO.expirationDateString}
|
AND date_format(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 != ''">
|
||||||
|
|||||||
Reference in New Issue
Block a user