コード例 #1
0
        /// <summary>
        /// 创建库存
        /// </summary>
        /// <param name="outString"></param>
        /// <returns></returns>
        public bool CreateStock(DBAccess_MySql db, string houseNumber, BarcodeInfo info, out string outString)
        {
            outString = "";
            string sql = string.Format(ConfigurationManager.AppSettings["SQL_CreateStock"].Replace('\n', ' '), houseNumber, info.ProductCode, info.BatchNo, info.UnitQty, info.VendorCode, info.PacketSeqNo, info.Barcode);
            var    rlt = db.ExecSql(sql, out outString);

            return(rlt == DBExeResult.Successed);
        }
コード例 #2
0
        /// <summary>
        /// 分配货位
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="outString"></param>
        /// <returns></returns>
        public bool AllocationLoc(DBAccess_MySql db, string barcode, out string Loc, out string outString)
        {
            Loc = "";
            BarcodeInfo bi = new BarcodeInfo(barcode);

            outString = "";
            //找到空格位最少的巷道
            //找到该巷道货位 按 层,列,排  升序排序的 的一个货位
            //预定货位-将状态设置为入库预定I
            //返货预定储位
            DataTable dt = GetAllocationLoc(db, out outString);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(false);
            }
            Loc = dt.Rows[0]["house_number"].ToString();
            string sql = ConfigurationManager.AppSettings["SQL_BookingLoc"].Replace('\n', ' ');

            sql = string.Format(sql, Loc);
            var rlt = db.ExecSql(sql, out outString);

            return(rlt == DBExeResult.Successed);
        }
