///<summary> /// 解除绑定 /// 使用工作流070UnpackCarton.xoml /// </summary> public void UnpackCarton(string cartonNo, string line, string editor, string station, string customer) { logger.Debug("(UnpackCarton)Unpack start, cartonNo:" + cartonNo + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer); FisException ex; List<string> erpara = new List<string>(); carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); try { CartonStatusInfo condition = new CartonStatusInfo(); condition.cartonNo = cartonNo; IList<CartonStatusInfo> CartonStatus = cartRep.GetCartonStatusInfo(condition); if (CartonStatus.Count == 0) { //erpara.Add("Invalid Carton No!"); erpara.Add(cartonNo); ex = new FisException("PAC001", erpara); throw ex; } var currentProduct = CommonImpl.GetProductByInput(cartonNo, CommonImpl.InputTypeEnum.Carton); if (currentProduct == null) { FisException fe = new FisException("CHK079", new string[] { cartonNo }); throw fe; } string sessionKey = currentProduct.ProId; 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, "UnpackCartonForRCTO.xoml", "UnpackCartonForRCTO.rules", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.Carton, cartonNo); currentSession.AddValue(Session.SessionKeys.CustSN, currentProduct.CUSTSN); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); erpara.Add(sessionKey); ex = new FisException("CHK020", erpara); throw ex; } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); } else { 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; } } 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("(UnpackCarton)Unpack end, cartonNo:" + cartonNo + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer); } }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext) { IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>(); carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); try { //2. Assign Pallet //Assign Pallet 的方法: //1. 找到与Product.DeliveryNo 结合的Pallets //2. 取其中尚未完成Combine PO in Carton 的Pallets //3. 按照Pallet No 正序,和Pallet 已经完成Combine PO in Carton 的数量逆序排序,取第一个Pallet //DECLARE @dn char(16) //DECLARE @pea float //DECLARE @pea2 int //SELECT @pea = InfoValue FROM DeliveryInfo (NOLOCK) WHERE DeliveryNo=@dn AND InfoType = ‘CQty’ string peastr; Delivery dev = deliveryRep.Find(product.DeliveryNo); peastr = (string)dev.GetExtendedProperty("CQty"); int pea = 0; if (string.IsNullOrEmpty(peastr)) { pea = 0; } else { decimal tmp = Convert.ToDecimal(peastr); pea = Convert.ToInt32(tmp); } //SET @pea2=CONVERT(int, @pea) //CREATE TABLE #plt (Plt char(14), qty int, tot int) //CREATE TABLE #Pltamount (Plt char(14), qty int) //INSERT #plt //SELECT PalletNo, DeliveryQty, 0 //FROM Delivery_Pallet (NOLOCK) //WHERE DeliveryNo=@dn IList<DeliveryPalletInfo> palletList = deliveryRep.GetDeliveryPalletListByDN(product.DeliveryNo); //INSERT #Pltamount //SELECT PalletNo, COUNT(ProductID) as Qty //FROM Product (NOLOCK) //WHERE DeliveryNo = @dn IList<IProduct> mountList = productRep.GetProductListByDeliveryNo(product.DeliveryNo); //UPDATE #plt SET tot = b.qty FROM #plt a,#Pltamount b //WHERE a.Plt=b.Plt //SELECT * FROM #plt //DELETE FROM #plt WHERE @pea2 * CONVERT(int, qty) – CONVERT(int, tot) < 1 //SELECT * FROM #plt for (int i = palletList.Count-1; i >= 0; i--) { DeliveryPalletInfo node = palletList[i]; IList <ProductModel> proList = productRep.GetProductByDnPallet(product.DeliveryNo,node.palletNo); if ((proList != null) && (proList.Count > 0)) { int tot = proList.Count; int qty = node.deliveryQty; node.id = tot; if (pea*qty - tot <1) { //ITC-1414-0116 palletList.RemoveAt(i); } } } //SELECT TOP 1 Plt as [Pallet No] //FROM #plt //ORDER BY Plt, tot DESC var tmpList = from item in palletList orderby item.palletNo, item.id descending select item; IList<DeliveryPalletInfo> orderList = tmpList.ToList<DeliveryPalletInfo>(); string palletNo = orderList[0].palletNo; //3. Assign Location by Pallet //IF EXISTS(SELECT SnoId FROM PAK_LocMas (NOLOCK)WHERE Tp='PakLoc' AND Pno=@PalletNo) //BEGIN // SELECT @loc=SnoId FROM PAK_LocMas(NOLOCK) WHERE Tp='PakLoc' AND Pno=@PalletNo //END //ELSE //BEGIN //IF EXISTS(SELECT SnoId FROM PAK_LocMas(NOLOCK) WHERE Tp='PakLoc' AND Pno='' ) //BEGIN //SELECT @loc=SnoId FROM PAK_LocMas(NOLOCK) WHERE Tp='PakLoc' AND Pno='' ORDER BY CONVERT(int, SnoId) //UPDATE PAK_LocMas SET Pno=@PalletNo,Udt=GETDATE() WHERE Tp='PakLoc' AND SnoId=@loc //END //ELSE //BEGIN //SELECT @loc='Others' //END //END //@PalletNo – 上文分配的Pallet No //@loc – 系统分配的库位 string loc = ""; IList<PakLocMasInfo> macList = palletRep.GetPakLocMasList(palletNo, "PakLoc"); if (macList.Count > 0) { loc = macList[0].snoId; } else { macList = palletRep.GetPakLocMasList("", "PakLoc"); if (macList.Count > 0) { PakLocMasInfo locInfo = macList[0]; foreach (var item in macList) { if (Convert.ToInt64(locInfo.snoId) > Convert.ToInt64(item.snoId)) { locInfo = item; } } loc = locInfo.snoId; PakLocMasInfo sitem= new PakLocMasInfo(); PakLocMasInfo cond= new PakLocMasInfo(); sitem.pno= palletNo; sitem.udt = DateTime.Now; cond.tp = "PakLoc"; cond.snoId = loc; palletRep.UpdatePakLocMasInfoDefered(CurrentSession.UnitOfWork,sitem,cond ); } else { loc = "Others"; } } CurrentSession.AddValue("Location",loc); //4. Product结合Pallet and Carton //将页面上[Products in Carton] 中的每一个Product和上文系统分配的Pallet 以及上文生成的Carton No 进行结合 – Update Product //Product.PalletNo – Pallet No //Product.CartonSN – Carton No IList<IProduct> productList = (List<IProduct>)CurrentSession.GetValue(Session.SessionKeys.ProdList); foreach (var item in productList) { item.PalletNo = palletNo; item.CartonSN = product.CartonSN; //productRep.Update(item,CurrentSession.UnitOfWork); productRep.UpdateForBindDNAndPalletDefered(CurrentSession.UnitOfWork, (Product)item); } //ITC-1414-0070 //ITC-1414-0120 //5. 更新CartonStatus 的状态为95 (Station = ‘95’ ,Status= ‘1’),记录CartonLog CartonStatusInfo sinfo = new CartonStatusInfo(); CartonStatusInfo sconf = new CartonStatusInfo(); sconf.cartonNo = product.CartonSN; sinfo.editor = Editor; sinfo.line = Line; sinfo.station ="95";//Station; sinfo.status = 1;//pass sinfo.udt = DateTime.Now; cartRep.UpdateCartonStatusDefered(CurrentSession.UnitOfWork,sinfo,sconf); CartonLogInfo linfo = new CartonLogInfo(); linfo.cartonNo = product.CartonSN; linfo.editor = Editor; linfo.line = Line; linfo.station = "95"; linfo.status = 1;//pass linfo.cdt = DateTime.Now; cartRep.AddCartonLogInfoDefered(CurrentSession.UnitOfWork, linfo); //6.更新Carton上所有Product 的ProductStatus 的状态为Combine Po In Carton for Docking 的站号(Station = Combine Po In Carton for Docking 的站号,Status= ‘1’),并记录ProductLog string line = string.IsNullOrEmpty(this.Line) ? product.Status.Line : this.Line; var newStatus = new IMES.FisObject.FA.Product.ProductStatus(); newStatus.Editor = Editor; newStatus.Line = line; newStatus.StationId = Station; newStatus.Status = IMES.FisObject.Common.Station.StationStatus.Pass; IList<string> ProductIDList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.NewScanedProductIDList); productRep.UpdateProductListStatusDefered(CurrentSession.UnitOfWork, newStatus, ProductIDList); foreach (var item in productList) { var productLog = new ProductLog { Model = item.Model, Status = IMES.FisObject.Common.Station.StationStatus.Pass, Editor = Editor, Line = line, Station = Station, Cdt = DateTime.Now }; item.AddLog(productLog); productRep.Update(item, CurrentSession.UnitOfWork); } } catch (Exception) { throw; } return base.DoExecute(executionContext); }
/// <summary> /// 產生Carton NO號相关逻辑 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext) { IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product); IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); //Format of Carton No //CYMDDSSSS //Remark: //T – 前缀,固定字符’C’ //Y – Year Code,西元年的最后一位 //M – Month Code,1~9 表示1~9 月,A~C 表示10~12 月 //DD – Day Code,两位,00~31 //SSSS – 流水号,10进制,起始值为0001 try { string CartonNO = ""; string maxnum = ""; string prestr = ""; //求当前日期是一年的中第几周 //int weeks = 0; DateTime curDate = DateTime.Now; /*var ret = IMES.Infrastructure.Utility.Generates.WeekRuleEngine.Calculate("103", dateTime); string weekCode = ret.Week.ToString().PadLeft(2, '0'); string year = ret.Year.ToString(); string month = ret.*/ string year = curDate.Year.ToString(); //string month = Convert.ToString(curDate.Month,16); string month = curDate.Month.ToString("X");//2012/10/05 string dd = curDate.Day.ToString("d2"); CartonNO = "C" + year.Substring(year.Length - 1, 1) + month + dd; prestr = CartonNO; // 自己管理事务开始 SqlTransactionManager.Begin(); IUnitOfWork uof = new UnitOfWork();//使用自己的UnitOfWork //从NumControl中获取流水号 //GetMaxNumber INumControlRepository numControl = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>(); bool addflag = false; //maxnum = numControl.GetMaxNumber("CARTONNO", prestr + "{0}"); var maxObj = numControl.GetMaxValue("CARTONNO", prestr); //檢查有沒有lock index, 沒有lock index, 改變查詢條件 if (maxObj == null) { //lock NoType='CARTONNO' //string maxData = numControl.GetMaxNumber("CARTONNO", "{0}"); //maxObj = numControl.GetMaxNumberObj("CARTONNO", prestr + "{0}"); var data = numControl.GetMaxValue("CARTONNO", "Lock"); maxObj = numControl.GetMaxValue("CARTONNO", prestr); } if (maxObj != null) { maxnum = maxObj.Value; } if (string.IsNullOrEmpty(maxnum)) { maxnum = "0001";//"8000"; addflag = true; } else { //maxnum="CNU248000Y"; string numstr = maxnum.Substring(maxnum.Length - 4); if (numstr.ToUpper() == "9999") { FisException fe = new FisException("CHK867", new string[] { }); //流水号已满! throw fe; } //ITC-1414-0069 int result = Convert.ToInt32(numstr)+1; maxnum = result.ToString("d4"); } CartonNO = CartonNO + maxnum.ToUpper(); NumControl item = null;// new NumControl(); if (addflag) { item = new NumControl(); item.NOType = "CARTONNO"; item.Value = CartonNO; item.NOName = prestr; item.Customer = this.Customer; } else { item = maxObj; item.Value = CartonNO; } //numControl.SaveMaxNumber(item, addflag, prestr + "{0}"); numControl.SaveMaxNumber(item, addflag); uof.Commit(); //立即提交UnitOfWork更新NumControl里面的最大值 SqlTransactionManager.Commit();//提交事物,释放行级更新锁 product.CartonSN = CartonNO; //a. Insert CartonStatus //INSERT INTO [CartonStatus]([CartonNo],[Station],[Status],[Line],[Editor],[Cdt],[Udt]) //VALUES(@CartonNo, @Station, 1, @PdLine, @Editor, GETDATE(), GETDATE()) carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); CartonStatusInfo sinfo = new CartonStatusInfo(); sinfo.cartonNo = product.CartonSN; sinfo.station = Station; sinfo.status = 1;//pass sinfo.line = Line; sinfo.editor = Editor; sinfo.cdt = DateTime.Now; sinfo.udt = DateTime.Now; cartRep.AddCartonStatusInfoDefered(CurrentSession.UnitOfWork,sinfo); //b. Insert CartonLog //INSERT INTO [CartonLog]([CartonNo],[Station],[Status],[Line],[Editor],[Cdt]) //VALUES(@CartonNo, @Station, 1, @PdLine, @Editor, GETDATE()) CartonLogInfo linfo = new CartonLogInfo(); linfo.cartonNo = product.CartonSN; linfo.station = Station; linfo.status = 1;//pass linfo.line = Line; linfo.editor = Editor; linfo.cdt = DateTime.Now; cartRep.AddCartonLogInfoDefered(CurrentSession.UnitOfWork,linfo); } catch (Exception) { SqlTransactionManager.Rollback(); throw; } finally { SqlTransactionManager.Dispose(); SqlTransactionManager.End(); } return base.DoExecute(executionContext); }
/// <summary> /// /// </summary> /// <param name="inputSN"></param> /// <param name="model"></param> /// <param name="firstProID"></param> /// <param name="line"></param> /// <param name="editor"></param> /// <param name="station"></param> /// <param name="customer"></param> /// <returns></returns> public ArrayList InputSN(string inputCartonNo, string line, string editor, string station, string customer) { logger.Debug("(CombineCartonInDN)inputCartonNo start, inputCartonNo:" + inputCartonNo); try { ArrayList retLst = new ArrayList(); var productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>(); IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); //a. 如果用户录入的[Carton No] 在数据库(CartonStatus.CartonNo)中不存在,则报告错误:“Invalid Carton No!” carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); CartonStatusInfo carConf = new CartonStatusInfo(); carConf.cartonNo = inputCartonNo; IList<CartonStatusInfo> carList = cartRep.GetCartonStatusInfo(carConf); if (carList.Count == 0) { List<string> errpara = new List<string>(); errpara.Add(inputCartonNo); throw new FisException("PAK139", errpara);//此Carton 不存在! } //b.如果用户录入的[Carton No] 已经结合了Pallet,则报告错误:“This Carton has combined Pallet!” IProduct eqCondition1 = new Product(); IProduct notNullCondition1 = new Product(); eqCondition1.CartonSN = inputCartonNo; notNullCondition1.PalletNo = ""; IList<IProduct> prodcutlist1 = productRep.GetProductInfoListByConditionsNotNull(eqCondition1, notNullCondition1); if (prodcutlist1.Count != 0) { List<string> errpara = new List<string>(); errpara.Add(inputCartonNo); throw new FisException("PAK159", errpara);//“This Carton has combined Pallet!” } //c.如果用户录入的[Carton No] 已经结合了Delivery,则报告错误:“This Carton has combined Delivery!” IProduct eqCondition2 = new Product(); IProduct notNullCondition2 = new Product(); eqCondition2.CartonSN = inputCartonNo; notNullCondition2.DeliveryNo = ""; IList<IProduct> prodcutlist2 = productRep.GetProductInfoListByConditionsNotNull(eqCondition2, notNullCondition2); if (prodcutlist2.Count != 0) { List<string> errpara = new List<string>(); errpara.Add(inputCartonNo); throw new FisException("PAK160", errpara);//“This Carton has combined Delivery!” } IList<IProduct> prodList = new List<IProduct>(); prodList = productRep.GetProductListByCartonNo(inputCartonNo); if (prodList.Count == 0) { throw new FisException("CHK109", new string[] { }); } IProduct curProduct; curProduct = productRep.Find(prodList[0].ProId); retLst.Add(prodList[0].Model); string sessionKey = prodList[0].ProId; 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, "CombineCartonInDNForRCTO.xoml", "CombineCartonInDNForRCTO.rules", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.IsComplete, false); currentSession.AddValue(Session.SessionKeys.Product, curProduct); currentSession.AddValue(Session.SessionKeys.ProdList, prodList); IList<string> productIDList = new List<string>(); currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, productIDList); 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 { currentSession.AddValue(Session.SessionKeys.Product, curProduct); currentSession.Exception = null; currentSession.SwitchToWorkFlow(); /*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; } //======================================================== ArrayList retList = new ArrayList(); ProductInfoMaintain prodInfo = new ProductInfoMaintain(); if (string.IsNullOrEmpty(curProduct.CUSTSN)) { curProduct.CUSTSN =""; } prodInfo.ProductID = curProduct.ProId; prodInfo.Sn = curProduct.CUSTSN; prodInfo.Model = curProduct.Model; //prodInfo.Station = vendorCT; IList<IProduct> proList = (List<IProduct>)currentSession.GetValue(Session.SessionKeys.ProdList); IList<string> idList = (List<string>)currentSession.GetValue(Session.SessionKeys.NewScanedProductIDList); proList = productRep.GetProductListByCartonNo(inputCartonNo); foreach (IProduct item in proList) { idList.Add(item.ProId); } currentSession.AddValue(Session.SessionKeys.ProdList, proList); currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, idList); retList.Add(prodInfo); retList.Add(prodList.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("(CombineCartonInDN)inputCartonNo end, uutSn:" + inputCartonNo); } }
public ArrayList ReprintCartonLabel(string inputSN, string reason, string line, string editor, string station, string customer, IList<PrintItem> printItems) { logger.Debug("(CombinPoInCarton)ReprintLabel Start," + " [custSN]:" + inputSN + " [line]:" + line + " [editor]:" + editor + " [station]:" + station + " [customer]:" + customer); ArrayList retList = new ArrayList(); try { //var productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>(); //IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IProduct curProduct; curProduct = productRep.FindOneProductWithProductIDOrCustSNOrCarton(inputSN); if (curProduct == null) { if (inputSN.Substring(0, 2) == "CN" || inputSN.Substring(0, 2) == "5C") { List<string> errpara = new List<string>(); errpara.Add(inputSN); throw new FisException("PAK042", errpara); } else if (inputSN.Substring(0, 1) == "C") { List<string> errpara = new List<string>(); errpara.Add(inputSN); throw new FisException("CHK801", errpara); } else { List<string> errpara = new List<string>(); errpara.Add(inputSN); throw new FisException("SFC002", errpara); } } //d. 如果Product 尚未结合的Carton,则报告错误:“该Product 尚未Combine Carton,不能Reprint Carton Label!” if (string.IsNullOrEmpty(curProduct.CartonSN)) { List<string> errpara = new List<string>(); errpara.Add(curProduct.ProId); throw new FisException("PAK138", errpara); } //e. 如果输入的[Carton No] 在数据库(CartonStatus.CartonNo) 中不存在,则报告错误:“此Carton 不存在!” carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); CartonStatusInfo carConf = new CartonStatusInfo(); carConf.cartonNo = curProduct.CartonSN; IList<CartonStatusInfo> carList = cartRep.GetCartonStatusInfo(carConf); if (carList.Count == 0) { List<string> errpara = new List<string>(); errpara.Add(curProduct.ProId); throw new FisException("PAK139", errpara);//此Carton 不存在! } //如果Product 非Frame Or TRO Or BaseModel Or SLICE 的话,需要报告错误:“Product is not Frame Or TRO Or BaseModel Or SLICE” //SELECT @PN = Value FROM ModelInfo NOLOCk WHERE Model = @Model AND Name = 'PN' IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>(); string pn = ""; string noCarton = ""; string modelstr = curProduct.Model; Model curModel = modelRep.Find(curProduct.Model); pn = curModel.GetAttribute("PN"); noCarton = curModel.GetAttribute("NoCarton"); bool labelFlag = false; if (!string.IsNullOrEmpty(pn) && pn.Length >= 6) { if (pn.Substring(5, 1) == "U" || pn.Substring(5, 1) == "E" || curProduct.Model.Substring(0, 3) == "156" || curProduct.Model.Substring(0, 3) == "146" || curProduct.Model.Substring(0, 3) == "157" || curProduct.Model.Substring(0, 3) == "158" || curProduct.Model.Substring(0, 2) == "PO" || curProduct.Model.Substring(0, 2) == "2P" || curProduct.Model.Substring(0, 3) == "172" || curProduct.Model.Substring(0, 2) == "BC") { labelFlag = true; } } if (!labelFlag) { FisException fe = new FisException("PAK133", new string[] { }); //Product is not Frame Or TRO Or BaseModel Or SLICE throw fe; } string sessionKey = curProduct.ProId; var repository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.FA.Product.IProductRepository, IMES.FisObject.FA.Product.IProduct>(); 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); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow("ReprintCombinPoInCarton.xoml", "", wfArguments); currentSession.AddValue(Session.SessionKeys.PrintLogBegNo, curProduct.ProId); currentSession.AddValue(Session.SessionKeys.PrintLogEndNo, curProduct.ProId); currentSession.AddValue(Session.SessionKeys.PrintLogName, curProduct.ProId); currentSession.AddValue(Session.SessionKeys.PrintLogDescr, "CombinInCarton"); currentSession.AddValue(Session.SessionKeys.Reason, reason); currentSession.AddValue(Session.SessionKeys.PrintItems, printItems); 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; } IList<PrintItem> printList = (IList<PrintItem>)currentSession.GetValue(Session.SessionKeys.PrintItems); Delivery curDev = deliveryRep.Find(curProduct.DeliveryNo); string cQtyStr = (string)curDev.GetExtendedProperty("CQty"); int cQty = 0; if (string.IsNullOrEmpty(cQtyStr)) { cQty = 5; } else { decimal tmp = Convert.ToDecimal(cQtyStr); cQty = Convert.ToInt32(tmp); } // pdf string flagstr = (string)curDev.GetExtendedProperty("Flag"); string templatename = ""; if (flagstr == "N") { //HP_EDI.dbo.op_TemplateCheck '"&DN&"','Box Ship Label' templatename = cartRep.GetTemplateNameViaCallOpTemplateCheck(curProduct.DeliveryNo, "Box Ship Label"); //Not found template of this DN: "&DN if (templatename == "ERROR") { FisException ex; List<string> erpara = new List<string>(); erpara.Add(curProduct.DeliveryNo); ex = new FisException("PAK132", erpara);//Not found template of this DN: &DN throw ex; } } var log = new ReprintLog { LabelName = currentSession.GetValue(Session.SessionKeys.PrintLogName).ToString(), BegNo = currentSession.GetValue(Session.SessionKeys.PrintLogBegNo).ToString(), EndNo = currentSession.GetValue(Session.SessionKeys.PrintLogEndNo).ToString(), Descr = (string)currentSession.GetValue(Session.SessionKeys.PrintLogDescr), Reason = (string)currentSession.GetValue(Session.SessionKeys.Reason), Editor = editor }; //当Delivery 的CQty 属性=1,但Delivery.Model 的NoCarton 属性(Model.InfoType = ‘NoCarton’)不存在,或者存在但<>’Y’ 时,也需要列印Carton Label string printflag = "N"; if (cQty > 1 || (cQty ==1 && noCarton!="Y")) { printflag = "Y"; IUnitOfWork uof = new UnitOfWork(); var rep = RepositoryFactory.GetInstance().GetRepository<IReprintLogRepository, ReprintLog>(); rep.Add(log, uof); uof.Commit(); } retList.Add(printList); retList.Add(flagstr); retList.Add(0); retList.Add(curProduct.CartonSN); retList.Add(curProduct.DeliveryNo); retList.Add(curProduct.CUSTSN); retList.Add(templatename); retList.Add(cQty); retList.Add(printflag); return retList; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw new SystemException(e.Message); } finally { logger.Debug("(CombinPoInCarton)ReprintLabel End," + " [custSN]:" + inputSN + " [line]:" + line + " [editor]:" + editor + " [station]:" + station + " [customer]:" + customer); } }
/// <summary> /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { string Delivery = (string)CurrentSession.GetValue(Session.SessionKeys.DeliveryNo); Delivery CurrentDelivery = (Delivery)CurrentSession.GetValue(Session.SessionKeys.Delivery); IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IProductRepository repProduct = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); //// IList<string> nameList = new List<string>(); nameList.Add("UCC"); nameList.Add("BoxId"); repProduct.BackUpProductByDnPure( Delivery, Editor); repProduct.BackUpProductInfoByDn( Delivery, Editor, nameList); repProduct.BackUpProductStatusByDnPure( Delivery, Editor); //// ProductStatus newStatus = new ProductStatus(); newStatus.Editor = Editor; newStatus.Line = Line; newStatus.StationId = Station; newStatus.Status = StationStatus.Pass; newStatus.ReworkCode = ""; repProduct.UpdateUnPackProductStatusByDn(newStatus, Delivery); carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>(); //// ProductLog newLog = new ProductLog(); newLog.Editor = Editor; newLog.Line = Line; newLog.Station = Station; newLog.Status = StationStatus.Pass; repProduct.WriteUnPackProductLogByDn(Delivery,newLog); ////// repProduct.UnPackProductInfoByDeliveryNoAndInfoType("UCC",Delivery); repProduct.UnPackProductInfoByDeliveryNoAndInfoType("BoxId", Delivery); //////// if (Station != "8U") { IList<IProduct> lstProduct = repProduct.GetProductObjListByDn(Delivery); if (lstProduct != null && lstProduct.Count > 0) { foreach(IProduct tmp in lstProduct) { string carton = tmp.CartonSN; DM.CartonInfoInfo condition = new DM.CartonInfoInfo(); condition.cartonNo = carton; cartRep.DeleteCartonInfo(condition); //mantis 1395 DM.CartonStatusInfo cond = new DM.CartonStatusInfo(); DM.CartonStatusInfo sv = new DM.CartonStatusInfo(); cond.cartonNo = tmp.CartonSN; sv.station = Station; sv.status = 1; sv.editor = Editor; sv.udt = DateTime.Now; cartRep.UpdateCartonStatusDefered(CurrentSession.UnitOfWork, sv, cond); DM.CartonLogInfo item = new DM.CartonLogInfo(); item.cartonNo = tmp.CartonSN; item.cdt = DateTime.Now; item.editor = Editor; item.line = tmp.Status.Line; item.station = Station; item.status = 1; cartRep.AddCartonLogInfoDefered(CurrentSession.UnitOfWork, item); //mantis 1395 string palletNo = tmp.PalletNo; DM.PakLocMasInfo setValue = new DM.PakLocMasInfo(); DM.PakLocMasInfo pakLoc_condition = new DM.PakLocMasInfo(); setValue.pno = ""; setValue.editor = Editor; pakLoc_condition.pno = palletNo; pakLoc_condition.tp = "PakLoc"; palletRep.UpdatePakLocMasInfo(setValue, pakLoc_condition); } } } if (Station != "8U") repProduct.UnPackProductByDn(Delivery); else repProduct.UnPackProductByDnWithoutCartonSN(Delivery); ///////////////////// CurrentDelivery.Status = "00"; CurrentDelivery.Editor = this.Editor; CurrentDelivery.Udt = DateTime.Now; DeliveryRepository.Update(CurrentDelivery, CurrentSession.UnitOfWork); ///////////////////// return base.DoExecute(executionContext); }
/// <summary> /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作 /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { string CartonNo = (string)CurrentSession.GetValue(Session.SessionKeys.Carton); carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>(); IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IProductRepository repProduct = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IList<IProduct> lstProduct = repProduct.GetProductListByCartonNo(CartonNo); CartonInfoInfo condition = new CartonInfoInfo(); condition.cartonNo = CartonNo; cartRep.DeleteCartonInfo(condition); DeliveryRepository.UpdateDeliveryForStatusChange(Editor, CartonNo); // CartonStatusInfo setValue = new CartonStatusInfo(); CartonStatusInfo status_condition = new CartonStatusInfo(); setValue.cartonNo = CartonNo; setValue.status = 1; setValue.editor = Editor; setValue.station = Station; status_condition.cartonNo = CartonNo; cartRep.UpdateCartonStatus( setValue, status_condition); /////////////// CartonLogInfo item = new CartonLogInfo(); item.cartonNo = CartonNo; item.editor = Editor; item.line = Line; item.station = Station; item.status = 1; cartRep.AddCartonLogInfo(item); ////////////////// CurrentSession.AddValue(Session.SessionKeys.ProdList, lstProduct); CurrentSession.AddValue(Session.SessionKeys.DnIndex, 0); CurrentSession.AddValue(Session.SessionKeys.DnCount, lstProduct.Count); return base.DoExecute(executionContext); }
public ArrayList InputFirstCartonNo(string firstCN, string line, string editor, string station, string customer) { logger.Debug("(PalletVerifyForRCTO)InputFirstCartonNo start, custsn:" + firstCN + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer); FisException ex; List<string> erpara = new List<string>(); ArrayList retLst = new ArrayList(); try { // check carton info CartonStatusInfo condition = new CartonStatusInfo(); condition.cartonNo = firstCN; IList<CartonStatusInfo> CartonStatus = cartRep.GetCartonStatusInfo(condition); if (CartonStatus.Count == 0) { //erpara.Add("Invalid Carton No!"); erpara.Add(firstCN); ex = new FisException("PAC001", erpara); throw ex; } IList<IProduct>productList = productRepository.GetProductListByCartonNo(firstCN); if (productList.Count == 0) { //erpara.Add("This Carton does not be combined with Product!"); erpara.Add(firstCN); ex = new FisException("PAK161", erpara); throw ex; } string palletNo = productList[0].PalletNo; string DeliveryNo = productList[0].DeliveryNo; IProduct isNullCondition = new Product(); isNullCondition.PalletNo =""; IProduct eqCondition = new Product(); eqCondition.CartonSN =firstCN; IList<IProduct>productPalletLst = productRepository.GetProductInfoListByConditions( eqCondition, isNullCondition); if (productPalletLst.Count != 0) { //erpara.Add("This Carton does not be combined with Pallet!"); erpara.Add(firstCN); ex = new FisException("PAK162", erpara); throw ex; } ////check The Pallet have verified! PalletLogInfo log_condition = new PalletLogInfo(); log_condition.palletNo = palletNo; log_condition.station = "9A"; IList<PalletLogInfo> lstPallet = iPalletRepository.GetPalletLogInfoList(log_condition); if (lstPallet.Count > 0) { erpara.Add(palletNo); ex = new FisException("PAK163", erpara); //Pallet have verified throw ex; } ////check shipment int palletQty = DeliveryRepository.GetSumofDeliveryQtyFromDeliveryPallet(palletNo); IList<DeliveryPalletInfo> lstShipment = DeliveryRepository.GetDeliveryPalletListByPlt(palletNo); if (lstShipment.Count > 0) { string shipment = lstShipment[0].shipmentNo; string consolidate = DeliveryRepository.GetDeliveryInfoValue(DeliveryNo, "Consolidated"); if (consolidate != null && consolidate !="") { int count = DeliveryRepository.GetCountOfDeliveryNoPrefixForDoubleDeliveryInfoPairs("Consolidated", consolidate, "RedShipment", consolidate); if (palletNo.Substring(0, 2) != "BA" && palletNo.Substring(0, 2) != "NA") { string[] pattern = consolidate.Split('/'); int dnQty = 0; if (pattern.Length.ToString() != "2" || string.IsNullOrEmpty(pattern[0]) || string.IsNullOrEmpty(pattern[1])) { erpara.Add(firstCN); ex = new FisException("PAK024", erpara); //找不到该Delivery No 的Consolidated 属性 throw ex; } dnQty = Int32.Parse(pattern[1]); if (dnQty != count) { erpara.Add(firstCN); ex = new FisException("PAK165", erpara); //Delivery 尚未完全Download throw ex; } } //////////////// int SumCartonQty = 0; int SumDnPallletQty = 0; IList<Delivery> dnList = DeliveryRepository.GetDeliveryListByInfoTypeAndValue("Consolidated", consolidate); foreach (Delivery dn in dnList) { string DeliveryNo1 = dn.DeliveryNo; string cqty = DeliveryRepository.GetDeliveryInfoValue(DeliveryNo1, "CQty"); Decimal qty = Convert.ToDecimal(cqty); int cartonQty = (int)(dn.Qty / qty); if (dn.Qty % qty != 0) cartonQty++; SumCartonQty += cartonQty; int DnPallletQty = DeliveryRepository.GetSumDeliveryQtyOfACertainDN(DeliveryNo1); SumDnPallletQty += DnPallletQty; } if (SumCartonQty != SumDnPallletQty) { //从整机库get { erpara.Add(palletNo); ex = new FisException("CHK903", erpara); //PALLET 未完全Download! throw ex; } } } } retLst.Add(palletNo); retLst.Add(firstCN); retLst.Add(DeliveryNo); retLst.Add(palletQty); return retLst; } catch (FisException e) { throw e; } catch (Exception e) { logger.Error(e.Message, e); throw new SystemException(e.Message); } finally { logger.Debug("(PalletVerifyImpl)InputCustSNOnCooLabel end, custsn:" + firstCN + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer); } }
/// <summary> /// </summary> /// <param name="firstSn">firstSn</param> /// <param name="custSn">custSn</param> /// <returns></returns> public ArrayList InputCartonNo(string firstCN, string CartonNo,string firstPalletNo) { logger.Debug("(PalletVerifyImpl)ScanSN start, firstSn:" + firstCN + " custSn:" + CartonNo); ArrayList retLst = new ArrayList(); FisException ex; List<string> erpara = new List<string>(); try { var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); CartonStatusInfo condition = new CartonStatusInfo(); condition.cartonNo = CartonNo; IList<CartonStatusInfo> CartonStatus = cartRep.GetCartonStatusInfo(condition); if (CartonStatus.Count == 0) { //erpara.Add("Invalid Carton No!"); erpara.Add(CartonNo); ex = new FisException("PAC001", erpara); throw ex; } IList<IProduct> productList = productRepository.GetProductListByCartonNo(CartonNo); if (productList.Count == 0) { //erpara.Add("This Carton does not be combined with Product!"); erpara.Add(CartonNo); ex = new FisException("PAK161", erpara); throw ex; } string palletNo = productList[0].PalletNo; string DeliveryNo = productList[0].DeliveryNo; IProduct isNullCondition = new Product(); isNullCondition.PalletNo = ""; IProduct eqCondition = new Product(); eqCondition.CartonSN = CartonNo; IList<IProduct> productPalletLst = productRepository.GetProductInfoListByConditions(eqCondition, isNullCondition); if (productPalletLst.Count != 0) { //erpara.Add("This Carton does not be combined with Pallet!"); erpara.Add(firstCN); ex = new FisException("PAK162", erpara); throw ex; } if (palletNo != firstPalletNo) { //erpara.Add("This palletNo is not equal!"); erpara.Add(palletNo); erpara.Add(firstPalletNo); ex = new FisException("PAK164", erpara); throw ex; } retLst.Add(palletNo); retLst.Add(CartonNo); retLst.Add(DeliveryNo); return retLst; } catch (FisException e) { throw e; } catch (Exception e) { throw new SystemException(e.Message); } finally { logger.Debug("(PalletVerifyImpl)ScanSN end, firstSn:" + firstCN + " custSn:" + CartonNo); } }