调整在线开发,组织获取关联工序列表代码

This commit is contained in:
DEVICE8\12494
2023-05-04 15:08:19 +08:00
parent d132c8c229
commit c98236d10a
11 changed files with 192 additions and 70 deletions

View File

@@ -1,4 +1,5 @@
using JNPF.Common.Core.Manager;
using Aop.Api.Domain;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Filter;
using JNPF.Common.Security;
@@ -16,7 +17,10 @@ using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Senparc.Weixin.MP.AdvancedAPIs.Comment.CommentJson;
using SqlSugar;
using Tnb.BasicData;
using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities;
namespace JNPF.Systems;
@@ -442,27 +446,54 @@ 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")
if (input.category == DictConst.RegionCategoryStationCode)
{
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 jsonObj = input.propertyJson;
var eqpVal = jsonObj.GetValue("roweqp");
if (eqpVal is not null)
{
var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList();
if (unbindEqpIds?.Count > 0)
var eqpList = (jsonObj.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)
{
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync();
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();
}
}
}
var processVal = jsonObj.GetValue("rowprocess");
if (processVal is not null)
{
var dic = _repository.GetList().ToDictionary(x => x.FullName, x => x.Id);
var procList = jsonObj.Value<JArray>("rowprocess");
var basProcessStationList = procList.Select(x => new BasProcessStation
{
id = SnowflakeIdHelper.NextId(),
org_id = dic.ContainsKey(x.Value<string>("org_id")) ? dic[x.Value<string>("org_id")] : "",
process_id = x.Value<string>("id"),
process_code = x.Value<string>("process_code"),
station_code = input.enCode,
station_id = input.id,
create_id = _userManager.UserId,
create_time = DateTime.Now,
}).ToList();
isOK = await _repository.AsSugarClient().Insertable<BasProcessStation>(basProcessStationList).ExecuteCommandAsync();
//工位与工序解绑操作
//>1 根据传递的工位Id获取绑定过的工序Id
var processIds = await _repository.AsSugarClient().Queryable<BasProcessStation>().Where(it => it.station_id == input.id).Select(it => it.process_id).ToListAsync();
var curProcIds = basProcessStationList.Select(x => x.process_id).Except(processIds).ToList();
if (curProcIds?.Count > 0)
{
isOK = await _repository.AsSugarClient().Updateable<BasProcessStation>(it => new BasProcessStation { station_id = "", station_code = "" }).Where(it => curProcIds.Contains(it.process_id)).ExecuteCommandAsync();
}
}
if (!(isOK > 0)) throw Oops.Oh(ErrorCode.COM1001);
}
#region

View File

@@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
<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" />