/// <summary>
        /// 命令执行函数
        /// </summary>
        /// <param name="Command">命令</param>
        /// <returns>执行结果</returns>
        public override BasisCommandResult Execute(BasisEventCommand Command)
        {
            BasisCommandResult  result   = new BasisCommandResult();
            LDMachine           terminal = (LDMachine)Command.Session;
            LaidianCommandModel cmd      = (LaidianCommandModel)Command.Content;

            if (cmd.MessageType == MessageType.HEARTBEAT)
            {
                /*----------------------
                 * 1、更新时间
                 * -----------------------*/
                terminal.ComLinkLastTime = DateTime.Now;
            }
            else
            {
                if (next == null)
                {
                    // log.Info("用户" + client.ApplicationID + "执行的ID为" + Command.EventCommandID + "的指令没有对应执行器.");
                    result.ResultType = BasisCommandResult.CommandResultTypeEnum.NoRespnoseExecutor;
                    result.Content    = null;
                    return(result);
                }
                else
                {
                    return(this.next.Execute(Command));
                }
            }
            return(result);
        }
        /// <summary>
        /// 命令执行函数
        /// </summary>
        /// <param name="Command">命令</param>
        /// <returns>执行结果</returns>
        public override BasisCommandResult Execute(BasisEventCommand Command)
        {
            BasisCommandResult result = new BasisCommandResult();

            LDMachine terminal = (LDMachine)Command.Session;


            LaidianCommandModel cmd = (LaidianCommandModel)Command.Content;

            if (cmd.MessageType == MessageType.LAIDIAN_BUYLINE_REQ)
            {
                //cmd.Result = 0;
                int lineType = 0;

                /*----------------------
                 * 1、发送售线指令
                 * -----------------------*/
                //DN.cdport.SaleLine();
            }
            else
            {
                if (next == null)
                {
                    result.ResultType = BasisCommandResult.CommandResultTypeEnum.NoRespnoseExecutor;
                    result.Content    = null;
                    return(result);
                }
                else
                {
                    return(this.next.Execute(Command));
                }
            }
            return(result);
        }
示例#3
0
 public override BasisCommandResult Execute(BasisEventCommand Command)
 {
     if (next == null)
     {
         BasisCommandResult result = new BasisCommandResult();
         result.ResultType = BasisCommandResult.CommandResultTypeEnum.NoRespnoseExecutor;
         result.Content    = null;
         return(result);
     }
     else
     {
         return(next.Execute(Command));
     }
 }
