From a46027f5128b5916dfab636774872bbfef9fb8b9 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Fri, 26 Jul 2024 11:53:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=84=E6=A1=88=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E8=AE=BE=E5=A4=87=E7=9A=84=E6=97=B6=E5=80=99=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E7=A6=BB=E7=BA=BF=E7=9A=84=E8=AE=BE=E5=A4=87=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=84=E6=A1=88=E6=96=B0=E5=A2=9E=E6=88=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E7=B1=BB=E5=9E=8B=E5=92=8C=E5=AD=90=E7=B1=BB=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcEmergencyPlansController.java | 4 ++-- .../mapper/DcEmergencyPlansMapper.java | 11 ++++++++- .../service/DcEmergencyPlansService.java | 5 ++-- .../impl/DcEmergencyPlansServiceImpl.java | 23 +++++++++++++++---- .../business/DcEmergencyPlansMapper.xml | 20 ++++++++++++++++ 5 files changed, 54 insertions(+), 9 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java b/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java index ff87b615..cec418cb 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java @@ -113,7 +113,7 @@ public class DcEmergencyPlansController extends BaseController { //@PreAuthorize("@ss.hasPermi('business:plans:add')") @PostMapping public AjaxResult add(@RequestBody DcEmergencyPlans dcEmergencyPlans) { - return toAjax(dcEmergencyPlansService.insertDcEmergencyPlans(dcEmergencyPlans)); + return dcEmergencyPlansService.insertDcEmergencyPlans(dcEmergencyPlans); } /** @@ -123,7 +123,7 @@ public class DcEmergencyPlansController extends BaseController { // @PreAuthorize("@ss.hasPermi('business:plans:edit')") @PutMapping public AjaxResult update(@RequestBody DcEmergencyPlans dcEmergencyPlans) { - return toAjax(dcEmergencyPlansService.updateDcEmergencyPlans(dcEmergencyPlans)); + return dcEmergencyPlansService.updateDcEmergencyPlans(dcEmergencyPlans); } /** diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcEmergencyPlansMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcEmergencyPlansMapper.java index c753344a..043ffe70 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcEmergencyPlansMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcEmergencyPlansMapper.java @@ -1,6 +1,7 @@ package com.zc.business.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zc.business.domain.DcEmergencyPlans; import com.zc.business.domain.DcEvent; @@ -12,7 +13,7 @@ import java.util.List; * @author wangjiabao * @date 2024-02-21 */ -public interface DcEmergencyPlansMapper { +public interface DcEmergencyPlansMapper extends BaseMapper { /** * 查询事件预案 @@ -22,6 +23,14 @@ public interface DcEmergencyPlansMapper { */ List selectDcEmergencyPlansList(DcEmergencyPlans dcEmergencyPlans); + /** + * 查询事件预案 + * + * @param dcEmergencyPlans 事件预案 + * @return 结果 + */ + List selectDcEmergencyPlansByOne(DcEmergencyPlans dcEmergencyPlans); + /** * 根据事件id查询事件预案 * diff --git a/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java b/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java index 0d41cf45..0bbfcf89 100644 --- a/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java +++ b/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java @@ -1,6 +1,7 @@ package com.zc.business.service; import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.domain.AjaxResult; import com.zc.business.domain.*; import java.util.List; @@ -96,7 +97,7 @@ public interface DcEmergencyPlansService { * @param dcEmergencyPlans 事件预案 * @return 结果 */ - int insertDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); + AjaxResult insertDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); /** * 修改事件预案 @@ -104,7 +105,7 @@ public interface DcEmergencyPlansService { * @param dcEmergencyPlans 事件预案 * @return 结果 */ - int updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); + AjaxResult updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); /** * 批量删除事件预案 diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java index b413ec06..79006390 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java @@ -477,6 +477,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); if (StringUtils.isNotEmpty(dcExecuteAction.getDeviceList())) { String[] deviceList = dcExecuteAction.getDeviceList().split(UniversalEnum.COMMA.getValue()); + queryWrapper.eq(DcDevice::getDeviceState,UniversalEnum.ONE.getValue()); queryWrapper.in(DcDevice::getIotDeviceId, deviceList); dcDevices = dcDeviceService.list(queryWrapper); } @@ -1331,7 +1332,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { */ @Transactional(rollbackFor = Exception.class) @Override - public int insertDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans) { + public AjaxResult insertDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans) { + if (parityBit(dcEmergencyPlans)) { + return AjaxResult.error("存在相同类型的预案"); + } dcEmergencyPlans.setCreateTime(DateUtils.getNowDate()); List dcExecuteActionList = dataProcessing(dcEmergencyPlans); // 插入事件预案表数据 @@ -1339,7 +1343,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { dcExecuteActionList.forEach(dcExecuteAction -> dcExecuteAction.setEmergencyPlansId(dcEmergencyPlans.getId())); // 插入执行操作表数据 dcExecuteActionList.forEach(dcExecuteAction -> dcExecuteAction.setCreateTime(DateUtils.getNowDate())); - return dcExecuteActionService.insertDcExecuteActionBatch(dcExecuteActionList); + return AjaxResult.success(dcExecuteActionService.insertDcExecuteActionBatch(dcExecuteActionList)); } /** @@ -1350,7 +1354,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { */ @Transactional(rollbackFor = Exception.class) @Override - public int updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans) { + public AjaxResult updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans) { + if (parityBit(dcEmergencyPlans)) { + return AjaxResult.error("存在相同类型的预案"); + } dcEmergencyPlans.setUpdateTime(DateUtils.getNowDate()); List dcExecuteActionList = dataProcessing(dcEmergencyPlans); // 修改执行操作表数据 @@ -1391,7 +1398,15 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } // 修改事件预案表数据 - return dcEmergencyPlansMapper.updateDcEmergencyPlans(dcEmergencyPlans); + return AjaxResult.success(dcEmergencyPlansMapper.updateDcEmergencyPlans(dcEmergencyPlans)); + } + + /** + * 校验类型、子类不重复 + */ + public boolean parityBit(DcEmergencyPlans dcEmergencyPlans) { + List dcEmergencyPlansList = dcEmergencyPlansMapper.selectDcEmergencyPlansByOne(dcEmergencyPlans); + return dcEmergencyPlansList.size() > 0; } /** diff --git a/zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml b/zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml index d18eb453..3a761c2e 100644 --- a/zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml @@ -123,6 +123,26 @@ order by t1.id desc + +