From 6c3738d337fe68c2008b38ad58861aa4b48d5530 Mon Sep 17 00:00:00 2001 From: DESKTOP-9BNTV8O <DESKTOP-9BNTV8O@163.com> Date: 星期五, 13 十二月 2024 14:46:40 +0800 Subject: [PATCH] 修改问题 --- Wms/WMS.BLL/SysServer/StorageAreaServer.cs | 56 ++++++++++++++++++++++++++------------------------------ 1 files changed, 26 insertions(+), 30 deletions(-) diff --git a/Wms/WMS.BLL/SysServer/StorageAreaServer.cs b/Wms/WMS.BLL/SysServer/StorageAreaServer.cs index 1dc557a..8182074 100644 --- a/Wms/WMS.BLL/SysServer/StorageAreaServer.cs +++ b/Wms/WMS.BLL/SysServer/StorageAreaServer.cs @@ -69,11 +69,12 @@ TypeName = GetTypeName(m.Type),//绫诲埆鍚嶇О Temp = m.Temperature, TempName = m.TemperatureInfo == null ? "" : m.TemperatureInfo.DictName, + DeviceCode=m.DeviceCode, CreateTime = m.CreateTime, CreateUserName = m.CreateUserInfo == null ? "" : m.CreateUserInfo.RealName, UpdateTime = m.UpdateTime, UpdateUserName = m.UpdateUserInfo == null ? "" : m.UpdateUserInfo.RealName - }).ToList(); + }).OrderBy(w=>w.WareHouseNo).OrderBy(w => w.AreaNo).ToList(); } catch (Exception e) { @@ -147,35 +148,20 @@ { try { - string str = ""; - //鍒ゆ柇鎵�灞炰粨搴撴槸鍚︿负绔嬩綋搴� - if (model.WareHouseNo != "W01") + string str = ""; + + var area = Db.Queryable<SysStorageArea>().First(a => a.IsDel == "0" && a.AreaNo == model.AreaNo); + if (area != null) { - str = "-1:鎵�灞炰粨搴撲笉涓虹珛浣撳簱锛岃閲嶆柊閫夋嫨锛�"; - return str; + throw new Exception("褰撳墠鍖哄煙缂栫爜瀵瑰簲鐨勫尯鍩熷凡瀛樺湪"); } - //鑾峰彇绔嬩綋搴撴渶澶х紪鐮� - //var area = Db.Queryable<SysStorageArea>().Max(a => a.Id)(a => a.IsDel == "0" && a.WareHouseNo == "W01"); - var area = Db.Queryable<SysStorageArea>().Where(a => a.IsDel == "0" && a.WareHouseNo == "W01").OrderByDescending(a=>a.CreateTime).First(); - //楠岃瘉鏄惁瀛樺湪绔嬩綋搴撶涓�鏉″尯鍩熶俊鎭� - if (area == null) + if (!string.IsNullOrEmpty(model.DeviceCode)) { - model.AreaNo = "A01"; - } - else - { - var arr = area.AreaNo.Split("A"); - int a = int.Parse(arr[1]) + 1; - //鍒ゆ柇鏄惁灏忎簬10 - if (a < 10) + var area2 = Db.Queryable<SysStorageArea>().First(a => a.IsDel == "0" && a.DeviceCode == model.AreaNo); + if (area2 != null) { - model.AreaNo = "A0" + (int.Parse(arr[1]) + 1).ToString(); + throw new Exception("褰撳墠璁惧缂栫爜瀵瑰簲鐨勫尯鍩熷凡瀛樺湪"); } - else - { - model.AreaNo = "A" + (int.Parse(arr[1]) + 1).ToString(); - } - } Db.BeginTran(); @@ -184,6 +170,7 @@ { AreaNo = model.AreaNo, //鍖哄煙缂栫爜 AreaName = model.AreaName, //鍖哄煙鍚嶇О + DeviceCode=model.DeviceCode,//璁惧缂栫爜 WareHouseNo = model.WareHouseNo, //鎵�灞炰粨搴� RoadwayNo = null, //鎵�灞炲贩閬� Status = model.Status, //鏄惁鍚敤 @@ -220,16 +207,24 @@ /// <param name="temp">瀛樺偍鐜</param> /// <param name="userId">鎿嶄綔浜�</param> /// <returns>鏄惁鎴愬姛</returns> - public bool EditStorageArea(int id, string name, int priority, string type, string temp, int userId) + public bool EditStorageArea(int id, string name, int priority, string type, string temp,string deviceCode, int userId) { try { //鍒ゆ柇闄ゅ綋鍓峣d淇℃伅浠ュ鏄惁鍚湁缂栧彿鍜屽悕绉� - var bol = AreaRst.GetAllAsync() - .Any(m => m.Id != id && m.AreaName == name.Trim()); - if (bol) + //var bol = AreaRst.GetAllAsync() + // .Any(m => m.Id != id && m.AreaName == name.Trim()); + //if (bol) + //{ + // throw new Exception("褰撳墠鍖哄煙鍙锋垨鍖哄煙鍚嶇О宸插瓨鍦�"); + //} + if (!string.IsNullOrEmpty(deviceCode)) { - throw new Exception("褰撳墠鍖哄煙鍙锋垨鍖哄煙鍚嶇О宸插瓨鍦�"); + var bol2 = AreaRst.GetAllAsync().Any(m => m.Id != id && m.DeviceCode == deviceCode.Trim()); + if (bol2) + { + throw new Exception("褰撳墠璁惧缂栫爜瀵瑰簲鐨勫尯鍩熷凡瀛樺湪"); + } } var area = AreaRst.GetOneById(id); @@ -242,6 +237,7 @@ area.Priority = priority; area.Type = type; area.Temperature = temp; + area.DeviceCode = deviceCode; area.UpdateUser = userId; area.UpdateTime = DateTime.Now; var num = AreaRst.Edit(area); -- Gitblit v1.8.0