Browse Source

修改预案指定设备的时候去掉离线的设备

修改预案新增或修改的时候,事件类型和子类不能重复
develop
Mr.Wang 8 months ago
parent
commit
a46027f512
  1. 4
      zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java
  2. 11
      zc-business/src/main/java/com/zc/business/mapper/DcEmergencyPlansMapper.java
  3. 5
      zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java
  4. 23
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java
  5. 20
      zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml

4
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);
}
/**

11
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<DcEmergencyPlans> {
/**
* 查询事件预案
@ -22,6 +23,14 @@ public interface DcEmergencyPlansMapper {
*/
List<DcEmergencyPlans> selectDcEmergencyPlansList(DcEmergencyPlans dcEmergencyPlans);
/**
* 查询事件预案
*
* @param dcEmergencyPlans 事件预案
* @return 结果
*/
List<DcEmergencyPlans> selectDcEmergencyPlansByOne(DcEmergencyPlans dcEmergencyPlans);
/**
* 根据事件id查询事件预案
*

5
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);
/**
* 批量删除事件预案

23
zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

@ -477,6 +477,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
LambdaQueryWrapper<DcDevice> 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<DcExecuteAction> 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<DcExecuteAction> 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<DcEmergencyPlans> dcEmergencyPlansList = dcEmergencyPlansMapper.selectDcEmergencyPlansByOne(dcEmergencyPlans);
return dcEmergencyPlansList.size() > 0;
}
/**

20
zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml

@ -123,6 +123,26 @@
order by t1.id desc
</select>
<select id="selectDcEmergencyPlansByOne" parameterType="DcEmergencyPlans" resultMap="DcEmergencyPlansResult">
select t1.id,
t1.plan_name,
t1.event_type,
t1.trigger_mechanism,
t1.create_time,
t1.update_time,
t1.device_type,
t1.triggering_condition,
t1.controllable_device,
t1.control_command
from dc_emergency_plans t1
<where>
<if test="eventType != 0 "> and event_type = #{eventType}</if>
<if test="triggerMechanism != null and triggerMechanism != ''">
and trigger_mechanism =#{triggerMechanism}
</if>
</where>
</select>
<select id="selectDcEmergencyPlans" parameterType="Integer" resultMap="DcEmergencyPlansResult">
<include refid="selectDcEmergencyPlansListAll"/>
where t1.id = #{id}

Loading…
Cancel
Save