From 9dfb7d191bdf19595d766647222171f992d8af3f Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期六, 07 六月 2025 08:47:00 +0800
Subject: [PATCH] 修改显示屏显示

---
 Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs |  604 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 597 insertions(+), 7 deletions(-)

diff --git a/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs b/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
index b423607..40ac034 100644
--- a/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
+++ b/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs
@@ -1,5 +1,15 @@
-锘縰sing System.Diagnostics.CodeAnalysis;
+锘縰sing Dm.filter;
+using DocumentFormat.OpenXml.Drawing.Charts;
+using DocumentFormat.OpenXml.Office.CustomUI;
+using DocumentFormat.OpenXml.Presentation;
+using Elastic.Clients.Elasticsearch;
+using Furion.Logging;
+using Newtonsoft.Json;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
 using System.Text;
+using WCS.Application.Entity;
 
 namespace WCS.Application;
 
@@ -70,6 +80,8 @@
         ResponseModel result = new ResponseModel();
         try
         {
+            string str = JsonConvert.SerializeObject(models);
+            Log.Information("鎺ユ敹WMS鍑哄叆搴撲换鍔★紝浠诲姟鍙凤細" + models.TaskNo + ",鎵樼洏鍙凤細"+ models.PalletNo);
             // 楠岃瘉浠诲姟鏄惁宸插瓨鍦�
             var taskInfo = _db.Queryable<WcsTask>().First(w => w.TaskNo == models.TaskNo);
             if (taskInfo != null)
@@ -78,7 +90,7 @@
                 result.Msg = "浠诲姟:" + models.TaskNo + ";宸插瓨鍦�!";
                 return result;
             }
-            if (models.TaskType == "0")
+            if (models.TaskType == "0" && models.TaskType == "0")
             {
                 models.Order = 1;
             }
@@ -86,24 +98,56 @@
             {
                 models.Order = 2;
             }
+            Enum type;
+            var bale = "0";
+            decimal nqty = 0;
+            decimal ncomqty = 0;
+            if (models.TaskType == "0" )
+            {
+                type = TaskTypeEnum.In;
+            }
+            else if (models.TaskType == "1")
+            {
+                type = TaskTypeEnum.Out;
+            }
+            else if (models.TaskType == "3")
+            {
+                type = TaskTypeEnum.In;
+                bale = "1";//瑁瑰寘
+            }
+            else
+            {
+                type = TaskTypeEnum.Move;
+            }
+            if (!string.IsNullOrEmpty( models.Qty))
+            {
+                nqty =Convert.ToDecimal(models.Qty);
+            }
+            if (!string.IsNullOrEmpty(models.CompleteQty))
+            {
+                ncomqty = Convert.ToDecimal(models.CompleteQty);
+            }
             //鏂板浠诲姟
             var taskAdd = new WcsTask()
             {
                 TaskNo = models.TaskNo,
-                TaskType = TaskTypeEnum.Out,
+                TaskType = (TaskTypeEnum?)type,
                 Status = TaskStatusEnum.Wait,
                 //IsSuccess =TaskSuccessEnum.Success,
+                Levels = 999,
                 Origin = "WMS",
                 StartRoadway= models.StartRoadway,
                 StartLocate = models.StartLocate,
                 EndLocate = models.EndLocate,
                 EndRoadway= models.EndRoadway,
                 PalletNo = models.PalletNo,
+                IsBale = bale,
 
-                //LotNo =models.LotNo,
-                //SkuNo=models.SkuNo,
-                //SkuName=models.SkuName,
-                //Qty=models.Qty
+
+                LotNo = models.LotNo,
+                SkuName = models.SkuName,
+                Qty = nqty,
+                CompleteQty = ncomqty
             };
             _db.Insertable(taskAdd).ExecuteCommand();           
 
@@ -114,4 +158,550 @@
             return new ResponseModel() { StatusCode = -1, Msg = ex.Message };
         }
     }