示例#4
0
        /// <summary>
        /// 命令执行函数
        /// </summary>
        /// <param name="Command">命令</param>
        /// <returns>执行结果</returns>
        public override BasisCommandResult Execute(BasisEventCommand Command)
        {
            BasisCommandResult result = new BasisCommandResult();
            //  Command.Session;
            LDMachine terminal = (LDMachine)Command.Session;

            byte[] data    = (byte[])Command.Content;
            string strcmds = COM_Cmd.byteToString(data);

            if (data[3] == 0x51)//查询仓道
            {
                string strStation = "";
                try
                {
                    strStation = ((int)data[1]).ToString("D2");
                }
                catch
                {
                }

                /*----------------------
                 * 1、更新仓道
                 * -----------------------*/
                //udplog.logs.Enqueue(DateTime.Now.ToString() + "回复" + strcmds);
                string cdbno = "";// s.Substring(14, 10);


                int alertflag = (int)data[15];
                int errocode  = data[16];//
                int alertcnt  = 0;
                //int.TryParse(((int)data[15]).ToString() + ((int)data[16]).ToString(), out alertcnt);//充电宝使用次数
                alertcnt = Convert.ToInt32(data[17].ToString("X2") + data[18].ToString("X2"), 16);
                int usecnt = 0;        //
                int cdtmp  = data[22]; //仓道温度
                if (data[21] == 1)
                {
                    cdtmp = -1 * cdtmp;
                }

                //int.TryParse(((int)data[23]).ToString() + ((int)data[24]).ToString(),out usecnt);//充电宝使用次数
                usecnt = Convert.ToInt32(data[23].ToString("X2") + data[24].ToString("X2"), 16);
                //int.TryParse(((char)data[12]).ToString() + ((char)data[13]).ToString(),out errocode);//机器错误码
                double temp = 0;
                double.TryParse(((int)data[25]).ToString() + ((int)data[26]).ToString(), out temp);

                double idl = 0;
                double.TryParse(((int)data[27]).ToString() + ((int)data[28]).ToString(), out idl);

                double Adl = 0;
                double.TryParse(Convert.ToInt32((data[29].ToString("X2") + data[30].ToString("X2")), 16).ToString(), out Adl);

                int MachineStatus = data[31];//机器码


                CUWUGUI cuwugui = (CUWUGUI)terminal.Cuwuguis[strStation];//更新储物柜
                cuwugui.TestCnt   = 0;
                cuwugui.CommTime  = DateTime.Now;
                cuwugui.Adl       = Adl;
                cuwugui.AlartCnt  = alertcnt;
                cuwugui.UseCnt    = usecnt;
                cuwugui.alertflag = alertflag;
                cuwugui.errorflag = errocode;
                int    V12  = data[19];
                int    V5   = data[20];
                double DV12 = Math.Round(V12 * 11.5 / 15, 2);
                double DV5  = Math.Round((double)(V5 * 2 / 10), 2);

                cuwugui.V12  = DV12;
                cuwugui.V5   = DV5;
                cuwugui.Temp = cdtmp.ToString();
                if (errocode > 0)
                {
                    try
                    {
                        if (cuwugui.isReset == false && cuwugui.ResetCnt < 5 && cuwugui.ResetTime < DateTime.Now.AddMinutes(-2))
                        {
                            LoseCD lcd = new LoseCD();
                            lcd.ldate = DateTime.Now;
                            lcd.cdn   = byte.Parse(strStation);
                            terminal.NeedSendReBoot.Enqueue(lcd);
                            cuwugui.ResetCnt++;
                            cuwugui.isReset = true;
                        }
                    }
                    catch
                    { }
                }
                //if (data[data.Length - 3].ToString("D2") == "01")
                //{
                //    cuwugui.CWGStatus = CUWUGUISTATUS.SetingPower;

                //}
                //else
                //{
                //    cuwugui.CWGStatus = CUWUGUISTATUS.Error;
                //}
                if (data[4] == 2 || data[4] == 0x82)//2—充电宝好
                {
                    // cuwugui.fHasCDB = true;
                    //if (cuwugui.LastLostTime<DateTime.Now.AddMinutes(-1))
                    cuwugui.HasLostCnt = 0;
                    if (data[4] == 0x82)
                    {
                        cuwugui.cdstatus = true;
                    }
                    else
                    {
                        cuwugui.cdstatus = false;
                    }
                    cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;
                    try
                    {
                        string StrNo    = data[7].ToString("X2") + data[6].ToString("X2") + data[5].ToString("X2");
                        string StrYear  = data[8].ToString("X2");
                        string StrMonth = data[9].ToString("X2");
                        string StrDay   = data[10].ToString("X2");
                        cdbno = "00000000" + StrDay + StrMonth + StrYear + StrNo;
                    }
                    catch
                    {
                    }
                    if (cdbno != "00000000000000000000")
                    {
                        if (errocode == 0)
                        {
                            if (data[data.Length - 3].ToString("D2") == "01")
                            {
                                if (data[4] == 0x82)
                                {
                                    cuwugui.CWGStatus = CUWUGUISTATUS.SetingPower;
                                }

                                else
                                {
                                    cuwugui.CWGStatus = CUWUGUISTATUS.FullPower;
                                }
                            }
                            else
                            {
                                cuwugui.CWGStatus = CUWUGUISTATUS.None;
                            }
                            if (cuwugui.ResetTime < DateTime.Now.AddMinutes(-6))
                            {
                                cuwugui.ResetCnt = 0;
                            }
                        }
                        else
                        {
                            cuwugui.CWGStatus = CUWUGUISTATUS.Error;
                        }
                        cuwugui.HasLostCnt   = 0;
                        cuwugui.LastLostTime = DateTime.Now;
                        Chongdianbao cdb = new Chongdianbao();
                        cdb.CDBNO     = cdbno;
                        cdb.PowerDeep = idl;
                        cdb.temp      = temp;
                        cdb.UseCnt    = usecnt;
                        cuwugui.CDB   = cdb;
                        //udplog.logs.Enqueue(DateTime.Now.ToString() + "电量" + idl.ToString());
                    }
                    else
                    {
                        cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;
                        if (data[data.Length - 3].ToString("D2") == "01")
                        {
                            cuwugui.CWGStatus = CUWUGUISTATUS.FullPower;
                        }
                        else
                        {
                            cuwugui.CWGStatus = CUWUGUISTATUS.None;
                        }
                        if (cuwugui.LastLostTime < DateTime.Now.AddMinutes(-1))
                        {
                            cuwugui.HasLostCnt = 0;
                        }

                        Chongdianbao cdb = new Chongdianbao();
                        cdb.CDBNO = cdbno;

                        cdb.PowerDeep = idl;
                        cdb.temp      = temp;
                        cdb.UseCnt    = usecnt;
                        cuwugui.CDB   = cdb;
                        if (errocode == 0)//如果errocode>0了  前面已经加入了一次重启 ,就不需要再在这里重启了
                        {
                            try
                            {
                                if (cuwugui.isReset == false && cuwugui.ResetCnt < 5 && cuwugui.ResetTime < DateTime.Now.AddMinutes(-2))
                                {
                                    LoseCD lcd = new LoseCD();
                                    lcd.ldate = DateTime.Now;
                                    lcd.cdn   = byte.Parse(strStation);
                                    terminal.NeedSendReBoot.Enqueue(lcd);
                                    cuwugui.ResetCnt++;
                                    cuwugui.isReset = true;
                                }
                            }
                            catch
                            {
                            }
                        }
                        terminal.udplog.logs.Enqueue(DateTime.Now.ToString() + "充电宝编号错误" + idl.ToString());
                    }
                }
                else
                {
                    cuwugui.cdstatus = false;
                }

                if (data[4] == 1 || data[4] == 0x81 || data[4] == 4)//1-表示检测坏
                {
                    cuwugui.fHasCDB       = true;
                    cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;



                    Chongdianbao cdb = new Chongdianbao();
                    try
                    {
                        string StrNo    = data[7].ToString("X2") + data[6].ToString("X2") + data[5].ToString("X2");
                        string StrYear  = data[8].ToString("X2");
                        string StrMonth = data[9].ToString("X2");
                        string StrDay   = data[10].ToString("X2");
                        cdbno = "00000000" + StrDay + StrMonth + StrYear + StrNo;
                    }
                    catch
                    {
                    }
                    //if(cdb.CDBNO =="")
                    cdb.CDBNO = cdbno;

                    cdb.PowerDeep = 0;
                    cdb.UseCnt    = usecnt;
                    cdb.temp      = 0;
                    cuwugui.CDB   = cdb;

                    cuwugui.CWGStatus = CUWUGUISTATUS.Error;
                }

                if (data[4] == 0 || data[4] == 0x80)//0—表示空
                {
                    cuwugui.fHasCDB       = false;
                    cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;

                    cuwugui.CWGStatus = CUWUGUISTATUS.None;
                    if (cuwugui.LastLostTime < DateTime.Now.AddMinutes(-1))//如果归还时间失败时间已经过去两分钟,则清空失败,重新开放仓口
                    {
                        cuwugui.HasLostCnt = 0;
                    }
                    cuwugui.CDB = null;
                    cuwugui.Cmd = null;
                    if (errocode == 0)
                    {
                        if (cuwugui.ResetTime < DateTime.Now.AddMinutes(-6))
                        {
                            cuwugui.ResetCnt = 0;
                        }
                    }
                }
                if (errocode != 0)
                {
                    cuwugui.CWGStatus = CUWUGUISTATUS.Error;
                }
                terminal.Cuwuguis[strStation] = cuwugui;//将储物柜保存回去
                EventUI nui = new EventUI();
                nui.UIType = UIUpdateType.StatusUpdate;
                nui.huodao = strStation;
                nui.Msg    = strcmds;
                //事件通知界面更新
                terminal.fireEvent(nui);
            }
            else
            {
                if (next == null)
                {
                    // log.Info("用户" + client.ApplicationID + "执行的ID为" + Command.EventCommandID + "的指令没有对应执行器.");
                    result.ResultType = BasisCommandResult.CommandResultTypeEnum.NoRespnoseExecutor;
                    result.Content    = null;
                    return(result);
                }
                else
                {
                    return(this.next.Execute(Command));
                }
            }
            return(result);
        }
        /// <summary>
        /// 命令执行函数
        /// </summary>
        /// <param name="Command">命令</param>
        /// <returns>执行结果</returns>
        public override BasisCommandResult Execute(BasisEventCommand Command)
        {
            BasisCommandResult result = new BasisCommandResult();

            LDMachine terminal = (LDMachine)Command.Session;


            byte[] data       = (byte[])Command.Content;
            string strcmds    = COM_Cmd.byteToString(data);
            string strStation = "";

            try
            {
                strStation = ((int)data[1]).ToString("D2");
            }
            catch
            {
            }
            byte btype = data[3];

            if (btype == 'H' && data[2] == 0x04)//归还来电宝回复
            {
                //udplog.logs.Enqueue(DateTime.Now.ToString() + "请求归还出仓,回复" + strcmds);

                terminal.HuanEvent.Set();

                CUWUGUI cuwugui = (CUWUGUI)terminal.Cuwuguis[strStation]; //更新储物柜
                cuwugui.JieLost = 0;
                terminal.Cuwuguis[strStation] = cuwugui;                  //将储物柜保存回去
                if (data[4] == 0x21)
                {
                    terminal.HuanEvent.Set(); //
                                              //StartEvent.Reset();
                    EventUI nui = new EventUI();
                    nui.UIType = UIUpdateType.PutInting;
                    nui.huodao = strStation;
                    nui.Msg    = "设备已经准备好,请放入充电宝……";
                    terminal.fireEvent(nui);
                    terminal.oneorder.status = true;
                    tools.insertLog(strStation + "号仓已经准备好,请放入充电宝" + " " + strcmds, Logtype.H);
                }
                else
                {
                    terminal.BCEvent.Set();//归还出仓失败即可跳转下一个
                    terminal.oneorder.status  = false;
                    terminal.oneorder.iTryCnt = 3;
                    cuwugui.LastLostTime      = DateTime.Now;//记录
                    cuwugui.HasLostCnt       += 1;
                    if (terminal.oneorder.iTryCnt == 3)
                    {
                        terminal.StartEvent.Set();
                        // CUWUGUI cuwugui = (CUWUGUI)Cuwuguis[strStation];//更新储物柜
                        cuwugui.JieLost               = 0;
                        cuwugui.LastLostTime          = DateTime.Now; //记录
                        cuwugui.HasLostCnt           += 1;
                        terminal.Cuwuguis[strStation] = cuwugui;      //将储物柜保存回去
                        EventUI nui = new EventUI();
                        nui.UIType = UIUpdateType.PutIntFalse;
                        nui.Msg    = "归还充电宝失败";
                        nui.Flag   = false;
                        nui.huodao = strStation;
                        terminal.fireEvent(nui);
                        terminal.oneorder.status = true;
                    }
                    tools.insertLog(strStation + "号仓未能打开仓门" + " " + strcmds, Logtype.H);
                }
            }
            else if (btype == 'i')
            {
                if (data[4] == 0x21)
                {
                    // StartEvent.Reset();
                    EventUI nui = new EventUI();
                    nui.UIType = UIUpdateType.PutInting_check;
                    nui.Msg    = "充电宝检测通过,请稍候";
                    terminal.fireEvent(nui);
                    terminal.oneorder.status = true;
                }
                tools.insertLog("正在检测充电宝" + " " + strcmds, Logtype.H);
            }
            if (btype == 'I')
            {
                //udplog.logs.Enqueue(DateTime.Now.ToString() + "回复,归还充电宝失败");


                if (data[4] == 0x20)
                {
                    if (terminal.onehuanaction.HasLostHuodao.Contains((int)data[1]))
                    {
                        terminal.onehuanaction.HasLostHuodao.Dequeue();
                    }
                }
                else
                {
                    terminal.BCEvent.Set();
                    terminal.oneorder.iTryCnt++;
                    CUWUGUI cuwugui = (CUWUGUI)terminal.Cuwuguis[strStation]; //更新储物柜
                    cuwugui.JieLost               = 0;
                    cuwugui.LastLostTime          = DateTime.Now;             //记录
                    cuwugui.HasLostCnt           += 1;
                    terminal.Cuwuguis[strStation] = cuwugui;                  //将储物柜保存回去
                                                                              //归还失败  则Lost次数加1
                                                                              //onehuanaction.ActionTime = DateTime.Now;
                                                                              //onehuanaction.CntPin();

                    //onehuanaction.HasLostHuodao.Enqueue(int.Parse(strStation));
                    EventUI nui = new EventUI();
                    nui.UIType = UIUpdateType.PutIntFalse;
                    nui.huodao = strStation;
                    nui.Msg    = "充电宝放反或者充电宝故障,请电话联系客服";
                    terminal.fireEvent(nui);
                }
                terminal.StartEvent.Set();
                if (data[4] == 0x20)
                {
                    tools.insertLog(strStation + "号仓归还超时没放入充电宝" + " " + strcmds, Logtype.H);
                }
                else
                {
                    tools.insertLog(strStation + "号仓归还时充电宝放反或者充电宝故障" + " " + strcmds, Logtype.H);
                }
            }
            else if (btype == 'J')
            {
                terminal.BCEvent.Set();

                //udplog.logs.Enqueue(DateTime.Now.ToString() + "回复" + strcmds);
                terminal.StartEvent.Set();
                //归还成功  则清除失败次数
                terminal.onehuanaction.ActionStartTime = DateTime.Now;
                terminal.onehuanaction.HasLostHuodao.Clear();
                terminal.onehuanaction.firstHuodao = -1;
                //更新充电宝柜
                string  cdbno   = "";// s.Substring(14, 10);
                double  temp    = double.Parse(((int)data[25]).ToString() + ((int)data[26]).ToString());
                double  idl     = double.Parse(((int)data[27]).ToString() + ((int)data[28]).ToString());
                int     usecnt  = 0;                                      // int.Parse(((char)data[19]).ToString() + ((char)data[20]).ToString());
                CUWUGUI cuwugui = (CUWUGUI)terminal.Cuwuguis[strStation]; //更新储物柜
                cuwugui.TestCnt   = 0;
                cuwugui.CommTime  = DateTime.Now;
                cuwugui.CWGStatus = CUWUGUISTATUS.SetingPower;


                if (data[4] == 2 || data[4] == 0x82)//2—充电宝好
                {
                    //清除掉
                    cuwugui.LastLostTime  = DateTime.Now;
                    cuwugui.HasLostCnt    = 0;//
                    cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;


                    string StrNo = data[7].ToString("X2") + data[6].ToString("X2") + data[5].ToString("X2");
                    //Convert.ToInt32(data[7].ToString("X2") + data[6].ToString("X2") + data[5].ToString("X2"), 16).ToString("D8");
                    string StrYear  = data[8].ToString("X2");
                    string StrMonth = data[9].ToString("X2");
                    string StrDay   = data[10].ToString("X2");

                    cdbno = "00000000" + StrDay + StrMonth + StrYear + StrNo;
                    //StrNo + StrYear + StrMonth + StrDay + "000000";
                    if (cdbno != "00000000000000000000")
                    {
                        tools.insertLog(strStation + "号仓归还时充电宝放成功" + cdbno + " " + strcmds, Logtype.H);
                        if (idl == 4)
                        {
                            cuwugui.CWGStatus = CUWUGUISTATUS.FullPower;
                        }
                        else
                        {
                            cuwugui.CWGStatus = CUWUGUISTATUS.SetingPower;
                        }
                        Chongdianbao cdb = new Chongdianbao();
                        cdb.CDBNO                = cdbno;
                        cdb.PowerDeep            = idl;
                        cdb.UseCnt               = usecnt;
                        cuwugui.CDB              = cdb;
                        cdb.temp                 = temp;
                        terminal.oneorder.status = true;
                    }
                    else
                    {
                        //如果读取充电宝的编号错误,插入重启指令
                        try
                        {
                            if (cuwugui.isReset == false && cuwugui.ResetCnt < 5 && cuwugui.ResetTime < DateTime.Now.AddMinutes(-2))
                            {
                                LoseCD lcd = new LoseCD();
                                lcd.ldate = DateTime.Now;
                                lcd.cdn   = byte.Parse(strStation);
                                cuwugui.ResetCnt++;
                                cuwugui.isReset = true;
                                terminal.NeedSendReBoot.Enqueue(lcd);
                            }
                        }
                        catch
                        { }
                        terminal.oneorder.iTryCnt++;//= true;
                        cuwugui.CWGStatus = CUWUGUISTATUS.Error;
                        tools.insertLog(strStation + "号仓归还充电宝编号错误" + " " + strcmds, Logtype.H);
                    }
                }
                if (data[4] == 1 || data[4] == 0x21)//1-表示检测坏
                {
                    terminal.oneorder.iTryCnt++;
                    cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;
                    cuwugui.CWGStatus     = CUWUGUISTATUS.SetingPower;

                    cuwugui.LastLostTime = DateTime.Now;
                    cuwugui.HasLostCnt  += 1;//
                    for (int i = 5; i < 25; i++)
                    {
                        cdbno += data[i].ToString("D2");
                    }
                    if (cdbno != "00000000000000000000")
                    {
                        if (idl == 4)
                        {
                            cuwugui.CWGStatus = CUWUGUISTATUS.FullPower;
                        }
                        else
                        {
                            cuwugui.CWGStatus = CUWUGUISTATUS.SetingPower;
                        }
                        Chongdianbao cdb = new Chongdianbao();
                        cdb.CDBNO     = cdbno;
                        cdb.PowerDeep = idl;
                        cdb.UseCnt    = usecnt;
                        cuwugui.CDB   = cdb;
                        cdb.temp      = temp;
                    }
                    else
                    {
                        cuwugui.CWGStatus = CUWUGUISTATUS.Error;
                    }
                }
                if (data[4] == 0)//0—表示空
                {
                    terminal.oneorder.iTryCnt++;
                    cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;

                    cuwugui.CWGStatus = CUWUGUISTATUS.None;
                    cuwugui.CDB       = null;
                    cuwugui.Cmd       = null;
                }

                terminal.Cuwuguis[strStation] = cuwugui;//将储物柜保存回去

                EventUI nui = new EventUI();
                nui.UIType = UIUpdateType.PutIntSuccess;
                nui.huodao = strStation;
                nui.Msg    = "充电宝归还成功";
                nui.Flag   = true;

                terminal.fireEvent(nui);
            }
            else
            {
                if (next == null)
                {
                    result.ResultType = BasisCommandResult.CommandResultTypeEnum.NoRespnoseExecutor;
                    result.Content    = null;
                    return(result);
                }
                else
                {
                    return(this.next.Execute(Command));
                }
            }
            return(result);
        }
        /// <summary>
        /// 命令执行函数
        /// </summary>
        /// <param name="Command">命令</param>
        /// <returns>执行结果</returns>
        public override BasisCommandResult Execute(BasisEventCommand Command)
        {
            BasisCommandResult result = new BasisCommandResult();

            //  Command.Session;
            LDMachine terminal = (LDMachine)Command.Session;

            byte[] data       = (byte[])Command.Content;
            byte   btype      = data[3];
            string strcmds    = COM_Cmd.byteToString(data);
            string strStation = "";

            try
            {
                strStation = ((int)data[1]).ToString("D2");
            }
            catch
            {
            }
            if (btype == 'D')//取来电宝后,设备回复发送指令后回复的第一个数据,字母'O'
            {
                //udplog.logs.Enqueue(DateTime.Now.ToString() + "回复" + strcmds);

                CUWUGUI cuwugui = (CUWUGUI)terminal.Cuwuguis[strStation];
                cuwugui.HasLostCnt = 0;
                if (data[4] == 0x21)
                {
                    //udplog.logs.Enqueue(DateTime.Now.ToString() + ":请求租借出仓D");
                    tools.insertLog(strStation + "号仓 准备租借出仓" + strcmds, Logtype.J);
                    terminal.JEvent.Set();
                    EventUI nui = new EventUI();
                    nui.UIType = UIUpdateType.ChuHuoING;
                    nui.huodao = strStation;
                    terminal.oneorder.nowstatus = UIUpdateType.ChuHuoING;
                    if (terminal.ServerWork != null)
                    {
                        nui.Msg = terminal.ServerWork.userNikeName + "," + terminal.ServerWork.userHeadPic;
                    }
                    //事件通知界面更新
                    terminal.fireEvent(nui);
                }
                else
                {
                    terminal.BCEvent.Set();
                    //udplog.logs.Enqueue(DateTime.Now.ToString() + ":请求租借出仓失败");
                    //tools.insertLog(strStation + "号仓 租借出仓失败" + strcmds, Logtype.J);
                    terminal.oneorder.status    = false;
                    terminal.oneorder.nowstatus = UIUpdateType.ChuHuoL;
                    terminal.oneorder.iTryCnt   = 3;
                    if (terminal.oneorder.iTryCnt == 3)
                    {
                        EventUI nui = new EventUI();
                        nui.huodao = strStation;
                        nui.UIType = UIUpdateType.ChuHuoL;
                        nui.Msg    = "出货失败";
                        nui.Flag   = false;
                        //CUWUGUI cuwugui = (CUWUGUI)Cuwuguis[strStation];//更新储物柜
                        cuwugui.JieLost++;
                        cuwugui.JieLostTime = DateTime.Now;
                        cuwugui.CommTime    = DateTime.Now;

                        cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;

                        //cuwugui.JieLost++;
                        //cuwugui.LastLostTime = DateTime.Now;
                        terminal.Cuwuguis[strStation] = cuwugui;//将储物柜保存回去
                        //回复云端任务执行状态
                        ReponseWorkEvent evn = new ReponseWorkEvent();

                        evn.workNo     = terminal.oneorder.OrderNo;
                        evn.CDB        = cuwugui.CDB.CDBNO;
                        evn.huodao     = int.Parse(strStation);
                        evn.workstatus = false;
                        terminal.SendNetEvents.Enqueue(evn);
                        //事件通知界面更新
                        terminal.fireEvent(nui);
                        terminal.StartEvent.Set();
                    }
                }
                //正在处理云端的任务,更新界面的状态,其他的查询任务暂停。
            }
            else if (btype == 'E')//字母S,当下位机执行完任务后返回执行的状态,上位机需要答复下位机,即通知下位机已经收到;
            {
                // udplog.logs.Enqueue(DateTime.Now.ToString() + "回复" + strcmds);
                int     flag    = data[4];
                CUWUGUI cuwugui = (CUWUGUI)terminal.Cuwuguis[strStation];//更新储物柜

                if (flag == 1 || flag == 0x21)
                {
                    try
                    {
                        if (terminal.Test_Mode == 1)
                        {
                            cuwugui.AutoTestSuccessCnt++;
                        }
                    }
                    catch
                    { }
                    // ResponseWorkStatus();
                    EventUI nui = new EventUI();
                    nui.UIType = UIUpdateType.ChuHuoWait;
                    nui.huodao = strStation;
                    terminal.oneorder.nowstatus = UIUpdateType.ChuHuoWait;
                    nui.Msg = "出货完成,等待取走";
                    //事件通知界面更新
                    terminal.fireEvent(nui);

                    //回复云端任务执行状态
                    ReponseWorkEvent evn = new ReponseWorkEvent();
                    evn.CDB        = cuwugui.CDB.CDBNO;
                    evn.huodao     = int.Parse(strStation);
                    evn.workNo     = terminal.oneorder.OrderNo;
                    evn.workstatus = true;

                    if (terminal.cflag == 0)
                    {
                        terminal.SendNetEvents.Enqueue(evn);
                    }
                    cuwugui.CDB = null;

                    cuwugui.HasLostCnt = 0;

                    terminal.Cuwuguis[strStation] = cuwugui;
                    //XmlOperatorOrder xmlorder = new XmlOperatorOrder();
                    //xmlorder.orderno = oneorder.OrderNo;
                    //xmlorder.datatime = DateTime.Now.ToString();
                    //xmlorder.cdbno = "00000000000000000000";
                    //xmlorder.cmno = strStation;
                    //xmlorder.status = "0E1";
                    //xmlorder.Add();
                    //udplog.logs.Enqueue(DateTime.Now.ToString() + ":请求租借等待出货E1");
                    //tools.insertLog(strStation + "号仓租借出仓等待取走" + strcmds, Logtype.J);
                }
                else
                {
                    //udplog.logs.Enqueue(DateTime.Now.ToString() + ":请求租借出货失败E0");
                    terminal.oneorder.status    = false;
                    terminal.oneorder.nowstatus = UIUpdateType.ChuHuoL;
                    terminal.oneorder.iTryCnt   = 3;

                    if (terminal.oneorder.iTryCnt == 3)
                    {
                        //BCEvent.Set();

                        // lock (Cuwuguis)
                        {
                            cuwugui.JieLost++;
                            cuwugui.JieLostTime = DateTime.Now;
                            cuwugui.CommTime    = DateTime.Now;

                            cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;

                            //cuwugui.JieLost++;
                            //cuwugui.LastLostTime = DateTime.Now;
                            terminal.Cuwuguis[strStation] = cuwugui;//将储物柜保存回去
                        }
                        EventUI nui = new EventUI();
                        nui.UIType = UIUpdateType.ChuHuoL;
                        nui.huodao = strStation;
                        nui.Msg    = "出货失败";
                        nui.Flag   = false;
                        //回复云端任务执行状态
                        ReponseWorkEvent evn = new ReponseWorkEvent();
                        evn.workNo         = terminal.oneorder.OrderNo;
                        evn.CDB            = terminal.ServerWork.CDBNO;// cuwugui.CDB.CDBNO;
                        evn.huodao         = int.Parse(strStation);
                        evn.workstatus     = true;
                        terminal.jieResult = -5;
                        if (terminal.cflag == 0)
                        {
                            terminal.SendNetEvents.Enqueue(evn);
                            try
                            {
                                //XmlOperatorOrder xmlorder = new XmlOperatorOrder();
                                //xmlorder.orderno = oneorder.OrderNo;
                                //xmlorder.datatime = DateTime.Now.ToString();
                                //xmlorder.cdbno = cuwugui.CDB.CDBNO;
                                //xmlorder.cmno = strStation;
                                //xmlorder.status = "1";
                                //xmlorder.datatime = DateTime.Now.ToString();
                                //xmlorder.Modify();
                            }
                            catch
                            {
                            }
                        }
                        //事件通知界面更新
                        terminal.fireEvent(nui);
                        tools.insertLog(strStation + "号仓租借出仓失败" + strcmds, Logtype.J);
                        //Thread.Sleep(3000);
                        //StartEvent.Set();
                    }
                }
            }
            else if (data[3] == 'F')//字母S,当下位机执行完任务后返回执行的状态,上位机需要答复下位机,即通知下位机已经收到;
            {
                //terminal.jieMonitor.Stop();
                terminal.BCEvent.Set();
                terminal.udplog.logs.Enqueue(DateTime.Now.ToString() + "回复" + strcmds);
                int     flag    = data[4];
                CUWUGUI cuwugui = (CUWUGUI)terminal.Cuwuguis[strStation];//更新储物柜
                cuwugui.LastLostTime = DateTime.Now;
                cuwugui.HasLostCnt   = 0;
                if (flag == 1 || flag == 0x21)
                {
                    terminal.udplog.logs.Enqueue(strStation + "借出完成");
                    terminal.jieResult = 1;
                    EventUI nui = new EventUI();
                    nui.huodao = strStation;
                    nui.UIType = UIUpdateType.ChuHuoF;
                    nui.Msg    = "出货完成";
                    //回复云端任务执行状态


                    //事件通知界面更新
                    terminal.fireEvent(nui);


                    //完成出货,更新储物柜状态和
                    //ReponseWorkEvent evn = new ReponseWorkEvent();
                    //evn.workNo = oneorder.OrderNo;

                    //evn.workstatus = true;
                    ////lock (Cuwuguis)
                    ////{

                    //evn.workNo = oneorder.OrderNo;
                    //evn.CDB = cuwugui.CDB.CDBNO;
                    //cuwugui.CommTime = DateTime.Now;
                    //cuwugui.CWGStatus = CUWUGUISTATUS.None;
                    //cuwugui.CWGCommStatus = CWGCOMMSTATUS.OK;
                    //cuwugui.JieLost = 0;

                    //cuwugui.CDB = null;
                    //cuwugui.Cmd = null;
                    //Cuwuguis[strStation] = cuwugui;//将储物柜保存回去
                    ////}
                    terminal.oneorder.status    = true;
                    terminal.oneorder.nowstatus = UIUpdateType.ChuHuoF;
                    tools.insertLog(DateTime.Now.ToString() + " " + strStation + "号仓借出完成" + strcmds, Logtype.J);
                    Thread.Sleep(1000);
                    terminal.StartEvent.Set();
                    //evn.workstatus = true;
                    //if (cflag == 0)
                    //{

                    //    //SendNetEvents.Enqueue(evn);
                    //}
                    // ResponseWorkStatus();
                }
                else
                {
                    terminal.jieResult = -5;
                    terminal.udplog.logs.Enqueue(DateTime.Now.ToString() + ":请求租借出货完成F0,未取走");
                    EventUI nui = new EventUI();
                    nui.UIType = UIUpdateType.ChuHuoL;
                    nui.Msg    = "出货失败";
                    nui.Flag   = false;
                    nui.huodao = strStation;
                    //事件通知界面更新
                    terminal.fireEvent(nui);
                    terminal.oneorder.status    = true;
                    terminal.oneorder.nowstatus = UIUpdateType.ChuHuoL;
                    terminal.oneorder.iTryCnt   = 3;
                    cuwugui.CommTime            = DateTime.Now;
                    cuwugui.CWGStatus           = CUWUGUISTATUS.None;
                    cuwugui.CWGCommStatus       = CWGCOMMSTATUS.OK;
                    cuwugui.JieLost             = 0;

                    //cuwugui.CDB = null;
                    cuwugui.Cmd = null;
                    //if(Test_Mode==0)//如果是测试模式 则不需保存
                    terminal.Cuwuguis[strStation] = cuwugui;//将储物柜保存回去

                    tools.insertLog(strStation + "号仓借出未取走" + strcmds, Logtype.J);
                    Thread.Sleep(3000);
                    terminal.StartEvent.Set();
                }
            }
            else
            {
                if (next == null)
                {
                    // log.Info("用户" + client.ApplicationID + "执行的ID为" + Command.EventCommandID + "的指令没有对应执行器.");
                    result.ResultType = BasisCommandResult.CommandResultTypeEnum.NoRespnoseExecutor;
                    result.Content    = null;
                    return(result);
                }
                else
                {
                    return(this.next.Execute(Command));
                }
            }
            return(result);
        }