Browse Source

事件处置记录

develop
lau572 11 months ago
parent
commit
fd991eb61c
  1. 20
      zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java
  2. 36
      zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java
  3. 45
      zc-business/src/main/java/com/zc/business/enums/ValueConverter.java
  4. 8
      zc-business/src/main/java/com/zc/business/mapper/DcEventProcessMapper.java
  5. 11
      zc-business/src/main/java/com/zc/business/service/IDcEventProcessService.java
  6. 43
      zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java
  7. 52
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  8. 37
      zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml

20
zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java

@ -47,9 +47,18 @@ public class DcEventProcessController extends BaseController
* 查询事件处理流程列表
*/
@ApiOperation("查询事件处理流程列表")
// @PreAuthorize("@ss.hasPermi('system:process:list')")
@GetMapping("/list")
public TableDataInfo list(DcEventProcess dcEventProcess)
public List<DcEventProcess> list(DcEventProcess dcEventProcess)
{
return dcEventProcessService.selectDcEventProcessList(dcEventProcess);
}
/**
* 分页查询事件处理流程列表
*/
@ApiOperation("分页查询事件处理流程列表")
@GetMapping("/page")
public TableDataInfo page(DcEventProcess dcEventProcess)
{
startPage();
List<DcEventProcess> list = dcEventProcessService.selectDcEventProcessList(dcEventProcess);
@ -90,12 +99,7 @@ public class DcEventProcessController extends BaseController
// @PreAuthorize("@ss.hasPermi('system:process:add')")
@Log(title = "事件处理流程", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcEventProcess dcEventProcess) throws IOException, InvalidExtensionException {
//如果有文件传入
if(!dcEventProcess.getFile().isEmpty()){
String address =FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), dcEventProcess.getFile(), MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
dcEventProcess.setContext(address);
}
public AjaxResult add(@RequestBody DcEventProcess dcEventProcess){
return toAjax(dcEventProcessService.insertDcEventProcess(dcEventProcess));
}

36
zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java

@ -48,16 +48,12 @@ public class DcEventProcess
/** 1-节点
2-信息发布
3-设备管控
*/
@ApiModelProperty(value="流程类型")
@Excel(name = "1-节点 2-信息发布 ")
@ApiModelProperty(value="流程类型 1-节点,2-信息发布,3-设备管控")
@Excel(name = "流程类型")
private Integer processType;
/** $column.columnComment */
@ApiModelProperty("内容")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String context;
/** $column.columnComment */
@ApiModelProperty("流程ID")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@ -68,6 +64,20 @@ public class DcEventProcess
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String processName;
/** $column.columnComment */
@ApiModelProperty("内容")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String context;
/** $column.type */
@ApiModelProperty("内容类型")
@Excel(name = "${type}", readConverterExp = "$column.readConverterExp()")
private String type;
@ApiModelProperty("上传文件")
private MultipartFile file;
public MultipartFile getFile() {
return file;
}
@ -76,9 +86,6 @@ public class DcEventProcess
this.file = file;
}
@ApiModelProperty("上传文件")
private MultipartFile file;
public void setId(Long id)
{
this.id = id;
@ -161,6 +168,14 @@ public class DcEventProcess
return processName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -173,6 +188,7 @@ public class DcEventProcess
.append("context", getContext())
.append("processId", getProcessId())
.append("processName", getProcessName())
.append("type", getType())
.toString();
}
}

45
zc-business/src/main/java/com/zc/business/enums/ValueConverter.java

