组织管理,新增设备与工位绑定、解绑功能

This commit is contained in:
DEVICE8\12494
2023-04-26 17:58:53 +08:00
parent 631bb0c0e8
commit 6118106b72
9 changed files with 84 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
using JNPF.DependencyInjection;
using JNPF.Systems.Entitys.Model.Organize;
using Newtonsoft.Json.Linq;
namespace JNPF.Systems.Entitys.Dto.Department;
@@ -42,7 +43,7 @@ public class DepartmentCrInput
/// <summary>
/// 扩展属性.
/// </summary>
public string propertyJson { get; set; }
public JObject propertyJson { get; set; }
/// <summary>
/// 排序码.

View File

@@ -14,7 +14,10 @@ using JNPF.Systems.Interfaces.Permission;
using JNPF.Systems.Interfaces.System;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.EquipMgr.Entities;
namespace JNPF.Systems;
@@ -438,6 +441,27 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
int isOK = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.D2018);
//modified by ly on 20230426 处理工位信息,将工位插入到设备表
if (input.category == "workstation")
{
var eqpObj = input.propertyJson;
var eqpList = (eqpObj.Value<JArray>("roweqp"));
var eqpIds = eqpList.Select(x => x.Value<string>("id")).ToList();
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync();
//工位与设备解绑操作
var eqpEntities = await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(it => it.station_code == input.enCode).ToListAsync();
if (eqpEntities?.Count > 0)
{
var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList();
if (unbindEqpIds?.Count > 0)
{
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync();
}
}
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.COM1001);
}
#region
try

View File

@@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\..\common\Tnb.CollectiveOAuth\Tnb.CollectiveOAuth.csproj" />
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
<ProjectReference Include="..\..\message\Tnb.Message.Interfaces\Tnb.Message.Interfaces.csproj" />
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
</ItemGroup>