コード例 #1
0
        private void AssyToMrbBackFlush()
        {
            MRBGTList = new List <R_MRB_GT>();
            MRBTable  = new DataTable();

            sql      = $@" select * from r_mrb_gt where sap_flag = 0 and zcpp_flag = 1 and sap_station_code is not null ";
            MRBTable = SFCDB.RunSelect(sql).Tables[0];
            if (MRBTable != null && MRBTable.Rows.Count > 0)
            {
                foreach (DataRow row in MRBTable.Rows)
                {
                    rowR_MRBGT = (Row_R_MRB_GT)R_MRB_GT.NewRow();
                    rowR_MRBGT.loadData(row);
                    MRBGTList.Add(rowR_MRBGT.GetDataObject());
                }
            }

            postDate = Interface.GetPostDate(SFCDB);

            if (MRBGTList != null && MRBGTList.Count > 0)
            {
                foreach (R_MRB_GT r_mrb_gt in MRBGTList)
                {
                    rowR_MRBGT = null;
                    rowH_MRBGT = null;
                    logMessage = "";
                    zcpp_nsg_0091.SetValue("I_WERKS", "WDN1");
                    zcpp_nsg_0091.SetValue("I_MATNR", r_mrb_gt.SKUNO);
                    zcpp_nsg_0091.SetValue("I_LMNGA", r_mrb_gt.TOTAL_QTY.ToString());
                    zcpp_nsg_0091.SetValue("I_LGORT", r_mrb_gt.TO_STORAGE);
                    zcpp_nsg_0091.SetValue("I_AUFNR", r_mrb_gt.FROM_STORAGE);
                    zcpp_nsg_0091.SetValue("I_BUDAT", postDate);
                    rowR_MRBGT = (Row_R_MRB_GT)R_MRB_GT.GetObjByID(r_mrb_gt.ID, SFCDB);
                    try
                    {
                        zcpp_nsg_0091.CallRFC();
                        if (zcpp_nsg_0091.GetValue("O_MESSAGE").IndexOf("Material not exsit,pls check!") >= 0)
                        {
                            rowR_MRBGT.SAP_FLAG = "2";
                        }
                        else
                        {
                            rowR_MRBGT.SAP_FLAG = "1";
                        }
                    }
                    catch (Exception ex)
                    {
                        Interface.WriteIntoMESLog(SFCDB, BU, "MESInterface", "MESInterface.HWD.MrbBackFlush", "AssyToMrbBackFlush", r_mrb_gt.WORKORDERNO + ";" + this.IP + ";" + ex.ToString(), "", this.LoginUser.EMP_NO);
                        rowR_MRBGT.SAP_FLAG = "1";
                    }
                    SFCDB.ExecSQL(rowR_MRBGT.GetUpdateString(DB_TYPE_ENUM.Oracle));

                    logMessage                  = "M:" + zcpp_nsg_0091.GetValue("O_MESSAGE");
                    rowH_MRBGT                  = (Row_H_MRB_GT)H_MRB_GT.NewRow();
                    rowH_MRBGT.ID               = H_MRB_GT.GetNewID(BU, SFCDB);
                    rowH_MRBGT.WORKORDERNO      = r_mrb_gt.WORKORDERNO;
                    rowH_MRBGT.SAP_STATION_CODE = r_mrb_gt.SAP_STATION_CODE;
                    rowH_MRBGT.FROM_STORAGE     = r_mrb_gt.FROM_STORAGE;
                    rowH_MRBGT.TO_STORAGE       = r_mrb_gt.TO_STORAGE;
                    rowH_MRBGT.TOTAL_QTY        = r_mrb_gt.TOTAL_QTY;
                    rowH_MRBGT.CONFIRMED_FLAG   = r_mrb_gt.CONFIRMED_FLAG;
                    rowH_MRBGT.ZCPP_FLAG        = r_mrb_gt.ZCPP_FLAG;
                    rowH_MRBGT.SAP_FLAG         = r_mrb_gt.SAP_FLAG;
                    rowH_MRBGT.SKUNO            = r_mrb_gt.SKUNO;
                    rowH_MRBGT.SAP_MESSAGE      = logMessage;
                    rowH_MRBGT.EDIT_EMP         = this.LoginUser.EMP_NO;
                    rowH_MRBGT.EDIT_TIME        = Interface.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                    SFCDB.ExecSQL(rowH_MRBGT.GetInsertString(DB_TYPE_ENUM.Oracle));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// MRB 組裝退料拋賬
        /// </summary>
        /// <param name="requestValue"></param>
        /// <param name="Data"></param>
        /// <param name="StationReturn"></param>
        public void DoAssyToMrbBackFlush(JObject requestValue, JObject Data, MESStationReturn StationReturn)
        {
            try
            {
                SFCDB         = DBPools["SFCDB"].Borrow();
                R_MRB_GT      = new T_R_MRB_GT(SFCDB, DB_TYPE_ENUM.Oracle);
                H_MRB_GT      = new T_H_MRB_GT(SFCDB, DB_TYPE_ENUM.Oracle);
                synLock       = new T_R_SYNC_LOCK(SFCDB, DB_TYPE_ENUM.Oracle);
                zcpp_nsg_0091 = new ZCPP_NSBG_0091();
                MRBGTList     = new List <R_MRB_GT>();
                MRBTable      = new DataTable();

                if (Interface.IsMonthly(SFCDB, DB_TYPE_ENUM.Oracle))
                {
                    //月結不給拋賬
                    throw new Exception("This time is monthly,can't BackFlush");
                }

                IsRuning = synLock.IsLock("HWD_AssyToMrbBackFlush", SFCDB, DB_TYPE_ENUM.Oracle, out lockIp);
                if (IsRuning)
                {
                    throw new Exception("HWD AssyToMrbBackFlush interface is running on " + lockIp + ",Please try again later");
                }
                synLock.SYNC_Lock(BU, this.IP, "HWD_AssyToMrbBackFlush", "HWD_AssyToMrbBackFlush", this.LoginUser.EMP_NO, SFCDB, DB_TYPE_ENUM.Oracle);

                sql      = $@" select * from r_mrb_gt where sap_flag = 0 and zcpp_flag = 1 and sap_station_code is not null ";
                MRBTable = SFCDB.RunSelect(sql).Tables[0];
                if (MRBTable != null && MRBTable.Rows.Count > 0)
                {
                    foreach (DataRow row in MRBTable.Rows)
                    {
                        rowR_MRBGT = (Row_R_MRB_GT)R_MRB_GT.NewRow();
                        rowR_MRBGT.loadData(row);
                        MRBGTList.Add(rowR_MRBGT.GetDataObject());
                    }
                }
                postDate = Interface.GetPostDate(SFCDB);
                if (MRBGTList != null && MRBGTList.Count > 0)
                {
                    foreach (R_MRB_GT r_mrb_gt in MRBGTList)
                    {
                        rowR_MRBGT = null;
                        rowH_MRBGT = null;
                        logMessage = "";
                        zcpp_nsg_0091.SetValue("I_WERKS", "WDN1");
                        zcpp_nsg_0091.SetValue("I_MATNR", r_mrb_gt.SKUNO);
                        zcpp_nsg_0091.SetValue("I_LMNGA", r_mrb_gt.TOTAL_QTY.ToString());
                        zcpp_nsg_0091.SetValue("I_LGORT", r_mrb_gt.TO_STORAGE);
                        zcpp_nsg_0091.SetValue("I_AUFNR", r_mrb_gt.FROM_STORAGE);
                        zcpp_nsg_0091.SetValue("I_BUDAT", postDate);
                        rowR_MRBGT = (Row_R_MRB_GT)R_MRB_GT.GetObjByID(r_mrb_gt.ID, SFCDB);
                        try
                        {
                            zcpp_nsg_0091.CallRFC();
                            if (zcpp_nsg_0091.GetValue("O_MESSAGE").IndexOf("Material not exsit,pls check!") >= 0)
                            {
                                rowR_MRBGT.SAP_FLAG = "2";
                            }
                            else
                            {
                                rowR_MRBGT.SAP_FLAG = "1";
                            }
                        }
                        catch (Exception ex)
                        {
                            Interface.WriteIntoMESLog(SFCDB, BU, "MESStation", "MESStation.Interface.MrbBackFlush", "AssyToMrbBackFlush", r_mrb_gt.WORKORDERNO + ";" + this.IP + ";" + ex.ToString(), "", this.LoginUser.EMP_NO);
                            rowR_MRBGT.SAP_FLAG = "1";
                        }
                        SFCDB.ExecSQL(rowR_MRBGT.GetUpdateString(DB_TYPE_ENUM.Oracle));

                        logMessage                  = "M:" + zcpp_nsg_0091.GetValue("O_MESSAGE");
                        rowH_MRBGT                  = (Row_H_MRB_GT)H_MRB_GT.NewRow();
                        rowH_MRBGT.ID               = H_MRB_GT.GetNewID(BU, SFCDB);
                        rowH_MRBGT.WORKORDERNO      = r_mrb_gt.WORKORDERNO;
                        rowH_MRBGT.SAP_STATION_CODE = r_mrb_gt.SAP_STATION_CODE;
                        rowH_MRBGT.FROM_STORAGE     = r_mrb_gt.FROM_STORAGE;
                        rowH_MRBGT.TO_STORAGE       = r_mrb_gt.TO_STORAGE;
                        rowH_MRBGT.TOTAL_QTY        = r_mrb_gt.TOTAL_QTY;
                        rowH_MRBGT.CONFIRMED_FLAG   = r_mrb_gt.CONFIRMED_FLAG;
                        rowH_MRBGT.ZCPP_FLAG        = r_mrb_gt.ZCPP_FLAG;
                        rowH_MRBGT.SAP_FLAG         = r_mrb_gt.SAP_FLAG;
                        rowH_MRBGT.SKUNO            = r_mrb_gt.SKUNO;
                        rowH_MRBGT.SAP_MESSAGE      = logMessage;
                        rowH_MRBGT.EDIT_EMP         = this.LoginUser.EMP_NO;
                        rowH_MRBGT.EDIT_TIME        = Interface.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                        SFCDB.ExecSQL(rowH_MRBGT.GetInsertString(DB_TYPE_ENUM.Oracle));
                    }
                }
                synLock.SYNC_UnLock(BU, this.IP, "HWD_AssyToMrbBackFlush", "HWD_AssyToMrbBackFlush", this.LoginUser.EMP_NO, SFCDB, DB_TYPE_ENUM.Oracle);
                if (SFCDB != null)
                {
                    DBPools["SFCDB"].Return(SFCDB);
                }
                StationReturn.Status = StationReturnStatusValue.Pass;
            }
            catch (Exception exception)
            {
                StationReturn.Status = StationReturnStatusValue.Fail;
                throw exception;
            }
        }
コード例 #3
0
        private void WOToMRBBackFlush()
        {
            MRBGTList = new List <R_MRB_GT>();
            MRBTable  = new DataTable();

            sql = $@" update r_mrb_gt set sap_flag = '3' where (sap_flag = '2' or sap_flag = '0') and zcpp_flag = 0   and sap_station_code is not null  ";
            SFCDB.ExecSQL(sql);

            sql      = $@" select * from r_mrb_gt where sap_flag = 3 and zcpp_flag = 0  and sap_station_code is not null   ";
            MRBTable = SFCDB.RunSelect(sql).Tables[0];
            if (MRBTable != null && MRBTable.Rows.Count > 0)
            {
                foreach (DataRow row in MRBTable.Rows)
                {
                    rowR_MRBGT = (Row_R_MRB_GT)R_MRB_GT.NewRow();
                    rowR_MRBGT.loadData(row);
                    MRBGTList.Add(rowR_MRBGT.GetDataObject());
                }

                sql = " update r_mrb_gt set sap_flag = '4' where sap_flag = '3' and zcpp_flag = 0  and sap_station_code is not null   ";
                SFCDB.ExecSQL(sql);
            }

            postDate = InterfacePublicValues.GetPostDate(SFCDB);

            if (MRBGTList != null && MRBGTList.Count > 0)
            {
                foreach (R_MRB_GT r_mrb_gt in MRBGTList)
                {
                    rowR_MRBGT = null;
                    rowH_MRBGT = null;
                    logMessage = "";
                    zrfc_sfc_nsg_0020.SetValue("I_AUFNR", r_mrb_gt.WORKORDERNO);
                    zrfc_sfc_nsg_0020.SetValue("I_BUDAT", postDate);
                    zrfc_sfc_nsg_0020.SetValue("I_FLAG", r_mrb_gt.CONFIRMED_FLAG);
                    zrfc_sfc_nsg_0020.SetValue("I_LGORT_TO", r_mrb_gt.TO_STORAGE);
                    zrfc_sfc_nsg_0020.SetValue("I_LMNGA", r_mrb_gt.TOTAL_QTY.ToString());
                    zrfc_sfc_nsg_0020.SetValue("I_STATION", r_mrb_gt.SAP_STATION_CODE);
                    try
                    {
                        zrfc_sfc_nsg_0020.CallRFC();
                    }
                    catch (Exception ex)
                    {
                        //write log
                        WriteLog.WriteIntoMESLog(SFCDB, BU, "MESInterface", "MESInterface.HWD.MrbBackFlush", "WOToMRBBackFlush", r_mrb_gt.WORKORDERNO + ";" + ip + ";" + ex.ToString(), "", "interface");
                        continue;
                    }

                    if (zrfc_sfc_nsg_0020.GetValue("O_FLAG1") == "1")
                    {
                        rowR_MRBGT                = (Row_R_MRB_GT)R_MRB_GT.GetObjByID(r_mrb_gt.ID, SFCDB);
                        rowR_MRBGT.SAP_FLAG       = "2";
                        rowR_MRBGT.CONFIRMED_FLAG = "1";
                        try
                        {
                            SFCDB.ExecSQL(rowR_MRBGT.GetUpdateString(DB_TYPE_ENUM.Oracle));
                        }
                        catch (Exception ex)
                        {
                            WriteLog.WriteIntoMESLog(SFCDB, BU, "MESInterface", "MESInterface.HWD.MrbBackFlush", "WOToMRBBackFlush", r_mrb_gt.WORKORDERNO + ";" + ip + ";update r_mrb_gt fail," + ex.Message, "", "interface");
                        }
                    }

                    try
                    {
                        logMessage = " M:" + zrfc_sfc_nsg_0020.GetValue("O_MESSAGE")
                                     + " M1:" + zrfc_sfc_nsg_0020.GetValue("O_MESSAGE1")
                                     + " M2" + zrfc_sfc_nsg_0020.GetValue("O_MESSAGE2");
                        rowH_MRBGT                  = (Row_H_MRB_GT)H_MRB_GT.NewRow();
                        rowH_MRBGT.ID               = H_MRB_GT.GetNewID(BU, SFCDB);
                        rowH_MRBGT.WORKORDERNO      = r_mrb_gt.WORKORDERNO;
                        rowH_MRBGT.SAP_STATION_CODE = r_mrb_gt.SAP_STATION_CODE;
                        rowH_MRBGT.FROM_STORAGE     = r_mrb_gt.FROM_STORAGE;
                        rowH_MRBGT.TO_STORAGE       = r_mrb_gt.TO_STORAGE;
                        rowH_MRBGT.TOTAL_QTY        = r_mrb_gt.TOTAL_QTY;
                        rowH_MRBGT.CONFIRMED_FLAG   = r_mrb_gt.CONFIRMED_FLAG;
                        rowH_MRBGT.ZCPP_FLAG        = r_mrb_gt.ZCPP_FLAG;
                        rowH_MRBGT.SAP_FLAG         = r_mrb_gt.SAP_FLAG;
                        rowH_MRBGT.SKUNO            = r_mrb_gt.SKUNO;
                        rowH_MRBGT.SAP_MESSAGE      = logMessage;
                        rowH_MRBGT.EDIT_EMP         = "interface";
                        rowH_MRBGT.EDIT_TIME        = InterfacePublicValues.GetDBDateTime(SFCDB, DB_TYPE_ENUM.Oracle);
                        SFCDB.ExecSQL(rowH_MRBGT.GetInsertString(DB_TYPE_ENUM.Oracle));
                        //WriteLog.WriteIntoMESLog(SFCDB, BU, "MESInterface", "MESInterface.HWD.MrbBackFlush", "WOToMRBBackFlush" , r_mrb_gt.WORKORDERNO + ";" + ip + ";" + logMessage, "", "interface");
                    }
                    catch (Exception ex)
                    {
                        WriteLog.WriteIntoMESLog(SFCDB, BU, "MESInterface", "MESInterface.HWD.MrbBackFlush", "WOToMRBBackFlush", r_mrb_gt.WORKORDERNO + ";" + ip + ";inert into h_mrb_gt fail," + ex.Message, "", "interface");
                    }
                    SFCDB.CommitTrain();
                }
            }
        }