/// <summary> /// JOBSTOCK STATION PASS ACTION /// </summary> /// <param name="objWorkorder">wo obj</param> /// <param name="objSN">sn obj</param> /// <param name="Station">Station</param> /// <param name="confirmed_flag">confirmed_flag</param> public void JobStockPass(WorkOrder objWorkorder, SN objSN, MESPubLab.MESStation.MESStationBase Station, string confirmed_flag) { T_R_STOCK t_r_stock = new T_R_STOCK(Station.SFCDB, Station.DBType); T_R_SN t_r_sn = new T_R_SN(Station.SFCDB, Station.DBType); T_R_WO_BASE t_r_wo_base = new T_R_WO_BASE(Station.SFCDB, Station.DBType); T_R_STOCK_GT t_r_stock_gt = new T_R_STOCK_GT(Station.SFCDB, Station.DBType); T_C_SAP_STATION_MAP t_c_sap_station_map = new T_C_SAP_STATION_MAP(Station.SFCDB, Station.DBType); string gt_id = ""; #region write r_stock,r_stock_gt List <C_SAP_STATION_MAP> sapCodeList = t_c_sap_station_map.GetSAPStationMapBySkuOrderBySAPCodeASC(objWorkorder.SkuNO, Station.SFCDB); if (sapCodeList.Count == 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000224", new string[] { objWorkorder.SkuNO })); } Row_R_STOCK_GT rowStockGT; R_STOCK_GT objGT = t_r_stock_gt.GetNotGTbjByWO(objWorkorder.WorkorderNo, confirmed_flag, Station.SFCDB); if (objGT == null) { gt_id = t_r_stock_gt.GetNewID(Station.BU, Station.SFCDB); rowStockGT = (Row_R_STOCK_GT)t_r_stock_gt.NewRow(); rowStockGT.ID = gt_id; rowStockGT.WORKORDERNO = objWorkorder.WorkorderNo; rowStockGT.SKUNO = objWorkorder.SkuNO; rowStockGT.TOTAL_QTY = 1; rowStockGT.FROM_STORAGE = objWorkorder.WorkorderNo; rowStockGT.TO_STORAGE = objWorkorder.STOCK_LOCATION; rowStockGT.SAP_FLAG = "0"; rowStockGT.CONFIRMED_FLAG = confirmed_flag; rowStockGT.SAP_STATION_CODE = sapCodeList.Last().SAP_STATION_CODE; rowStockGT.EDIT_EMP = Station.LoginUser.EMP_NO; rowStockGT.EDIT_TIME = Station.GetDBDateTime(); Station.SFCDB.ExecSQL(rowStockGT.GetInsertString(Station.DBType)); } else { rowStockGT = (Row_R_STOCK_GT)t_r_stock_gt.GetObjByID(objGT.ID, Station.SFCDB); gt_id = rowStockGT.ID; rowStockGT.TOTAL_QTY = rowStockGT.TOTAL_QTY + 1; rowStockGT.EDIT_EMP = Station.LoginUser.EMP_NO; rowStockGT.EDIT_TIME = Station.GetDBDateTime(); Station.SFCDB.ExecSQL(rowStockGT.GetUpdateString(Station.DBType)); } Row_R_STOCK rowStock = (Row_R_STOCK)t_r_stock.NewRow(); rowStock.ID = t_r_stock.GetNewID(Station.BU, Station.SFCDB); rowStock.SN = objSN.SerialNo; rowStock.WORKORDERNO = objWorkorder.WorkorderNo; rowStock.SKUNO = objWorkorder.SkuNO; rowStock.NEXT_STATION = objSN.NextStation; rowStock.FROM_STORAGE = objWorkorder.WorkorderNo; rowStock.TO_STORAGE = objWorkorder.STOCK_LOCATION; rowStock.CONFIRMED_FLAG = confirmed_flag; rowStock.SAP_FLAG = "0"; rowStock.EDIT_EMP = Station.LoginUser.EMP_NO; rowStock.EDIT_TIME = Station.GetDBDateTime(); rowStock.GT_ID = gt_id; Station.SFCDB.ExecSQL(rowStock.GetInsertString(Station.DBType)); #endregion #region update status Row_R_SN rowSN = (Row_R_SN)t_r_sn.GetObjByID(objSN.ID, Station.SFCDB); rowSN.NEXT_STATION = "JOBFINISH"; rowSN.STOCK_STATUS = "1"; rowSN.COMPLETED_FLAG = "1"; rowSN.COMPLETED_TIME = Station.GetDBDateTime(); rowSN.STOCK_IN_TIME = Station.GetDBDateTime(); rowSN.EDIT_EMP = Station.LoginUser.EMP_NO; rowSN.EDIT_TIME = Station.GetDBDateTime(); Station.SFCDB.ExecSQL(rowSN.GetUpdateString(Station.DBType)); t_r_sn.RecordPassStationDetail(rowSN.SN, Station.Line, Station.StationName, Station.StationName, Station.BU, Station.SFCDB); t_r_wo_base.UpdateFinishQty(objWorkorder.WorkorderNo, 1, Station.SFCDB); #endregion }
public void UpdateSNKP(WorkOrder woObject, List <R_SN> snList, MESPubLab.MESStation.MESStationBase Station) { T_C_KP_LIST t_c_kp_list = new T_C_KP_LIST(Station.SFCDB, Station.DBType); T_C_KP_List_Item t_c_kp_list_item = new T_C_KP_List_Item(Station.SFCDB, Station.DBType); T_C_KP_List_Item_Detail t_c_kp_list_item_detail = new T_C_KP_List_Item_Detail(Station.SFCDB, Station.DBType); T_R_SN_KP t_r_sn_kp = new T_R_SN_KP(Station.SFCDB, Station.DBType); T_C_SKU_MPN t_c_sku_mpn = new T_C_SKU_MPN(Station.SFCDB, Station.DBType); T_C_KP_Rule c_kp_rule = new T_C_KP_Rule(Station.SFCDB, Station.DBType); Row_R_SN_KP rowSNKP; List <C_KP_List_Item> kpItemList = new List <C_KP_List_Item>(); List <C_SKU_MPN> skuMpnList = new List <C_SKU_MPN>(); List <C_KP_List_Item_Detail> itemDetailList = new List <C_KP_List_Item_Detail>(); C_KP_Rule kpRule = new C_KP_Rule(); int scanseq = 0; int result; string skuMpn = ""; try { kpItemList = t_c_kp_list_item.GetItemObjectByListId(woObject.KP_LIST_ID, Station.SFCDB); if (kpItemList == null || kpItemList.Count == 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { woObject.SkuNO })); } foreach (R_SN r_sn in snList) { //先刪除再添加 if (t_r_sn_kp.CheckLinkBySNID(r_sn.ID, Station.SFCDB)) { result = t_r_sn_kp.DeleteBySNID(r_sn.ID, Station.SFCDB); } foreach (C_KP_List_Item kpItem in kpItemList) { itemDetailList = t_c_kp_list_item_detail.GetItemDetailObjectByItemId(kpItem.ID, Station.SFCDB); if (itemDetailList == null || itemDetailList.Count == 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { woObject.SkuNO })); } skuMpnList = t_c_sku_mpn.GetMpnBySkuAndPartno(Station.SFCDB, woObject.SkuNO, kpItem.KP_PARTNO); if (skuMpnList.Count != 0) { skuMpn = skuMpnList[0].MPN; } foreach (C_KP_List_Item_Detail itemDetail in itemDetailList) { scanseq = scanseq + 1; kpRule = c_kp_rule.GetKPRule(Station.SFCDB, kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE); if (kpRule == null) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000256", new string[] { kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE })); } if (kpRule.REGEX == "") { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000256", new string[] { kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE })); } rowSNKP = (Row_R_SN_KP)t_r_sn_kp.NewRow(); rowSNKP.ID = t_r_sn_kp.GetNewID(Station.BU, Station.SFCDB); rowSNKP.R_SN_ID = r_sn.ID; rowSNKP.SN = r_sn.SN; rowSNKP.VALUE = ""; rowSNKP.PARTNO = kpItem.KP_PARTNO; rowSNKP.KP_NAME = kpItem.KP_NAME; rowSNKP.MPN = skuMpn; rowSNKP.SCANTYPE = itemDetail.SCANTYPE; rowSNKP.ITEMSEQ = kpItem.SEQ; rowSNKP.SCANSEQ = scanseq; rowSNKP.DETAILSEQ = itemDetail.SEQ; rowSNKP.STATION = kpItem.STATION; rowSNKP.REGEX = kpRule.REGEX; rowSNKP.VALID_FLAG = 1; rowSNKP.EXKEY1 = ""; rowSNKP.EXVALUE1 = ""; rowSNKP.EXKEY2 = ""; rowSNKP.EXVALUE2 = ""; rowSNKP.EDIT_EMP = Station.LoginUser.EMP_NO; rowSNKP.EDIT_TIME = Station.GetDBDateTime(); result = Convert.ToInt32(Station.SFCDB.ExecSQL(rowSNKP.GetInsertString(Station.DBType))); if (result <= 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000083", new string[] { "R_SN_KP:" + r_sn.SN, "ADD" })); } } } } } catch (Exception ex) { throw ex; } }