Browse Source

Merge branch 'master' of ssh://10.10.100.21/source/mes-client

Hcsy 7 years ago
parent
commit
90c6873233

+ 6 - 3
PLCDataReader/DataOperate/DataHelper.cs

@@ -519,8 +519,9 @@ namespace UAS_PLCDataReader.DataOperate
                     {
                     {
                         result = command.ExecuteNonQuery();
                         result = command.ExecuteNonQuery();
                     }
                     }
-                    catch (Exception)
+                    catch (Exception e)
                     {
                     {
+                        LogManager.DoLog(e.StackTrace + e.Message + SQL);
                         command.Connection = new OracleConnection(DBConnectionString);
                         command.Connection = new OracleConnection(DBConnectionString);
                         command.Connection.Open();
                         command.Connection.Open();
                         result = command.ExecuteNonQuery();
                         result = command.ExecuteNonQuery();
@@ -531,8 +532,9 @@ namespace UAS_PLCDataReader.DataOperate
                     {
                     {
                         result = command.ExecuteNonQuery();
                         result = command.ExecuteNonQuery();
                     }
                     }
-                    catch (Exception)
+                    catch (Exception e)
                     {
                     {
+                        LogManager.DoLog(e.StackTrace + e.Message + SQL);
                         command.Connection = new OracleConnection(DBConnectionString);
                         command.Connection = new OracleConnection(DBConnectionString);
                         command.Connection.Open();
                         command.Connection.Open();
                         result = command.ExecuteNonQuery();
                         result = command.ExecuteNonQuery();
@@ -543,8 +545,9 @@ namespace UAS_PLCDataReader.DataOperate
                     {
                     {
                         result = command.ExecuteNonQuery();
                         result = command.ExecuteNonQuery();
                     }
                     }
-                    catch (Exception)
+                    catch (Exception e)
                     {
                     {
+                        LogManager.DoLog(e.StackTrace + e.Message + SQL);
                         command.Connection = new OracleConnection(DBConnectionString);
                         command.Connection = new OracleConnection(DBConnectionString);
                         command.Connection.Open();
                         command.Connection.Open();
                         result = command.ExecuteNonQuery();
                         result = command.ExecuteNonQuery();

+ 4 - 30
PLCDataReader/Device/Information/DeviceStatusInfo.cs

@@ -43,14 +43,15 @@ namespace UAS_PLCDataReader.Device.Infomation
             }
             }
             //查询设备参数信息
             //查询设备参数信息
             sql.Clear();
             sql.Clear();
-            sql.Append("select dr_updatedate,dc_name,case when dc_type='INQTY' then dr_qty when dc_type='OUTQTY' then dr_okqty end data ");
-            sql.Append("from DEVICEPOLLINGCONFIG left join devicecommand on dpc_dccode = dc_code left join DEVICERUNSTATUS ");
+            sql.Append("select dr_updatedate,dc_name,case when dc_type='INQTY' then dr_qty when dc_type='OUTQTY' then dr_okqty when dc_type='TEMPERATURE' ");
+            sql.Append("then dr_TEMPERATURE when dc_type='PARAM1' then dr_value1 when dc_type='PARAM2' then dr_value2 when dc_type='PARAM3' then dr_value3 end ");
+            sql.Append("data from DEVICEPOLLINGCONFIG left join devicecommand on dpc_dccode = dc_code left join DEVICERUNSTATUS ");
             sql.Append("on dpc_decode = dr_decode where dpc_decode = '" + de_code + "'");
             sql.Append("on dpc_decode = dr_decode where dpc_decode = '" + de_code + "'");
             GridDeivceStatusInfo.DataSource = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             GridDeivceStatusInfo.DataSource = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             GridViewDeviceStatusInfo.BestFitColumns();
             GridViewDeviceStatusInfo.BestFitColumns();
             sql.Clear();
             sql.Clear();
             //查询设备运行日志
             //查询设备运行日志
-            sql.Append("select * from DEVICERUNRECORD where drr_decode='"+ de_code + "'");
+            sql.Append("select * from DEVICERUNRECORD where drr_decode='" + de_code + "'");
             GridDeviceRunLog.DataSource = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             GridDeviceRunLog.DataSource = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             sql.Clear();
             sql.Clear();
             sql.Append("select '接收'||nvl(dpg_receivedatasize,0)||'字节' dpg_receivedatasize,'发送'||nvl(dpg_senddatasize,0)||'字节' dpg_senddatasize");
             sql.Append("select '接收'||nvl(dpg_receivedatasize,0)||'字节' dpg_receivedatasize,'发送'||nvl(dpg_senddatasize,0)||'字节' dpg_senddatasize");
@@ -64,33 +65,6 @@ namespace UAS_PLCDataReader.Device.Infomation
                 string TimeSpan = dt.Rows[0]["dpg_runtime"].ToString();
                 string TimeSpan = dt.Rows[0]["dpg_runtime"].ToString();
                 dpg_runtime.Text = BaseUtil.MinutesToDayTime(int.Parse(TimeSpan == "" ? "0" : TimeSpan));
                 dpg_runtime.Text = BaseUtil.MinutesToDayTime(int.Parse(TimeSpan == "" ? "0" : TimeSpan));
             }
             }
-            //if (Main.ReturnData.ContainsKey(de_code))
-            //{
-            //    //dnc_ip.Text = Main.ReturnData[de_code].SendCount.ToString();
-            //    //dpg_runtime.Text = BaseUtil.MinutesToDayTime((DateTime.Now - Main.ReturnData[de_code].StartTime).TotalMinutes);
-            //    //dpg_onlinetime.Text = Main.ReturnData[de_code].StartTime.ToString("yyyy-MM-dd HH:mm:ss");
-            //    //dpg_senddatasize.Text = Main.ReturnData[de_code].ReceiveDataSize.ToString();
-            //    Dictionary<string, string> ItemData = Main.ReturnData[de_code].ItemData;
-            //    if (ItemData != null && ItemData.Count > 0)
-            //    {
-            //        foreach (var item in ItemData)
-            //        {
-            //            switch (item.Key)
-            //            {
-            //                case "INQTY":
-            //                    INQTY.Text = item.Value;
-            //                    break;
-            //                case "OUTQTY":
-            //                    OUTQTY.Text = item.Value;
-            //                    break;
-            //                case "TEMPERATURE":
-            //                    break;
-            //                default:
-            //                    break;
-            //            }
-            //        }
-            //    }
-            //}
         }
         }
 
 
         private void DeviceStatusInfo_KeyDown(object sender, KeyEventArgs e)
         private void DeviceStatusInfo_KeyDown(object sender, KeyEventArgs e)

