调整组织管理,工位绑定工序代码

This commit is contained in:
DEVICE8\12494
2023-05-04 15:40:17 +08:00
parent c98236d10a
commit ca43cd8bfe
2 changed files with 9 additions and 3 deletions

View File

@@ -472,7 +472,9 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
{
var dic = _repository.GetList().ToDictionary(x => x.FullName, x => x.Id);
var procList = jsonObj.Value<JArray>("rowprocess");
var basProcessStationList = procList.Select(x => new BasProcessStation
var pids = procList.Select(x => x.Value<string>("id")).Distinct().ToList();
var dbProcIds = await _repository.AsSugarClient().Queryable<BasProcessStation>().Where(it => pids.Contains(it.process_id)).Select(it => it.process_id).ToListAsync();
var basProcessStationList = procList.Where(x => !dbProcIds.Contains(x.Value<string>("id"))).Select(x => new BasProcessStation
{
id = SnowflakeIdHelper.NextId(),
org_id = dic.ContainsKey(x.Value<string>("org_id")) ? dic[x.Value<string>("org_id")] : "",
@@ -483,7 +485,11 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
create_id = _userManager.UserId,
create_time = DateTime.Now,
}).ToList();
isOK = await _repository.AsSugarClient().Insertable<BasProcessStation>(basProcessStationList).ExecuteCommandAsync();
//数据库中不存在则插入
if (basProcessStationList?.Count > 0)
{
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();