浏览代码

添加设备变更日志查询

章政 7 年之前
父节点
当前提交
d2dc61522b

+ 15 - 12
PLCDataReader/Device/Information/DeviceStatusInfo.cs

@@ -49,20 +49,23 @@ namespace UAS_PLCDataReader.Device.Infomation
                 dpg_senddatasize.Text = Main.ReturnData[de_code].SendDataSize.ToString();
                 dpg_receivedatasize.Text = Main.ReturnData[de_code].ReceiveDataSize.ToString();
                 Dictionary<string, string> ItemData = Main.ReturnData[de_code].ItemData;
-                foreach (var item in ItemData)
+                if (ItemData != null && ItemData.Count > 0)
                 {
-                    switch (item.Key)
+                    foreach (var item in ItemData)
                     {
-                        case "INQTY":
-                            INQTY.Text = item.Value;
-                            break;
-                        case "OUTQTY":
-                            OUTQTY.Text = item.Value;
-                            break;
-                        case "TEMPERATURE":
-                            break;
-                        default:
-                            break;
+                        switch (item.Key)
+                        {
+                            case "INQTY":
+                                INQTY.Text = item.Value;
+                                break;
+                            case "OUTQTY":
+                                OUTQTY.Text = item.Value;
+                                break;
+                            case "TEMPERATURE":
+                                break;
+                            default:
+                                break;
+                        }
                     }
                 }
             }

+ 209 - 6
PLCDataReader/Main.Designer.cs

@@ -33,6 +33,7 @@ namespace UAS_PLCDataReader
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
             this.RibbonNav = new DevExpress.XtraBars.Ribbon.RibbonControl();
             this.ButtonDeviceList = new DevExpress.XtraBars.BarButtonItem();
@@ -42,6 +43,7 @@ namespace UAS_PLCDataReader
             this.ButtionPolling = new DevExpress.XtraBars.BarButtonItem();
             this.ButtonDeviceStatus = new DevExpress.XtraBars.BarButtonItem();
             this.ButtonWorkCenterStatus = new DevExpress.XtraBars.BarButtonItem();
+            this.ButtonDeviceRunLog = new DevExpress.XtraBars.BarButtonItem();
             this.DeviceInf = new DevExpress.XtraBars.Ribbon.RibbonPage();
             this.RibDeviceInf = new DevExpress.XtraBars.Ribbon.RibbonPageGroup();
             this.DeviceCommandSetting = new DevExpress.XtraBars.Ribbon.RibbonPage();
@@ -172,9 +174,23 @@ namespace UAS_PLCDataReader
             this.PageWorkCenterStatus = new DevExpress.XtraTab.XtraTabPage();
             this.GridWorkCenterStatus = new UAS_PLCDataReader.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewWorkCenterStatus = new UAS_PLCDataReader.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
-            this.TimerDeviceStatus = new System.Windows.Forms.Timer();
-            this.CommonTipController = new DevExpress.Utils.ToolTipController();
-            this.TimerUpdateDevice = new System.Windows.Forms.Timer();
+            this.PageDeviceRunLog = new DevExpress.XtraTab.XtraTabPage();
+            this.ButtonSearchDeviceRunLog = new DevExpress.XtraEditors.SimpleButton();
+            this.TextDrrDeCode = new DevExpress.XtraEditors.TextEdit();
+            this.LabelDrrDeCode = new DevExpress.XtraEditors.LabelControl();
+            this.GridDeviceRunLog = new UAS_PLCDataReader.CustomerControl.AutoDataGridControl.AutoDataGridControl();
+            this.GirdViewDeviceRunLog = new UAS_PLCDataReader.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
+            this.主键 = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_decode = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_dename = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_command = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_date = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_commandfrom = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_doman = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_remark = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.TimerDeviceStatus = new System.Windows.Forms.Timer(this.components);
+            this.CommonTipController = new DevExpress.Utils.ToolTipController(this.components);
+            this.TimerUpdateDevice = new System.Windows.Forms.Timer(this.components);
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -214,6 +230,10 @@ namespace UAS_PLCDataReader
             this.PageWorkCenterStatus.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).BeginInit();
