////STEP 4 IMPORT THE COORDINATES FROM CSV AND GENERATE ROUTE
        public async Task ImportCoordinatesCreateRoute(int carName, bool isReturn = false)
        {
            //get the coordinates from uploaded CSV

            var formFile = HttpContext.Request.Form.Files[0];

            if (formFile != null)
            {
                var list = new List <Coordinate>();
                using (var ms = new MemoryStream())
                {
                    formFile.CopyTo(ms);
                    ms.Position = 0;

                    StreamReader reader = new StreamReader(ms);

                    while (!reader.EndOfStream)
                    {
                        var line   = reader.ReadLine();
                        var values = line.Split(',');
                        var anc    = new Coordinate(double.Parse(values[0]), double.Parse(values[1]));
                        list.Add(anc);
                    }
                }

                ////update the end position in cache
                // update the final endpoint in cache
                var carData = _carService.GetCarByName(carName);
                var cached  = await RedisHelper.Instance.GetCacheItem <CachedRecordingModel>($"car_{carData.CarName}");

                cached.EndPoint           = list.LastOrDefault();
                cached.ImpotedCoordinates = list.ToArray();
                cached.RouteStatus        = 1;
                await RedisHelper.Instance.SetCache($"car_{carData.CarName}", cached);

                //create a new route in db
                _carService.AddRoute(carData.Id, list.ToArray());

                //send command to robot
                //路径点与传输:
                var outbound = new OutboundModel();
                outbound.CarName = cached.CarName;
                outbound.Data    = new List <object>();
                outbound.Ip      = cached.Ip;
                var msg_total = cached.ImpotedCoordinates.Count;
                for (int i = 0; i < msg_total; i++)
                {
                    outbound.Data.Add(new msg_map_route
                    {
                        msg_total = msg_total,
                        msg_count = i + 1, //it starts with 1
                        latitude  = cached.ImpotedCoordinates[i].Latitude,
                        longitude = cached.ImpotedCoordinates[i].Longitude
                    });
                }
                RedisHelper.Instance.SetCache("command", outbound).Wait();
            }
        }