From cb40c1af86a50608ac7ccac0da3f0f88af8239dc Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期一, 02 九月 2024 13:25:58 +0800
Subject: [PATCH] 添加设备、点位上的字段

---
 Admin.NET/WCS.Application/Entity/WcsPosition.cs                        |    8 +
 Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceOutput.cs     |   24 ++++
 Admin.NET/WCS.Application/Enum/PLCEnum.cs                              |   17 +++
 Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceInput.cs      |   10 ++
 Web/src/api/wcs/wcsDevice.ts                                           |    8 +
 Web/src/views/wcs/wcsDevice/component/editDialog.vue                   |    9 +
 Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionInput.cs  |    5 +
 Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs        |   38 +++++--
 Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionOutput.cs |    5 +
 Web/src/views/wcs/wcsPosition/component/editDialog.vue                 |    5 +
 Admin.NET/WCS.Application/Entity/WcsDevice.cs                          |    7 +
 Web/src/views/wcs/wcsDevice/index.vue                                  |    6 +
 Admin.NET/WCS.Application/PLC/PLCTaskAction.cs                         |    7 +
 Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceDto.cs        |    5 +
 Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionDto.cs    |   93 +++++++++--------
 Web/src/views/wcs/wcsPosition/index.vue                                |    1 
 16 files changed, 188 insertions(+), 60 deletions(-)

diff --git a/Admin.NET/WCS.Application/Entity/WcsDevice.cs b/Admin.NET/WCS.Application/Entity/WcsDevice.cs
index 4f521c7..c1675c9 100644
--- a/Admin.NET/WCS.Application/Entity/WcsDevice.cs
+++ b/Admin.NET/WCS.Application/Entity/WcsDevice.cs
@@ -15,6 +15,13 @@
     public long PlcId { get; set; }
 
     /// <summary>
+    /// 浜や簰绫诲瀷
+    /// </summary>
+    [Required]
+    [SugarColumn(ColumnName = "DeviceType", ColumnDescription = "浜や簰绫诲瀷")]
+    public DeviceTypeEnum DeviceType { get; set; }
+
+    /// <summary>
     /// 璁惧绾у埆
     /// </summary>
     [Required]
diff --git a/Admin.NET/WCS.Application/Entity/WcsPosition.cs b/Admin.NET/WCS.Application/Entity/WcsPosition.cs
index e481678..6b2feef 100644
--- a/Admin.NET/WCS.Application/Entity/WcsPosition.cs
+++ b/Admin.NET/WCS.Application/Entity/WcsPosition.cs
@@ -34,7 +34,13 @@
     [Required]
     [SugarColumn(ColumnName = "PosType", ColumnDescription = "娴佺▼瀛楃被鍨�")]
     public PLCDataTypeEnum PosType { get; set; }
-    
+
+    /// <summary>
+    /// 瀛楃涓查暱搴�
+    /// </summary>
+    [SugarColumn(ColumnName = "StringLength", ColumnDescription = "瀛楃涓查暱搴�")]
+    public int? StringLength { get; set; }
+
     /// <summary>
     /// 鏄剧ず灞廼p鍦板潃
     /// </summary>
diff --git a/Admin.NET/WCS.Application/Enum/PLCEnum.cs b/Admin.NET/WCS.Application/Enum/PLCEnum.cs
index 1bdfe6d..d0f45f7 100644
--- a/Admin.NET/WCS.Application/Enum/PLCEnum.cs
+++ b/Admin.NET/WCS.Application/Enum/PLCEnum.cs
@@ -138,4 +138,21 @@
     //String
     [Description("String")]
     String = 11,
+}
+/// <summary>
+/// 浜や簰绫诲瀷
+/// </summary>
+[Description("浜や簰绫诲瀷")]
+public enum DeviceTypeEnum
+{
+    /// <summary>
+    /// 涓氬姟
+    /// </summary>
+    [Description("涓氬姟")]
+    Business = 1,
+    /// <summary>
+    /// 椤甸潰灞曠ず
+    /// </summary>
+    [Description("椤甸潰灞曠ず")]
+    Show = 2,
 }
