From 1650f3fe1467d21074b597042861c46f3a8c4447 Mon Sep 17 00:00:00 2001 From: zhaowc <526854230@qq.com> Date: 星期二, 01 四月 2025 10:11:24 +0800 Subject: [PATCH] 问题修改 --- Wms/Wms/Controllers/SysController.cs | 510 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 495 insertions(+), 15 deletions(-) diff --git a/Wms/Wms/Controllers/SysController.cs b/Wms/Wms/Controllers/SysController.cs index 8ef43b0..607e3bb 100644 --- a/Wms/Wms/Controllers/SysController.cs +++ b/Wms/Wms/Controllers/SysController.cs @@ -20,6 +20,8 @@ using System.Security.Cryptography; using Model.ModelDto; using Model.ModelDto.LogDto; +using Newtonsoft.Json.Linq; +using Model.ModelVm.LogVm; namespace Wms.Controllers { @@ -41,6 +43,9 @@ private readonly IOperationSysServer _operation; //鎿嶄綔鏃ュ織 private readonly IExceptionServer _table; //寮傚父澶勭悊 private readonly IHeaderSettingsServer _headerSet;//琛ㄥご璁剧疆 + + private readonly IMaterialCategoryServer _category;//鐗╂枡绫诲埆 + /// <summary> /// 鏋勯�犲嚱鏁� /// </summary> @@ -54,7 +59,8 @@ /// <param name="dic">鏁版嵁瀛楀吀</param> /// <param name="operation">鎿嶄綔鏃ュ織</param> /// <param name="table">寮傚父澶勭悊</param> - public SysController(IWareHouseServer wareHouseSvc, IStorageAreaServer areaSvc, IStorageRoadwayServer roadwaySvc, IStorageLocatServer locatSvc, IPalletsServer palletSvc, IPalletTrackServer palletTrackSvc, IMenuServer menuSvc, IDictionaryServer dic, IOperationSysServer operation, IExceptionServer table, IHeaderSettingsServer headerSet) + /// <param name="category">鐗╂枡绫诲埆</param> + public SysController(IWareHouseServer wareHouseSvc, IStorageAreaServer areaSvc, IStorageRoadwayServer roadwaySvc, IStorageLocatServer locatSvc, IPalletsServer palletSvc, IPalletTrackServer palletTrackSvc, IMenuServer menuSvc, IDictionaryServer dic, IOperationSysServer operation, IExceptionServer table, IHeaderSettingsServer headerSet, IMaterialCategoryServer category) { _wareHouseSvc = wareHouseSvc; //浠撳簱 _areaSvc = areaSvc; //鍖哄煙 @@ -69,6 +75,7 @@ _table = table; //寮傚父澶勭悊 _headerSet = headerSet;//琛ㄥご璁剧疆 + _category = category;//鐗╂枡绫诲埆 } #region 鑿滃崟绠$悊 @@ -225,7 +232,7 @@ } catch (Exception ex) { - return Ok(new { data = "", code = 3, msg = "鏂板鑿滃崟淇℃伅寮傚父锛�"+ ex.Message }); + return Ok(new { data = "", code = 3, msg = "鏂板鑿滃崟淇℃伅寮傚父锛�" + ex.Message }); } } @@ -729,6 +736,50 @@ return Ok(new { code = 1, msg = e.Message }); } } + + /// <summary> + /// 娣诲姞鍖哄煙淇℃伅 + /// </summary> + /// <param name="model">妯″瀷</param> + /// <returns></returns> + [HttpPost] + public IActionResult InsertStorageArea(SysStorageArea model) + { + try + { + //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D + var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(userId)) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + model.CreateUser = int.Parse(userId); + string bolls = _areaSvc.InsertStorageArea(model); + var arr = bolls.Split(":"); + if (arr[0] != "-1") + { + SysStorageArea area = _areaSvc.GetStorageMaxArea(); + _operation.InsertOperation("浠撳簱璁剧疆", "鍖哄煙绠$悊", area.AreaNo, "娣诲姞", "娣诲姞鍖哄煙淇℃伅 鍖哄煙鍙凤細" + area.AreaNo, Convert.ToInt32(userId)); + return Ok(new { code = 0, msg = bolls, data = "" }); + } + else + { + return Ok(new { code = 1, msg = bolls, data = "" }); + } + + } + catch (Exception e) + { + return Ok(new { code = 1, msg = e.Message }); + } + + } + /// <summary> /// 淇敼鍖哄煙淇℃伅 /// </summary> @@ -1006,7 +1057,7 @@ } } /// <summary> - /// 娣诲姞鍌ㄤ綅淇℃伅 + /// 娣诲姞绔嬩綋搴撳偍浣嶄俊鎭� /// </summary> /// <param name="model">妯″瀷</param> /// <returns></returns> @@ -1051,6 +1102,54 @@ return Ok(new { code = 400, ErrorMsg = "鏁版嵁鏍煎紡閿欒" }); } } + + /// <summary> + /// 娣诲姞骞冲簱鍌ㄤ綅淇℃伅 + /// </summary> + /// <param name="model">妯″瀷</param> + /// <returns></returns> + [AllowAnonymous] + [HttpPost] + public async Task<IActionResult> AddPkStorageLocat(AddLocateVm model) + { + if (ModelState.IsValid) + { + try + { + //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D + //var claimsIdentity = this.User.Identity as ClaimsIdentity; + //if (claimsIdentity == null) + //{ + // return Ok(new { code = 400, ErrorMsg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + //} + //var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + //if (string.IsNullOrWhiteSpace(userId)) + //{ + // return Ok(new { code = 400, ErrorMsg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + //} + var bolls = await _locatSvc.AddPkStorageLocat(model, 1); + if (bolls > 0) + { + await _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", model.RoadwayNo, "娣诲姞", "娣诲姞鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + model.RoadwayNo, 1); + return Ok(new { code = 200, ErrorMsg = "娣诲姞鎴愬姛", data = bolls }); + } + else + { + return Ok(new { code = 400, ErrorMsg = "娣诲姞澶辫触", data = "" }); + } + + } + catch (Exception e) + { + return Ok(new { code = 400, ErrorMsg = "璇疯仈绯荤鐞嗗憳/" + e.Message }); + } + } + else //鏁版嵁鏍煎紡閿欒 + { + return Ok(new { code = 400, ErrorMsg = "鏁版嵁鏍煎紡閿欒" }); + } + } + /// <summary> /// 淇敼鍌ㄤ綅淇℃伅 /// </summary> @@ -1128,17 +1227,22 @@ string msg = "鍌ㄤ綅鐘舵�� 鍌ㄤ綅鍙凤細" + storage.RoadwayNo; if (model.Id.Count > 1) { - foreach (var item in model.Id) + var sstorage = _locatSvc.GetStorageLocat(model.Id); + foreach (var item in sstorage) { - storage = _locatSvc.GetStorageLocat(item); - _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", storage.LocatNo, "鎵归噺缂栬緫", "鎵归噺淇敼鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + storage.LocatNo, Convert.ToInt32(userId)); + _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", item.LocatNo, "鎵归噺缂栬緫", "鎵归噺淇敼鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + item.LocatNo, Convert.ToInt32(userId)); } + //foreach (var item in model.Id) + //{ + // storage = _locatSvc.GetStorageLocat(item); + // _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", storage.LocatNo, "鎵归噺缂栬緫", "鎵归噺淇敼鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + storage.LocatNo, Convert.ToInt32(userId)); + //} } else { _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", storage.LocatNo, "淇敼", "淇敼鍌ㄤ綅淇℃伅 鍌ㄤ綅鍙凤細" + storage.LocatNo, Convert.ToInt32(userId)); } - + return Ok(new { code = 0, msg = "缂栬緫鎴愬姛", data = "" }); } else @@ -1157,6 +1261,47 @@ return Ok(new { code = 1, msg = "鏁版嵁鏍煎紡閿欒" }); } } + + /// <summary> + /// 淇敼鍌ㄤ綅鐘舵�佹爣璇嗕俊鎭泦鍚� + /// </summary> + /// <param name="model">妯″瀷</param> + /// <returns></returns> + [HttpPost] + public IActionResult EditStorageLocatListNew (EditLocateListNewVm model) + { + try + { + //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D + var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(userId)) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + var bolls = _locatSvc.EditStorageLocatListNew(model, int.Parse(userId)); + if (bolls) + { + _operation.InsertOperation("浠撳簱璁剧疆", "鍌ㄤ綅绠$悊", "", "淇敼", $"淇敼宸烽亾锛歿model.RoadWayNo}銆佹帓:{model.Row}銆佸垪:{model.Column}銆佸眰:{model.Layer}銆佹繁搴︼細{model.Dept}鐨勫尯鍩燂細{model.AreaNo}銆佺姸鎬�:{model.Status}銆佹爣璇嗭細{model.Flag}鐨勫偍浣嶄俊鎭� ", Convert.ToInt32(userId)); + + return Ok(new { code = 0, msg = "缂栬緫鎴愬姛", data = "" }); + } + else + { + return Ok(new { code = 1, msg = "缂栬緫澶辫触", data = "" }); + } + + } + catch (Exception e) + { + return Ok(new { code = 1, msg = e.Message }); + } + } + #endregion #region 鎵樼洏鏉$爜绠$悊 @@ -1271,17 +1416,21 @@ { throw new Exception("褰撳墠鏄剧ず鐨勬潯鐮佷笉鏄渶鏂版潯鐮侊紝璇烽噸鏂版坊鍔�"); } - string str = model.PalletNo.Substring(3, 5); - string remove = model.PalletNo.Substring(0, 3); + string str = model.PalletNo.Substring(2, 6); + string remove = model.PalletNo.Substring(0, 2); int sibelius = Convert.ToInt16(str); for (int i = 0; i < model.GroupCount; i++) { + if (sibelius>999999) + { + throw new Exception("鎵樼洏缁勪腑宸叉湁鎵樼洏鐮佷綅鏁板凡杈句笂绾�"); + } if (i != 0) { sibelius += 1; } - string code = remove + Convert.ToString(sibelius).PadLeft(5, '0'); + string code = remove + Convert.ToString(sibelius).PadLeft(6, '0'); for (int j = 0; j < model.SameCount; j++) { var re = BarcodeHelper.GetCodeBarBase64(code, 80, 50); @@ -1384,11 +1533,11 @@ int uid = Convert.ToInt32(userId); //鏇存敼浜� tabledto.UpdateUser = uid; - string strMesage = _table.EditStatus(tabledto); + string strMesage = _table.EditStatus(tabledto); if (strMesage == "") { return Ok(new { code = 0, msg = "澶勭悊鎴愬姛" }); - } + } else { return Ok(new { code = 1, msg = strMesage }); @@ -1438,18 +1587,20 @@ #region 鍌ㄤ綅鍥句緥 + #region 绔嬪簱 /// <summary> /// 鏍规嵁浠撳簱 鎺� /// </summary> /// <param name="wareHouseNo">浠撳簱</param> /// <param name="roadway">宸烽亾鍙�</param> /// <param name="row">鎺�</param> + /// <param name="depth">娣卞害</param> /// <returns></returns> [HttpGet] - public IActionResult GetStorageLocatLists(string wareHouseNo, string roadway,string row) + public IActionResult GetStorageLocatLists(string wareHouseNo, string roadway, string row, string depth) { //鑾峰彇鍌ㄤ綅淇℃伅 - List<SysStorageLocat> storagelist = _locatSvc.GetStorageLocatLists(wareHouseNo, roadway, row); + List<SysStorageLocat> storagelist = _locatSvc.GetStorageLocatLists(wareHouseNo, roadway, row, depth); //鑾峰彇鏈�澶у眰绾� int maxLayer = _locatSvc.GetMaxLayer(wareHouseNo, roadway, row); @@ -1527,7 +1678,7 @@ [HttpGet] public IActionResult GetStorageProportion1(string wareHouseNo, string roadwayNo) { - List<GetLocateVm> getLocateVms = _locatSvc.GetStorageProportion1(wareHouseNo,roadwayNo); + List<GetLocateVm> getLocateVms = _locatSvc.GetStorageProportion1(wareHouseNo, roadwayNo); return Ok(new { data = getLocateVms, @@ -1552,6 +1703,41 @@ msg = "鑾峰彇浠撳簱宸烽亾鎴愬姛" }); } + + + + #endregion + + #region 骞冲簱 + + /// <summary> + /// 鏍规嵁浠撳簱 鎺� + /// </summary> + /// <param name="wareHouseNo">浠撳簱</param> + /// <param name="row">鎺�</param> + /// <param name="depth">娣卞害</param> + /// <returns></returns> + [HttpGet] + public IActionResult GetFlatLibraryLegend(string wareHouseNo, string row) + { + //鑾峰彇鍌ㄤ綅淇℃伅 + List<SysStorageLocat> storagelist = _locatSvc.GetFlatLibraryLegend(wareHouseNo, row); + + //Dictionary<string, int> dic = new Dictionary<string, int>() + //{ + // "B01" + //}; + + return Ok(new + { + data = storagelist, + //dic, + code = 0, + msg = "" + }); + } + + #endregion /// <summary> /// 鏍规嵁鍌ㄤ綅鍦板潃鑾峰彇鍌ㄤ綅涓婄殑鎵樼洏鍜岀墿鍝佷俊鎭� @@ -1586,7 +1772,301 @@ #endregion + #region 鐗╂枡绫诲埆 + /// <summary> + /// 鑾峰彇鐗╂枡绫诲埆淇℃伅 + /// </summary> + /// <param name="categoryName">绫诲埆鍚嶇О</param> + /// <param name="areaNo">鍖哄煙缂栫爜</param> + /// <returns></returns> + /// <exception cref="Exception"></exception> + [HttpGet] + public IActionResult GetMaterialCategories(string categoryName, string areaNo) + { + try + { + var list = _category.GetMaterialCategories(categoryName, areaNo); + return Ok(new + { + data = list, + code = 1, + msg = "鑾峰彇鐗╂枡閫昏緫搴撳尯淇℃伅鎴愬姛" + }); + } + catch (Exception ex) + { + return Ok(new + { + data = "", + code = 0, + msg = ex.Message + }); + } + } + + /// <summary> + /// 鑾峰彇鐗╂枡绫诲埆涓嬫媺鑿滃崟淇℃伅 + /// </summary> + /// <returns></returns> + /// <exception cref="Exception"></exception> + [HttpGet] + public IActionResult GetMaterialCategories1() + { + try + { + var list = _category.GetMaterialCategories(); + return Ok(new + { + data = list, + code = 1, + msg = "鑾峰彇鐗╂枡閫昏緫搴撳尯淇℃伅鎴愬姛" + }); + } + catch (Exception ex) + { + return Ok(new + { + data = "", + code = 0, + msg = ex.Message + }); + } + } + + + /// <summary> + /// 鏍规嵁Id鑾峰彇鐗╂枡绫诲埆淇℃伅 + /// </summary> + /// <param name="Id">Id</param> + /// <returns></returns> + /// <exception cref="Exception"></exception> + [HttpGet] + public IActionResult GetMaterialCategoriesById(int Id) + { + try + { + var list = _category.GetMaterialCategoriesById(Id); + return Ok(new + { + data = list, + code = 1, + msg = "鏍规嵁Id鑾峰彇閫昏緫搴撳尯淇℃伅鎴愬姛" + }); + } + catch (Exception ex) + { + return Ok(new + { + data = "", + code = 0, + msg = ex.Message + }); + } + } + + /// <summary> + /// 鑾峰彇鍖哄煙淇℃伅 + /// </summary> + /// <returns></returns> + [HttpGet] + public IActionResult GetStorageAreaList() + { + try + { + var bolls = _category.GetStorageAreaList(); + + List<XmSelectDto> list = new List<XmSelectDto>(); + + foreach (var item in bolls) + { + XmSelectDto list1 = new XmSelectDto() + { + name = item.AreaName, //鍖哄煙鍚嶇О + value = item.AreaNo, //鍖哄煙鍙� + selected = false, //鏄惁閫変腑 + }; + list.Add(list1); + } + + return Ok(new { code = 0, msg = "鍖哄煙淇℃伅", data = bolls, list }); + } + catch (Exception e) + { + return Ok(new { code = 1, msg = e.Message }); + } + } + + /// <summary> + /// 鏂板绫诲埆淇℃伅 + /// </summary> + /// <param name="category">鐗╂枡绫诲埆瀹炰綋</param> + /// <returns></returns> + /// <exception cref="Exception"></exception> + [HttpPost] + public IActionResult InsertMaterialCategories(SysMaterialCategory category) + { + try + { + //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D + var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(userId)) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + category.CreateUser = int.Parse(userId); + + var list = _category.InsertMaterialCategories(category); + + _operation.InsertOperation("鍩虹淇℃伅", "閫昏緫搴撳尯", category.CategoryNo, "娣诲姞", "娣诲姞閫昏緫搴撳尯淇℃伅 閫昏緫搴撳尯鍙凤細" + category.CategoryNo, Convert.ToInt32(userId)); + + return Ok(new + { + data = list, + code = 1, + msg = "鏂板鐗╂枡閫昏緫搴撳尯淇℃伅鎴愬姛" + }); + + + } + catch (Exception ex) + { + return Ok(new + { + data = "", + code = 0, + msg = ex.Message + }); + } + } + + /// <summary> + /// 缂栬緫绫诲埆淇℃伅 + /// </summary> + /// <param name="category">鐗╂枡绫诲埆瀹炰綋</param> + /// <returns></returns> + /// <exception cref="Exception"></exception> + [HttpPost] + public IActionResult ExitMaterialCategories(SysMaterialCategory category) + { + try + { + //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D + var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(userId)) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + category.UpdateUser = int.Parse(userId); + + var list = _category.ExitMaterialCategories(category); + + _operation.InsertOperation("鍩虹淇℃伅", "閫昏緫搴撳尯", category.CategoryNo, "缂栬緫", "缂栬緫閫昏緫搴撳尯淇℃伅 閫昏緫搴撳尯鍙凤細" + category.CategoryNo, Convert.ToInt32(userId)); + + return Ok(new + { + data = list, + code = 1, + msg = "缂栬緫鐗╂枡閫昏緫搴撳尯淇℃伅鎴愬姛" + }); + + + } + catch (Exception ex) + { + return Ok(new + { + data = "", + code = 0, + msg = ex.Message + }); + } + } + + /// <summary> + /// 鍒犻櫎绫诲埆淇℃伅 + /// </summary> + /// <param name="category">鐗╂枡绫诲埆瀹炰綋</param> + /// <returns></returns> + /// <exception cref="Exception"></exception> + [HttpPost] + public IActionResult DeleteMaterialCategories(MaterialCategoryDto category) + { + try + { + //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D + var claimsIdentity = this.User.Identity as ClaimsIdentity; + if (claimsIdentity == null) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; + if (string.IsNullOrWhiteSpace(userId)) + { + return Ok(new { code = 1, msg = "涓鸿幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" }); + } + category.UpdateUser = userId; + + var list = _category.DeleteMaterialCategories(category); + + _operation.InsertOperation("鍩虹淇℃伅", "閫昏緫搴撳尯", category.CategoryNo, "鍒犻櫎", "鍒犻櫎閫昏緫搴撳尯淇℃伅 閫昏緫搴撳尯鍙凤細" + category.CategoryNo, Convert.ToInt32(userId)); + + return Ok(new + { + data = list, + code = 1, + msg = "鍒犻櫎鐗╂枡閫昏緫搴撳尯淇℃伅鎴愬姛" + }); + + + } + catch (Exception ex) + { + return Ok(new + { + data = "", + code = 0, + msg = ex.Message + }); + } + } + + #endregion + + #region 鎿嶄綔鏃ュ織 + + /// <summary> + /// 鑾峰彇鎿嶄綔鏃ュ織淇℃伅 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [AllowAnonymous] + [HttpPost] + public IActionResult GetLogOperationList(GetOperationVm model) + { + try + { + var bolls = _operation.GetOperationList(model.MenuName, model.Type, model.Msg, model.StartTime, model.EndTime, model.Page, model.Limit, out int count); + + return Ok(new { code = 0, count, msg = "鎿嶄綔鏃ュ織淇℃伅", data = bolls }); + } + catch (Exception e) + { + return Ok(new { code = 1, msg = e.Message }); + } + } + + #endregion #region 鏁版嵁琛ㄦ牸琛ㄥご鑷畾涔�(閫氱敤鏂规硶) /// <summary> -- Gitblit v1.8.0