public ActionResult AddNew() { ViewBag.Party_Id = new SelectList(db.Parties.Where(m => m.Status == true).ToList(), "Party_Id", "Party_Name"); ViewBag.RawRice_id = new SelectList(db.RarRices.Where(m => m.Status == true).ToList(), "RawRice_id", "Item_Name"); var Pricing = db.Pricing.Where(m => m.Status == true).ToList(); var RawRice = db.RarRices.Where(m => m.Status == true).ToList(); ViewBag.Rice_category_Id = new SelectList(db.Rice_Categories.Where(m => m.Status == true).ToList(), "Rice_category_Id", "Rice_Category_Name"); ViewBag.Packing_Id = new SelectList(db.Packings.ToList(), "Packing_Id", "Packing_Type"); var viewModel = new ProductionViewModel { RawRices = RawRice, Pricings = Pricing }; return(View(viewModel)); }
private ProductionViewModel InitProductionViewModel(ProductionViewModel model) { var company = GlobalFunctions.GetCompanyList(_companyBll); if (CurrentUser.UserRole != Enums.UserRole.Administrator) { var userPlantCompany = _userPlantMapBll.GetCompanyByUserId(CurrentUser.USER_ID); var poaMapCompany = _poaMapBll.GetCompanyByPoaId(CurrentUser.USER_ID); var distinctCompany = company.Where(x => userPlantCompany.Contains(x.Value)); if (CurrentUser.UserRole == Enums.UserRole.POA) { distinctCompany = company.Where(x => poaMapCompany.Contains(x.Value)); } company = new SelectList(distinctCompany, "Value", "Text"); } var listPlant = GlobalFunctions.GetPlantAll().Where(x => CurrentUser.ListUserPlants.Contains(x.Value)); model.CompanyCodeList = company; model.PlantWerkList = new SelectList(listPlant, "Value", "Text"); model.MonthList = GlobalFunctions.GetMonthList(_monthBll); model.YearList = ProductionYearList(); model.Month = DateTime.Now.Month.ToString(); model.Year = DateTime.Now.Year.ToString(); var input = Mapper.Map <ProductionGetByParamInput>(model); input.ProoductionDate = null; input.UserRole = CurrentUser.UserRole; input.ListUserPlants = CurrentUser.ListUserPlants; var dbData = _productionBll.GetFactAllByParam(input).OrderByDescending(x => x.PRODUCTION_DATE).ToList(); model.Details = Mapper.Map <List <ProductionDetail> >(dbData); return(model); }
public MainViewModel() { Consumption = new ConsumptionViewModel(new ConsumersService()); Production = new ProductionViewModel(new ProductionService()); Retail = new RetailViewModel(); }
public OEEController(ApplicationDbContext context) { _context = context; _productionViewModel = new ProductionViewModel(); _oeeViewModel = new OEEViewModel(); }
public async Task Initailize() { if (SalesManagerViewModel == null) { var salesProducts = await _SalesProductService.GetSalesProducts(); var pigStock = salesProducts .Select(d => d.Production.LivestockProduct) .FirstOrDefault(d => d.Name.Equals("돼지")); // Create SalesManagerViewModel SalesManagerViewModel = new SalesManagerViewModel { Id = pigStock.Id, Name = pigStock.Name, UnitPrice = pigStock.UnitPrice, Weight = pigStock.Weight, }; foreach (var salesProduct in salesProducts.Where(d => d.Production.LivestockProduct.Name.Equals("돼지"))) { // Add ProductionViewModel var productionViewMdoel = new ProductionViewModel(SalesManagerViewModel) { Id = salesProduct.Id, Name = salesProduct.Production.Name, Weight = salesProduct.Production.Weight, TransferRate = salesProduct.Production.TransferRate, MarginRate = salesProduct.Production.MarginRate, }; productionViewMdoel.PropertyChanged += ProductionViewMdoel_PropertyChanged; SalesManagerViewModel.Productions.Add(productionViewMdoel); // Add SalesProductViewModel var salesProductViewModel = new SalesProductViewModel(productionViewMdoel) { Id = salesProduct.Id, Name = salesProduct.Production.Name, CommisionRate = salesProduct.CommssionRate, ShippingCost = salesProduct.ShippingCost, Weight = salesProduct.Weight, }; var packingInfo = salesProduct.PackingInfo; if (packingInfo != null) { salesProductViewModel.PackResources.PackingWeight = packingInfo.PackingWeight; foreach (var packResource in packingInfo.Resources) { salesProductViewModel.PackResources.ItemList.Add(new PackResourceViewModel { Id = packResource.Resource.Id, Name = packResource.Resource.Name, Price = packResource.Resource.Price, Type = packResource.Resource.Type, Count = packResource.Count, }); } } salesProductViewModel.PackResources.ApplyToAllProductRequest += PackResources_ApplyToAllProductRequest; salesProductViewModel.PackingInfoUpdated += SalesProductViewModel_PackingInfoUpdated; salesProductViewModel.PackingResourceUpdated += SalesProductViewModel_PackingResourceUpdated; salesProductViewModel.PropertyChanged += SalesProductViewModel_PropertyChanged; SalesManagerViewModel.SalesProducts.Add(salesProductViewModel); } // Initialize PropertyChangedEvent SalesManagerViewModel.PropertyChanged += SalesManagerViewModel_PropertyChanged; } }
public ProductionController(ApplicationDbContext context) { _context = context; _productionViewModel = new ProductionViewModel(); }
public async Task <JsonResult> GetTaskSummaries(string startDate, string endDate, string machineNo, string machineGroup, string machineModel, string pdLine) { _productionViewModel = new ProductionViewModel(); var machines = await _context.Machines.ToListAsync(); _productionViewModel.AvailableTime = machines.Sum(x => x.WorkingHr * 60); _productionViewModel.AvailableTimeHr = string.Format("{0:00}:{1:00}", _productionViewModel.AvailableTime / 60, _productionViewModel.AvailableTime % 60); DateTime date1 = string.IsNullOrEmpty(startDate) ? DateTime.Now.Date : Convert.ToDateTime(startDate).Date; DateTime date2 = string.IsNullOrEmpty(endDate) ? DateTime.Now.Date : Convert.ToDateTime(endDate).Date; var result = await _context.JobTasks.Include(c => c.JobEntity) .Include(c => c.Machine) .Where(x => x.DueDate.Date >= date1 && x.DueDate.Date <= date2 && x.ReleaseFlag) .OrderBy(o => o.Priority) .ThenBy(o => o.StartDate) .ToListAsync(); if (!string.IsNullOrEmpty(machineNo)) { result = result.Where(x => (string.IsNullOrEmpty(x.MachineNoReady) ? x.MachineNo : x.MachineNoReady) == machineNo).ToList(); } if (!string.IsNullOrEmpty(machineGroup)) { result = result.Where(x => x.Machine.MacGroup == machineGroup).ToList(); } if (!string.IsNullOrEmpty(machineModel)) { result = result.Where(x => x.Machine.MachineModel == machineModel).ToList(); } if (!string.IsNullOrEmpty(pdLine)) { result = result.Where(x => x.Machine.ProductionLine == pdLine).ToList(); } //Summaries _productionViewModel.PlanCount = result.Count(); _productionViewModel.ActualCount = result.Where(x => x.StartFlag).Count(); //Production Progress double ts = 0; foreach (var item in machines) { string iString = DateTime.Now.ToString("yyyy-MM-dd") + " " + item.MacStartTime.ToString("HH:mm"); DateTime oDate = DateTime.ParseExact(iString, "yyyy-MM-dd HH:mm", null); double tsi; tsi = DateTime.Now.Subtract(oDate).TotalMinutes; ts = ts + tsi; } double prgT = 0; foreach (var tsk in result.Where(x => x.StartFlag)) { double prg = tsk.StandardTime; prgT = prgT + prg; } var timeProgress = ts; _productionViewModel.TimePlan = result.Sum(x => x.StandardTime); _productionViewModel.TimeProgress = Convert.ToInt32((timeProgress / _productionViewModel.AvailableTime) * 100); _productionViewModel.ProductionProgress = Convert.ToInt32((prgT / _productionViewModel.AvailableTime) * 100); _productionViewModel.PlanProgress = Convert.ToInt32((_productionViewModel.TimePlan / _productionViewModel.AvailableTime) * 100); return(Json(_productionViewModel)); }
public ActionResult GetProductionsByQueryDateDate(GenericSearch search) { try { if (search.Year < 1) { ViewBag.ErrorCode = -1; ViewBag.ErrorMessage = "Please provide a valid Report Year"; return(View("Report", new ProductionViewModel { Products = new List <Product>(), Fields = new List <Field>(), YearList = GetYears(), MonthList = GetMonths(), ProductionObjects = new List <ProductionObject>() })); } if (search.Month > 0) { ViewBag.SearchPeriod = Enum.GetName(typeof(MonthList), search.Month) + "/" + search.Year; } else { ViewBag.SearchPeriod = search.Year; } var txd = new ProductionServices().GetProductionStaticReportByPeriod(PageNumber, ItemsPerPage, search.Month, search.Year); if (!txd.Any()) { ViewBag.ErrorMessage = "No record found"; ViewBag.ErrorCode = -1; return(View("Report", new ProductionViewModel { Products = new List <Product>(), Fields = new List <Field>(), YearList = GetYears(), MonthList = GetMonths(), ProductionObjects = new List <ProductionObject>() })); } var txx = new ProductionViewModel { Products = new List <Product>(), Fields = new List <Field>(), YearList = GetYears(), MonthList = GetMonths(), ProductionObjects = txd }; Session["_prodRepoPage"] = 1; Session["_prodRepoGenSearch"] = search; return(View("Report", txx)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); ViewBag.ErrorMessage = "No record found"; ViewBag.ErrorCode = -1; return(View("Report", new ProductionViewModel { Products = new List <Product>(), Fields = new List <Field>(), YearList = GetYears(), MonthList = GetMonths(), Productions = new List <Production>() })); } }