\ No newline at end of file
diff --git a/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs b/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
index 47c28e2..ffa4e97 100644
--- a/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
@@ -21,6 +21,11 @@
     private static List<WcsPosition> listPlcStation;
 
     private static List<PLCUtil> listPlcUtil = new List<PLCUtil>();
+    //瀵瑰鍏竷杩炴帴鐘舵��
+    public static List<PLCUtil> listPlcConn
+    {
+        get { return listPlcUtil; }
+    }
     private static CancellationTokenSource cts;//鍙栨秷绾跨▼鏍囪瘑
 
     public static event EventHandler DeviceValueChangeEvent;
@@ -84,7 +89,7 @@
                     }
                     try
                     {
-                        var modPlcUtil = listPlcUtil.FirstOrDefault(s => s.PlcId == modPlc.Id);
+                        var modPlcUtil = listPlcUtil.FirstOrDefault(s => s != null && s.PlcId == modPlc.Id);
                         if (modPlcUtil == null)
                         {
                             modPlcUtil = new PLCUtil(modPlc);
diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceDto.cs b/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceDto.cs
index 9a3c42d..7a568af 100644
--- a/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceDto.cs
+++ b/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceDto.cs
@@ -12,6 +12,11 @@
     public string PlcIdIP { get; set; }
 
     /// <summary>
+    /// 浜や簰绫诲瀷
+    /// </summary>
+    public DeviceTypeEnum DeviceType { get; set; }
+
+    /// <summary>
     /// 涓婚敭Id
     /// </summary>
     public long Id { get; set; }
diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceInput.cs b/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceInput.cs
index a4b8c8a..c998258 100644
--- a/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceInput.cs
+++ b/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceInput.cs
@@ -20,6 +20,11 @@
     public virtual long PlcId { get; set; }
 
     /// <summary>
+    /// 浜や簰绫诲瀷
+    /// </summary>
+    public virtual DeviceTypeEnum DeviceType { get; set; }
+
+    /// <summary>
     /// 璁惧绾у埆
     /// </summary>
     public virtual DeviceLevelEnum Level { get; set; }
@@ -138,6 +143,11 @@
     /// </summary>
     [Required(ErrorMessage = "PlcId涓嶈兘涓虹┖")]
     public override long PlcId { get; set; }
+    /// <summary>
+    /// 浜や簰绫诲瀷
+    /// </summary>
+    [Required(ErrorMessage = "浜や簰绫诲瀷涓嶈兘涓虹┖")]
+    public override DeviceTypeEnum DeviceType { get; set; }
 
     /// <summary>
     /// 璁惧绾у埆
diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceOutput.cs b/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceOutput.cs
index e66ea48..1e3e202 100644
--- a/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceOutput.cs
+++ b/Admin.NET/WCS.Application/Service/WcsDevice/Dto/WcsDeviceOutput.cs
@@ -12,6 +12,11 @@
     public long Id { get; set; }
 
     /// <summary>
+    /// 浜や簰绫诲瀷
+    /// </summary>
+    public DeviceTypeEnum DeviceType { get; set; }
+
+    /// <summary>
     /// PlcId
     /// </summary>
     public long PlcId { get; set; }
@@ -20,6 +25,11 @@
     /// PlcId 鎻忚堪
     /// </summary>
     public string PlcIdIP { get; set; }
+
+    /// <summary>
+    /// 璁惧绫诲瀷
+    /// </summary>
+    public PLCTypeEnum Type { get; set; }
 
     /// <summary>
     /// 璁惧绾у埆
@@ -106,6 +116,20 @@
     /// </summary>
     public bool IsDelete { get; set; }
 
+    /// <summary>
+    /// 浠诲姟鍙�
+    /// </summary>
+    public string TaskNo { get; set; }
+    /// <summary>
+    /// 浠诲姟绫诲瀷
+    /// </summary>
+    public TaskTypeEnum TaskType { get; set; }
+    public string Plc { get; set; }
+    public string Wcs { get; set; }
+    /// <summary>
+    /// 杩炴帴鐘舵��
+    /// </summary>
+    public bool Status { get; set; }
 }
 
 
diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
index b52d4b1..9c32c01 100644
--- a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
+++ b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
@@ -41,6 +41,7 @@
             {
                 Id = u.Id,
                 PlcId = u.PlcId,
+                DeviceType = (DeviceTypeEnum)u.DeviceType,
                 PlcIdIP = plcid.IP,
                 Level = (DeviceLevelEnum)u.Level,
                 DbNumber = u.DbNumber,
@@ -121,19 +122,6 @@
     }
 
     /// <summary>
-    /// 鑾峰彇璁惧淇℃伅鍒楄〃
-    /// </summary>
-    /// <param name="input"></param>
-    /// <returns></returns>
-    [HttpGet]
-    [ApiDescriptionSettings(Name = "List")]
-    [DisplayName("鑾峰彇璁惧淇℃伅鍒楄〃")]
-    public async Task<List<WcsDeviceOutput>> List([FromQuery] PageWcsDeviceInput input)
-    {
-        return await _wcsDeviceRep.AsQueryable().Select<WcsDeviceOutput>().ToListAsync();
-    }
-
-    /// <summary>
     /// 鑾峰彇PlcId鍒楄〃
     /// </summary>
     /// <returns></returns>
@@ -199,5 +187,29 @@
         await _wcsDeviceRep.Context.Insertable(listPosition).ExecuteCommandAsync();
     }
 