コード例 #3
0
ファイル: PLCSystem_CON.cs プロジェクト: 13TT/TEST2
        /// <summary>
        /// 输送机PLC连接的处理逻辑
        /// </summary>
        /// <param name="Sender"></param>
        /// <param name="e"></param>
        private static void V_LoopWrite(object Sender, EArgOnHandle_Process e)
        {
            string plcID        = ((PLCProcesser)Sender).Name;
            string currentConNo = "";

            try
            {
                var ps  = Dic_SRM_PS.Where(item => item.Value.address.PLC == plcID).ToList();
                var spw = Dic_SRM_SPW.Where(item => item.Value.address.PLC == plcID).ToList();

                foreach (var p in ps)
                {
                    //p.Value.LoadFromPLC(e.PLCConn);
                }
                foreach (var s in spw)
                {
                    s.Value.LoadFromPLC(e.PLCConn);
                }

                var arry_sts = Dic_CON_STS.Where(item => item.Value.address.PLC == plcID).ToList();

                foreach (var kv in arry_sts)
                {
                    currentConNo = kv.Key;
                    kv.Value.LoadFromPLC(e.PLCConn);

                    #region 写日志
                    Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                                                   Enum_LogGrade.LogGrade_Nin,
                                                   Enum_LogMessageType.LogMsgType_Event,
                                                   "V_LoopWrite-ReadConnStatus",
                                                   string.Format("[{0}]-[{1}]", plcID, currentConNo),
                                                   ByteHelper.ToMessage(kv.Value.Tobytes(), CON_Status.cGroupLen));
                    #endregion
                }
                var arry_req = Dic_CON_Req.Where(item => item.Value.address.PLC == plcID).ToList();
                foreach (var kv in arry_req)
                {
                    currentConNo = kv.Key;
                    kv.Value.LoadFromPLC(e.PLCConn);
                    #region 写日志
                    Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                                                   Enum_LogGrade.LogGrade_Nin,
                                                   Enum_LogMessageType.LogMsgType_Event,
                                                   "V_LoopWrite-ReadRequest",
                                                   string.Format("[{0}]-[{1}]-{2}", plcID, currentConNo, kv.Value.s_ScanBarCode),
                                                   ByteHelper.ToMessage(kv.Value.Tobytes(), CON_Request.cGroupLen));
                    #endregion
                    #region
                    //if (kv.Value.s_OverRead == 1)
                    //{
                    //    string sql = string.Format(ConfigurationManager.AppSettings["Sql_CodeSel"].Replace('\n', ' '));
                    //    string outString = "";
                    //    var db = new DBAccess_MySql("MySql");
                    //    DBAccess_MySql dby = new DBAccess_MySql();
                    //    dby = db.ReturnSQL_String(sql, out outString);
                    //    string a = null;
                    //    while (dby.rec.Read())
                    //    {
                    //        a = dby.rec.GetString(0);
                    //    }
                    //    if (a != "")
                    //    {
                    //        string outBC = "";
                    //        if (!PLCSystem_CON.SIMPLCRequest.TryGetValue(currentConNo, out outBC))
                    //        {
                    //            kv.Value.s_ScanBarCode = a;// outBC;
                    //            kv.Value.s_OverRead = 0;
                    //            PLCSystem_CON.SIMPLCRequest.Remove(currentConNo);

                    //        }
                    //    }
                    //string sql3 = string.Format(ConfigurationManager.AppSettings["Sql_CodeDel"].Replace('\n', ' '));
                    //var rlt = db.ExecSql(sql, out outString);
                    //kv.Value.s_ScanBarCode = ff.txt_BarCode.Text; //"1121712-BN76:S1Q0893:24:011:S22333:";// outBC;
                    //kv.Value.s_OverRead = 0;
                    //PLCSystem_CON.SIMPLCRequest.Remove(currentConNo);
                    ////ff.txt_BarCode.Text = "";
                    //}
                    #endregion
                    if (kv.Value.s_OverRead == 1)
                    {
                        string outBC = "";
                        if (PLCSystem_CON.SIMPLCRequest.TryGetValue("102", out outBC))//(currentConNo, out outBC))
                        {
                            kv.Value.s_ScanBarCode = outBC;
                            kv.Value.s_OverRead    = 0;
                            PLCSystem_CON.SIMPLCRequest.Remove("102");
                        }
                        if (PLCSystem_CON.SIMPLCRequest.TryGetValue(currentConNo, out outBC))
                        {
                            kv.Value.s_ScanBarCode = outBC;
                            kv.Value.s_OverRead    = 1;
                            PLCSystem_CON.SIMPLCRequest.Remove(currentConNo);
                        }
                    }
                    if (kv.Value.s_OverRead == 0)
                    {
                        string outString = "";
                        //插入输入库,分配货位,分配目的地
                        //应答消息
                        CON_Response cr = null;
                        Dic_CON_Res.TryGetValue(kv.Key, out cr);
                        if (cr == null)
                        {
                            continue;
                        }
                        cr.s_TUID    = kv.Value.s_ScanBarCode;
                        cr.s_TaskID  = kv.Value.s_TaskID;
                        cr.s_FromLoc = kv.Value.s_RequestLoc;

                        BarcodeInfo bi = new BarcodeInfo(cr.s_TUID);

                        #region
                        //Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                        //    Enum_LogGrade.LogGrade_Nin,
                        //    Enum_LogMessageType.LogMsgType_Event,
                        //    "V_LoopWrite-WriteResponse",
                        //    "条码分解",
                        //    bi.ToString());
                        #endregion

                        CurentBarcode = bi.ToString();
                        if (kv.Value.StnType == eStationType.SP)
                        {
                            //匹配路线更新目的地,(紧测试用,将来会用WMBusiness里业务类代替)
                            string toLoc = "0";
                            //Dic_setPath.TryGetValue(cr.s_FromLoc.ToString(), out toLoc);

                            WMBusiness wmsbus = new WMBusiness();
                            var        b      = wmsbus.RequestInStock(cr.s_TUID, cr.s_FromLoc.ToString(), out toLoc, out outString);
                            if (b)
                            {
                                byte tb_toLoc = 0;
                                if (!byte.TryParse(toLoc, out tb_toLoc))
                                {
                                    continue;
                                }
                                cr.s_ToLoc = tb_toLoc;
                                //将应答任务目的地写入PLC
                                cr.WirteToPLC(e.PLCConn);
                                #region
                                Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                                                               Enum_LogGrade.LogGrade_Nin,
                                                               Enum_LogMessageType.LogMsgType_Event,
                                                               "V_LoopWrite-WriteResponse",
                                                               string.Format("PLC:[{0}]-CON:[{1}]-TUID:[{2}]-FROMLOC:[{3}]-TOLOC:{4}-Resoponse:", plcID, currentConNo, cr.s_TUID, cr.s_FromLoc.ToString(), cr.s_ToLoc),
                                                               ByteHelper.ToMessage(cr.Tobytes(), CON_Response.cGroupLen));
                                #endregion
                            }
                            else
                            {
                                Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Error,
                                                               Enum_LogGrade.LogGrade_Nin,
                                                               Enum_LogMessageType.LogMsgType_Event,
                                                               "V_LoopWrite-WriteResponse", "入库请求失败.", outString);
                            }
                        }
                        else if (kv.Value.StnType == eStationType.AP)
                        {
                            string toLoc = "0";
                            Dic_setPath.TryGetValue(kv.Value.s_RequestLoc.ToString(), out toLoc);
                            cr.s_ToLoc = byte.Parse(toLoc);
                            //将应答任务目的地写入PLC
                            cr.WirteToPLC(e.PLCConn);
                        }
                        else
                        {
                            //异常处理20181206
                        }
                        //更新请求任务WCS已写入状态
                        var r = kv.Value.SetOverRead(e.PLCConn);
                        Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Debug,
                                                       Enum_LogGrade.LogGrade_Nin,
                                                       Enum_LogMessageType.LogMsgType_Event,
                                                       "V_LoopWrite-UpdateRequestStats",
                                                       string.Format("PLC:[{0}]-CON:[{1}]-TUID:[{2}]-FROMLOC:[{3}]-WriteStatus:[{4}]", plcID, currentConNo, cr.s_FromLoc.ToString(), cr.s_TUID, r.ToString()), "");
                    }
                }
                e.result = true;
            }
            catch (Exception ex)
            {
                Program.Log_Agent_CON.WriteLog(Enum_LogType.LogType_Error,
                                               Enum_LogGrade.LogGrade_Nin,
                                               Enum_LogMessageType.LogMsgType_Exception,
                                               string.Format("V_LoopWrite-[{0}]-[{1}]", plcID, currentConNo),
                                               ex.Message,
                                               ex.StackTrace);
                e.result = false;
            }
        }