@ -22,6 +22,11 @@ public class ValueConverter {
private static final Map<String, String> valueMappingSon = new HashMap<>();
// 静态映射,用于存储转换关系 事件源转换
private static final Map<Integer, Integer> valueMappingSource = new HashMap<>();
// 事件来源名称
private static final Map<String, String> eventSourceName = new HashMap<>();
// 事件类型名称
private static final Map<String, String> eventTypeName = new HashMap<>();
static {
valueMappingSource.put(1,5);
valueMappingSource.put(4,7);
@ -87,6 +92,26 @@ public class ValueConverter {
valueMappingSon.put("11-2", "2-1");
valueMappingSon.put("11-3", "2-1");
valueMappingSon.put("99-1", "11-1");
eventSourceName.put("1","96659");
eventSourceName.put("2","交警转接");
eventSourceName.put("3","道路巡查");
eventSourceName.put("4","视频巡查");
eventSourceName.put("5","视频AI");
eventSourceName.put("6","一键救援");
eventSourceName.put("7","其他");
eventTypeName.put("1","交通事故");
eventTypeName.put("2","车辆故障");
eventTypeName.put("3","交通管制");
eventTypeName.put("4","交通拥堵");
eventTypeName.put("5","非法上路");
eventTypeName.put("6","路障清除");
eventTypeName.put("7","施工建设");
eventTypeName.put("8","服务区异常");
eventTypeName.put("9","设施设备隐患");
eventTypeName.put("10","异常天气");
eventTypeName.put("11","其他事件");
}
}
@ -100,6 +125,14 @@ public class ValueConverter {
public static Map<Integer, Integer> getValueMappingSource() {
return ValueMappingHolder.valueMappingSource;
}
public static Map<String, String> getEventSourceName() {
return ValueMappingHolder.eventSourceName;
}
public static Map<String, String> getEventTypeName() {
return ValueMappingHolder.eventTypeName;
}
/**
* 根据输入值返回转换后的值
* 如果输入值不在映射中则返回输入值本身
@ -118,6 +151,18 @@ public class ValueConverter {
Map<Integer, Integer> mapping = getValueMappingSource();
return mapping.getOrDefault(inputValue, inputValue);
}
public static String eventSourceName(String inputValue) {
Map<String, String> mapping = getEventSourceName();
return mapping.getOrDefault(inputValue, inputValue);
}
public static String eventTypeName(String inputValue) {
Map<String, String> mapping = getEventTypeName();
return mapping.getOrDefault(inputValue, inputValue);
}
//测试
// @Test
// public void text(){

8
zc-business/src/main/java/com/zc/business/mapper/DcEventProcessMapper.java

@ -35,6 +35,14 @@ public interface DcEventProcessMapper
*/
int insertDcEventProcess(DcEventProcess dcEventProcess);
/**
* 批量新增事件处理流程
*
* @param dcEventProcessList 事件处理流程
* @return 结果
*/
boolean batchInsertDcEventProcess(List<DcEventProcess> dcEventProcessList);
/**
* 修改事件处理流程
*

11
zc-business/src/main/java/com/zc/business/service/IDcEventProcessService.java

@ -1,6 +1,9 @@
package com.zc.business.service;
import java.io.IOException;
import java.util.List;
import com.ruoyi.common.exception.file.InvalidExtensionException;
import com.zc.business.domain.DcEventProcess;
/**
@ -35,6 +38,14 @@ public interface IDcEventProcessService
*/
int insertDcEventProcess(DcEventProcess dcEventProcess);
/**
* 批量新增事件处理流程
*
* @param dcEventProcessList 事件处理流程
* @return 结果
*/
boolean batchInsertDcEventProcess(List<DcEventProcess> dcEventProcessList);
/**
* 修改事件处理流程
*

43
zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java

@ -1,6 +1,12 @@
package com.zc.business.service.impl;
import java.io.IOException;
import java.util.List;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.exception.file.InvalidExtensionException;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.business.mapper.DcEventProcessMapper;
@ -52,9 +58,46 @@ public class DcEventProcessServiceImpl implements IDcEventProcessService
@Override
public int insertDcEventProcess(DcEventProcess dcEventProcess)
{
//如果有文件传入
if(!dcEventProcess.getFile().isEmpty()){
try {
String address = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), dcEventProcess.getFile(), MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
dcEventProcess.setContext(address);
String type = address.split("\\.")[1];
dcEventProcess.setType(type);
} catch (IOException | InvalidExtensionException e){
e.printStackTrace();
}
}
return dcEventProcessMapper.insertDcEventProcess(dcEventProcess);
}
/**
* 新增事件处理流程
*
* @param dcEventProcessList 事件处理流程
* @return 结果
*/
@Override
public boolean batchInsertDcEventProcess(List<DcEventProcess> dcEventProcessList)
{
dcEventProcessList.forEach(dcEventProcess -> {
//如果有文件传入
if(!dcEventProcess.getFile().isEmpty()){
try {
String address = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), dcEventProcess.getFile(), MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
dcEventProcess.setContext(address);
String type = address.split("\\.")[1];
dcEventProcess.setType(type);
} catch (IOException | InvalidExtensionException e){
e.printStackTrace();
}
}
});
return dcEventProcessMapper.batchInsertDcEventProcess(dcEventProcessList);
}
/**
* 修改事件处理流程
*

52
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -7,17 +7,16 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.zc.business.domain.*;
import com.zc.business.enums.ValueConverter;
import com.zc.business.mapper.*;
import com.zc.business.service.IDcEventProcessService;
import com.zc.business.service.IDcEventService;
import com.zc.business.service.IMiddleDatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -67,6 +66,9 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//查询路网信息
@Autowired
private DcFacilityServiceImpl dcFacilityService;
//事件处置记录
@Autowired
private IDcEventProcessService dcEventProcessService;
/**
@ -342,6 +344,25 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
break;
}
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEvent.getId());
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
List<DcProcessConfig> processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(dcEvent.getEventType().intValue());
if (processConfigList != null && processConfigList.size() > 0){
DcProcessConfig dcProcessConfig = processConfigList.get(0);
dcEventProcess.setProcessType(1);
dcEventProcess.setProcessId(Long.valueOf(dcProcessConfig.getNodeNode()));
dcEventProcess.setProcessName(dcProcessConfig.getProcessNode());
}
String sourceName = ValueConverter.eventSourceName(dcEvent.getEventSource().toString());
String typeName = ValueConverter.eventTypeName(dcEvent.getEventType().toString());
dcEventProcess.setContext("由" + sourceName + "上报了一起" + typeName + "事件");
dcEventProcessService.insertDcEventProcess(dcEventProcess);
return i7;
} else {
return -1;
@ -364,6 +385,8 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
if (flag) {
//中间库
List<MdEvent> mdEventList = new ArrayList<>();
List<DcEventProcess> dcEventProcessList = new ArrayList<>();
for (DcEvent dcEvent : dcEventList) {
MdEvent mdEvent = new MdEvent(dcEvent);
mdEventList.add(mdEvent);
@ -433,8 +456,29 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
break;
}
//事件处置流程记录
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEvent.getId());
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
List<DcProcessConfig> processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(dcEvent.getEventType().intValue());
if (processConfigList != null && processConfigList.size() > 0){
DcProcessConfig dcProcessConfig = processConfigList.get(0);
dcEventProcess.setProcessType(1);
dcEventProcess.setProcessId(Long.valueOf(dcProcessConfig.getNodeNode()));
dcEventProcess.setProcessName(dcProcessConfig.getProcessNode());
}
String sourceName = ValueConverter.eventSourceName(dcEvent.getEventSource().toString());
String typeName = ValueConverter.eventTypeName(dcEvent.getEventType().toString());
dcEventProcess.setContext("由" + sourceName + "上报了一起" + typeName + "事件");
dcEventProcessList.add(dcEventProcess);
}
middleDatabaseService.batchInsertMiddleDatabaseEvent(mdEventList);
//批量插入事件流程记录表
dcEventProcessService.batchInsertDcEventProcess(dcEventProcessList);
}
return flag;

37
zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml

@ -14,10 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="context" column="context" />
<result property="processId" column="process_id" />
<result property="processName" column="process_name" />
<result property="type" column="type" />
</resultMap>
<sql id="selectDcEventProcessVo">
select id, event_id, operation_time, operator, source, process_type, context, process_id, process_name from dc_event_process
select id, event_id, operation_time, operator, source, process_type, context, process_id, process_name, `type` from dc_event_process
</sql>
<select id="selectDcEventProcessList" parameterType="DcEventProcess" resultMap="DcEventProcessResult">
@ -29,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="source != null "> and source = #{source}</if>
<if test="processType != null "> and process_type = #{processType}</if>
<if test="context != null and context != ''"> and context = #{context}</if>
<if test="type != null and type != ''"> and `type` = #{type}</if>
<if test="processId != null "> and process_id = #{processId}</if>
<if test="processName != null and processName != ''"> and process_name like concat('%', #{processName}, '%')</if>
</where>
@ -51,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="context != null">context,</if>
<if test="processId != null">process_id,</if>
<if test="processName != null">process_name,</if>
<if test="type != null">`type`,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -62,9 +65,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="context != null">#{context},</if>
<if test="processId != null">#{processId},</if>
<if test="processName != null">#{processName},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
<insert id="batchInsertDcEventProcess">
<foreach collection ="list" item="item" index= "index" separator =";">
insert into dc_event_process
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.id != null">id,</if>
<if test="item.eventId != null and item.eventId != ''">event_id,</if>
<if test="item.operationTime != null">operation_time,</if>
<if test="item.operator != null and item.operator != ''">operator,</if>
<if test="item.source != null">source,</if>
<if test="item.processType != null">process_type,</if>
<if test="item.context != null">context,</if>
<if test="item.processId != null">process_id,</if>
<if test="item.processName != null">process_name,</if>
<if test="item.type != null">`type`,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="item.id != null">#{item.id},</if>
<if test="item.eventId != null and item.eventId != ''">#{item.eventId},</if>
<if test="item.operationTime != null">#{item.operationTime},</if>
<if test="item.operator != null and item.operator != ''">#{item.operator},</if>
<if test="item.source != null">#{item.source},</if>
<if test="item.processType != null">#{item.processType},</if>
<if test="item.context != null">#{item.context},</if>
<if test="item.processId != null">#{item.processId},</if>
<if test="item.processName != null">#{item.processName},</if>
<if test="item.type != null">#{item.type},</if>
</trim>
</foreach>
</insert>
<update id="updateDcEventProcess" parameterType="DcEventProcess">
update dc_event_process
<trim prefix="SET" suffixOverrides=",">
@ -74,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="source != null">source = #{source},</if>
<if test="processType != null">process_type = #{processType},</if>
<if test="context != null">context = #{context},</if>
<if test="type != null">`type` = #{type},</if>
<if test="processId != null">process_id = #{processId},</if>
<if test="processName != null">process_name = #{processName},</if>
</trim>

Loading…
Cancel
Save