/// <summary> /// 获取Product表相关信息 /// </summary> /// <param name="line">line</param> /// <param name="editor">editor</param> /// <param name="station">station</param> /// <param name="customer">customer</param> /// <param name="customerSN">customer SN</param> public S_RowData_Product GetProduct(string line, string editor, string station, string customer,string customerSN) { logger.Debug("(_CombineCOAandDN)GetProduct start.customerSN:" + customerSN); string keyStr = ""; try { string sessionKey = customerSN; keyStr = sessionKey; Session 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, "CombineCOAandDNBlock.xoml", "", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.CustSN, customerSN); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } S_RowData_Product ret = new S_RowData_Product(); ret.DN = ""; ret.Model = ""; ret.ProductID = ""; ret.isBT = "false"; ret.isCDSI = ""; ret.isFactoryPo = ""; ret.isWin8 = ""; IProduct temp = productRepository.GetProductByCustomSn(customerSN); if (null != temp) { ret.ProductID = temp.ProId; ret.isBT = temp.IsBT.ToString(); ret.Model = temp.Model; IList<IMES.FisObject.Common.Model.ModelInfo> isPO = modelRep.GetModelInfoByModelAndName(temp.Model, "PO"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpPO in isPO) { if (tmpPO.Value == "Y") { ret.isCDSI = "true"; } else { IList<IMES.FisObject.Common.Model.ModelInfo> isATSNAV = modelRep.GetModelInfoByModelAndName(temp.Model, "ATSNAV"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpATSNAV in isATSNAV) { if (tmpATSNAV.Value == null) { } else if (tmpATSNAV.Value != "") { ret.isCDSI = "true"; } break; } } break; } if (ret.isCDSI == "true") { CdsiastInfo condition = new CdsiastInfo(); condition.snoId = temp.ProId; condition.tp = "FactoryPO"; IList<CdsiastInfo> isCdsiastInfo = productRepository.GetCdsiastInfoList(condition); ret.isFactoryPo = ""; foreach (CdsiastInfo tmpCdsiastInfo in isCdsiastInfo) { ret.isFactoryPo = tmpCdsiastInfo.sno; break; } if (ret.isBT == "true" || ret.isBT == "True") { } else { if (ret.isFactoryPo == "" || ret.isFactoryPo == null) { throw new FisException("CHK882", new string[] { }); } } } IList<MoBOMInfo> win8list = bomRepository.GetPnListByModelAndBomNodeTypeAndDescr(temp.Model, "P1", "ECOA"); if (win8list != null && win8list.Count > 0) { IList<string> typeList = new List<string>(); typeList.Add("P/N"); typeList.Add("Key"); typeList.Add("Hash"); IList<IMES.FisObject.FA.Product.ProductInfo> infoList = productRepository.GetProductInfoList(temp.ProId, typeList); if (infoList == null || infoList.Count != 3) { throw new FisException("CHK885", new string[] { }); //ret.isWin8 = "true"; } else { ret.isWin8 = "true"; } } if (ret.isCDSI == "true") { DNQueryCondition conditionDN = new DNQueryCondition(); DateTime aTime = DateTime.Now; aTime = aTime.AddDays(-3); conditionDN.ShipDateFrom = new DateTime(aTime.Year, aTime.Month, aTime.Day, 0, 0, 0, 0); conditionDN.Model = ret.Model; if (conditionDN.Model != "") { IList<Srd4CoaAndDn> dnList = currentRepository.GetDNListByConditionForPerformanceWithSorting(conditionDN); foreach (Srd4CoaAndDn tmp in dnList) { if (ret.isFactoryPo != "") { if (ret.isFactoryPo != tmp.PoNo) { continue; } } ret.DN = tmp.DeliveryNO; break; } } } else { Delivery assignDelivery = null; int assignQty = 0; IList<Delivery> deliveryList = currentRepository.GetDeliveryListByModel(ret.Model,"PC",12,"00"); if (deliveryList.Count == 0) { if (temp.IsBT) { } else { List<string> errpara = new List<string>(); errpara.Add(customerSN); throw new FisException("PAK101", errpara);//无此机型Delivery! } } //a) ShipDate 越早,越优先 //b) 散装优先于非散装 //c) 剩余未包装Product数量越少的越优先 bool assignNA = false; foreach (Delivery dvNode in deliveryList) { int curqty = productRepository.GetCombinedQtyByDN(dvNode.DeliveryNo); int tmpqty = dvNode.Qty - curqty; int curQty = productRepository.GetCombinedQtyByDN(dvNode.DeliveryNo); if (tmpqty > 0 ) { bool naflag = false; foreach (DeliveryPallet dpNode in dvNode.DnPalletList) { if (dpNode.PalletID.Substring(0, 2) == "NA") { naflag = true; break; } } if (assignDelivery == null) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; continue; } if (DateTime.Compare(assignDelivery.ShipDate, dvNode.ShipDate) < 0) { continue; } if (!assignNA && naflag) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; } else if (assignNA == naflag) { if (tmpqty < assignQty) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; } } } } if (assignDelivery == null) { if (temp.IsBT) { } else { FisException fe = new FisException("PAK103", new string[] { }); //没找到可分配的delivery throw fe; } } else { ret.DN = assignDelivery.DeliveryNo; } } } return ret; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { Session sessionDelete = SessionManager.GetInstance.GetSession(keyStr, SessionType); ; if (sessionDelete != null) { SessionManager.GetInstance.RemoveSession(sessionDelete); } logger.Debug("(_CombineCOAandDN)GetProduct end, customerSN:" + customerSN); } }
/// <summary> /// 获取Product表相关信息 /// </summary> /// <param name="line">line</param> /// <param name="editor">editor</param> /// <param name="station">station</param> /// <param name="customer">customer</param> /// <param name="customerSN">customer SN</param> public S_RowData_Product GetProduct(string line, string editor, string station, string customer,string customerSN) { logger.Debug("(_CombineCOAandDN)GetProduct start.customerSN:" + customerSN); string keyStr = ""; try { var currentProduct = CommonImpl.GetProductByInput(customerSN, CommonImpl.InputTypeEnum.CustSN); if (null == currentProduct) { List<string> errpara = new List<string>(); errpara.Add(customerSN); throw new FisException("SFC002", errpara); } if (!string.IsNullOrEmpty(currentProduct.CartonSN)) { string temp = "CartonSN:" + currentProduct.CartonSN.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } if (!string.IsNullOrEmpty(currentProduct.DeliveryNo)) { string temp = "DeliveryNo:" + currentProduct.DeliveryNo.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } if (!string.IsNullOrEmpty(currentProduct.PalletNo)) { string temp = "PalletNo:" + currentProduct.PalletNo.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } if (!string.IsNullOrEmpty(currentProduct.PizzaID)) { string temp = "PizzaID:" + currentProduct.PizzaID.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } if ( currentProduct.CartonWeight == (decimal)0.00) { } else { string temp = "CartonWeight:" + currentProduct.CartonWeight.ToString(); List<string> errpara = new List<string>(); errpara.Add(temp); throw new FisException("CHK858", errpara); } } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } try { string sessionKey = customerSN; keyStr = sessionKey; Session 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, "CombineCOAandDNBlock.xoml", "", out wfName, out rlName); WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments); currentSession.AddValue(Session.SessionKeys.CustSN, customerSN); currentSession.SetInstance(instance); if (!SessionManager.GetInstance.AddSession(currentSession)) { currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists."); } currentSession.WorkflowInstance.Start(); currentSession.SetHostWaitOne(); if (currentSession.Exception != null) { if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null) { currentSession.ResumeWorkFlow(); } throw currentSession.Exception; } string isBSaM = currentSession.GetValue(ExtendSession.SessionKeys.IsBSamModel) as string; S_RowData_Product ret = new S_RowData_Product(); ret.DN = ""; ret.Model = ""; ret.isBSaM = ""; ret.ProductID = ""; ret.isBT = "false"; ret.isCDSI = ""; ret.isFactoryPo = ""; ret.isWin8 = ""; IProduct temp = productRepository.GetProductByCustomSn(customerSN); if (null != temp) { ret.ProductID = temp.ProId; ret.isBT = temp.IsBT.ToString(); ret.Model = temp.Model; IList<IMES.FisObject.Common.Model.ModelInfo> isPO = modelRep.GetModelInfoByModelAndName(temp.Model, "PO"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpPO in isPO) { if (tmpPO.Value == "Y") { ret.isCDSI = "true"; } else { IList<IMES.FisObject.Common.Model.ModelInfo> isATSNAV = modelRep.GetModelInfoByModelAndName(temp.Model, "ATSNAV"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpATSNAV in isATSNAV) { if (tmpATSNAV.Value == null) { } else if (tmpATSNAV.Value != "") { ret.isCDSI = "true"; } break; } } break; } if (ret.isCDSI == "true") { CdsiastInfo condition = new CdsiastInfo(); condition.snoId = temp.ProId; condition.tp = "FactoryPO"; IList<CdsiastInfo> isCdsiastInfo = productRepository.GetCdsiastInfoList(condition); ret.isFactoryPo = ""; foreach (CdsiastInfo tmpCdsiastInfo in isCdsiastInfo) { ret.isFactoryPo = tmpCdsiastInfo.sno; break; } if (ret.isBT == "true" || ret.isBT == "True") { } else { if (ret.isFactoryPo == "" || ret.isFactoryPo == null) { throw new FisException("CHK882", new string[] { }); } } } //Vincent 2015-02-26 Mo 綁訂PoNo else if (temp.IsBindedPo) { ret.isCDSI = "true"; ret.isFactoryPo = temp.BindPoNo; } //Marked by Benson at 20130517 For CQ Mantis 24 // IList<MoBOMInfo> win8list = bomRepository.GetPnListByModelAndBomNodeTypeAndDescr(temp.Model, "P1", "ECOA"); // if (win8list != null && win8list.Count > 0) //Marked by Benson at 20130517 For CQ Mantis 24 bool bWIN8 = false; CommonImpl2 cm2 = new CommonImpl2(); IHierarchicalBOM bom = bomRepository.GetHierarchicalBOMByModel(temp.Model); bWIN8=cm2.CheckIsWIN8(bom); if(bWIN8) { // mantis 1574 IList<string> valueList = ipartRepository.GetValueFromSysSettingByName("Site"); if (valueList.Count == 0) { throw new Exception("Error:尚未設定Site..."); } string errMsg = ""; IList<string> typeList = new List<string>(); typeList.Add("P/N"); typeList.Add("Key"); if (valueList[0] == "ICC") { typeList.Add("COA"); } else { typeList.Add("Hash"); } IList<IMES.FisObject.FA.Product.ProductInfo> infoList = productRepository.GetProductInfoList(temp.ProId, typeList); if (infoList != null) { StringBuilder infoTypes = new StringBuilder(); foreach (var v in infoList) { if ((null != v.InfoValue) && !string.IsNullOrEmpty(v.InfoValue.Trim())) infoTypes.Append(v.InfoType).Append(","); } string win8Type = infoTypes.ToString(); foreach (string s in typeList) { if (!(win8Type.Contains(s))) errMsg += s+ "缺少 "; } } else { foreach (string s in typeList) errMsg += s + "缺少 "; } if (!string.IsNullOrEmpty(errMsg)) { throw new FisException("CHK969", new string[] { errMsg }); } ret.isWin8 = "true"; } if (!"Y".Equals(isBSaM)) { if (ret.isCDSI == "true") { DNQueryCondition conditionDN = new DNQueryCondition(); DateTime aTime = DateTime.Now; aTime = aTime.AddDays(-3); conditionDN.ShipDateFrom = new DateTime(aTime.Year, aTime.Month, aTime.Day, 0, 0, 0, 0); conditionDN.Model = ret.Model; if (conditionDN.Model != "") { IList<Srd4CoaAndDn> dnList = currentRepository.GetDNListByConditionForPerformanceWithSorting(conditionDN); foreach (Srd4CoaAndDn tmp in dnList) { if (ret.isFactoryPo != "") { if (ret.isFactoryPo != tmp.PoNo) { continue; } } ret.DN = tmp.DeliveryNO; break; } } } else { Delivery assignDelivery = null; int assignQty = 0; // modify for other model, ex: Jamestown in mantis 1945 //IList<Delivery> deliveryList = currentRepository.GetDeliveryListByModel(ret.Model,"PC",12,"00"); IList<Delivery> deliveryList = getDnByModel(ret.Model); //Vincent 2015-02-27 過濾綁訂PoDN IList<string> bindPoNoList = moRep.GetBindPoNoByModel(ret.Model); if (bindPoNoList != null && bindPoNoList.Count > 0) { deliveryList = deliveryList.Where(x => !bindPoNoList.Contains(x.PoNo)).ToList(); } if (deliveryList.Count == 0) { if (temp.IsBT) { } else { List<string> errpara = new List<string>(); errpara.Add(customerSN); throw new FisException("PAK101", errpara);//无此机型Delivery! } } //a) ShipDate 越早,越优先 //b) 散装优先于非散装 //c) 剩余未包装Product数量越少的越优先 bool assignNA = false; foreach (Delivery dvNode in deliveryList) { int curqty = productRepository.GetCombinedQtyByDN(dvNode.DeliveryNo); int tmpqty = dvNode.Qty - curqty; int curQty = productRepository.GetCombinedQtyByDN(dvNode.DeliveryNo); if (tmpqty > 0 ) { bool naflag = false; foreach (DeliveryPallet dpNode in dvNode.DnPalletList) { if (dpNode.PalletID.Substring(0, 2) == "NA") { naflag = true; break; } } if (assignDelivery == null) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; continue; } if (DateTime.Compare(assignDelivery.ShipDate, dvNode.ShipDate) < 0) { continue; } if (!assignNA && naflag) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; } else if (assignNA == naflag) { if (tmpqty < assignQty) { assignDelivery = dvNode; assignQty = tmpqty; assignNA = naflag; } } } } if (assignDelivery == null) { if (temp.IsBT) { } else { FisException fe = new FisException("PAK103", new string[] { }); //没找到可分配的delivery throw fe; } } else { ret.DN = assignDelivery.DeliveryNo; } } } else // isBSaM { //if (! ChkInDelivery(ret.Model)) //{ // List<string> errpara = new List<string>(); // errpara.Add(ret.Model); // throw new FisException("PAK174", errpara); //} if (ChkInCartonLoc(ret.ProductID)) { List<string> errpara = new List<string>(); errpara.Add(ret.ProductID); throw new FisException("PAK175", errpara); } ret.isBSaM = isBSaM; //Y } } return ret; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw e; } finally { Session sessionDelete = SessionManager.GetInstance.GetSession(keyStr, SessionType); ; if (sessionDelete != null) { SessionManager.GetInstance.RemoveSession(sessionDelete); } logger.Debug("(_CombineCOAandDN)GetProduct end, customerSN:" + customerSN); } }
/// <summary> /// 获取Product表相关信息 /// </summary> /// <param name="customerSN">customer SN</param> public S_RowData_Product GetProductOnly(string customerSN) { logger.Debug("(_CombineCOAandDN)GetProductOnly start.customerSN:" + customerSN); try { S_RowData_Product ret = new S_RowData_Product(); ret.DN = ""; ret.Model = ""; ret.ProductID = ""; ret.isBT = "false"; ret.isCDSI = ""; ret.isFactoryPo = ""; IProduct temp = productRepository.GetProductByCustomSn(customerSN); if (null != temp) { ret.ProductID = temp.ProId; ret.isBT = temp.IsBT.ToString(); ret.Model = temp.Model; IList<IMES.FisObject.Common.Model.ModelInfo> isPO = modelRep.GetModelInfoByModelAndName(temp.Model, "PO"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpPO in isPO) { if (tmpPO.Value == "Y") { ret.isCDSI = "true"; } else { IList<IMES.FisObject.Common.Model.ModelInfo> isATSNAV = modelRep.GetModelInfoByModelAndName(temp.Model, "ATSNAV"); foreach (IMES.FisObject.Common.Model.ModelInfo tmpATSNAV in isATSNAV) { if (tmpATSNAV.Value == null) { } else if (tmpATSNAV.Value != "") { ret.isCDSI = "true"; } break; } } break; } if (ret.isCDSI == "true") { CdsiastInfo condition = new CdsiastInfo(); condition.snoId = temp.ProId; condition.tp = "FactoryPO"; IList<CdsiastInfo> isCdsiastInfo = productRepository.GetCdsiastInfoList(condition); ret.isFactoryPo = ""; foreach (CdsiastInfo tmpCdsiastInfo in isCdsiastInfo) { ret.isFactoryPo = tmpCdsiastInfo.sno; break; } if (ret.isBT == "true" || ret.isBT == "True") { } else { if (ret.isFactoryPo == "" || ret.isFactoryPo == null) { throw new FisException("CHK882", new string[] { }); } } } } return ret; } 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("(_CombineCOAandDN)GetProductOnly end. customerSN:" + customerSN); } }
public void btnGetProduct_ServerClick(object sender, System.EventArgs e) { S_RowData_Product temp = new S_RowData_Product(); try { if (null == station) { station = ""; } temp = iCombineCOAandDN.GetProduct(HLine.Value, userId, station, customer, HSN.Value); } catch (FisException ee) { writeToAlertMessage(ee.mErrmsg); HFull.Value = "1"; ResetAll(); return; } catch (Exception ex) { writeToAlertMessage(ex.Message); HFull.Value = "1"; ResetAll(); return; } HBSAM.Value = ""; if (temp.isBSaM != "") { HBSAM.Value = temp.isBSaM; txtBSAMLoc.Text = "BSAM"; } bool checkRet = false; try { checkRet = CheckCOAForUI(); } catch (FisException ee) { writeToAlertMessage(ee.mErrmsg); ResetAll(); return; } catch (Exception ex) { writeToAlertMessage(ex.Message); ResetAll(); return; } if (null == temp.ProductID || "" == temp.ProductID || "statusnotfind" == temp.ProductID || "statuswrong" == temp.ProductID || temp.Model == null || temp.Model == "") { string productWrong = "Wrong customer S/N !"; if ("statuswrong" == temp.ProductID) { productWrong = this.GetLocalResourceObject(Pre + "_msgHold").ToString(); } if ("statusnotfind" == temp.ProductID) { productWrong = this.GetLocalResourceObject(Pre + "_msgHoldWrong").ToString(); } ReGetProductFail(productWrong); return; } if (null != temp.Model) { HTxtModel.Value = temp.Model; } if (null != temp.ProductID) { HTxtProductID.Value = temp.ProductID; } HFACTORYPO.Value = ""; HISWIN8.Value = ""; if (temp.isWin8 == "true") { HISWIN8.Value = "true"; } if (temp.isCDSI == "true") { HFACTORYPO.Value = temp.isFactoryPo; HTxtBT.Value = temp.isBT; //this.updatePanelAll.Update(); ReIsBT(); //ReIsCDSI(temp.isBT); return; } if (null != temp.isBT) { HTxtBT.Value = temp.isBT; //this.updatePanelAll.Update(); ReIsBT(); return; } if (temp.isBSaM != "") { ReIsBT(); } }