Browse Source

新增告警分发接口

main
sjh 1 year ago
parent
commit
a94ee24c10
  1. 86
      src/main/java/com/biutag/supervision/controller/api/jwdc/AlarmApiController.java
  2. 8
      src/main/java/com/biutag/supervision/mapper/DataAlarmDispositionInfoMapper.java
  3. 8
      src/main/java/com/biutag/supervision/mapper/DataAlarmDispositionSetMapper.java
  4. 19
      src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmApiDto.java
  5. 31
      src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmDeviceInfoDto.java
  6. 79
      src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmDispositionInfoDto.java
  7. 81
      src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmInfoDto.java
  8. 93
      src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmYjzjDto.java
  9. 31
      src/main/java/com/biutag/supervision/pojo/entity/DataAlarmAlarmInfo.java
  10. 6
      src/main/java/com/biutag/supervision/pojo/entity/DataAlarmDeviceInfo.java
  11. 8
      src/main/java/com/biutag/supervision/pojo/entity/DataAlarmDispositionInfo.java
  12. 6
      src/main/java/com/biutag/supervision/pojo/entity/DataAlarmYjzj.java
  13. 9
      src/main/java/com/biutag/supervision/service/DataAlarmDeviceInfoService.java
  14. 17
      src/main/java/com/biutag/supervision/service/DataAlarmDispositionInfoService.java
  15. 11
      src/main/java/com/biutag/supervision/service/DataAlarmDispositionSetService.java
  16. 10
      src/main/java/com/biutag/supervision/service/DataAlarmYjzjService.java

86
src/main/java/com/biutag/supervision/controller/api/jwdc/AlarmApiController.java

@ -0,0 +1,86 @@
package com.biutag.supervision.controller.api.jwdc;
import com.alibaba.fastjson.JSON;
import com.biutag.supervision.pojo.dto.jwdc.AlarmApiDto;
import com.biutag.supervision.pojo.dto.jwdc.AlarmYjzjDto;
import com.biutag.supervision.pojo.entity.DataAlarmAlarmInfo;
import com.biutag.supervision.pojo.entity.DataAlarmDeviceInfo;
import com.biutag.supervision.pojo.entity.DataAlarmDispositionInfo;
import com.biutag.supervision.pojo.entity.DataAlarmYjzj;
import com.biutag.supervision.service.DataAlarmAlarmInfoService;
import com.biutag.supervision.service.DataAlarmDeviceInfoService;
import com.biutag.supervision.service.DataAlarmDispositionInfoService;
import com.biutag.supervision.service.DataAlarmYjzjService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Validated
@RequiredArgsConstructor
@RequestMapping("api/alarm")
@RestController
public class AlarmApiController {
private final DataAlarmAlarmInfoService alarmInfoService;
private final DataAlarmYjzjService yjzjService;
private final DataAlarmDeviceInfoService deviceInfoService;
private final DataAlarmDispositionInfoService dispositionInfoService;
@PostMapping
@Transactional
public String addAll(@RequestBody @Valid AlarmApiDto dto) {
log.info("告警分发准备导入数据: {}", JSON.toJSONString(dto));
List<DataAlarmYjzj> yjzjEntities = new ArrayList<>();
List<DataAlarmDeviceInfo> deviceInfos = new ArrayList<>();
List<DataAlarmDispositionInfo> dispositionInfos = new ArrayList<>();
if (dto.getAlarmInfo() != null) {
DataAlarmAlarmInfo alarmInfo = new DataAlarmAlarmInfo();
try {
BeanUtils.copyProperties(alarmInfo, dto.getAlarmInfo());
alarmInfoService.save(alarmInfo);
if (dto.getAlarmInfo().getAlmZJList() != null) {
for (AlarmYjzjDto yjzj : dto.getAlarmInfo().getAlmZJList()) {
DataAlarmYjzj yjzjEntity = new DataAlarmYjzj();
BeanUtils.copyProperties(yjzjEntity, yjzj);
yjzjEntity.setAlarm_info_id(alarmInfo.getId());
yjzjEntity.setOuter_id(yjzj.getId());
yjzjEntity.setId(null);
yjzjEntities.add(yjzjEntity);
}
}
if (dto.getDeviceInfo() != null) {
DataAlarmDeviceInfo deviceInfo = new DataAlarmDeviceInfo();
BeanUtils.copyProperties(deviceInfo, dto.getDeviceInfo());
deviceInfo.setAlarm_info_id(alarmInfo.getId());
deviceInfos.add(deviceInfo);
}
if (dto.getDispositionInfo() != null) {
DataAlarmDispositionInfo dispositionInfo = new DataAlarmDispositionInfo();
BeanUtils.copyProperties(dispositionInfo, dto.getDispositionInfo());
dispositionInfo.setAlarmInfoId(alarmInfo.getId());
dispositionInfos.add(dispositionInfo);
}
yjzjService.saveAll(yjzjEntities);
deviceInfoService.saveAll(deviceInfos);
dispositionInfoService.saveAll(dispositionInfos);
} catch (Exception e) {
log.error("告警分发接受失败:", e);
}
}
return "success";
}
}

