예제 #1
0
        public ActionResult _Update(GridCommand command, MrpPlan mrpPlan, string importTypeTo, string flowTo, DateTime? startDateTo
            , DateTime? endDateTo, string startWeekTo, string endWeekTo, string itemTo)
        {
            MrpPlanSearchModel searchModel = new MrpPlanSearchModel();
            searchModel.ImportType = importTypeTo;
            searchModel.Flow = flowTo;
            searchModel.Item = itemTo;
            searchModel.StartDate = startDateTo;
            searchModel.EndDate = endDateTo;
            searchModel.StartWeek = startWeekTo;
            searchModel.EndWeek = endWeekTo;

            MrpPlan newMrpPlan = genericMgr.FindAll<MrpPlan>(
                @" from MrpPlan as m where  m.PlanDate=? and m.Item=? and m.Flow=? and m.Location=?",
                new object[] { mrpPlan.PlanDate, mrpPlan.Item, mrpPlan.Flow, mrpPlan.Location })[0];
            if (mrpPlan.Qty != newMrpPlan.Qty || mrpPlan.OrderQty != newMrpPlan.OrderQty)
            {
                newMrpPlan.CurrentQty = mrpPlan.Qty;
                newMrpPlan.OrderQty = mrpPlan.OrderQty;
                this.planMgr.UpdateMrpPlan(newMrpPlan);
            }

            SearchStatementModel searchStatementModel = PrepareSearchStatement(command, searchModel);
            return PartialView(GetAjaxPageData<MrpPlan>(searchStatementModel, command));
        }
예제 #2
0
 public void UpdateMrpPlan(MrpPlan mrpPlan)
 {
     mrpPlan.Qty = mrpPlan.CurrentQty;
     this.genericMgr.Update(mrpPlan);
     User user = SecurityContextHolder.Get();
     var mrpPlanLog = this.genericMgr.FindAll<MrpPlanLog>
         (" from MrpPlanLog where PlanDate=? and Item = ? and PlanVersion=? and Flow=? and Location=?",
         new object[] { mrpPlan.PlanDate, mrpPlan.Item, mrpPlan.PlanVersion, mrpPlan.Flow, mrpPlan.Location })
         .First();
     mrpPlanLog.Qty = mrpPlan.Qty;
     mrpPlanLog.UnitQty = 1;
     this.genericMgr.Update(mrpPlanLog);
 }
예제 #3
0
        public void CreateMrpPlan(string flowCode, List<MrpPlanLog> mrpPlanLogList)
        {
            var flowStategy = this.genericMgr.FindAll<FlowStrategy>(" from FlowStrategy where Flow =? ", flowCode).First();
            var leadTime = DateTimeHelper.TimeTranfer(flowStategy.LeadTime, flowStategy.TimeUnit, CodeMaster.TimeUnit.Day);

            var user = SecurityContextHolder.Get();
            var mrpPlanDic = this.genericMgr.FindAll<MrpPlan>
                ("select d from MrpPlan as d where d.PlanDate>=? and  d.Flow=? ",
                new object[] { mrpPlanLogList.Min(p => p.PlanDate).AddDays(-leadTime), flowCode })
                 .GroupBy(p => p.Item, (k, g) => new { k, g }).ToDictionary(d => d.k, d => d.g.ToList());

            int planVersion = int.Parse(numberControlMgr.GetNextSequence(com.Sconit.Entity.MRP.BusinessConstants.NUMBERCONTROL_DAILYLYPLAN + "_" + flowCode));
            foreach (var mrpPlanLog in mrpPlanLogList)
            {
                mrpPlanLog.WindowTime = mrpPlanLog.PlanDate;
                //提前期
                mrpPlanLog.PlanDate = mrpPlanLog.WindowTime.AddDays(-Math.Round(leadTime));

                var q_mrpPlan = (mrpPlanDic.ValueOrDefault(mrpPlanLog.Item) ?? new List<MrpPlan>())
                    .Where(p => p.Flow == flowCode && p.PlanDate == mrpPlanLog.PlanDate && p.Location == mrpPlanLog.Location);

                MrpPlan mrpPlan = new MrpPlan();
                if (q_mrpPlan.Count() == 0)
                {
                    #region New DailyPlan
                    mrpPlan.Flow = flowCode;
                    mrpPlan.PlanDate = mrpPlanLog.PlanDate;
                    mrpPlan.Item = mrpPlanLog.Item;
                    mrpPlan.Location = mrpPlanLog.Location;
                    mrpPlan.Qty = mrpPlanLog.Qty * (double)mrpPlanLog.UnitQty;
                    mrpPlan.PlanVersion = planVersion;
                    mrpPlan.Party = mrpPlanLog.Party;
                    mrpPlan.OrderType = mrpPlanLog.OrderType;
                    this.genericMgr.Create(mrpPlan);
                    #endregion

                    #region New DailyPlanLog
                    mrpPlanLog.PlanVersion = mrpPlan.PlanVersion;
                    mrpPlanLog.CreateDate = System.DateTime.Now;
                    mrpPlanLog.CreateUserId = user.Id;
                    mrpPlanLog.CreateUserName = user.FullName;
                    this.genericMgr.Create(mrpPlanLog);
                    #endregion
                }
                else if (q_mrpPlan.Count() == 1)
                {
                    if (q_mrpPlan.First().Qty != mrpPlanLog.Qty * (double)mrpPlanLog.UnitQty)
                    {
                        mrpPlan = q_mrpPlan.First();
                        mrpPlan.Qty = mrpPlanLog.Qty * (double)mrpPlanLog.UnitQty;
                        mrpPlan.PlanVersion = planVersion;
                        this.genericMgr.Update(mrpPlan);

                        #region New DailyPlanlog
                        mrpPlanLog.PlanVersion = mrpPlan.PlanVersion;
                        mrpPlanLog.CreateDate = System.DateTime.Now;
                        mrpPlanLog.CreateUserId = user.Id;
                        mrpPlanLog.CreateUserName = user.FullName;
                        this.genericMgr.Create(mrpPlanLog);
                        #endregion
                    }
                }
                else
                {
                    throw new TechnicalException("Error:DateException");
                }
            }
        }