/*************************************************************************************
 *
 * 文 件 名:   SendDataToAgv
 * 描    述:   向Agv发送数据
 * 备    注:
 * 创 建 者：  Du
 * 创建时间：  2022/8/2 9:41:19
*************************************************************************************/

using Newtonsoft.Json;
using RGD.ZhiQianAPI;
using RGD.ZhiQianAPI.ZhiQianModel;
using System;
using System.Collections.Generic;
using System.Runtime.ConstrainedExecution;

namespace RGD.ZhiQianAPI
{
    public class SendDataToAgv
    {
        private static string agvip = "http://192.168.0.52:8000";

        /// <summary>
        /// 向agv发送出库任务组
        /// </summary>
        /// <param name="createOrder"></param>
        /// <returns></returns>
        public static CreateOrderResponse SendOutOrInvTasksToAgv(CreateOrder createOrder)
        {
            var url = agvip + "/rcs/api/orders/create/v3";
            var jsonModel=JsonConvert.SerializeObject(createOrder);
            var content = HttpServer.sendJsonToService(url, jsonModel, "CreateOrder");
            return JsonConvert.DeserializeObject<CreateOrderResponse>(content);
        }
        /// <summary>
        /// 向agv发送首个入库任务
        /// </summary>
        /// <param name="createOrder"></param>
        /// <returns></returns>
        public static CreateOrderResponse SendFirstInTaskToAgv(CreateOrder createOrder)
        {
            var url = agvip + "/rcs/api/orders/create/v3";
            var jsonModel = JsonConvert.SerializeObject(createOrder);
            var content = HttpServer.sendJsonToService(url, jsonModel, "CreateOrder");
            return JsonConvert.DeserializeObject<CreateOrderResponse>(content);
        }
        /// <summary>
        /// 向agv发送追加任务
        /// </summary>
        /// <param name="appendOrder"></param>
        /// <returns></returns>
        public static AppendCompleteCancelResponse SendSuperaddTaskToAgv(AppendOrder appendOrder)
        {
            var url = agvip + "/rcs/api/orders/append/v3";
            var jsonModel = JsonConvert.SerializeObject(appendOrder);
            var content = HttpServer.sendJsonToService(url, jsonModel, "AppendOrder");
            return JsonConvert.DeserializeObject<AppendCompleteCancelResponse>(content);
        }
        /// <summary>
        /// 向agv发送停止追加任务标识
        /// </summary>
        /// <param name="completeOrder"></param>
        /// <returns></returns>
        public static AppendCompleteCancelResponse SendStopAppendTaskToAgv(CompleteOrder completeOrder)
        {
            var url = agvip + "/rcs/api/orders/complete/v3";
            var jsonModel = JsonConvert.SerializeObject(completeOrder);
            var content = HttpServer.sendJsonToService(url, jsonModel, "CompleteOrder");
            return JsonConvert.DeserializeObject<AppendCompleteCancelResponse>(content);
        }
        /// <summary>
        /// 取消任务
        /// </summary>
        /// <param name="cancelOrder"></param>
        /// <returns></returns>
        public static AppendCompleteCancelResponse cancelAgvOrder(CancelOrder cancelOrder)
        {
            var url = agvip + "/rcs/api/orders/cancel/v3";
            var jsonModel = JsonConvert.SerializeObject(cancelOrder);
            var content = HttpServer.sendJsonToService(url, jsonModel, "CancelOrder");
            return JsonConvert.DeserializeObject<AppendCompleteCancelResponse>(content);
        }
    }
}