mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 23:47:56 +00:00
Merge pull request #339 from SyncrowIOT/feat/commission-device
Feat/commission device
This commit is contained in:
@@ -65,7 +65,7 @@ export class DisableSpaceHandler
|
||||
}
|
||||
}
|
||||
|
||||
const tagUuids = space.tags?.map((tag) => tag.uuid) || [];
|
||||
const tagUuids = space.productAllocations?.map((tag) => tag.uuid) || [];
|
||||
/* const subspaceDtos =
|
||||
space.subspaces?.map((subspace) => ({
|
||||
subspaceUuid: subspace.uuid,
|
||||
|
||||
@@ -582,8 +582,8 @@ export class SpaceService {
|
||||
queryRunner: QueryRunner,
|
||||
): Promise<void> {
|
||||
try {
|
||||
if (space.subspaces || space.tags) {
|
||||
if (space.tags) {
|
||||
if (space.subspaces || space.productAllocations) {
|
||||
if (space.productAllocations) {
|
||||
await this.spaceProductAllocationService.unlinkModels(
|
||||
space,
|
||||
queryRunner,
|
||||
|
||||
@@ -18,7 +18,6 @@ import { In, QueryRunner } from 'typeorm';
|
||||
import { SubspaceModelEntity } from '@app/common/modules/space-model';
|
||||
import { ValidationService } from '../space-validation.service';
|
||||
import { SubspaceRepository } from '@app/common/modules/space/repositories/subspace.repository';
|
||||
import { TagService } from '../tag';
|
||||
import { ModifyAction } from '@app/common/constants/modify-action.enum';
|
||||
import { SubspaceDeviceService } from './subspace-device.service';
|
||||
import { ModifyTagDto } from 'src/space/dtos/tag/modify-tag.dto';
|
||||
@@ -34,7 +33,6 @@ export class SubSpaceService {
|
||||
constructor(
|
||||
private readonly subspaceRepository: SubspaceRepository,
|
||||
private readonly validationService: ValidationService,
|
||||
private readonly tagService: TagService,
|
||||
private readonly newTagService: NewTagService,
|
||||
public readonly deviceService: SubspaceDeviceService,
|
||||
private readonly subspaceProductAllocationService: SubspaceProductAllocationService,
|
||||
@@ -481,21 +479,6 @@ export class SubSpaceService {
|
||||
{ disabled: true },
|
||||
);
|
||||
|
||||
if (subspace.tags?.length) {
|
||||
const modifyTagDtos: ProcessTagDto[] = subspace.tags.map((tag) => ({
|
||||
uuid: tag.uuid,
|
||||
action: ModifyAction.ADD,
|
||||
name: tag.tag,
|
||||
productUuid: tag.product.uuid,
|
||||
}));
|
||||
await this.tagService.moveTags(
|
||||
modifyTagDtos,
|
||||
queryRunner,
|
||||
subspace.space,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
if (subspace.devices.length > 0) {
|
||||
await this.deviceService.deleteSubspaceDevices(
|
||||
subspace.devices,
|
||||
|
||||
@@ -118,7 +118,7 @@ export class TagService {
|
||||
await queryRunner.manager.update(
|
||||
this.tagRepository.target,
|
||||
{ uuid: tag.uuid },
|
||||
{ subspace, space: null },
|
||||
{ subspace },
|
||||
);
|
||||
tag.subspace = subspace;
|
||||
}
|
||||
@@ -127,10 +127,9 @@ export class TagService {
|
||||
await queryRunner.manager.update(
|
||||
this.tagRepository.target,
|
||||
{ uuid: tag.uuid },
|
||||
{ subspace: null, space: space },
|
||||
{ subspace: null },
|
||||
);
|
||||
tag.subspace = null;
|
||||
tag.space = space;
|
||||
}
|
||||
|
||||
return tag;
|
||||
@@ -367,7 +366,6 @@ export class TagService {
|
||||
where: [
|
||||
{
|
||||
tag,
|
||||
space: { uuid: spaceUuid },
|
||||
product: { uuid: productUuid },
|
||||
disabled: false,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user