+    /// <summary>
+    /// 鑾峰彇璁惧淇℃伅鍒楄〃
+    /// </summary>
+    /// <param name="input"></param>
+    /// <returns></returns>
+    [HttpGet]
+    [ApiDescriptionSettings(Name = "List")]
+    [DisplayName("鑾峰彇璁惧淇℃伅鍒楄〃")]
+    public async Task<List<WcsDeviceOutput>> List([FromQuery] PageWcsDeviceInput input)
+    {
+        var list = await _wcsDeviceRep.AsQueryable()
+                                    .LeftJoin<WcsPlc>((a, b) => a.PlcId == b.Id)
+                                    .Select<WcsDeviceOutput>((a, b) => new WcsDeviceOutput() { Type = b.Type }, true)
+                                    .ToListAsync();
+        //鑾峰彇璺烘満鐨勭姸鎬�
+        var listConn = PLCTaskAction.listPlcConn;
+        foreach (var modDevice in list)
+        {
+            var modUtil = listConn.FirstOrDefault(s => s != null && s.PlcId == modDevice.PlcId);
+            modDevice.Status = modUtil == null ? false : modUtil.Connected;
+        }
 
+
+        return list;
+    }
 }
diff --git a/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionDto.cs b/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionDto.cs
index f32161c..a328c25 100644
--- a/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionDto.cs
+++ b/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionDto.cs
@@ -1,49 +1,54 @@
 锘�
 namespace WCS.Application;
 
