From 6b2ec7bd05459ddb4ea99df00267dbfda49cbdc7 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期日, 03 八月 2025 14:11:12 +0800
Subject: [PATCH] 设备控制增加电量显示

---
 Admin.NET/WCS.Application/Configuration/Database.json     |    1 
 Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs |   33 ++++++++++++++++
 Web/src/api/wcs/wcsDevice.ts                              |    9 ++++
 Web/src/views/device/deviceStartStop/index.vue            |   28 ++++++++++++-
 4 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/Admin.NET/WCS.Application/Configuration/Database.json b/Admin.NET/WCS.Application/Configuration/Database.json
index ec225b1..b273893 100644
--- a/Admin.NET/WCS.Application/Configuration/Database.json
+++ b/Admin.NET/WCS.Application/Configuration/Database.json
@@ -12,6 +12,7 @@
         //"ConnectionString": "Server=localhost;Database=xxx;Uid=xxx;Pwd=xxx;SslMode=None;", // MySql 搴撹繛鎺ュ瓧绗︿覆",
         //"ConnectionString": "User Id=xxx; Password=xxx; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))", // Oracle 搴撹繛鎺ュ瓧绗︿覆
         "ConnectionString": "Server=10.26.200.29;Database=WCS_JC34;User Id=sa;Password=boxline@2016;", // SqlServer 搴撹繛鎺ュ瓧绗︿覆
+        //"ConnectionString": "Server=192.168.62.200;Database=WCS_JC34;User Id=sa;Password=sql2019;", // SqlServer 搴撹繛鎺ュ瓧绗︿覆
 
 
         //"SlaveConnectionConfigs": [ // 璇诲啓鍒嗙/涓讳粠
diff --git a/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs b/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
index f118c60..8555912 100644
--- a/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
+++ b/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
@@ -11,6 +11,7 @@
 {
     private readonly SqlSugarRepository<WcsPlc> _wcsPlcRep;
     private readonly SysCacheService _sysCacheService;
+    private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
     public WcsPlcService(SqlSugarRepository<WcsPlc> wcsPlcRep, SysCacheService sysCacheService)
     {
         _wcsPlcRep = wcsPlcRep;
@@ -139,6 +140,38 @@
         var modService = new { PLCTaskAction.boRunningState, PLCTaskAction.boOffline, PLCTaskAction.boRefresh, PLCTaskAction.boDemo, PLCTaskAction.boDrumReversal, PLCTaskAction.boOutLock, PLCTaskAction.boEnterLock };
         return new { listPlc, modService };
     }
+
+    [HttpGet]
+    [ApiDescriptionSettings(Name = "GetCarDL")]
+    [DisplayName("鑾峰彇绌挎杞︾數閲�")]
+    public async Task<dynamic> GetCarDL()
+    {
+        var listPlc = await _wcsPlcRep.AsQueryable()
+            .Where(s => s.Type == PLCTypeEnum.ShuttleCar)
+            .ToListAsync();
+
+        List<Dictionary<string, string>> _dicList = new List<Dictionary<string, string>>();
+        foreach (var modPlc in listPlc)
+        {
+            var modbus = new ModbusUtil(modPlc);
+            var listPlcDevice = _db.Queryable<WcsDevice>().First(s => s.PlcId == modPlc.Id);
+            var (result, value) = modbus.GetDBValue(listPlcDevice.PosType, listPlcDevice.PlcPos);
+            if (result.IsSucceed)
+            {
+                var listPlcStation = _db.Queryable<WcsPosition>().Where(s => s.DeviceId == modPlc.Id).ToList();
+                var modCarDl = listPlcStation.FirstOrDefault(s => s.Text == "鐢垫睜鐢甸噺");
+                var (resultDl, valueDl) = modbus.GetDBValue(modCarDl.PosType, modCarDl.PlcPos);
+                if (resultDl.IsSucceed)
+                {
+                    Dictionary<string, string> _dic = new Dictionary<string, string>();
+                    _dic.Add(modPlc.Text, valueDl);
+
+                    _dicList.Add(_dic);
+                }
+            }            
+        }
+        return new { _dicList };
+    }
     /// <summary>
     /// 鑾峰彇浣嶇疆淇℃伅
     /// </summary>
diff --git a/Web/src/api/wcs/wcsDevice.ts b/Web/src/api/wcs/wcsDevice.ts
index d2b0fec..79a4583 100644
--- a/Web/src/api/wcs/wcsDevice.ts
+++ b/Web/src/api/wcs/wcsDevice.ts
@@ -21,6 +21,7 @@
   WriteInfo = '/api/wcsDevice/WriteInfo',
   WriteTaskInfo = '/api/wcsDevice/WriteTaskInfo',
   WriteStartStop = '/api/wcsDevice/WriteStartStop',
+  GetCarDL = '/api/wcsPLC/GetCarDL',
 }
 // 澧炲姞璁惧淇℃伅
 export const WriteLocationInfo = (params?: any) =>
