@ -5,24 +5,17 @@ import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants ;
import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants ;
import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO ;
import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO ;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity ;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity ;
import com.hnac.hzims.operational.station.feign.IStationClient ;
import com.hnac.hzims.operational.station.wrapper.VideoSyncWrapper ;
import com.hnac.hzims.operational.station.service.IStationService ;
import com.hnac.hzims.operational.station.vo.StationVO ;
import lombok.AllArgsConstructor ;
import lombok.AllArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import lombok.extern.slf4j.Slf4j ;
import org.aspectj.lang.JoinPoint ;
import org.aspectj.lang.JoinPoint ;
import org.aspectj.lang.annotation.After ;
import org.aspectj.lang.annotation.After ;
import org.aspectj.lang.annotation.Aspect ;
import org.aspectj.lang.annotation.Aspect ;
import org.aspectj.lang.annotation.Pointcut ;
import org.aspectj.lang.annotation.Pointcut ;
import org.springblade.core.tool.utils.BeanUtil ;
import org.springblade.core.tool.utils.Func ;
import org.springblade.mqtt.producer.IMqttSender ;
import org.springblade.mqtt.producer.IMqttSender ;
import org.springframework.stereotype.Component ;
import org.springframework.stereotype.Component ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.List ;
import java.util.Optional ;
import java.util.stream.Collectors ;
/ * *
/ * *
* @Author : huangxing
* @Author : huangxing
@ -32,9 +25,9 @@ import java.util.stream.Collectors;
@Component
@Component
@AllArgsConstructor
@AllArgsConstructor
@Slf4j
@Slf4j
public class Add VideoAspect {
public class VideoSync Aspect {
private final IStationService stationService ;
private final VideoSyncWrapper wrapper ;
private final IMqttSender mqttSender ;
private final IMqttSender mqttSender ;
@Pointcut ( "execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.saveBatch(..)) " +
@Pointcut ( "execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.saveBatch(..)) " +
@ -51,26 +44,15 @@ public class AddVideoAspect {
if ( args . length = = 1 ) {
if ( args . length = = 1 ) {
Object arg = args [ 0 ] ;
Object arg = args [ 0 ] ;
if ( arg instanceof StationVideoTypeEntity ) {
if ( arg instanceof StationVideoTypeEntity ) {
List < VideoSyncDTO > videoSyncDTOS = Lists . newArrayList ( this . convert ( ( StationVideoTypeEntity ) arg ) ) ;
List < VideoSyncDTO > videoSyncDTOS = Lists . newArrayList ( wrapper . convert ( ( StationVideoTypeEntity ) arg ) ) ;
mqttSender . sendToMqtt ( MqttTopicConstants . TOPIC_VIDEO_INSERT , JSON . toJSONString ( videoSyncDTOS ) ) ;
mqttSender . sendToMqtt ( MqttTopicConstants . TOPIC_VIDEO_INSERT , JSON . toJSONString ( videoSyncDTOS ) ) ;
}
}
else if ( arg instanceof List ) {
else if ( arg instanceof List ) {
List < StationVideoTypeEntity > videoList = ( List < StationVideoTypeEntity > ) args [ 0 ] ;
List < StationVideoTypeEntity > videoList = ( List < StationVideoTypeEntity > ) args [ 0 ] ;
List < VideoSyncDTO > videoSyncDTOS = videoList . stream ( ) . map ( this : : convert ) . collect ( Collectors . toList ( ) ) ;
List < VideoSyncDTO > videoSyncDTOS = wrapper . listVO ( videoList ) ;
mqttSender . sendToMqtt ( MqttTopicConstants . TOPIC_VIDEO_INSERT , JSON . toJSONString ( videoSyncDTOS ) ) ;
mqttSender . sendToMqtt ( MqttTopicConstants . TOPIC_VIDEO_INSERT , JSON . toJSONString ( videoSyncDTOS ) ) ;
}
}
}
}
}
}
private VideoSyncDTO convert ( StationVideoTypeEntity entity ) {
VideoSyncDTO videoSyncDTO = BeanUtil . copy ( entity , VideoSyncDTO . class ) ;
StationVO station = stationService . getStationByCode ( entity . getStationId ( ) ) ;
String stationName = Optional . ofNullable ( station ) . map ( StationVO : : getName ) . orElse ( "" ) ;
videoSyncDTO . setId ( String . valueOf ( entity . getId ( ) ) ) ;
videoSyncDTO . setItemId ( String . valueOf ( entity . getId ( ) ) ) ;
videoSyncDTO . setStationName ( stationName ) ;
videoSyncDTO . setItemName ( stationName + " " + videoSyncDTO . getName ( ) ) ;
return videoSyncDTO ;
}
}
}