8
src/main/java/com/biutag/supervision/mapper/DataAlarmDispositionInfoMapper.java

@ -0,0 +1,8 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.DataAlarmDispositionInfo;
public interface DataAlarmDispositionInfoMapper extends BaseMapper<DataAlarmDispositionInfo> {
}

8
src/main/java/com/biutag/supervision/mapper/DataAlarmDispositionSetMapper.java

@ -1,8 +0,0 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.DataAlarmDispositionSet;
public interface DataAlarmDispositionSetMapper extends BaseMapper<DataAlarmDispositionSet> {
}

19
src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmApiDto.java

@ -0,0 +1,19 @@
package com.biutag.supervision.pojo.dto.jwdc;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class AlarmApiDto {
@JsonProperty("AlarmInfo")
private AlarmInfoDto alarmInfo;
@JsonProperty("DeviceInfo")
private AlarmDeviceInfoDto deviceInfo;
@JsonProperty("DispositionInfo")
private AlarmDispositionInfoDto dispositionInfo;
}

31
src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmDeviceInfoDto.java

@ -0,0 +1,31 @@
package com.biutag.supervision.pojo.dto.jwdc;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class AlarmDeviceInfoDto {
@JsonProperty("SPSBBM")
private String SPSBBM;
@JsonProperty("VideoID")
private String VideoID;
@JsonProperty("VideoName")
private String VideoName;
@JsonProperty("Channel")
private String Channel;
@JsonProperty("Plat_IP")
private String Plat_IP;
@JsonProperty("Plat_Port")
private String Plat_Port;
@JsonProperty("GBID")
private String GBID;
}

79
src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmDispositionInfoDto.java

@ -0,0 +1,79 @@
package com.biutag.supervision.pojo.dto.jwdc;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class AlarmDispositionInfoDto {
@JsonProperty("DispositionID")
private String DispositionID;
@JsonProperty("Title")
private String Title;
@JsonProperty("SystemKeyID")
private String SystemKeyID;
@JsonProperty("SystemKeyName")
private String SystemKeyName;
@JsonProperty("DisArearID")
private String DisArearID;
@JsonProperty("DisScenceID")
private String DisScenceID;
@JsonProperty("ReceiveAddr")
private String ReceiveAddr;
@JsonProperty("DispositionRange")
private String DispositionRange;
@JsonProperty("DispositionStatus")
private Integer DispositionStatus;
@JsonProperty("AlarmBusinessId")
private String AlarmBusinessId;
@JsonProperty("AlarmBusinessName")
private String AlarmBusinessName;
@JsonProperty("ProblemId")
private String ProblemId;
@JsonProperty("ProblemName")
private String ProblemName;
@JsonProperty("AlarmLevel")
private Integer AlarmLevel;
@JsonProperty("AlarmModel")
private Integer AlarmModel;
@JsonProperty("AlarmNumber")
private Integer AlarmNumber;
@JsonProperty("IsEnable")
private Boolean IsEnable;
@JsonProperty("IsMerge")
private Boolean IsMerge;
@JsonProperty("TruncationTime")
private String TruncationTime;
@JsonProperty("IsTopLevelMsgSwitch")
private Boolean IsTopLevelMsgSwitch;
@JsonProperty("TopLevelMsgCycle")
private Integer TopLevelMsgCycle;
@JsonProperty("expire")
private Integer expire;
@JsonProperty("DispostionCategory")
private String DispostionCategory;
}