コード例 #4
0
        public bool CreateStock(string houseNumber, BarcodeInfo info, out string outString)
        {
            var db = new DBAccess_MySql("MySql");

            return(CreateStock(db, houseNumber, info, out outString));
        }
コード例 #5
0
        /// <summary>
        ///入库申请
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="RequestLoc"></param>
        /// <param name="fromStn"></param>
        /// <param name="outString"></param>
        /// <returns></returns>
        public bool RequestInStock(string barcode, string RequestLoc, out string fromStn, out string outString)
        {
            string newHouseNumber = "";
            string Line           = "";
            bool   r = false;

            fromStn   = "";
            outString = "";
            //1判断是否重复申请
            //2.创建库存
            //3.分配货位
            //4.获取巷到对应EP点
            //5.创建入库执行
            var db = new DBAccess_MySql("MySql");

            try
            {
                db.StartTran();
                r = IsRepeatPallet(barcode, out outString);
                if (r)
                {
                    throw new ApplicationException(string.Format("[{0}]重复的入库申请!{1}", barcode, outString));
                }
                r = AllocationLoc(db, barcode, out newHouseNumber, out outString);
                if (!r)
                {
                    throw new ApplicationException(string.Format("[{0}]分配货位失败!{1}", barcode, outString));
                }
                BarcodeInfo bi = new BarcodeInfo(barcode);
                r = CreateStock(db, newHouseNumber, bi, out outString);
                if (!r)
                {
                    throw new ApplicationException(string.Format("[{0}]创建库存失败{!1}", barcode, outString));
                }
                Line    = PLCSystem_SRM.GetLineByhouseNumber(newHouseNumber).ToString();
                fromStn = PLCSystem_SRM.SysSRMMaping.GetConNodeID(Line, PLCSystem_SRM.InStnNo, eStationType.EP);
                if (Line == "" || fromStn == "")
                {
                    throw new ApplicationException(string.Format("[{0}]获取匹配巷道及入库站点失败!{1}", barcode, outString));
                }
                r = CreateOrderInfo_In(db, barcode, PLCSystem_SRM.InStnNo, newHouseNumber, Line, out outString);
                if (!r)
                {
                    throw new ApplicationException(string.Format("[{0}]创建入库指令失败!{1}", barcode, outString));
                }
                db.CommitTran();
            }
            catch (Exception ex)
            {
                outString = ex.Message;
                Program.Log_Agent_BUS.WriteLog(Enum_LogType.LogType_Error,
                                               Enum_LogGrade.LogGrade_Nin,
                                               Enum_LogMessageType.LogMsgType_Exception,
                                               "RequestInStocke",
                                               ex.Message,
                                               ex.StackTrace);
                r = false;
                db.RollBack();
            }
            return(r);
        }