/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { //从Session里取得Product对象 Product currentProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); //获取Product_Part所有AST信息( Product_Part.BomNodeType = ’AT’) IList<ProductPart> list = new List<ProductPart>(); ProductPart cond = new ProductPart(); cond.ProductID = currentProduct.ProId; cond.BomNodeType = "AT"; list = productRepository.GetProductPartList(cond); IList<ASTInfo> infos = new List<ASTInfo>(); foreach (ProductPart temp in list) { ASTInfo item = new ASTInfo(); item.ASTType = temp.PartType; item.PartNo = temp.PartID; item.PartSn = temp.PartSn; infos.Add(item); } CurrentSession.AddValue(Session.SessionKeys.ProductPartList, infos); return base.DoExecute(executionContext); }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { ASTInfo info = (ASTInfo)CurrentSession.GetValue(Session.SessionKeys.ASTInfoList); var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string prod1 = (string)CurrentSession.GetValue(Session.SessionKeys.Prod1); string prod2 = (string)CurrentSession.GetValue(Session.SessionKeys.Prod2); ProductPart setValue = new ProductPart(); ProductPart cond = new ProductPart(); setValue.ProductID = prod2; cond.ProductID = prod1; cond.PartID = info.PartNo; cond.BomNodeType = "AT"; productRepository.UpdateProductPart(setValue, cond); //Change CombineASTNumber IList<CombinedAstNumberInfo> bindAstInfo= productRepository.GetCombinedAstNumber(new CombinedAstNumberInfo { ProductID = prod1, AstNo=info.PartSn, State="Used" ,AstType="AST"}); if (bindAstInfo != null && bindAstInfo.Count > 0) { foreach (CombinedAstNumberInfo item in bindAstInfo) { item.ProductID = prod2; item.Remark = string.IsNullOrEmpty(item.Remark) ? "Old:" + prod1 : item.Remark + "~Old:" + prod1; productRepository.UpdateCombinedAstNumber(item); } } return base.DoExecute(executionContext); }
/// <summary> /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var product = CurrentSession.GetValue(Session.SessionKeys.Product) as IProduct; IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string[] prodList = new string[1]; prodList[0] = product.ProId; ProductPart part = new ProductPart(); part.Station = Station; productRep.DeleteProductPartsDefered(CurrentSession.UnitOfWork, prodList, part); return base.DoExecute(executionContext); }
public void Save(object part_unit, object part_owner, string station, string key) { if (part_unit == null) { throw new ArgumentNullException(); } if (part_owner == null) { throw new ArgumentNullException(); } //if (part_unit != null) //{ // var product = (Product)part_owner; // Session session = SessionManager.GetInstance.GetSession(product.ProId, Session.SessionType.Product); // if (session == null) // { // throw new InstanceNotFoundException("Can not get Session instance from SessionManager!"); // } Session session = SessionManager.GetInstance.GetSession(key, Session.SessionType.Product); if (session == null) { throw new InstanceNotFoundException("Can not get Session instance from SessionManager!"); } Product product = (Product)session.GetValue(Session.SessionKeys.Product); Pizza pizza = product.PizzaObj; IPizzaRepository pizza_repository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>(); /* IList<IProductPart> product_parts = pizza_repository.GetPizzaPartsByPartNoAndValue(((PartUnit)part_unit).Pn.Trim(), ((PartUnit)part_unit).Sn.Trim()); if (product_parts != null && product_parts.Count > 0) { return; } */ if (pizza != null) { IProductPart part = new ProductPart(); part.PartID = ((PartUnit)part_unit).Pn; part.PartSn = ((PartUnit)part_unit).Sn; part.BomNodeType = ((PartUnit)part_unit).Type; part.CheckItemType = ((PartUnit)part_unit).ItemType; part.PartType = ((PartUnit)part_unit).ValueType; part.Station = station; part.Editor = session.Editor; pizza.AddPart(part); pizza_repository.Update(pizza, session.UnitOfWork); } }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { ASTInfo info = (ASTInfo)CurrentSession.GetValue(Session.SessionKeys.ASTInfoList); var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string prod2 = (string)CurrentSession.GetValue(Session.SessionKeys.Prod2); IList<ProductPart> list = new List<ProductPart>(); ProductPart cond = new ProductPart(); cond.PartID = info.PartNo; cond.BomNodeType = "AT"; cond.ProductID = prod2; list = productRepository.GetProductPartList(cond); if (list != null && list.Count > 0) { foreach (ProductPart productPart in list) { //Check Destination ProductID CombinedASTNumber and Release Ast Number IList<CombinedAstNumberInfo> destBindAstInfo = productRepository.GetCombinedAstNumber(new CombinedAstNumberInfo { ProductID = prod2, AstNo = productPart.PartSn, State = "Used", AstType="AST" }); if (destBindAstInfo != null && destBindAstInfo.Count > 0) { foreach (CombinedAstNumberInfo item in destBindAstInfo) { item.Remark = string.Format("BindStation:{0}", item.Station); item.UnBindProductID = item.ProductID; item.UnBindStation = this.Station; item.ProductID = ""; item.Station = ""; item.Udt = DateTime.Now; item.State = "Release"; item.Editor = this.Editor; productRepository.UpdateCombinedAstNumber(item); } } } string[] a = {prod2}; cond.ProductID = ""; productRepository.DeleteProductParts(a, cond); } return base.DoExecute(executionContext); }
private IList<ProductPart> GetNowParts(IProduct currentProduct, string keyConstType) { List<ProductPart> nowParts = new List<ProductPart>(); List<string> errpara = new List<string>(); IList<ConstValueInfo> cvInfo = new List<ConstValueInfo>(); ConstValueInfo cvCond = new ConstValueInfo(); cvCond.type = keyConstType; cvCond.name = currentProduct.Model; cvInfo = partRepository.GetConstValueInfoList(cvCond); if (cvInfo == null || cvInfo.Count == 0) { cvCond = new ConstValueInfo(); cvCond.type = keyConstType; cvCond.name = currentProduct.Family; cvInfo = partRepository.GetConstValueInfoList(cvCond); } if (cvInfo == null || cvInfo.Count == 0) { //throw new FisException("CHK1026", errpara); // 此机器没有要解的料 return nowParts; } ConstValueInfo tmp = cvInfo[0]; string[] wantRemovePartTypes = tmp.value.Split(','); foreach (string wantRemovePartType in wantRemovePartTypes) { ProductPart cond = new ProductPart(); cond.ProductID = currentProduct.ProId; cond.CheckItemType = wantRemovePartType; IList<ProductPart> list = productRepository.GetProductPartList(cond); //if (list == null || list.Count == 0) //{ // errpara.Add(wantRemovePartType); // throw new FisException("CHK1027", errpara); // 该机器没有结合@KP,不能过此站 //} if (list != null) nowParts.AddRange(list); } return nowParts; }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { ASTInfo info = (ASTInfo)CurrentSession.GetValue(Session.SessionKeys.ASTInfoList); var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string prod1 = (string)CurrentSession.GetValue(Session.SessionKeys.Prod1); string prod2 = (string)CurrentSession.GetValue(Session.SessionKeys.Prod2); ProductPart setValue = new ProductPart(); ProductPart cond = new ProductPart(); setValue.ProductID = prod2; cond.ProductID = prod1; cond.PartID = info.PartNo; cond.BomNodeType = "AT"; productRepository.UpdateProductPart(setValue, cond); return base.DoExecute(executionContext); }
/// <summary> /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var product = CurrentSession.GetValue(Session.SessionKeys.Product) as IProduct; IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string deliveryNo = product.DeliveryNo; List<string> erpara = new List<string>(); IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); string[] prodList = new string[1]; prodList[0] = product.ProId; ProductPart tmp = new ProductPart(); tmp.Station = "8C"; productRep.BackUpProductPart(prodList, tmp, this.Editor); productRep.DeleteProductParts(prodList,tmp); Delivery CurrentDelivery = DeliveryRepository.Find(deliveryNo); if (CurrentDelivery == null) { // erpara.Add(deliveryNo); // throw new FisException("CHK107", erpara); return base.DoExecute(executionContext); } if (CurrentDelivery.Status == "88" || CurrentDelivery.Status == "87" || CurrentDelivery.Status == "00") { CurrentDelivery.Status = "00"; CurrentDelivery.Editor = this.Editor; CurrentDelivery.Udt = DateTime.Now; DeliveryRepository.Update(CurrentDelivery, CurrentSession.UnitOfWork); } return base.DoExecute(executionContext); }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { ASTInfo info = (ASTInfo)CurrentSession.GetValue(Session.SessionKeys.ASTInfoList); var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string prod2 = (string)CurrentSession.GetValue(Session.SessionKeys.Prod2); IList<ProductPart> list = new List<ProductPart>(); ProductPart cond = new ProductPart(); cond.PartID = info.PartNo; cond.BomNodeType = "AT"; cond.ProductID = prod2; list = productRepository.GetProductPartList(cond); if (list != null && list.Count > 0) { string[] a = {prod2}; cond.ProductID = ""; productRepository.DeleteProductParts(a, cond); } return base.DoExecute(executionContext); }
/// <summary> /// 产生BindCoaToProduct /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); ICOAStatusRepository coaRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>(); IPart part = null; string custSN = (string)CurrentSession.GetValue(Session.SessionKeys.CustSN); var product = productRepository.GetProductByCustomSn(custSN); if (null == product) { List<string> errpara = new List<string>(); errpara.Add(custSN); throw new FisException("SFC002", errpara); } //var product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); string model = product.Model; // 取ModelBOM 中Model 直接下阶中有BomNodeType 为'P1' 的Part IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>(); IHierarchicalBOM sessionBOM = null; sessionBOM = ibomRepository.GetHierarchicalBOMByModel(product.Model); IList<IBOMNode> bomNodeLst = new List<IBOMNode>(); bomNodeLst = sessionBOM.FirstLevelNodes; if (bomNodeLst != null && bomNodeLst.Count > 0) { foreach (IBOMNode ibomnode in bomNodeLst) { IPart currentPart = ibomnode.Part; if (currentPart.BOMNodeType == "P1" && currentPart.Descr.IndexOf("COA") == 0) { part = currentPart; break; } } } string coaSN = (string)CurrentSession.GetValue(Session.SessionKeys.COASN); if (coaSN != "" && part == null) { List<string> err = new List<string>(); err.Add(coaSN); err.Add(custSN); throw new FisException("CHK187", err); } else if (coaSN != "" && part != null) { ICOAStatusRepository currentRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>(); IList<COAStatus> coaList = currentRepository.GetCOAStatusRange(coaSN, coaSN); if (null == coaList || coaList.Count == 0) { List<string> err = new List<string>(); err.Add(coaSN); err.Add(custSN); throw new FisException("CHK187", err); } foreach (COAStatus tmp in coaList) { if (part.PN != tmp.IECPN) { List<string> err = new List<string>(); err.Add(coaSN); err.Add(custSN); throw new FisException("CHK187", err); } } IList<ProductPart> parts = new List<ProductPart>(); parts = productRepository.GetProductPartsByPartSn(coaSN); foreach (ProductPart iparts in parts) { if (iparts.PartSn == coaSN && iparts.ProductID != product.ProId) { List<string> err = new List<string>(); err.Add(coaSN); err.Add(custSN); throw new FisException("CHK187", err); } } /*// IMES_FA..Product_Part 表中与当前Product 绑定的Parts IList<IProductPart> productParts = new List<IProductPart>(); productParts = ((IProduct)product).ProductParts; if (productParts == null || productParts.Count <= 0) { //该Product尚未绑定Part! List<string> err = new List<string>(); err.Add(coaSN); err.Add(custSN); throw new FisException("CHK187", err); }*/ COAStatus reCOA = coaRepository.Find(coaSN); IProductPart bindPart = new ProductPart(); bindPart.ProductID = product.ProId; bindPart.PartID = part.PN; bindPart.PartSn = coaSN; bindPart.Cdt = DateTime.Now; bindPart.BomNodeType = "P1"; bindPart.PartType = part.Type; bindPart.CustomerPn = part.CustPn; if (this.Editor == null) { Editor = ""; } if (this.Station == null) { Station = ""; } bindPart.Station = Station; bindPart.Editor = Editor; bindPart.CheckItemType = ""; bindPart.Iecpn = ""; product.AddPart(bindPart); reCOA.Editor = Editor; reCOA.Status = "A1"; coaRepository.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, reCOA); COALog newItem = new COALog(); newItem.COASN = coaSN; newItem.LineID = custSN; newItem.Editor = Editor; newItem.StationID = "A1"; newItem.Tp = ""; coaRepository.InsertCOALogDefered(CurrentSession.UnitOfWork, newItem); productRepository.Update(product, CurrentSession.UnitOfWork); } return base.DoExecute(executionContext); }
/// <summary> /// 备份Product / ProductStatus / Product_Part / ProductInfo 表中将被解绑的记录 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { IDeliveryRepository currentRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); Session session = CurrentSession; string DN = (string)session.GetValue(Session.SessionKeys.DeliveryNo); IList<IProduct> productList = (IList<IProduct>)session.GetValue(Session.SessionKeys.ProdNoList); IProduct currentProduct = null; foreach (IProduct ele in productList) { currentProduct = ele; productList.Remove(ele); break; } if (productList.Count == 0) { session.AddValue(Session.SessionKeys.IsComplete, true); } session.AddValue(Session.SessionKeys.ProdNoList, productList); session.AddValue(Session.SessionKeys.Product, currentProduct); IList<string> itemTypes = new List<string>(); itemTypes.Add("CKK"); productRepository.BackUpProductInfoDefered(session.UnitOfWork, currentProduct.ProId, this.Editor, "CKK"); productRepository.RemoveProductInfosByTypeDefered(session.UnitOfWork, currentProduct.ProId, itemTypes); //// Delete CartonInfo carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); CartonInfoInfo infoCond = new CartonInfoInfo(); infoCond.cartonNo = currentProduct.CartonSN; cartRep.DeleteCartonInfoDefered(session.UnitOfWork, infoCond); //Delete Product_Part string[] prodList = new string[1]; prodList[0] = currentProduct.ProId; ProductPart tmp = new ProductPart(); tmp.Station = "8C"; productRepository.BackUpProductPartDefered(session.UnitOfWork, prodList, tmp, this.Editor); productRepository.DeleteProductPartsDefered(session.UnitOfWork, prodList, tmp); //Update Product productRepository.BackUpProductStatusDefered(session.UnitOfWork, currentProduct.ProId, this.Editor); productRepository.BackUpProductDefered(session.UnitOfWork, currentProduct.ProId, this.Editor); currentProduct.CartonSN = string.Empty; currentProduct.PalletNo = string.Empty; currentProduct.DeliveryNo = string.Empty; currentProduct.Udt = DateTime.Now; productRepository.Update(currentProduct, session.UnitOfWork); Delivery oldDelivery = currentRepository.Find(DN); if (oldDelivery != null) { oldDelivery.Status = "00"; currentRepository.Update(oldDelivery, session.UnitOfWork); #region 清空Pallet weight IPalletRepository currentPltRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>(); IList<string> palletNoList = currentRepository.GetPalletNoListByDeliveryNo(DN); foreach (string pn in palletNoList) { //mantis1666: Unpack DN by DN,清除棧板庫位時若unpack 的 DN為棧板唯一的DN才能清庫位 //在Pallet 結合DN最後一筆時,才能清空Pallet Location Pallet pallet = currentPltRepository.Find(pn); IList<string> dnList = productRepository.GetDeliveryNoListByPalletNo(pn); if (dnList.Count < 2) { PakLocMasInfo setVal = new PakLocMasInfo(); PakLocMasInfo cond = new PakLocMasInfo(); setVal.editor = Editor; setVal.pno = ""; cond.pno = pn; cond.tp = "PakLoc"; currentPltRepository.UpdatePakLocMasInfoDefered(session.UnitOfWork, setVal, cond); //Clear Floor in Pallet pallet.Floor = ""; //Clear Floor in Pallet } //Clear weight in Pallet pallet.Weight = 0; pallet.Weight_L = 0; PalletLog palletLog = new PalletLog { PalletNo = pallet.PalletNo, Station = "RETURN", Line = "Weight:0", Cdt = DateTime.Now, Editor = this.Editor }; pallet.AddLog(palletLog); currentPltRepository.Update(pallet, session.UnitOfWork); } #endregion } return base.DoExecute(executionContext); }
private IProductPart getUpdatedPart(IProductPart part, bool isSn, string val, String objType) { IProductPart ret = null; if (string.Compare(objType, "MB", true) == 0) { IProductPart tempPart = part; if (isSn) { ret = new ProductPart(tempPart.ID, tempPart.PartID, tempPart.ProductID, val, string.Empty, tempPart.Station, tempPart.Editor, tempPart.Cdt, DateTime.Now); } } else { IProductPart tempPart = part; if (isSn) { //ret = new ProductPart(tempPart.ID, tempPart.PartID, tempPart.ProductID, val, string.Empty, tempPart.Station, tempPart.Editor, tempPart.Cdt, DateTime.Now); ret = new ProductPart(tempPart.ID, tempPart.PartID, tempPart.ProductID, val, string.Empty, tempPart.Station, this.Editor, tempPart.Cdt, DateTime.Now); } else { //ret = new ProductPart(tempPart.ID, tempPart.PartID, val, tempPart.Value, string.Empty, tempPart.Station, tempPart.Editor, tempPart.Cdt, DateTime.Now); ret = new ProductPart(tempPart.ID, tempPart.PartID, val, tempPart.Value, string.Empty, tempPart.Station, this.Editor, tempPart.Cdt, DateTime.Now); } } return ret; }
/// <summary> /// 检查AST是否满足要求 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string needPartType = "ATSN9"; string needPartNoSessionName = "NeedPartType" + needPartType; IPart needPart = CurrentSession.GetValue(needPartNoSessionName) as IPart; if (null != needPart) { IProduct currenProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); IProductPart assetTag1 = new ProductPart(); assetTag1.BomNodeType = needPart.BOMNodeType; assetTag1.Iecpn = string.Empty; //part.PN; assetTag1.CustomerPn = string.Empty; //part.CustPn; assetTag1.ProductID = currenProduct.ProId; assetTag1.PartID = needPart.PN; assetTag1.PartSn = needPart.PN; assetTag1.PartType = needPart.Descr; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; currenProduct.AddPart(assetTag1); productRepository.Update(currenProduct, CurrentSession.UnitOfWork); } return base.DoExecute(executionContext);
/* /// <summary> /// 印第一个pizza标签 /// </summary> /// <param name="custSN">CustomerSN</param> /// <param name="line"></param> /// <param name="editor"></param> /// <param name="station"></param> /// <param name="customer"></param> /// <param name="printItems"></param> /// <returns>Print Items</returns> public IList<PrintItem> PrintPizzaLabelFinal(string custSN, string line, string editor, string station, string customer, IList<PrintItem> printItems) { logger.Debug("(_CombineCOAandDN)PrintPizzaLabelFinal start, [CustomerSN]:" + custSN + " [line]: " + line + " [editor]:" + editor + " [station]:" + station + " [customer]:" + customer); string sessionKey = custSN; try { Session session = SessionManager.GetInstance.GetSession(sessionKey, SessionType); if (session != null) { string doDelivery = (string)session.GetValue("doDelivery"); if (doDelivery != null && doDelivery == "true") { var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN); if (null == currentProduct) { List<string> errpara = new List<string>(); errpara.Add(custSN); throw new FisException("SFC002", errpara); } string DNTemp = (string)session.GetValue(Session.SessionKeys.DeliveryNo); if (currentProduct.DeliveryNo != DNTemp) { return null; } } session.AddValue(Session.SessionKeys.IsComplete, true); session.AddValue(Session.SessionKeys.PrintItems, printItems); session.AddValue(Session.SessionKeys.PrintLogName, "PIZZA Label"); session.AddValue(Session.SessionKeys.PrintLogBegNo, custSN); session.AddValue(Session.SessionKeys.PrintLogEndNo, custSN); session.AddValue(Session.SessionKeys.PrintLogDescr, ""); session.Exception = null; session.SwitchToWorkFlow(); //check workflow exception if (session.Exception != null) { if (session.GetValue(Session.SessionKeys.WFTerminated) != null) { session.ResumeWorkFlow(); } throw session.Exception; } return (IList<PrintItem>)session.GetValue(Session.SessionKeys.PrintItems); //return null; } else { return null; } } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { Session sessionDelete = SessionManager.GetInstance.GetSession(sessionKey, SessionType); if (sessionDelete != null) { SessionManager.GetInstance.RemoveSession(sessionDelete); } logger.Debug("(_CombineCOAandDN)PrintPizzaLabelFinal end, [CustomerSN]:" + custSN + " [line]: " + line + " [editor]:" + editor + " [station]:" + station + " [customer]:" + customer); } }*/ /// <summary> /// Insert Product_Part - Combine COA /// </summary> /// <param name="custSN">CustomerSN</param> /// <param name="coaSN">coaSN</param> /// <param name="editor">editor</param> public void BindPart(string custSN, string coaSN,string editor) { try { COAStatus reCOA = coaRepository.Find(coaSN); IProduct product = productRepository.GetProductByCustomSn(custSN); if (product == null) { return ; } IProductPart bindPart = new ProductPart(); bindPart.ProductID = product.ProId; bindPart.PartID = reCOA.IECPN; bindPart.PartSn = coaSN; bindPart.Cdt = DateTime.Now; if (editor == null) { editor = ""; } bindPart.Editor = editor; product.AddPart(bindPart); reCOA.Status = "A1"; reCOA.Editor = editor; coaRepository.UpdateCOAStatus(reCOA); COALog newItem = new COALog(); newItem.COASN = coaSN; newItem.LineID = custSN; newItem.Editor = editor; newItem.StationID = "A1"; coaRepository.InsertCOALog(newItem); } catch (Exception ee) { throw ee; } }
/// <summary> /// 刷uutSn,启动工作流,检查输入的uutSn,卡站,获取ProductModel /// </summary> /// <param name="uutSn"></param> /// <param name="line"></param> /// <param name="editor"></param> /// <param name="station"></param> /// <param name="customer"></param> /// <returns>ProductModel</returns> public ArrayList InputCTNO(string ctno, string line, string editor, string station, string customer) { logger.Debug("(LCMDefectInputForRCTOImpl)InputCTNO start, CTno:" + ctno); try { string uutSn = ctno; var productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>(); ProductPart conf = new ProductPart(); conf.PartSn = ctno; conf.CheckItemType = "LCM"; IList<ProductPart> productList = productRep.GetProductPartList(conf); foreach (ProductPart item in productList) { IProduct pro = productRep.Find(item.ProductID); if (!string.IsNullOrEmpty(pro.CartonSN)) { FisException ex; List<string> erpara = new List<string>(); erpara.Add(pro.ProId); ex = new FisException("CHK934", erpara); throw ex; } } string sessionKey = productList[0].ProductID; Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType); if (currentSession == null) { currentSession = new Session(sessionKey, SessionType, editor, station, line, customer); Dictionary<string, object> wfArguments = new Dictionary<string, object>(); wfArguments.Add("Key", sessionKey); wfArguments.Add("Station", station); wfArguments.Add("CurrentFlowSession", currentSession); wfArguments.Add("Editor", editor); wfArguments.Add("PdLine", line); wfArguments.Add("Customer", customer); wfArguments.Add("SessionType", SessionType); string wfName, rlName; RouteManagementUtils.GetWorkflow(station, "LCMDefectInputForRCTO.xoml", "", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.IsComplete, false); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); } else { FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } currentSession.AddValue("CTNO", ctno ); ArrayList retlist = new ArrayList(); retlist.Add(sessionKey); retlist.Add(productList.Count); return retlist; } catch (FisException e) { logger.Error(e.mErrmsg, e); throw new Exception(e.mErrmsg); } catch (Exception e) { logger.Error(e.Message, e); throw new SystemException(e.Message); } finally { logger.Debug("(LCMDefectInputForRCTOImpl)InputCTNO end, CTno:" + ctno); } }
/// <summary> /// 保存AST /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); var currenProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); var currentAST = (string)CurrentSession.GetValue("AST"); //2012-9-4, Jessica Liu, UC需求变更 var currentVendor = (string)CurrentSession.GetValue("Vendor"); bool isCDSI = currenProduct.IsCDSI; if (isCDSI == false) { /* 2012-9-4, Jessica Liu, UC需求变更 IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(currenProduct.Model); for (int i = 0; i < bom.FirstLevelNodes.Count; i++) { IPart part = ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Part; if ((part.BOMNodeType == "AT") && (part.Descr == "ATSN1")) { IProductPart assetTag1 = new ProductPart(); assetTag1.BomNodeType = "AT"; assetTag1.Iecpn = string.Empty; //part.PN; assetTag1.CustomerPn = string.Empty; //part.CustPn; assetTag1.ProductID = currenProduct.ProId; assetTag1.PartID = part.PN; assetTag1.PartSn = currentAST; assetTag1.PartType = "ATSN1"; //"AT"; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; currenProduct.AddPart(assetTag1); } } */ IProductPart assetTag1 = new ProductPart(); assetTag1.BomNodeType = "AT"; assetTag1.Iecpn = string.Empty; //part.PN; assetTag1.CustomerPn = string.Empty; //part.CustPn; assetTag1.ProductID = currenProduct.ProId; assetTag1.PartID = currentVendor; assetTag1.PartSn = currentAST; assetTag1.PartType = "ATSN1"; //"AT"; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; currenProduct.AddPart(assetTag1); } return base.DoExecute(executionContext); }
/// <summary> /// 产生Asset SN /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var currenProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); var currentAST = (string)CurrentSession.GetValue("AssetSN"); var ProdidOrCustsn = (string)CurrentSession.GetValue("ProdidOrCustsn"); //Jessica Liu, 2012-4-16 string descr = (string)CurrentSession.GetValue("DESCR"); IPart part = null; IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(currenProduct.Model); for (int i = 0; i < bom.FirstLevelNodes.Count; i++) { IPart tempPart = ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Part; //Jessica Liu, 2012-4-16 //if ((tempPart.BOMNodeType == "AT") && (tempPart.Descr == "ATSN3")) if ((tempPart.BOMNodeType == "AT") && (tempPart.Descr == descr)) { part = tempPart; break; } } if (part == null) { List<string> erpara = new List<string>(); erpara.Add(ProdidOrCustsn); throw new FisException("CHK205", erpara); } else { IProductPart assetTag1 = new ProductPart(); assetTag1.BomNodeType = "AT"; assetTag1.Iecpn = string.Empty; //part.PN; assetTag1.CustomerPn = string.Empty; //part.CustPn; assetTag1.ProductID = currenProduct.ProId; assetTag1.PartID = part.PN; assetTag1.PartSn = currentAST; //Jessica Liu, 2012-4-16 //assetTag1.PartType = "ATSN3"; //"AT"; assetTag1.PartType = descr; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; currenProduct.AddPart(assetTag1); productRepository.Update(currenProduct, CurrentSession.UnitOfWork); } 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") if((jpmodel == "29" || jpmodel == "39") && CheckJapanByPart(curProduct.Model)) { 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); }
ArrayList ITPDLCheckForRCTO.InputProductID(string ID, string line, string editor, string station, string customer) { logger.Debug("(TPDLCheckForRCTOImpl)InputCustomerSN start, customerSN:" + ID + "editor:" + editor + "station:" + station + "customer:" + customer); try { ArrayList retList = new ArrayList(); string productID = ""; string lcmCT = ""; var productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>(); if (ID.Length == 14) { string ctno = ID; lcmCT = ID; //若刷入的为[LCM CT],则获取Product_Part.ProductID //( Condtion: Product_Part.PartSn=[LCM CT] and CheckItemType=’LCM’) //若ProductID不存在,则报错:“错误的LCM CT”;若存在,则显示LCM CT ProductPart conf = new ProductPart(); conf.PartSn = ctno; conf.CheckItemType = "LCM"; IList<ProductPart> productList = productRep.GetProductPartList(conf); foreach (ProductPart item in productList) { IMES.FisObject.FA.Product.IProduct pro = productRep.Find(item.ProductID); if (!string.IsNullOrEmpty(pro.CartonSN)) { FisException ex; List<string> erpara = new List<string>(); erpara.Add(pro.ProId); ex = new FisException("CHK940", erpara);//“错误的LCM CT” throw ex; } } productID = productList[0].ProductID; } else { //若刷入的为[ProductID],取Product_Part.PartSn //(Condition: Product_Part.ProductID=[ProductID] and CheckItemType = ‘LCM’), //若PartSn不存在,则报错:“未结合LCM CT”;否则,显示LCM CT ProductPart conf = new ProductPart(); conf.ProductID = ID; conf.CheckItemType = "LCM"; IList<ProductPart> productList = productRep.GetProductPartList(conf); if (productList.Count == 0) { FisException ex; List<string> erpara = new List<string>(); erpara.Add(ID); ex = new FisException("CHK941", erpara);//“未结合LCM CT” throw ex; } productID = ID; lcmCT = productList[0].PartSn; } //获取[ProductID]已绑定TPDL的PartSn(Top 1 Product_Part.PartSn Condition: Product_Part.ProductID=[ProductID] and CheckItemType=’TPDL’) //若PartSn为空或者Null,则报错:“LCM未结合TPDL” //若PartSn不为空,则显示在UI,显示格式:***** string tpdl = ""; ProductPart tconf = new ProductPart(); tconf.ProductID = productID; tconf.CheckItemType = "TPDL"; IList<ProductPart> proList = productRep.GetProductPartList(tconf); if (proList.Count == 0) { FisException ex; List<string> erpara = new List<string>(); erpara.Add(ID); ex = new FisException("CHK945", erpara);//“LCM未结合TPDL” throw ex; } tpdl = proList[0].PartSn; string sessionKey = productID; Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType); if (currentSession == null) { currentSession = new Session(sessionKey, ProductSessionType, editor, station, line, customer); Dictionary<string, object> wfArguments = new Dictionary<string, object>(); wfArguments.Add("Key", sessionKey); wfArguments.Add("Station", station); wfArguments.Add("CurrentFlowSession", currentSession); wfArguments.Add("Editor", editor); wfArguments.Add("PdLine", line); wfArguments.Add("Customer", customer); wfArguments.Add("SessionType", ProductSessionType); string wfName, rlName; RouteManagementUtils.GetWorkflow(station, "TPDLCheckForRCTO.xoml", "", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.Product, sessionKey); currentSession.AddValue(Session.SessionKeys.IsComplete, false); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); } else { FisException ex; List<string> erpara = new List<string>(); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } //=============================================================================== //Get infomation Product curProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product); currentSession.AddValue("TPDL", tpdl); retList.Add(curProduct.ProId); retList.Add(lcmCT); retList.Add(tpdl); //=============================================================================== return retList; } catch (Exception) { throw; } }
/// <summary> /// Generate ATSN7 label /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); var partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); Product curProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); IList<string> pnList = CurrentSession.GetValue("PnListOfATSN7") as IList<string>; bool bCDSI = (bool)CurrentSession.GetValue("bCDSI"); if (bCDSI == true) { string AST1 = ""; CdsiastInfo cdi = new CdsiastInfo(); cdi.tp = "ASSET_TAG"; cdi.snoId = curProduct.ProId; IList<CdsiastInfo> cdsiastInfoList = productRepository.GetCdsiastInfoList(cdi); if (cdsiastInfoList != null && cdsiastInfoList.Count > 0) { AST1 = cdsiastInfoList[0].sno; } string AST2 = ""; CdsiastInfo cdi2 = new CdsiastInfo(); cdi2.tp = "ASSET_TAG2"; cdi2.snoId = curProduct.ProId; IList<CdsiastInfo> cdsiastInfoList2 = productRepository.GetCdsiastInfoList(cdi2); if (cdsiastInfoList2 != null && cdsiastInfoList2.Count > 0) { AST2 = cdsiastInfoList2[0].sno; } if ((AST1 == "") && (AST2 == "")) { List<string> errpara = new List<string>(); throw new FisException("CHK203", errpara); } else { //不为空则存入 //保存product和Asset SN的绑定关系 foreach (string tmp in pnList) { if (AST1 != "") { IProductPart assetTag1 = new ProductPart(); assetTag1.ProductID = curProduct.ProId; assetTag1.PartID = tmp; assetTag1.PartType = "ATSN7"; assetTag1.Iecpn = ""; assetTag1.CustomerPn = ""; assetTag1.PartSn = AST1; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; assetTag1.BomNodeType = "AT"; curProduct.AddPart(assetTag1); productRepository.Update(curProduct, CurrentSession.UnitOfWork); } if (AST2 != "") { IProductPart assetTag2 = new ProductPart(); assetTag2.ProductID = curProduct.ProId; assetTag2.PartID = tmp; assetTag2.PartType = "ATSN7"; assetTag2.Iecpn = ""; assetTag2.CustomerPn = ""; assetTag2.PartSn = AST2; assetTag2.Station = Station; assetTag2.Editor = Editor; assetTag2.Cdt = DateTime.Now; assetTag2.Udt = DateTime.Now; assetTag2.BomNodeType = "AT"; curProduct.AddPart(assetTag2); productRepository.Update(curProduct, CurrentSession.UnitOfWork); } } } } else //Not CDSI { string custNum = ""; string cust = curProduct.ModelObj.GetAttribute("Cust"); IList<AssetRangeInfo> assetRangeList = partRepository.GetAssetRangesByCode(cust); if (assetRangeList.Count == 0) //No AssetRange found { List<string> errpara = new List<string>(); throw new FisException("CHK200", errpara); } AssetRangeInfo assetRange = assetRangeList[0]; if (assetRange.begin.Length != assetRange.end.Length) //Length of Begin and End mismatch { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } try { SqlTransactionManager.Begin(); lock (_syncRoot_GetSeq) { INumControlRepository numCtrlRepository = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>(); string largestCustNum = numCtrlRepository.GetMaxAssetNumber("AST", cust, "HP"); if (string.IsNullOrEmpty(largestCustNum)) { custNum = assetRange.begin; //Save current custNum to numControl NumControl item = new NumControl(0, "AST", assetRange.code, custNum, "HP"); numCtrlRepository.SaveMaxAssetNumber(item, true); SqlTransactionManager.Commit(); } else { if (largestCustNum.Length != assetRange.begin.Length) //Length of largestCustNum and assetRange.begin mismatch { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } string prePartCur = ""; string numPartCur = ""; ParseAst(largestCustNum, out prePartCur, out numPartCur); if (numPartCur == "") { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } string prePartMax = ""; string numPartMax = ""; ParseAst(assetRange.end, out prePartMax, out numPartMax); if (numPartMax == "") { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } if (prePartCur != prePartMax) //Prefix of largestCustNum and assetRange.end mismatch { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } long numCur = long.Parse(numPartCur); long numMax = long.Parse(numPartMax); if (numCur >= numMax) { List<string> errpara = new List<string>(); throw new FisException("CHK201", errpara); } numCur++; custNum = prePartCur; int fillZeroCount = numPartCur.Length - numCur.ToString().Length; for (int i = 0; i < fillZeroCount; i++) { custNum += "0"; } custNum += numCur.ToString(); //Save current custNum to numControl NumControl item = new NumControl(0, "AST", assetRange.code, custNum, "HP"); numCtrlRepository.SaveMaxAssetNumber(item, false); SqlTransactionManager.Commit(); } } } catch (Exception e) { SqlTransactionManager.Rollback(); throw e; } finally { SqlTransactionManager.Dispose(); SqlTransactionManager.End(); } //Update custNum if (cust == "SCUSTA-1") { custNum = "000" + custNum.Trim() + "00"; } /* else if (cust == "CUSTW-1") { custNum = custNum.Trim() + " HQ P47"; } else if (cust == "CUSTW-2") { custNum = custNum.Trim() + " HQ P49"; } */ ConstValueInfo cond = new ConstValueInfo(); cond.type = "AST"; cond.name = cust; IList<ConstValueInfo> valList = partRepository.GetConstValueInfoList(cond); if (valList.Count > 0 && !String.IsNullOrEmpty(valList[0].value)) { custNum += valList[0].value.Trim(); } //保存product和Asset SN的绑定关系 foreach (string tmp in pnList) { IProductPart assetTag = new ProductPart(); assetTag.ProductID = curProduct.ProId; assetTag.PartID = tmp; assetTag.PartType = "ATSN7"; assetTag.Iecpn = ""; assetTag.CustomerPn = ""; assetTag.PartSn = custNum; assetTag.Station = Station; assetTag.Editor = Editor; assetTag.Cdt = DateTime.Now; assetTag.Udt = DateTime.Now; assetTag.BomNodeType = "AT"; curProduct.AddPart(assetTag); productRepository.Update(curProduct, CurrentSession.UnitOfWork); } } return base.DoExecute(executionContext); }
/// <summary> /// 检查Prodid和KBCT的对应关系是否合法 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { string CurrentKBCT = (string)CurrentSession.GetValue("KBCT"); var currenProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); string CheckModel = CurrentSession.GetValue("CheckModel") as string; //ITC-1413-0019, Jessica Liu, 2012-6-20 string currentProdModel = currenProduct.Model; if ((null==CheckModel || "PC".Equals(CheckModel) || "".Equals(CheckModel)) && (currentProdModel.Substring(0, 2) != "PC")) { List<string> errpara = new List<string>(); throw new FisException("CHK286", errpara); //非PC Model,不能刷此界面 } else if ("RCTO".Equals(CheckModel) && (currentProdModel.Substring(0, 3) != "173")) { List<string> errpara = new List<string>(); throw new FisException("CHK1007", errpara); //非RCTO Model,不能刷此界面 } var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); ProductPart condition = new ProductPart(); condition.ProductID = currenProduct.ProId; condition.CheckItemType = "KB"; IList<ProductPart> prodPartList = productRepository.GetProductPartList(condition); if (prodPartList != null && prodPartList.Count > 0) { string firstProdPartSn = prodPartList[0].PartSn; if (string.IsNullOrEmpty(firstProdPartSn)) { List<string> errpara = new List<string>(); throw new FisException("CHK116", errpara); //ProdId未绑定KB } else if (firstProdPartSn.Substring(0, 5) != CurrentKBCT.Substring(0, 5)) { List<string> errpara = new List<string>(); throw new FisException("CHK117", errpara); //ProdId与 KB CT 匹配错误 } } else { List<string> errpara = new List<string>(); throw new FisException("CHK115", errpara); //找不到对应的Product Part信息 } return base.DoExecute(executionContext); }
/// <summary> /// write ProductInfo /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Session session = CurrentSession; ActivityCommonImpl utl = ActivityCommonImpl.Instance; var prdRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IProduct currentProduct = utl.IsNull<IProduct>(session, Session.SessionKeys.Product); IList<IPart> needCombinePartList = utl.IsNull<IList<IPart>>(session, Session.SessionKeys.NeedCombineAstPartList); //(IList<IPart>)session.GetValue("NeedCombineAstPartList"); //if (needCombineAstList.Count == 0) //{ // throw new FisException("CHK205", new List<string> { currentProduct.ProId, this.Station }); // 此机器不需要print asset Label ! //} IPart part = needCombinePartList.Where(x => x.BOMNodeType == "PP" && x.Descr == "Asstage-3").FirstOrDefault(); //string astPartNo = CheckAsstage3(currentProduct, needCombinePartList); //if(!string.IsNullOrEmpty(astPartNo)) if (part!=null && !string.IsNullOrEmpty(part.PN)) { ProductPart prdPart = new ProductPart(); prdPart.PartSn =currentProduct.CUSTSN; prdPart.BomNodeType = part.BOMNodeType; // "PP"; prdPart.PartType = part.Descr; //"Asstage-3"; prdPart.Editor = this.Editor; prdPart.Station = this.Station; prdPart.PartID = part.PN;//astPartNo; prdPart.CheckItemType = "GenPPAST3"; currentProduct.AddPart(prdPart); prdRep.Update(currentProduct, session.UnitOfWork); //var item = new PrintLog // { // Name ="Asstage-3", // BeginNo = currentProduct.CUSTSN, // EndNo = currentProduct.CUSTSN, // Descr = "", // Editor = this.Editor // }; // var repository = RepositoryFactory.GetInstance().GetRepository<IPrintLogRepository, PrintLog>(); // repository.Add(item, CurrentSession.UnitOfWork); } return base.DoExecute(executionContext); }
/// <summary> /// 根据BOM查询结果,对Special_Det表进行相应修改 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var currenProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); List<string> BLUETOOTH = new List<string>(); List<string> MDM = new List<string>(); bool isBlue = false; // bool isMdm = false; Model CurrentModle = modelRep.Find(currenProduct.Model); string family = CurrentModle.Family.FamilyName; IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); ILCMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<ILCMRepository>(); IHierarchicalBOM curBom = bomRep.GetHierarchicalBOMByModel(currenProduct.Model); IList<IBOMNode> bomList = curBom.FirstLevelNodes; foreach (IBOMNode bomNode in bomList) { IList<IBOMNode> chileNodeList = bomNode.Children; foreach (IBOMNode bomNodeChild in chileNodeList) { if (bomNodeChild.Part.BOMNodeType == "KP") { if (bomNodeChild.Part.Descr.Contains("BLUETOOTH")) { BLUETOOTH.Add(bomNodeChild.Part.PN); } if (bomNodeChild.Part.Descr.Contains("MDM")) { MDM.Add(bomNodeChild.Part.PN); } } } } if (BLUETOOTH.Count > 0) { IList<MasterLabelInfo> tmp = productRepository.GetMasterLabelByVCAndCode(BLUETOOTH.ToArray(), family); if (tmp.Count > 0 && tmp[0].code != "" && tmp[0].code != null) isBlue = true; } else { isBlue = true; } if (isBlue == false) { FisException ex = new FisException("CHK896", new string[] { }); //"Machine has been in stack or out!" throw ex; } isBlue = false; if (MDM.Count > 0) { IList<MasterLabelInfo> tmp = productRepository.GetMasterLabelByVCAndCode(MDM.ToArray(), family); if (tmp.Count > 0 && tmp[0].code != "" && tmp[0].code != null) isBlue = true; } else { isBlue = true; } if (isBlue == false) { FisException ex = new FisException("CHK897", new string[] { }); //"Machine has been in stack or out!" throw ex; } ProductPart WirelessPart = new ProductPart(); WirelessPart.PartType = "WIRELESS"; //chk898 WirelessPart.ProductID = currenProduct.ProId; List<string> Wireless = (List<string>)productRepository.GetPartSnPrefixListFromProductPart(WirelessPart); isBlue = false; if (Wireless.Count > 0) { IList<MasterLabelInfo> tmp = productRepository.GetMasterLabelByVCAndCode(Wireless.ToArray(), family); if (tmp.Count > 0 && tmp[0].code != "" && tmp[0].code != null) isBlue = true; } else { isBlue = true; } if (isBlue == false) { FisException ex = new FisException("CHK898", new string[] { }); //"Machine has been in stack or out!" throw ex; } ProductPart WWANPart = new ProductPart(); WWANPart.PartType = "WWAN"; //chk898 WWANPart.ProductID = currenProduct.ProId; List<string> WWAN = (List<string>)productRepository.GetPartSnPrefixListFromProductPart(WWANPart); isBlue = false; if (WWAN.Count > 0) { IList<MasterLabelInfo> tmp = productRepository.GetMasterLabelByVCAndCode(WWAN.ToArray(), family); if (tmp.Count > 0 && tmp[0].code != "" && tmp[0].code != null) isBlue = true; } else { isBlue = true; } if (isBlue == false) { FisException ex = new FisException("CHK899", new string[] { }); //"Machine has been in stack or out!" throw ex; } return base.DoExecute(executionContext); }
/// <summary> /// Check RMN /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Product curProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); IList<IBOMNode> bomNodeList = (IList<IBOMNode>)CurrentSession.GetValue(Session.SessionKeys.SessionBom); String curCode = (String)CurrentSession.GetValue(Session.SessionKeys.MBCode); IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); List<string> errpara = new List<string>(); Model curModel = modelRep.Find(curProduct.Model); //SELECT @esn='',@imei='',@aiccid='',@siccid='',@pno='',@family='',@meid='',@pcid='',@wwan='',@LabelNO1='',@LabelNO2='',@wimax='' //SELECT @ZM_wwan='',@wwanzmode='',@SID='' string esn = string.Empty; string imei = string.Empty; string aiccid = string.Empty; string siccid = string.Empty; string pno = string.Empty; string family = string.Empty; string meid = string.Empty; string pcid = string.Empty; string wwan = string.Empty; string LabelNO1 = string.Empty; string LabelNO2 = string.Empty; string wimax = string.Empty; string zm_wwan = string.Empty; string wwanzmode = string.Empty; string sid = string.Empty; string mn = string.Empty; //2.取Model (IMES_FA..Product.Model)/ Family (IMES_GetData..Model.Family)并赋值给@pno / @family pno = curProduct.Model; family = curModel.FamilyName; //3.如果ModelBOM 中Model 的直接下阶中存在Part No = '60WIMAX00001' 的Part,则置@wimax='Y', //并取Product 的ESN (IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'ESN')赋值给变量@esn IHierarchicalBOM curBom = bomRep.GetHierarchicalBOMByModel(pno); IList<IBOMNode> bomList = curBom.FirstLevelNodes; foreach (IBOMNode node in bomList) { if (node.Part.PN == "60WIMAX00001") { wimax = "Y"; break; } } //4.如果ModelBOM 中Model 的直接下阶中不存在Part No = '60WIMAX00001' 的Part, //则取Product 的ESN (IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'ESN')的后8位赋值给变量@esn esn = (string)curProduct.GetExtendedProperty("ESN"); if (wimax != "Y") { if (!string.IsNullOrEmpty(esn)) { if (esn.Length >= 8) { esn = esn.Substring(esn.Length - 8, 8); } } else { esn = ""; } } //5.取Product 的IMEI(IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'IMEI') / MEID ((IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'MEID')) / AICCID (IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'AICCID')/ SICCID (IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'SICCID')/ PCID (IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'PCID') //分别赋值给变量 @imei / @meid / @aiccid / @siccid / @pcid imei = (string)curProduct.GetExtendedProperty("IMEI"); meid = (string)curProduct.GetExtendedProperty("MEID"); aiccid = (string)curProduct.GetExtendedProperty("AICCID"); siccid = (string)curProduct.GetExtendedProperty("SICCID"); pcid = (string)curProduct.GetExtendedProperty("PCID"); //6.取Model 的MN1 (IMES_GetData..ModelInfo.Value,Condition: Name = 'MN1')/ SID (IMES_GetData..ModelInfo.Value,Condition: Name = 'SID')属性 //赋值给变量@MN, @SID mn = curModel.GetAttribute("MN1"); sid = curModel.GetAttribute("SID"); //7. Insert #wwan //将ModelBOM 中Model 直接下阶的所有Descr like 'WWAN%' 的Part 的Part No 插入到#wwan //Remark: //#wwan 定义如下 //CREATE TABLE #wwan (SPno char(20) ) CurrentSession.AddValue("WLabel", ""); IList <string> wwanList = new List<string>(); foreach (IBOMNode node in bomList) { if (!string.IsNullOrEmpty(node.Part.Descr) && node.Part.Descr.Length >= 4 && node.Part.BOMNodeType!="PL") { if (node.Part.Descr.Substring(0,4)=="WWAN") { wwanList.Add(node.Part.PN); } } //8.将ModelBOM 中Model 直接下阶中BomNodeType 为'PL', //Descr='WWANID LABEL 1' 的Part 的Part No 赋值给@LabelNO1 if (node.Part.BOMNodeType == "PL" && node.Part.Descr == "WWANID LABEL 1" ) { LabelNO1 = node.Part.PN; } //9.将ModelBOM 中Model 直接下阶中BomNodeType 为'PL',Descr='WWANID LABEL 2' //的Part 的Part No 赋值给@LabelNO2 if (node.Part.BOMNodeType == "PL" && node.Part.Descr == "WWANID LABEL 2" ) { LabelNO2 = node.Part.PN; } } //10.如果#wwan 无记录并且@wimax='',则表明无需列印WWAN ID Label 或者Wimax Label,退出 if (wwanList.Count == 0 && string.IsNullOrEmpty(wimax))//NO BM { if (!string.IsNullOrEmpty(LabelNO1) || !string.IsNullOrEmpty(LabelNO2)) { CurrentSession.AddValue("WLabel", "WWAN ID Label"); return base.DoExecute(executionContext); } } //11. 按照如下方法,赋值变量@wwan / @ZM_wwan //参考方法: //IF EXISTS (SELECT * FROM #wwan WHERE SPno like 'BM2WL%') // BEGIN // SELECT @wwan=RTRIM(SPno) FROM #wwan WHERE SPno like 'BM2WL%' // SELECT @ZM_wwan=@wwan // END //ELSE // BEGIN // SELECT @wwan=RTRIM(SPno) FROM #wwan //END if (wwanList.Count > 0) { wwan = wwanList[0]; foreach (string str in wwanList) { if (str.Substring(0, 5) == "BM2WL") { wwan = str.TrimEnd(); zm_wwan = wwan; break; } } } //12.如果@wwan<>'' AND @wwan IS NOT NULL, //则取ModelBOM 中@wwan 直接下阶中Part No 为6 位的Part 中的任意一个的AS 属性 //(IMES_GetData..PartInfo.InfoValue,Condition: InfoType = 'AS')赋值给@wwanzmode if (!string.IsNullOrEmpty(wwan)) { IHierarchicalBOM tmpBom = bomRep.GetHierarchicalBOMByModel(wwan); IList<IBOMNode> tmpBomList = tmpBom.FirstLevelNodes; foreach(IBOMNode node in tmpBomList) { if (node.Part.PN.Length ==6) { wwanzmode =node.Part.GetAttribute("AS"); break; } } } //检查列印WWAN Label 需要的Image D/L 数据是否上传 //=========================================================================== //DECLARE @wwanKP varchar(100) //DECLARE @wwanKPAS varchar(10) //DECLARE @LabelMEID varchar(10) //DECLARE @LabelIMEI varchar(10) //DECLARE @LabelICCID varchar(10) //DECLARE @LabelESN varchar(10) string wwanKP = ""; string wwanKPAS = ""; //string labelMEID = ""; //string labelIMEI = ""; //string labelICCID = ""; //string labelESN = ""; //IF @wwan<>'' //BEGIN if (!string.IsNullOrEmpty(wwan)) { //SELECT @wwanKP = PartNo FROM Product_Part NOLOCK WHERE ProductID = @pid AND PartType = 'WWAN' IList<ProductPart> list = new List<ProductPart>(); ProductPart wcond = new ProductPart(); wcond.ProductID = curProduct.ProId; wcond.PartType = "WWAN"; list = productRep.GetProductPartList(wcond); wwanKP = list[0].PartID; //SELECT @wwanKPAS = InfoValue FROM PartInfo NOLOCK WHERE PartNo = @wwanKP AND InfoType = 'AS' //SELECT @wwanKPAS = LEFT(@wwanKPAS, CHARINDEX('-', @wwanKPAS)-1) wwanKPAS = partRep.GetPartInfoValue(wwanKP, "AS"); string[] splitpattern = wwanKPAS.Split('-'); if (splitpattern.Length > 0) { wwanKPAS = splitpattern[0]; } else { wwanKPAS = ""; } //IF NOT EXISTS(SELECT * FROM HP_WWANLabel NOLOCK //WHERE LEFT(ModuleNo, CHARINDEX('-', ModuleNo)-1) = @wwanKPAS) // SELECT '0','Please maintain HP_WWANLabel!' // RETURN //ELSE // SELECT @LabelESN = LabelESn, @LabelICCID= LabelICCID, @LabelMEID = LabelMEID, @LabelIMEI = LabelIMEI // FROM HP_WWANLabel NOLOCK WHERE LEFT(ModuleNo, CHARINDEX('-', ModuleNo)-1) = @wwanKPAS IList<HpWwanlabelInfo> hpList = bomRep.GetHpWwanlabelInfoByModuleNoPrefix(wwanKPAS); if (hpList.Count <= 0) { errpara.Add(this.Key);//Please maintain HP_WWANLabel! throw new FisException("PAK152", errpara); } HpWwanlabelInfo hpInfo = hpList[0]; //IF @LabelESN = 'Y' // IF @esn = '' // SELECT '0', 'ESN missing!' // RETURN if (hpInfo.labelESn == "Y") { if (string.IsNullOrEmpty(esn)) { errpara.Add(this.Key);//ESN missing! throw new FisException("PAK153", errpara); } } //IF @LabelIMEI = 'Y' // IF @imei = '' // SELECT '0', 'IMEI missing!' // RETURN if (hpInfo.labelIMEI == "Y") { if (string.IsNullOrEmpty(imei)) { errpara.Add(this.Key);//IMEI missing! throw new FisException("PAK154", errpara); } } //IF @LabelMEID = 'Y' // IF @meid = '' // SELECT '0', 'MEID missing!' // if (hpInfo.labelMEID == "Y") { if (string.IsNullOrEmpty(meid)) { errpara.Add(this.Key);//MEID missing! throw new FisException("PAK155", errpara); } } //IF @LabelICCID = 'Y' // IF @siccid = '' // SELECT '0', 'SICCID missing!' // RETURN if (hpInfo.labelICCID == "Y") { if (string.IsNullOrEmpty(siccid)) { errpara.Add(this.Key);//SICCID missing! throw new FisException("PAK156", errpara); } } } //=========================================================================== //14.如果(@family='DIABLO 2.1' or @family='DIABLO 2.0' or @family = 'HARBOUR 1.1')AND @pcid='', //则报告错误:“PCID missing!”后,退出 if ((family == "DIABLO 2.1" || family =="DIABLO 2.0" || family =="HARBOUR 1.1")&& (pcid == "")) { FisException fe = new FisException("PAK108", new string[] { }); //PCID missing! throw fe; } //15.如果@wimax<>'',则需要列印的是Wimax Label, //此时要求弹出对话框提示用户:“Please print Wimax Label!”后,再列印Wimax Label; //否则,列印的是WWAN ID Label,无需提示 //Wimax Label 和WWAN ID Label使用同一个Batch File 列印 if (wimax != "") { CurrentSession.AddValue("WLabel", "Wimax Label"); } else { if (string.IsNullOrEmpty(LabelNO1) && string.IsNullOrEmpty(LabelNO2)) { CurrentSession.AddValue("WLabel", ""); } else { CurrentSession.AddValue("WLabel", "WWAN ID Label"); } } return base.DoExecute(executionContext); }
/// <summary> /// 删除AST的处理 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { var currenProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); /* 2012-9-4, Jessica Liu, UC需求变更 var currentPart = (IProductPart)CurrentSession.GetValue("Part"); currenProduct.RemovePart(currentPart.Value, currentPart.PartID); */ //delete Product_Part where ProductID = '*****' and BomNodeType = 'AT' and PartType = 'ATSN1' string[] a = { currenProduct.ProId }; var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); var otCond = new IMES.FisObject.Common.Part.ProductPart(); otCond.BomNodeType = "AT"; otCond.PartType = "ATSN1"; productRepository.DeleteProductParts(a, otCond); return base.DoExecute(executionContext); }
private void combineCDSI(Session session,IProduct product, IPart part, string checkItemType, string avPartNo ) { var prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); string AST1 = ""; CdsiastInfo cdi = new CdsiastInfo(); cdi.tp = "ASSET_TAG"; cdi.snoId = product.ProId; IList<CdsiastInfo> cdsiastInfoList = prodRep.GetCdsiastInfoList(cdi); if (cdsiastInfoList != null && cdsiastInfoList.Count > 0) { AST1 = cdsiastInfoList[0].sno; } string AST2 = ""; CdsiastInfo cdi2 = new CdsiastInfo(); cdi2.tp = "ASSET_TAG2"; cdi2.snoId = product.ProId; IList<CdsiastInfo> cdsiastInfoList2 = prodRep.GetCdsiastInfoList(cdi2); if (cdsiastInfoList2 != null && cdsiastInfoList2.Count > 0) { AST2 = cdsiastInfoList2[0].sno; } if ((AST1 == "") && (AST2 == "")) { List<string> errpara = new List<string>(); throw new FisException("CHK203", errpara); } else { //不为空则存入 //保存product和Asset SN的绑定关系 if (AST1 != "") { IProductPart assetTag1 = new ProductPart(); assetTag1.ProductID = product.ProId; assetTag1.PartID = part.PN; assetTag1.PartType = part.Descr; assetTag1.Iecpn = ""; assetTag1.CustomerPn = avPartNo; assetTag1.PartSn = AST1; assetTag1.Station = this.Station; assetTag1.Editor = this.Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; assetTag1.BomNodeType = part.BOMNodeType; assetTag1.CheckItemType = checkItemType; product.AddPart(assetTag1); prodRep.Update(product, session.UnitOfWork); } if (AST2 != "") { IProductPart assetTag2 = new ProductPart(); assetTag2.ProductID = product.ProId; assetTag2.PartID = part.PN; assetTag2.PartType = part.Descr; assetTag2.Iecpn = ""; assetTag2.CustomerPn = avPartNo; assetTag2.PartSn = AST2; assetTag2.Station = this.Station; assetTag2.Editor = this.Editor; assetTag2.Cdt = DateTime.Now; assetTag2.Udt = DateTime.Now; assetTag2.BomNodeType = part.BOMNodeType; assetTag2.CheckItemType = checkItemType; product.AddPart(assetTag2); prodRep.Update(product, session.UnitOfWork); } session.AddValue("AST1", AST1); session.AddValue("AST2", AST2); //2012-5-2 string ASTinfo = ""; if (!string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo += AST1 + ", " + AST2; } else if (!string.IsNullOrEmpty(AST1) && string.IsNullOrEmpty(AST2)) { ASTinfo = AST1; } else if (string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo = AST2; } session.AddValue("ASTInfo", ASTinfo); } }
/// <summary> /// /// </summary> /// <param name="prodId"></param> /// <param name="inputCOA"></param> /// <returns></returns> public ArrayList checkCOA(string prodId, string inputCOA) { logger.Debug("(CombineCOAandDNNew)checkCOA start," + " [prodId]: " + prodId); FisException ex; List<string> erpara = new List<string>(); string sessionKey = prodId; string nodeStr = ""; ArrayList retList = new ArrayList(); try { Session curSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType); if (curSession == null) { erpara.Add(sessionKey); ex = new FisException("CHK021", erpara); throw ex; } else { //======================================================== Product curProduct = (Product)curSession.GetValue(Session.SessionKeys.Product); string coaPN = (string)curSession.GetValue("COAPN"); IHierarchicalBOM curBom = bomRep.GetHierarchicalBOMByModel(curProduct.Model); IList<IBOMNode> bomNodeList = curBom.FirstLevelNodes; //如果当前PRODUCT已经收集了COA (Product_Part 中看是否有绑定COA – 存在BomNodeType = 'P1' , //IMES_GetData..Part.Descr LIKE 'COA%' 的Part),则需要进行如下检查: string productCoa = ""; ProductPart proPart = null; if (curProduct.ProductParts != null && curProduct.ProductParts.Count > 0) { foreach (ProductPart iprodpart in curProduct.ProductParts) { IPart curPart = partRep.GetPartByPartNo(iprodpart.PartID); if (curPart.BOMNodeType == "P1" && curPart.Descr.IndexOf("COA") == 0) { productCoa = curPart.PN; proPart = iprodpart; break; } } } if (proPart != null) { //检查刷入的COA No 是否和已与Product结合的COA No 是否一致,如果不一致, //则需要报告错误:“用户刷入的COA No 与Product 结合的COA No 不一致,请联系相关人员!”; if (inputCOA != proPart.PartSn) { erpara.Add(sessionKey); ex = new FisException("PAK147", erpara);//“用户刷入的COA No 与Product 结合的COA No 不一致,请联系相关人员!” nodeStr = ex.mErrmsg; retList.Add(nodeStr); retList.Add(""); return retList; } } else { //用户刷入的COA 如果不存在,则报告错误:'COA is not exist!' //Remark: //使用COAStatus.COASN = @COA查询COAStatus 表没有存在记录,则表明用户刷入的COA 不存在 COAStatus reCOA = coaRep.Find(inputCOA); if (null == reCOA) { erpara.Add(sessionKey); ex = new FisException("PAK149", erpara);//COA is not exist! nodeStr = ex.mErrmsg; retList.Add(nodeStr); retList.Add(""); return retList; } //用户刷入的COA 如果Part No(COAStatus.IECPN) 与上文不符, //则报告错误:'COA Pn is wrong! Please reinput COA.' //Remark: //使用COAStatus.COASN = @COA查询COAStatus 表取得记录的IECPN栏位为COA Pn if (coaPN != reCOA.IECPN) { erpara.Add(sessionKey); ex = new FisException("PAK150", erpara);//'COA Pn is wrong! Please reinput COA.' nodeStr = ex.mErrmsg; retList.Add(nodeStr); retList.Add(""); return retList; } //用户刷入的COA 如果不是可以结合状态,需要报告错误:'Invalid COA! Please reinput COA.' //Remark: //使用COAStatus.COASN = @COA 查询COAStatus 表取得记录的Status 如果不是'P1',则该COA 不是可以结合状态 if ("P1" != reCOA.Status) { erpara.Add(sessionKey); ex = new FisException("PAK151", erpara);//'Invalid COA! Please reinput COA.' nodeStr = ex.mErrmsg; retList.Add(nodeStr); retList.Add(""); return retList; } } //用户刷入的COA 如果与其它Product 结合,则报告错误:“该COA 已与其它Product 结合,请联系相关人员!” //Remark: //IF EXISTS(SELECT * FROM Product_Part WHERE PartSn = @COA AND ProductID <> @ProductId) //PRINT '该COA 已与其它Product 结合,不能在此使用!' IList<ProductPart> partlist = new List<ProductPart>(); ProductPart cond = new ProductPart(); cond.PartSn = inputCOA; partlist = productRep.GetProductPartList(cond); foreach (ProductPart part in partlist) { if (part.ProductID != curProduct.ProId) { erpara.Add(sessionKey); ex = new FisException("PAK148", erpara);//“该COA 已与其它Product 结合,请联系相关人员!” nodeStr = ex.mErrmsg; retList.Add(nodeStr); retList.Add(""); return retList; } } //保存正确COA if (proPart == null) { curSession.AddValue(Session.SessionKeys.COASN, inputCOA); curSession.AddValue("COAPart", proPart); } retList.Add(nodeStr); retList.Add(inputCOA); return retList; } } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { logger.Debug("(CombineCOAandDNNew)checkCOA end," + " [prodId]: " + prodId); } }
/// <summary> /// Generate ATSN7 label /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Session session = CurrentSession; ActivityCommonImpl utl = ActivityCommonImpl.Instance; var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); var partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); IProduct curProduct = utl.IsNull<IProduct>(session, Session.SessionKeys.Product); bool needASTSN= ((string)session.GetValue(Session.SessionKeys.GenerateASTSN))=="Y"; bool isCDSI = ((string)session.GetValue(Session.SessionKeys.HasCDSI)) == "Y"; bool isCNRS = ((string)session.GetValue(Session.SessionKeys.HasCNRS)) == "Y"; string avPartNo = (string)session.GetValue(Session.SessionKeys.AVPartNo)??""; if (isCDSI) { IPart cdsiPart = utl.IsNull<IPart>(session, Session.SessionKeys.CDSIPart); combineCDSI(session, curProduct, cdsiPart, "CDSI", avPartNo); } else if (isCNRS) // AstType 為 'ATSN3' { IPart cnrsPart = utl.IsNull<IPart>(session, Session.SessionKeys.CNRSPart); combineCDSI(session, curProduct, cnrsPart, "CNRS", avPartNo); } if (needASTSN ) { IList<IPart> partList = utl.IsNull<IList<IPart>>(session, Session.SessionKeys.NeedGenAstPartList); IList<AstDefineInfo> astDefineList = utl.IsNull<IList<AstDefineInfo>>(session, Session.SessionKeys.NeedGenAstDefineList); if (utl.UPS.checkUPSDeviceInAssignStation(curProduct, astDefineList, this.Station)) { return base.DoExecute(executionContext); } bool hasAssignAst = false; foreach (AstDefineInfo astDefine in astDefineList) { IPart part = partList.Where(x => x.BOMNodeType == astDefine.AstType && x.Descr == astDefine.AstCode).FirstOrDefault(); if (part == null) { continue; } string custNum3 = null; string custNum = utl.GenAst.AssignAstNumber(session, part, curProduct, this.Station, this.Customer, this.Editor, out custNum3); #region dsable code move to utl ////0001323: 特殊资产编号 //IList<ConstValueInfo> cvInfoList =null; //ConstValueInfo cvInfo =null; //string custNum = null; //string custNum3 = null; //if (utl.TryConstValue("PreFixSNAST", part.PN, out cvInfoList, out cvInfo)) //{ // if (string.IsNullOrEmpty(curProduct.CUSTSN)) // { // throw new FisException("CQCHK1108", new string[] { curProduct.ProId }); // } // else // { // custNum = cvInfo.value.Trim() + curProduct.CUSTSN; // } //} //else //{ // #region 產生ATSN 需要 // string astPo = (string)session.GetValue("AstPo"); // string cust = null; // string cust3 = null; // if (string.IsNullOrEmpty(astPo)) // { // cust = astPo; // } // else // { // cust = curProduct.ModelObj.GetAttribute("Cust"); // cust3 = curProduct.ModelObj.GetAttribute("Cust3"); // } // if (!string.IsNullOrEmpty(cust)) // { // //custNum=getAstNumber(session, utl, curProduct, cust); // custNum = utl.GetAstNumber(session, curProduct, cust,this.Station,this.Customer,this.Editor); // } // //检查Declare @Cust3 = ModelInfo.Value (Conditon: Model=#Prodocut.Model and Name = ‘Cust3’) , // //若@Cust3 不为空且不为Null,则执行下面AST的分配工作: // if (!string.IsNullOrEmpty(cust3)) // { // //custNum3 = getAstNumber(session, utl, curProduct, cust3); // custNum3 = utl.GetAstNumber(session, curProduct, cust3, this.Station, this.Customer, this.Editor); // } // #endregion //} #endregion //保存product和Asset SN的绑定关系 if (!string.IsNullOrEmpty(custNum)) { IProductPart assetTag = new ProductPart(); assetTag.ProductID = curProduct.ProId; assetTag.PartID = part.PN; assetTag.PartType = part.Descr; assetTag.Iecpn = ""; assetTag.CustomerPn = part.GetAttribute("AV") ?? string.Empty; assetTag.PartSn = custNum; assetTag.Station = Station; assetTag.Editor = Editor; assetTag.Cdt = DateTime.Now; assetTag.Udt = DateTime.Now; assetTag.BomNodeType = part.BOMNodeType; assetTag.CheckItemType = "GenASTSN"; curProduct.AddPart(assetTag); productRepository.Update(curProduct, session.UnitOfWork); } if (!string.IsNullOrEmpty(custNum3)) { IProductPart assetTag = new ProductPart(); assetTag.ProductID = curProduct.ProId; assetTag.PartID = part.PN; assetTag.PartType = part.Descr; assetTag.Iecpn = ""; assetTag.CustomerPn = part.GetAttribute("AV") ?? string.Empty; assetTag.PartSn = custNum3; assetTag.Station = Station; assetTag.Editor = Editor; assetTag.Cdt = DateTime.Now; assetTag.Udt = DateTime.Now; assetTag.BomNodeType = part.BOMNodeType; assetTag.CheckItemType = "GenASTSN"; curProduct.AddPart(assetTag); productRepository.Update(curProduct, session.UnitOfWork); } session.AddValue("AssetSN", custNum ?? ""); session.AddValue("AssetSN3", custNum3 ?? ""); hasAssignAst = true; } if (!hasAssignAst) { throw new FisException("CQCHK1093", new string[] { curProduct.ProId, string.Join(",", astDefineList.Select(x=>x.AstCode).ToArray())}); } } return base.DoExecute(executionContext); }
/// <summary> /// Check CDSI(shell机器),如果是,则从CDSIAST表中根据ProdID取得资产标签,进行结合,并打印 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Session session = CurrentSession; ActivityCommonImpl utl = ActivityCommonImpl.Instance; IProduct getProduct = utl.IsNull<IProduct>(session, Session.SessionKeys.Product); IList<IPart> needGenAstPartList =utl.IsNull<IList<IPart>>(session,Session.SessionKeys.NeedGenAstPartList); //Product getProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product); //var ProdidOrCustsn = (string)CurrentSession.GetValue("ProdidOrCustsn"); string prodidOrCustsn = getProduct.ProId + "/" + getProduct.CUSTSN; //string descr = (string)session.GetValue("DESCR"); bool isCDSI = getProduct.IsCDSI; //session.AddValue(Session.SessionKeys.HasCDSI, isCDSI ? "Y":"N"); //2012-5-2 session.AddValue("ASTInfo", ""); if (isCDSI == true) { IPart part = null; if (needGenAstPartList.Count > 0) { part = needGenAstPartList.FirstOrDefault(); } if (part == null) { throw new FisException("CHK522", new List<string> { prodidOrCustsn }); } string atsnav = (string)getProduct.GetModelProperty("ATSNAV")??""; string checkItemType = string.IsNullOrEmpty(atsnav) ? "CNRS" : "CDSI"; string descr = part.Descr; string AST1 = ""; string AST2 = ""; var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); //Get AV Part No if (string.IsNullOrEmpty(atsnav)) { if (needGenAstPartList.Count == 1) { atsnav = needGenAstPartList[0].PN; } else { var cnrsPart = needGenAstPartList.Where(x => x.BOMNodeType == "AT" && x.Descr == "ATSN3").FirstOrDefault(); if (cnrsPart != null) { atsnav = cnrsPart.PN; } else { atsnav = needGenAstPartList[0].PN; } } } CdsiastInfo cdi = new CdsiastInfo(); cdi.tp = "ASSET_TAG"; cdi.snoId = getProduct.ProId; IList<CdsiastInfo> cdsiastInfoList = productRepository.GetCdsiastInfoList(cdi); if (cdsiastInfoList != null && cdsiastInfoList.Count > 0) { AST1 = cdsiastInfoList[0].sno; } CdsiastInfo cdi2 = new CdsiastInfo(); cdi2.tp = "ASSET_TAG2"; cdi2.snoId = getProduct.ProId; IList<CdsiastInfo> cdsiastInfoList2 = productRepository.GetCdsiastInfoList(cdi2); if (cdsiastInfoList2 != null && cdsiastInfoList2.Count > 0) { AST2 = cdsiastInfoList2[0].sno; } if (string.IsNullOrEmpty(AST1) && string.IsNullOrEmpty(AST2)) { throw new FisException("CHK203", new List<string> { prodidOrCustsn }); } else { //不为空则存入,保存product和Asset SN的绑定关系 //保存product和Asset SN的绑定关系 //Insert Product_Part values(@prdid,@partpn,@astsn1’’,’AT’,@user,getdate(),getdate()) //Insert Product_Part values(@prdid,@partpn,@astsn2’’,’AT’,@user,getdate(),getdate()) //注:@partpn 为PartNo in (bom中BomNodeType=’AT’ Descr=’ATSN1’ 对应的Pn) //IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>(); // IList<IPart> needGenAstPartList = (IList < IPart >) session.GetValue(Session.SessionKeys.NeedGenAstPartList); //IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(getProduct.Model); //IList<IBOMNode> ATList = bom.GetNodesByNodeType("AT"); //if (ATList != null) //{ // /* ITC-1360-1363, Jessica Liu, 2012-3-10 // part = ATList.Where(at => at.Part.Descr == "ATSN3") // .Select(at => at.Part) // .FirstOrDefault<IPart>(); // */ // part = ATList.Where(at => at.Part.Descr == descr) // .Select(at => at.Part) // .FirstOrDefault<IPart>(); //} /* ITC-1360-0328,Jessica Liu, 2012-2-11 if(part ==null){ List<string> errpara = new List<string>(); errpara.Add(ProdidOrCustsn); throw new FisException("CHK203", errpara); } */ //ITC-1360-0496, Jessica Liu, 2012-2-28 if (!string.IsNullOrEmpty(AST1)) { IProductPart assetTag1 = new ProductPart(); assetTag1.BomNodeType = part.BOMNodeType; assetTag1.Iecpn = string.Empty; //part.PN; assetTag1.CustomerPn = atsnav; //string.Empty; //part.CustPn; assetTag1.ProductID = getProduct.ProId; assetTag1.PartID = (part == null) ? "" : part.PN; //part.PN; assetTag1.PartSn = AST1; assetTag1.PartType = descr; //"AT"; assetTag1.Station = Station; assetTag1.Editor = Editor; assetTag1.Cdt = DateTime.Now; assetTag1.Udt = DateTime.Now; assetTag1.CheckItemType = checkItemType; getProduct.AddPart(assetTag1); productRepository.Update(getProduct, CurrentSession.UnitOfWork); } if (!string.IsNullOrEmpty(AST2)) { IProductPart assetTag2 = new ProductPart(); assetTag2.BomNodeType = part.BOMNodeType; assetTag2.Iecpn = string.Empty; //part.PN; assetTag2.CustomerPn = atsnav; //part.CustPn; assetTag2.ProductID = getProduct.ProId; assetTag2.PartID = (part == null) ? "" : part.PN; //part.PN; assetTag2.PartSn = AST2; assetTag2.PartType = descr; //"AT"; assetTag2.Station = Station; assetTag2.Editor = Editor; assetTag2.Cdt = DateTime.Now; assetTag2.Udt = DateTime.Now; assetTag2.CheckItemType = checkItemType; getProduct.AddPart(assetTag2); productRepository.Update(getProduct, session.UnitOfWork); } session.AddValue("AST1", AST1); session.AddValue("AST2", AST2); //2012-5-2 string ASTinfo = ""; if (!string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo += AST1 + ", " + AST2; } else if (!string.IsNullOrEmpty(AST1) && string.IsNullOrEmpty(AST2)) { ASTinfo = AST1; } else if (string.IsNullOrEmpty(AST1) && !string.IsNullOrEmpty(AST2)) { ASTinfo = AST2; } session.AddValue("ASTInfo", ASTinfo); } } return base.DoExecute(executionContext); }
public ArrayList GetProductInfo(string prodId, string editor, string stationId, string customer) { logger.Debug("(IHPPNLabelforRCTO)InputProdId start, [prodId]: " + prodId + " [editor]:" + editor + " [station]:" + stationId + " [customer]:" + customer); //List<string> retvaluelist = new List<string>(); ArrayList retvaluelist = new ArrayList(); string sessionKey = prodId; try { //////////////////////////////////////////////////////////////////////////////////// ArrayList retList = new ArrayList(); string productID = ""; string lcmCT = ""; string model = ""; var productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>(); IModelRepository CurrentModelRepository = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); if (prodId.Length == 14) { string strLCM = prodId; lcmCT = prodId; //若为[LCM CT],Product_Part表不存在@ProductID(Product_Part.PartSn=[LCM CT])则报错:“LCM CT 不存在” ProductPart conf = new ProductPart(); conf.PartSn = strLCM; IList<ProductPart> productList = productRep.GetProductPartList(conf); if (productList.Count == 0) { //IMES.FisObject.FA.Product.IProduct pro = productRep.Find(item.ProductID); //if (!string.IsNullOrEmpty(pro.ProId)) //{ /*FisException ex; List<string> erpara = new List<string>(); erpara.Add(pro.ProId); ex = new FisException("CHK953", erpara);//“LCM CT不存在” throw ex;*/ throw new FisException("CHK953", new string[] { }); // } } productID = productList[0].ProductID; var currentProduct = productRep.GetProductByIdOrSn(productID); model = currentProduct.Model; } else if (prodId.Length == 9 || prodId.Length == 10) { //若ProductID在Product/ProductStatus不存在,则报错:“ProductID不存在” IMES.FisObject.FA.Product.IProduct pro = productRep.Find(prodId); if (pro == null) { /*FisException ex; List<string> erpara = new List<string>(); erpara.Add(pro.ProId); ex = new FisException("CHK951", erpara);//“ProductID不存在” throw ex;*/ throw new FisException("CHK951", new string[] { }); } productID = pro.ProId; var currentProduct = productRep.GetProductByIdOrSn(productID); model = currentProduct.Model; } IList<IMES.FisObject.Common.Model.ModelInfo> infos = new List<IMES.FisObject.Common.Model.ModelInfo>(); infos = CurrentModelRepository.GetModelInfoByModelAndName(model, "FOX"); string HPPN = ""; if (infos == null || infos.Count <= 0) { throw new FisException("CHK952", new string[] { }); //"HP PN不存在" } else { HPPN = infos[0].Value; } //////////////////////////////////////////////////////////////////////////////////// retvaluelist.Add(productID); retvaluelist.Add(model); retvaluelist.Add(HPPN); return retvaluelist; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { logger.Debug("(HPPNLabelforRCTO)InputProdId end, [pdLine]:" + "" + " [prodId]: " + prodId + " [editor]:" + editor + " [station]:" + stationId + " [customer]:" + customer); } }