private string GetMasterChildRollNumber(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto) { int count = _repository.Repository <TPOCProductRoll>().GetAllBy(pr => pr.MasterRollID == tpoCProductRollDto.MasterRollID).Count(); count++; return(GetMasterRollNumber(tpoCProductRollDto, prodLineDto) + count.ToString("00")); }
private string GetIMRollNumber(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto) { bool old = false; string newLotNumber = GetNewLotNumber(tpoCProductRollDto); if (tpoCProductRollDto.RawMaterialReceivedID != 0) { try { RawMaterialReceived rm = _repository.Repository <RawMaterialReceived>().GetById(tpoCProductRollDto.RawMaterialReceivedID); if (rm.LotNumber.Substring(0, 7) != newLotNumber) { old = true; } } catch { old = true; } } WorkOrder workOrder = _repository.Repository <WorkOrder>().GetById(tpoCProductRollDto.WorkOrderID); string newProdCode = string.Empty; if (old) { newProdCode = FillOldIMLot(newLotNumber, workOrder); } else { newProdCode = FillCurrentIMLot(newLotNumber, workOrder); } return(newProdCode); }
public string GetNewRollOrCartonCode(IProductEntryDto dto) { ProductionLinesDto productionLinesDto = GetProdLineDto(dto.LineID); ProdLineTypeDto prodLineTypeDto = GetProdLineTypeDto(productionLinesDto.LineTypeID); return(GetNewRollOrCartonCode(dto, productionLinesDto, prodLineTypeDto)); }
private string GetChildRollNumber(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto) { // TODO: FIXME string masterRollNumber = GetMasterRollNumber(tpoCProductRollDto, prodLineDto); int count = _repository.Repository <TPOCProductRoll>().GetAllBy(pr => pr.Code.StartsWith(masterRollNumber)).Count(); count++; return(masterRollNumber + count.ToString("00")); }
public void EditProdEntry(TPOCProductRollDto tpoCProductRollDto) { int count = 0; if (!string.IsNullOrEmpty(tpoCProductRollDto.Code)) { count = _repository.Repository <TPOCProductRoll>().GetAllBy(r => r.Code == tpoCProductRollDto.Code).Count(); // can't add a new roll with same name as one that exists if (count > 0 && tpoCProductRollDto.ID == 0) { tpoCProductRollDto.Code = string.Empty; } } ProductionLinesDto prodLineDto = GetProdLineDto(tpoCProductRollDto.LineID); ProdLineTypeDto prodLineTypeDto = GetProdLineTypeDto(prodLineDto.LineTypeID); if (string.IsNullOrEmpty(tpoCProductRollDto.Code)) { tpoCProductRollDto.Code = GetNewRollOrCartonCode(tpoCProductRollDto, prodLineDto, prodLineTypeDto); } tpoCProductRollDto.ProductID = GetTPOProductId(tpoCProductRollDto); tpoCProductRollDto.BatchNumber = GetBatchNumber(tpoCProductRollDto); tpoCProductRollDto.LengthUoMID = GetUomId(tpoCProductRollDto.LengthUoM); tpoCProductRollDto.WeightUoMID = GetUomId(tpoCProductRollDto.WeightUoM); TPOCProductRoll entity; if (tpoCProductRollDto.ID == 0) { entity = new TPOCProductRoll(); Mapper.Map(tpoCProductRollDto, entity); _repository.Repository <TPOCProductRoll>().Insert(entity); } else { entity = GetById(tpoCProductRollDto.ID); _repository.Repository <TPOCProductRoll>().Update(entity); } if (IsFlashingMasterRoll(tpoCProductRollDto)) { AddToReworkList(tpoCProductRollDto); } if (prodLineTypeDto.ProdLineTypeCode == "TPO" || prodLineTypeDto.ProdLineTypeCode == "CO") { UpdateScrimUsageEntry(tpoCProductRollDto); } CommitUnitOfWork(); }
public JsonResult FetchProductionLines() { List <ProductionLinesDto> productionLines = new List <ProductionLinesDto>(); using (TPO.Services.Production.ProductionLineService service = new TPO.Services.Production.ProductionLineService()) { productionLines = service.GetByPlant(CurrentPlantId); } // create default DTO ProductionLinesDto defaultItem = new ProductionLinesDto(); defaultItem.ID = 0; defaultItem.LineDesc = "--- Select Line ---"; productionLines.Insert(0, defaultItem); return(Json(productionLines, JsonRequestBehavior.AllowGet)); }
public string GetNewRollOrCartonCode(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto, ProdLineTypeDto prodLineTypeDto) { switch (prodLineTypeDto.ProdLineTypeCode) { case "TPO": if (prodLineDto.TPOMorC == "M") { return(GetMasterRollNumber(tpoCProductRollDto, prodLineDto)); } else if (!tpoCProductRollDto.MasterRollID.HasValue) { return(GetChildRollNumber(tpoCProductRollDto, prodLineDto)); } else { return(GetMasterChildRollNumber(tpoCProductRollDto, prodLineDto)); } break; case "WI": return(GetMasterChildRollNumber(tpoCProductRollDto, prodLineDto)); break; case "RW": return(GetChildRollNumber(tpoCProductRollDto, prodLineDto)); break; case "IM": return(GetIMRollNumber(tpoCProductRollDto, prodLineDto)); break; case "CO": return(GetChildRollNumber(tpoCProductRollDto, prodLineDto)); break; default: throw new ArgumentOutOfRangeException("Unknown Production Line Type"); } }
private string GetMasterRollNumber(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto) { return(prodLineDto.LabelID.ToString("00") + (tpoCProductRollDto.ProductionDate.Year % 100).ToString("00") + tpoCProductRollDto.ProductionDate.DayOfYear.ToString("000") + "01"); }
public JsonResult GetWorkOrderShiftData(int lineID, int shiftID, int workOrderID, DateTime prodDate) { WorkOrderShiftDataModel model = new WorkOrderShiftDataModel(); //Set default units of measure using (UnitOfMeasureService svc = new UnitOfMeasureService()) { var lengthDefault = svc.GetDefaultByTypeCode("L"); if (lengthDefault != null) { model.LengthUnitOfMeasure = lengthDefault.Code; } var weightDefault = svc.GetDefaultByTypeCode("W"); if (weightDefault != null) { model.WeightUnitOfMeasure = weightDefault.Code; } } //Get production line ProductionLinesDto lineDto = null; using (ProductionLineService lineSvc = new ProductionLineService()) { lineDto = lineSvc.Get(lineID); } if (lineDto != null) { List <TPOCProductRollDto> rollDtos = new List <TPOCProductRollDto>(); using (TPOCProductRollService rollSvc = new TPOCProductRollService()) { if (lineDto.TPOMorC == "M") { //Get master rolls rollDtos.AddRange(rollSvc.GetMasterRollsByShift(lineID, shiftID, prodDate)); } else { //Get child rolls rollDtos.AddRange(rollSvc.GetChildRollsByShift(lineID, shiftID, prodDate)); } } //Filter for rolls specific to the work order var workOrderRolls = rollDtos.Where(r => r.WorkOrderID == workOrderID).ToList(); model.RollCount1 = workOrderRolls.Count; model.Length1 = workOrderRolls.Sum(r => r.Length); model.Weight1 = workOrderRolls.Sum(r => r.Weight); model.ShiftRollWeight = rollDtos.Sum(r => r.Weight); //Get scraps List <TPOLineScrapDto> scrapDtos = new List <TPOLineScrapDto>(); using (TPOLineScrapService scrapSvc = new TPOLineScrapService()) { scrapDtos.AddRange(scrapSvc.GetByShift(shiftID, prodDate)); } //Filter for scraps specific to the work order var woScraps = scrapDtos.Where(s => s.WorkOrderID == workOrderID).ToList(); for (int i = 0; i < woScraps.Count; i++) { switch (woScraps[i].TPOLineScrapTypeDescription) { case "Second": { model.Length2 += woScraps[i].Length; model.Weight2 += woScraps[i].Weight; } break; case "Third": { model.Length3 += woScraps[i].Length; model.Weight3 += woScraps[i].Weight; } break; case "Fourth": { model.Length4 += woScraps[i].Length; model.Weight4 += woScraps[i].Weight; } break; } } model.ShiftScrapWeight = scrapDtos.Sum(s => s.Weight); //Get downtime List <DownTimeDto> dtDtos = new List <DownTimeDto>(); using (DownTimeService dtSvc = new DownTimeService()) { dtDtos.AddRange(dtSvc.GetByShift(lineID, shiftID, prodDate)); } var woDowntime = dtDtos.Where(dt => dt.WorkOrderID == workOrderID).ToList(); model.DownTimeMinutes = woDowntime.Sum(dt => dt.DownTimeMinutes); model.ShiftDownTimeMinutes = dtDtos.Sum(dt => dt.DownTimeMinutes); //Get production line schedule List <ProductionLineScheduleDto> plSchedDtos = new List <ProductionLineScheduleDto>(); using (ProductionLineScheduleService plSchedSvc = new ProductionLineScheduleService()) { plSchedDtos.AddRange(plSchedSvc.GetByShift(lineID, shiftID, prodDate)); } model.ScheduledRunTime = plSchedDtos.Sum(s => s.MinutesScheduled); //Check if feeder entry forms need to be used if (lineDto.LineDescCode == "TPO") { model.RMUse = true; List <TPOFormulationLineProductDto> formDtos = new List <TPOFormulationLineProductDto>(); using (TPOFormulationLineProductService formSvc = new TPOFormulationLineProductService()) { formDtos.AddRange(formSvc.GetByWorkOrder(lineID, workOrderID)); } if (formDtos.Count > 0) { model.Form = formDtos.First().TPOFormulationID; model.Extruders = formDtos.First().TPOFormulationExtruders; } List <WorkOrderShiftDataDto> eorDtos = new List <WorkOrderShiftDataDto>(); using (WorkOrderShiftDataService eorSvc = new WorkOrderShiftDataService()) { eorDtos.AddRange(eorSvc.GetByShift(lineID, shiftID, prodDate)); if (eorDtos.Count == 0) { eorSvc.Add(new WorkOrderShiftDataDto() { LineID = lineID, ProductionDate = prodDate, ShiftID = shiftID, WorkOrderID = workOrderID, PlantID = CurrentPlantId, EnteredBy = CurrentUser, DateEntered = DateTime.Now, ModifiedBy = CurrentUser, LastModified = DateTime.Now }); } else { model.ScrimA = eorDtos.First().ScrimAreaUsed; model.ScrimW = eorDtos.First().ScrimWeightUsed; model.Resin = eorDtos.First().DrainedResin; } } } } return(Json(model, JsonRequestBehavior.AllowGet)); }