@ -1,11 +1,11 @@
package com.zc.business.service.impl ;
package com.zc.business.service.impl ;
import com.alibaba.fastjson.JSONObject ;
import com.ruoyi.common.core.domain.AjaxResult ;
import com.ruoyi.common.core.domain.AjaxResult ;
import com.ruoyi.common.utils.DateUtils ;
import com.ruoyi.common.utils.DateUtils ;
import com.ruoyi.common.utils.SecurityUtils ;
import com.ruoyi.common.utils.SecurityUtils ;
import com.ruoyi.common.utils.uuid.IdUtils ;
import com.ruoyi.common.utils.uuid.IdUtils ;
import com.zc.business.domain.DcEvent ;
import com.zc.business.domain.* ;
import com.zc.business.domain.DcWarning ;
import com.zc.business.enums.ValueConverter ;
import com.zc.business.enums.ValueConverter ;
import com.zc.business.mapper.DcEventMapper ;
import com.zc.business.mapper.DcEventMapper ;
import com.zc.business.mapper.DcWarningMapper ;
import com.zc.business.mapper.DcWarningMapper ;
@ -16,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.annotation.Transactional ;
import java.util.ArrayList ;
import java.util.Calendar ;
import java.util.HashMap ;
import java.util.HashMap ;
import java.util.List ;
import java.util.List ;
@ -42,7 +44,7 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 预警信息
* @return 预警信息
* /
* /
@Override
@Override
public HashMap < String , Object > selectDcWarningById ( Integer id )
public DcWarning selectDcWarningById ( String id )
{
{
return dcWarningMapper . selectDcWarningById ( id ) ;
return dcWarningMapper . selectDcWarningById ( id ) ;
}
}
@ -74,9 +76,11 @@ public class DcWarningServiceImpl implements IDcWarningService
public int insertDcWarning ( DcWarning dcWarning )
public int insertDcWarning ( DcWarning dcWarning )
{
{
dcWarning . setCreateTime ( DateUtils . getNowDate ( ) ) ;
dcWarning . setCreateTime ( DateUtils . getNowDate ( ) ) ;
//设置事件Id UUID无下划线格式32
if ( dcWarning . getId ( ) = = null ) {
String uuid = IdUtils . fastSimpleUUID ( ) ;
//设置事件Id UUID无下划线格式32
dcWarning . setId ( uuid ) ;
String uuid = IdUtils . fastSimpleUUID ( ) ;
dcWarning . setId ( uuid ) ;
}
return dcWarningMapper . insertDcWarning ( dcWarning ) ;
return dcWarningMapper . insertDcWarning ( dcWarning ) ;
}
}
@ -144,8 +148,13 @@ public class DcWarningServiceImpl implements IDcWarningService
if ( dcWarning . getWarningType ( ) ! = null ) {
if ( dcWarning . getWarningType ( ) ! = null ) {
dcEvent . setEventType ( ( long ) ValueConverter . convertValueHost ( dcWarning . getWarningType ( ) ) ) ; //事件主类
dcEvent . setEventType ( ( long ) ValueConverter . convertValueHost ( dcWarning . getWarningType ( ) ) ) ; //事件主类
}
}
if ( StringUtils . isBlank ( dcWarning . getWarningSubclass ( ) ) ) {
if ( StringUtils . isBlank ( dcWarning . getWarningSubclass ( ) ) & & dcWarning . getWarningType ( ) ! = 7 & &
dcEvent . setEventSubclass ( ValueConverter . convertValueSon ( dcWarning . getWarningSubclass ( ) ) ) ; //事件子类
dcWarning . getWarningType ( ) ! = 10 ) {
dcEvent . setEventSubclass ( ValueConverter . convertValueSon ( dcWarning . getWarningSubclass ( ) ) ) ; //事件子类(7与10不转)
}
if ( StringUtils . isBlank ( dcWarning . getWarningSubclass ( ) ) & & ( dcWarning . getWarningType ( ) = = 7 | |
dcWarning . getWarningType ( ) = = 10 ) ) {
dcEvent . setEventSubclass ( dcWarning . getWarningSubclass ( ) ) ; //事件子类(7与10主类对应的子类直接set)
}
}
dcEvent . setEventTitle ( dcWarning . getWarningTitle ( ) ) ; //标题
dcEvent . setEventTitle ( dcWarning . getWarningTitle ( ) ) ; //标题
dcEvent . setLang ( dcWarning . getLane ( ) ) ; //车道
dcEvent . setLang ( dcWarning . getLane ( ) ) ; //车道
@ -170,4 +179,230 @@ public class DcWarningServiceImpl implements IDcWarningService
{
{
return dcWarningMapper . selectDcWarningoTherConfig ( dcWarning ) ;
return dcWarningMapper . selectDcWarningoTherConfig ( dcWarning ) ;
}
}
/ * *
* @Description 感知事件批量转换
*
* @author liuwenge
* @date 2024 / 3 / 16 16 : 36
* @param dcWarningBatchConvert
* @return com . ruoyi . common . core . domain . AjaxResult
* /
@Override
@Transactional
public AjaxResult batchConvert ( DcWarningBatchConvert dcWarningBatchConvert ) {
if ( StringUtils . isBlank ( dcWarningBatchConvert . getType ( ) ) ) {
return AjaxResult . error ( "请选择操作类型" ) ;
}
List < DcWarning > dcWarningList = dcWarningBatchConvert . getWarningList ( ) ;
if ( dcWarningList ! = null & & dcWarningList . size ( ) > 0 ) {
//误报,批量删除
if ( "0" . equals ( dcWarningBatchConvert . getType ( ) ) ) {
dcWarningMapper . batchDelete ( dcWarningList ) ;
} else {
//确认,批量转换为事件
List < DcEvent > dcEventList = new ArrayList < > ( ) ;
for ( DcWarning dcWarning : dcWarningList ) {
if ( dcWarning = = null | | dcWarning . getId ( ) = = null | | StringUtils . isBlank ( dcWarning . getStakeMark ( ) ) | |
StringUtils . isBlank ( dcWarning . getDirection ( ) ) ) {
return AjaxResult . error ( "参数错误" ) ;
}
dcWarning . setUserId ( SecurityUtils . getUserId ( ) ) ;
DcEvent dcEvent = new DcEvent ( ) ;
dcEvent . setId ( dcWarning . getId ( ) ) ; //id
dcEvent . setStakeMark ( dcWarning . getStakeMark ( ) ) ; //桩号
dcEvent . setDirection ( dcWarning . getDirection ( ) ) ; //方向
dcEvent . setDeptId ( dcWarning . getDeptId ( ) ) ; //部门
dcEvent . setOccurrenceTime ( dcWarning . getWarningTime ( ) ) ; //预警时间
if ( dcWarning . getWarningLevel ( ) ! = null ) {
dcEvent . setEventLevel ( dcWarning . getWarningLevel ( ) . longValue ( ) ) ; //事件等级
}
if ( dcWarning . getWarningSource ( ) ! = null ) {
dcEvent . setEventSource ( ( long ) ValueConverter . convertValueSource ( dcWarning . getWarningSource ( ) ) ) ; //事件来源
}
if ( dcWarning . getWarningType ( ) ! = null ) {
dcEvent . setEventType ( ( long ) ValueConverter . convertValueHost ( dcWarning . getWarningType ( ) ) ) ; //事件主类
}
if ( StringUtils . isBlank ( dcWarning . getWarningSubclass ( ) ) ) {
dcEvent . setEventSubclass ( ValueConverter . convertValueSon ( dcWarning . getWarningSubclass ( ) ) ) ; //事件子类
}
dcEvent . setEventTitle ( dcWarning . getWarningTitle ( ) ) ; //标题
dcEvent . setLang ( dcWarning . getLane ( ) ) ; //车道
dcEvent . setRemark ( dcEvent . getRemark ( ) ) ; //备注
dcEvent . setIsPerceived ( 1 ) ; //是否感知事件
dcEvent . setEventState ( Long . valueOf ( 1 ) ) ; //状态为处理中
dcEvent . setCreateTime ( DateUtils . getNowDate ( ) ) ; //创建时间
dcEvent . setUserId ( SecurityUtils . getUserId ( ) ) ; //处置人员
Calendar cal = Calendar . getInstance ( ) ;
cal . add ( Calendar . HOUR , 3 ) ;
dcEvent . setEstimatedEndTime ( cal . getTime ( ) ) ; //预计解除时间
dcEvent . setRoadId ( 1L ) ; //道路id
dcEvent . setRoadName ( "济菏高速" ) ; //道路id
dcEvent . setInTunnel ( 0 ) ; //是否处在隧道
Integer warningType = dcWarning . getWarningType ( ) ;
if ( warningType = = 1 ) {
//交通拥堵
DcEventTrafficCongestion dcEventTrafficCongestion = new DcEventTrafficCongestion ( ) ;
dcEventTrafficCongestion . setId ( dcWarning . getId ( ) ) ;
dcEventTrafficCongestion . setCongestionCause ( 5L ) ;
dcEventTrafficCongestion . setCongestionMileage ( 0F ) ;
dcEventTrafficCongestion . setMaxCongestionMileage ( 0F ) ;
dcEvent . setDcEventTrafficCongestion ( dcEventTrafficCongestion ) ;
} else if ( warningType = = 4 ) {
//停车
DcEventVehicleAccident dcEventVehicleAccident = new DcEventVehicleAccident ( ) ;
dcEventVehicleAccident . setId ( dcWarning . getId ( ) ) ;
if ( dcWarning . getWarningSource ( ) = = 1 ) {
dcEventVehicleAccident . setReporterName ( "视频AI" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 2 ) {
dcEventVehicleAccident . setReporterName ( "雷达识别" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 3 ) {
dcEventVehicleAccident . setReporterName ( "智慧锥桶" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 4 ) {
dcEventVehicleAccident . setReporterName ( "护栏碰撞" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 6 ) {
dcEventVehicleAccident . setReporterName ( "非机预警" ) ;
}
dcEventVehicleAccident . setReporterPhoneNumber ( "96659" ) ;
dcEventVehicleAccident . setLocationType ( 1L ) ;
dcEventVehicleAccident . setTrafficJam ( 0L ) ;
dcEventVehicleAccident . setWeatherCondition ( 1L ) ;
dcEventVehicleAccident . setCongestionAhead ( 1 ) ;
dcEventVehicleAccident . setAtIntersection ( 1 ) ;
dcEventVehicleAccident . setOnCurve ( 1 ) ;
dcEventVehicleAccident . setSmallCar ( 0L ) ;
dcEventVehicleAccident . setTrucks ( 0L ) ;
dcEventVehicleAccident . setBuses ( 0L ) ;
dcEventVehicleAccident . setTankers ( 0L ) ;
dcEventVehicleAccident . setMinorInjuries ( 0L ) ;
dcEventVehicleAccident . setSeriousInjuries ( 0L ) ;
dcEventVehicleAccident . setFatalities ( 0L ) ;
dcEvent . setDcEventVehicleAccident ( dcEventVehicleAccident ) ;
} else if ( warningType = = 7 ) {
//道路施工
} else if ( warningType = = 8 ) {
//异常天气
DcEventAbnormalWeather dcEventAbnormalWeather = new DcEventAbnormalWeather ( ) ;
dcEventAbnormalWeather . setId ( dcWarning . getId ( ) ) ;
dcEventAbnormalWeather . setEmergencyLevel ( 1L ) ;
dcEvent . setDcEventAbnormalWeather ( dcEventAbnormalWeather ) ;
} else if ( warningType = = 9 ) {
//护栏碰撞
DcEventAccident dcEventAccident = new DcEventAccident ( ) ;
dcEventAccident . setId ( dcWarning . getId ( ) ) ;
if ( dcWarning . getWarningSource ( ) = = 1 ) {
dcEventAccident . setReporterName ( "视频AI" ) ;
dcEventAccident . setReporterPhoneNumber ( "96659" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 2 ) {
dcEventAccident . setReporterName ( "雷达识别" ) ;
dcEventAccident . setReporterPhoneNumber ( "96659" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 3 ) {
dcEventAccident . setReporterName ( "智慧锥桶" ) ;
dcEventAccident . setReporterPhoneNumber ( "96659" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 4 ) {
dcEventAccident . setReporterName ( "护栏碰撞" ) ;
dcEventAccident . setReporterPhoneNumber ( "96659" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 5 ) {
dcEventAccident . setReporterName ( "扫码报警" ) ;
JSONObject otherConfig = JSONObject . parseObject ( dcWarning . getOtherConfig ( ) ) ;
if ( otherConfig ! = null & & otherConfig . containsKey ( "phone" ) ) {
dcEventAccident . setReporterPhoneNumber ( otherConfig . getString ( "phone" ) ) ;
dcEventAccident . setVehicleOwnerPhone ( otherConfig . getString ( "phone" ) ) ;
}
} else if ( dcWarning . getWarningSource ( ) = = 6 ) {
dcEventAccident . setReporterName ( "非机预警" ) ;
dcEventAccident . setReporterPhoneNumber ( "96659" ) ;
}
dcEventAccident . setLocationType ( 1L ) ;
dcEventAccident . setTrafficJam ( 0f ) ;
dcEventAccident . setWeatherCondition ( 1L ) ;
dcEventAccident . setImpactLevel ( 1L ) ;
dcEventAccident . setIsReverseCargo ( 0 ) ;
dcEventAccident . setIsMaintenance ( 0 ) ;
dcEventAccident . setCongestionAhead ( 0 ) ;
dcEventAccident . setOnCurve ( 0 ) ;
dcEventAccident . setSmallCar ( 0L ) ;
dcEventAccident . setTrucks ( 0L ) ;
dcEventAccident . setBuses ( 0L ) ;
dcEventAccident . setTankers ( 0L ) ;
dcEventAccident . setMinorInjuries ( 0L ) ;
dcEventAccident . setSeriousInjuries ( 0L ) ;
dcEventAccident . setFatalities ( 0L ) ;
dcEvent . setDcEventAccident ( dcEventAccident ) ;
} else if ( warningType = = 10 ) {
//交通事故
DcEventAccident dcEventAccident = new DcEventAccident ( ) ;
} else if ( warningType = = 11 ) {
//车辆故障
DcEventVehicleAccident dcEventVehicleAccident = new DcEventVehicleAccident ( ) ;
dcEventVehicleAccident . setId ( dcWarning . getId ( ) ) ;
if ( dcWarning . getWarningSource ( ) = = 1 ) {
dcEventVehicleAccident . setReporterName ( "视频AI" ) ;
dcEventVehicleAccident . setReporterPhoneNumber ( "96659" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 2 ) {
dcEventVehicleAccident . setReporterName ( "雷达识别" ) ;
dcEventVehicleAccident . setReporterPhoneNumber ( "96659" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 3 ) {
dcEventVehicleAccident . setReporterName ( "智慧锥桶" ) ;
dcEventVehicleAccident . setReporterPhoneNumber ( "96659" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 4 ) {
dcEventVehicleAccident . setReporterName ( "护栏碰撞" ) ;
dcEventVehicleAccident . setReporterPhoneNumber ( "96659" ) ;
} else if ( dcWarning . getWarningSource ( ) = = 5 ) {
dcEventVehicleAccident . setReporterName ( "扫码报警" ) ;
JSONObject otherConfig = JSONObject . parseObject ( dcWarning . getOtherConfig ( ) ) ;
if ( otherConfig ! = null & & otherConfig . containsKey ( "phone" ) ) {
dcEventVehicleAccident . setReporterPhoneNumber ( otherConfig . getString ( "phone" ) ) ;
}
} else if ( dcWarning . getWarningSource ( ) = = 6 ) {
dcEventVehicleAccident . setReporterName ( "非机预警" ) ;
dcEventVehicleAccident . setReporterPhoneNumber ( "96659" ) ;
}
dcEventVehicleAccident . setLocationType ( 1L ) ;
dcEventVehicleAccident . setTrafficJam ( 0L ) ;
dcEventVehicleAccident . setWeatherCondition ( 1L ) ;
dcEventVehicleAccident . setCongestionAhead ( 1 ) ;
dcEventVehicleAccident . setAtIntersection ( 1 ) ;
dcEventVehicleAccident . setOnCurve ( 1 ) ;
dcEventVehicleAccident . setSmallCar ( 0L ) ;
dcEventVehicleAccident . setTrucks ( 0L ) ;
dcEventVehicleAccident . setBuses ( 0L ) ;
dcEventVehicleAccident . setTankers ( 0L ) ;
dcEventVehicleAccident . setMinorInjuries ( 0L ) ;
dcEventVehicleAccident . setSeriousInjuries ( 0L ) ;
dcEventVehicleAccident . setFatalities ( 0L ) ;
dcEvent . setDcEventVehicleAccident ( dcEventVehicleAccident ) ;
}
dcEventList . add ( dcEvent ) ;
}
//批量更改感知事件状态
dcWarningMapper . batchUpdateState ( SecurityUtils . getUserId ( ) , dcWarningList ) ;
//批量插入事件表
dcEventService . batchInsertDcEventWarning ( dcEventList ) ;
}
} else {
return AjaxResult . error ( "请选择感知事件" ) ;
}
return AjaxResult . success ( "批量操作成功" ) ;
}
}
}