+/// <summary>
+/// 璁惧宸ヤ綅杈撳嚭鍙傛暟
+/// </summary>
+public class WcsPositionDto
+{
     /// <summary>
-    /// 璁惧宸ヤ綅杈撳嚭鍙傛暟
+    /// 璁惧ID
     /// </summary>
-    public class WcsPositionDto
-    {
-        /// <summary>
-        /// 璁惧ID
-        /// </summary>
-        public string? DeviceIdText { get; set; }
-        
-        /// <summary>
-        /// 涓婚敭Id
-        /// </summary>
-        public long Id { get; set; }
-        
-        /// <summary>
-        /// 璁惧ID
-        /// </summary>
-        public long DeviceId { get; set; }
-        
-        /// <summary>
-        /// 宸ヤ綅鍙�
-        /// </summary>
-        public string? StationNum { get; set; }
-        
-        /// <summary>
-        /// 鍋忕Щ閲�
-        /// </summary>
-        public string? PlcPos { get; set; }
-        
-        /// <summary>
-        /// 娴佺▼瀛楃被鍨�
-        /// </summary>
-        public PLCDataTypeEnum? PosType { get; set; }
-        
-        /// <summary>
-        /// 鏄剧ず灞廼p鍦板潃
-        /// </summary>
-        public string? LedIP { get; set; }
-        
-        /// <summary>
-        /// 鎻忚堪
-        /// </summary>
-        public string? Text { get; set; }
-        
-    }
+    public string? DeviceIdText { get; set; }
+
+    /// <summary>
+    /// 涓婚敭Id
+    /// </summary>
+    public long Id { get; set; }
+
+    /// <summary>
+    /// 璁惧ID
+    /// </summary>
+    public long DeviceId { get; set; }
+
+    /// <summary>
+    /// 宸ヤ綅鍙�
+    /// </summary>
+    public string? StationNum { get; set; }
+
+    /// <summary>
+    /// 鍋忕Щ閲�
+    /// </summary>
+    public string? PlcPos { get; set; }
+
+    /// <summary>
+    /// 娴佺▼瀛楃被鍨�
+    /// </summary>
+    public PLCDataTypeEnum? PosType { get; set; }
+
+    /// <summary>
+    /// 瀛楃涓查暱搴�
+    /// </summary>
+    public int? StringLength { get; set; }
+
+    /// <summary>
+    /// 鏄剧ず灞廼p鍦板潃
+    /// </summary>
+    public string? LedIP { get; set; }
+
+    /// <summary>
+    /// 鎻忚堪
+    /// </summary>
+    public string? Text { get; set; }
+
+}
diff --git a/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionInput.cs b/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionInput.cs
index 03bcb70..5cd2b4b 100644
--- a/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionInput.cs
+++ b/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionInput.cs
@@ -27,6 +27,11 @@
     public virtual PLCDataTypeEnum PosType { get; set; }
 
     /// <summary>
+    /// 瀛楃涓查暱搴�
+    /// </summary>
+    public virtual int? StringLength { get; set; }
+
+    /// <summary>
     /// 鏄剧ず灞廼p鍦板潃
     /// </summary>
     public virtual string? LedIP { get; set; }
diff --git a/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionOutput.cs b/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionOutput.cs
index 9144a43..507bfb0 100644
--- a/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionOutput.cs
+++ b/Admin.NET/WCS.Application/Service/WcsPosition/Dto/WcsPositionOutput.cs
@@ -37,6 +37,11 @@
     public PLCDataTypeEnum? PosType { get; set; }
 
     /// <summary>
+    /// 瀛楃涓查暱搴�
+    /// </summary>
+    public int? StringLength { get; set; }
+
+    /// <summary>
     /// 鏄剧ず灞廼p鍦板潃
     /// </summary>
     public string? LedIP { get; set; }
diff --git a/Web/src/api/wcs/wcsDevice.ts b/Web/src/api/wcs/wcsDevice.ts
index 8bd165a..f531fe1 100644
--- a/Web/src/api/wcs/wcsDevice.ts
+++ b/Web/src/api/wcs/wcsDevice.ts
@@ -7,6 +7,7 @@
   DetailWcsDevice = '/api/wcsDevice/detail',
   GetWcsPlcPlcIdDropdown = '/api/wcsDevice/WcsPlcPlcIdDropdown',
   GeneratePos = '/api/wcsDevice/GeneratePos',
+  ListWcsDevice = '/api/wcsDevice/list',
 }
 
 // 澧炲姞璁惧淇℃伅
@@ -61,4 +62,9 @@
 	method: 'post',
 	data: params
 	});
-	
\ No newline at end of file
+	
+export const listWcsDevice = () =>
+	request({
+	url: Api.ListWcsDevice,
+	method: 'get'
+	});
\ No newline at end of file
diff --git a/Web/src/views/wcs/wcsDevice/component/editDialog.vue b/Web/src/views/wcs/wcsDevice/component/editDialog.vue
index 0eed749..da9d95d 100644
--- a/Web/src/views/wcs/wcsDevice/component/editDialog.vue
+++ b/Web/src/views/wcs/wcsDevice/component/editDialog.vue
@@ -24,6 +24,15 @@
 
 					</el-col>
 					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
