唐耀东
2022-10-12 d1bcbbefab4da603c275ed61d0018a46dbc67d1e
ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/SgIpcServiceImpl.java
@@ -19,6 +19,7 @@
import com.ruoyi.oa.domain.SgIpc;
import com.ruoyi.oa.mapper.SgIpcMapper;
import com.ruoyi.oa.service.ISgIpcService;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@@ -61,19 +62,23 @@
        lqw.eq(bo.getOrganizationId() != null, SgIpc::getOrganizationId, bo.getOrganizationId());
        lqw.eq(bo.getConstructionBatchId() != null, SgIpc::getConstructionBatchId, bo.getConstructionBatchId());
        lqw.like(StringUtils.isNotBlank(bo.getModel()), SgIpc::getModel, bo.getModel());
        lqw.orderByDesc(SgIpc::getUpdateTime);
        return lqw;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean insertByBo(SgIpcBo bo) {
        List<SgIpc> list = baseMapper.selectList(new LambdaQueryWrapper<SgIpc>()
            .eq(SgIpc::getSchoolId, bo.getSchoolId()).eq(SgIpc::getMac, bo.getMac()));
        if (list.size() > 0) {
            throw new ServiceException("MAC重复", HttpStatus.HTTP_PARTIAL);
        }
        SgNvr nvr = nvrMapper.selectById(bo.getNvrId());
        if (!bo.getOrganizationId().equals(nvr.getOrganizationId())) {
            throw new ServiceException("IPC所属单位与所选NVR所属单位不符", HttpStatus.HTTP_PARTIAL);
        if (null != bo.getNvrId()) {
            SgNvr nvr = nvrMapper.selectById(bo.getNvrId());
            if (!bo.getOrganizationId().equals(nvr.getOrganizationId())) {
                throw new ServiceException("IPC所属单位与所选NVR所属单位不符", HttpStatus.HTTP_PARTIAL);
            }
        }
        SgIpc add = BeanUtil.toBean(bo, SgIpc.class);
        validEntityBeforeSave(add);
@@ -85,6 +90,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateByBo(SgIpcBo bo) {
        List<SgIpc> list = baseMapper.selectList(new LambdaQueryWrapper<SgIpc>()
            .eq(SgIpc::getSchoolId, bo.getSchoolId())
@@ -93,9 +99,11 @@
        if (list.size() > 0) {
            throw new ServiceException("MAC重复", HttpStatus.HTTP_PARTIAL);
        }
        SgNvr nvr = nvrMapper.selectById(bo.getNvrId());
        if (!bo.getOrganizationId().equals(nvr.getOrganizationId())) {
            throw new ServiceException("IPC所属单位与所选NVR所属单位不符", HttpStatus.HTTP_PARTIAL);
        if (null != bo.getNvrId()) {
            SgNvr nvr = nvrMapper.selectById(bo.getNvrId());
            if (!bo.getOrganizationId().equals(nvr.getOrganizationId())) {
                throw new ServiceException("IPC所属单位与所选NVR所属单位不符", HttpStatus.HTTP_PARTIAL);
            }
        }
        SgIpc update = BeanUtil.toBean(bo, SgIpc.class);
        validEntityBeforeSave(update);
@@ -112,6 +120,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
        if (isValid) {
            //TODO 做一些业务上的校验,判断是否需要校验