public void Execute(JobContext context) { if (!context.JobDataMap.ContainKey("UserCode")) { log.Error("User code not specified."); } if (!context.JobDataMap.ContainKey("Plant")) { log.Error("Plant not specified."); } if (context.JobDataMap.ContainKey("UserCode") && context.JobDataMap.ContainKey("Plant")) { SAPService.SAPService sapService = new SAPService.SAPService(); if (context.JobDataMap.ContainKey("SIServiceAddress") && context.JobDataMap.ContainKey("SIServicePort")) { sapService.Url = ServiceURLHelper.ReplaceServiceUrl(sapService.Url, context.JobDataMap.GetStringValue("SIServiceAddress"), context.JobDataMap.GetStringValue("SIServicePort")); } Double diffDate = 0; if (context.JobDataMap.ContainKey("DayDiff")) { diffDate = context.JobDataMap.GetDoubleValue("DayDiff"); } //sapService.GetProcOrdersAsync(context.JobDataMap.GetStringValue("UserCode"), null, null, context.JobDataMap.GetStringValue("Plant"), DateTime.Now.AddDays(diffDate), true); } }
public void Execute(JobContext context) { if (!context.JobDataMap.ContainKey("ProductLine")) { log.Error("ProductLine not specified."); } SAPService.SAPService sapService = new SAPService.SAPService(); if (context.JobDataMap.ContainKey("SIServiceAddress") && context.JobDataMap.ContainKey("SIServicePort")) { sapService.Url = ServiceURLHelper.ReplaceServiceUrl(sapService.Url, context.JobDataMap.GetStringValue("SIServiceAddress"), context.JobDataMap.GetStringValue("SIServicePort")); } sapService.GetVehicleStationInfoByProductLine(context.JobDataMap.GetStringValue("ProductLine")); }
public void Execute(JobContext context) { if (!context.JobDataMap.ContainKey("UserCode")) { log.Error("User code not specified."); } if (context.JobDataMap.ContainKey("UserCode")) { SAPService.SAPService sapService = new SAPService.SAPService(); if (context.JobDataMap.ContainKey("SIServiceAddress") && context.JobDataMap.ContainKey("SIServicePort")) { sapService.Url = ServiceURLHelper.ReplaceServiceUrl(sapService.Url, context.JobDataMap.GetStringValue("SIServiceAddress"), context.JobDataMap.GetStringValue("SIServicePort")); } sapService.CreateDN(context.JobDataMap.GetStringValue("UserCode")); } }
public void Execute(JobContext context) { if (!context.JobDataMap.ContainKey("UserCode")) { log.Error("User code not specified."); } if (!context.JobDataMap.ContainKey("DayDiff")) { log.Error("Day difference not specified."); } if (context.JobDataMap.ContainKey("UserCode") && context.JobDataMap.ContainKey("DayDiff")) { string userCode = context.JobDataMap.GetStringValue("UserCode"); DateTime dateTimeNow = DateTime.Now; SAPService.SAPService sapService = new SAPService.SAPService(); if (context.JobDataMap.ContainKey("SIServiceAddress") && context.JobDataMap.ContainKey("SIServicePort")) { sapService.Url = ServiceURLHelper.ReplaceServiceUrl(sapService.Url, context.JobDataMap.GetStringValue("SIServiceAddress"), context.JobDataMap.GetStringValue("SIServicePort")); } //sapService.GetProdOrders(userCode, dateTimeNow.AddDays(context.JobDataMap.GetDoubleValue("DayDiff")), null); } }
public ActionResult Refresh(string PartyFrom, string Item) { try { if (string.IsNullOrEmpty(PartyFrom)) { throw new BusinessException("供应商代码不能为空"); } // FlowMaster flowMaster = base.genericMgr.FindById<FlowMaster>(flow); // Region region = base.genericMgr.FindById<Region>(flowMaster.PartyTo); SAPService.SAPService sapService = new SAPService.SAPService(); sapService.Url = ReplaceSIServiceUrl(sapService.Url); com.Sconit.Entity.ACC.User user = SecurityContextHolder.Get(); Supplier supplier = base.genericMgr.FindById<Supplier>(PartyFrom); DateTime lastModifyDate = supplier.LastRefreshDate == null ? DateTime.Now : supplier.LastRefreshDate.Value; sapService.GetProcOrders(null, PartyFrom, Item, GetSAPPlant(), user.Code); SaveSuccessMessage("计划协议刷新成功。"); } catch (BusinessException ex) { SaveBusinessExceptionMessage(ex); } catch (Exception ex) { SaveErrorMessage(ex); } TempData["OrderMasterSearchModel"] = new OrderMasterSearchModel { PartyFrom = PartyFrom, Item = Item }; return View("Index"); }
public ActionResult _ScheduleLineList(GridCommand command, OrderMasterSearchModel searchModel) { try { TempData["OrderMasterSearchModel"] = searchModel; if (string.IsNullOrWhiteSpace(searchModel.PartyFrom) && string.IsNullOrWhiteSpace(searchModel.Item)) { SaveWarningMessage("请选择一个供应商或物料进行查询。"); return View(); } #region 重新调用取最新的 // FlowMaster flowMaster = base.genericMgr.FindById<FlowMaster>(searchModel.Flow); string item = searchModel.Item != string.Empty && searchModel.Item != null ? searchModel.Item : string.Empty; // Region region = base.genericMgr.FindById<Region>(flowMaster.PartyTo); SAPService.SAPService sapService = new SAPService.SAPService(); sapService.Url = ReplaceSIServiceUrl(sapService.Url); com.Sconit.Entity.ACC.User user = SecurityContextHolder.Get(); // Supplier supplier = base.genericMgr.FindById<Supplier>(searchModel.PartyFrom); // DateTime lastModifyDate = supplier.LastRefreshDate == null ? DateTime.Now : supplier.LastRefreshDate.Value; IList<com.Sconit.Web.SAPService.OrderDetail> scheduleList = sapService.GetProcOrders(null, searchModel.PartyFrom, item, GetSAPPlant(), user.Code); #endregion DateTime dateTimeNow = DateTime.Now; int listDays = searchModel.ListDays == null ? 21 : (searchModel.ListDays.Value > 0 ? searchModel.ListDays.Value : 0); ScheduleView scheduleView = PrepareScheduleView(searchModel.PartyFrom, searchModel.Item, dateTimeNow, listDays, scheduleList, searchModel.NotIncludeZeroShipQty); #region grid column var columns = new List<GridColumnSettings>(); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.OrderNoHead, Title = Resources.ORD.OrderDetail.OrderDetail_ScheduleLineNo, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.SequenceHead, Title = Resources.ORD.OrderDetail.OrderDetail_ScheduleLineSeq, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.LesOrderNoHead, Title = Resources.ORD.OrderDetail.OrderDetail_OrderNo, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.SupplierHead, Title = Resources.ORD.OrderMaster.OrderMaster_PartyFrom, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.ItemHead, Title = Resources.ORD.OrderDetail.OrderDetail_Item, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.ItemDescriptionHead, Title = Resources.ORD.OrderDetail.OrderDetail_ItemDescription, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.ReferenceItemCodeHead, Title = Resources.ORD.OrderDetail.OrderDetail_ReferenceItemCode, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.UomHead, Title = Resources.ORD.OrderDetail.OrderDetail_Uom, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.UnitCountHead, Title = Resources.ORD.OrderDetail.OrderDetail_UnitCount, Sortable = false }); //columns.Add(new GridColumnSettings //{ // Member = scheduleView.ScheduleHead.CurrentShipQtyHead, // Title = Resources.ORD.OrderDetail.OrderDetail_CurrentShipQty, // Sortable = false //}); //可发货数 columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.ShipQtyHead, Title = Resources.ORD.OrderDetail.OrderDetail_ShipQty, Sortable = false }); //已发货数 //columns.Add(new GridColumnSettings //{ // Member = scheduleView.ScheduleHead.ShippedQtyHead, // Title = Resources.ORD.OrderDetail.OrderDetail_ShippedQty, // Sortable = false, // Visible = false //}); //已收货数 columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.ReceivedQtyHead, Title = Resources.ORD.OrderDetail.OrderDetail_ReceivedQty, Sortable = false }); //总计划数 columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.OrderQtyHead, Title = Resources.ORD.OrderDetail.OrderDetail_TotalOrderQty, Sortable = false }); //历史计划数 columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.BackOrderQtyHead, Title = Resources.ORD.OrderDetail.OrderDetail_BackOrderQty, Sortable = false }); //未来汇总 columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.ForecastQtyHead, Title = Resources.ORD.OrderDetail.OrderDetail_ForecastQty, Sortable = false }); //冻结期计划数 columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.OrderQtyInFreeze, Title = "冻结期计划数", Sortable = false, Visible = false }); //已处理数 columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.HandledQty, Title = "已处理数", Sortable = false, Visible = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.FlowHead, Title = Resources.ORD.OrderDetail.OrderDetail_Flow, Sortable = false }); columns.Add(new GridColumnSettings { Member = scheduleView.ScheduleHead.LocationToHead, Title = Resources.ORD.OrderDetail.OrderDetail_LocationTo, Sortable = false }); #endregion #region if (scheduleView.ScheduleHead.ColumnCellList != null && scheduleView.ScheduleHead.ColumnCellList.Count > 0) { for (int i = 0; i < listDays; i++) { columns.Add(new GridColumnSettings { Member = "RowCellList[" + i + "].DisplayQty", MemberType = typeof(string), Title = (scheduleView.ScheduleHead.ColumnCellList[i].EndDate.Value < dateTimeNow.Date) ? "欠交" : scheduleView.ScheduleHead.ColumnCellList[i].EndDate.Value.Date.ToShortDateString(), Sortable = false }); } } #endregion ViewData["columns"] = columns.ToArray(); IList<ScheduleBody> scheduleBodyList = scheduleView.ScheduleBodyList != null && scheduleView.ScheduleBodyList.Count > 0 ? scheduleView.ScheduleBodyList.OrderBy(s => s.ReferenceItemCode).ThenBy(s => s.OrderNo).ToList() : new List<ScheduleBody>(); return PartialView(scheduleBodyList); } catch (SoapException ex) { SaveErrorMessage(ex.Actor); } catch (BusinessException ex) { SaveBusinessExceptionMessage(ex); } catch (Exception ex) { SaveErrorMessage(ex); } return Json(null); }
public void Execute(JobContext context) { if (!context.JobDataMap.ContainKey("UserCode")) { log.Error("User code not specified."); } if (!context.JobDataMap.ContainKey("FtpServer")) { log.Error("FtpServer not specified."); } if (!context.JobDataMap.ContainKey("FtpPort")) { log.Error("FtpPort not specified."); } if (!context.JobDataMap.ContainKey("FtpUser")) { log.Error("FtpUser not specified."); } if (!context.JobDataMap.ContainKey("FtpPass")) { log.Error("FtpPass not specified."); } if (!context.JobDataMap.ContainKey("FtpFolder")) { log.Error("FtpFolder not specified."); } if (!context.JobDataMap.ContainKey("LocalFolder")) { log.Error("LocalFolder not specified."); } if (!context.JobDataMap.ContainKey("LocalTempFolder")) { log.Error("LocalTempFolder not specified."); } if (context.JobDataMap.ContainKey("UserCode") && context.JobDataMap.ContainKey("FtpServer") && context.JobDataMap.ContainKey("FtpPort") && context.JobDataMap.ContainKey("FtpUser") && context.JobDataMap.ContainKey("FtpPass") && context.JobDataMap.ContainKey("FtpFolder") && context.JobDataMap.ContainKey("LocalFolder") && context.JobDataMap.ContainKey("LocalTempFolder")) { SAPService.SAPService sapService = new SAPService.SAPService(); if (context.JobDataMap.ContainKey("SIServiceAddress") && context.JobDataMap.ContainKey("SIServicePort")) { sapService.Url = ServiceURLHelper.ReplaceServiceUrl(sapService.Url, context.JobDataMap.GetStringValue("SIServiceAddress"), context.JobDataMap.GetStringValue("SIServicePort")); } sapService.ReportLocLotDetAsync(context.JobDataMap.GetStringValue("UserCode"), context.JobDataMap.GetStringValue("FtpServer"), context.JobDataMap.GetIntValue("FtpPort"), context.JobDataMap.GetStringValue("FtpUser"), context.JobDataMap.GetStringValue("FtpPass"), context.JobDataMap.GetStringValue("FtpFolder"), context.JobDataMap.GetStringValue("LocalFolder"), context.JobDataMap.GetStringValue("LocalTempFolder")); } }
public void GetCurrentVanOrder(string plant, string sapOrderNo, string prodlLine, string userCode) { SAPService.SAPService sapService = new SAPService.SAPService(); sapService.Url = this.systemMgr.ReplaceSIServiceUrl(sapService.Url); sapService.GetCurrentVanOrder(plant, sapOrderNo, prodlLine, userCode); }
public void CancelReportOrderOp(int orderOpReportId) { OrderOperationReport orderOperationReport = this.genericMgr.FindById<OrderOperationReport>(orderOpReportId); if (orderOperationReport.Status == CodeMaster.OrderOpReportStatus.Cancel) { throw new BusinessException("工序报工已经取消。"); } DateTime dateTimeNow = DateTime.Now; User user = SecurityContextHolder.Get(); OrderMaster orderMaster = this.genericMgr.FindEntityWithNativeSql<OrderMaster>("select * from ORD_OrderMstr_4 WITH(NOLOCK) where OrderNo = ?", orderOperationReport.OrderNo).Single(); OrderOperation orderOperation = this.genericMgr.FindById<OrderOperation>(orderOperationReport.OrderOperationId); com.Sconit.Entity.SAP.ORD.ProdOpReport prodOpReport = this.genericMgr.FindEntityWithNativeSql<com.Sconit.Entity.SAP.ORD.ProdOpReport>("select * from SAP_ProdOpReport WITH(NOLOCK) where OrderOpReportId = ?", orderOperationReport.Id).Single(); #region 先更新ProdOpReport,防止生产报工同时已经传给SAP bool isReportToSAP = true; if (prodOpReport.Status != StatusEnum.Success) { #region 生产单报工还未传给SAP #region 更新报工记录为成功,不用再传给SAP prodOpReport.Status = StatusEnum.Success; prodOpReport.IsCancel = true; this.genericMgr.Update(prodOpReport); isReportToSAP = false; #endregion #endregion } else { #region 生产单报工已经传给SAP #region 报工记录设置取消标记 prodOpReport.IsCancel = true; this.genericMgr.Update(prodOpReport); isReportToSAP = true; #endregion #endregion } this.genericMgr.FlushSession(); #endregion //IList<OrderOperation> refOrderOperationList = null; // if (orderOperation.NeedReport && // !(orderMaster.ProdLineType == CodeMaster.ProdLineType.Cab // || orderMaster.ProdLineType == CodeMaster.ProdLineType.Chassis // || orderMaster.ProdLineType == CodeMaster.ProdLineType.Assembly // || orderMaster.ProdLineType == CodeMaster.ProdLineType.Special // || orderMaster.ProdLineType == CodeMaster.ProdLineType.Check)) // { // refOrderOperationList = this.genericMgr.FindEntityWithNativeSql<OrderOperation>(@"select * from ORD_OrderOp where OrderNo= ? // and Op > ISNULL((select Op from ORD_OrderOp where OrderNo = ? and Op < ? and NeedReport = ?), 0) and Op < ?" // , new object[] { orderMaster.OrderNo, orderMaster.OrderNo, orderOperation.Operation, true, orderOperation.Operation }); // } if (orderMaster.ProdLineType == CodeMaster.ProdLineType.Cab || orderMaster.ProdLineType == CodeMaster.ProdLineType.Chassis || orderMaster.ProdLineType == CodeMaster.ProdLineType.Assembly || orderMaster.ProdLineType == CodeMaster.ProdLineType.Special || orderMaster.ProdLineType == CodeMaster.ProdLineType.Check) { if (orderMaster.Status == CodeMaster.OrderStatus.Close) { throw new BusinessException("整车物料已经反冲,不能取消报工。"); } } else { #region 物料反消耗 if (orderOperation.NeedReport) { IList<com.Sconit.Entity.SAP.ORD.ProdOpBackflush> prodOpBackflushList = this.genericMgr.FindEntityWithNativeSql<com.Sconit.Entity.SAP.ORD.ProdOpBackflush>( "select * from SAP_ProdOpBackflush where OrderOpReportId = ?", orderOperationReport.Id); if (prodOpBackflushList != null && prodOpBackflushList.Count > 0) { foreach (com.Sconit.Entity.SAP.ORD.ProdOpBackflush prodOpBackflush in prodOpBackflushList) { this.productionLineMgr.AntiBackflushProductOrder(prodOpBackflush); } } //if (refOrderOperationList != null && refOrderOperationList.Count > 0) //{ // foreach (OrderOperation refOrderOperation in refOrderOperationList) // { // this.productionLineMgr.AntiBackflushProductOrder(refOrderOperation, orderOperationReport); // if (!(orderMaster.ProdLineType == CodeMaster.ProdLineType.Cab // || orderMaster.ProdLineType == CodeMaster.ProdLineType.Chassis // || orderMaster.ProdLineType == CodeMaster.ProdLineType.Assembly // || orderMaster.ProdLineType == CodeMaster.ProdLineType.Special // || orderMaster.ProdLineType == CodeMaster.ProdLineType.Check)) // { // refOrderOperation.BackflushQty -= prodOpReport.GAMNG; // refOrderOperation.BackflushQty -= prodOpReport.SCRAP; // } // refOrderOperation.ReportQty -= prodOpReport.GAMNG; // refOrderOperation.ScrapQty -= prodOpReport.SCRAP; // } //} } #endregion #region 成品反收货 if (!string.IsNullOrWhiteSpace(orderOperationReport.ReceiptNo)) { this.receiptMgr.CancelReceipt(orderOperationReport.ReceiptNo); } #endregion } #region 更新生产单状态为执行中 if (orderMaster.Status != CodeMaster.OrderStatus.InProcess) { if (orderMaster.ProdLineType == CodeMaster.ProdLineType.Cab || orderMaster.ProdLineType == CodeMaster.ProdLineType.Chassis || orderMaster.ProdLineType == CodeMaster.ProdLineType.Assembly || orderMaster.ProdLineType == CodeMaster.ProdLineType.Special || orderMaster.ProdLineType == CodeMaster.ProdLineType.Check) { orderMaster.Status = CodeMaster.OrderStatus.InProcess; orderMaster.CompleteDate = null; orderMaster.CompleteUserId = null; orderMaster.CompleteUserName = null; this.genericMgr.Update(orderMaster); } else { orderMaster.Status = CodeMaster.OrderStatus.InProcess; orderMaster.CloseDate = null; orderMaster.CloseUserId = null; orderMaster.CloseUserName = null; this.genericMgr.Update(orderMaster); } } #endregion #region 更新工序反冲数量 if (!(orderMaster.ProdLineType == CodeMaster.ProdLineType.Cab || orderMaster.ProdLineType == CodeMaster.ProdLineType.Chassis || orderMaster.ProdLineType == CodeMaster.ProdLineType.Assembly || orderMaster.ProdLineType == CodeMaster.ProdLineType.Special || orderMaster.ProdLineType == CodeMaster.ProdLineType.Check)) { orderOperation.BackflushQty -= prodOpReport.GAMNG; orderOperation.BackflushQty -= prodOpReport.SCRAP; } orderOperation.ReportQty -= prodOpReport.GAMNG; orderOperation.ScrapQty -= prodOpReport.SCRAP; this.genericMgr.Update(orderOperation); //if (refOrderOperationList != null && refOrderOperationList.Count > 0) //{ // foreach (OrderOperation refOrderOperation in refOrderOperationList) // { // this.genericMgr.Update(refOrderOperation); // } //} #endregion #region 更新工序报工记录状态 orderOperationReport.Status = CodeMaster.OrderOpReportStatus.Cancel; orderOperationReport.CancelDate = dateTimeNow; orderOperationReport.CancelUser = user.Id; orderOperationReport.CancelUserName = user.FullName; this.genericMgr.Update(orderOperationReport); #endregion #region 插入取消报工记录 com.Sconit.Entity.SAP.ORD.CancelProdOpReport cancelProdOpReport = new Entity.SAP.ORD.CancelProdOpReport(); cancelProdOpReport.AUFNR = prodOpReport.AUFNR; cancelProdOpReport.TEXT = prodOpReport.Id.ToString(); cancelProdOpReport.Status = Entity.SAP.StatusEnum.Pending; cancelProdOpReport.CreateDate = dateTimeNow; cancelProdOpReport.LastModifyDate = dateTimeNow; cancelProdOpReport.ErrorCount = 0; cancelProdOpReport.ReceiptNo = prodOpReport.ReceiptNo; cancelProdOpReport.OrderNo = prodOpReport.OrderNo; cancelProdOpReport.OrderOpId = prodOpReport.OrderOpId; if (!isReportToSAP) { #region 生产单报工还未传给SAP #region 新增取消报工记录 cancelProdOpReport.Status = Entity.SAP.StatusEnum.Success; this.genericMgr.Create(cancelProdOpReport); this.genericMgr.FlushSession(); #endregion #endregion } else { #region 生产单报工已经传给SAP #region 取消报工传给SAP try { SAPService.SAPService sapService = new SAPService.SAPService(); sapService.Url = this.systemMgr.ReplaceSIServiceUrl(sapService.Url); IList<string> errorMsgList = sapService.CancelReportProdOrderOperation(cancelProdOpReport.AUFNR, cancelProdOpReport.TEXT, user.Code); if (errorMsgList != null && errorMsgList.Count > 0) { BusinessException businessException = new BusinessException(); foreach (string errorMsg in errorMsgList) { businessException.AddMessage(errorMsg); } throw businessException; } this.genericMgr.Create(cancelProdOpReport); this.genericMgr.FlushSession(); } catch (SoapException sex) { throw new BusinessException(sex.Actor); } catch (BusinessException bex) { throw bex; } catch (Exception ex) { throw new BusinessException("取消报工异常,异常信息:{0}。", ex.Message); } #endregion #endregion } #endregion }
public ActionResult _AjaxScheduleLineItem(GridCommand command, string Item, string Supplier) { try { if (command.Page > 1 && TempData["scheduleLineItemList"] != null) { IList<ScheduleLineItem> scheduleLineItemListReturn = TempData["scheduleLineItemList"] != null ? TempData["scheduleLineItemList"] as IList<ScheduleLineItem> : null; TempData["scheduleLineItemList"] = scheduleLineItemListReturn; GridModel<ScheduleLineItem> returnGrid = new GridModel<ScheduleLineItem>(); returnGrid.Total = scheduleLineItemListReturn.Count; returnGrid.Data = scheduleLineItemListReturn.Skip((command.Page - 1) * command.PageSize).Take(command.PageSize); return PartialView(returnGrid); } var user = SecurityContextHolder.Get(); SAPService.SAPService sapService = new SAPService.SAPService(); sapService.Url = ReplaceSIServiceUrl(sapService.Url); sapService.Timeout = 600000; //int.Parse(this.systemMgr.GetEntityPreferenceValue(com.Sconit.Entity.SYS.EntityPreference.CodeEnum.SAPServiceTimeOut)); IList<object[]> objList = sapService.GetScheduleLineItem(user.Code, Item, Supplier, GetSAPPlant()); IList<ScheduleLineItem> scheduleLineItemList = new List<ScheduleLineItem>(); // IList<Item> itemList = new List<Item>(); string[] deleteSupplierArr = new string[] { "9000000013", "1000002749", "1000002523", "1000002192", "1000002191", "1000002190", "1000002184", "1000001780", "1000000619", "1000000482", "1000000630", "1000000759", "1000001680", "1000000787" }; objList = (from o in objList where !deleteSupplierArr.Contains(o[0]) && o[0] != null && o[0] != string.Empty && o[1] != string.Empty && o[1] != string.Empty select o).ToList(); StringBuilder hql = new StringBuilder(); IList<object> parm = new List<object>(); List<Item> itemList = new List<Item>(); StringBuilder supplierHql = new StringBuilder(); IList<object> supplierParm = new List<object>(); List<Supplier> supplierList = new List<Supplier>(); int j = 0; if (objList != null && objList.Count > 0) { #region int i = 0; while (i < objList.Count) { for (int ii = 0; ii < 2000; ii++) { if (i == objList.Count) { break; } ScheduleLineItem scheduLineItem = new ScheduleLineItem(); scheduLineItem.Supplier = (string)objList[i][0]; scheduLineItem.Item = (string)objList[i][1]; scheduLineItem.EBELN = (string)objList[i][2]; scheduLineItem.EBELP = (string)objList[i][3]; //if (string.IsNullOrEmpty(scheduLineItem.Supplier) || scheduLineItem.Supplier == null || string.IsNullOrEmpty(scheduLineItem.Item) || scheduLineItem.Item == null) //{ // j++; // i++; // continue; //} //bool deleteSup = false; ////数组中的供应商过滤掉 //deleteSup = deleteSupplierArr.Where(d => d == scheduLineItem.Supplier).Count() > 0; //if (deleteSup) //{ // j++; // i++; // continue; //} if (hql.Length == 0) { hql.Append("from Item where Code in (?"); supplierHql.Append(" from Supplier as s where s.Code in(?"); } else { hql.Append(", ?"); supplierHql.Append(", ?"); } parm.Add(scheduLineItem.Item); supplierParm.Add(scheduLineItem.Supplier); scheduleLineItemList.Add(scheduLineItem); i++; } if (hql != null && hql.ToString() != string.Empty) { IList<Item> CurrentItemList = base.genericMgr.FindAll<Item>(hql.ToString() + ")", parm.ToArray()); if (CurrentItemList != null && CurrentItemList.Count > 0) { itemList.AddRange(CurrentItemList); } IList<Supplier> CurrentSupplierList = base.genericMgr.FindAll<Supplier>(supplierHql.ToString() + ")", supplierParm.ToArray()); { supplierList.AddRange(CurrentSupplierList); } } hql = new StringBuilder(); parm = new List<object>(); supplierHql = new StringBuilder(); supplierParm = new List<object>(); // itemList.Add( base.genericMgr.FindAll<Item>(hql + ")", parm.ToArray())); } if (itemList != null && itemList.Count > 0) { foreach (ScheduleLineItem scheduleLineItem in scheduleLineItemList) { //var item = itemList.FirstOrDefault(t => t.Code == scheduleLineItem.Item); var items = itemList.Where(t => t.Code == scheduleLineItem.Item); if (items != null && items.Count() > 0) { var item = items.First(); scheduleLineItem.Description = item.Description; scheduleLineItem.Uom = item.Uom; scheduleLineItem.Container = item.Container; scheduleLineItem.ReferenceCode = item.ReferenceCode; scheduleLineItem.UnitCount = item.UnitCount; } //scheduleLineItem.ContainerDesc = item.ContainerDesc; //var supplier = supplierList.FirstOrDefault(s => s.Code == scheduleLineItem.Supplier); var suppliers = supplierList.Where(s => s.Code == scheduleLineItem.Supplier); if (suppliers != null && suppliers.Count() > 0) { var supplier = suppliers.First(); scheduleLineItem.Name = supplier.Name; scheduleLineItem.ShortCode = supplier.ShortCode; } } } #endregion } GridModel<ScheduleLineItem> grid = new GridModel<ScheduleLineItem>(); grid.Total = objList.Count - j; TempData["scheduleLineItemList"] = scheduleLineItemList; grid.Data = scheduleLineItemList.Skip((command.Page - 1) * command.PageSize).Take(command.PageSize); return PartialView(grid); } catch (BusinessException ex) { SaveBusinessExceptionMessage(ex); } catch (Exception ex) { SaveErrorMessage(ex); } return PartialView(new GridModel<ScheduleLineItem>() { Data = new List<ScheduleLineItem>(), Total = 0 }); #region //com.Sconit.Entity.ACC.User user = SecurityContextHolder.Get(); //string whereStatement = "where exists (" + // " select 1 from UserPermissionView as p where p.UserId =" + user.Id + " and p.PermissionCode=s.Supplier)"; //IList<object> param = new List<object>(); //HqlStatementHelper.AddLikeStatement("Item", Item, HqlStatementHelper.LikeMatchMode.Start, "s", ref whereStatement, param); //HqlStatementHelper.AddEqStatement("Supplier", Supplier, "s", ref whereStatement, param); //string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors); //SearchStatementModel searchStatementModel = new SearchStatementModel(); //searchStatementModel.SelectCountStatement = "select count(*) from ScheduleLineItem as s "; //searchStatementModel.SelectStatement = "select s from ScheduleLineItem as s"; //searchStatementModel.WhereStatement = whereStatement; //searchStatementModel.SortingStatement = sortingStatement; //searchStatementModel.Parameters = param.ToArray<object>(); //GridModel<ScheduleLineItem> grid = GetAjaxPageData<ScheduleLineItem>(searchStatementModel, command); //if (grid.Data != null && grid.Data.Count() > 0) //{ // var items = grid.Data.Select(o => o.Item).ToArray(); // IList<Item> itemList = new List<Item>(); // string hql = string.Empty; // IList<object> parm = new List<object>(); // foreach (string itemCode in items.Distinct()) // { // if (hql == string.Empty) // { // hql = "from Item where Code in (?"; // } // else // { // hql += ", ?"; // } // parm.Add(itemCode); // } // itemList = base.genericMgr.FindAll<Item>(hql + ")", parm.ToArray()); // if (itemList != null && itemList.Count > 0) // { // foreach (ScheduleLineItem scheduleLineItem in grid.Data) // { // foreach (var item in itemList) // { // if (scheduleLineItem.Item == item.Code) // { // scheduleLineItem.Description = item.Description; // scheduleLineItem.Uom = item.Uom; // scheduleLineItem.ReferenceCode = item.ReferenceCode; // scheduleLineItem.UnitCount = item.UnitCount; // } // } // } // } //} //return PartialView(grid); #endregion }
public ActionResult _AjaxDemandPlanList(GridCommand command, OrderMasterSearchModel searchModel) { try { //if (string.IsNullOrWhiteSpace(searchModel.Item)) //{ // return PartialView(new GridModel(new List<ScheduleBody>())); //} #region 重新调用取最新的 string item = searchModel.Item != string.Empty && searchModel.Item != null ? searchModel.Item : string.Empty; SAPService.SAPService sapService = new SAPService.SAPService(); sapService.Url = ReplaceSIServiceUrl(sapService.Url); com.Sconit.Entity.ACC.User user = SecurityContextHolder.Get(); IList<com.Sconit.Web.SAPService.OrderDetail> scheduleList = sapService.GetProcOrders(null, user.Code.Trim(), item, GetSAPPlant(), user.Code); #endregion DateTime dateTimeNow = DateTime.Now; int listDays = searchModel.ListDays == null ? 21 : (searchModel.ListDays.Value > 0 ? searchModel.ListDays.Value : 0); ScheduleView scheduleView = PrepareScheduleViewBySupplier(searchModel.Flow, searchModel.Item, dateTimeNow, listDays, scheduleList, searchModel.NotIncludeZeroShipQty); var returnList = new List<ScheduleBody>(); IList<ScheduleBody> scheduleBodyList = scheduleView.ScheduleBodyList != null && scheduleView.ScheduleBodyList.Count > 0 ? scheduleView.ScheduleBodyList.OrderBy(s => s.ReferenceItemCode).ThenBy(s => s.OrderNo).ToList() : new List<ScheduleBody>(); foreach (var scheduleBody in scheduleBodyList) { if (scheduleBody.RowCellList != null && scheduleBody.RowCellList.Count > 0) { //需求预测的已收数要以sap的为准 scheduleBody.ReceivedQty = scheduleBody.RowCellList.Sum(r => r.ReceivedQty).ToString("0.###"); scheduleBody.DemandDate = scheduleBody.RowCellList.Min(r => r.EndDate).Value.ToShortDateString() + "-" + scheduleBody.RowCellList.Max(r => r.EndDate).Value.ToShortDateString(); scheduleBody.DemandQty = Convert.ToDecimal(scheduleBody.ForecastQty) + Convert.ToDecimal(scheduleBody.BackOrderQty); } else { //需求预测的已收数要以sap的为准 scheduleBody.ReceivedQty = scheduleBody.RowCellList.Sum(r => r.ReceivedQty).ToString("0.###"); scheduleBody.DemandDate = DateTime.Now.ToString() + "-" + DateTime.Now.ToString(); scheduleBody.DemandQty = Convert.ToDecimal(scheduleBody.BackOrderQty); } } TempData["DemandPlanList"] = scheduleBodyList; scheduleBodyList = scheduleBodyList.Where(r => r.DemandQty.ToString("0.###") != r.ReceivedQty).ToList(); GridModel<ScheduleBody> gridmodel = new GridModel<ScheduleBody>(); gridmodel.Total = scheduleBodyList.Count; gridmodel.Data = scheduleBodyList.Skip((command.Page - 1) * command.PageSize).Take(command.PageSize); return PartialView(gridmodel); } catch (SoapException ex) { SaveErrorMessage(ex.Actor); } catch (BusinessException ex) { SaveBusinessExceptionMessage(ex); } catch (Exception ex) { SaveErrorMessage(ex); } return PartialView(new GridModel(new List<ScheduleBody>())); }