+
+    /// <summary>
+    /// WCS鎺ユ敹WMS涓嬪彂鐨勫嚭鍏ュ簱鍗曚换鍔�
+    /// </summary>
+    /// <param name="models"></param>
+    /// <returns></returns>
+    [HttpPost]
+    [AllowAnonymous]
+    public ResponseModel AddOrderTask(List<ResponseOrderTaskModel> models)
+    {
+        ResponseModel result = new ResponseModel();
+        try
+        {
+            foreach (var item in models)
+            {
+                string str = JsonConvert.SerializeObject(models);
+                Log.Information("鎺ユ敹WMS鎺ㄩ�佺殑绠辩爜淇℃伅锛�" + str);
+                // 楠岃瘉浠诲姟鏄惁宸插瓨鍦�
+                //var taskInfo = _db.Queryable<WcsOderTask>().First(w => w.OrderNo == item.OrderNo && w.SkuNo == item.SkuNo && w.LotNo == item.LotNo);
+                //if (taskInfo == null)
+                //{
+                //var taskid = _db.Queryable<WcsOderTask>().OrderByDescending(w=>w.CreateTime).First();
+                //int newid = (int)taskid.Id + 1;
+                var orderAdd = new WcsOderTask()
+                    {
+                        
+                        OrderNo = item.OrderNo,
+                        TaskNo = "",
+                        LotNo = item.LotNo,
+                        SkuNo = item.SkuNo,
+                        SkuName = item.SkuName,
+                        BoxType = item.BoxType,
+                        Qty = item.Qty,
+                        TaskType = (TaskTypeEnum)item.TaskType,
+                        CreateTime = DateTime.Now,
+                        Status = TaskStatusEnum.Wait,
+                    };
+                    _db.Insertable(orderAdd).ExecuteCommand();
+               //}
+            }
+            return new ResponseModel() { StatusCode = 0, Msg = "鎻掑叆鎴愬姛" };
+        }
+        catch (Exception ex)
+        {
+            return new ResponseModel() { StatusCode = -1, Msg = ex.Message };
+        }
+    }
+
+
+    /// <summary>
+    /// WCS鎺ュ彈璧嬬爜绯荤粺鎺ㄩ�佺殑绠辩爜淇℃伅
+    /// </summary>
+    /// <param name="models">绠辩爜淇℃伅</param>
+    /// <returns>鍙嶉淇℃伅</returns>
+    [HttpPost]
+    [AllowAnonymous]
+    public ResponseFuMaModel AddHttpBoxInfo(FumaBoxInfoInput models)
+    {
+        
+        try
+        {
+            string str = JsonConvert.SerializeObject(models);
+            Log.Information("鎺ユ敹璧嬬爜鎺ㄩ�佺殑绠辩爜淇℃伅锛�"+str);
+            if (models.Origin != "璧嬬爜")
+            {
+                throw new Exception("鏉ユ簮鏈瘑鍒�");
+            }
+            var num = _db.Queryable<WcsBoxInfo>().Where(m=>m.BoxNo == models.BoxNo && m.IsDelete == false).ToList();
+            var type = "add";
+            if (num.Count>0)
+            {
+                //WCS瀛樺湪绠辩爜淇℃伅锛屾洿鏂扮鐮佷俊鎭�(闇�鍒ゆ柇绠辩爜鏄惁宸茬粍鐩樺叆搴�)
+                var num2 = num.Count(m => m.Status != "0" || !string.IsNullOrWhiteSpace(m.PalletNo));
+                if (num2 > 0)
+                {
+                    throw new Exception("璇ョ宸插叆鐩樺叆搴擄紝涓嶅彲鏇存柊淇℃伅");
+                }
+                type = "edit";
+            }
+            
+            if (models.DelistList.Count == 0) 
+            {
+                throw new Exception("鐩掔爜闆嗗悎涓嶈兘涓虹┖");
+            }
+            
+            var listBox = new List<WcsBoxInfo>();
+            foreach (var item in models.DelistList)
+            {
+                var level = "3";
+                if (string.IsNullOrWhiteSpace(item.BoxNo2))
+                {
+                    level = "2";
+                }
+                if (item.DelistList2.Count == 0)
+                {
+                    throw new Exception("鏀爜闆嗗悎涓嶈兘涓虹┖");
+                }
+                //浜岀骇鐮�
+                foreach (var item2 in item.DelistList2)
+                {
+                    if (string.IsNullOrWhiteSpace(models.ProductionTime) || string.IsNullOrWhiteSpace(models.ExpirationTime))
+                    {
+                        throw new Exception("鐢熶骇鏃ユ湡鎴栧け鏁堟棩鏈熶笉鑳戒负绌�");
+                    }
+                    DateTime proTime;
+                    DateTime expTime;
+                    var isValid = DateTime.TryParse(models.ProductionTime, out proTime);
+                    var isValid2 = DateTime.TryParse(models.ExpirationTime, out expTime);
+                    if (!isValid || !isValid2)
+                    {
+                        throw new Exception("鐢熶骇鏃ユ湡鎴栧け鏁堟棩鏈熸牸寮忛敊璇�");
+                    };
+                    DateTime? stortime = null;
+                    if (!string.IsNullOrWhiteSpace(models.StoreTime))
+                    {
+                        stortime = DateTime.Parse(models.StoreTime);
+                    }
+
+                    var boxAdd = new WcsBoxInfo()
+                    {
+                        BoxNo = models.BoxNo,
+                        //OrderNo = models.OrderNo,
+                        SkuNo = models.SkuNo,
+                        SkuName = models.SkuName,
+                        Standard = models.Standard,
+                        LotNo = models.LotNo,
+                        LineNo = models.LineNo,                 // 浜х嚎鍙锋垨浜х嚎鍚嶇О
+                        Qty = item2.Qty,
+                        FullQty = models.FullQty,
+                        //SupplierLot = models.SupplierLot,
+                        InsPectMark = models.InsPectMark,
+                        BitBoxMark = models.BitBoxMark,
+                        //InspectStatus = models.InspectStatus锛�
+                        ProductionTime = proTime,
+                        ExpirationTime = expTime,
+                        StoreTime = stortime,
+                        EndLotFlag = string.IsNullOrWhiteSpace(models.EndBatchMark) ? "0" : models.EndBatchMark,
+
+                        BoxNo2 = item.BoxNo2,
+                        BoxNo3 = item2.BoxNo3,
+                        QtyCount = item2.QtyCount,
+                        QtyOrd = item2.QtyOrd,
+                        
+                        Status = "0",
+                        Level = level,
+
+                        IsDelete = false
+                    };
+                    listBox.Add(boxAdd);
+                }
+
+            }
+            _db.Insertable(listBox).ExecuteCommand();
+            if (type == "edit")
+            {
+                //gen
+                _db.Deleteable(num).ExecuteCommand();
+                return new ResponseFuMaModel() { Success = "0", Message = "鏇存柊鎴愬姛" };
+            }
+            return new ResponseFuMaModel() { Success = "0", Message = "鎻掑叆鎴愬姛" };
+        }
+        catch (Exception ex)
+        {
+            return new ResponseFuMaModel() { Success = "-1", Message = ex.Message };
+        }
+    }
+
+    /// <summary>
+    /// WCS鎺ュ彈璧嬬爜绯荤粺鎺ㄩ�佺殑绠辩爜绉婚櫎
+    /// </summary>
+    /// <param name="models">绠辩爜淇℃伅</param>
+    /// <returns>鍙嶉淇℃伅</returns>
+    [HttpPost]
+    [AllowAnonymous]
+    public ResponseFuMaModel DelgatesHttpBoxInfo(FumaBoxInfoInput models)
+    {
+
+        try
+        {
+            string str = JsonConvert.SerializeObject(models);
+            Log.Information("鎺ユ敹璧嬬爜鎺ㄩ�佺殑绠辩爜绉婚櫎锛�" + str);
+            var num = _db.Queryable<WcsBoxInfo>().Where(m => m.BoxNo == models.BoxNo && m.IsDelete == false).ToList();
+            if (num.Count > 0)
+            {
+                //WCS瀛樺湪绠辩爜淇℃伅锛屾洿鏂扮鐮佷俊鎭�(闇�鍒ゆ柇绠辩爜鏄惁宸茬粍鐩樺叆搴�)
+                var num2 = num.Count(m => m.Status != "0" || !string.IsNullOrWhiteSpace(m.PalletNo));
+                if (num2 > 0)
+                {
+                    throw new Exception("璇ョ宸茬洏鍏ュ簱锛屼笉鍙洿鏂颁俊鎭�");
+                }
+            }
+            if (num.Count == 0)
+            {
+                throw new Exception("鏈壘鍒拌绠辩爜锛岀鐮佺Щ闄ゅけ璐ワ紒");
+            }
+
+            _db.Deleteable(num).ExecuteCommand();
+            return new ResponseFuMaModel() { Success = "0", Message = "绉婚櫎绠辩爜鎴愬姛" };
+        }
+        catch (Exception ex)
+        {
+            return new ResponseFuMaModel() { Success = "-1", Message = ex.Message };
+        }
+    }
+
+    /// <summary>
+    /// WCS鎺ュ彈璧嬬爜绯荤粺鎺ㄩ�佺殑缁撴壒鎬绘暟閲�
+    /// </summary>
+    /// <param name="models">缁撴壒鏁伴噺淇℃伅</param>
+    /// <returns>鍙嶉淇℃伅</returns>
+    [HttpPost]
+    [AllowAnonymous]
+    public ResponseFuMaModel HttpTotalNum(FumaJiepiModel models)
+    {
+
+        try
+        {
+            string str = JsonConvert.SerializeObject(models);
+            Log.Information("鎺ユ敹璧嬬爜鎺ㄩ�佺殑瀹屽伐缁撴壒鎬绘暟閲忥細" + str);
+            //鏌ョ湅璧嬬爜涓嬪彂鐨勪换鍔′俊鎭槸鍚︽鍦ㄥ垎鎷�
+            var num = _db.Queryable<WcsCheckTask>().Where(m => m.SkuNo == models.SkuNo &&m.LotNo == models.LotNo && m.Status == "1").ToList();
+            if (num.Count < 1)
+            {
+                return new ResponseFuMaModel() { Success = "-1", Message = "璇ユ壒娆℃湭杩涜鍒嗘嫞鎴栧凡缁撴壒" };
+            }
+
+            int Fqty = int.Parse(models.FinishQty);
+            int Jpqty = 0;
+            //鍐欏叆璇ヤ换鍔″畬鎴愭暟閲�
+            foreach (var item in num)
+            {
+                int jp = 0;//缁撴壒鏄惁闇�瑕佺粍鐩�0锛氫笉闇�瑕侊紝1锛氶渶瑕併�備笉闇�瑕佺粍鐩樺垯鐩存帴閲婃斁鍒嗛亾锛岄渶瑕佺粍鐩樺垯涓嬪彂PLC棰勭粨鎵逛俊鍙�
+                item.FinishQty = Fqty;
+                //鍒ゆ柇褰撳墠鍗曟嵁鐮佸灈鏁伴噺鏄惁鍜屽畬宸ユ暟閲忕浉绛夛紝鏄垯缁撴壒璇ュ崟鎹�
+                //鑾峰彇宸茬粍鐩樻暟閲�
+                var checkNum = _db.Queryable<WcsBoxInfoLog>().Where(m => m.SkuNo == models.SkuNo && m.LotNo == models.LotNo && m.OrderCode == item.OrderNo).ToList();//缁勭洏琛ㄧ鐮佷俊鎭�
+                if (checkNum.Count>0)
+                {
+                    if (!(string.IsNullOrEmpty(checkNum.First().BoxNo2))||!(string.IsNullOrEmpty(checkNum.First().BoxNo3)))//鏈夋敮鐮�
+                    {
+                        foreach (var item2 in checkNum)
+                        {
+                            Jpqty = (int)(Jpqty + item2.Qty);
+                        }
+                    }
+                    else//鏃犳敮鐮�
+                    {
+                        foreach (var item2 in checkNum)
+                        {
+                            Jpqty = (int)(Jpqty + item2.QtyCount);
+                        }
+                    }
+                }
+                
+                //鑾峰彇宸叉彃鐮佹暟閲�
+                var checkNum2 = _db.Queryable<WcsBoxInfo>().Where(m =>m.BitBoxMark != "1" && m.SkuNo == models.SkuNo && m.LotNo == models.LotNo &&(m.PalletNo != null || m.PalletNo != "") && m.OrderCode == item.OrderNo).ToList();//绠辩爜琛ㄥ凡鐮佸灈绠辩爜淇℃伅
+                if (checkNum2.Count>0)
+                {
+                    jp = 1;//绠辩爜琛ㄨ繕鏈夋湭缁勭洏绠憋紝闇�瑕佺粍鐩�
+                    if (!string.IsNullOrEmpty(checkNum2.First().BoxNo2)||!string.IsNullOrEmpty(checkNum2.First().BoxNo3))//鏈夋敮鐮�
+                    {
+                        foreach (var item2 in checkNum2)
+                        {
+                            Jpqty = (int)(Jpqty + item2.Qty);
+                        }
+                    }
+                    else//鏃犳敮鐮�
+                    {
+                        foreach (var item2 in checkNum2)
+                        {
+                            Jpqty = (int)(Jpqty + item2.QtyCount);
+                        }
+                    }
+                }
+
+                //鑾峰彇闆剁鏁伴噺
+                var checkNum3 = _db.Queryable<WcsBoxInfo>().Where(m => m.BitBoxMark == "1" && m.SkuNo == models.SkuNo && m.LotNo == models.LotNo).ToList();
+                if (checkNum3.Count > 0) 
+                {
+                    if (!string.IsNullOrEmpty(checkNum3.First().BoxNo2) || !string.IsNullOrEmpty(checkNum3.First().BoxNo3))//鏈夋敮鐮�
+                    {
+                        foreach (var item3 in checkNum3)
+                        {
+                            Jpqty = (int)(Jpqty + item3.Qty);
+                        }
+                    }
+                    else//鏃犳敮鐮�
+                    {
+                        foreach (var item3 in checkNum3)
+                        {
+                            Jpqty = (int)(Jpqty + item3.QtyCount);
+                        }
+                    }
+                }
+
+                if (Jpqty == Fqty)
+                {
+                    var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == ("2灞傛墭鐩樿緭閫佺嚎")).First();
+                    if (modPlc == null)
+                        throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+                    PLCUtil plcConn = new PLCUtil(modPlc);
+                    //鍒ゆ柇褰撳墠鍒嗛亾鏄惁鏈夋湭缁勭洏绠�
+                    if (jp == 0)
+                    {
+                        // 鍒嗛亾瑙g粦锛屾姄绠卞搧绉嶅啓鍏�0
+                        var ret1 = plcConn.SetPlcDBValue(item.PosTypeLot, item.DbNumber, item.PlcPos, "0");
+                        if (ret1.IsSucceed)
+                        {
+                            //鏇存柊鍏ュ簱璁㈠崟
+                            var orderTask = _db.Queryable<WcsOderTask>().Where(w => w.SkuNo == item.SkuNo && w.LotNo == item.LotNo && w.IsDelete == false).ToList();
+                            if (orderTask.Count > 0)
+                            {
+                                foreach (var item2 in orderTask)
+                                {
+                                    item2.Status = TaskStatusEnum.Complete;
+                                    _db.Updateable(item2).ExecuteCommand();
+                                }
+                            }
+                            //鍐欏叆娴佺▼瀛楁垚鍔熷悗鏇存柊鍒嗘嫞浠诲姟    liudl 鏈�鍚庝竴鎵樼洏鐢宠瀹屽叆搴撴墠鍙竻绌�
+                            item.OrderNo = "";
+                            item.TaskNo = "";
+                            item.LotNo = "";
+                            item.SkuNo = "";
+                            item.SkuName = "";
+                            item.BoxType = "";
+                            item.Qty = 0;
+                            item.PZNo = "";
+                            item.Status = "0";      // 缁戝畾鍒嗛亾 0锛氳В缁�  1锛氱粦瀹� 
+                            item.FinishQty = 0;
+
+                            //鏇存柊鍒嗘嫞浠诲姟
+                            _db.Updateable(item).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+                        }
+                    }
+                    else 
+                    { 
+                        //棰勭粨鎵逛俊鍙蜂笅鍙�
+                    
+                        var ret2 = plcConn.SetPlcDBValue(item.PosType, item.DbNumber, item.PosLot, "1");//鍐欏叆寮�濮嬬粨鎵逛俊鍙�
+                        if (ret2.IsSucceed)
+                        {
+                            item.Status = "2";//缁撴壒涓�
+                        }
+                        else { throw new Exception("瀹屽伐缁撴壒淇″彿涓嬪彂缁橮LC閿欒"); }
+                    }
+                    _db.Updateable(item).ExecuteCommand();
+                }
+            }
+            
+            return new ResponseFuMaModel() { Success = "0", Message = "鎺ュ彈瀹屽伐缁撴壒鏁伴噺鎴愬姛" };
+        }
+        catch (Exception ex)
+        {
+            return new ResponseFuMaModel() { Success = "-1", Message = ex.Message };
+        }
+    }
+
+
+    /// <summary>
+    /// WCS鎺ュ彈WMS鍏ュ簱鏀捐揣纭鎺ュ彛
+    /// </summary>
+    /// <param name="models"></param>
+    /// <returns>鍙嶉淇℃伅</returns>
+    [HttpPost]
+    [AllowAnonymous]
+    public IsBaleModel2 HttpInConfirm(PortModel models)
+    {
+
+        try
+        {
+            string str = JsonConvert.SerializeObject(models);
+            Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣纭锛屾斁璐у彛锛�" + models.Port+"鍏ュ簱鍙�");
+
+            var portno = models.Port;
+            var layer = "3";
+            switch (models.Port)
+            {
+                case "033":
+                    portno = "33";
+                    layer = "1";
+                    break;
+                case "039":
+                    portno = "39";
+                    layer = "1";
+                    break;
+                case "044":
+                    portno = "44";
+                    layer = "1";
+                    break;
+                case "051":
+                    portno = "51";
+                    layer = "1";
+                    break;
+            }
+
+            //妫�娴嬪叆搴撳彛鐘舵�侊紝120涓哄彲鏀撅紝鍗犵敤鍒欎慨鏀逛负130
+            var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First();
+            if (modPlc == null)
+                throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+            PLCUtil plcConn = new PLCUtil(modPlc);
+            //鑾峰彇宸ヤ綅鐐逛綅淇℃伅
+            var listPlcDevice = _db.Queryable<WcsDevice>().Where(s => s.LedIP != null && s.StationNum == portno).First();
+            var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "PLC").First();
+
+            var (res1, val) = plcConn.GetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos);
+            if (val.ToString() == "120")
+            {
+                //璇诲彇鎴愬姛鍚庡啓鍏�130
+                modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First();
+                var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "130");//鍗犵敤姝ゅ伐浣�
+                if (ret.IsSucceed)
+                {
+                    //鍥炰紶WMS鍙斁淇″彿
+                    return new IsBaleModel2() { Success = 0, Message = "鎺ュ彈鎴愬姛" };
+                }
+            }
+            return new IsBaleModel2() { Success = -1, Message = "璇诲彇PLC鐐逛綅淇℃伅澶辫触" };
+        }
+        catch (Exception ex)
+        {
+            return new IsBaleModel2() { Success = -1, Message = ex.Message };
+        }
+    }
+
+
+    /// <summary>
+    /// WCS鎺ュ彈WMS鍏ュ簱鏀捐揣璇锋眰鎺ュ彛
+    /// </summary>
+    /// <param name="models"></param>
+    /// <returns>鍙嶉淇℃伅</returns>
+    [HttpPost]
+    [AllowAnonymous]
+    public IsBaleModel2 HttpInRequest(PortRequestModel models)
+    {
+        try
+        {
+            string str = JsonConvert.SerializeObject(models);
+            Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣璇锋眰锛屾斁璐у彛锛�" + models.Port + "鍏ュ簱鍙�");
+
+            var portno = models.Port;
+            var layer = "3";
+            switch (models.Port)
+            {
+                case "033":
+                    portno = "33";
+                    layer = "1";
+                    break;
+                case "039":
+                    portno = "39";
+                    layer = "1";
+                    break;
+                case "044":
+                    portno = "44";
+                    layer = "1";
+                    break;
+                case "051":
+                    portno = "51";
+                    layer = "1";
+                    break;
+            }
+
+            var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First();
+            if (modPlc == null)
+                throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+            PLCUtil plcConn = new PLCUtil(modPlc);
+            //鑾峰彇宸ヤ綅鐐逛綅淇℃伅
+            var listPlcDevice = _db.Queryable<WcsDevice>().Where(s=>s.LedIP != null && s.StationNum == portno).First();
+            var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "浠诲姟鍙�").First();
+            plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, models.TaskNo);//鍐欏叆浠诲姟鍙�
+                                                                                                              //
+            modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First();
+            var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "140");//鍐欏叆寮�濮嬫斁璐т俊鍙�
+            if (ret.IsSucceed)
+            {
+                //鍥炰紶WMS鏀捐揣淇″彿
+                return new IsBaleModel2() { Success = 0, Message = "鎺ュ彈鎴愬姛" };
+            }
+            return new IsBaleModel2() { Success = -1, Message = "璇诲彇PLC鐐逛綅淇℃伅澶辫触" };
+        }
+        catch (Exception ex)
+        {
+            return new IsBaleModel2() { Success = -1, Message = ex.Message };
+        }
+    }
+
+
+
+    /// <summary>
+    /// WCS鎺ュ彈WMS灏忚溅鏀惧畬鎴愭帴鍙�
+    /// </summary>
+    /// <param name="models"></param>
+    /// <returns>鍙嶉淇℃伅</returns>
+    [HttpPost]
+    [AllowAnonymous]
+    public IsBaleModel2 HttpInFinish(PortModel models)
+    {
+
+        try
+        {
+            string str = JsonConvert.SerializeObject(models);
+            Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣瀹屾垚锛屾斁璐у彛锛�" + models.Port + "鍏ュ簱鍙�");
+
+            var portno = models.Port;
+            var layer = "3";
+            switch (models.Port)
+            {
+                case "033":
+                    portno = "33";
+                    layer = "1";
+                    break;
+                case "039":
+                    portno = "39";
+                    layer = "1";
+                    break;
+                case "044":
+                    portno = "44";
+                    layer = "1";
+                    break;
+                case "051":
+                    portno = "51";
+                    layer = "1";
+                    break;
+            }
+
+            var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First();
+            if (modPlc == null)
+                throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC");
+            PLCUtil plcConn = new PLCUtil(modPlc);
+            //鑾峰彇宸ヤ綅鐐逛綅淇℃伅
+            var listPlcDevice = _db.Queryable<WcsDevice>().Where(s => s.LedIP != null && s.StationNum == portno).First();
+            var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First();
+
+            var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "160");//鏀惧畬鎴�
+            if (ret.IsSucceed)
+            {
+                //鍥炰紶WMS鏀捐揣淇″彿
+                return new IsBaleModel2() { Success = 0, Message = "鎺ュ彈鎴愬姛" };
+            }
+            return new IsBaleModel2() { Success = -1, Message = "璇诲彇PLC鐐逛綅淇℃伅澶辫触" };
+        }
+        catch (Exception ex)
+        {
+            return new IsBaleModel2() { Success = -1, Message = ex.Message };
+        }
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.8.0