+ 8 - 8
PLCDataReader/Main.Designer.cs

@@ -270,7 +270,7 @@ namespace UAS_PLCDataReader
             this.RibbonNav.Pages.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPage[] {
             this.RibbonNav.Pages.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPage[] {
             this.DeviceInf,
             this.DeviceInf,
             this.DeviceCommandSetting});
             this.DeviceCommandSetting});
-            this.RibbonNav.Size = new System.Drawing.Size(1033, 128);
+            this.RibbonNav.Size = new System.Drawing.Size(1040, 128);
             // 
             // 
             // ButtonDeviceList
             // ButtonDeviceList
             // 
             // 
@@ -400,7 +400,7 @@ namespace UAS_PLCDataReader
             this.MainTabControl.Name = "MainTabControl";
             this.MainTabControl.Name = "MainTabControl";
             this.MainTabControl.SelectedTabPage = this.PageDeviceList;
             this.MainTabControl.SelectedTabPage = this.PageDeviceList;
             this.MainTabControl.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
             this.MainTabControl.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
-            this.MainTabControl.Size = new System.Drawing.Size(1033, 583);
+            this.MainTabControl.Size = new System.Drawing.Size(1040, 584);
             this.MainTabControl.TabIndex = 3;
             this.MainTabControl.TabIndex = 3;
             this.MainTabControl.TabPages.AddRange(new DevExpress.XtraTab.XtraTabPage[] {
             this.MainTabControl.TabPages.AddRange(new DevExpress.XtraTab.XtraTabPage[] {
             this.PageDeviceList,
             this.PageDeviceList,
@@ -427,7 +427,7 @@ namespace UAS_PLCDataReader
             this.PageDeviceList.Controls.Add(this.GridDeviceList);
             this.PageDeviceList.Controls.Add(this.GridDeviceList);
             this.PageDeviceList.Name = "PageDeviceList";
             this.PageDeviceList.Name = "PageDeviceList";
             this.PageDeviceList.PageVisible = false;
             this.PageDeviceList.PageVisible = false;
-            this.PageDeviceList.Size = new System.Drawing.Size(1027, 577);
+            this.PageDeviceList.Size = new System.Drawing.Size(1034, 578);
             this.PageDeviceList.Text = "xtraTabPage1";
             this.PageDeviceList.Text = "xtraTabPage1";
             this.PageDeviceList.VisibleChanged += new System.EventHandler(this.PageDeviceList_VisibleChanged);
             this.PageDeviceList.VisibleChanged += new System.EventHandler(this.PageDeviceList_VisibleChanged);
             // 
             // 
@@ -435,7 +435,7 @@ namespace UAS_PLCDataReader
             // 
             // 
             this.ButtonAddDevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonAddDevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonAddDevice.Grid = null;
             this.ButtonAddDevice.Grid = null;
-            this.ButtonAddDevice.Location = new System.Drawing.Point(811, 4);
+            this.ButtonAddDevice.Location = new System.Drawing.Point(818, 4);
             this.ButtonAddDevice.Name = "ButtonAddDevice";
             this.ButtonAddDevice.Name = "ButtonAddDevice";
             this.ButtonAddDevice.Size = new System.Drawing.Size(64, 23);
             this.ButtonAddDevice.Size = new System.Drawing.Size(64, 23);
             this.ButtonAddDevice.TabIndex = 16;
             this.ButtonAddDevice.TabIndex = 16;
@@ -445,7 +445,7 @@ namespace UAS_PLCDataReader
             // 
             // 
             this.ButtonDeleteDevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonDeleteDevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonDeleteDevice.Grid = null;
             this.ButtonDeleteDevice.Grid = null;
-            this.ButtonDeleteDevice.Location = new System.Drawing.Point(951, 4);
+            this.ButtonDeleteDevice.Location = new System.Drawing.Point(958, 4);
             this.ButtonDeleteDevice.Name = "ButtonDeleteDevice";
             this.ButtonDeleteDevice.Name = "ButtonDeleteDevice";
             this.ButtonDeleteDevice.Size = new System.Drawing.Size(64, 23);
             this.ButtonDeleteDevice.Size = new System.Drawing.Size(64, 23);
             this.ButtonDeleteDevice.TabIndex = 15;
             this.ButtonDeleteDevice.TabIndex = 15;
@@ -456,7 +456,7 @@ namespace UAS_PLCDataReader
             this.ButtonSaveDevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonSaveDevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonSaveDevice.Grid = null;
             this.ButtonSaveDevice.Grid = null;
             this.ButtonSaveDevice.HandlerOtherFirst = true;
             this.ButtonSaveDevice.HandlerOtherFirst = true;
-            this.ButtonSaveDevice.Location = new System.Drawing.Point(881, 4);
+            this.ButtonSaveDevice.Location = new System.Drawing.Point(888, 4);
             this.ButtonSaveDevice.Name = "ButtonSaveDevice";
             this.ButtonSaveDevice.Name = "ButtonSaveDevice";
             this.ButtonSaveDevice.Size = new System.Drawing.Size(64, 23);
             this.ButtonSaveDevice.Size = new System.Drawing.Size(64, 23);
             this.ButtonSaveDevice.TabIndex = 14;
             this.ButtonSaveDevice.TabIndex = 14;
@@ -579,7 +579,7 @@ namespace UAS_PLCDataReader
             this.GridDeviceList.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
             this.GridDeviceList.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
             this.DataItemRepositoryItemComboBox1});
             this.DataItemRepositoryItemComboBox1});
             this.GridDeviceList.RowCount = 0;
             this.GridDeviceList.RowCount = 0;
-            this.GridDeviceList.Size = new System.Drawing.Size(1027, 546);
+            this.GridDeviceList.Size = new System.Drawing.Size(1034, 547);
             this.GridDeviceList.TabIndex = 0;
             this.GridDeviceList.TabIndex = 0;
             this.GridDeviceList.TableName = null;
             this.GridDeviceList.TableName = null;
             this.GridDeviceList.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
             this.GridDeviceList.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
@@ -1944,7 +1944,7 @@ namespace UAS_PLCDataReader
             this.Appearance.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128)))));
             this.Appearance.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128)))));
             this.Appearance.Options.UseForeColor = true;
             this.Appearance.Options.UseForeColor = true;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
-            this.ClientSize = new System.Drawing.Size(1033, 711);
+            this.ClientSize = new System.Drawing.Size(1040, 712);
             this.Controls.Add(this.MainTabControl);
             this.Controls.Add(this.MainTabControl);
             this.Controls.Add(this.RibbonNav);
             this.Controls.Add(this.RibbonNav);
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

+ 7 - 3
PLCDataReader/Main.cs

@@ -145,7 +145,7 @@ namespace UAS_PLCDataReader
             ButtonSaveDevice.Grid = GridDeviceList;
             ButtonSaveDevice.Grid = GridDeviceList;
             ButtonDeleteDevice.Grid = GridDeviceList;
             ButtonDeleteDevice.Grid = GridDeviceList;
             //轮询配置界面
             //轮询配置界面
