From 829eabf256e29392ca63f6da48829dba3b075dfe Mon Sep 17 00:00:00 2001 From: huanghongfeng <huanghongfeng@hnkhzn.com> Date: 星期五, 24 一月 2025 08:59:53 +0800 Subject: [PATCH] 资料,优化程序 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs | 712 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 612 insertions(+), 100 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs" index 276f81e..48b9dfe 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs" @@ -14,6 +14,10 @@ using System.Diagnostics; using Newtonsoft.Json; using System.Security.Policy; +using static WIDESEA_ITaskInfoService.ITaskService; +using MailKit.Search; +using WIDESEA_Common.Log; +using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; namespace WIDESEA_TaskInfoService { @@ -400,7 +404,7 @@ } targetCodes[4] = "01"; string LocationCode = string.Join("-", targetCodes); //缁勮娴呭簱浣嶅湴鍧� - Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode); + Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode && (x.LocationStatus == (int)LocationStatusEnum.Free || x.LocationStatus == (int)LocationStatusEnum.InStock)); if (locationInfos == null) { return content = WebResponseContent.Instance.Error($"鏈壘鍒拌璐т綅淇℃伅,璐т綅缂栧彿:{locationInfos}"); @@ -409,11 +413,11 @@ { if (locationInfos.LocationStatus == (int)LocationStatusEnum.Free) //鍒ゆ柇娴呰揣浣嶆槸鍚︽湁璐� { - return content = WebResponseContent.Instance.OK(data: TaskNum); + return content = WebResponseContent.Instance.OK(); } else { - Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode); + Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode && x.StockStatus== (int)StockStatusEmun.宸插叆搴�); if (dt_StockInfo == null) { return content = WebResponseContent.Instance.Error($"鏈壘鍒拌璐т綅鐨勫簱瀛樹俊鎭�,璐т綅缂栧彿:{LocationCode}"); @@ -422,7 +426,36 @@ { Dt_LocationInfo newLocation; //鏌ヨ蛋璐т綅锛岃繘琛岀敓鎴愮Щ搴撲换鍔� - newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo); //鎷垮埌浜嗙Щ搴撳悗鐨勮揣浣� + int Locationtype = 9; //榛樿涓�9 + if (dt_StockInfo.MaterialType == (int)InventoryMaterialType.鎴愬搧) + { + Locationtype = 11; + } + else if (dt_StockInfo.MaterialType == (int)InventoryMaterialType.鍘熸潗鏂�) + { + Locationtype = 10; + } + //newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo,Locationtype); //鎷垮埌浜嗙Щ搴撳悗鐨勮揣浣� + if (dt_StockInfo.MaterialType == (int)InventoryMaterialType.鎴愬搧) + { + string[] targetCodesst = dt_StockInfo.PalletCode.Split("*"); + Dt_InboundOrder dt_Inbound = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.OrderName == targetCodesst[0]); + if (dt_Inbound.Startingcolumn != 0 || dt_Inbound.Terminationcolumn != 0) + { + newLocation = _basicService.LocationInfoService.GetLocation2(locationInfos.RoadwayNo, Locationtype, dt_Inbound.Startingcolumn, dt_Inbound.Terminationcolumn); + } + else + { + newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype); + } + + } + else + { + newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype); + } + + if (newLocation != null) { Dt_Task dt_Task = new() @@ -439,6 +472,7 @@ Creater = "WMS", CreateDate = DateTime.Now, TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), + MaterialType = dt_StockInfo.MaterialType }; _unitOfWorkManage.BeginTran(); if (locationInfos.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) @@ -455,6 +489,7 @@ loca.Add(newLocation); loca.Add(locationInfos); _basicService.LocationInfoService.UpdateData(loca); + BaseDal.AddData(dt_Task); _unitOfWorkManage.CommitTran(); return content = WebResponseContent.Instance.OK(data: dt_Task); } @@ -477,76 +512,95 @@ public string ReceiveWMSTask = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTask"]; - + /// <summary> /// 鎺ユ敹璧风偣闇�瑕佺殑绌烘墭鐩樿繘琛屽嚭搴� /// </summary> /// <param name="SourceAddress"></param> /// <returns></returns> - public WebResponseContent Empty_outbound(string SourceAddress) + public WebResponseContent Empty_outbound(GenerateInv generate) { WebResponseContent content = new WebResponseContent(); - - try { - Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.RoadwayNo == "2" && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()); - if (locationInfos != null) + Dt_Task task = BaseDal.QueryFirst(x => x.TargetAddress == generate.SourceAddress); + if (task == null) { - Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == locationInfos.LocationCode); - if (dt_StockInfo != null) + string RoadwayNo = "1"; + if (generate.SourceAddress != "R01-002-041-001-01") { - Dt_LocationInfo newSourceAddress; - newSourceAddress = _basicService.LocationInfoService.GetLocationplatform(SourceAddress); - if (newSourceAddress != null) - { - Dt_Task dt_Task = new() - { - PalletCode = dt_StockInfo.PalletCode, - TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), - Roadway = locationInfos.RoadwayNo, - TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(), - TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), - SourceAddress = locationInfos.LocationCode, - TargetAddress = newSourceAddress.LocationCode, - CurrentAddress = locationInfos.LocationCode, - NextAddress = newSourceAddress.LocationCode, - Grade = 1, - Creater = "WMS", - Depth = locationInfos.Depth, - CreateDate = DateTime.Now, - PalletCodequantity = (int)dt_StockInfo.Materialweight, - }; + RoadwayNo = "2"; + } + Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.RoadwayNo == RoadwayNo && x.EnableStatus != (int)EnableStatusEnum.Disable && x.Depth==1 && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()); + if(locationInfos == null) + { + locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.RoadwayNo == RoadwayNo && x.Depth == 2 && x.EnableStatus != (int)EnableStatusEnum.Disable && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()); + } - _unitOfWorkManage.BeginTran(); - dt_StockInfo.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾; - dt_StockInfo.Remark = "绛夊緟鍫嗗灈鏈哄畬鎴愬嚭搴撲换鍔�"; - if (locationInfos.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) + if (locationInfos != null) + { + Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == locationInfos.LocationCode); + if (dt_StockInfo != null && dt_StockInfo.MaterialType == (int)InventoryMaterialType.绌烘墭) + { + + + Dt_LocationInfo newSourceAddress; + newSourceAddress = _basicService.LocationInfoService.GetLocationplatform(generate.SourceAddress); + if (newSourceAddress != null) { - locationInfos.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); + Dt_Task dt_Task = new() + { + PalletCode = dt_StockInfo.PalletCode, + TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), + Roadway = locationInfos.RoadwayNo, + TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(), + TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), + SourceAddress = locationInfos.LocationCode, + TargetAddress = newSourceAddress.LocationCode, + CurrentAddress = locationInfos.LocationCode, + NextAddress = newSourceAddress.LocationCode, + Grade = 1, + Creater = "WMS", + Depth = locationInfos.Depth, + CreateDate = DateTime.Now, + PalletCodequantity = (int)dt_StockInfo.Materialweight, + MaterialType = dt_StockInfo.MaterialType + }; + + _unitOfWorkManage.BeginTran(); + dt_StockInfo.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾; + dt_StockInfo.Remark = "绛夊緟鍫嗗灈鏈哄畬鎴愬嚭搴撲换鍔�"; + if (locationInfos.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) + { + locationInfos.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); + } + BaseDal.AddData(dt_Task); + _basicService.LocationInfoService.UpdateData(locationInfos); + _stockService.StockInfoService.Repository.UpdateData(dt_StockInfo); + _unitOfWorkManage.CommitTran(); + + return content = WebResponseContent.Instance.OK(data: dt_Task); } - BaseDal.AddData(dt_Task); - _basicService.LocationInfoService.UpdateData(locationInfos); - _stockService.StockInfoService.Repository.UpdateData(dt_StockInfo); - _unitOfWorkManage.CommitTran(); - - return content = WebResponseContent.Instance.OK(data: dt_Task); + else + { + return content = WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙扮紪鍙凤紝缂栧彿锛歿generate.SourceAddress}"); + } } else { - return content = WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙扮紪鍙凤紝缂栧彿锛歿SourceAddress}"); + return content = WebResponseContent.Instance.Error($"鏃犺搴撲綅绌烘墭涓哄簱瀛樹俊鎭紝搴撲綅缂栧彿锛歿locationInfos.LocationCode}"); } + } else { - return content = WebResponseContent.Instance.Error($"璇ュ簱浣嶇┖鎵樹负搴撳瓨淇℃伅锛屽簱浣嶇紪鍙凤細{locationInfos.LocationCode}"); + return content = WebResponseContent.Instance.Error($"璇ュ贩閬撳凡鏃犵┖鎵樼洏锛屽贩閬撳彿:{RoadwayNo}宸烽亾"); } - } else { - return content = WebResponseContent.Instance.Error("璇ュ贩閬撳凡鏃犵┖鎵樼洏锛屽贩閬撳彿:2宸烽亾"); + return content = WebResponseContent.Instance.Error($"宸叉湁璇ョ珯鍙扮殑绌烘墭鍑哄簱浠诲姟锛岀珯鍙扮紪鍙穥generate.SourceAddress}"); } } catch (Exception ex) @@ -554,6 +608,71 @@ _unitOfWorkManage.RollbackTran(); return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛屾姤閿欎俊鎭細{ex.Message}"); throw; + } + } + + + /// <summary> + /// 鎺ユ敹璧风偣闇�瑕佺殑绌烘墭鐩樿繘琛屽嚭搴� + /// </summary> + /// <param name="SourceAddress"></param> + /// <returns></returns> + public WebResponseContent Rawmaterialout(GenerateInv3 generate) + { + WebResponseContent content = new WebResponseContent(); + List<Dt_StockInfo> dt_StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.PalletCode.Contains(generate.PalletCode) && x.MaterialType== (int)InventoryMaterialType.鍘熸潗鏂�).OrderBy(x=>x.CreateDate).Take(generate.outCount).ToList(); + + if(dt_StockInfo.Count > 0) + { + for (int i = 0; i < dt_StockInfo.Count; i++) + { + Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == dt_StockInfo[i].LocationCode); //纭璐т綅淇℃伅鏄惁瀵逛笂 + if (locationinfo != null) + { + Dt_Task dt_Task = new() + { + PalletCode = dt_StockInfo[i].PalletCode, + TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), + Roadway = locationinfo.RoadwayNo, + TaskType = TaskTypeEnum.Outbound.ObjToInt(), + TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), + SourceAddress = locationinfo.LocationCode, + TargetAddress = locationinfo.RoadwayNo == "1" ? "R01-002-041-011-01" : "R02-002-027-011-01", + CurrentAddress = locationinfo.LocationCode, + NextAddress = locationinfo.RoadwayNo == "1" ? "R01-002-041-011-01" : "R02-002-027-011-01", + Grade = 1, + Creater = "WMS", + Depth = locationinfo.Depth, + CreateDate = DateTime.Now, + PalletCodequantity = (int)dt_StockInfo[i].Materialweight, + PLCTo = generate.TargetAddress == "R01-002-041-011-01" ? 1 : 2, + MaterialType = dt_StockInfo[i].MaterialType + }; + + _unitOfWorkManage.BeginTran(); + dt_StockInfo[i].StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾; + dt_StockInfo[i].Remark = "绛夊緟鍫嗗灈鏈哄畬鎴愬嚭搴撲换鍔�"; + if (locationinfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) + { + locationinfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + } + BaseDal.AddData(dt_Task); + _basicService.LocationInfoService.UpdateData(locationinfo); + _stockService.StockInfoService.Repository.UpdateData(dt_StockInfo); + _unitOfWorkManage.CommitTran(); + + content = WebResponseContent.Instance.OK(data: dt_Task); + } + else + { + content = WebResponseContent.Instance.Error($"鐗╂枡淇℃伅涓庤揣浣嶄俊鎭笉瀵癸紝鎵樼洏鍙凤細{dt_StockInfo[i].PalletCode}"); + } + } + return content; + } + else + { + return content = WebResponseContent.Instance.Error($"鏈壘鍒板嚭搴撶殑搴撳瓨淇℃伅"); } } @@ -565,7 +684,6 @@ public WebResponseContent ManualOutbound(SaveModel saveModel) { WebResponseContent content = new WebResponseContent(); - try { List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); @@ -575,69 +693,84 @@ for (int i = 0; i < saveModel.DelKeys.Count; i++) { Dt_StockInfo stockt = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == saveModel.DelKeys[i].ToString()); - Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockt.Id); - stockt.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾; - if(stockt.MaterialType != (int)InventoryMaterialType.绌烘墭) + if (stockt.StockStatus == (int)StockStatusEmun.宸插叆搴� && (stockt.Wlstatus == (int)InventoryMaterialStatus.鍚堟牸 || stockt.Wlstatus == (int)InventoryMaterialStatus.杩斿伐)) { - stocktdetail.Status = (int)StockStatusEmun.鍑哄簱閿佸畾; - } - - - Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockt.LocationCode); - if (locationinfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) - { - locationinfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); - } - else if (locationinfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) - { - locationinfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); - } - string LocationName = "R00-000-001-001-01"; - if (stockt.MaterialType == (int)InventoryMaterialType.鍘熸潗鏂�) - { - if (locationinfo.RoadwayNo == "1") + if(stockt.MaterialType != (int)InventoryMaterialType.鍘熸潗鏂�) { - LocationName = "R01-002-000-005-01"; + Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockt.Id); + stockt.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾; + if (stockt.MaterialType != (int)InventoryMaterialType.绌烘墭) + { + stocktdetail.Status = (int)StockStatusEmun.鍑哄簱閿佸畾; + } + Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockt.LocationCode); + if (locationinfo.RoadwayNo == "1") + { + if (locationinfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) + { + locationinfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + } + else if (locationinfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) + { + locationinfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); + } + string LocationName = "R01-002-044-001-01"; + if (stockt.MaterialType == (int)InventoryMaterialType.绌烘墭) + { + LocationName = "R01-002-043-001-01"; + } + Dt_LocationInfo newTargetAddress; + newTargetAddress = _basicService.LocationInfoService.GetLocationplatform(LocationName); + Dt_Task dt_Task = new() + { + PalletCode = stockt.PalletCode, + TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), + Roadway = newTargetAddress.RoadwayNo, + TaskType = TaskTypeEnum.Outbound.ObjToInt(), + TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), + SourceAddress = locationinfo.LocationCode, + TargetAddress = newTargetAddress.LocationCode, + CurrentAddress = locationinfo.LocationCode, + NextAddress = newTargetAddress.LocationCode, + Grade = 1, + Creater = "WMS", + Depth = locationinfo.Depth, + CreateDate = DateTime.Now, + MaterialType= stockt.MaterialType + }; + dtstockt.Add(stockt); + locations.Add(locationinfo); + taskdt.Add(dt_Task); + if (stockt.MaterialType != (int)InventoryMaterialType.绌烘墭) + { + dtstocktdetail.Add(stocktdetail); + } + } + else + { + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛屽彧鍙嚭搴�1宸烽亾鐨勬墭鐩樺拰鎴愬搧锛屽嚭搴撴潯鐮侊細{saveModel.DelKeys[i].ToString()}"); + } } else { - LocationName = "R02-002-000-005-01"; + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛岃涓嶈閫夋嫨鍘熸潗鏂欏嚭搴擄紝鍑哄簱鏉$爜锛歿saveModel.DelKeys[i].ToString()}"); } } - Dt_LocationInfo newTargetAddress; - newTargetAddress = _basicService.LocationInfoService.GetLocationplatform(LocationName); - Dt_Task dt_Task = new() + else { - PalletCode = stockt.PalletCode, - TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), - Roadway = newTargetAddress.RoadwayNo, - TaskType = TaskTypeEnum.Outbound.ObjToInt(), - TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), - SourceAddress = locationinfo.LocationCode, - TargetAddress = newTargetAddress.LocationCode, - CurrentAddress = locationinfo.LocationCode, - NextAddress = newTargetAddress.LocationCode, - Grade = 1, - Creater = "WMS", - Depth = locationinfo.Depth, - CreateDate = DateTime.Now, - }; - dtstockt.Add(stockt); - locations.Add(locationinfo); - taskdt.Add(dt_Task); - if (stockt.MaterialType != (int)InventoryMaterialType.绌烘墭) - { - dtstocktdetail.Add(stocktdetail); + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛岃閫夋嫨宸插叆搴撲笖鍚堟牸鐨勭墿鏂欏嚭搴擄紒锛侊紒锛屽嚭搴撴潯鐮侊細{saveModel.DelKeys[i].ToString()}"); } - + } var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTask, taskdt, "涓嬪彂浠诲姟鍏ュ簱"); _unitOfWorkManage.BeginTran(); - _stockService.StockInfoService.Repository.UpdateData(dtstockt); - _stockService.StockInfoDetailService.Repository.UpdateData(dtstocktdetail); - _basicService.LocationInfoService.Repository.UpdateData(locations); - BaseDal.AddData(taskdt); - + if (dtstockt.Count > 0) + { + _stockService.StockInfoService.Repository.UpdateData(dtstockt); + _stockService.StockInfoDetailService.Repository.UpdateData(dtstocktdetail); + _basicService.LocationInfoService.Repository.UpdateData(locations); + BaseDal.AddData(taskdt); + } _unitOfWorkManage.CommitTran(); content = WebResponseContent.Instance.OK(); return content; @@ -649,6 +782,222 @@ throw; } } + + + public WebResponseContent ManualOutbound2(SaveModel saveModel) + { + WebResponseContent content = new WebResponseContent(); + try + { + List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); + List<Dt_LocationInfo> locations = new List<Dt_LocationInfo>(); + List<Dt_Task> taskdt = new List<Dt_Task>(); + List<Dt_StockInfoDetail> dtstocktdetail = new List<Dt_StockInfoDetail>(); + + + List<Dt_StockInfo> stocktData= _stockService.StockInfoService.Repository.QueryData(x=>x.StockStatus== (int)StockStatusEmun.宸插叆搴� && x.MaterialType == (int)InventoryMaterialType.鍘熸潗鏂�); + List<Dt_LocationInfo> locationinfoData = _basicService.LocationInfoService.Repository.QueryData(x =>x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()); + List<Dt_StockInfoDetail> StockInfoDetailData = _stockService.StockInfoDetailService.Repository.QueryData(x => x.Status == (int)StockStatusEmun.宸插叆搴�); + + + string json = saveModel.DelKeys[0].ToString(); + List<string> palletCodes = JsonConvert.DeserializeObject<List<string>>(json); + + foreach (var palletCode in palletCodes) + { + Dt_StockInfo stockt = stocktData.FirstOrDefault(x => x.PalletCode == palletCode); + if (stockt !=null) + { + if (stockt.StockStatus == (int)StockStatusEmun.宸插叆搴� && (stockt.Wlstatus == (int)InventoryMaterialStatus.鍚堟牸 || stockt.Wlstatus == (int)InventoryMaterialStatus.閫�璐� || stockt.Wlstatus == (int)InventoryMaterialStatus.鐗归噰)) + { + Dt_StockInfoDetail stocktdetail = StockInfoDetailData.FirstOrDefault(x => x.StockId == stockt.Id); + if(stocktdetail != null) + { + Dt_LocationInfo locationinfo = locationinfoData.FirstOrDefault(x => x.LocationCode == stockt.LocationCode); + if(locationinfo != null) + { + stockt.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾; + if (locationinfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) + { + locationinfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + } + + string TargetAdd = ""; + if (saveModel.DelKeys[1].ToString()=="20") + { + TargetAdd = "R02-001-021-001-02"; + }else if(saveModel.DelKeys[1].ToString() == "30") + { + TargetAdd = "R02-001-022-001-02"; + } + else if (saveModel.DelKeys[1].ToString() == "40") + { + TargetAdd = "R01-002-044-001-01"; + } + else + { + TargetAdd = locationinfo.RoadwayNo == "2" ? "R02-002-027-011-01" : "R01-002-041-011-01"; + } + + + Dt_Task dt_Task = new() + { + PalletCode = stockt.PalletCode, + TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), + Roadway = locationinfo.RoadwayNo, + TaskType = TaskTypeEnum.Outbound.ObjToInt(), + TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), + SourceAddress = locationinfo.LocationCode, + TargetAddress = TargetAdd, + CurrentAddress = locationinfo.LocationCode, + NextAddress = TargetAdd, + Grade = 1, + Creater = "WMS", + Depth = locationinfo.Depth, + CreateDate = DateTime.Now, + PLCTo = int.Parse(saveModel.DelKeys[1].ToString()), + MaterialType=stockt.MaterialType + }; + dtstockt.Add(stockt); + locations.Add(locationinfo); + taskdt.Add(dt_Task); + dtstocktdetail.Add(stocktdetail); + } + else + { + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫簱浣嶄俊鎭紝璇锋牳瀵癸紒锛侊紒锛屽嚭搴撴潯鐮侊細{palletCode}"); + } + } + else + { + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫簱瀛樿鎯呬俊鎭紝璇锋牳瀵癸紒锛侊紒锛屽嚭搴撴潯鐮侊細{palletCode}"); + } + } + else + { + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛岃閫夋嫨宸插叆搴撲笖锛堝悎鏍硷紝鐗归噰锛岄��璐э級鐨勭墿鏂欏嚭搴擄紒锛侊紒锛屽嚭搴撴潯鐮侊細{palletCode}"); + } + } + else + { + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛屾湭鎵惧埌瀵瑰簲鏉$爜鐨勫簱瀛樹俊鎭紝鍑哄簱鏉$爜锛歿palletCode}"); + + } + } + var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTask, taskdt, "涓嬪彂浠诲姟鍏ュ簱"); + _unitOfWorkManage.BeginTran(); + if(dtstockt.Count > 0) + { + _stockService.StockInfoService.Repository.UpdateData(dtstockt); + _stockService.StockInfoDetailService.Repository.UpdateData(dtstocktdetail); + _basicService.LocationInfoService.Repository.UpdateData(locations); + BaseDal.AddData(taskdt); + } + _unitOfWorkManage.CommitTran(); + content = WebResponseContent.Instance.OK($"鍑哄簱鎴愬姛锛屽嚭搴撴�绘暟锛歿palletCodes.Count}锛屾垚鍔熸暟閲忥細{dtstockt.Count}"); + return content; + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛屾姤閿欎俊鎭細{ex.Message}"); + throw; + } + } + + public WebResponseContent ManualOutbound3(SaveModel saveModel) + { + WebResponseContent content = new WebResponseContent(); + try + { + List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); + + + List<Dt_StockInfo> stocktData = _stockService.StockInfoService.Repository.QueryData(x => x.StockStatus == (int)StockStatusEmun.宸插叆搴�); + string json = saveModel.DelKeys[0].ToString(); + List<int> palletCodes = JsonConvert.DeserializeObject<List<int>>(json); + + foreach (int pallid in palletCodes) + { + Dt_StockInfo stockt = stocktData.FirstOrDefault(x => x.Id == pallid); + if (stockt != null) + { + + stockt.Wlstatus = int.Parse(saveModel.DelKeys[1].ToString()); + dtstockt.Add(stockt); + } + else + { + return content = WebResponseContent.Instance.Error($"淇敼澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫簱瀛樹俊鎭紝搴撳瓨缂栧彿锛歿pallid}"); + + } + } + _unitOfWorkManage.BeginTran(); + if (dtstockt.Count > 0) + { + _stockService.StockInfoService.Repository.UpdateData(dtstockt); + } + _unitOfWorkManage.CommitTran(); + content = WebResponseContent.Instance.OK($"淇敼鎴愬姛"); + return content; + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return content = WebResponseContent.Instance.Error($"淇敼澶辫触锛屾姤閿欎俊鎭細{ex.Message}"); + throw; + } + } + + public WebResponseContent ManualOutbound4(SaveModel saveModel) + { + WebResponseContent content = new WebResponseContent(); + try + { + List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); + + + List<Dt_StockInfo> stocktData = _stockService.StockInfoService.Repository.QueryData(x => x.StockStatus == (int)StockStatusEmun.宸插叆搴�); + string json = saveModel.DelKeys[0].ToString(); + List<int> palletCodes = JsonConvert.DeserializeObject<List<int>>(json); + + foreach (int pallid in palletCodes) + { + Dt_StockInfo stockt = stocktData.FirstOrDefault(x => x.Id == pallid); + if (stockt != null) + { + + stockt.Mgeneratetime = DateTime.Parse(saveModel.DelKeys[1].ToString()); + dtstockt.Add(stockt); + } + else + { + return content = WebResponseContent.Instance.Error($"淇敼澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫簱瀛樹俊鎭紝搴撳瓨缂栧彿锛歿pallid}"); + + } + } + _unitOfWorkManage.BeginTran(); + if (dtstockt.Count > 0) + { + _stockService.StockInfoService.Repository.UpdateData(dtstockt); + } + _unitOfWorkManage.CommitTran(); + content = WebResponseContent.Instance.OK($"淇敼鎴愬姛"); + return content; + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return content = WebResponseContent.Instance.Error($"淇敼澶辫触锛屾姤閿欎俊鎭細{ex.Message}"); + throw; + } + } + + public class PalletCodeList + { + public string PalletCode { get; set; } + } + public (Dt_Task?, Dt_LocationInfo?) AddRelocationTask(Dt_LocationInfo location, Dt_StockInfo stockInfo, Dt_Task task) { @@ -845,5 +1194,168 @@ } return (null, LocationStatusEnum.Free.ObjToInt()); } + + /// <summary> + /// 浜哄伐鎵嬪姩鍑哄簱锛堝垹闄ゅ簱瀛橈級 + /// </summary> + /// <param name="saveModel"></param> + /// <returns></returns> + public WebResponseContent ManualOutboundDeleteinventory(SaveModel saveModel) + { + WebResponseContent content = new WebResponseContent(); + try + { + List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); + List<Dt_LocationInfo> locations = new List<Dt_LocationInfo>(); + List<Dt_StockInfoDetail> dtstocktdetail = new List<Dt_StockInfoDetail>(); + + for (int i = 0; i < saveModel.DelKeys.Count; i++) + { + Dt_StockInfo stockt = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == saveModel.DelKeys[i].ToString()); + if (stockt.StockStatus == (int)StockStatusEmun.宸插叆搴�) + { + Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockt.Id); + Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockt.LocationCode); + locationinfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + dtstockt.Add(stockt); + locations.Add(locationinfo); + if (stockt.MaterialType == (int)InventoryMaterialType.绌烘墭) + { + dtstocktdetail.Add(stocktdetail); + } + WriteLog.GetLog("浜哄伐鎵嬪姩鍒犻櫎搴撳瓨淇℃伅").Write($"鎵樼洏鏉$爜锛歿stockt.PalletCode},搴撲綅缂栧彿锛歿stockt.LocationCode}", $"浜哄伐鍑哄簱搴撳瓨"); + } + else + { + return content = WebResponseContent.Instance.Error($"鍑哄簱澶辫触锛岃搴撳瓨淇℃伅涓嶅彲杩涜鍑哄簱"); + } + + } + _unitOfWorkManage.BeginTran(); + _stockService.StockInfoService.Repository.DeleteData(dtstockt); + if(dtstocktdetail.Count==0) + { + _stockService.StockInfoDetailService.Repository.DeleteData(dtstocktdetail); + } + _basicService.LocationInfoService.Repository.UpdateData(locations); + _unitOfWorkManage.CommitTran(); + content = WebResponseContent.Instance.OK(); + return content; + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return content = WebResponseContent.Instance.Error($"鎵嬪姩鍑哄簱淇℃伅澶辫触锛屾姤閿欎俊鎭細{ex.Message}"); + throw; + } + } + + /// <summary> + /// 浠诲姟鍙栨秷 + /// </summary> + /// <param name="saveModel"></param> + /// <returns></returns> + public WebResponseContent Cancelinventory(int taskNum) + { + WebResponseContent content = new WebResponseContent(); + Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); + if(task != null) + { + if(task.TaskType== (int)TaskTypeEnum.Outbound || task.TaskType == (int)TaskTypeEnum.PalletOutbound) + { + //澶勭悊鍑哄簱鐨勯�昏緫 + Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); + if (locationinfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt()) + { + locationinfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + } + if (locationinfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) + { + locationinfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); + } + _basicService.LocationInfoService.Repository.UpdateData(locationinfo); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == task.PalletCode); + stockInfo.StockStatus = (int)StockStatusEmun.宸插叆搴�; + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfo.Id); + if(stocktdetail != null) + { + stocktdetail.Status = (int)StockStatusEmun.宸插叆搴�; + _stockService.StockInfoDetailService.Repository.UpdateData(stocktdetail); + } + BaseDal.DeleteData(task); + BaseDal.DeleteAndMoveIntoHty(task, OperateType.浜哄伐鍒犻櫎); + WriteLog.GetLog("浠诲姟鏃ュ織").Write($"鍑哄簱浠诲姟鍙栨秷鎴愬姛锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"浠诲姟鍙栨秷"); + WebResponseContent webResponseContent = HttpHelper.Post<WebResponseContent>(ReceiveWCSTask, task.TaskNum, "浠诲姟鍒犻櫎"); + return content = WebResponseContent.Instance.Error($"鍑哄簱浠诲姟鍙栨秷鎴愬姛"); + + } + else if(task.TaskType == (int)TaskTypeEnum.Inbound || task.TaskType == (int)TaskTypeEnum.PalletInbound) + { + //澶勭悊鍑哄簱鐨勯�昏緫 + Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + if (locationinfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt() || locationinfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) + { + locationinfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + } + _basicService.LocationInfoService.Repository.UpdateData(locationinfo); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == task.PalletCode); + _stockService.StockInfoService.Repository.DeleteData(stockInfo); + Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfo.Id); + if (stocktdetail != null) + { + _stockService.StockInfoDetailService.Repository.DeleteData(stocktdetail); + } + BaseDal.DeleteData(task); + BaseDal.DeleteAndMoveIntoHty(task, OperateType.浜哄伐鍒犻櫎); + WriteLog.GetLog("浠诲姟鏃ュ織").Write($"鍏ュ簱浠诲姟鍙栨秷鎴愬姛锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"浠诲姟鍙栨秷"); + WebResponseContent webResponseContent = HttpHelper.Post<WebResponseContent>(ReceiveWCSTask, task.TaskNum, "浠诲姟鍒犻櫎"); + return content = WebResponseContent.Instance.Error($"鍏ュ簱浠诲姟鍙栨秷鎴愬姛"); + } + else if (task.TaskType == (int)TaskTypeEnum.RelocationIn) //搴撳唴绉诲簱 + { + //澶勭悊鍑哄簱鐨勯�昏緫 + Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + if (locationinfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt() || locationinfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) + { + locationinfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + } + _basicService.LocationInfoService.Repository.UpdateData(locationinfo); + + Dt_LocationInfo locationinfo2 = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); + if (locationinfo2.LocationStatus == LocationStatusEnum.Lock.ObjToInt()) + { + locationinfo2.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + } + if (locationinfo2.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) + { + locationinfo2.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); + } + _basicService.LocationInfoService.Repository.UpdateData(locationinfo2); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == task.PalletCode); + stockInfo.StockStatus = (int)StockStatusEmun.宸插叆搴�; + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfo.Id); + if (stocktdetail != null) + { + stocktdetail.Status = (int)StockStatusEmun.宸插叆搴�; + _stockService.StockInfoDetailService.Repository.UpdateData(stocktdetail); + } + BaseDal.DeleteData(task); + BaseDal.DeleteAndMoveIntoHty(task, OperateType.浜哄伐鍒犻櫎); + WriteLog.GetLog("浠诲姟鏃ュ織").Write($"鍏ュ簱浠诲姟鍙栨秷鎴愬姛锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"浠诲姟鍙栨秷"); + WebResponseContent webResponseContent = HttpHelper.Post<WebResponseContent>(ReceiveWCSTask, task.TaskNum, "浠诲姟鍒犻櫎"); + return content = WebResponseContent.Instance.Error($"鍏ュ簱浠诲姟鍙栨秷鎴愬姛"); + } + else + { + return content = WebResponseContent.Instance.Error($"璇ヤ换鍔$殑浠诲姟绫诲瀷寮傚父锛屽彇娑堝け璐�"); + } + } + else + { + return content = WebResponseContent.Instance.Error($"鏈壘鍒颁换鍔″彿"); + } + } } } -- Gitblit v1.9.3