|
|
@@ -20,285 +20,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services |
|
|
|
{ |
|
|
|
_db = db; |
|
|
|
} |
|
|
|
|
|
|
|
//#region 配方工艺流程 |
|
|
|
///// <summary> |
|
|
|
///// 获取工艺流程 |
|
|
|
///// </summary> |
|
|
|
///// <param name="inputDto"></param> |
|
|
|
///// <returns></returns> |
|
|
|
//public PageUtil GetBomTechnologyPage(PageInputBase inputDto) |
|
|
|
//{ |
|
|
|
// int total = new RefAsync<int>(); |
|
|
|
// var res = _db.Queryable<BPA_BomTechnology, BPA_BOMEntry, BPA_Batching>((a, b, c) => new |
|
|
|
// JoinQueryInfos(JoinType.Left, a.BomentryId == b.Id, JoinType.Left, b.BatchingId == c.Id) |
|
|
|
// ).Where((a, b, c) => a.IsDeleted == 0 && a.ChnologyId == inputDto.chnologyId && a.GroupId == groupId) |
|
|
|
// .WhereIF(!string.IsNullOrWhiteSpace(inputDto.bomId), (a, b, c) => b.BomId == inputDto.bomId) |
|
|
|
// .OrderBy(a => a.Sort, OrderByType.Asc) |
|
|
|
// .Select((a, b, c) => new |
|
|
|
// { |
|
|
|
// Id = a.Id, |
|
|
|
// BatchingId = a.BomentryId, |
|
|
|
// ChnologyId = a.ChnologyId, |
|
|
|
// BatchingName = c.Batching_Name, |
|
|
|
// BomQty = b.BomQty, |
|
|
|
// TotalCount = a.TotalCount, |
|
|
|
// Sort = a.Sort |
|
|
|
// }).ToPageList(inputDto.Current, inputDto.PageSize, ref total); |
|
|
|
// return new PageUtil() |
|
|
|
// { |
|
|
|
// Data = res, |
|
|
|
// Total = total |
|
|
|
// }; |
|
|
|
//} |
|
|
|
///// <summary> |
|
|
|
///// 添加工艺流程 |
|
|
|
///// </summary> |
|
|
|
///// <param name="inputDto"></param> |
|
|
|
///// <returns></returns> |
|
|
|
//public async Task<bool> AddBomTechnology(List<BomTechnologyBaseDto> inputDto) |
|
|
|
//{ |
|
|
|
// var groupId = string.IsNullOrWhiteSpace(CurrentUser.TenantId) |
|
|
|
// ? App.User?.FindFirst(ClaimConst.GroupId)?.Value |
|
|
|
// : CurrentUser.TenantId; |
|
|
|
// var res = 0; |
|
|
|
// var addlist = new List<BPA_BomTechnology>(); |
|
|
|
// var uplist = new List<BPA_BomTechnology>(); |
|
|
|
// var list = _db.Queryable<BPA_BomTechnology>().Where(x => x.GroupId == groupId && x.IsDeleted == 0).ToList(); |
|
|
|
// for (int i = 0; i < inputDto.Count; i++) |
|
|
|
// { |
|
|
|
// if (list.Count > 0) |
|
|
|
// { |
|
|
|
// var model = list.Where(a => a.BomentryId == inputDto[i].BatchingId && a.IsDeleted == 0 && a.ChnologyId == inputDto[i].ChnologyId).FirstOrDefault(); |
|
|
|
// if (model != null) |
|
|
|
// { |
|
|
|
// model.BomentryId = inputDto[i].BatchingId; |
|
|
|
// model.Sort = inputDto[i].Sort; |
|
|
|
// model.TotalCount = inputDto[i].total; |
|
|
|
// uplist.Add(model); |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// var data = new BPA_BomTechnology() |
|
|
|
// { |
|
|
|
// Id = Guid.NewGuid().ToString(), |
|
|
|
// BomentryId = inputDto[i].BatchingId, |
|
|
|
// ChnologyId = inputDto[i].ChnologyId, |
|
|
|
// Sort = inputDto[i].Sort, |
|
|
|
// CreateAt = DateTime.Now, |
|
|
|
// GroupId = groupId, |
|
|
|
// IsDeleted = 0, |
|
|
|
// TotalCount = inputDto[i].total |
|
|
|
// }; |
|
|
|
// addlist.Add(data); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// var data = new BPA_BomTechnology() |
|
|
|
// { |
|
|
|
// Id = Guid.NewGuid().ToString(), |
|
|
|
// BomentryId = inputDto[i].BatchingId, |
|
|
|
// ChnologyId = inputDto[i].ChnologyId, |
|
|
|
// Sort = inputDto[i].Sort, |
|
|
|
// CreateAt = DateTime.Now, |
|
|
|
// GroupId = groupId, |
|
|
|
// IsDeleted = 0, |
|
|
|
// }; |
|
|
|
// addlist.Add(data); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if (addlist.Count > 0) |
|
|
|
// { |
|
|
|
// res = await _db.Insertable(addlist).ExecuteCommandAsync(); |
|
|
|
// } |
|
|
|
// if (uplist.Count > 0) |
|
|
|
// { |
|
|
|
// res = await _db.Updateable(uplist).ExecuteCommandAsync(); |
|
|
|
// } |
|
|
|
|
|
|
|
// return res > 0; |
|
|
|
//} |
|
|
|
///// <summary> |
|
|
|
///// 修改工艺流程 |
|
|
|
///// </summary> |
|
|
|
///// <param name="inputDto"></param> |
|
|
|
///// <returns></returns> |
|
|
|
//public bool UpdateBomTechnology(BomTechnologyBaseDto inputDto) |
|
|
|
//{ |
|
|
|
// var check = _db.Queryable<BPA_BomTechnology>().Any(a => a.BomentryId == inputDto.BatchingId && a.IsDeleted == 0 && a.ChnologyId == inputDto.ChnologyId && a.Id != inputDto.Id); |
|
|
|
// if (check) throw Oops.Oh("工艺流程已存在"); |
|
|
|
// var data = _db.Queryable<BPA_BomTechnology>().Where(a => a.Id == inputDto.Id).First(); |
|
|
|
// if (data == null) throw Oops.Oh("工艺流程不存在"); |
|
|
|
// data.BomentryId = inputDto.BatchingId; |
|
|
|
// data.ChnologyId = inputDto.ChnologyId; |
|
|
|
// data.Sort = inputDto.Sort; |
|
|
|
// var res = _db.Updateable(data).ExecuteCommand(); |
|
|
|
// return res > 0; |
|
|
|
//} |
|
|
|
///// <summary> |
|
|
|
///// 删除工艺流程 |
|
|
|
///// </summary> |
|
|
|
///// <param name="ids"></param> |
|
|
|
///// <returns></returns> |
|
|
|
//public bool DeleteBomTechnology(List<string> ids) |
|
|
|
//{ |
|
|
|
// var resEntity = _db.Queryable<BPA_BomTechnology>().Where(x => ids.Contains(x.Id)).ToList(); |
|
|
|
// foreach (var item in resEntity) |
|
|
|
// { |
|
|
|
// item.IsDeleted = 1; |
|
|
|
// } |
|
|
|
// var res = _db.Updateable(resEntity).ExecuteCommand(); |
|
|
|
// return res > 0; |
|
|
|
//} |
|
|
|
//#endregion |
|
|
|
//#region 配方工艺动作 |
|
|
|
///// <summary> |
|
|
|
///// 查询配方工艺流程动作 |
|
|
|
///// </summary> |
|
|
|
///// <returns></returns> |
|
|
|
//public BPA_BomTechnologyAction GetBomTechnologyAction(BomTechnologyActionBase dto) |
|
|
|
//{ |
|
|
|
// var res = _db.Queryable<BPA_BomTechnologyAction>().Where(x => x.IsDeleted == 0 && x.BomId == dto.BomId && x.ChnologyId == dto.ChnologyId && x.GroupId == groupId) |
|
|
|
// .OrderBy(i => i.Sort, OrderByType.Desc) |
|
|
|
// .First(); |
|
|
|
// return res; |
|
|
|
//} |
|
|
|
//public async Task<List<BPA_BomTechnologyAction>> GetBomTechnologyActionList(string BomId) |
|
|
|
//{ |
|
|
|
// var res = await _db.Queryable<BPA_BomTechnologyAction>().Where(x => x.IsDeleted == 0 && x.BomId == BomId && x.GroupId == groupId) |
|
|
|
// .OrderBy(i => i.Sort, OrderByType.Asc) |
|
|
|
// .ToListAsync(); |
|
|
|
// return res; |
|
|
|
//} |
|
|
|
//public BPA_BomTechnologyAction GetBomTechnologyActionById(string id) |
|
|
|
//{ |
|
|
|
// var res = _db.Queryable<BPA_BomTechnologyAction>().Where(x => x.Id == id) |
|
|
|
// .OrderBy(i => i.Sort, OrderByType.Desc) |
|
|
|
// .First(); |
|
|
|
// return res; |
|
|
|
//} |
|
|
|
|
|
|
|
///// <summary> |
|
|
|
///// 添加配方工艺流程动作步骤 |
|
|
|
///// </summary> |
|
|
|
///// <param name="inputDto"></param> |
|
|
|
///// <returns></returns> |
|
|
|
//public async Task<bool> AddBomTechnologyAction(BomTechnologyActionBaseDto inputDto) |
|
|
|
//{ |
|
|
|
// var res = 0; |
|
|
|
// var addlist = new BPA_BomTechnologyAction(); |
|
|
|
// var uplist = new BPA_BomTechnologyAction(); |
|
|
|
// var list = _db.Queryable<BPA_BomTechnologyAction>().Where(x => x.GroupId == groupId && x.IsDeleted == 0).ToList(); |
|
|
|
|
|
|
|
// if (inputDto != null) |
|
|
|
// { |
|
|
|
|
|
|
|
// if (list.Count > 0) |
|
|
|
// { |
|
|
|
// var sort = list.Max(x => x.Sort); |
|
|
|
// var model = list.Where(a => a.BomId == inputDto.BomId && a.IsDeleted == 0 && a.ChnologyId == inputDto.ChnologyId && a.BomId == inputDto.BomId).FirstOrDefault(); |
|
|
|
// if (string.IsNullOrEmpty(inputDto.Id)) |
|
|
|
// { |
|
|
|
// model = null; |
|
|
|
// } |
|
|
|
// if (model != null) |
|
|
|
// { |
|
|
|
// model.ActionJson = inputDto.ActionJson; |
|
|
|
// model.StepName = inputDto.StepName; |
|
|
|
// uplist = model; |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// var data = new BPA_BomTechnologyAction() |
|
|
|
// { |
|
|
|
// Id = Guid.NewGuid().ToString(), |
|
|
|
// ActionJson = inputDto.ActionJson, |
|
|
|
// ChnologyId = inputDto.ChnologyId, |
|
|
|
// StepName = inputDto.StepName, |
|
|
|
// CreateAt = DateTime.Now, |
|
|
|
// GroupId = groupId, |
|
|
|
// IsDeleted = 0, |
|
|
|
// BomId = inputDto.BomId, |
|
|
|
// Sort = sort + 1, |
|
|
|
// IsBatch = inputDto.IsBatch |
|
|
|
// }; |
|
|
|
// addlist = data; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// var data = new BPA_BomTechnologyAction() |
|
|
|
// { |
|
|
|
// Id = Guid.NewGuid().ToString(), |
|
|
|
// ActionJson = inputDto.ActionJson, |
|
|
|
// StepName = inputDto.StepName, |
|
|
|
// ChnologyId = inputDto.ChnologyId, |
|
|
|
// CreateAt = DateTime.Now, |
|
|
|
// GroupId = groupId, |
|
|
|
// IsDeleted = 0, |
|
|
|
// BomId = inputDto.BomId, |
|
|
|
// Sort = 1, |
|
|
|
// IsBatch = inputDto.IsBatch |
|
|
|
// }; |
|
|
|
// addlist = data; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if (!string.IsNullOrWhiteSpace(addlist.ActionJson)) |
|
|
|
// { |
|
|
|
// res = await _db.Insertable(addlist).ExecuteCommandAsync(); |
|
|
|
// } |
|
|
|
// if (!string.IsNullOrWhiteSpace(uplist.ActionJson)) |
|
|
|
// { |
|
|
|
// res = await _db.Updateable(uplist).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
// } |
|
|
|
// return res > 0; |
|
|
|
//} |
|
|
|
|
|
|
|
///// <summary> |
|
|
|
///// 删除工艺动作步骤 |
|
|
|
///// </summary> |
|
|
|
///// <param name="ids"></param> |
|
|
|
///// <returns></returns> |
|
|
|
//public async Task<bool> DeleteBomTechnologyAction(string ids) |
|
|
|
//{ |
|
|
|
// var resEntity = _db.Queryable<BPA_BomTechnologyAction>().Where(x => ids == x.Id).First(); |
|
|
|
// if (resEntity == null) throw Oops.Oh("工艺流程不存在"); |
|
|
|
// if (resEntity.IsBatch) |
|
|
|
// { |
|
|
|
// //如果是绑定的是物料的步骤 则删除物料步骤相关表数据 |
|
|
|
// var resEntitywl = _db.Queryable<BPA_BomTechnology>().Where(x => resEntity.ChnologyId.Contains(x.ChnologyId) && x.GroupId == groupId).ToList(); |
|
|
|
// foreach (var item in resEntitywl) |
|
|
|
// { |
|
|
|
// item.IsDeleted = 1; |
|
|
|
// } |
|
|
|
// await _db.Updateable(resEntitywl).ExecuteCommandAsync(); |
|
|
|
// } |
|
|
|
// resEntity.IsDeleted = 1; |
|
|
|
// var res = await _db.Updateable(resEntity).ExecuteCommandAsync(); |
|
|
|
// return res > 0; |
|
|
|
//} |
|
|
|
///// <summary> |
|
|
|
///// 排序 |
|
|
|
///// </summary> |
|
|
|
///// <param name="updateSortDtos"></param> |
|
|
|
///// <returns></returns> |
|
|
|
//public async Task<bool> UpdateSortBomTechnologyAction(List<UpdateSortDto> updateSortDtos) |
|
|
|
//{ |
|
|
|
// try |
|
|
|
// { |
|
|
|
// var ids = updateSortDtos.Select(p => p.id).ToArray(); |
|
|
|
// var list = _db.Queryable<BPA_BomTechnologyAction>().Where(x => ids.Contains(x.Id)).ToList(); |
|
|
|
// list.ForEach(x => x.Sort = updateSortDtos.Where(p => p.id == x.Id).FirstOrDefault().sort); |
|
|
|
// return await _db.Updateable(list).ExecuteCommandAsync() > 0; |
|
|
|
// } |
|
|
|
// catch (Exception e) |
|
|
|
// { |
|
|
|
// throw Oops.Oh("更新出错"); |
|
|
|
// } |
|
|
|
//} |
|
|
|
//#endregion |
|
|
|
#region 商品工艺(新版本工艺制作) |
|
|
|
/// <summary> |
|
|
|
/// 添加商品工艺 |
|
|
|