From 1c209385d0d9042a517e78c6becba9c3915f3062 Mon Sep 17 00:00:00 2001 From: mashuai Date: Tue, 8 Apr 2025 08:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/service/impl/BmProjectServiceImpl.java | 16 ++++++++++++++++ .../basic/service/impl/BmUnitServiceImpl.java | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmProjectServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmProjectServiceImpl.java index 5106da17..5d0e5a1f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmProjectServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmProjectServiceImpl.java @@ -14,6 +14,8 @@ import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.encryption.Sm4Utils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.basic.domain.BmAgreementInfo; +import com.bonus.material.basic.mapper.BmAgreementInfoMapper; import com.bonus.material.purchase.config.RemoteConfig; import com.bonus.system.api.RemoteDeptService; import com.bonus.system.api.domain.SysDept; @@ -21,6 +23,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bonus.material.basic.mapper.BmProjectMapper; import com.bonus.material.basic.domain.BmProject; @@ -48,6 +51,9 @@ public class BmProjectServiceImpl implements IBmProjectService @Resource private RemoteConfig remoteConfig; + @Resource + private BmAgreementInfoMapper bmAgreementInfoMapper; + /** * 查询标段工程管理 * @@ -255,6 +261,16 @@ public class BmProjectServiceImpl implements IBmProjectService @Override public AjaxResult deleteBmProjectByProId(Long proId) { + if (proId == null) { + return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg()); + } + // 根据工程id查询该工程是否已新建协议,存在则不能删除 + BmAgreementInfo bmAgreementInfo = new BmAgreementInfo(); + bmAgreementInfo.setProjectId(proId); + List list = bmAgreementInfoMapper.selectBmAgreementInfoList(bmAgreementInfo); + if (CollectionUtils.isNotEmpty(list)) { + return AjaxResult.error("该工程已新建协议,不能删除"); + } int result = bmProjectMapper.deleteBmProjectByProId(proId); if (result > 0) { return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmUnitServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmUnitServiceImpl.java index db9210aa..d0c69e95 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmUnitServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmUnitServiceImpl.java @@ -14,6 +14,8 @@ import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.utils.encryption.Sm4Utils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.basic.domain.BmAgreementInfo; +import com.bonus.material.basic.mapper.BmAgreementInfoMapper; import com.bonus.material.purchase.config.RemoteConfig; import com.bonus.system.api.RemoteDeptService; import com.bonus.system.api.domain.SysDept; @@ -47,6 +49,9 @@ public class BmUnitServiceImpl implements IBmUnitService @Resource private RemoteDeptService remoteDeptService; + @Resource + private BmAgreementInfoMapper bmAgreementInfoMapper; + /** * 查询往来单位管理 @@ -198,6 +203,16 @@ public class BmUnitServiceImpl implements IBmUnitService @Override public AjaxResult deleteBmUnitByUnitId(Long unitId) { + if (unitId == null) { + return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg()); + } + // 根据工程id查询该工程是否已新建协议,存在则不能删除 + BmAgreementInfo bmAgreementInfo = new BmAgreementInfo(); + bmAgreementInfo.setUnitId(unitId); + List list = bmAgreementInfoMapper.selectBmAgreementInfoList(bmAgreementInfo); + if (CollectionUtils.isNotEmpty(list)) { + return AjaxResult.error("该单位已新建协议,不能删除"); + } //先查看往来单位是否被绑定,绑定则不能删除 if (bmUnitMapper.countBmUnitPersonByUnitId(unitId) > 0) { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "该单位还绑定相关人员,无法删除");