fix(产品管理): 产品启用时会重复触发DeviceProductDeployEvent事件 (#513)

Co-authored-by: XIXUANHAO <xi_xh@foxmail.com>
This commit is contained in:
XiXuanHao 2024-10-08 09:40:17 +08:00 committed by GitHub
parent 6dc16ce715
commit 9b9545ecca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package org.jetlinks.community.device.service;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository; import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository;
import org.hswebframework.web.bean.FastBeanCopier; import org.hswebframework.web.bean.FastBeanCopier;
import org.hswebframework.web.crud.events.EntityEventHelper;
import org.hswebframework.web.crud.service.GenericReactiveCrudService; import org.hswebframework.web.crud.service.GenericReactiveCrudService;
import org.hswebframework.web.exception.BusinessException; import org.hswebframework.web.exception.BusinessException;
import org.jetlinks.community.device.entity.DeviceInstanceEntity; import org.jetlinks.community.device.entity.DeviceInstanceEntity;
@ -43,6 +44,7 @@ public class LocalDeviceProductService extends GenericReactiveCrudService<Device
.set(DeviceProductEntity::getState, DeviceProductState.registered.getValue()) .set(DeviceProductEntity::getState, DeviceProductState.registered.getValue())
.where(DeviceProductEntity::getId, id) .where(DeviceProductEntity::getId, id)
.execute() .execute()
.as(EntityEventHelper::setDoNotFireEvent)
) )
.flatMap(i -> FastBeanCopier .flatMap(i -> FastBeanCopier
.copy(product, new DeviceProductDeployEvent()) .copy(product, new DeviceProductDeployEvent())