From 25184cadd4011856d95e76f1d79b37ce51a3e548 Mon Sep 17 00:00:00 2001
From: chengsc <Demo@DESKTOP-CPA90BF>
Date: 星期三, 30 十月 2024 11:34:12 +0800
Subject: [PATCH] 修改问题

---
 Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs |   75 +++++++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
index 0b6596b..ee6a929 100644
--- a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
+++ b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
@@ -375,6 +375,81 @@
     }
 
 
+
+    /// <summary>
+    /// 鎵嬪姩鍐欏叆PLC鍚仠淇℃伅
+    /// </summary>
+    /// <param name="input"></param>
+    /// <returns></returns>
+    [HttpPost]
+    [ApiDescriptionSettings(Name = "WriteStartStop")]
+    [DisplayName("鍐欏叆PLC鍚仠淇℃伅")]
+    public async Task WriteStartStop(WcsDeviceStartStop input)
+    {
+        WcsPlc modPlc;
+        string DbNum = "";// DB鍧� 
+
+         
+        var plcList = await _wcsPlcRep.Context.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.IsDelete == false).ToListAsync();
+        if (input.Layer == "1")
+        {
+            modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎");
+            if (modPlc == null)
+                throw Oops.Bah($"鏈煡璇㈠埌1妤煎眰PLC淇℃伅");
+            DbNum = "";
+        }
+        else if (input.Layer == "2")
+        {
+            modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎");
+            if (modPlc == null)
+                throw Oops.Bah($"鏈煡璇㈠埌2妤煎眰PLC淇℃伅");
+            DbNum = "91";
+            PLCUtil modUtil = new PLCUtil(modPlc);
+            switch (input.Type)
+            {
+                case "TwoPalletStart":
+                    modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.0", "true");
+                    break;
+                case "OnePalletStop":
+                    modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.1", "true");
+                    break;
+                case "TwoMaStart":
+                    modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.0", "true");
+                    break;
+                case "TwoMaStop":
+                    modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.1", "true");
+                    break;
+                case "TwoMaTwoStart":
+                    modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.2", "true");
+                    break;
+                case "TwoMaTwoStop":
+                    modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.3", "true");
+                    break;
+                case "TwoBoxStart":
+                    modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.2", "true");
+                    break; 
+                case "TwoBoxStop":
+                    modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.3", "true");
+                    break;
+                default:
+                    break;
+            }
+            modUtil.Close();
+        }
+        else if (input.Layer == "3")
+        {
+            modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎");
+            if (modPlc == null)
+                throw Oops.Bah($"鏈煡璇㈠埌3妤煎眰PLC淇℃伅");
+            DbNum = "";
+        }
+        else
+        {
+            throw Oops.Bah("鎿嶄綔绫诲瀷淇℃伅閿欒");
+        }
+        
+    }
+
     #endregion
 
     /// <summary>

--
Gitblit v1.8.0