+            this.PageDeviceRunLog.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.TextDrrDeCode.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridDeviceRunLog)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GirdViewDeviceRunLog)).BeginInit();
             this.SuspendLayout();
             // 
             // RibbonNav
@@ -229,9 +249,10 @@ namespace UAS_PLCDataReader
             this.ButtonPollingSetting,
             this.ButtionPolling,
             this.ButtonDeviceStatus,
-            this.ButtonWorkCenterStatus});
+            this.ButtonWorkCenterStatus,
+            this.ButtonDeviceRunLog});
             this.RibbonNav.Location = new System.Drawing.Point(0, 0);
-            this.RibbonNav.MaxItemId = 15;
+            this.RibbonNav.MaxItemId = 16;
             this.RibbonNav.Name = "RibbonNav";
             this.RibbonNav.Pages.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPage[] {
             this.DeviceInf,
@@ -307,6 +328,16 @@ namespace UAS_PLCDataReader
             this.ButtonWorkCenterStatus.Tag = "PageWorkCenterStatus";
             this.ButtonWorkCenterStatus.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.ButtonItem_ItemClick);
             // 
+            // ButtonDeviceRunLog
+            // 
+            this.ButtonDeviceRunLog.Caption = "设备运行日志";
+            this.ButtonDeviceRunLog.Glyph = global::UAS_PLCDataReader.Properties.Resources.Png_Device;
+            this.ButtonDeviceRunLog.Id = 15;
+            this.ButtonDeviceRunLog.LargeGlyph = global::UAS_PLCDataReader.Properties.Resources.Png_Device;
+            this.ButtonDeviceRunLog.Name = "ButtonDeviceRunLog";
+            this.ButtonDeviceRunLog.Tag = "PageDeviceRunLog";
+            this.ButtonDeviceRunLog.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.ButtonItem_ItemClick);
+            // 
             // DeviceInf
             // 
             this.DeviceInf.Groups.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPageGroup[] {
@@ -334,6 +365,7 @@ namespace UAS_PLCDataReader
             // RibDeviceCommand
             // 
             this.RibDeviceCommand.ItemLinks.Add(this.ButtonDeviceStatus);
+            this.RibDeviceCommand.ItemLinks.Add(this.ButtonDeviceRunLog);
             this.RibDeviceCommand.Name = "RibDeviceCommand";
             this.RibDeviceCommand.Text = "ribbonPageGroup3";
             // 
@@ -353,7 +385,8 @@ namespace UAS_PLCDataReader
             this.PagePollingSetting,
             this.PagePolling,
             this.PageDeviceStatus,
-            this.PageWorkCenterStatus});
+            this.PageWorkCenterStatus,
+            this.PageDeviceRunLog});
             // 
             // PageDeviceList
             // 
@@ -1666,6 +1699,156 @@ namespace UAS_PLCDataReader
             this.GridViewWorkCenterStatus.Name = "GridViewWorkCenterStatus";
             this.GridViewWorkCenterStatus.OptionsView.ShowGroupPanel = false;
             // 
+            // PageDeviceRunLog
+            // 
+            this.PageDeviceRunLog.Controls.Add(this.ButtonSearchDeviceRunLog);
+            this.PageDeviceRunLog.Controls.Add(this.TextDrrDeCode);
+            this.PageDeviceRunLog.Controls.Add(this.LabelDrrDeCode);
+            this.PageDeviceRunLog.Controls.Add(this.GridDeviceRunLog);
+            this.PageDeviceRunLog.Name = "PageDeviceRunLog";
+            this.PageDeviceRunLog.PageVisible = false;
+            this.PageDeviceRunLog.Size = new System.Drawing.Size(1027, 577);
+            this.PageDeviceRunLog.Text = "设备运行日志";
+            // 
+            // ButtonSearchDeviceRunLog
+            // 
+            this.ButtonSearchDeviceRunLog.Location = new System.Drawing.Point(170, 4);
+            this.ButtonSearchDeviceRunLog.Name = "ButtonSearchDeviceRunLog";
+            this.ButtonSearchDeviceRunLog.Size = new System.Drawing.Size(64, 23);
+            this.ButtonSearchDeviceRunLog.TabIndex = 3;
+            this.ButtonSearchDeviceRunLog.Text = "查询";
+            this.ButtonSearchDeviceRunLog.Click += new System.EventHandler(this.ButtonSearchDeviceRunLog_Click);
+            // 
+            // TextDrrDeCode
+            // 
+            this.TextDrrDeCode.Location = new System.Drawing.Point(64, 5);
+            this.TextDrrDeCode.MenuManager = this.RibbonNav;
+            this.TextDrrDeCode.Name = "TextDrrDeCode";
+            this.TextDrrDeCode.Size = new System.Drawing.Size(100, 20);
+            this.TextDrrDeCode.TabIndex = 2;
+            // 
+            // LabelDrrDeCode
+            // 
+            this.LabelDrrDeCode.Appearance.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.LabelDrrDeCode.Location = new System.Drawing.Point(10, 7);
+            this.LabelDrrDeCode.Name = "LabelDrrDeCode";
+            this.LabelDrrDeCode.Size = new System.Drawing.Size(48, 17);
+            this.LabelDrrDeCode.TabIndex = 1;
+            this.LabelDrrDeCode.Text = "设备编号";
+            // 
+            // GridDeviceRunLog
+            // 
+            this.GridDeviceRunLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.GridDeviceRunLog.Condition = null;
+            this.GridDeviceRunLog.GetDataSQL = null;
+            this.GridDeviceRunLog.ID = null;
+            this.GridDeviceRunLog.InsertSQL = null;
+            this.GridDeviceRunLog.Location = new System.Drawing.Point(-1, 29);
+            this.GridDeviceRunLog.MainView = this.GirdViewDeviceRunLog;
+            this.GridDeviceRunLog.MenuManager = this.RibbonNav;
+            this.GridDeviceRunLog.Name = "GridDeviceRunLog";
+            this.GridDeviceRunLog.RowCount = 0;
+            this.GridDeviceRunLog.Size = new System.Drawing.Size(1028, 553);
+            this.GridDeviceRunLog.TabIndex = 0;
+            this.GridDeviceRunLog.TableName = null;
+            this.GridDeviceRunLog.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
+            this.GirdViewDeviceRunLog});
+            // 
+            // GirdViewDeviceRunLog
+            // 
+            this.GirdViewDeviceRunLog.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
+            this.主键,
+            this.drr_decode,
+            this.drr_dename,
+            this.drr_command,
+            this.drr_date,
+            this.drr_commandfrom,
+            this.drr_doman,
+            this.drr_remark});
+            this.GirdViewDeviceRunLog.GridControl = this.GridDeviceRunLog;
+            this.GirdViewDeviceRunLog.IndicatorWidth = 30;
+            this.GirdViewDeviceRunLog.Name = "GirdViewDeviceRunLog";
+            this.GirdViewDeviceRunLog.OptionsView.ShowGroupPanel = false;
+            // 
+            // 主键
+            // 
+            this.主键.Caption = "drr_id";
+            this.主键.FieldName = "DRR_ID";
+            this.主键.Name = "主键";
+            this.主键.OptionsColumn.AllowEdit = false;
+            // 
+            // drr_decode
+            // 
+            this.drr_decode.Caption = "设备编号";
+            this.drr_decode.FieldName = "DRR_DECODE";
+            this.drr_decode.Name = "drr_decode";
+            this.drr_decode.OptionsColumn.AllowEdit = false;
+            this.drr_decode.Visible = true;
+            this.drr_decode.VisibleIndex = 0;
+            this.drr_decode.Width = 142;
+            // 
+            // drr_dename
+            // 
+            this.drr_dename.Caption = "设备名称";
+            this.drr_dename.FieldName = "DRR_DENAME";
+            this.drr_dename.Name = "drr_dename";
+            this.drr_dename.OptionsColumn.AllowEdit = false;
+            this.drr_dename.Visible = true;
+            this.drr_dename.VisibleIndex = 1;
+            this.drr_dename.Width = 142;
+            // 
+            // drr_command
+            // 
+            this.drr_command.Caption = "指令类型";
+            this.drr_command.FieldName = "DRR_COMMAND";
+            this.drr_command.Name = "drr_command";
+            this.drr_command.OptionsColumn.AllowEdit = false;
+            this.drr_command.Visible = true;
+            this.drr_command.VisibleIndex = 2;
+            this.drr_command.Width = 142;
+            // 
+            // drr_date
+            // 
+            this.drr_date.Caption = "日期";
+            this.drr_date.FieldName = "DRR_DATE";
+            this.drr_date.Name = "drr_date";
+            this.drr_date.OptionsColumn.AllowEdit = false;
+            this.drr_date.Visible = true;
+            this.drr_date.VisibleIndex = 3;
+            this.drr_date.Width = 142;
+            // 
+            // drr_commandfrom
+            // 
+            this.drr_commandfrom.Caption = "指令来源";
+            this.drr_commandfrom.FieldName = "DRR_COMMANDFROM";
+            this.drr_commandfrom.Name = "drr_commandfrom";
+            this.drr_commandfrom.OptionsColumn.AllowEdit = false;
+            this.drr_commandfrom.Visible = true;
+            this.drr_commandfrom.VisibleIndex = 4;
+            this.drr_commandfrom.Width = 142;
+            // 
+            // drr_doman
+            // 
+            this.drr_doman.Caption = "执行人";
+            this.drr_doman.FieldName = "DRR_DOMAN";
+            this.drr_doman.Name = "drr_doman";
+            this.drr_doman.OptionsColumn.AllowEdit = false;
+            this.drr_doman.Visible = true;
+            this.drr_doman.VisibleIndex = 5;
+            this.drr_doman.Width = 142;
+            // 
+            // drr_remark
+            // 
+            this.drr_remark.Caption = "备注";
+            this.drr_remark.FieldName = "DRR_REMARK";
+            this.drr_remark.Name = "drr_remark";
+            this.drr_remark.OptionsColumn.AllowEdit = false;
+            this.drr_remark.Visible = true;
+            this.drr_remark.VisibleIndex = 6;
+            this.drr_remark.Width = 144;
+            // 
             // TimerDeviceStatus
             // 
             this.TimerDeviceStatus.Interval = 10000;
