protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { List<string> pizzaIDList = (List<string>)CurrentSession.GetValue(Session.SessionKeys.PizzaNoList); Pizza NewPizza = new Pizza(); NewPizza.PizzaID = pizzaIDList[0]; IProduct currentProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); NewPizza.BindProduct = currentProduct; PizzaStatus NewStatus = new PizzaStatus(); NewStatus.Editor = Editor; NewStatus.LineID = Line; NewStatus.StationID = Station; NewStatus.PizzaID = NewPizza.PizzaID; NewPizza.Status = NewStatus; currentProduct.PizzaObj = NewPizza; CurrentSession.AddValue(Session.SessionKeys.Product, currentProduct); CurrentSession.AddValue(Session.SessionKeys.Pizza, NewPizza); return base.DoExecute(executionContext); }
/// <summary> /// 获取DCode /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { string line = this.Line; string lineAs = ""; if (line != null && line.Length > 0) { lineAs = line.Substring(0, 1); } else { lineAs = " "; } DateTime dt = DateTime.Now; string year = string.Empty; string month = string.Empty; year = dt.Year.ToString().Substring(dt.Year.ToString().Length - 1, 1); switch (dt.Month.ToString()) { case "10": month = "A"; break; case "11": month = "B"; break; case "12": month = "C"; break; default: month = dt.Month.ToString().Substring(dt.Month.ToString().Length - 1, 1); break; } string preSeqStr = year + lineAs + month; string likecont = preSeqStr + "{0}"; NumControl numCtrl = null; INumControlRepository numCtrlRepository = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>(); string type = "PizzaID"; try { SqlTransactionManager.Begin(); lock (_syncRoot_GetSeq) { bool insOrUpd = true; //string maxMo = numCtrlRepository.GetMaxNumber(type, likecont); string seq = string.Empty; string maxSeqStr = string.Empty; string maxNumStr = string.Empty; bool ChongQingIs = false; //流水码的取得 //numCtrl = numCtrlRepository.GetMaxNumberObj(type, likecont); numCtrl = numCtrlRepository.GetMaxValue(type, preSeqStr); //檢查有沒有lock index, 沒有lock index, 改變查詢條件 if (numCtrl == null) { //lock NoType='PizzaID' //string maxData = numCtrlRepository.GetMaxNumber(type, "{0}"); //numCtrl = numCtrlRepository.GetMaxNumberObj(type, likecont); NumControl data = numCtrlRepository.GetMaxValue(type, "Lock"); numCtrl = numCtrlRepository.GetMaxValue(type, preSeqStr); } //if (string.IsNullOrEmpty(maxMo)) if (numCtrl == null) { seq = "200000"; insOrUpd = true; IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); ArrayList retList = new ArrayList(); IList<string> valueList = new List<string>(); valueList = partRepository.GetValueFromSysSettingByName("Site"); if (valueList.Count == 0) { } else { if (valueList[0] == "ICC") { ChongQingIs = true; } } if (ChongQingIs == true) { seq = "500000"; } } else { string maxMo = numCtrl.Value; seq = maxMo.Substring(maxMo.Length - 6, 6); insOrUpd = false; // if (seq.ToUpper() == "499999") // { /*List<string> errpara = new List<string>(); throw new FisException("CHK162", errpara);*/ // } //IList<NumControl> numCtrlLst = numCtrlRepository.GetNumControlByNoTypeAndValue(type, maxMo); //int numCtrlId = numCtrlLst[0].ID; //numCtrl = numCtrlRepository.Find(numCtrlId); } if (insOrUpd) { maxNumStr = seq; } else { if (seq.ToUpper() == "499999") { maxNumStr = "200000"; } else if (seq.ToUpper() == "999999") { maxNumStr = "500000"; } else { int num = Convert.ToInt32(seq); num += 1; maxNumStr = num.ToString(); int len = maxNumStr.Length; for (var i = 0; i < 6 - len; i++) { maxNumStr = "0" + maxNumStr; } } } maxSeqStr = preSeqStr + maxNumStr; CurrentSession.AddValue(Session.SessionKeys.PizzaID, maxSeqStr); if (insOrUpd) { //numCtrlRepository.Add(new NumControl(0, type, string.Empty, maxSeqStr, this.Customer), CurrentSession.UnitOfWork); //numCtrlRepository.InsertNumControl(new NumControl(0, type, string.Empty, maxSeqStr, this.Customer)); numCtrlRepository.InsertNumControl(new NumControl(0, type, preSeqStr, maxSeqStr, this.Customer)); } else { numCtrl.Value = maxSeqStr; //numCtrl.NOType = "PizzaID"; //numCtrl.NOName = ""; //numCtrl.Customer = this.Customer; numCtrlRepository.SaveMaxNumber(numCtrl, false); //numCtrlRepository.SaveMaxNumber(numCtrl, false, preSeqStr + "{0}"); //numCtrlRepository.Update(numCtrl, CurrentSession.UnitOfWork); } //CurrentSession.AddValue(Session.SessionKeys.PrintLogName, Station); //CurrentSession.AddValue(Session.SessionKeys.PrintLogBegNo, maxSeqStr); //CurrentSession.AddValue(Session.SessionKeys.PrintLogEndNo, maxSeqStr); //CurrentSession.AddValue(Session.SessionKeys.PrintLogDescr, ""); } string pizzaIDList = (string)CurrentSession.GetValue(Session.SessionKeys.PizzaID); Pizza NewPizza = new Pizza(); NewPizza.PizzaID = pizzaIDList; NewPizza.MMIID = ""; string model =(string) CurrentSession.GetValue(Session.SessionKeys.ModelName); if (!string.IsNullOrEmpty(model)) { NewPizza.Model=model; } IProduct currentProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); if (currentProduct != null) { currentProduct.PizzaID = pizzaIDList; CurrentSession.AddValue(Session.SessionKeys.Product, currentProduct); } CurrentSession.AddValue(Session.SessionKeys.Pizza, NewPizza); Pizza CurrentPizza = (Pizza)CurrentSession.GetValue(Session.SessionKeys.Pizza); PizzaStatus currentPizzaStatus = new PizzaStatus(); currentPizzaStatus.Editor = this.Editor; if (null == this.Line) { currentPizzaStatus.LineID = ""; } else { currentPizzaStatus.LineID = this.Line; } PizzaLog pizzaLog=new PizzaLog(); pizzaLog.Cdt = DateTime.Now; pizzaLog.Station = this.Station; pizzaLog.Line = this.Line; pizzaLog.Editor = this.Editor; pizzaLog.Model = model; pizzaLog.PizzaID = CurrentPizza.PizzaID; CurrentPizza.AddPizzaLog(pizzaLog); currentPizzaStatus.PizzaID = CurrentPizza.PizzaID; pizzaLog.Descr = ""; //currentPizzaStatus.StationID = "00"; currentPizzaStatus.StationID = this.Station; CurrentPizza.MMIID = ""; CurrentPizza.Status = currentPizzaStatus; IPizzaRepository currentPizzaRepository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>(); currentPizzaRepository.Add(CurrentPizza, CurrentSession.UnitOfWork); SqlTransactionManager.Commit(); } catch (Exception e) { SqlTransactionManager.Rollback(); throw e; } finally { SqlTransactionManager.Dispose(); SqlTransactionManager.End(); } return base.DoExecute(executionContext); }
private void UnpackPizzaPart(Pizza p, string unpackForNotStation) { IPizzaRepository pizzaRepository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>(); IList<PizzaPart> plistUnpack = new List<PizzaPart>(); IList<PizzaPart> plist = pizzaRepository.GetPizzaPartsByValueLike(14, "", p.PizzaID); foreach (PizzaPart pp in plist) { if (unpackForNotStation.Equals(pp.Station)) { continue; } plistUnpack.Add(pp); } if (plistUnpack.Count > 0) { pizzaRepository.BackUpPizzaPartDefered(CurrentSession.UnitOfWork, p.PizzaID, CurrentSession.Editor); foreach (PizzaPart pp in plistUnpack) { PizzaPart delpizza = new PizzaPart(); delpizza.PizzaID = p.PizzaID; delpizza.PartNo = pp.PartNo; delpizza.PartSn = pp.PartSn; pizzaRepository.DeletePizzaPartDefered(CurrentSession.UnitOfWork, delpizza); } } }
private void UpdatePizza(Pizza pizza, string station, string changeCartonSN) { IPizzaRepository pizzaRepository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>(); if (null != changeCartonSN) pizza.CartonSN = changeCartonSN; if (null != pizza.Status) pizza.Status.StationID = station; string line = string.IsNullOrEmpty(this.Line) ? pizza.Status.LineID : this.Line; var PizzaLog = new PizzaLog { Model = pizza.Model, Editor = Editor, Line = line, Station = Station, Descr = "", PizzaID = pizza.PizzaID, Cdt = DateTime.Now }; pizza.AddPizzaLog(PizzaLog); pizzaRepository.Update(pizza, CurrentSession.UnitOfWork); }
/// <summary> /// 检查输入的Pizza是否可以解绑 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var currentPizzaID = (string)CurrentSession.GetValue(Session.SessionKeys.PizzaNoList); //判断是否包含”-”字符 if (currentPizzaID.IndexOf("-") > 0) { FisException ex; List<string> erpara = new List<string>(); ex = new FisException("CHK101", erpara); throw ex; } else { Pizza currentpizza = new Pizza(); PizzaStatus currentPizzaStatus = new PizzaStatus(); IPizzaRepository currentPizzaRepository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>(); IList<PizzaPart> pizzaParts = (IList<PizzaPart>)currentPizzaRepository.GetPizzaPartsByValue(currentPizzaID); //按照Value找到一条记录 if (pizzaParts.Count == 1) { var pizzaID = pizzaParts[0].PizzaID.ToString(); currentpizza = currentPizzaRepository.Find(pizzaID); currentPizzaStatus = currentpizza.Status; IList<PizzaPart> currentPizzaPart = (IList<PizzaPart>)currentpizza.PizzaParts; } //按照Value不能找到记录 else if (pizzaParts.Count == 0) { currentpizza = currentPizzaRepository.Find(currentPizzaID); // IList<PizzaPart> currentPizzaPart = (IList<PizzaPart>)currentpizza.PizzaParts; //按照PizzaID能找到记录 // if (currentPizzaPart.Count > 0) if (currentpizza!=null) { currentPizzaStatus = currentpizza.Status; } //按照PizzaID和Value都不能找到记录 else { FisException ex; List<string> erpara = new List<string>(); ex = new FisException("PAK011", erpara); throw ex; } } //按照Value找到多条记录 else if (pizzaParts.Count > 1) { FisException ex; List<string> erpara = new List<string>(); erpara.Add(currentPizzaID); ex = new FisException("CHK102", erpara); throw ex; } IProductRepository currentProductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IProduct currentProduct = (IProduct)currentProductRepository.GetProductByPizzaID(currentPizzaID); //判断是否已与机器绑定 if (currentProduct != null && currentProduct.ProId != "") { FisException ex; List<string> erpara = new List<string>(); ex = new FisException("CHK103", erpara); throw ex; } else { var infoType = "KIT2"; int count = currentProductRepository.GetProductInfoCountByInfoValue(infoType, currentPizzaID); if (count > 0) { FisException ex; List<string> erpara = new List<string>(); ex = new FisException("CHK103", erpara); throw ex; } } CurrentSession.AddValue(Session.SessionKeys.Pizza, currentpizza); } return base.DoExecute(executionContext); }
/// <summary> /// 获取DCode /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IPizzaRepository pizzaRep = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>(); ICOAStatusRepository coaRep = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>(); IPrintLogRepository printLogRep = RepositoryFactory.GetInstance().GetRepository<IPrintLogRepository, PrintLog>(); Product curProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); Delivery curDn = (Delivery)CurrentSession.GetValue(Session.SessionKeys.Delivery); string pizzaID = (string)CurrentSession.GetValue(Session.SessionKeys.PizzaID); string coaSN = (string)CurrentSession.GetValue(Session.SessionKeys.COASN); string curEditor = ""; string curStation = ""; if (!string.IsNullOrEmpty(this.Editor)) { curEditor = this.Editor; } if (!string.IsNullOrEmpty(this.Station)) { curStation = this.Station; } if (!curProduct.IsBT) { //Update Product – Combine DN //Product.DeliveryNo – Delivery No (from UI) bool bindFlag = false; curProduct.DeliveryNo = curDn.DeliveryNo; Delivery newDn = null; IList<string> proList = new List<string>(); proList.Add(curProduct.ProId); bindFlag = productRep.BindDN(curDn.DeliveryNo, proList, curDn.Qty); while (!bindFlag) { newDn = GetNextDelivery(curProduct); if (newDn == null) { FisException fe = new FisException("PAK103", new string[] { }); //没找到可分配的delivery throw fe; } else { bindFlag = productRep.BindDN(newDn.DeliveryNo, proList, newDn.Qty); } } if (newDn != null) { curDn = newDn; curProduct.DeliveryNo = curDn.DeliveryNo; CurrentSession.AddValue(Session.SessionKeys.Delivery, curDn); } int dvQty = productRep.GetCombinedQtyByDN(curDn.DeliveryNo); if (dvQty == curDn.Qty) { curDn.Status = "87"; deliveryRep.Update(curDn, CurrentSession.UnitOfWork); } } //3. 如果有绑定COA,则需要完成如下操作 //a) Insert Product_Part - Combine COA //b) Update COAStatus - Update COA Status // COAStatus.Status = 'A1' //c) Insert COALog – Insert COA Log // COASN – COA // Line – 当前绑定的Customer S/N // Station – 'A1' if (!string.IsNullOrEmpty(coaSN)) { ProductPart coaPart = (ProductPart)CurrentSession.GetValue("COAPart"); IPart bomPart = (IPart)CurrentSession.GetValue("COABOMPart"); COAStatus reCOA = coaRep.Find(coaSN); IProductPart bindPart = new ProductPart(); bindPart.ProductID = curProduct.ProId; bindPart.PartID = bomPart.PN; bindPart.PartSn = coaSN; bindPart.Cdt = DateTime.Now; bindPart.BomNodeType = "P1"; bindPart.PartType = bomPart.Type; bindPart.CustomerPn = bomPart.CustPn; bindPart.Editor = curEditor; bindPart.Station = curStation; bindPart.CheckItemType = ""; bindPart.Iecpn = ""; curProduct.AddPart(bindPart); reCOA.Status = "A1"; reCOA.Editor = curEditor; coaRep.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, reCOA); COALog newItem = new COALog(); newItem.COASN = coaSN; newItem.LineID = curProduct.CUSTSN; newItem.Editor = Editor; newItem.StationID = "A1"; newItem.Tp = ""; coaRep.InsertCOALogDefered(CurrentSession.UnitOfWork, newItem); } //7.Insert IMES_PAK..Pizza / IMES_PAK..PizzaStatus / //IMES_PAK..Pizza.MMIID = '' //IMES_PAK..PizzaStatus.Station = '00' Pizza CurrentPizza = new Pizza(); PizzaStatus currentPizzaStatus = new PizzaStatus(); currentPizzaStatus.Editor = this.Editor; if (null == this.Line) { currentPizzaStatus.LineID = ""; } else { currentPizzaStatus.LineID = this.Line; } currentPizzaStatus.PizzaID = pizzaID; currentPizzaStatus.StationID = "00"; CurrentPizza.PizzaID = pizzaID; CurrentPizza.MMIID = ""; CurrentPizza.Status = currentPizzaStatus; pizzaRep.Add(CurrentPizza, CurrentSession.UnitOfWork); //8.Update Product – Combine Pizza Id //Product.PizzaID – Pizza ID curProduct.PizzaID = pizzaID; productRep.Update(curProduct, CurrentSession.UnitOfWork); //Model 的第10,11码是”29” 或者”39” 的产品是出货日本的产品;否则,是非出货日本的产品 string jpmodel = curProduct.Model.Substring(9, 2); bool jpflag = false; if (jpmodel == "29" || jpmodel == "39") { jpflag = true; } //IMES_GetData..PrintLog var item = new PrintLog { Name = "PIZZA Label-1", BeginNo = curProduct.CUSTSN, EndNo = curProduct.CUSTSN, Descr = "PIZZA Label-1", Editor = this.Editor }; printLogRep.Add(item, CurrentSession.UnitOfWork); //出货日本在列印列印Pizza Label 后,还需要列印Japan Pizza Label if (jpflag) { var jitem = new PrintLog { Name = "PIZZA Label-2", BeginNo = curProduct.CUSTSN, EndNo = curProduct.CUSTSN, Descr = "PIZZA Label-2", Editor = this.Editor }; printLogRep.Add(jitem, CurrentSession.UnitOfWork); } if (curProduct.IsBT) { var btitem = new PrintLog { Name = "BT COO Label", BeginNo = curProduct.CUSTSN, EndNo = curProduct.CUSTSN, Descr = "BT COO Label", Editor = this.Editor }; printLogRep.Add(btitem, CurrentSession.UnitOfWork); } CurrentSession.AddValue("JPFlag", jpflag); return base.DoExecute(executionContext); }