81
src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmInfoDto.java

@ -0,0 +1,81 @@
package com.biutag.supervision.pojo.dto.jwdc;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Setter
@Getter
public class AlarmInfoDto {
@JsonProperty("SourceSysLbl")
private String SourceSysLbl;
@JsonProperty("DCYJ_YWLSH")
private String DCYJ_YWLSH;
@JsonProperty("DCYJ_BT")
private String DCYJ_BT;
@JsonProperty("DCYJ_JYQK")
private String DCYJ_JYQK;
@JsonProperty("YJSASJBM")
private String YJSASJBM;
@JsonProperty("JWDCFSDM")
private String JWDCFSDM;
@JsonProperty("JWDCFSDMName")
private String JWDCFSDMName;
@JsonProperty("RQSJ")
private String RQSJ;
@JsonProperty("FSDW_GAJGJGDM")
private String FSDW_GAJGJGDM;
@JsonProperty("FSDW_GAJGMC")
private String FSDW_GAJGMC;
@JsonProperty("XXDJDW_GAJGJGDM")
private String XXDJDW_GAJGJGDM;
@JsonProperty("XXDJDW_GAJGMC")
private String XXDJDW_GAJGMC;
@JsonProperty("JSON")
private String JSON;
@JsonProperty("ZXTYJDM")
private String ZXTYJDM;
@JsonProperty("S_AlarmID")
private String S_AlarmID;
@JsonProperty("S_Key")
private String S_Key;
@JsonProperty("S_Title")
private String S_Title;
@JsonProperty("S_Subtitle")
private String S_Subtitle;
@JsonProperty("S_BodyType")
private String S_BodyType;
@JsonProperty("S_BodyInfo")
private String S_BodyInfo;
@JsonProperty("SystemKeyID")
private String SystemKeyID;
@JsonProperty("Scence")
private String Scence;
@JsonProperty("AlmZJList")
private List<AlarmYjzjDto> AlmZJList;
}

93
src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmYjzjDto.java

@ -0,0 +1,93 @@
package com.biutag.supervision.pojo.dto.jwdc;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import lombok.Getter;
import lombok.Setter;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
@Setter
@Getter
public class AlarmYjzjDto {
@JsonProperty("id")
private String id;
@JsonProperty("ALM_AlarmID")
private String ALM_AlarmID;
@JsonProperty("DCYJYWLSH")
private String DCYJYWLSH;
@JsonProperty("GJC")
private String GJC;
@JsonProperty("KSSJ")
private String KSSJ;
@JsonProperty("JSSJ")
private String JSSJ;
@JsonProperty("DZWJMC")
private String DZWJMC;
@JsonProperty("DZWJGS")
private String DZWJGS;
@JsonProperty("DZWJLX")
private String DZWJLX;
@JsonProperty("DZWJDX")
private BigDecimal DZWJDX;
@JsonProperty("DZWJWZ")
private String DZWJWZ;
@JsonProperty("DMTBZBT")
private String DMTBZBT;
@JsonProperty("DMTBZJYQK")
private String DMTBZJYQK;
@JsonProperty("DMTBZRQSJ")
@JsonDeserialize(using = CustomLocalDateTimeDeserializer.class)
private LocalDateTime DMTBZRQSJ;
@JsonProperty("DMTBZDJDWGAJGDM")
private String DMTBZDJDWGAJGDM;
@JsonProperty("DMTBZDJDWGAJGMC")
private String DMTBZDJDWGAJGMC;
@JsonProperty("DMTBZDJRGMSFHM")
private String DMTBZDJRGMSFHM;
@JsonProperty("DMTBZDJRXM")
private String DMTBZDJRXM;
private static class CustomLocalDateTimeDeserializer extends StdDeserializer<LocalDateTime> {
protected CustomLocalDateTimeDeserializer() {
super(LocalDateTime.class);
}
@Override
public LocalDateTime deserialize(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) throws IOException {
String dateStr = p.getText();
if (dateStr.startsWith("/Date(") && dateStr.endsWith(")/")) {
String timestampStr = dateStr.substring(6, dateStr.length() - 2);
// 去掉时区部分
String[] parts = timestampStr.split("-");
long timestamp = Long.parseLong(parts[0]);
return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
}
throw new IllegalArgumentException("Invalid date format: " + dateStr);
}
}
}