@@ -1738,6 +1921,11 @@ namespace UAS_PLCDataReader
             this.PageWorkCenterStatus.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).EndInit();
+            this.PageDeviceRunLog.ResumeLayout(false);
+            this.PageDeviceRunLog.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.TextDrrDeCode.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridDeviceRunLog)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GirdViewDeviceRunLog)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -1886,5 +2074,20 @@ namespace UAS_PLCDataReader
         private DevExpress.XtraGrid.Columns.GridColumn de_item3;
         private DevExpress.XtraEditors.Repository.RepositoryItemComboBox DataItemRepositoryItemComboBox1;
         private DevExpress.XtraGrid.Columns.GridColumn dc_type;
+        private DevExpress.XtraBars.BarButtonItem ButtonDeviceRunLog;
+        private DevExpress.XtraTab.XtraTabPage PageDeviceRunLog;
+        private AutoDataGridControl GridDeviceRunLog;
+        private GridViewWithSerialNum GirdViewDeviceRunLog;
+        private DevExpress.XtraGrid.Columns.GridColumn 主键;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_decode;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_dename;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_command;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_date;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_commandfrom;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_doman;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_remark;
+        private LabelControl LabelDrrDeCode;
+        private SimpleButton ButtonSearchDeviceRunLog;
+        private TextEdit TextDrrDeCode;
     }
 }

+ 20 - 2
PLCDataReader/Main.cs

@@ -174,6 +174,9 @@ namespace UAS_PLCDataReader
             ButtonAddNetConfig.Grid = GridDeviceNetSetting;
             ButtonSaveNetConfig.Grid = GridDeviceNetSetting;
 
