调整组织管理,工位绑定工序代码
This commit is contained in:
@@ -68,7 +68,7 @@ namespace Tnb.BasicData
|
||||
if (organize != null)
|
||||
{
|
||||
var whereExpr = Expressionable.Create<BasProcess, BasProcessStation>();
|
||||
var curProcessIds = await db.Queryable<BasProcessStation>().Where(it => it.station_id == organize.Id).Select(it => it.process_id).ToListAsync();
|
||||
var curProcessIds = await db.Queryable<BasProcessStation>().Where(it => it.station_id == organize.Id).Select(it => it.process_id).Distinct().ToListAsync();
|
||||
if (curProcessIds?.Count > 0)
|
||||
{
|
||||
whereExpr = whereExpr.And((a, b) => curProcessIds.Contains(a.id)).Or((a, b) => string.IsNullOrEmpty(b.process_id));
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user