Beispiel #1
0
        public static string ForcedOrder(string deviceId, string orderID, string check_order)
        {
            if (!CheckToken())
            {
                ResetToken();
            }

            DeleteOrderConfirm(deviceId, orderID);
            List <CommandPara> lsCmdPars = new List <CommandPara>();

            lsCmdPars.Add(new CommandPara()
            {
                isNum = false, paraName = "orderID", paraValue = orderID
            });
            lsCmdPars.Add(new CommandPara()
            {
                isNum = true, paraName = "Check_order", paraValue = check_order
            });
            //FORCED_END
            string result = currsdk.sendCommand(TxtToken, deviceId, CALLBACK_URL, SERVICEID, FORCED_END, lsCmdPars);

            if (result == null)
            {
                ZHHelper.ConsoleOut("ForcedOrder 获取失败,请看日志");
                return("获取失败,请看日志");
            }
            Console.WriteLine("-----ForcedOrder-----");
            ZHHelper.ConsoleOut($"强制结单命令 {DateTime.Now.ToString("hh:mm:ss,fff")} " + result);
            Console.WriteLine($"deviceId:{deviceId}");
            Console.WriteLine($"orderID:{orderID}");
            Console.WriteLine("---------------" + System.Environment.NewLine);
            return(result);
        }
Beispiel #2
0
        public static string QueryInfo(string deviceId, string state)
        {
            if (!CheckToken())
            {
                ResetToken();
            }

            List <CommandPara> lsCmdPars = new List <CommandPara>();

            lsCmdPars.Add(new CommandPara()
            {
                isNum = true, paraName = "State", paraValue = state
            });

            string result = currsdk.sendCommand(TxtToken, deviceId, CALLBACK_URL, SERVICEID, QUERY_INFO, lsCmdPars);

            if (result == null)
            {
                ZHHelper.ConsoleOut("QueryInfo 获取失败,请看日志");
                return("获取失败,请看日志");
            }
            Console.WriteLine("-----QueryInfo-----");
            ZHHelper.ConsoleOut($"设备查询命令 {DateTime.Now.ToString("hh:mm:ss,fff")} " + result);
            Console.WriteLine($"deviceId:{deviceId}");
            Console.WriteLine("---------------" + System.Environment.NewLine);
            return(result);
        }
Beispiel #3
0
        public static string CancelOrder(string deviceId, string orderID)
        {
            if (!CheckToken())
            {
                ResetToken();
            }
            //移除存在的OrderConf消息确认列表
            DeleteOrderConfirm(deviceId, orderID);
            List <CommandPara> lsCmdPars = new List <CommandPara>();

            lsCmdPars.Add(new CommandPara()
            {
                isNum = false, paraName = "orderID", paraValue = orderID
            });

            string result = currsdk.sendCommand(TxtToken, deviceId, CALLBACK_URL, SERVICEID, CANCEL_ORDER, lsCmdPars);

            if (result == null)
            {
                ZHHelper.ConsoleOut("CancelOrder 获取失败,请看日志");
                return("获取失败,请看日志");
            }
            Console.WriteLine("-----CancelOrder-----");
            ZHHelper.ConsoleOut($"取消订单命令 {DateTime.Now.ToString("hh:mm:ss,fff")} " + result);
            Console.WriteLine($"deviceId:{deviceId}");
            Console.WriteLine($"orderID:{orderID}");
            Console.WriteLine("---------------" + System.Environment.NewLine);
            return(result);
        }
