diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/BmAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/BmAgreementInfoController.java index e625acd5..4845406d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/BmAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/BmAgreementInfoController.java @@ -114,9 +114,9 @@ public class BmAgreementInfoController extends BaseController @PreventRepeatSubmit //@RequiresPermissions("basic:info:remove") @SysLog(title = "协议管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除协议管理") - @DeleteMapping("/{agreementIds}") - public AjaxResult remove(@PathVariable Long[] agreementIds) + @DeleteMapping("/{agreementId}") + public AjaxResult remove(@PathVariable("agreementId") Long agreementId) { - return toAjax(bmAgreementInfoService.deleteBmAgreementInfoByAgreementIds(agreementIds)); + return toAjax(bmAgreementInfoService.deleteBmAgreementInfoByAgreementId(agreementId)); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/BmAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/BmAgreementInfoMapper.java index 2670b4be..280e11d0 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/BmAgreementInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/BmAgreementInfoMapper.java @@ -63,4 +63,11 @@ public interface BmAgreementInfoMapper public int selectNumByMonth(Date nowDate); String getProtocol(String agreementId); + + /** + * 根据协议id查询协议信息 + * @param agreementId + * @return + */ + int selectByagreementId(Long agreementId); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmAgreementInfoServiceImpl.java index 1aa007cf..472b629a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmAgreementInfoServiceImpl.java @@ -124,6 +124,17 @@ public class BmAgreementInfoServiceImpl implements IBmAgreementInfoService @Override public AjaxResult updateBmAgreementInfo(BmAgreementInfo bmAgreementInfo) { + // 根据unitId和projectId判断,修改的单位和工程是否已经关联协议 + BmAgreementInfo agreementInfo = new BmAgreementInfo(); + agreementInfo.setUnitId(bmAgreementInfo.getUnitId()); + agreementInfo.setProjectId(bmAgreementInfo.getProjectId()); + List list = bmAgreementInfoMapper.selectBmAgreementInfoList(agreementInfo); + if (!CollectionUtils.isEmpty(list)) { + BmAgreementInfo info = list.get(0); + if (info != null && info.getAgreementId() != null && !info.getAgreementId().equals(bmAgreementInfo.getAgreementId())) { + return AjaxResult.error("该单位和工程已关联协议,请勿重复创建!"); + } + } bmAgreementInfo.setUpdateTime(DateUtils.getNowDate()); int count = bmAgreementInfoMapper.updateBmAgreementInfo(bmAgreementInfo); if (count > 0) { @@ -168,6 +179,12 @@ public class BmAgreementInfoServiceImpl implements IBmAgreementInfoService @Override public int deleteBmAgreementInfoByAgreementId(Long agreementId) { - return bmAgreementInfoMapper.deleteBmAgreementInfoByAgreementId(agreementId); + //查询该协议是否存在领料任务,有的话不能删除 + int res = bmAgreementInfoMapper.selectByagreementId(agreementId); + if (res > 0) { + throw new ServiceException("该协议存在领料任务,不能删除"); + } else { + return bmAgreementInfoMapper.deleteBmAgreementInfoByAgreementId(agreementId); + } } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmUnitPersonServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmUnitPersonServiceImpl.java index 317fddff..0fa74d2b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmUnitPersonServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmUnitPersonServiceImpl.java @@ -4,6 +4,8 @@ import com.alibaba.nacos.common.utils.CollectionUtils; import com.bonus.common.biz.enums.HttpCodeEnum; import com.bonus.common.core.constant.SecurityConstants; import com.bonus.common.core.utils.DateUtils; +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.material.basic.domain.BmUnit; import com.bonus.material.basic.mapper.BmUnitMapper; @@ -150,6 +152,9 @@ public class BmUnitPersonServiceImpl implements IBmUnitPersonService if (unit.getTypeId() != null) { unit.setTypeName(labelMap.get(unit.getTypeId().toString()) == null ? "" : labelMap.get(unit.getTypeId().toString())); } + if (StringUtils.isNotBlank(unit.getTelphone())) { + unit.setTelphone(Sm4Utils.decrypt(unit.getTelphone())); + } AjaxResult ajaxResult = remoteDeptService.getInfo(unit.getDeptId(), SecurityConstants.INNER); //健壮性判断 if (ajaxResult.isSuccess()) { 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 f84c525f..db9210aa 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 @@ -125,15 +125,13 @@ public class BmUnitServiceImpl implements IBmUnitService if (unit != null) { return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), HttpCodeEnum.NAME_DUPLICATE.getMsg()); } + //判断手机号是否合法 + if (StringUtils.isNotBlank(bmUnit.getTelphone()) && !PhoneUtil.isMobile(bmUnit.getTelphone())) { + return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_FORMAT.getMsg()); + } if (StringUtils.isNotBlank(bmUnit.getTelphone())) { String telPhone = Sm4Utils.encrypt(bmUnit.getTelphone()); bmUnit.setTelphone(telPhone); - } else { - return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_FORMAT.getMsg()); - } - //判断手机号是否合法 - if (!PhoneUtil.isMobile(bmUnit.getTelphone())) { - return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_FORMAT.getMsg()); } bmUnit.setCreateTime(DateUtils.getNowDate()); bmUnit.setCreateBy(SecurityUtils.getUserId().toString()); diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmAgreementInfoMapper.xml index 17e04d9f..4c0ca091 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmAgreementInfoMapper.xml @@ -133,4 +133,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from bm_agreement_info where agreement_id = #{agreementId} + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmUnitPersonMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmUnitPersonMapper.xml index e81bce61..093340f5 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmUnitPersonMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmUnitPersonMapper.xml @@ -53,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" group by bu.unit_id + order by bu.create_time desc