16 changed files with 458 additions and 45 deletions
@ -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"; |
||||||
|
} |
||||||
|
} |
||||||
@ -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> { |
||||||
|
|
||||||
|
} |
||||||
@ -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> { |
|
||||||
|
|
||||||
} |
|
||||||
@ -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; |
||||||
|
} |
||||||
@ -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; |
||||||
|
} |
||||||
@ -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; |
||||||
|
} |
||||||
@ -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; |
||||||
|
} |
||||||
@ -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); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -1,11 +1,18 @@ |
|||||||
package com.biutag.supervision.service; |
package com.biutag.supervision.service; |
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
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.mapper.DataAlarmDeviceInfoMapper; |
||||||
|
import com.biutag.supervision.pojo.entity.DataAlarmDeviceInfo; |
||||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
@Service |
@Service |
||||||
public class DataAlarmDeviceInfoService extends ServiceImpl<DataAlarmDeviceInfoMapper, DataAlarmDeviceInfo> { |
public class DataAlarmDeviceInfoService extends ServiceImpl<DataAlarmDeviceInfoMapper, DataAlarmDeviceInfo> { |
||||||
|
|
||||||
|
@Transactional |
||||||
|
public void saveAll(List<DataAlarmDeviceInfo> entities) { |
||||||
|
this.saveBatch(entities); |
||||||
|
} |
||||||
} |
} |
||||||
|
|||||||
@ -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); |
||||||
|
} |
||||||
|
} |
||||||
@ -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> { |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,11 +1,17 @@ |
|||||||
package com.biutag.supervision.service; |
package com.biutag.supervision.service; |
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
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.mapper.DataAlarmYjzjMapper; |
||||||
|
import com.biutag.supervision.pojo.entity.DataAlarmYjzj; |
||||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
@Service |
@Service |
||||||
public class DataAlarmYjzjService extends ServiceImpl<DataAlarmYjzjMapper, DataAlarmYjzj> { |
public class DataAlarmYjzjService extends ServiceImpl<DataAlarmYjzjMapper, DataAlarmYjzj> { |
||||||
|
@Transactional |
||||||
|
public void saveAll(List<DataAlarmYjzj> entities) { |
||||||
|
this.saveBatch(entities); |
||||||
|
} |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue