From 8826a713798e645e42381227e9263c16c65c9f97 Mon Sep 17 00:00:00 2001 From: hwh <332078369@qq.com> Date: 星期五, 05 七月 2024 15:04:47 +0800 Subject: [PATCH] 客户、物流、单位、包装 --- Wms/WMS.BLL/SysServer/PackagServer.cs | 388 +++++++++++++++++++++++++----------------------------- 1 files changed, 180 insertions(+), 208 deletions(-) diff --git a/Wms/WMS.BLL/SysServer/PackagServer.cs b/Wms/WMS.BLL/SysServer/PackagServer.cs index 8da9fd8..d6ca134 100644 --- a/Wms/WMS.BLL/SysServer/PackagServer.cs +++ b/Wms/WMS.BLL/SysServer/PackagServer.cs @@ -9,6 +9,8 @@ using WMS.IBLL.ISysServer; using WMS.IDAL.ISysInterface; using Model.ModelVm.SysVm; +using System.Threading.Tasks; +using Utility; namespace WMS.BLL.SysServer { @@ -29,7 +31,7 @@ /// <param name="packagName">鍖呰鍚嶇О</param> /// <param name="level">绛夌骇</param> /// <returns>鍖呰闆嗗悎</returns> - public List<PackagDto> GetPackagList(string packagNo, string packagName, int? level, int page, int limit, out int count) + public async Task<List<PackagDto>> GetPackagList(string packagNo, string packagName, int? level, int page, int limit, RefAsync<int> count) { try { @@ -39,9 +41,9 @@ .AndIF(level != null, it => it.Level.Equals(level)) .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏� - var data = PackagRst.GetAllByOrderPage(item, limit, page, out int counts) + var data = await PackagRst.GetAllByOrderPage(item, limit, page, out int counts) .Includes(x => x.CreateUserInfo) - .Includes(x => x.UpdateUserInfo).ToList(); + .Includes(x => x.UpdateUserInfo).ToListAsync(); count = counts; return data.Select(m => new PackagDto() @@ -83,10 +85,9 @@ /// </summary> /// <param name="id">鍖呰id</param> /// <returns></returns> - public SysPackag GetPackagById(int id) + public async Task<SysPackag> GetPackagById(int id) { - SysPackag packag = PackagRst.GetOneById(id); - return packag; + return await PackagRst.GetOneByIdAsync(id); } /// <summary> @@ -94,101 +95,88 @@ /// </summary> /// <param name="model">鍖呰淇℃伅</param> /// <returns>true锛氭垚鍔� flase锛氬け璐�</returns> - public int AddPackag(AddEditPackagVm model) + public async Task<int> AddPackag(AddEditPackagVm model) { - try + var rowCount = await PackagRst.GetAllWhere(m => m.PackagNo == model.PackagNo).CountAsync(); + if (rowCount > 0) { - var rowCount = PackagRst.GetAllWhere(m => m.PackagNo == model.PackagNo).Count(); - if (rowCount > 0) - { - throw new Exception("鍖呰缂栧彿宸插瓨鍦�!"); - } + throw Oops.Bah("鍖呰缂栧彿宸插瓨鍦�!"); + } - rowCount = PackagRst.GetAllWhere(m => m.PackagName == model.PackagName).Count(); - if (rowCount > 0) - { - throw new Exception("鍖呰鍚嶇О宸插瓨鍦�!"); - } + rowCount = await PackagRst.GetAllWhere(m => m.PackagName == model.PackagName).CountAsync(); + if (rowCount > 0) + { + throw Oops.Bah("鍖呰鍚嶇О宸插瓨鍦�!"); + } - SysPackag packagModel = new SysPackag(); - packagModel.PackagNo = model.PackagNo; - packagModel.PackagName = model.PackagName; - packagModel.Level = 0; + SysPackag packagModel = new SysPackag(); + packagModel.PackagNo = model.PackagNo; + packagModel.PackagName = model.PackagName; + packagModel.Level = 0; - //鍒ゆ柇浜旂骇鍖呰鏄惁涓虹┖ - if (!string.IsNullOrEmpty(model.L5Num) && !string.IsNullOrEmpty(model.L5Name)) - { - packagModel.L5Num = int.Parse(model.L5Num); - packagModel.L5Name = model.L5Name; - packagModel.Level += 1; - //鍒ゆ柇鍥涚骇鍖呰鏄惁涓虹┖ - if (string.IsNullOrEmpty(model.L4Num) && string.IsNullOrEmpty(model.L4Name)) - { - return 2; - } - } + //鍒ゆ柇浜旂骇鍖呰鏄惁涓虹┖ + if (!string.IsNullOrEmpty(model.L5Num) && !string.IsNullOrEmpty(model.L5Name)) + { + packagModel.L5Num = int.Parse(model.L5Num); + packagModel.L5Name = model.L5Name; + packagModel.Level += 1; //鍒ゆ柇鍥涚骇鍖呰鏄惁涓虹┖ - if (!string.IsNullOrEmpty(model.L4Num) && !string.IsNullOrEmpty(model.L4Name)) + if (string.IsNullOrEmpty(model.L4Num) && string.IsNullOrEmpty(model.L4Name)) { - packagModel.L4Num = int.Parse(model.L4Num); - packagModel.L4Name = model.L4Name; - packagModel.Level += 1; - //鍒ゆ柇涓夌骇鍖呰鏄惁涓虹┖ - if (string.IsNullOrEmpty(model.L3Num) && string.IsNullOrEmpty(model.L3Name)) - { - return 2; - } + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇娣诲姞!"); } - //鍒ゆ柇涓夌骇鍖呰鏄惁涓虹┖ - if (!string.IsNullOrEmpty(model.L3Num) && !string.IsNullOrEmpty(model.L3Name)) - { - packagModel.L3Num = int.Parse(model.L3Num); - packagModel.L3Name = model.L3Name; - packagModel.Level += 1; - //鍒ゆ柇浜岀骇鍖呰鏄惁涓虹┖ - if (string.IsNullOrEmpty(model.L2Num) && string.IsNullOrEmpty(model.L2Name)) - { - return 2; - } - } - //鍒ゆ柇浜岀骇鍖呰鏄惁涓虹┖ - if (!string.IsNullOrEmpty(model.L2Num) && !string.IsNullOrEmpty(model.L2Name)) - { - packagModel.L2Num = int.Parse(model.L2Num); - packagModel.L2Name = model.L2Name; - packagModel.Level += 1; - //鍒ゆ柇涓�绾у寘瑁呮槸鍚︿负绌� - if (string.IsNullOrEmpty(model.L1Num) && string.IsNullOrEmpty(model.L1Name)) - { - return 2; - } - } - //鍒ゆ柇涓�绾у寘瑁呮槸鍚︿负绌� - if (!string.IsNullOrEmpty(model.L1Num) && !string.IsNullOrEmpty(model.L1Name)) - { - packagModel.L1Num = int.Parse(model.L1Num); - packagModel.L1Name = model.L1Name; - packagModel.Level += 1; - } - else - { - return 2; - } - - packagModel.CreateUser = (int)model.CreateUser; - - int rowNum = PackagRst.Add(packagModel); - if (rowNum > 0) - { - return 1; - } - - return 0; } - catch (Exception e) + //鍒ゆ柇鍥涚骇鍖呰鏄惁涓虹┖ + if (!string.IsNullOrEmpty(model.L4Num) && !string.IsNullOrEmpty(model.L4Name)) { - throw new Exception(e.Message); + packagModel.L4Num = int.Parse(model.L4Num); + packagModel.L4Name = model.L4Name; + packagModel.Level += 1; + //鍒ゆ柇涓夌骇鍖呰鏄惁涓虹┖ + if (string.IsNullOrEmpty(model.L3Num) && string.IsNullOrEmpty(model.L3Name)) + { + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇娣诲姞!"); + } } + //鍒ゆ柇涓夌骇鍖呰鏄惁涓虹┖ + if (!string.IsNullOrEmpty(model.L3Num) && !string.IsNullOrEmpty(model.L3Name)) + { + packagModel.L3Num = int.Parse(model.L3Num); + packagModel.L3Name = model.L3Name; + packagModel.Level += 1; + //鍒ゆ柇浜岀骇鍖呰鏄惁涓虹┖ + if (string.IsNullOrEmpty(model.L2Num) && string.IsNullOrEmpty(model.L2Name)) + { + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇娣诲姞!"); + } + } + //鍒ゆ柇浜岀骇鍖呰鏄惁涓虹┖ + if (!string.IsNullOrEmpty(model.L2Num) && !string.IsNullOrEmpty(model.L2Name)) + { + packagModel.L2Num = int.Parse(model.L2Num); + packagModel.L2Name = model.L2Name; + packagModel.Level += 1; + //鍒ゆ柇涓�绾у寘瑁呮槸鍚︿负绌� + if (string.IsNullOrEmpty(model.L1Num) && string.IsNullOrEmpty(model.L1Name)) + { + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇娣诲姞!"); + } + } + //鍒ゆ柇涓�绾у寘瑁呮槸鍚︿负绌� + if (!string.IsNullOrEmpty(model.L1Num) && !string.IsNullOrEmpty(model.L1Name)) + { + packagModel.L1Num = int.Parse(model.L1Num); + packagModel.L1Name = model.L1Name; + packagModel.Level += 1; + } + else + { + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇娣诲姞!"); + } + + packagModel.CreateUser = (int)model.CreateUser; + + return await PackagRst.AddAsync(packagModel); } /// <summary> @@ -196,117 +184,109 @@ /// </summary> /// <param name="model">鍖呰淇℃伅</param> /// <returns>true锛氭垚鍔� flase锛氬け璐�</returns> - public int EditPackag(AddEditPackagVm model) + public async Task<int> EditPackag(AddEditPackagVm model) { - try + if (string.IsNullOrEmpty(model.PackagName)) { - if (string.IsNullOrEmpty(model.PackagName)) + var date = await PackagRst.GetAllWhere(m => m.Id != model.Id && (m.PackagName == model.PackagName)).CountAsync(); + if (date > 0) { - var date = PackagRst.GetAllWhere(m => m.Id != model.Id && (m.PackagName == model.PackagName)).Count(); - if (date > 0) - { - throw new Exception("鍖呰鍚嶇О宸插瓨鍦�!"); - } + throw Oops.Bah("鍖呰鍚嶇О宸插瓨鍦�!"); } - var packagItems = PackagRst.GetOneById(model.Id); - packagItems.Id = model.Id; //id - packagItems.PackagNo = model.PackagNo; //鍖呰缂栧彿 - packagItems.PackagName = model.PackagName; //鍖呰鎻忚堪 - //packagItems.IsDel = model.IsDel; 鍘熷洜: 淇敼鏃朵笉闇�瑕佷慨鏀笽sDel瀛楁 - packagItems.UpdateTime = DateTime.Now; //淇敼鏃堕棿 - packagItems.UpdateUser = model.CreateUser; //淇敼浜� - packagItems.Level = 0; + } + var packagItems = PackagRst.GetOneById(model.Id); + packagItems.Id = model.Id; //id + packagItems.PackagNo = model.PackagNo; //鍖呰缂栧彿 + packagItems.PackagName = model.PackagName; //鍖呰鎻忚堪 + //packagItems.IsDel = model.IsDel; 鍘熷洜: 淇敼鏃朵笉闇�瑕佷慨鏀笽sDel瀛楁 + packagItems.UpdateTime = DateTime.Now; //淇敼鏃堕棿 + packagItems.UpdateUser = model.CreateUser; //淇敼浜� + packagItems.Level = 0; - //鍒ゆ柇浜旂骇鍖呰鏄惁涓虹┖ - if (!string.IsNullOrEmpty(model.L5Num) && !string.IsNullOrEmpty(model.L5Name)) - { - packagItems.L5Num = int.Parse(model.L5Num); - packagItems.L5Name = model.L5Name; - packagItems.Level += 1; - //鍒ゆ柇鍥涚骇鍖呰鏄惁涓虹┖ - if (string.IsNullOrEmpty(model.L4Num) && string.IsNullOrEmpty(model.L4Name)) - { - return 2; - } - } - else - { - packagItems.L5Num = null; - packagItems.L5Name = null; - } + //鍒ゆ柇浜旂骇鍖呰鏄惁涓虹┖ + if (!string.IsNullOrEmpty(model.L5Num) && !string.IsNullOrEmpty(model.L5Name)) + { + packagItems.L5Num = int.Parse(model.L5Num); + packagItems.L5Name = model.L5Name; + packagItems.Level += 1; //鍒ゆ柇鍥涚骇鍖呰鏄惁涓虹┖ - if (!string.IsNullOrEmpty(model.L4Num) && !string.IsNullOrEmpty(model.L4Name)) + if (string.IsNullOrEmpty(model.L4Num) && string.IsNullOrEmpty(model.L4Name)) { - packagItems.L4Num = int.Parse(model.L4Num); - packagItems.L4Name = model.L4Name; - packagItems.Level += 1; - //鍒ゆ柇涓夌骇鍖呰鏄惁涓虹┖ - if (string.IsNullOrEmpty(model.L3Num) && string.IsNullOrEmpty(model.L3Name)) - { - return 2; - } + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇淇敼 璇烽噸鏂拌緭鍏�"); } - else - { - packagItems.L4Num = null; - packagItems.L4Name = null; - } - //鍒ゆ柇涓夌骇鍖呰鏄惁涓虹┖ - if (!string.IsNullOrEmpty(model.L3Num) && !string.IsNullOrEmpty(model.L3Name)) - { - packagItems.L3Num = int.Parse(model.L3Num); - packagItems.L3Name = model.L3Name; - packagItems.Level += 1; - //鍒ゆ柇浜岀骇鍖呰鏄惁涓虹┖ - if (string.IsNullOrEmpty(model.L2Num) && string.IsNullOrEmpty(model.L2Name)) - { - return 2; - } - } - else - { - packagItems.L3Num = null; - packagItems.L3Name = null; - } - //鍒ゆ柇浜岀骇鍖呰鏄惁涓虹┖ - if (!string.IsNullOrEmpty(model.L2Num) && !string.IsNullOrEmpty(model.L2Name)) - { - packagItems.L2Num = int.Parse(model.L2Num); - packagItems.L2Name = model.L2Name; - packagItems.Level += 1; - //鍒ゆ柇涓�绾у寘瑁呮槸鍚︿负绌� - if (string.IsNullOrEmpty(model.L1Num) && string.IsNullOrEmpty(model.L1Name)) - { - return 2; - } - } - else - { - packagItems.L3Num = null; - packagItems.L3Name = null; - } - //鍒ゆ柇涓�绾у寘瑁呮槸鍚︿负绌� - if (!string.IsNullOrEmpty(model.L1Num) && !string.IsNullOrEmpty(model.L1Name)) - { - packagItems.L1Num = int.Parse(model.L1Num); - packagItems.L1Name = model.L1Name; - packagItems.Level += 1; - } - else - { - packagItems.L1Num = null; - packagItems.L1Name = null; - - return 2; - } - - var rowCount = PackagRst.Edit(packagItems); - return rowCount; } - catch (Exception e) + else { - throw new Exception(e.Message); + packagItems.L5Num = null; + packagItems.L5Name = null; } + //鍒ゆ柇鍥涚骇鍖呰鏄惁涓虹┖ + if (!string.IsNullOrEmpty(model.L4Num) && !string.IsNullOrEmpty(model.L4Name)) + { + packagItems.L4Num = int.Parse(model.L4Num); + packagItems.L4Name = model.L4Name; + packagItems.Level += 1; + //鍒ゆ柇涓夌骇鍖呰鏄惁涓虹┖ + if (string.IsNullOrEmpty(model.L3Num) && string.IsNullOrEmpty(model.L3Name)) + { + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇淇敼 璇烽噸鏂拌緭鍏�"); + } + } + else + { + packagItems.L4Num = null; + packagItems.L4Name = null; + } + //鍒ゆ柇涓夌骇鍖呰鏄惁涓虹┖ + if (!string.IsNullOrEmpty(model.L3Num) && !string.IsNullOrEmpty(model.L3Name)) + { + packagItems.L3Num = int.Parse(model.L3Num); + packagItems.L3Name = model.L3Name; + packagItems.Level += 1; + //鍒ゆ柇浜岀骇鍖呰鏄惁涓虹┖ + if (string.IsNullOrEmpty(model.L2Num) && string.IsNullOrEmpty(model.L2Name)) + { + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇淇敼 璇烽噸鏂拌緭鍏�"); + } + } + else + { + packagItems.L3Num = null; + packagItems.L3Name = null; + } + //鍒ゆ柇浜岀骇鍖呰鏄惁涓虹┖ + if (!string.IsNullOrEmpty(model.L2Num) && !string.IsNullOrEmpty(model.L2Name)) + { + packagItems.L2Num = int.Parse(model.L2Num); + packagItems.L2Name = model.L2Name; + packagItems.Level += 1; + //鍒ゆ柇涓�绾у寘瑁呮槸鍚︿负绌� + if (string.IsNullOrEmpty(model.L1Num) && string.IsNullOrEmpty(model.L1Name)) + { + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇淇敼 璇烽噸鏂拌緭鍏�"); + } + } + else + { + packagItems.L3Num = null; + packagItems.L3Name = null; + } + //鍒ゆ柇涓�绾у寘瑁呮槸鍚︿负绌� + if (!string.IsNullOrEmpty(model.L1Num) && !string.IsNullOrEmpty(model.L1Name)) + { + packagItems.L1Num = int.Parse(model.L1Num); + packagItems.L1Name = model.L1Name; + packagItems.Level += 1; + } + else + { + packagItems.L1Num = null; + packagItems.L1Name = null; + + throw Oops.Bah("鍖呰绛夌骇涓嶅彲瓒婄骇淇敼 璇烽噸鏂拌緭鍏�"); + } + + return await PackagRst.EditAsync(packagItems); } /// <summary> @@ -314,27 +294,19 @@ /// </summary> /// <param name="packagId">鍖呰淇℃伅涓婚敭ID</param> /// <returns>true锛氭垚鍔� flase锛氬け璐�</returns> - public bool DelPackag(int packagId, int userId) + public async Task<bool> DelPackag(int packagId, int userId) { - try + var packagItems = await PackagRst.GetOneByIdAsync(packagId); + if (packagItems == null) { - var packagItems = PackagRst.GetOneById(packagId); - if (packagItems == null) - { - throw new Exception("鍖呰淇℃伅涓嶅瓨鍦紒"); - } - - packagItems.IsDel = "1"; - packagItems.UpdateTime = DateTime.Now; - packagItems.UpdateUser = userId; - - var rowCount = PackagRst.Edit(packagItems); - return rowCount > 0; + throw Oops.Bah("鍖呰淇℃伅涓嶅瓨鍦紒"); } - catch (Exception e) - { - throw new Exception(e.Message); - } + + packagItems.IsDel = "1"; + packagItems.UpdateTime = DateTime.Now; + packagItems.UpdateUser = userId; + + return await PackagRst.EditAsync(packagItems) > 0; } } } -- Gitblit v1.8.0