From 89051aef8a2c1a85d457914cf6317fe70e0e321c Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期日, 29 十二月 2024 04:33:10 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs | 223 +++++++++++++++++++++---------------------------------- 1 files changed, 87 insertions(+), 136 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" index a65c399..7db7c96 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" @@ -99,30 +99,7 @@ OrderQuantity = model.Qty, OrderId = oldOutboundOrder.Id }; - List<Dt_StockInfo>? stockInfos = new List<Dt_StockInfo>(); - //ERP涓婁紶娴嬭瘯浠撻鏂欏崟鏇存柊瀵瑰簲搴撳瓨鐘舵�� - if (warehouse.WarehouseCode == WarehouseEnum.HA64.ToString()) - { - WebResponseContent responseContent = TestOutStocksUpdate(warehouse, model); - if (!responseContent.Status) - { - return responseContent; - } - stockInfos = responseContent.Data as List<Dt_StockInfo>; - } - _unitOfWorkManage.BeginTran(); - if (stockInfos.Count>0) - { - _stockInfoRepository.UpdateData(stockInfos); - //娴嬭瘯鏋跺簱缁橢RP涓婃姤鍑哄簱瀹屾垚 - if (!TestOutBack(stockInfos, warehouse, model).Status) - { - _unitOfWorkManage.RollbackTran(); - return WebResponseContent.Instance.Error($"娴嬭瘯鏋跺嚭搴撲笂鎶ュけ璐�"); - } - } _outboundOrderDetailRepository.AddData(outboundOrderDetail); - _unitOfWorkManage.CommitTran(); } } else @@ -136,7 +113,6 @@ OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), OrderQuantity = model.Qty, }; - Dt_OutboundOrder outboundOrder = new Dt_OutboundOrder() { OrderNo=model.OrderNo, @@ -145,33 +121,11 @@ OrderType = OutOrderTypeEnum.Issue.ObjToInt(), CreateType = OrderCreateTypeEnum.UpperSystemPush.ObjToInt(), WarehouseId = warehouse.WarehouseId, + DepartmentCode = model.DepartmentCode, + DepartmentName = model.DepartmentName, Details = new List<Dt_OutboundOrderDetail> { outboundOrderDetail } }; - List<Dt_StockInfo>? stockInfos = new List<Dt_StockInfo>(); - //ERP涓婁紶娴嬭瘯浠撻鏂欏崟鏇存柊瀵瑰簲搴撳瓨鐘舵�� - if (warehouse.WarehouseCode == WarehouseEnum.HA64.ToString()) - { - WebResponseContent responseContent = TestOutStocksUpdate(warehouse, model); - if (!responseContent.Status) - { - return responseContent; - } - stockInfos = responseContent.Data as List<Dt_StockInfo>; - } - _unitOfWorkManage.BeginTran(); - if (stockInfos.Count > 0) - { - _stockInfoRepository.UpdateData(stockInfos); - //娴嬭瘯鏋跺簱缁橢RP涓婃姤鍑哄簱瀹屾垚 - if (!TestOutBack(stockInfos, warehouse, model).Status) - { - _unitOfWorkManage.RollbackTran(); - return WebResponseContent.Instance.Error($"娴嬭瘯鏋跺嚭搴撲笂鎶ュけ璐�"); - } - } Db.InsertNav(outboundOrder).Include(x => x.Details).ExecuteCommand(); - _unitOfWorkManage.CommitTran(); - } } else if (model.Way == 2) @@ -218,49 +172,100 @@ } } //涓婃姤鍑哄簱瀹屾垚 - public WebResponseContent TestOutUpload(int id) + public WebResponseContent TestOutUpload(int id,Dt_StockInfo stockInfo) { try { Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x=>x.Id==id).Includes(x=>x.Details).First(); Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == outboundOrder.WarehouseId); //娴嬭瘯鏋跺簱缁橢RP涓婃姤鍑哄簱瀹屾垚 - ERPPickItemModel eRPOutPick = new ERPPickItemModel() + ERPIssueModel issueModel = new ERPIssueModel(); + List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); + if (stockInfo==null) { - Lotno = "20241226001", - Qty = "5", - Location = warehouse.WarehouseCode - }; - ERPPickModel pickModel = new ERPPickModel() + stockInfos = TestOutStocksUpdate(warehouse).Data as List<Dt_StockInfo> ?? new List<Dt_StockInfo>(); + List<ERPPickItemModel> eRPOutPick =new List<ERPPickItemModel>(); + for (int i = 0; i < stockInfos.Count; i++) + { + ERPPickItemModel pickItemModel = new ERPPickItemModel() + { + Lotno= stockInfos[i].Details[0].BatchNo, + Qty= stockInfos[i].Details[0].StockQuantity.ObjToInt().ToString(), + Location= warehouse.WarehouseCode + }; + eRPOutPick.Add(pickItemModel); + } + + ERPPickModel pickModel = new ERPPickModel() + { + Rowindex = outboundOrder.Details[0].RowNo, + Material = outboundOrder.Details[0].MaterielCode, + Qty = (outboundOrder.Details[0].OrderQuantity.ObjToInt()).ToString(), + Dataitem = eRPOutPick + }; + + ERPIssueItemModel issueItemModel = new ERPIssueItemModel() + { + Pickcode = outboundOrder.UpperOrderNo, + PickList = new List<ERPPickModel>() { pickModel } + }; + issueModel = new ERPIssueModel() + { + UniqueTag = id.ToString(), + Code = outboundOrder.OrderNo,//娴嬭瘯 + WarehouseCode = warehouse.WarehouseCode, + Docremark = "", + Deptno = outboundOrder.DepartmentCode, + Deptname = outboundOrder.DepartmentName, + Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + Createuser = outboundOrder.Creater, + Issitem = new List<ERPIssueItemModel>() { issueItemModel }, + }; + } + else { - Rowindex = outboundOrder.Details[0].RowNo, - Material = outboundOrder.Details[0].MaterielCode, - Qty = (outboundOrder.Details[0].OrderQuantity.ObjToInt()).ToString(), - Dataitem=new List<ERPPickItemModel> { eRPOutPick } - }; + Dt_OutboundOrderDetail orderDetail = outboundOrder.Details.FirstOrDefault(x => x.MaterielCode == stockInfo.Details[0].MaterielCode); + + ERPPickItemModel pickItemModel = new ERPPickItemModel() + { + Lotno = stockInfo.Details[0].BatchNo, + Qty = stockInfo.Details[0].StockQuantity.ObjToInt().ToString(), + Location = stockInfo.LocationCode + }; + ERPPickModel pickModel = new ERPPickModel() + { + Rowindex = outboundOrder.Details[0].RowNo, + Material = outboundOrder.Details[0].MaterielCode, + Qty = (outboundOrder.Details[0].OrderQuantity.ObjToInt()).ToString(), + Dataitem = new List<ERPPickItemModel> { pickItemModel } + }; + ERPIssueItemModel issueItemModel = new ERPIssueItemModel() + { + Pickcode = outboundOrder.UpperOrderNo, + PickList = new List<ERPPickModel>() { pickModel } + }; + issueModel = new ERPIssueModel() + { + UniqueTag = id.ToString(), + Code = outboundOrder.OrderNo,//娴嬭瘯 + WarehouseCode = warehouse.WarehouseCode, + Docremark = "", + Deptno = outboundOrder.DepartmentCode, + Deptname = outboundOrder.DepartmentName, + Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + Createuser = outboundOrder.Creater, + Issitem = new List<ERPIssueItemModel>() { issueItemModel }, + }; + } - ERPIssueItemModel issueItemModel = new ERPIssueItemModel() - { - Pickcode = outboundOrder.UpperOrderNo, - PickList = new List<ERPPickModel>() { pickModel } - }; - ERPIssueModel issueModel = new ERPIssueModel() - { - UniqueTag = id.ToString(), - Code = "FL20241226001", - WarehouseCode = warehouse.WarehouseCode, - Docremark = "", - Deptno = "F2HAECZSQZ", - Deptname = "娣畨浜屽巶鍒朵笁鍖洪樆鐒�", - Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), - Createuser = "TC20082", - Issitem = new List<ERPIssueItemModel>() { issueItemModel }, - }; string response = _invokeERPService.InvokeOutStandardsApi(issueModel); ErpRequestContent requestContent = response.DeserializeObject<ErpRequestContent>(); if (requestContent.res == 1) { - + if (stockInfos.Count>0) + { + _stockInfoRepository.UpdateData(stockInfos); + } return WebResponseContent.Instance.OK(requestContent.Data); } else @@ -272,7 +277,6 @@ { return WebResponseContent.Instance.Error(ex.Message); } - return WebResponseContent.Instance.OK(); } /// <summary> /// 鏇存敼鍑哄簱鍗曞簱瀛樼姸鎬� @@ -280,15 +284,15 @@ /// <param name="warehouse"></param> /// <param name="model"></param> /// <returns></returns> - public WebResponseContent TestOutStocksUpdate(Dt_Warehouse warehouse, ErpOutOrderDTO model) + public WebResponseContent TestOutStocksUpdate(Dt_Warehouse warehouse) { try { //鑾峰彇鍑哄簱鍗曞簱瀛� - List<Dt_StockInfo> stockInfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).OrderBy(x => x.CreateDate).Includes(x => x.Details).Where(x => x.Details.Any(x => x.MaterielCode == model.MCode)).Take((int)(model.Qty)).ToList(); - if (model.Qty > stockInfos.Count) + List<Dt_StockInfo> stockInfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).ToList(); + if (stockInfos.Count<=0) { - return WebResponseContent.Instance.Error($"鐗╂枡:{model.MCode}搴撳瓨涓嶈冻"); + return WebResponseContent.Instance.Error($"搴撳瓨涓嶈冻"); } //鏇存敼鐘舵�� stockInfos.ForEach(x => @@ -302,58 +306,5 @@ return WebResponseContent.Instance.Error(ex.Message); } } - ///鎺ㄩ�佹祴璇曟灦鍑哄簱 - public WebResponseContent TestOutBack(List<Dt_StockInfo> stockInfos,Dt_Warehouse warehouse, ErpOutOrderDTO model) - { - try - { - //娴嬭瘯鏋跺簱缁橢RP涓婃姤鍑哄簱瀹屾垚 - List<ERPOutPickDetail> pickDetails = stockInfos.Select(x => new ERPOutPickDetail() - { - Lotno = x.Details[0].BatchNo, - Qty = x.Details[0].StockQuantity.ObjToInt() - }).ToList(); - ERPOutPick outPick = new ERPOutPick() - { - Rowindex = model.RowNo, - Material = model.MCode, - Qty = model.Qty.ObjToInt(), - Dataitem = pickDetails - }; - ERPOutboundModel inboundModel = new ERPOutboundModel() - { - Way = 1, - UniqueTag = model.OrderNo, - Code = model.OrderNo, - WarehouseCode = warehouse.WarehouseCode, - Docremark = "", - Deptno = model.DepartmentCode, - DeptName = model.DepartmentName, - Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), - Createuser = "WMS", - Picklist = new List<ERPOutPick>() { outPick }, - }; - string response = _invokeERPService.InvokeOutboundOrderApi(inboundModel); - ErpRequestContent requestContent=response.DeserializeObject<ErpRequestContent>(); - if (requestContent.res==1) - { - - return WebResponseContent.Instance.OK(requestContent.Data); - } - else - { - return WebResponseContent.Instance.Error(requestContent.Data); - } - } - catch (Exception ex) - { - return WebResponseContent.Instance.Error(ex.Message); - } - } - - //public WebResponseContent FeedbackOutbondIssue(List<Dt_OutStockLockInfo> outStockLockInfos) - //{ - // ERPPickItemModel - //} } } -- Gitblit v1.9.3