/// <summary> /// 依照檢驗計畫取得該物件的datatable /// </summary> /// <param name="QCTypeData"></param> /// <param name="objectName"></param> /// <returns></returns> public static DataTable GetInspectionData(QCTypeInfo QCTypeData, string objectName) { string sql = ""; DataTable dtQCTarget = null; #region 依照檢驗計畫取得該物件的datatable switch (QCTypeData.QCTarget) { case "MES_WIP_LOT": { LotInfo lot = LotInfo.GetLotByLot(objectName); if (lot == null) { throw new Exception(TextMessage.Error.T00378(objectName)); } dtQCTarget = lot.CopyDataToTable(lot.ID); } break; case "MES_WIP_COMP": { //取得component資訊以及所在的工作站 sql = @"SELECT L.OPERATION,C.* FROM MES_WIP_COMP C INNER JOIN MES_WIP_LOT L ON C.CURRENTLOT = L.LOT WHERE COMPONENTID = #[STRING]"; ComponentInfo comp = InfoCenter.GetBySQL <ComponentInfo>(sql, objectName); if (comp == null) { throw new Exception(TextMessage.Error.T00154(objectName)); } dtQCTarget = comp.CopyDataToTable(comp.ID); } break; case "MES_CMS_CAR": { CarrierInfo carrier = CarrierInfo.GetCarrierByCarrierNo(objectName); if (carrier == null) { throw new RuleCimesException(TextMessage.Error.T00725(objectName)); } dtQCTarget = carrier.CopyDataToTable(carrier.ID); } break; case "MES_TOOL_MAST": { ToolInfo tool = ToolInfo.GetToolByName(objectName); if (tool == null) { throw new Exception(TextMessage.Error.T00592(objectName)); } dtQCTarget = tool.CopyDataToTable(tool.ID); } break; case "MES_MMS_MLOT": { MaterialLotInfo mlot = MaterialLotInfo.GetMaterialLotByMaterialLot(objectName); if (mlot == null) { throw new Exception(TextMessage.Error.T00512(objectName)); } dtQCTarget = mlot.CopyDataToTable(mlot.ID); } break; case "MES_EQP_EQP": { EquipmentInfo equipment = EquipmentInfo.GetEquipmentByName(objectName); if (equipment == null) { throw new Exception(TextMessage.Error.T00885(objectName)); } dtQCTarget = equipment.CopyDataToTable(equipment.ID); } break; default: { sql = string.Format("SELECT * FROM {0} WHERE {1} = #[STRING]", QCTypeData.QCTarget, QCTypeData.IdentityColumn); dtQCTarget = DBCenter.GetDataTable(sql, objectName); if (dtQCTarget == null || dtQCTarget.Rows.Count == 0) { throw new Exception(TextMessage.Error.T00030("InspectionTarget", objectName)); } } break; } #endregion return(dtQCTarget); }
/// <summary> /// 確認預約工作站是否有開啟物料檢查功能 /// </summary> private void CheckBom(string opeartoinName, EquipmentInfo equipData, LotInfo lotData) { //確認工作站是否有開啟物料檢查功能,如果機台資料為NULL,則直接跳過這個檢查機制 var operationData = OperationInfo.GetOperationByName(opeartoinName).ChangeTo <OperationInfoEx>(); if (operationData.CheckBOM == "Y" && equipData != null) { #region 先比對BOM表的料是否都有上機 //取得客製表[CST_WPC_BOM]工單對應華司料(SORTF = 2)的資料 var WOBomList = CSTWPCWorkOrderBOMInfo.GetDataByWorkOrderAndSORTF(_LotData.WorkOrder, "2"); //取得目前選定的機台上所有的物料資料 var eqpMLotList = EquipmentMaterialLotInfo.GetEquipmentMaterialLotByEquipment(equipData.EquipmentName); //確認目前選定的機台是否已經有上物料 WOBomList.ForEach(WOBom => { bool isFind = false; foreach (var eqpMLot in eqpMLotList) { //取得料編號資料 var materialLotData = MaterialLotInfo.GetMaterialLotByMaterialLot(eqpMLot.MaterialLot); if (WOBom.MATNR == materialLotData.MaterialNO) { //註記有找到對應的物料編號 isFind = true; break; } } if (isFind == false) { //機台:{0} 沒有上物料編號{1}的資料! throw new Exception(RuleMessage.Error.C10145(equipData.EquipmentName, WOBom.MATNR)); } }); #endregion #region 依照料號的孔位設定,確認孔位都有華司資料 var deviceVersion = DeviceVersionInfo.GetLotCurrentDeviceVersion(lotData).ChangeTo <DeviceVersionInfoEx>(); if (deviceVersion.PushLocation.ToString().IsNullOrEmpty()) { //[00031]{0}:{1}的系統屬性:{2} 未設定,請洽IT人員! throw new CimesException(TextMessage.Error.T00031(GetUIResource("Device"), deviceVersion.DeviceName, "PUSH_LOCATION")); } var lstPushLocation = deviceVersion["PUSH_LOCATION"].ToString().Split(','); //先取得機台上的物料批資訊 List <MaterialLotInfo> eqpMaterialLotList = new List <MaterialLotInfo>(); eqpMLotList.ForEach(p => { var mLot = MaterialLotInfo.GetMaterialLotByMaterialLot(p.MaterialLot); eqpMaterialLotList.Add(mLot); }); for (int i = 0; i < lstPushLocation.Length; i++) { var mlotData = eqpMaterialLotList.Find(p => p.Location == lstPushLocation[i]); if (mlotData == null) { throw new CimesException(RuleMessage.Error.C00041(equipData.EquipmentName, lstPushLocation[i])); } } #endregion } }