31
src/main/java/com/biutag/supervision/pojo/entity/DataAlarmAlarmInfo.java

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Setter
@Getter
public class DataAlarmAlarmInfo {
@ -20,15 +22,15 @@ public class DataAlarmAlarmInfo {
// 业务流水号(公安标准)
@TableField("DCYJ_YWLSH")
private String dcyjYwlsh;
private String DCYJ_YWLSH;
// 标题生成规则
@TableField("DCYJ_BT")
private String dcyjBt;
private String DCYJ_BT;
// 消息文本内容生成规则
@TableField("DCYJ_JYQK")
private String dcyjJyqk;
private String DCYJ_JYQK;
// 预警涉案事件编号(外部编码)
@TableField("YJSASJBM")
@ -48,19 +50,19 @@ public class DataAlarmAlarmInfo {
// 发生单位代码
@TableField("FSDW_GAJGJGDM")
private String fsdwGajgjgdm;
private String FSDW_GAJGJGDM;
// 发生单位名称
@TableField("FSDW_GAJGMC")
private String fsdwGajgmc;
private String FSDW_GAJGMC;
// 登记单位代码
@TableField("XXDJDW_GAJGJGDM")
private String xxdjdwGajgjgdm;
private String XXDJDW_GAJGJGDM;
// 登记单位名称
@TableField("XXDJDW_GAJGMC")
private String xxdjdwGajgmc;
private String XXDJDW_GAJGMC;
// Json参数
@TableField("JSON")
@ -72,27 +74,27 @@ public class DataAlarmAlarmInfo {
// 原始系统的预警标识号 即子系统的原始预警的标识号(外部编码)
@TableField("S_AlarmID")
private String sAlarmid;
private String S_AlarmID;
// 原始系统预警的关键ID(外部编码) 视频:设备编码 执法:案件ID 评议:样本ID
@TableField("S_Key")
private String sKey;
private String S_Key;
// 原始系统预警的标题 视频:设备名称 执法:案件名称 评议:受访群众姓名+联系方式
@TableField("S_Title")
private String sTitle;
private String S_Title;
// 原始系统预警的副标题 视频:场所 执法:刑事或行政 评议:业务类型
@TableField("S_Subtitle")
private String sSubtitle;
private String S_Subtitle;
// 原始系统预警的主体类型 1、图片 2、文本
@TableField("S_BodyType")
private String sBodytype;
private String S_BodyType;
// 原始系统预警的主体信息(预警规则) 1、视频采用图片类型,该字段为图片位置 2、执法采用文本类型,该字段为案件的简要情况 3、评议采用文本类型,该字段为评议结果
@TableField("S_BodyInfo")
private String sBodyinfo;
private String S_BodyInfo;
// 布控的检测方法ID(外部编码)
@TableField("SystemKeyID")
@ -102,4 +104,7 @@ public class DataAlarmAlarmInfo {
@TableField("Scence")
private String Scence;
@TableField(exist = false)
private List<DataAlarmYjzj> AlmZJList;
}

6
src/main/java/com/biutag/supervision/pojo/entity/DataAlarmDeviceInfo.java

@ -16,7 +16,7 @@ public class DataAlarmDeviceInfo {
// 关联ID
@TableField("alarm_info_id")
private Long alarmInfoId;
private Long alarm_info_id;
// 视频设备编码(外部编码)
@TableField("SPSBBM")
@ -36,11 +36,11 @@ public class DataAlarmDeviceInfo {
// IP(外部编码)
@TableField("Plat_IP")
private String platIp;
private String Plat_IP;
// 端口(外部编码)
@TableField("Plat_Port")
private String platPort;
private String Plat_Port;
// 国标ID
@TableField("GBID")

8
src/main/java/com/biutag/supervision/pojo/entity/DataAlarmDispositionSet.java → src/main/java/com/biutag/supervision/pojo/entity/DataAlarmDispositionInfo.java

@ -8,7 +8,7 @@ import lombok.Setter;
@Setter
@Getter
public class DataAlarmDispositionSet {
public class DataAlarmDispositionInfo {
// ID
@TableId(value = "id", type = IdType.AUTO)
@ -84,11 +84,11 @@ public class DataAlarmDispositionSet {
// 是否开启升级 0 不开启 1 开启(外部编码)
@TableField("IsEnable")
private Integer IsEnable;
private Boolean IsEnable;
// 是否开启合并 0 不开启 1 开启(外部编码)
@TableField("IsMerge")
private Integer IsMerge;
private Boolean IsMerge;
// 截断时间(外部编码)
@TableField("TruncationTime")
@ -96,7 +96,7 @@ public class DataAlarmDispositionSet {
// 是否开启升级 0 不开启 1 开启(外部编码)
@TableField("IsTopLevelMsgSwitch")
private Integer IsTopLevelMsgSwitch;
private Boolean IsTopLevelMsgSwitch;
// 多少次后升级(外部编码)
@TableField("TopLevelMsgCycle")

6
src/main/java/com/biutag/supervision/pojo/entity/DataAlarmYjzj.java

@ -19,15 +19,15 @@ public class DataAlarmYjzj {
// 关联ID
@TableField("alarm_info_id")
private Long alarmInfoId;
private Long alarm_info_id;
// 主键(外部编码)
@TableField("outer_id")
private String outerId;
private String outer_id;
// 督察预警ID(外部编码)
@TableField("ALM_AlarmID")
private String almAlarmid;
private String ALM_AlarmID;
// 督察预警_业务流水号(外部编码)
@TableField("DCYJYWLSH")

9
src/main/java/com/biutag/supervision/service/DataAlarmDeviceInfoService.java

@ -1,11 +1,18 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.DataAlarmDeviceInfo;
import com.biutag.supervision.mapper.DataAlarmDeviceInfoMapper;
import com.biutag.supervision.pojo.entity.DataAlarmDeviceInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class DataAlarmDeviceInfoService extends ServiceImpl<DataAlarmDeviceInfoMapper, DataAlarmDeviceInfo> {
@Transactional
public void saveAll(List<DataAlarmDeviceInfo> entities) {
this.saveBatch(entities);
}
}

17
src/main/java/com/biutag/supervision/service/DataAlarmDispositionInfoService.java

@ -0,0 +1,17 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.mapper.DataAlarmDispositionInfoMapper;
import com.biutag.supervision.pojo.entity.DataAlarmDispositionInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class DataAlarmDispositionInfoService extends ServiceImpl<DataAlarmDispositionInfoMapper, DataAlarmDispositionInfo> {
@Transactional
public void saveAll(List<DataAlarmDispositionInfo> entities) {
this.saveBatch(entities);
}
}

11
src/main/java/com/biutag/supervision/service/DataAlarmDispositionSetService.java

@ -1,11 +0,0 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.DataAlarmDispositionSet;
import com.biutag.supervision.mapper.DataAlarmDispositionSetMapper;
import org.springframework.stereotype.Service;
@Service
public class DataAlarmDispositionSetService extends ServiceImpl<DataAlarmDispositionSetMapper, DataAlarmDispositionSet> {
}

10
src/main/java/com/biutag/supervision/service/DataAlarmYjzjService.java

@ -1,11 +1,17 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.DataAlarmYjzj;
import com.biutag.supervision.mapper.DataAlarmYjzjMapper;
import com.biutag.supervision.pojo.entity.DataAlarmYjzj;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class DataAlarmYjzjService extends ServiceImpl<DataAlarmYjzjMapper, DataAlarmYjzj> {
@Transactional
public void saveAll(List<DataAlarmYjzj> entities) {
this.saveBatch(entities);
}
}

Loading…
Cancel
Save