12 changed files with 1235 additions and 0 deletions
@ -0,0 +1,108 @@ |
|||||
|
package com.zc.business.controller; |
||||
|
|
||||
|
import com.ruoyi.common.core.controller.BaseController; |
||||
|
import com.ruoyi.common.core.domain.AjaxResult; |
||||
|
import com.ruoyi.common.core.page.TableDataInfo; |
||||
|
import com.zc.business.domain.DcEmergencyPlans; |
||||
|
import com.zc.business.domain.DcEvent; |
||||
|
import com.zc.business.service.DcEmergencyPlansService; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import io.swagger.annotations.ApiParam; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 事件预案Controller |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-02-21 |
||||
|
*/ |
||||
|
@Api(tags = "事件预案") |
||||
|
@RestController |
||||
|
@RequestMapping("/business/plans") |
||||
|
public class DcEmergencyPlansController extends BaseController { |
||||
|
|
||||
|
@Autowired |
||||
|
private DcEmergencyPlansService dcEmergencyPlansService; |
||||
|
|
||||
|
/** |
||||
|
* 查询事件预案列表 |
||||
|
*/ |
||||
|
@ApiOperation("查询事件预案列表") |
||||
|
@PreAuthorize("@ss.hasPermi('business:plans:list')") |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo list(DcEmergencyPlans dcEmergencyPlans) { |
||||
|
startPage(); |
||||
|
List<DcEmergencyPlans> list = dcEmergencyPlansService.selectDcEmergencyPlansList(dcEmergencyPlans); |
||||
|
return getDataTable(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据事件预案id查询事件预案列表 |
||||
|
*/ |
||||
|
@ApiOperation("根据事件预案id查询事件预案列表") |
||||
|
@PreAuthorize("@ss.hasPermi('business:plans:list')") |
||||
|
@GetMapping("/list/{id}") |
||||
|
public AjaxResult list(@PathVariable @ApiParam(name = "id", value = "事件预案id", required = true) Integer id) { |
||||
|
|
||||
|
DcEmergencyPlans dcEmergencyPlans = dcEmergencyPlansService.selectDcEmergencyPlans(id); |
||||
|
return AjaxResult.success(dcEmergencyPlans); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据事件数据查询事件预案列表 |
||||
|
*/ |
||||
|
@ApiOperation("根据事件数据查询事件预案列表") |
||||
|
@PreAuthorize("@ss.hasPermi('business:plans:list')") |
||||
|
@PostMapping("/list/event/type") |
||||
|
public AjaxResult listByEventType(@RequestBody DcEvent dcEvent) { |
||||
|
|
||||
|
List<DcEmergencyPlans> dcEmergencyPlansList = dcEmergencyPlansService.selectDcEmergencyPlansByEventType(dcEvent); |
||||
|
return AjaxResult.success(dcEmergencyPlansList); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增事件预案 |
||||
|
*/ |
||||
|
@ApiOperation("新增预案") |
||||
|
@PreAuthorize("@ss.hasPermi('business:plans:add')") |
||||
|
@PostMapping |
||||
|
public AjaxResult add(@RequestBody DcEmergencyPlans dcEmergencyPlans) { |
||||
|
return toAjax(dcEmergencyPlansService.insertDcEmergencyPlans(dcEmergencyPlans)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改事件预案 |
||||
|
*/ |
||||
|
@ApiOperation("修改预案") |
||||
|
@PreAuthorize("@ss.hasPermi('business:plans:edit')") |
||||
|
@PutMapping |
||||
|
public AjaxResult update(@RequestBody DcEmergencyPlans dcEmergencyPlans) { |
||||
|
return toAjax(dcEmergencyPlansService.updateDcEmergencyPlans(dcEmergencyPlans)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量修改事件预案 |
||||
|
*/ |
||||
|
// @ApiOperation("修改预案")
|
||||
|
// @PreAuthorize("@ss.hasPermi('business:plans:edit')")
|
||||
|
// @Log(title = "事件预案", businessType = BusinessType.UPDATE)
|
||||
|
@PutMapping("/batch") |
||||
|
public AjaxResult updateBatch(@RequestBody List<DcEmergencyPlans> dcEmergencyPlansList) { |
||||
|
return toAjax(dcEmergencyPlansService.updateBatchDcEmergencyPlans(dcEmergencyPlansList)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量删除事件预案 |
||||
|
*/ |
||||
|
@ApiOperation("批量删除预案") |
||||
|
@PreAuthorize("@ss.hasPermi('business:plans:remove')") |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public AjaxResult update(@PathVariable String[] ids) { |
||||
|
return toAjax(dcEmergencyPlansService.deleteDcEmergencyPlans(ids)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,85 @@ |
|||||
|
package com.zc.business.domain; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 事件预案对象 dc_emergency_plans |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-02-21 |
||||
|
*/ |
||||
|
|
||||
|
@ApiModel("事件预案实体") |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
public class DcEmergencyPlans { |
||||
|
|
||||
|
/** |
||||
|
* 事件预案编号 |
||||
|
*/ |
||||
|
@ApiModelProperty("事件预案编号") |
||||
|
private Integer id; |
||||
|
|
||||
|
/** |
||||
|
* 预案名称 |
||||
|
*/ |
||||
|
@ApiModelProperty("预案名称") |
||||
|
private String planName; |
||||
|
|
||||
|
/** |
||||
|
* 事件类型 |
||||
|
*/ |
||||
|
@ApiModelProperty("事件类型") |
||||
|
private int eventType; |
||||
|
|
||||
|
/** |
||||
|
* 触发机制 |
||||
|
*/ |
||||
|
@ApiModelProperty("触发机制") |
||||
|
private String triggerMechanism; |
||||
|
|
||||
|
@ApiModelProperty("创建时间") |
||||
|
private Date createTime; |
||||
|
@ApiModelProperty("修改时间") |
||||
|
private Date updateTime; |
||||
|
|
||||
|
/** |
||||
|
* 设备类型 |
||||
|
*/ |
||||
|
@ApiModelProperty("设备类型") |
||||
|
private String deviceType; |
||||
|
|
||||
|
/** |
||||
|
* 触发条件 |
||||
|
*/ |
||||
|
@ApiModelProperty("触发条件") |
||||
|
private String triggeringCondition; |
||||
|
|
||||
|
/** |
||||
|
* 可控设备 |
||||
|
*/ |
||||
|
@ApiModelProperty("可控设备") |
||||
|
private String controllableDevice; |
||||
|
|
||||
|
/** |
||||
|
* 控制指令 |
||||
|
*/ |
||||
|
@ApiModelProperty("控制指令") |
||||
|
private String controlCommand; |
||||
|
|
||||
|
/** |
||||
|
* 执行操作 |
||||
|
*/ |
||||
|
@ApiModelProperty("执行操作") |
||||
|
private List<DcExecuteAction> dcExecuteAction; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,79 @@ |
|||||
|
package com.zc.business.domain; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 执行操作对象 dc_execute_action |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-02-21 |
||||
|
*/ |
||||
|
|
||||
|
@ApiModel("执行操作实体") |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
public class DcExecuteAction{ |
||||
|
|
||||
|
/** |
||||
|
* 执行操作编号 |
||||
|
*/ |
||||
|
@ApiModelProperty("执行操作编号") |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 所属预案 |
||||
|
*/ |
||||
|
@ApiModelProperty("所属预案") |
||||
|
private Integer emergencyPlansId; |
||||
|
|
||||
|
/** |
||||
|
* 设备类型 |
||||
|
*/ |
||||
|
@ApiModelProperty("设备类型") |
||||
|
private int deviceType; |
||||
|
|
||||
|
/** |
||||
|
* 操作类型 |
||||
|
*/ |
||||
|
@ApiModelProperty("操作类型") |
||||
|
private int actionType; |
||||
|
|
||||
|
@ApiModelProperty("创建时间") |
||||
|
private Date createTime; |
||||
|
@ApiModelProperty("修改时间") |
||||
|
private Date updateTime; |
||||
|
|
||||
|
/** |
||||
|
* 检索规则条件 |
||||
|
*/ |
||||
|
@ApiModelProperty("检索规则条件") |
||||
|
private int searchRule; |
||||
|
|
||||
|
/** |
||||
|
* 个数/里程 |
||||
|
*/ |
||||
|
@ApiModelProperty("个数/里程") |
||||
|
private Integer number; |
||||
|
|
||||
|
/** |
||||
|
* 设备列表 |
||||
|
*/ |
||||
|
@ApiModelProperty("设备列表") |
||||
|
private String deviceList; |
||||
|
|
||||
|
/** |
||||
|
* 其他配置 |
||||
|
*/ |
||||
|
@ApiModelProperty("其他配置") |
||||
|
private String otherConfig; |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,38 @@ |
|||||
|
package com.zc.business.enums; |
||||
|
|
||||
|
/** |
||||
|
* 事件类型 |
||||
|
* @author wangjiabao |
||||
|
*/ |
||||
|
public enum EventTypeEnum { |
||||
|
|
||||
|
TRAFFIC_ACCIDENT(1, "交通事故"), |
||||
|
VEHICLE_MALFUNCTION(2, "车辆故障"), |
||||
|
TRAFFIC_CONTROL(3, "交通管制"), |
||||
|
TRAFFIC_JAM(4, "交通拥堵"), |
||||
|
ILLEGAL_ROAD_USE(5, "非法上路"), |
||||
|
ROADBLOCK_CLEARANCE(6, "路障清除"), |
||||
|
CONSTRUCTION_AND_CONSTRUCTION(7, "施工建设"), |
||||
|
SERVICE_AREA_ABNORMALITY(8, "服务区异常"), |
||||
|
EQUIPMENT_HAZARDS(9, "设施设备隐患"), |
||||
|
ABNORMAL_WEATHER(10, "异常天气"), |
||||
|
OTHER_EVENTS(11, "其他事件"); |
||||
|
private final int code; |
||||
|
private final String info; |
||||
|
|
||||
|
EventTypeEnum(int code, String info) |
||||
|
{ |
||||
|
this.code = code; |
||||
|
this.info = info; |
||||
|
} |
||||
|
|
||||
|
public int getCode() |
||||
|
{ |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
public String getInfo() |
||||
|
{ |
||||
|
return info; |
||||
|
} |
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
package com.zc.business.mapper; |
||||
|
|
||||
|
|
||||
|
import com.zc.business.domain.DcEmergencyPlans; |
||||
|
import com.zc.business.domain.DcEvent; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 事件预案Mapper接口 |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-02-21 |
||||
|
*/ |
||||
|
public interface DcEmergencyPlansMapper { |
||||
|
|
||||
|
/** |
||||
|
* 查询事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
List<DcEmergencyPlans> selectDcEmergencyPlansList(DcEmergencyPlans dcEmergencyPlans); |
||||
|
|
||||
|
/** |
||||
|
* 根据事件id查询事件预案 |
||||
|
* |
||||
|
* @param id 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
DcEmergencyPlans selectDcEmergencyPlans(Integer id); |
||||
|
|
||||
|
/** |
||||
|
* 根据事件类型查询事件预案 |
||||
|
* |
||||
|
* @param event 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
List<DcEmergencyPlans> selectDcEmergencyPlansByEventType(DcEvent event); |
||||
|
|
||||
|
/** |
||||
|
* 新增事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int insertDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); |
||||
|
|
||||
|
/** |
||||
|
* 修改事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除事件预案 |
||||
|
* |
||||
|
* @param ids 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int deleteDcEmergencyPlans(String[] ids); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
@ -0,0 +1,60 @@ |
|||||
|
package com.zc.business.mapper; |
||||
|
|
||||
|
|
||||
|
import com.zc.business.domain.DcExecuteAction; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 执行操作Mapper接口 |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-02-21 |
||||
|
*/ |
||||
|
public interface DcExecuteActionMapper { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 批量新增执行操作 |
||||
|
* |
||||
|
* @param dcExecuteActionList 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int insertDcExecuteActionBatch(List<DcExecuteAction> dcExecuteActionList); |
||||
|
|
||||
|
/** |
||||
|
* 批量修改执行操作 |
||||
|
* |
||||
|
* @param dcExecuteActionList 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int updateDcExecuteActionBatch(List<DcExecuteAction> dcExecuteActionList); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除执行操作 |
||||
|
* |
||||
|
* @param ids 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int deleteDcExecuteActionByEmergencyPlansId(String[] ids); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除执行操作 |
||||
|
* |
||||
|
* @param ids 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int deleteDcExecuteAction(List<String> ids); |
||||
|
|
||||
|
/** |
||||
|
* 根据事件预案id查询执行操作 |
||||
|
* |
||||
|
* @param emergencyPlansId 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
List<String> selectDcExecuteActionByEmergencyPlansId(String emergencyPlansId); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
@ -0,0 +1,72 @@ |
|||||
|
package com.zc.business.service; |
||||
|
|
||||
|
import com.zc.business.domain.DcEmergencyPlans; |
||||
|
import com.zc.business.domain.DcEvent; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 事件预案Service接口 |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-02-21 |
||||
|
*/ |
||||
|
public interface DcEmergencyPlansService { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 查询事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
List<DcEmergencyPlans> selectDcEmergencyPlansList(DcEmergencyPlans dcEmergencyPlans); |
||||
|
|
||||
|
/** |
||||
|
* 根据事件id查询事件预案 |
||||
|
* |
||||
|
* @param id 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
DcEmergencyPlans selectDcEmergencyPlans(Integer id); |
||||
|
|
||||
|
/** |
||||
|
* 根据事件类型查询事件预案 |
||||
|
* |
||||
|
* @param event 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
List<DcEmergencyPlans> selectDcEmergencyPlansByEventType(DcEvent event); |
||||
|
|
||||
|
/** |
||||
|
* 新增事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int insertDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); |
||||
|
|
||||
|
/** |
||||
|
* 修改事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); |
||||
|
|
||||
|
/** |
||||
|
* 批量修改事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlansList 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int updateBatchDcEmergencyPlans(List<DcEmergencyPlans> dcEmergencyPlansList); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除事件预案 |
||||
|
* |
||||
|
* @param ids 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int deleteDcEmergencyPlans(String[] ids); |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
package com.zc.business.service; |
||||
|
|
||||
|
import com.zc.business.domain.DcExecuteAction; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 执行操作Service接口 |
||||
|
* |
||||
|
* @author wangjiabao |
||||
|
* @date 2024-02-21 |
||||
|
*/ |
||||
|
public interface DcExecuteActionService { |
||||
|
|
||||
|
/** |
||||
|
* 批量新增执行操作 |
||||
|
* |
||||
|
* @param dcExecuteActionList 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int insertDcExecuteActionBatch(List<DcExecuteAction> dcExecuteActionList); |
||||
|
|
||||
|
/** |
||||
|
* 批量修改执行操作 |
||||
|
* |
||||
|
* @param dcExecuteActionList 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int updateDcExecuteActionBatch(List<DcExecuteAction> dcExecuteActionList); |
||||
|
|
||||
|
/** |
||||
|
* 根据事件预案id批量删除执行操作 |
||||
|
* |
||||
|
* @param ids 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int deleteDcExecuteActionByEmergencyPlansId(String[] ids); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除执行操作 |
||||
|
* |
||||
|
* @param ids 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
int deleteDcExecuteAction(List<String> ids); |
||||
|
|
||||
|
/** |
||||
|
* 根据事件预案id查询执行操作 |
||||
|
* |
||||
|
* @param emergencyPlansId 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
List<String> selectDcExecuteActionByEmergencyPlansId(String emergencyPlansId); |
||||
|
} |
@ -0,0 +1,359 @@ |
|||||
|
package com.zc.business.service.impl; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.fasterxml.jackson.core.type.TypeReference; |
||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
|
import com.ruoyi.common.utils.DateUtils; |
||||
|
import com.zc.business.domain.*; |
||||
|
import com.zc.business.enums.EventTypeEnum; |
||||
|
import com.zc.business.mapper.DcEmergencyPlansMapper; |
||||
|
import com.zc.business.service.DcEmergencyPlansService; |
||||
|
import com.zc.business.service.DcExecuteActionService; |
||||
|
import org.apache.commons.lang3.StringEscapeUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import javax.script.ScriptEngine; |
||||
|
import javax.script.ScriptEngineManager; |
||||
|
import javax.script.ScriptException; |
||||
|
import java.util.*; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
@Service |
||||
|
public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
||||
|
|
||||
|
@Resource |
||||
|
private DcEmergencyPlansMapper dcEmergencyPlansMapper; |
||||
|
@Resource |
||||
|
private DcExecuteActionService dcExecuteActionService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 查询事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<DcEmergencyPlans> selectDcEmergencyPlansList(DcEmergencyPlans dcEmergencyPlans) { |
||||
|
return dcEmergencyPlansMapper.selectDcEmergencyPlansList(dcEmergencyPlans); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据事件id查询事件预案 |
||||
|
* |
||||
|
* @param id 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Override |
||||
|
public DcEmergencyPlans selectDcEmergencyPlans(Integer id) { |
||||
|
return dcEmergencyPlansMapper.selectDcEmergencyPlans(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据事件类型查询事件预案 |
||||
|
* |
||||
|
* @param event 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<DcEmergencyPlans> selectDcEmergencyPlansByEventType(DcEvent event) { |
||||
|
List<DcEmergencyPlans> dcEmergencyPlansList = dcEmergencyPlansMapper.selectDcEmergencyPlansByEventType(event); |
||||
|
|
||||
|
int eventType = Integer.parseInt(event.getEventType().toString()); |
||||
|
|
||||
|
if (eventType == EventTypeEnum.TRAFFIC_ACCIDENT.getCode()) { |
||||
|
return dcEmergencyPlansList.stream() |
||||
|
.filter(dcEmergencyPlans -> { |
||||
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
||||
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
||||
|
int eventLevel = Integer.parseInt(triggerJson.get("eventLevel").toString()); |
||||
|
return eventLevel == event.getEventLevel(); |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
} else if (eventType == EventTypeEnum.VEHICLE_MALFUNCTION.getCode()) { |
||||
|
return dcEmergencyPlansList.stream() |
||||
|
.filter(dcEmergencyPlans -> { |
||||
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
||||
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
||||
|
String[] lane = event.getLang().split(","); |
||||
|
int[] intArray = Arrays.stream(lane) |
||||
|
.mapToInt(Integer::parseInt) |
||||
|
.toArray(); |
||||
|
JSONArray eventLevel = JSONArray.parseArray(triggerJson.get("roadOccupancy").toString()); |
||||
|
return Arrays.stream(intArray).anyMatch(Arrays.asList(eventLevel.toArray())::contains); |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
} else if (eventType == EventTypeEnum.TRAFFIC_CONTROL.getCode()) { |
||||
|
return dcEmergencyPlansList.stream() |
||||
|
.filter(dcEmergencyPlans -> { |
||||
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
||||
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
||||
|
// 管制分类
|
||||
|
Integer controlType = Integer.parseInt(triggerJson.get("controlType").toString()); |
||||
|
// 分类
|
||||
|
Integer classify = Integer.parseInt(triggerJson.get("classify").toString()); |
||||
|
// 分类原因
|
||||
|
Integer controlCause = Integer.parseInt(triggerJson.get("controlCause").toString()); |
||||
|
// 事件--交通管制数据
|
||||
|
DcEventTrafficControl dcEventTrafficControl = event.getDcEventTrafficControl(); |
||||
|
Integer eventControlType = Integer.parseInt(dcEventTrafficControl.getControlType().toString()); |
||||
|
Integer eventClassify = Integer.parseInt(dcEventTrafficControl.getClassify().toString()); |
||||
|
Integer eventControlCause = Integer.parseInt(dcEventTrafficControl.getControlCause().toString()); |
||||
|
return controlType.equals(eventControlType) && classify.equals(eventClassify) && controlCause.equals(eventControlCause); |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
} else if (eventType == EventTypeEnum.TRAFFIC_JAM.getCode()) { |
||||
|
return dcEmergencyPlansList.stream() |
||||
|
.filter(dcEmergencyPlans -> { |
||||
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
||||
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
||||
|
// 拥堵原因
|
||||
|
Integer congestionCause = Integer.parseInt(triggerJson.get("congestionCause").toString()); |
||||
|
// 详细原因
|
||||
|
Integer detailedReasons = Integer.parseInt(triggerJson.get("detailedReasons").toString()); |
||||
|
// 事件--交通拥堵数据
|
||||
|
DcEventTrafficCongestion dcEventTrafficCongestion = event.getDcEventTrafficCongestion(); |
||||
|
Integer eventCongestionCause = Integer.parseInt(dcEventTrafficCongestion.getCongestionCause().toString()); |
||||
|
Integer eventDetailedReasons = Integer.parseInt(dcEventTrafficCongestion.getDetailedReasons().toString()); |
||||
|
return congestionCause.equals(eventCongestionCause) && detailedReasons.equals(eventDetailedReasons); |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
} else if (eventType == EventTypeEnum.ILLEGAL_ROAD_USE.getCode() || eventType == EventTypeEnum.ROADBLOCK_CLEARANCE.getCode()) { |
||||
|
return dcEmergencyPlansList.stream() |
||||
|
.filter(dcEmergencyPlans -> { |
||||
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
||||
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
||||
|
String eventSubclass = triggerJson.get("eventSubclass").toString(); |
||||
|
// 事件--非法上路/路障清除 数据
|
||||
|
String subclass = event.getEventSubclass(); |
||||
|
return eventSubclass.equals(subclass); |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
} else if (eventType == EventTypeEnum.CONSTRUCTION_AND_CONSTRUCTION.getCode()) { |
||||
|
return dcEmergencyPlansList.stream() |
||||
|
.filter(dcEmergencyPlans -> { |
||||
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
||||
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
||||
|
String subclass = triggerJson.get("eventSubclass").toString(); |
||||
|
Integer controlMode = Integer.parseInt(triggerJson.get("controlMode").toString()); |
||||
|
JSONArray lane = JSONArray.parseArray(triggerJson.get("lane").toString()); |
||||
|
// 事件--施工建设数据
|
||||
|
DcEventConstruction dcEventConstruction = event.getDcEventConstruction(); |
||||
|
String eventSubclass = event.getEventSubclass(); |
||||
|
Integer eventControlMode = Integer.parseInt(dcEventConstruction.getControlMode().toString()); |
||||
|
String[] eventLane = event.getLang().split(","); |
||||
|
int[] eventLaneInt = Arrays.stream(eventLane) |
||||
|
.mapToInt(Integer::parseInt) |
||||
|
.toArray(); |
||||
|
return subclass.equals(eventSubclass) && controlMode.equals(eventControlMode) |
||||
|
&& Arrays.stream(eventLaneInt).anyMatch(Arrays.asList(lane.toArray())::contains); |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
} else if (eventType == EventTypeEnum.SERVICE_AREA_ABNORMALITY.getCode()) { |
||||
|
return dcEmergencyPlansList.stream() |
||||
|
.filter(dcEmergencyPlans -> { |
||||
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
||||
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
||||
|
Integer facilityId = Integer.parseInt(triggerJson.get("facilityId").toString()); |
||||
|
Integer disableFacility = Integer.parseInt(triggerJson.get("disableFacility").toString()); |
||||
|
|
||||
|
// 事件--服务区异常数据
|
||||
|
DcEventServiceArea dcEventServiceArea = event.getDcEventServiceArea(); |
||||
|
Integer eventFacilityId = Integer.parseInt(dcEventServiceArea.getFacilityId().toString()); |
||||
|
Integer eventDisableFacility = Integer.parseInt(dcEventServiceArea.getDisableFacility().toString()); |
||||
|
return facilityId.equals(eventFacilityId) && disableFacility.equals(eventDisableFacility); |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
} else if (eventType == EventTypeEnum.ABNORMAL_WEATHER.getCode()) { |
||||
|
return dcEmergencyPlansList.stream() |
||||
|
.filter(dcEmergencyPlans -> { |
||||
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
||||
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
||||
|
String unusualWeather = triggerJson.get("unusualWeather").toString(); |
||||
|
// 条件
|
||||
|
JSONArray conditions = JSON.parseArray(triggerJson.get("conditions").toString()); |
||||
|
|
||||
|
// 事件--异常天气数据
|
||||
|
DcEventAbnormalWeather dcEventAbnormalWeather = event.getDcEventAbnormalWeather(); |
||||
|
String weatherSituation = dcEventAbnormalWeather.getWeatherSituation(); |
||||
|
// 异常天气数据
|
||||
|
Integer numericalValue = Integer.parseInt(dcEventAbnormalWeather.getNumericalValue()); |
||||
|
String conditionString = conditions.stream().map(condition -> { |
||||
|
JSONObject conditionJSON = JSON.parseObject(condition.toString()); |
||||
|
String comparisonOperator = StringEscapeUtils.unescapeXml(conditionJSON.get("comparisonOperator").toString()); |
||||
|
String thresholdValue = conditionJSON.get("thresholdValue").toString(); |
||||
|
return numericalValue + comparisonOperator + thresholdValue; |
||||
|
}).collect(Collectors.joining(" && ")); |
||||
|
|
||||
|
ScriptEngineManager manager = new ScriptEngineManager(); |
||||
|
ScriptEngine engine = manager.getEngineByName("js"); |
||||
|
boolean result = false; |
||||
|
try { |
||||
|
result = (boolean) engine.eval(conditionString); |
||||
|
} catch (ScriptException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return unusualWeather.equals(weatherSituation) && result; |
||||
|
}) |
||||
|
.collect(Collectors.toList()); |
||||
|
} else { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 新增事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
@Override |
||||
|
public int insertDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans) { |
||||
|
dcEmergencyPlans.setCreateTime(DateUtils.getNowDate()); |
||||
|
List<DcExecuteAction> dcExecuteActionList = dataProcessing(dcEmergencyPlans); |
||||
|
// 插入事件预案表数据
|
||||
|
dcEmergencyPlansMapper.insertDcEmergencyPlans(dcEmergencyPlans); |
||||
|
dcExecuteActionList.forEach(dcExecuteAction -> dcExecuteAction.setEmergencyPlansId(dcEmergencyPlans.getId())); |
||||
|
// 插入执行操作表数据
|
||||
|
dcExecuteActionList.forEach(dcExecuteAction -> dcExecuteAction.setCreateTime(DateUtils.getNowDate())); |
||||
|
return dcExecuteActionService.insertDcExecuteActionBatch(dcExecuteActionList); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改事件预案 |
||||
|
* |
||||
|
* @param dcEmergencyPlans 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
@Override |
||||
|
public int updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans) { |
||||
|
dcEmergencyPlans.setUpdateTime(DateUtils.getNowDate()); |
||||
|
List<DcExecuteAction> dcExecuteActionList = dataProcessing(dcEmergencyPlans); |
||||
|
// 修改事件预案表数据
|
||||
|
dcEmergencyPlansMapper.updateDcEmergencyPlans(dcEmergencyPlans); |
||||
|
// 修改执行操作表数据
|
||||
|
dcExecuteActionList.forEach(dcExecuteAction -> dcExecuteAction.setUpdateTime(DateUtils.getNowDate())); |
||||
|
// 过滤出删除掉的执行操作和恢复操作
|
||||
|
String dcExecuteActionId = dcExecuteActionList.stream() |
||||
|
.filter(dcExecuteAction -> dcExecuteAction.getId() != null) |
||||
|
.map(DcExecuteAction::getEmergencyPlansId) |
||||
|
.map(String::valueOf) |
||||
|
.findFirst() |
||||
|
.orElse(null); |
||||
|
List<String> ids = dcExecuteActionList.stream() |
||||
|
.filter(dcExecuteAction -> dcExecuteAction.getId() != null) |
||||
|
.map(DcExecuteAction::getId) |
||||
|
.collect(Collectors.toList()); |
||||
|
// 查询出事件预案关联的执行操作和恢复操作
|
||||
|
List<String> dcExecuteActionIdList = dcExecuteActionService.selectDcExecuteActionByEmergencyPlansId(dcExecuteActionId); |
||||
|
List<String> commonIds = new ArrayList<>(ids); |
||||
|
commonIds.retainAll(dcExecuteActionIdList); |
||||
|
|
||||
|
// 删除后的执行操作id和恢复操作id
|
||||
|
List<String> idsNotInDcExecuteActionIdList = new ArrayList<>(dcExecuteActionIdList); |
||||
|
idsNotInDcExecuteActionIdList.removeAll(commonIds); |
||||
|
// 根据执行操作id和恢复操作id,进行删除操作
|
||||
|
if (idsNotInDcExecuteActionIdList.size() > 0) { |
||||
|
System.out.println("存在需要删除的数据"); |
||||
|
dcExecuteActionService.deleteDcExecuteAction(idsNotInDcExecuteActionIdList); |
||||
|
} |
||||
|
|
||||
|
// 过滤出新增的执行操作
|
||||
|
List<DcExecuteAction> insertDcExecuteActionList = dcExecuteActionList.stream() |
||||
|
.filter(dcExecuteAction -> dcExecuteAction.getId() == null) |
||||
|
.collect(Collectors.toList()); |
||||
|
if (insertDcExecuteActionList.size() > 0) { |
||||
|
dcExecuteActionService.insertDcExecuteActionBatch(insertDcExecuteActionList); |
||||
|
} |
||||
|
|
||||
|
return dcExecuteActionService.updateDcExecuteActionBatch(dcExecuteActionList); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int updateBatchDcEmergencyPlans(List<DcEmergencyPlans> dcEmergencyPlansList) { |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量删除事件预案 |
||||
|
* |
||||
|
* @param ids 事件预案 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
@Override |
||||
|
public int deleteDcEmergencyPlans(String[] ids) { |
||||
|
// 批量删除执行操作
|
||||
|
dcExecuteActionService.deleteDcExecuteActionByEmergencyPlansId(ids); |
||||
|
// 批量删除事件预案
|
||||
|
return dcEmergencyPlansMapper.deleteDcEmergencyPlans(ids); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 将json字符串转Map |
||||
|
* |
||||
|
* @param jsonStr |
||||
|
* @return |
||||
|
*/ |
||||
|
public static Map<String, String> jsonToMap(String jsonStr) { |
||||
|
try { |
||||
|
ObjectMapper objectMapper = new ObjectMapper(); |
||||
|
return objectMapper.readValue(jsonStr, new TypeReference<Map<String, String>>() { |
||||
|
}); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 数据处理 |
||||
|
*/ |
||||
|
public static List<DcExecuteAction> dataProcessing(DcEmergencyPlans dcEmergencyPlans) { |
||||
|
// 过滤出执行操作数据
|
||||
|
List<DcExecuteAction> dcExecuteActionOperationList = dcEmergencyPlans.getDcExecuteAction() |
||||
|
.stream() |
||||
|
.filter(dcExecuteAction -> dcExecuteAction.getActionType() == 1) |
||||
|
.collect(Collectors.toList()); |
||||
|
List<DcExecuteAction> dcExecuteActionList = dcEmergencyPlans.getDcExecuteAction(); |
||||
|
// 设备类型 数据处理
|
||||
|
String deviceType = dcExecuteActionOperationList.stream() |
||||
|
.map(DcExecuteAction::getDeviceType) |
||||
|
.map(String::valueOf) |
||||
|
.collect(Collectors.joining(",")); |
||||
|
dcEmergencyPlans.setDeviceType(deviceType); |
||||
|
// 可控设备 数据处理
|
||||
|
List<DcExecuteAction> dcExecuteActionNewList = dcExecuteActionOperationList.stream() |
||||
|
.filter(dcExecuteAction -> dcExecuteAction.getSearchRule() == 1) |
||||
|
.collect(Collectors.toList()); |
||||
|
String controllableDevice = dcExecuteActionNewList.stream() |
||||
|
.map(DcExecuteAction::getDeviceList) |
||||
|
.collect(Collectors.joining("、")); |
||||
|
dcEmergencyPlans.setControllableDevice(controllableDevice); |
||||
|
// 控制指令 数据处理
|
||||
|
List<String> otherConfigList = dcExecuteActionOperationList.stream() |
||||
|
.map(DcExecuteAction::getOtherConfig) |
||||
|
.collect(Collectors.toList()); |
||||
|
|
||||
|
List<String> otherConfigStringList = otherConfigList.stream() |
||||
|
.map(json -> jsonToMap(json)) |
||||
|
.filter(Objects::nonNull) |
||||
|
.map(map -> map.values().stream().collect(Collectors.joining(","))) |
||||
|
.collect(Collectors.toList()); |
||||
|
|
||||
|
String controlCommand = otherConfigStringList.stream() |
||||
|
.collect(Collectors.joining(";")); |
||||
|
dcEmergencyPlans.setControlCommand(controlCommand); |
||||
|
return dcExecuteActionList; |
||||
|
} |
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
package com.zc.business.service.impl; |
||||
|
|
||||
|
import com.zc.business.domain.DcExecuteAction; |
||||
|
import com.zc.business.mapper.DcExecuteActionMapper; |
||||
|
import com.zc.business.service.DcExecuteActionService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class DcExecuteActionServiceImpl implements DcExecuteActionService { |
||||
|
|
||||
|
@Resource |
||||
|
private DcExecuteActionMapper dcExecuteActionMapper; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 批量新增执行操作 |
||||
|
* |
||||
|
* @param dcExecuteActionList 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Override |
||||
|
public int insertDcExecuteActionBatch(List<DcExecuteAction> dcExecuteActionList) { |
||||
|
return dcExecuteActionMapper.insertDcExecuteActionBatch(dcExecuteActionList); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量修改执行操作 |
||||
|
* |
||||
|
* @param dcExecuteActionList 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Override |
||||
|
public int updateDcExecuteActionBatch(List<DcExecuteAction> dcExecuteActionList) { |
||||
|
return dcExecuteActionMapper.updateDcExecuteActionBatch(dcExecuteActionList); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据事件预案id批量删除执行操作 |
||||
|
* |
||||
|
* @param ids 执行操作 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public int deleteDcExecuteActionByEmergencyPlansId(String[] ids) { |
||||
|
return dcExecuteActionMapper.deleteDcExecuteActionByEmergencyPlansId(ids); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量删除执行操作 |
||||
|
* |
||||
|
* @param ids 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Override |
||||
|
public int deleteDcExecuteAction(List<String> ids) { |
||||
|
return dcExecuteActionMapper.deleteDcExecuteAction(ids); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据事件预案id查询执行操作 |
||||
|
* |
||||
|
* @param emergencyPlansId 执行操作 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<String> selectDcExecuteActionByEmergencyPlansId(String emergencyPlansId) { |
||||
|
return dcExecuteActionMapper.selectDcExecuteActionByEmergencyPlansId(emergencyPlansId); |
||||
|
} |
||||
|
} |
@ -0,0 +1,128 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper |
||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.zc.business.mapper.DcEmergencyPlansMapper"> |
||||
|
|
||||
|
<resultMap type="DcEmergencyPlans" id="DcEmergencyPlansResult"> |
||||
|
<result property="id" column="id"/> |
||||
|
<result property="planName" column="plan_name"/> |
||||
|
<result property="eventType" column="event_type"/> |
||||
|
<result property="triggerMechanism" column="trigger_mechanism"/> |
||||
|
<result property="createTime" column="create_time"/> |
||||
|
<result property="updateTime" column="update_time"/> |
||||
|
<result property="deviceType" column="device_type"/> |
||||
|
<result property="triggeringCondition" column="triggering_condition"/> |
||||
|
<result property="controllableDevice" column="controllable_device"/> |
||||
|
<result property="controlCommand" column="control_command"/> |
||||
|
<collection property="dcExecuteAction" ofType="DcExecuteAction"> |
||||
|
<result property="id" column="action_id"/> |
||||
|
<result property="emergencyPlansId" column="action_emergency_plans_id"/> |
||||
|
<result property="deviceType" column="action_device_type"/> |
||||
|
<result property="actionType" column="action_action_type"/> |
||||
|
<result property="createTime" column="action_create_time"/> |
||||
|
<result property="updateTime" column="action_update_time"/> |
||||
|
<result property="searchRule" column="action_search_rule"/> |
||||
|
<result property="number" column="action_number"/> |
||||
|
<result property="deviceList" column="action_device_list"/> |
||||
|
<result property="otherConfig" column="action_other_config"/> |
||||
|
</collection> |
||||
|
</resultMap> |
||||
|
|
||||
|
<insert id="insertDcEmergencyPlans" parameterType="DcEmergencyPlans" useGeneratedKeys="true" keyColumn="id" |
||||
|
keyProperty="id"> |
||||
|
insert into dc_emergency_plans |
||||
|
<trim prefix="(" suffix=")" suffixOverrides=","> |
||||
|
<if test="planName != null and planName != ''">plan_name,</if> |
||||
|
<if test="eventType != null">event_type,</if> |
||||
|
<if test="triggerMechanism != null and triggerMechanism != ''">trigger_mechanism,</if> |
||||
|
<if test="createTime != null">create_time,</if> |
||||
|
<if test="updateTime != null">update_time,</if> |
||||
|
<if test="deviceType != null and deviceType != ''">device_type,</if> |
||||
|
<if test="triggeringCondition != null and triggeringCondition != ''">triggering_condition,</if> |
||||
|
<if test="controllableDevice != null and controllableDevice != ''">controllable_device,</if> |
||||
|
<if test="controlCommand != null and controlCommand != ''">control_command,</if> |
||||
|
</trim> |
||||
|
<trim prefix="values (" suffix=")" suffixOverrides=","> |
||||
|
<if test="planName != null and planName != ''">#{planName},</if> |
||||
|
<if test="eventType != null">#{eventType},</if> |
||||
|
<if test="triggerMechanism != null and triggerMechanism != ''">#{triggerMechanism},</if> |
||||
|
<if test="createTime != null">#{createTime},</if> |
||||
|
<if test="updateTime != null">#{updateTime},</if> |
||||
|
<if test="deviceType != null and deviceType != ''">#{deviceType},</if> |
||||
|
<if test="triggeringCondition != null and triggeringCondition != ''">#{triggeringCondition},</if> |
||||
|
<if test="controllableDevice != null and controllableDevice != ''">#{controllableDevice},</if> |
||||
|
<if test="controlCommand != null and controlCommand != ''">#{controlCommand},</if> |
||||
|
</trim> |
||||
|
</insert> |
||||
|
|
||||
|
<update id="updateDcEmergencyPlans" parameterType="DcEmergencyPlans"> |
||||
|
update dc_emergency_plans |
||||
|
set plan_name = #{planName}, |
||||
|
event_type = #{eventType}, |
||||
|
trigger_mechanism = #{triggerMechanism}, |
||||
|
update_time = #{updateTime}, |
||||
|
device_type = #{deviceType}, |
||||
|
triggering_condition = #{triggeringCondition}, |
||||
|
controllable_device = #{controllableDevice}, |
||||
|
control_command = #{controlCommand} |
||||
|
where id = #{id} |
||||
|
</update> |
||||
|
|
||||
|
<delete id="deleteDcEmergencyPlans" parameterType="String"> |
||||
|
delete from dc_emergency_plans where id in |
||||
|
<foreach item="id" collection="array" open="(" separator="," close=")"> |
||||
|
#{id} |
||||
|
</foreach> |
||||
|
</delete> |
||||
|
<sql id="selectDcEmergencyPlansListAll"> |
||||
|
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, |
||||
|
t2.id as action_id, |
||||
|
t2.emergency_plans_id as action_emergency_plans_id, |
||||
|
t2.device_type as action_device_type, |
||||
|
t2.action_type as action_action_type, |
||||
|
t2.create_time as action_create_time, |
||||
|
t2.search_rule as action_search_rule, |
||||
|
t2.`number` as action_number, |
||||
|
t2.device_list as action_device_list, |
||||
|
t2.other_config as action_other_config |
||||
|
from dc_emergency_plans t1 |
||||
|
left join dc_execute_action t2 |
||||
|
on t1.id = t2.emergency_plans_id |
||||
|
</sql> |
||||
|
|
||||
|
<select id="selectDcEmergencyPlansList" 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 |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectDcEmergencyPlans" parameterType="Integer" resultMap="DcEmergencyPlansResult"> |
||||
|
<include refid="selectDcEmergencyPlansListAll"/> |
||||
|
where t1.id = #{id} |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectDcEmergencyPlansByEventType" parameterType="dcEvent" resultMap="DcEmergencyPlansResult"> |
||||
|
<include refid="selectDcEmergencyPlansListAll"/> |
||||
|
where t1.event_type = #{eventType} |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,112 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper |
||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.zc.business.mapper.DcExecuteActionMapper"> |
||||
|
|
||||
|
|
||||
|
<insert id="insertDcExecuteActionBatch" parameterType="java.util.List"> |
||||
|
insert into dc_execute_action |
||||
|
|
||||
|
(emergency_plans_id, |
||||
|
device_type, |
||||
|
action_type, |
||||
|
create_time, |
||||
|
search_rule, |
||||
|
`number`, |
||||
|
device_list, |
||||
|
other_config |
||||
|
) |
||||
|
values |
||||
|
<foreach collection="list" item="item" separator=","> |
||||
|
|
||||
|
(#{item.emergencyPlansId}, |
||||
|
#{item.deviceType}, |
||||
|
#{item.actionType}, |
||||
|
#{item.createTime}, |
||||
|
#{item.searchRule}, |
||||
|
#{item.number}, |
||||
|
#{item.deviceList}, |
||||
|
#{item.otherConfig}) |
||||
|
|
||||
|
</foreach> |
||||
|
</insert> |
||||
|
|
||||
|
<update id="updateDcExecuteActionBatch" parameterType="java.util.List"> |
||||
|
update dc_execute_action |
||||
|
<trim prefix="set" suffixOverrides=","> |
||||
|
<trim prefix="emergency_plans_id =case" suffix="end,"> |
||||
|
<foreach collection="list" item="item" index="index"> |
||||
|
when id=#{item.id} |
||||
|
then #{item.emergencyPlansId} |
||||
|
</foreach> |
||||
|
</trim> |
||||
|
<trim prefix="device_type =case" suffix="end,"> |
||||
|
<foreach collection="list" item="item" index="index"> |
||||
|
when id=#{item.id} |
||||
|
then #{item.deviceType} |
||||
|
</foreach> |
||||
|
</trim> |
||||
|
<trim prefix="action_type =case" suffix="end,"> |
||||
|
<foreach collection="list" item="item" index="index"> |
||||
|
when id=#{item.id} |
||||
|
then #{item.actionType} |
||||
|
</foreach> |
||||
|
</trim> |
||||
|
<trim prefix="update_time =case" suffix="end,"> |
||||
|
<foreach collection="list" item="item" index="index"> |
||||
|
when id=#{item.id} |
||||
|
then #{item.updateTime} |
||||
|
</foreach> |
||||
|
</trim> |
||||
|
<trim prefix="search_rule =case" suffix="end,"> |
||||
|
<foreach collection="list" item="item" index="index"> |
||||
|
when id=#{item.id} |
||||
|
then #{item.searchRule} |
||||
|
</foreach> |
||||
|
</trim> |
||||
|
<trim prefix="number =case" suffix="end,"> |
||||
|
<foreach collection="list" item="item" index="index"> |
||||
|
when id=#{item.id} |
||||
|
then #{item.number} |
||||
|
</foreach> |
||||
|
</trim> |
||||
|
<trim prefix="device_list =case" suffix="end,"> |
||||
|
<foreach collection="list" item="item" index="index"> |
||||
|
when id=#{item.id} |
||||
|
then #{item.deviceList} |
||||
|
</foreach> |
||||
|
</trim> |
||||
|
<trim prefix="other_config =case" suffix="end,"> |
||||
|
<foreach collection="list" item="item" index="index"> |
||||
|
when id=#{item.id} |
||||
|
then #{item.otherConfig} |
||||
|
</foreach> |
||||
|
</trim> |
||||
|
</trim> |
||||
|
where id in |
||||
|
<foreach collection="list" item="item" index="index" separator="," open="(" close=")"> |
||||
|
#{item.id} |
||||
|
</foreach> |
||||
|
</update> |
||||
|
|
||||
|
<delete id="deleteDcExecuteActionByEmergencyPlansId" parameterType="String"> |
||||
|
delete from dc_execute_action where emergency_plans_id in |
||||
|
<foreach item="id" collection="array" open="(" separator="," close=")"> |
||||
|
#{id} |
||||
|
</foreach> |
||||
|
</delete> |
||||
|
|
||||
|
<delete id="deleteDcExecuteAction" parameterType="java.util.List"> |
||||
|
delete from dc_execute_action where id in |
||||
|
<foreach item="id" collection="list" index="index" separator="," open="(" close=")"> |
||||
|
#{id} |
||||
|
</foreach> |
||||
|
</delete> |
||||
|
|
||||
|
<select id="selectDcExecuteActionByEmergencyPlansId" parameterType="String" resultType="String"> |
||||
|
select id from dc_execute_action where emergency_plans_id = #{emergencyPlansId} |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue