|
|
@ -8,8 +8,12 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.aspectj.lang.JoinPoint; |
|
|
|
import org.aspectj.lang.annotation.After; |
|
|
|
import org.aspectj.lang.annotation.Aspect; |
|
|
|
import org.aspectj.lang.annotation.Before; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.concurrent.locks.Lock; |
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Aspect |
|
|
|
@Component |
|
|
@ -18,6 +22,13 @@ public class DeviceStateChangeAspect { |
|
|
|
private final WebSocketSender webSocketService; |
|
|
|
private final DeviceStateService deviceStateService; |
|
|
|
|
|
|
|
private final Lock lock = new ReentrantLock(); |
|
|
|
|
|
|
|
@Before("execution(* com.iflytop.sgs.app.model.bo.status..set*(..))") |
|
|
|
public void beforeSetMethod(JoinPoint joinPoint) { |
|
|
|
lock.lock(); |
|
|
|
} |
|
|
|
|
|
|
|
@After("execution(* com.iflytop.sgs.app.model.bo.status.device.*.set*(..))") |
|
|
|
public void afterSetMethod(JoinPoint joinPoint) { |
|
|
|
try { |
|
|
@ -32,6 +43,8 @@ public class DeviceStateChangeAspect { |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("处理状态变更后的值失败", e); |
|
|
|
} finally { |
|
|
|
lock.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |