private OQCLot CreateNewLot(ActionEventArgs actionEventArgs, Item item, DBDateTime currentDBDateTime, bool forRework, string oldLotNo) { string lotNoMarkCode = forRework ? "R" : "L"; string lotType = forRework ? OQCLotType.OQCLotType_ReDO : OQCLotType.OQCLotType_Normal; string productionType = ""; decimal lotSize = 0; OQCFacade oqcFacade = new OQCFacade(DataProvider); TryFacade tryFacade = new TryFacade(this.DataProvider); OQCLot newOQCLot = null; OQCLot objLot = null; DateTime currentDateTime = FormatHelper.ToDateTime(currentDBDateTime.DBDate, currentDBDateTime.DBTime); object[] tryListOfRCard = null; object[] tryListOfOldLot = null; if (forRework) { OQCLot oldLot = oqcFacade.GetOQCLot(oldLotNo, OQCFacade.Lot_Sequence_Default) as OQCLot; productionType = oldLot.ProductionType; if (productionType == ProductionType.ProductionType_Try) { tryListOfRCard = tryFacade.GetTryListOfRCard(actionEventArgs.ProductInfo.NowSimulation.RunningCard, item.ItemCode); } //Lot Size lotSize = oldLot.LotCapacity; tryListOfOldLot = tryFacade.GetTryListOfLotNo(oldLot.LOTNO); } else { #region 先获取产品序列号对应的工单的productionType(来自于tblmo.momemo) // 先获取产品序列号对应的工单的productionType(来自于tblmo.momemo) MO mo = (new MOFacade(DataProvider)).GetMO(actionEventArgs.ProductInfo.NowSimulation.MOCode) as MO; SystemSettingFacade ssf = new SystemSettingFacade(this.DataProvider); Parameter param; param = ssf.GetParameter(mo.MOType, BenQGuru.eMES.Web.Helper.MOType.GroupType) as Parameter; if (param != null) { if (string.Compare(param.ParameterValue, BenQGuru.eMES.Web.Helper.MOType.MOTYPE_RMAREWORKMOTYPE, true) == 0) { productionType = ProductionType.ProductionType_Claim; } else { if (string.IsNullOrEmpty(mo.MOMemo)) { productionType = ProductionType.ProductionType_Mass; mo.MOMemo = MOProductType.MO_Product_Type_Mass.ToUpper(); } // 根据Memo获取ProductionType param = ssf.GetParameter(mo.MOMemo, MOProductType.GroupType) as Parameter; //changed by hiro 08/11/10 判断param不空进行比较 if (param != null) { if (string.Compare(param.ParameterValue, MOProductType.MO_Product_Type_New, true) == 0) { productionType = ProductionType.ProductionType_New; } else if (string.Compare(param.ParameterValue, MOProductType.MO_Product_Type_Mass, true) == 0) { productionType = ProductionType.ProductionType_Mass; } else { throw new Exception("$Error_MOMemoNotConfig $Domain_Parameter=" + mo.MOMemo); } tryListOfRCard = tryFacade.GetTryListOfRCard(actionEventArgs.ProductInfo.NowSimulation.RunningCard, item.ItemCode); if (tryListOfRCard != null && tryListOfRCard.Length > 0) { productionType = ProductionType.ProductionType_Try; } } else { throw new Exception("$CS_System_Params_Losted $Domain_ParameterGroup='" + MOProductType.GroupType + "' $Domain_Parameter=" + mo.MOMemo); } } } else { throw new Exception("$CS_System_Params_Losted $Domain_ParameterGroup='" + BenQGuru.eMES.Web.Helper.MOType.GroupType + "' $Domain_Parameter=" + mo.MOType); } #endregion } #region 获取ShiftDay和ShiftCode BaseSetting.BaseModelFacade dataModel = new BaseSetting.BaseModelFacade(this.DataProvider); Domain.BaseSetting.Resource res = (Domain.BaseSetting.Resource)dataModel.GetResource(actionEventArgs.ResourceCode); int shiftDay = 0; string shiftCode = string.Empty; BaseSetting.ShiftModelFacade shiftModel = new BaseSetting.ShiftModelFacade(this.DataProvider); Domain.BaseSetting.TimePeriod period = (Domain.BaseSetting.TimePeriod)shiftModel.GetTimePeriod(res.ShiftTypeCode, currentDBDateTime.DBTime); if (period == null) { throw new Exception("$OutOfPerid"); } shiftCode = period.ShiftCode; if (period.IsOverDate == Web.Helper.FormatHelper.TRUE_STRING) { if (period.TimePeriodBeginTime < period.TimePeriodEndTime) { shiftDay = FormatHelper.TODateInt(currentDateTime.AddDays(-1)); } else if (Web.Helper.FormatHelper.TOTimeInt(currentDateTime) < period.TimePeriodBeginTime) { shiftDay = FormatHelper.TODateInt(currentDateTime.AddDays(-1)); } else { shiftDay = FormatHelper.TODateInt(currentDateTime); } } else { shiftDay = FormatHelper.TODateInt(currentDateTime); } #endregion bool needCreateNewLot = false; bool needAddLotTryCode = false; // 获取Lot的主逻辑 if (productionType == ProductionType.ProductionType_Try) //试流批 { object[] lotList = oqcFacade.GetLotList4TryCase(item.ItemCode, res.StepSequenceCode, lotType, productionType, lotNoMarkCode); if (lotList == null || lotList.Length == 0) // 找不到对应的任何试流批,则新建试流批 { needCreateNewLot = true; needAddLotTryCode = true; } else // 找到多个,则遍历每一个,找其中试流批与RCard完全一致的批,若没有则新建试流批 { object[] tryListOfLot; foreach (OQCLot lotTemp in lotList) { tryListOfLot = tryFacade.GetTryListOfLotNo(lotTemp.LOTNO); if (tryListOfRCard != null && tryListOfRCard.Length != 0 && tryListOfLot != null && tryListOfLot.Length != 0 && this.CompareTryCodeList(tryListOfRCard, tryListOfLot) == true) { newOQCLot = oqcFacade.GetOQCLot(lotTemp.LOTNO, lotTemp.LotSequence) as OQCLot; break; } } if (newOQCLot == null) { needCreateNewLot = true; needAddLotTryCode = true; } } } else //新品批或量产批或理赔批 { objLot = oqcFacade.GetMaxLot4NormalCase(item.ItemCode, res.StepSequenceCode, lotType, productionType, lotNoMarkCode); if (objLot == null || objLot.LOTNO == null || objLot.LOTNO == string.Empty) { needCreateNewLot = true; needAddLotTryCode = false; } else { newOQCLot = oqcFacade.GetOQCLot(objLot.LOTNO, OQCFacade.Lot_Sequence_Default) as OQCLot; } } // Added By Hi1/Venus.Feng on 20081128 for Hisense Version // 增加了ForRework的这个条件 // 如果是Rework,都应该产生新的批,因为调用该函数之前,就已经by老的lot获取新的lot了,但是没有获取到 // 才会跑到该函数中,所以在该函数中对于Rework的Case,都应该产生新的批 // End Added if (needCreateNewLot || forRework) { newOQCLot = oqcFacade.CreateNewOQCLot(); objLot = oqcFacade.GetMaxLot(res.StepSequenceCode, shiftDay, lotNoMarkCode); if (objLot == null || objLot.LOTNO == null || objLot.LOTNO == string.Empty) { newOQCLot.LOTNO = res.StepSequenceCode + shiftDay.ToString() + lotNoMarkCode + "001"; } else { string oldLotNO = objLot.LOTNO; string newSequence = Convert.ToString((int.Parse(oldLotNO.Substring(oldLotNO.Length - 3, 3)) + 1)); newOQCLot.LOTNO = oldLotNO.Substring(0, oldLotNO.Length - 3) + newSequence.PadLeft(3, '0'); } // Create New OQC Lot if (forRework) { newOQCLot = oqcFacade.CreateNewOQCLot(newOQCLot.LOTNO, actionEventArgs.UserCode, currentDBDateTime, res.OrganizationID, lotSize, res.StepSequenceCode, item.ItemCode, oldLotNo, lotType, productionType, res.ResourceCode, shiftDay, shiftCode); } else { newOQCLot = oqcFacade.CreateNewOQCLot(newOQCLot.LOTNO, actionEventArgs.UserCode, currentDBDateTime, res.OrganizationID, item.LotSize, res.StepSequenceCode, item.ItemCode, oldLotNo, lotType, productionType, res.ResourceCode, shiftDay, shiftCode); } oqcFacade.AddOQCLot(newOQCLot); if (needAddLotTryCode || forRework) { Try2Lot try2Lot = null; if (forRework) { if (tryListOfOldLot != null && tryListOfOldLot.Length > 0) { foreach (Try tempTry in tryListOfOldLot) { try2Lot = tryFacade.CreateNewTry2Lot(); try2Lot.EAttribute1 = ""; try2Lot.LotNo = newOQCLot.LOTNO; try2Lot.MaintainDate = currentDBDateTime.DBDate; try2Lot.MaintainTime = currentDBDateTime.DBTime; try2Lot.MaintainUser = actionEventArgs.UserCode; try2Lot.TryCode = tempTry.TryCode; tryFacade.AddTry2Lot(try2Lot); } } } else { foreach (Try tempTry in tryListOfRCard) { try2Lot = tryFacade.CreateNewTry2Lot(); try2Lot.EAttribute1 = ""; try2Lot.LotNo = newOQCLot.LOTNO; try2Lot.MaintainDate = currentDBDateTime.DBDate; try2Lot.MaintainTime = currentDBDateTime.DBTime; try2Lot.MaintainUser = actionEventArgs.UserCode; try2Lot.TryCode = tempTry.TryCode; tryFacade.AddTry2Lot(try2Lot); } } } } return(newOQCLot); }
public void UpdateTry2Lot(Try2Lot try2Lot) { this.DataProvider.Update(try2Lot); }
public void DeleteTry2Lot(Try2Lot try2Lot) { this.DataProvider.Delete(try2Lot); }
public void AddTry2Lot(Try2Lot try2Lot) { this.DataProvider.Insert(try2Lot); }