SemiFinishedManager.cs 3.9 KB
using AGVLib;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CtuDeviceLib.manager
{
    public class SemiFinishedManager
    {
        static string packLineServer { get { return ConfigAppSettings.GetValue("packLineServer", "http://10.68.52.23:8081"); } }
        //10.68.52.23:8081
        //HsdServer/StorageStatus/InStorage
        //POST
        //
        /// <summary>
        /// 请求是否可以放料
        /// </summary>
        /// <returns></returns>
        public static bool CanPut()
        {
            bool enable = ConfigAppSettings.GetValue("Enable_InlineComm", true);
            if (!enable) return true;
            try
            {
                string server = packLineServer+"/HsdServer/StorageStatus/InStorage";
                string content = JsonHelper.SerializeObject(new clsRequest());
                string json = HttpHelper.Post(server, content);
                clsRtn rtnData = JsonHelper.DeserializeJsonToObject<clsRtn>(json);
                if (string.IsNullOrEmpty(json))
                {
                    LogUtil.error($"请求入料线体是否放料异常【{content}】【{json}】");
                }
                if (rtnData != null && rtnData.code == 0)
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("请求入料线体是否放料异常", ex);
            }
            return false;
        }
        public static bool PutOK()
        {
            bool enable = ConfigAppSettings.GetValue("Enable_InlineComm", true);
            if (!enable) return true;
            try
            {
                string server = packLineServer+"/HsdServer/StorageStatus/InStorage";
                string content = JsonHelper.SerializeObject(new clsRequest2());
                string json = HttpHelper.Post(server, content);
                clsRtn rtnData = JsonHelper.DeserializeJsonToObject<clsRtn>(json);
                if (string.IsNullOrEmpty(json))
                {
                    LogUtil.error($"入料线体放料完成通知异常【{content}】【{json}】");
                }
                if (rtnData != null && rtnData.code == 0)
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("入料线体放料完成通知异常", ex);
            }
            return false;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static bool CheckCarton(out clsCarton carton)
        {
            carton = null;
            bool enable = ConfigAppSettings.GetValue("Enable_InlineComm", true);
            if (!enable) return false;
            try
            {
                string server = packLineServer+"/HsdServer/StorageStatus/CheckCarton";
                string content = JsonHelper.SerializeObject(new clsRequest());
                string json = HttpHelper.Post(server, content);
                carton = JsonHelper.DeserializeJsonToObject<clsCarton>(json);
                if (carton != null && carton.cartonCode == 0)
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("CheckCarton error", ex);
            }
            return false;
        }
    }
    public class clsCarton
    {
        public int cartonCode { get; set; }
        public string cartonID { get; set; }
    }
    class clsRtn
    {
        /// <summary>
        /// 0允许
        /// -1,不允许
        /// </summary>
        public int code { get; set; }
    }
    class clsRequest
    {
        public string RequestCode { get; set; } = "1";
    }
    class clsRequest2
    {
        public string Finish { get; set; } = "1";
    }
}