Beispiel #4
0
        //PLACE_ORDER
        public static string PlaceOrder(string deviceId, string orderID, string carNo, string parkNo)
        {
            SetAssigning(deviceId, orderID, carNo, parkNo);
            //if (!CheckToken())
            //{
            //    ResetToken();
            //}
            InitToken();

            List <CommandPara> lsCmdPars = new List <CommandPara>();

            lsCmdPars.Add(new CommandPara()
            {
                isNum = false, paraName = "orderID", paraValue = orderID
            });
            lsCmdPars.Add(new CommandPara()
            {
                isNum = false, paraName = "carNo", paraValue = carNo
            });
            lsCmdPars.Add(new CommandPara()
            {
                isNum = false, paraName = "parkNo", paraValue = parkNo
            });

            string result = currsdk.sendCommand(TxtToken, deviceId, CALLBACK_URL, SERVICEID, PLACE_ORDER, lsCmdPars);

            if (result == null)
            {
                ZHHelper.ConsoleOut("PlaceOrder 获取失败,请看日志");

                //不回信息则视为设备异常
                //发送取消命令
                CancelOrder(deviceId, orderID);
                //发送电量查询

                //向服务器发送设备异常通知
                var url = "https://www.chupiao.xyz/api/Servermessage/fail_deivce";
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("deviceid", deviceId);
                dic.Add("order_number", orderID);
                var res = Helper.HttpClientHelper.PostResponse(url, dic);
                Console.WriteLine($"设备异常 fail_deivce:{res}");

                return("获取失败,请看日志");
            }
            Console.WriteLine("-----PlaceOrder-----");
            ZHHelper.ConsoleOut($"下发订单命令 {DateTime.Now.ToString("hh:mm;ss,fff")} " + result);
            Console.WriteLine($"deviceId:{deviceId}");
            Console.WriteLine($"orderID:{orderID}");
            Console.WriteLine("---------------" + System.Environment.NewLine);
            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// 指派中
        /// 等待服务返回消息送达标识
        /// 30秒未确认或拒绝订单这发送取消此设备订单
        /// </summary>
        public static void SetAssigning(string deviceId, string orderID, string carNo, string parkNo)
        {
            Task task = new TaskFactory().StartNew(() =>
            {
                var dev   = deviceId;
                var order = orderID;

                ///
                ///1.等待消息送达
                /// N 秒后如果未收到响应数据则再次发送,
                /// M 秒后如果再次未收到,则发送取消命令,并向服务器汇报
                ///2.等到按钮响应
                /// N 秒后如未收到响应数据,则发送取消命令,并向服务器汇报
                ///
                Stopwatch sw = new Stopwatch();
                sw.Start();
                while (true)
                {
                    Thread.Sleep(1000);
                    if (OrderConf.Where(x => x.Key == dev && x.Value == order).Count() > 0)
                    {
                        //N 秒未接收则告知服务器
                        if (sw.ElapsedMilliseconds > 30000)
                        {
                            //告知后推出循环
                            {
                                //var url = "http://www.chupiao.xyz/api/Servermessage";

                                var url = "http://www.chupiao.xyz/api/Servermessage";
                                Dictionary <string, string> dic = new Dictionary <string, string>();
                                dic.Add("deviceid", deviceId);
                                dic.Add("order_number", orderID);
                                var res = Helper.HttpClientHelper.PostResponse(url, dic);
                                Console.WriteLine(res);
                            }
                            ZHHelper.ConsoleOut($"{DateTime.Now.ToString("hh:mm:ss,fff")} while 告知后推出循环");
                            sw.Restart();
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            });
        }
Beispiel #6
0
        public ActionResult <string> Post([FromBody] MessageArrivals mess)
        {
            //Console.WriteLine($"接收到消息送达 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:{mess.orderID}");
            //Core.Core.SetMessageArrivals(mess.deviceId, mess.orderID);

            AssignResult r = new AssignResult();

            if (mess == null)
            {
                r.code = 200;
                r.Des  = "传入的数据异常";
                ZHHelper.ConsoleOut($"接收到消息送达 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
                //MessageArrivals
                Console.WriteLine($"MessageArrivals {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
            }
            else if (mess.deviceId == null || mess.deviceId == "")
            {
                r.code = 200;
                r.Des  = "传入的deviceId数据异常";
                //ZHHelper.ConsoleOut($"接收到消息送达 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
                Console.WriteLine($"MessageArrivals {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
            }
            else if (mess.orderID == null || mess.orderID == "")
            {
                r.code = 200;
                r.Des  = "传入的orderID数据异常";
                //ZHHelper.ConsoleOut($"接收到消息送达 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
                Console.WriteLine($"MessageArrivals {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
            }
            else
            {
                r.code = 200;
                r.Des  = "MessageArrivals ok";
                //ZHHelper.ConsoleOut($"接收到消息送达 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:{mess.orderID}");
                Console.WriteLine($"MessageArrivals {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm {mess.orderID}");
                Core.Core.SetMessageArrivals(mess.deviceId, mess.orderID);
            }
            return(Ok(r));
        }
Beispiel #7
0
        public ActionResult <string> Post([FromBody] OrderConfirm order)
        {
            //ZHHelper.ConsoleOut($"接收到订单确认 {DateTime.Now.ToString("hh:mm:ss,fff")} order confirm:{order.orderID}");
            //Core.Core.GetOrderConfirm(order);
            //AssignResult r = new AssignResult();
            //r.code = 200;
            //return Ok(r);

            AssignResult r = new AssignResult();

            if (order == null)
            {
                r.code = 200;
                r.Des  = "传入的数据异常";
                ZHHelper.ConsoleOut($"接收到订单确认 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
            }
            else if (order.deviceId == null || order.deviceId == "")
            {
                r.code = 200;
                r.Des  = "传入的deviceId数据异常";
                ZHHelper.ConsoleOut($"接收到订单确认 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
            }
            else if (order.orderID == null || order.orderID == "")
            {
                r.code = 200;
                r.Des  = "传入的orderID数据异常";
                ZHHelper.ConsoleOut($"接收到订单确认 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:code:{r.code} Des:{r.code}");
            }
            else
            {
                r.code = 200;
                ZHHelper.ConsoleOut($"接收到订单确认 {DateTime.Now.ToString("hh:mm:ss,fff")} message confirm:{order.orderID}");
                Core.Core.DeleteOrderConfirm(order.deviceId, order.orderID);
            }
            return(Ok(r));
        }