Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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 _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>()));
        }