-            GridPollingSetting.GetDataSQL = "SELECT '' POLLSETTINGSTATUSCOLUMN,0 CHECKEDCOLUMN,DPC_MAN,DPC_ID,DPC_DECODE,de_name DPC_DENAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , nvl(DPC_ENABLE,0)DPC_ENABLE,DPC_STATUS,DPC_REMARK,EM_NAME FROM DEVICEPOLLINGCONFIG left join EMPLOYEE on em_code=dpc_man left join device on de_code=dpc_decode WHERE DPC_MAN='" + User.UserCode + "' ORDER BY DPC_ID";
+            GridPollingSetting.GetDataSQL = "SELECT '' POLLSETTINGSTATUSCOLUMN,0 CHECKEDCOLUMN,DPC_MAN,DPC_ID,DPC_DECODE,de_name DPC_DENAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , nvl(DPC_ENABLE,0)DPC_ENABLE,DPC_STATUS,DPC_REMARK,EM_NAME FROM DEVICEPOLLINGCONFIG left join EMPLOYEE on em_code=dpc_man left join device on de_code=dpc_decode WHERE DPC_MAN='" + User.UserCode + "' ORDER BY dpc_decode";
             GridPollingSetting.ID = "DPC_ID";
             GridPollingSetting.ID = "DPC_ID";
             GridPollingSetting.TableName = "DEVICEPOLLINGCONFIG";
             GridPollingSetting.TableName = "DEVICEPOLLINGCONFIG";
             GridPollingSetting.InsertSQL = "insert into DEVICEPOLLINGCONFIG(DPC_ID,DPC_DECODE, DPC_DENAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK,DPC_MAN) values(DEVICEPOLLINGCONFIG_seq.nextval,:DPC_DECODE,:DPC_DENAME,:DPC_INTERVAL ,:DPC_DCCODE ,:DPC_FUNCTION , :DPC_ENABLE,:DPC_STATUS ,:DPC_REMARK,'" + User.UserCode + "')";
             GridPollingSetting.InsertSQL = "insert into DEVICEPOLLINGCONFIG(DPC_ID,DPC_DECODE, DPC_DENAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK,DPC_MAN) values(DEVICEPOLLINGCONFIG_seq.nextval,:DPC_DECODE,:DPC_DENAME,:DPC_INTERVAL ,:DPC_DCCODE ,:DPC_FUNCTION , :DPC_ENABLE,:DPC_STATUS ,:DPC_REMARK,'" + User.UserCode + "')";
@@ -163,7 +163,7 @@ namespace UAS_PLCDataReader
             ButtonNewCommand.Grid = GridCommandSetting;
             ButtonNewCommand.Grid = GridCommandSetting;
 
 
             //设备联网配置界面
             //设备联网配置界面
