diff --git a/detection/src/main/java/com/njcn/gather/err/mapper/PqErrSysMapper.java b/detection/src/main/java/com/njcn/gather/err/mapper/PqErrSysMapper.java index f9d64486..d882334e 100644 --- a/detection/src/main/java/com/njcn/gather/err/mapper/PqErrSysMapper.java +++ b/detection/src/main/java/com/njcn/gather/err/mapper/PqErrSysMapper.java @@ -2,12 +2,20 @@ package com.njcn.gather.err.mapper; import com.github.yulichang.base.MPJBaseMapper; import com.njcn.gather.err.pojo.po.PqErrSys; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @author caozehui * @date 2024-11-27 */ public interface PqErrSysMapper extends MPJBaseMapper { - + /** + * 根据ids获取绑定的计划数量 + * @param ids + * @return + */ + Integer getCountBoundByIds(@Param("ids") List ids); } diff --git a/detection/src/main/java/com/njcn/gather/err/mapper/mapping/PqErrSysMapper.xml b/detection/src/main/java/com/njcn/gather/err/mapper/mapping/PqErrSysMapper.xml index 05d7b039..feb388b9 100644 --- a/detection/src/main/java/com/njcn/gather/err/mapper/mapping/PqErrSysMapper.xml +++ b/detection/src/main/java/com/njcn/gather/err/mapper/mapping/PqErrSysMapper.xml @@ -3,5 +3,16 @@ + diff --git a/detection/src/main/java/com/njcn/gather/err/pojo/enums/ErrResponseEnum.java b/detection/src/main/java/com/njcn/gather/err/pojo/enums/ErrResponseEnum.java new file mode 100644 index 00000000..6058c322 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/err/pojo/enums/ErrResponseEnum.java @@ -0,0 +1,20 @@ +package com.njcn.gather.err.pojo.enums; + +import lombok.Getter; + +/** + * @author caozehui + * @data 2025-03-10 + */ +@Getter +public enum ErrResponseEnum { + ERR_SYS_BOUND_NOT_DELETE("A100001","误差体系已被计划所绑定,无法删除!"); + + private String code; + private String message; + + ErrResponseEnum(String code, String message) { + this.code = code; + this.message = message; + } +} diff --git a/detection/src/main/java/com/njcn/gather/err/service/impl/PqErrSysServiceImpl.java b/detection/src/main/java/com/njcn/gather/err/service/impl/PqErrSysServiceImpl.java index f4908901..aae55047 100644 --- a/detection/src/main/java/com/njcn/gather/err/service/impl/PqErrSysServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/err/service/impl/PqErrSysServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.gather.err.mapper.PqErrSysMapper; +import com.njcn.gather.err.pojo.enums.ErrResponseEnum; import com.njcn.gather.err.pojo.param.PqErrSysParam; import com.njcn.gather.err.pojo.po.PqErrSys; import com.njcn.gather.err.pojo.po.PqErrSysDtls; @@ -93,6 +94,10 @@ public class PqErrSysServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = {Exception.class}) public boolean deletePqErrSys(List ids) { + Integer count = this.baseMapper.getCountBoundByIds(ids); + if (count > 0) { + throw new BusinessException(ErrResponseEnum.ERR_SYS_BOUND_NOT_DELETE); + } pqErrSysDtlsService.deletePqErrSysDtlsByPqErrSysId(ids); this.lambdaUpdate().in(PqErrSys::getId, ids).set(PqErrSys::getState, DataStateEnum.DELETED.getCode()).update(); return true; diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index e92075ad..899c7e0b 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -510,6 +510,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme } } + /** * 获取备注信息 * diff --git a/detection/src/main/java/com/njcn/gather/script/mapper/PqScriptMapper.java b/detection/src/main/java/com/njcn/gather/script/mapper/PqScriptMapper.java index c5ff4bd5..53b6203a 100644 --- a/detection/src/main/java/com/njcn/gather/script/mapper/PqScriptMapper.java +++ b/detection/src/main/java/com/njcn/gather/script/mapper/PqScriptMapper.java @@ -4,6 +4,8 @@ import com.github.yulichang.base.MPJBaseMapper; import com.njcn.gather.script.pojo.po.PqScript; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @author caozehui * @date 2024-11-18 @@ -18,5 +20,13 @@ public interface PqScriptMapper extends MPJBaseMapper { * @Date: 2024/12/16 18:08 */ Boolean selectScriptIsValueType(@Param("scriptId") String scriptId); + + /** + * 根据脚本id获取绑定的计划数量 + * + * @param scriptIds + * @return + */ + Integer getBoundCountByScriptIds(@Param("scriptIds") List scriptIds); } diff --git a/detection/src/main/java/com/njcn/gather/script/mapper/mapping/PqScriptMapper.xml b/detection/src/main/java/com/njcn/gather/script/mapper/mapping/PqScriptMapper.xml index fb2050b5..1003935c 100644 --- a/detection/src/main/java/com/njcn/gather/script/mapper/mapping/PqScriptMapper.xml +++ b/detection/src/main/java/com/njcn/gather/script/mapper/mapping/PqScriptMapper.xml @@ -12,5 +12,16 @@ State=1 and Id = #{scriptId} + diff --git a/detection/src/main/java/com/njcn/gather/script/pojo/enums/ScriptResponseEnum.java b/detection/src/main/java/com/njcn/gather/script/pojo/enums/ScriptResponseEnum.java new file mode 100644 index 00000000..e5effde6 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/script/pojo/enums/ScriptResponseEnum.java @@ -0,0 +1,20 @@ +package com.njcn.gather.script.pojo.enums; + +import lombok.Getter; + +/** + * @author caozehui + * @data 2025-03-10 + */ +@Getter +public enum ScriptResponseEnum { + SCRIPT_BOUND_NOT_DELETE("A020001", "脚本已被计划所绑定,无法删除!"); + + private String code; + private String message; + + ScriptResponseEnum(String code, String message) { + this.code = code; + this.message = message; + } +} diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptServiceImpl.java index ebcf2f93..8b1cc53f 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptServiceImpl.java @@ -7,7 +7,11 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.gather.plan.pojo.po.AdPlan; +import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.script.mapper.PqScriptMapper; +import com.njcn.gather.script.pojo.enums.ScriptResponseEnum; import com.njcn.gather.script.pojo.param.PqScriptParam; import com.njcn.gather.script.pojo.po.PqScript; import com.njcn.gather.script.service.IPqScriptDtlsService; @@ -77,6 +81,10 @@ public class PqScriptServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = {Exception.class}) public boolean deletePqScript(List ids) { + Integer count = this.baseMapper.getBoundCountByScriptIds(ids); + if (count > 0) { + throw new BusinessException(ScriptResponseEnum.SCRIPT_BOUND_NOT_DELETE); + } //删除对应的脚本详情 pqScriptDtlsService.deletePqScriptDtlsByScriptId(ids); LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); diff --git a/detection/src/main/java/com/njcn/gather/source/mapper/PqSourceMapper.java b/detection/src/main/java/com/njcn/gather/source/mapper/PqSourceMapper.java index 8472c18c..fb9edb69 100644 --- a/detection/src/main/java/com/njcn/gather/source/mapper/PqSourceMapper.java +++ b/detection/src/main/java/com/njcn/gather/source/mapper/PqSourceMapper.java @@ -2,6 +2,9 @@ package com.njcn.gather.source.mapper; import com.github.yulichang.base.MPJBaseMapper; import com.njcn.gather.source.pojo.po.PqSource; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @author caozehui @@ -9,5 +12,12 @@ import com.njcn.gather.source.pojo.po.PqSource; */ public interface PqSourceMapper extends MPJBaseMapper { + /** + * 根据ids获取绑定的计划数量 + * + * @param ids + * @return + */ + Integer getCountBoundByIds(@Param("ids") List ids); } diff --git a/detection/src/main/java/com/njcn/gather/source/mapper/mapping/PqSourceMapper.xml b/detection/src/main/java/com/njcn/gather/source/mapper/mapping/PqSourceMapper.xml index 29e91a51..51effd3f 100644 --- a/detection/src/main/java/com/njcn/gather/source/mapper/mapping/PqSourceMapper.xml +++ b/detection/src/main/java/com/njcn/gather/source/mapper/mapping/PqSourceMapper.xml @@ -3,5 +3,16 @@ + diff --git a/detection/src/main/java/com/njcn/gather/source/pojo/enums/SourceResponseEnum.java b/detection/src/main/java/com/njcn/gather/source/pojo/enums/SourceResponseEnum.java new file mode 100644 index 00000000..16dd50a9 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/source/pojo/enums/SourceResponseEnum.java @@ -0,0 +1,20 @@ +package com.njcn.gather.source.pojo.enums; + +import lombok.Getter; + +/** + * @author caozehui + * @data 2025-03-10 + */ +@Getter +public enum SourceResponseEnum { + SOURCE_BOUND_NOT_DELETE("A030001", "源已被计划所绑定,无法删除!"); + + private String code; + private String message; + + SourceResponseEnum(String code, String message) { + this.code = code; + this.message = message; + } +} diff --git a/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java b/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java index 45d8bfe3..c30724c7 100644 --- a/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java @@ -13,6 +13,7 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.gather.device.pojo.enums.CommonEnum; import com.njcn.gather.device.pojo.enums.DevResponseEnum; import com.njcn.gather.source.mapper.PqSourceMapper; +import com.njcn.gather.source.pojo.enums.SourceResponseEnum; import com.njcn.gather.source.pojo.param.PqSourceParam; import com.njcn.gather.source.pojo.po.PqSource; import com.njcn.gather.source.pojo.po.SourceInitialize; @@ -85,6 +86,10 @@ public class PqSourceServiceImpl extends ServiceImpl i @Override @Transactional(rollbackFor = {Exception.class}) public boolean deletePqSource(List ids) { + Integer count = this.baseMapper.getCountBoundByIds(ids); + if(count > 0){ + throw new BusinessException(SourceResponseEnum.SOURCE_BOUND_NOT_DELETE); + } return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update(); }