From 53356ca9fa2313b662c3fedf010a36bafbf985d1 Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Wed, 31 Jan 2024 11:12:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=95=B0=E6=8D=AE=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E7=94=A8=E7=89=A9=E7=90=86=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataBase/Services/BatchingService.cs | 6 +- .../DataBase/Services/GoodsService.cs | 24 +- .../Services/GoodsTechnologyService.cs | 279 ------------------ .../Device/Services/DeviceService.cs | 6 +- .../Device/Services/ProductFunctionService.cs | 7 +- .../Device/Services/ProductTopicsService.cs | 7 +- .../Org/Services/UserService.cs | 6 +- .../System/Services/DictDataService.cs | 6 +- .../System/Services/DictTypeService.cs | 6 +- .../System/Services/MenuService.cs | 9 +- 10 files changed, 34 insertions(+), 322 deletions(-) diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs index 56d6b1f..426b688 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs @@ -211,11 +211,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services { // 查询数据库中是否存在未删除的活动信息 var resEntitites = _db.Queryable().In(Ids).ToList(); - resEntitites.ForEach(x => - { - x.IsDeleted = 1; - }); - var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + var res =await _db.Deleteable(resEntitites).ExecuteCommandAsync(); return res>0; } diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs index 6bf4e78..c65d20d 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs @@ -189,11 +189,25 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services /// public async Task DeleteGoods(string id) { - var goods = _db.Queryable().Where(x => x.Id== id).First(); - if (goods == null) throw Oops.Oh("商品不存在"); - goods.IsDeleted = 1; - var res = await _db.Updateable(goods).ExecuteCommandAsync(); - return res > 0; + try + { + _db.Ado.BeginTran(); + var goods = _db.Queryable().Where(x => x.Id == id).First(); + if (goods == null) throw Oops.Oh("商品不存在"); + var goodsbom = _db.Queryable().Where(x => x.Goods_Id == id).ToList(); + var goodsTechnology = _db.Queryable().Where(x => x.GoodsId == id).ToList(); + await _db.Deleteable(goodsbom).ExecuteCommandAsync(); + await _db.Deleteable(goodsTechnology).ExecuteCommandAsync(); + var res = await _db.Deleteable(goods).ExecuteCommandAsync(); + _db.Ado.CommitTran(); + return res > 0; + } + catch (Exception) + { + _db.Ado.RollbackTran(); + throw Oops.Oh("删除失败"); + } + } /// /// 查询商品单位 diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs index a4c825f..72c3c7f 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs @@ -20,285 +20,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services { _db = db; } - - //#region 配方工艺流程 - ///// - ///// 获取工艺流程 - ///// - ///// - ///// - //public PageUtil GetBomTechnologyPage(PageInputBase inputDto) - //{ - // int total = new RefAsync(); - // var res = _db.Queryable((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 - // }; - //} - ///// - ///// 添加工艺流程 - ///// - ///// - ///// - //public async Task AddBomTechnology(List inputDto) - //{ - // var groupId = string.IsNullOrWhiteSpace(CurrentUser.TenantId) - // ? App.User?.FindFirst(ClaimConst.GroupId)?.Value - // : CurrentUser.TenantId; - // var res = 0; - // var addlist = new List(); - // var uplist = new List(); - // var list = _db.Queryable().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; - //} - ///// - ///// 修改工艺流程 - ///// - ///// - ///// - //public bool UpdateBomTechnology(BomTechnologyBaseDto inputDto) - //{ - // var check = _db.Queryable().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().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; - //} - ///// - ///// 删除工艺流程 - ///// - ///// - ///// - //public bool DeleteBomTechnology(List ids) - //{ - // var resEntity = _db.Queryable().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 配方工艺动作 - ///// - ///// 查询配方工艺流程动作 - ///// - ///// - //public BPA_BomTechnologyAction GetBomTechnologyAction(BomTechnologyActionBase dto) - //{ - // var res = _db.Queryable().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> GetBomTechnologyActionList(string BomId) - //{ - // var res = await _db.Queryable().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().Where(x => x.Id == id) - // .OrderBy(i => i.Sort, OrderByType.Desc) - // .First(); - // return res; - //} - - ///// - ///// 添加配方工艺流程动作步骤 - ///// - ///// - ///// - //public async Task AddBomTechnologyAction(BomTechnologyActionBaseDto inputDto) - //{ - // var res = 0; - // var addlist = new BPA_BomTechnologyAction(); - // var uplist = new BPA_BomTechnologyAction(); - // var list = _db.Queryable().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; - //} - - ///// - ///// 删除工艺动作步骤 - ///// - ///// - ///// - //public async Task DeleteBomTechnologyAction(string ids) - //{ - // var resEntity = _db.Queryable().Where(x => ids == x.Id).First(); - // if (resEntity == null) throw Oops.Oh("工艺流程不存在"); - // if (resEntity.IsBatch) - // { - // //如果是绑定的是物料的步骤 则删除物料步骤相关表数据 - // var resEntitywl = _db.Queryable().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; - //} - ///// - ///// 排序 - ///// - ///// - ///// - //public async Task UpdateSortBomTechnologyAction(List updateSortDtos) - //{ - // try - // { - // var ids = updateSortDtos.Select(p => p.id).ToArray(); - // var list = _db.Queryable().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 商品工艺(新版本工艺制作) /// /// 添加商品工艺 diff --git a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs index 172ec41..a417aac 100644 --- a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs +++ b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs @@ -130,11 +130,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services public async Task DelDeviceInfo(List inputList) { var data = await _db.Queryable().Where(x => inputList.Contains(x.Id)).ToListAsync(); - foreach (var item in data) - { - item.IsDeleted = 1; - } - var res = await _db.Updateable(data) .ExecuteCommandAsync(); + var res = await _db.Deleteable(data) .ExecuteCommandAsync(); return res > 0; } /// diff --git a/BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs b/BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs index d2faf1d..58293c5 100644 --- a/BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs +++ b/BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs @@ -158,11 +158,8 @@ namespace BPA.SAAS.Manage.Application.Device.Services public async Task DeleteProductFunction(List ids) { var resEntity = _db.Queryable().Where(x => ids.Contains(x.Id)).ToList(); - foreach (var item in resEntity) - { - item.IsDeleted = 1; - } - var res =await _db.Updateable(resEntity).ExecuteCommandAsync(); + + var res =await _db.Deleteable(resEntity).ExecuteCommandAsync(); return res > 0; } #endregion diff --git a/BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs b/BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs index b4a5be8..d20652c 100644 --- a/BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs +++ b/BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs @@ -86,11 +86,8 @@ namespace BPA.SAAS.Manage.Application.Device.Services public async Task DelProductTopics(List inputList) { var data = await _db.Queryable().Where(x => inputList.Contains(x.Id)).ToListAsync(); - foreach (var item in data) - { - item.IsDeleted = 1; - } - var res = await _db.Updateable(data).ExecuteCommandAsync(); + + var res = await _db.Deleteable(data).ExecuteCommandAsync(); return res > 0; } } diff --git a/BPA.SAAS.Manage.Application/Org/Services/UserService.cs b/BPA.SAAS.Manage.Application/Org/Services/UserService.cs index 637e2ce..acf0d21 100644 --- a/BPA.SAAS.Manage.Application/Org/Services/UserService.cs +++ b/BPA.SAAS.Manage.Application/Org/Services/UserService.cs @@ -97,11 +97,7 @@ namespace BPA.SAAS.Manage.Application.Org.Services public async Task DeleteUser(List input) { var resEntitites = _db.Queryable().In(input).ToList(); - resEntitites.ForEach(x => - { - x.IsDeleted = 1; - }); - var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + var res =await _db.Deleteable(resEntitites).ExecuteCommandAsync(); return res > 0; } diff --git a/BPA.SAAS.Manage.Application/System/Services/DictDataService.cs b/BPA.SAAS.Manage.Application/System/Services/DictDataService.cs index 2601098..4cf3687 100644 --- a/BPA.SAAS.Manage.Application/System/Services/DictDataService.cs +++ b/BPA.SAAS.Manage.Application/System/Services/DictDataService.cs @@ -147,11 +147,7 @@ namespace BPA.SAAS.Manage.Application public async Task BatchDelDictData(List Ids) { var resEntitites = _db.Queryable().In(Ids).ToList(); - resEntitites.ForEach(x => - { - x.IsDeleted = 1; - }); - var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + var res =await _db.Deleteable(resEntitites).ExecuteCommandAsync(); return res > 0; } } diff --git a/BPA.SAAS.Manage.Application/System/Services/DictTypeService.cs b/BPA.SAAS.Manage.Application/System/Services/DictTypeService.cs index b18bce0..7858c8a 100644 --- a/BPA.SAAS.Manage.Application/System/Services/DictTypeService.cs +++ b/BPA.SAAS.Manage.Application/System/Services/DictTypeService.cs @@ -143,10 +143,8 @@ namespace BPA.SAAS.Manage.Application.System.Services { _db.Ado.BeginTran(); var dictType = _db.Queryable().Where(x => x.IsDeleted == 0).Where(x => ids.Contains(x.Id)).ToList(); - dictType.ForEach(x => { - x.IsDeleted = 1; - }); - var res =await _db.Updateable(dictType).ExecuteCommandAsync(); + + var res =await _db.Deleteable(dictType).ExecuteCommandAsync(); _db.Ado.CommitTran(); return res>0; } diff --git a/BPA.SAAS.Manage.Application/System/Services/MenuService.cs b/BPA.SAAS.Manage.Application/System/Services/MenuService.cs index bf23bc1..883efeb 100644 --- a/BPA.SAAS.Manage.Application/System/Services/MenuService.cs +++ b/BPA.SAAS.Manage.Application/System/Services/MenuService.cs @@ -177,11 +177,12 @@ namespace BPA.SAAS.Manage.Application.System.Services _db.Ado.BeginTran(); // 查询数据库中是否存在未删除的活动信息 var resEntitites = _db.Queryable().In(input).ToList(); - resEntitites.ForEach(x => + for (int i = 0; i < resEntitites.Count; i++) { - x.IsDeleted = 1; - }); - var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + var childlist = _db.Queryable().Where(x => x.Pid == resEntitites[i].Id).ToList(); + if(childlist.Count>0) resEntitites.AddRange(childlist); + } + var res =await _db.Deleteable(resEntitites).ExecuteCommandAsync(); _db.Ado.CommitTran(); return res>0; }