+            GridDeviceRunLog.GetDataSQL = "SELECT * FROM DEVICERUNRECORD";
+            GridDeviceRunLog.ID = "drr_id";
+            GridDeviceRunLog.TableName = "DEVICERUNRECORD";
             TimerUpdateDevice.Start();
 
             Ptime = new Dictionary<int, PollingTimer>();
@@ -524,7 +527,7 @@ namespace UAS_PLCDataReader
                     Dictionary<string, string> ItemData = new Dictionary<string, string>();
                     int[] Arr = BaseUtil.GetDecimalData(BaseUtil.ASCIIToString(client[DpcID].Returnvalue[IP]), 8);
                     //返回的参数个数和定义的参数个数相等或者小于的时候
-                    if (Arr.Length == DC.Rows.Count|| DC.Rows.Count > Arr.Length)
+                    if (Arr.Length == DC.Rows.Count || DC.Rows.Count > Arr.Length)
                     {
                         for (int i = 0; i < Arr.Length; i++)
                         {
@@ -567,7 +570,7 @@ namespace UAS_PLCDataReader
                             ReturnData[Decode].ItemData = ItemData;
                             LogicHandler.UpdateDeviceData(dh, Decode, ItemData);
                             QueueUpdateDevice.Enqueue(ReturnData[Decode]);
-                            LogicHandler.DoDeviceDataDiffLog(dh, pl.DeviceCode, pl.DeviceName, pl.CommandCode, User.UserName);
+                            LogicHandler.DoDeviceDataDiffLog(dh, pl.DeviceCode, pl.DeviceName, Command, pl.CommandCode, User.UserName);
                         }
                     }
                     client[DpcID].Returnvalue.Remove(IP);
@@ -862,5 +865,20 @@ namespace UAS_PLCDataReader
             }
         }
         #endregion
+
+        #region 设备运行日志查看
+        private void ButtonSearchDeviceRunLog_Click(object sender, EventArgs e)
+        {
+            if (TextDrrDeCode.Text != "")
+            {
+                GridDeviceRunLog.GetDataSQL = "SELECT * FROM DEVICERUNRECORD WHERE drr_decode like '%" + TextDrrDeCode.Text + "%'";
+            }
+            else
+            {
+                GridDeviceRunLog.GetDataSQL = "SELECT * FROM DEVICERUNRECORD";
+            }
+            GridDeviceRunLog.RefreshData();
+        }
+        #endregion
     }
 }

+ 4 - 4
PLCDataReader/PublicMethod/LogicHandler.cs

@@ -41,16 +41,16 @@ namespace UAS_PLCDataReader.PublicMethod
         /// <summary>
         /// 进行差异日志记录
         /// </summary>
-        public static void DoDeviceDataDiffLog(DataHelper dh, string iDeCode, string iDeName, string iCommand, string iMan)
+        public static void DoDeviceDataDiffLog(DataHelper dh, string iDeCode, string iDeName, string iCommand, string iCommandFrom, string iMan)
         {
             sql.Clear();
-            sql.Append("insert into DeviceRunRecord(drr_id,drr_decode,drr_dename,drr_command,drr_date,drr_doman,drr_remark)");
-            sql.Append("values(DeviceRunRecord_seq.nextval,'" + iDeCode + "','" + iDeName + "','" + iCommand + "',sysdate,'" + iMan + "','')");
+            sql.Append("insert into DeviceRunRecord(drr_id,drr_decode,drr_dename,drr_command,drr_commandfrom,drr_date,drr_doman,drr_remark)");
+            sql.Append("values(DeviceRunRecord_seq.nextval,'" + iDeCode + "','" + iDeName + "','" + iCommand + "','" + iCommandFrom + "',sysdate,'" + iMan + "','')");
             dh.ExecuteSql(sql.ToString(), "insert");
         }
 
         /// <summary>
-        /// 更新设备数据
+        /// 更新设备数据投入,产出等数据
         /// </summary>
         /// <param name="Decode"></param>
         /// <param name="ItemData"></param>