using XYY.Core.Standard.Mvc;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using XYY.Service.Standard.First;
using XYY.TaskTrack.Standard.TaskModel;
using System.Collections.Generic;

namespace XYY.Api.First.Controllers
{

    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BatchTrackingController : ApiControllerBase
    {
        private ILadingTrackingService _trackingService;
        public BatchTrackingController(ILadingTrackingService trackingService)
        {
            _trackingService = trackingService;
        }

        public async Task<IActionResult> TestPublic()
        {
            await _trackingService.TestPublic();
            return Ok();

        }

        public async Task<IActionResult> SendInitHKXiKeOrders()
        {
            await _trackingService.SendInitHKXiKeOrders();
            return Ok();

        }

        public async Task<IActionResult> TestSendLog(Frist_Log fristLog)
        {
            await _trackingService.TestSendLog(fristLog);
            return Ok();
        }

        public async Task<IActionResult> UpdateFile()
        {
            var filelist = (await Request.ReadFormAsync()).Files;
            if (filelist != null && filelist.Count > 0)
            {
                var file = filelist[0];
                var result = await _trackingService.AddBatchJob(file.OpenReadStream());
                return Ok(result);
            }
            else
            {
                return Error("请上传一个文件");
            }
        }
        public async Task<IActionResult> TrackSupplement(TrackSupplementRequest param)
        {
            await _trackingService.TrackSupplement(param);
            return Ok();
        }
        [HttpPost]
        public async Task<IActionResult> Lading51Track(List<string> ladingNumber)
        {
            var result=await _trackingService.Lading51TrackService(ladingNumber);
            return Ok(result);
        }

        public async Task<IActionResult> testDez()
        {
            await _trackingService.testDez();
            return Ok();
        }
        
        //[HttpPost]
        //public async Task<IActionResult> test51track(List<string> ladingNumber)
        //{
        //    bool IsTest = true;
        //    var result = await _trackingService.Lading51TrackService(ladingNumber, IsTest);
        //    return Ok(result);
        //}
    }
}