@@ -58,6 +59,14 @@
 		data: params,
 	});
 
+export const GetCarDL = () => 
+	request({
+			url: Api.GetCarDL,
+			method: 'get',
+			data: {},
+		});
+
+
 // 澧炲姞璁惧淇℃伅
 export const addWcsDevice = (params?: any) =>
 	request({
diff --git a/Web/src/views/device/deviceStartStop/index.vue b/Web/src/views/device/deviceStartStop/index.vue
index c924ddd..427378a 100644
--- a/Web/src/views/device/deviceStartStop/index.vue
+++ b/Web/src/views/device/deviceStartStop/index.vue
@@ -5,15 +5,18 @@
                 <el-collapse-item title="浠撳簱涓�灞�" name="1">
                     <el-card class="box-card" shadow="hover">
                         <el-text style="margin-right: 15px;">1鍙风┛姊溅</el-text>
+                        <el-text style="margin-right: 15px;">鐢甸噺锛歿{carDL1}}</el-text>
                         <el-button @click="write('ShuttleCar', '1', '41093', '1')">澶嶄綅</el-button>
                         <el-button @click="write('ShuttleCar', '1', '41096', '1')">姝e悜瀵荤爜</el-button>
                         <el-button @click="write('ShuttleCar', '1', '41096', '2')">鍙嶅悜瀵荤爜</el-button>
+                        
                     </el-card>
                     <el-card class="box-card" shadow="hover">
                         <el-text style="margin-right: 15px;">2鍙风┛姊溅</el-text>
+                        <el-text style="margin-right: 15px;">鐢甸噺锛歿{carDL2}}</el-text>
                         <el-button @click="write('ShuttleCar', '2', '41093', '1')">澶嶄綅</el-button>
                         <el-button @click="write('ShuttleCar', '2', '41096', '1')">姝e悜瀵荤爜</el-button>
-                        <el-button @click="write('ShuttleCar', '2', '41096', '2')">鍙嶅悜瀵荤爜</el-button>
+                        <el-button @click="write('ShuttleCar', '2', '41096', '2')">鍙嶅悜瀵荤爜</el-button>                        
                     </el-card>
                 </el-collapse-item>
             </el-collapse>
@@ -45,12 +48,32 @@
 
 import { ref, reactive, onMounted } from 'vue';
 import { listStatus, listPosition } from '/@/api/wcs/wcsPlc';
-import { WriteStartStop } from '/@/api/wcs/wcsDevice';
+import { WriteStartStop,GetCarDL } from '/@/api/wcs/wcsDevice';
 import { ElMessage } from "element-plus";
 
+const carDL1= ref<any>({});
+carDL1.value="鑾峰彇涓�..";
+const carDL2= ref<any>({});
+carDL2.value="鑾峰彇涓�..";
 const activeNames = ref(['1'])
 const activeNames2 = ref(['2'])
 const state = ref<any>({});
+const handleQuery = async () => {
+	var resCar = await GetCarDL();
+    if (resCar.data.result._dicList && resCar.data.result._dicList.length > 0) {        
+       resCar.data.result._dicList.forEach(car => {
+            const name = Object.keys(car)[0];
+            if(name=="绌挎杞�1"){
+                carDL1.value=car[name]+"%";
+            }
+            if(name=="绌挎杞�2"){
+                carDL2.value=car[name]+"%";
+            }
+        });
+    }
+};
+handleQuery();
+
 
 const write = async (type: string, no: string, layer: string, FuncName: string) => {
 
@@ -60,7 +83,6 @@
         Layer: layer,
         FuncName: FuncName
     };
-
     var res = await WriteStartStop(data);
     console.log(res.data.result);
     // ElMessage.success(res.data.result);

--
Gitblit v1.8.0