-            GridDeviceNetSetting.GetDataSQL = "SELECT 0 CHECKEDCOLUMN,DNC_ID,DNC_DECODE,DNC_GATEWAY,DNC_UPPERIP,DNC_PORT,DNC_MAC,DNC_IP,DNC_TYPE FROM DEVICENETCONFIG order by DNC_ID";
+            GridDeviceNetSetting.GetDataSQL = "SELECT 0 CHECKEDCOLUMN,DNC_ID,DNC_DECODE,DNC_GATEWAY,DNC_UPPERIP,DNC_PORT,DNC_MAC,DNC_IP,DNC_TYPE FROM DEVICENETCONFIG order by dnc_decode";
             GridDeviceNetSetting.ID = "dnc_id";
             GridDeviceNetSetting.ID = "dnc_id";
             GridDeviceNetSetting.TableName = "DEVICENETCONFIG";
             GridDeviceNetSetting.TableName = "DEVICENETCONFIG";
             GridDeviceNetSetting.InsertSQL = "insert into DEVICENETCONFIG(DNC_ID,DNC_DECODE,DNC_GATEWAY,DNC_UPPERIP,DNC_PORT,DNC_MAC,DNC_IP,DNC_TYPE) values(DEVICENETCONFIG_SEQ.NEXTVAL,:DNC_DECODE,:DNC_GATEWAY,:DNC_UPPERIP,:DNC_PORT,:DNC_MAC,:DNC_IP,:DNC_TYPE)";
             GridDeviceNetSetting.InsertSQL = "insert into DEVICENETCONFIG(DNC_ID,DNC_DECODE,DNC_GATEWAY,DNC_UPPERIP,DNC_PORT,DNC_MAC,DNC_IP,DNC_TYPE) values(DEVICENETCONFIG_SEQ.NEXTVAL,:DNC_DECODE,:DNC_GATEWAY,:DNC_UPPERIP,:DNC_PORT,:DNC_MAC,:DNC_IP,:DNC_TYPE)";
@@ -581,6 +581,7 @@ namespace UAS_PLCDataReader
                         {
                         {
                             ReturnData[Decode].ItemData = ItemData;
                             ReturnData[Decode].ItemData = ItemData;
                             LogicHandler.UpdateDeviceData(Decode, ItemData);
                             LogicHandler.UpdateDeviceData(Decode, ItemData);
+                            LogicHandler.DoDeviceDataDiffLog(pl.DeviceCode, pl.DeviceName, Command, pl.CommandCode, User.UserName);
                         }
                         }
                         //每次更新轮询的数据
                         //每次更新轮询的数据
                         ReturnData[Decode].ReceiveDataSize += ReceiveCommandByteSize;
                         ReturnData[Decode].ReceiveDataSize += ReceiveCommandByteSize;
