| | |
| | | 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); |
| | | //æµè¯æ¶åºç»ERP䏿¥åºåºå®æ |
| | | if (!TestOutBack(stockInfos, warehouse, model).Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æµè¯æ¶åºåºä¸æ¥å¤±è´¥"); |
| | | } |
| | | } |
| | | _outboundOrderDetailRepository.AddData(outboundOrderDetail); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | } |
| | | else |
| | |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | OrderQuantity = model.Qty, |
| | | }; |
| | | |
| | | Dt_OutboundOrder outboundOrder = new Dt_OutboundOrder() |
| | | { |
| | | OrderNo=model.OrderNo, |
| | |
| | | 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); |
| | | //æµè¯æ¶åºç»ERP䏿¥åºåºå®æ |
| | | 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) |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | //䏿¥åºåºå®æ |
| | | //䏿¥åºåºå®æ æµè¯æ¶ |
| | | public WebResponseContent TestOutUpload(int id) |
| | | { |
| | | try |
| | |
| | | //æµè¯æ¶åºç»ERP䏿¥åºåºå®æ |
| | | ERPPickItemModel eRPOutPick = new ERPPickItemModel() |
| | | { |
| | | Lotno = "20241226001", |
| | | Qty = "5", |
| | | Lotno = "20241227001", |
| | | Qty = "1", |
| | | Location = warehouse.WarehouseCode |
| | | }; |
| | | ERPPickModel pickModel = new ERPPickModel() |
| | |
| | | ERPIssueModel issueModel = new ERPIssueModel() |
| | | { |
| | | UniqueTag = id.ToString(), |
| | | Code = "FL20241226001", |
| | | Code = "FL20241227001",//æµè¯ |
| | | WarehouseCode = warehouse.WarehouseCode, |
| | | Docremark = "", |
| | | Deptno = "F2HAECZSQZ", |
| | | Deptname = "æ·®å®äºåå¶ä¸åºé»ç", |
| | | Deptno = outboundOrder.DepartmentCode, |
| | | Deptname = outboundOrder.DepartmentName, |
| | | Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | Createuser = "TC20082", |
| | | Issitem = new List<ERPIssueItemModel>() { issueItemModel }, |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | /// <summary> |
| | | /// æ´æ¹åºåºååºåç¶æ |
| | |
| | | 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(); |
| | | List<Dt_StockInfo> stockInfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).ToList(); |
| | | if (model.Qty > stockInfos.Count) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç©æ:{model.MCode}åºåä¸è¶³"); |
| | |
| | | } |
| | | } |
| | | ///æ¨éæµè¯æ¶åºåº |
| | | public WebResponseContent TestOutBack(List<Dt_StockInfo> stockInfos,Dt_Warehouse warehouse, ErpOutOrderDTO model) |
| | | { |
| | | try |
| | | { |
| | | //æµè¯æ¶åºç»ERP䏿¥åºåºå®æ |
| | | 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 TestOutBack(int id,List<string> locationIds) |
| | | //{ |
| | | // try |
| | | // { |
| | | |
| | | // string response = _invokeERPService.InvokeOutStandardsApi(issueModel); |
| | | // 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) |
| | | //{ |