fix 优化出差组生成

This commit is contained in:
2024-07-04 18:27:53 +08:00
parent 870b848203
commit 6c4ad11c28

View File

@@ -115,13 +115,13 @@ public class CreateDefinitelyGroupJob : BaseJob
foreach (var factory in tenants.Where(x => x.PCode == workplace.Code))
{
var factoryName = $"*{type.GetDescription()}厂区系统组({factory.Name})";
if (!await DbContext.Queryable<DeviceGroupEntity>().Where(x => x.PCode == workplaceGrp.Code).AnyAsync(x => x.Name == factoryName))
var factoryGrp = await DbContext.Queryable<DeviceGroupEntity>().Where(x => x.PCode == workplaceGrp.Code).FirstAsync(x => x.Name == factoryName);
if (factoryGrp == null)
{
var currentCode = Guid.NewGuid();
await DbContext.InsertAsync(new DeviceGroupEntity
factoryGrp = new DeviceGroupEntity
{
PCode = workplaceGrp.Code,
Code = currentCode,
Code = Guid.NewGuid(),
Type = type,
Name = factoryName,
Editable = false,
@@ -129,21 +129,26 @@ public class CreateDefinitelyGroupJob : BaseJob
Remark = _remark,
TenantId = factory.Code,
});
};
await DbContext.InsertAsync(factoryGrp);
}
if (type == DeviceTypeEnumType.Door)
{
if (!await DbContext.Queryable<DeviceGroupEntity>().Where(x => x.PCode == factoryGrp.Code).AnyAsync(x => x.IsBusinessTrip))
{
await DbContext.InsertAsync(new DeviceGroupEntity
{
PCode = currentCode,
Code = currentCode,
PCode = factoryGrp.Code,
Code = Guid.NewGuid(),
Type = type,
Name = "出差组",
Name = "*出差组",
Editable = false,
AbleSetNext = false,
Remark = _remark,
IsBusinessTrip = true,
TenantId = factory.Code
Remark = _remark,
TenantId = factory.Code,
});
}
}