@@ -771,7 +772,10 @@ namespace UAS_PLCDataReader
                     //如果是最后一行则循环尾数
                     //如果是最后一行则循环尾数
                     if (j == RowCount - 1)
                     if (j == RowCount - 1)
                     {
                     {
-                        LastRowCount = Count % CountPerRow;
+                        if (Count == CountPerRow)
+                            LastRowCount = Count;
+                        else
+                            LastRowCount = Count % CountPerRow;
                     }
                     }
                     for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
                     for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
                     {
                     {

+ 6 - 2
PLCDataReader/PublicMethod/LogicHandler.cs

@@ -15,8 +15,6 @@ namespace UAS_PLCDataReader.PublicMethod
         public LogicHandler() { }
         public LogicHandler() { }
 
 
         static DataHelper dh = SystemInf.dh;
         static DataHelper dh = SystemInf.dh;
-        //用于拼接SQL
-        static StringBuilder sql = new StringBuilder();
         //用于存放批量执行的SQL
         //用于存放批量执行的SQL
         static List<string> sqls = new List<string>();
         static List<string> sqls = new List<string>();
         /// <summary>
         /// <summary>
@@ -102,6 +100,7 @@ namespace UAS_PLCDataReader.PublicMethod
         /// </summary>
         /// </summary>
         public static void DoDeviceDataDiffLog(string iDeCode, string iDeName, string iCommand, string iCommandFrom, string iMan)
         public static void DoDeviceDataDiffLog(string iDeCode, string iDeName, string iCommand, string iCommandFrom, string iMan)
         {
         {
+            StringBuilder sql = new StringBuilder();
             sql.Clear();
             sql.Clear();
             sql.Append("insert into DeviceRunRecord(drr_id,drr_decode,drr_dename,drr_command,drr_commandfrom,drr_date,drr_doman,drr_remark)");
             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 + "','')");
             sql.Append("values(DeviceRunRecord_seq.nextval,'" + iDeCode + "','" + iDeName + "','" + iCommand + "','" + iCommandFrom + "',sysdate,'" + iMan + "','')");
@@ -117,6 +116,7 @@ namespace UAS_PLCDataReader.PublicMethod
         /// <param name="iOnLine">上线或者离线</param>
         /// <param name="iOnLine">上线或者离线</param>
         public static void DoDevicePollingLog(string iDeCode, bool iOnLine)
         public static void DoDevicePollingLog(string iDeCode, bool iOnLine)
         {
         {
+            StringBuilder sql = new StringBuilder();
             sql.Clear();
             sql.Clear();
             sql.Append("update DEVICEPOLLINGLOG set ");
             sql.Append("update DEVICEPOLLINGLOG set ");
             if (iOnLine)
             if (iOnLine)
@@ -141,6 +141,7 @@ namespace UAS_PLCDataReader.PublicMethod
         /// <param name="iOnLine">上线或者离线</param>
         /// <param name="iOnLine">上线或者离线</param>
         public static void DoDevicePollingLog(string iDeCode, string iSendDataSize, string iReceiveDataSize, bool iOnLine)
         public static void DoDevicePollingLog(string iDeCode, string iSendDataSize, string iReceiveDataSize, bool iOnLine)
         {
         {
+            StringBuilder sql = new StringBuilder();
             sql.Clear();
             sql.Clear();
             sql.Append("update DEVICEPOLLINGLOG set dpg_senddatasize=nvl(dpg_senddatasize,0)+" + iSendDataSize);
             sql.Append("update DEVICEPOLLINGLOG set dpg_senddatasize=nvl(dpg_senddatasize,0)+" + iSendDataSize);
             sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + iReceiveDataSize + ",dpg_count=nvl(dpg_count,0)+1 ");
             sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + iReceiveDataSize + ",dpg_count=nvl(dpg_count,0)+1 ");
@@ -164,6 +165,7 @@ namespace UAS_PLCDataReader.PublicMethod
         /// <param name="iReceiveDataSize">接收数据大小</param>
         /// <param name="iReceiveDataSize">接收数据大小</param>
         public static void DoDevicePollingLog(string iDeCode, string iSendDataSize, string iReceiveDataSize)
         public static void DoDevicePollingLog(string iDeCode, string iSendDataSize, string iReceiveDataSize)
         {
         {
+            StringBuilder sql = new StringBuilder();
             sql.Clear();
             sql.Clear();
             sql.Append("update DEVICEPOLLINGLOG set dpg_status='running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + iSendDataSize);
             sql.Append("update DEVICEPOLLINGLOG set dpg_status='running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + iSendDataSize);
             sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + iReceiveDataSize + ",dpg_count=nvl(dpg_count,0)+1 ");
             sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + iReceiveDataSize + ",dpg_count=nvl(dpg_count,0)+1 ");
@@ -212,6 +214,7 @@ namespace UAS_PLCDataReader.PublicMethod
                         break;
                         break;
                 }
                 }
             }
             }
+            StringBuilder sql = new StringBuilder();
             sql.Clear();
             sql.Clear();
             sql.Append("update DeviceRunstatus set dr_qty={0},dr_okqty={1},dr_TEMPERATURE={2},");
             sql.Append("update DeviceRunstatus set dr_qty={0},dr_okqty={1},dr_TEMPERATURE={2},");
             sql.Append("dr_value1={3},dr_value2={4},dr_value3={5},dr_updatedate=sysdate where dr_decode='" + Decode + "'");
             sql.Append("dr_value1={3},dr_value2={4},dr_value3={5},dr_updatedate=sysdate where dr_decode='" + Decode + "'");
@@ -227,6 +230,7 @@ namespace UAS_PLCDataReader.PublicMethod
         /// <param name="iDestatus"></param>
         /// <param name="iDestatus"></param>
         public static void UpdateDeviceStatus(string iDecode, string iDename, string iDestatus)
         public static void UpdateDeviceStatus(string iDecode, string iDename, string iDestatus)
         {
         {
+            StringBuilder sql = new StringBuilder();
             sql.Clear();
             sql.Clear();
             sql.Append("MERGE INTO DeviceRunstatus alias1 USING (select '" + iDecode + "' dr_decode from  dual) alias2 ");
             sql.Append("MERGE INTO DeviceRunstatus alias1 USING (select '" + iDecode + "' dr_decode from  dual) alias2 ");
             sql.Append("ON (alias1.dr_decode=alias2.dr_decode) WHEN MATCHED THEN  UPDATE  SET dr_startdate =sysdate,Dr_runstatus='" + iDestatus + "' ");
             sql.Append("ON (alias1.dr_decode=alias2.dr_decode) WHEN MATCHED THEN  UPDATE  SET dr_startdate =sysdate,Dr_runstatus='" + iDestatus + "' ");