+						<el-form-item label="浜や簰绫诲瀷" prop="deviceType">
+							<el-select clearable v-model="ruleForm.deviceType" placeholder="璇烽�夋嫨浜や簰绫诲瀷">
+								<el-option v-for="(item, index) in dl('DeviceTypeEnum')" :key="index"
+									:value="Number(item.value)"
+									:label="`${item.name} (${item.code}) [${item.value}]`"></el-option>
+							</el-select>
+						</el-form-item>
+					</el-col>
+					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 						<el-form-item label="璁惧绾у埆" prop="level">
 							<el-select clearable v-model="ruleForm.level" placeholder="璇烽�夋嫨璁惧绾у埆">
 								<el-option v-for="(item, index) in dl('DeviceLevelEnum')" :key="index"
diff --git a/Web/src/views/wcs/wcsDevice/index.vue b/Web/src/views/wcs/wcsDevice/index.vue
index bb543eb..cabac56 100644
--- a/Web/src/views/wcs/wcsDevice/index.vue
+++ b/Web/src/views/wcs/wcsDevice/index.vue
@@ -55,6 +55,12 @@
           </template>
 
         </el-table-column>
+        <el-table-column prop="deviceType" label="浜や簰绫诲瀷" show-overflow-tooltip="">
+          <template #default="scope">
+            <el-tag :type="dv('DeviceTypeEnum', scope.row.deviceType)?.tagType"> {{ dv('DeviceTypeEnum',
+              scope.row.deviceType)?.name }}</el-tag>
+          </template>
+        </el-table-column>
         <el-table-column prop="level" label="璁惧绾у埆" show-overflow-tooltip="">
           <template #default="scope">
             <el-tag :type="dv('DeviceLevelEnum', scope.row.level)?.tagType"> {{ dv('DeviceLevelEnum',
diff --git a/Web/src/views/wcs/wcsPosition/component/editDialog.vue b/Web/src/views/wcs/wcsPosition/component/editDialog.vue
index c9f7574..28c7352 100644
--- a/Web/src/views/wcs/wcsPosition/component/editDialog.vue
+++ b/Web/src/views/wcs/wcsPosition/component/editDialog.vue
@@ -47,6 +47,11 @@
 						
 					</el-col>
 					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
+						<el-form-item label="瀛楃涓查暱搴�" prop="stringLength">
+							<el-input v-model="ruleForm.stringLength" placeholder="璇疯緭鍏ュ瓧绗︿覆闀垮害閲�" maxlength="32" show-word-limit clearable />
+						</el-form-item>
+					</el-col>
+					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 						<el-form-item label="鏄剧ず灞廼p鍦板潃" prop="ledIP">
 							<el-input v-model="ruleForm.ledIP" placeholder="璇疯緭鍏ユ樉绀哄睆ip鍦板潃" maxlength="50" show-word-limit clearable />
 							
diff --git a/Web/src/views/wcs/wcsPosition/index.vue b/Web/src/views/wcs/wcsPosition/index.vue
index 343d80a..a589b8c 100644
--- a/Web/src/views/wcs/wcsPosition/index.vue
+++ b/Web/src/views/wcs/wcsPosition/index.vue
@@ -64,6 +64,7 @@
               scope.row.posType)?.name}}</el-tag>
           </template>
         </el-table-column>
+        <el-table-column prop="stringLength" label="瀛楃涓查暱搴�" show-overflow-tooltip="" />
         <el-table-column prop="ledIP" label="鏄剧ず灞廼p鍦板潃" show-overflow-tooltip="" />
         <el-table-column prop="text" label="鎻忚堪" show-overflow-tooltip="" />
         <el-table-column label="淇敼璁板綍" width="80" align="center" show-overflow-tooltip>

--
Gitblit v1.8.0