| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | //䏿¥åºåºå®æ æµè¯æ¶ |
| | | 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); |
| | | //æµè¯æ¶åºç»ERP䏿¥åºåºå®æ |
| | | ERPPickItemModel eRPOutPick = new ERPPickItemModel() |
| | | ERPIssueModel issueModel = new ERPIssueModel(); |
| | | List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | if (stockInfo==null) |
| | | { |
| | | Lotno = "20241227001", |
| | | Qty = "1", |
| | | 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 = "OT" + DateTime.Now.ToString("yyyyMMddHHmmss"),//æµè¯ |
| | | WarehouseCode = warehouse.WarehouseCode, |
| | | Docremark = "", |
| | | Deptno = outboundOrder.DepartmentCode, |
| | | Deptname = outboundOrder.DepartmentName, |
| | | Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | Createuser = "TC20082", |
| | | 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 = "OT" + DateTime.Now.ToString("yyyyMMddHHmmss"),//æµè¯ |
| | | WarehouseCode = warehouse.WarehouseCode, |
| | | Docremark = "", |
| | | Deptno = outboundOrder.DepartmentCode, |
| | | Deptname = outboundOrder.DepartmentName, |
| | | Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | Createuser = "TC20082", |
| | | 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 = "FL20241227001",//æµè¯ |
| | | WarehouseCode = warehouse.WarehouseCode, |
| | | Docremark = "", |
| | | Deptno = outboundOrder.DepartmentCode, |
| | | Deptname = outboundOrder.DepartmentName, |
| | | 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 |
| | |
| | | /// <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).Includes(x => x.Details).ToList(); |
| | | if (model.Qty > stockInfos.Count) |
| | | if (stockInfos.Count<=0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç©æ:{model.MCode}åºåä¸è¶³"); |
| | | return WebResponseContent.Instance.Error($"åºåä¸è¶³"); |
| | | } |
| | | //æ´æ¹ç¶æ |
| | | stockInfos.ForEach(x => |
| | |
| | | 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) |
| | | //{ |
| | | // ERPPickItemModel |
| | | //} |
| | | } |
| | | } |