瀏覽代碼

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

Hcsy 6 年之前
父節點
當前提交
25b69f4a54

+ 18 - 18
UAS-MES/FunctionCode/Make/Make_Repair.cs

@@ -254,26 +254,12 @@ namespace UAS_MES.Make
                             sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
                             sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
                             sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "' union select '" + firstsn + "' from dual)) ");
-                            sql.Append("and cm_craftcode='" + cr_code.Text + "'and nvl(cm_lastdeco,0)<>0 group by cm_craftcode,cm_stepcode,cm_soncode having ");
+                            sql.Append("and cm_craftcode='" + cr_code.Text + "'  group by cm_craftcode,cm_stepcode,cm_soncode having ");
                             sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
                             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             if (dt.Rows.Count > 0)
                             {
-                                //如果本工序包含老化则默认选择本工序,否则选择上料的后一道工序
-                                if (dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_ifburnin,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + dt.Rows[0]["cm_stepcode"].ToString() + "'").ToString() != "0")
-                                    cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
-                                else
-                                {
-                                    string nextstep = LogicHandler.GetNextStep(dt.Rows[0]["cm_craftcode"].ToString(), dt.Rows[0]["cm_stepcode"].ToString(), ms_prodcode.Text);
-                                    if (ms_paststep.Contains(nextstep))
-                                    {
-                                        cdstepcode = nextstep;
-                                    }
-                                    else
-                                    {
-                                        cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
-                                    }
-                                }
+                                cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
                             }
                             else
                             {
@@ -281,12 +267,26 @@ namespace UAS_MES.Make
                                 sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
                                 sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
                                 sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "'  union select '" + firstsn + "' from dual)) ");
-                                sql.Append("and cm_craftcode='" + cr_code.Text + "' group by cm_craftcode,cm_stepcode,cm_soncode having ");
+                                sql.Append("and cm_craftcode='" + cr_code.Text + "' and nvl(cm_lastdeco,0)<>0 group by cm_craftcode,cm_stepcode,cm_soncode having ");
                                 sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
                                 dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                                 if (dt.Rows.Count > 0)
                                 {
-                                    cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
+                                    //如果本工序包含老化则默认选择本工序,否则选择上料的后一道工序
+                                    if (dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_ifburnin,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + dt.Rows[0]["cm_stepcode"].ToString() + "'").ToString() != "0")
+                                        cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
+                                    else
+                                    {
+                                        string nextstep = LogicHandler.GetNextStep(dt.Rows[0]["cm_craftcode"].ToString(), dt.Rows[0]["cm_stepcode"].ToString(), ms_prodcode.Text);
+                                        if (ms_paststep.Contains(nextstep))
+                                        {
+                                            cdstepcode = nextstep;
+                                        }
+                                        else
+                                        {
+                                            cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
+                                        }
+                                    }
                                 }
                             }
                             if (cdstepcode == "")

+ 0 - 16
UAS_DeviceMonitor/Main.Designer.cs

@@ -134,7 +134,6 @@ namespace UAS_DeviceMonitor
             this.pl_remark = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageDeviceStatus = new DevExpress.XtraTab.XtraTabPage();
             this.PanelDeviceStatus = new DevExpress.XtraEditors.XtraScrollableControl();
-            this.pictureEdit1 = new DevExpress.XtraEditors.PictureEdit();
             this.PageWorkCenterStatus = new DevExpress.XtraTab.XtraTabPage();
             this.GridWorkCenterStatus = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewWorkCenterStatus = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
@@ -166,8 +165,6 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).BeginInit();
             this.PageDeviceStatus.SuspendLayout();
-            this.PanelDeviceStatus.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureEdit1.Properties)).BeginInit();
             this.PageWorkCenterStatus.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).BeginInit();
@@ -1202,22 +1199,12 @@ namespace UAS_DeviceMonitor
             // 
             // PanelDeviceStatus
             // 
-            this.PanelDeviceStatus.Controls.Add(this.pictureEdit1);
             this.PanelDeviceStatus.Dock = System.Windows.Forms.DockStyle.Fill;
             this.PanelDeviceStatus.Location = new System.Drawing.Point(0, 0);
             this.PanelDeviceStatus.Name = "PanelDeviceStatus";
             this.PanelDeviceStatus.Size = new System.Drawing.Size(1027, 577);
             this.PanelDeviceStatus.TabIndex = 0;
             // 
-            // pictureEdit1
-            // 
-            this.pictureEdit1.Location = new System.Drawing.Point(502, 126);
-            this.pictureEdit1.MenuManager = this.RibbonNav;
-            this.pictureEdit1.Name = "pictureEdit1";
-            this.pictureEdit1.Properties.ShowCameraMenuItem = DevExpress.XtraEditors.Controls.CameraMenuItemVisibility.Auto;
-            this.pictureEdit1.Size = new System.Drawing.Size(100, 96);
-            this.pictureEdit1.TabIndex = 0;
-            // 
             // PageWorkCenterStatus
             // 
             this.PageWorkCenterStatus.Controls.Add(this.GridWorkCenterStatus);
@@ -1305,8 +1292,6 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).EndInit();
             this.PageDeviceStatus.ResumeLayout(false);
-            this.PanelDeviceStatus.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.pictureEdit1.Properties)).EndInit();
             this.PageWorkCenterStatus.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).EndInit();
@@ -1420,7 +1405,6 @@ namespace UAS_DeviceMonitor
         private AutoDataGridControl GridWorkCenterStatus;
         private GridViewWithSerialNum GridViewWorkCenterStatus;
         private XtraScrollableControl PanelDeviceStatus;
-        private PictureEdit pictureEdit1;
         private System.Windows.Forms.ToolTip CommonTipController;
     }
 }

+ 50 - 17
UAS_DeviceMonitor/Main.cs

@@ -389,21 +389,65 @@ namespace UAS_DeviceMonitor
         {
             if (PageDeviceStatus.PageVisible)
             {
-                ShowDeviceStatus();
-                TimerDeviceStatus.Start();
+                DataTable dt = (DataTable)dh.ExecuteSql("select distinct de_code,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code order by de_code", "select");
+                //界面重新展示时如过数量不一致则重新绘制
+                if (PanelDeviceStatus.Controls.Count != dt.Rows.Count)
+                {
+                    int CountPerRow = PanelDeviceStatus.Width / 110;
+                    int RightPadding = PanelDeviceStatus.Width % 110;
+                    int Count = dt.Rows.Count;
+                    int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
+                    int LastRowCount = 0;
+                    for (int i = 0; i < PanelDeviceStatus.Controls.Count; i++)
+                    {
+                        PanelDeviceStatus.Controls[i].Dispose();
+                    }
+                    for (int j = 0; j < RowCount; j++)
+                    {
+                        //如果是最后一行则循环尾数
+                        if (j == RowCount - 1)
+                        {
+                            LastRowCount = Count % CountPerRow;
+                        }
+                        for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
+                        {
+                            PictureEditWithText pic = new PictureEditWithText();
+                            pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j;
+                            pic.Anchor = AnchorStyles.Left;
+                            pic.Anchor = AnchorStyles.Top;
+                            pic.Picedit.Properties.SizeMode = PictureSizeMode.Squeeze;
+                            if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
+                            {
+                                CommonTipController.SetToolTip(pic.Picedit, "离线");
+                                pic.Picedit.Image = Properties.Resources.network_offline;
+                            }
+                            else
+                            {
+                                CommonTipController.SetToolTip(pic.Picedit, "在线");
+                                pic.Picedit.Image = Properties.Resources.net_connected;
+                            }
+                            pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
+                            pic.Picedit.BorderStyle = BorderStyles.HotFlat;
+                            pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 130);
+                            PanelDeviceStatus.Controls.Add(pic);
+                        }
+                    }
+                    BaseUtil.CleanMemory();
+                    TimerDeviceStatus.Start();
+                }
             }
         }
 
         //重新展示设备图像界面
         private void ShowDeviceStatus()
         {
-            DataTable dt = (DataTable)dh.ExecuteSql("select * from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code where rownum<4 order by de_code", "select");
+            DataTable dt = (DataTable)dh.ExecuteSql("select distinct de_code,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code order by de_code", "select");
             int CountPerRow = PanelDeviceStatus.Width / 110;
             int RightPadding = PanelDeviceStatus.Width % 110;
             int Count = dt.Rows.Count;
             int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
-            PanelDeviceStatus.Controls.Clear();
             int LastRowCount = 0;
+            //只更换现有控件的图片,不必重新绘制控件
             for (int j = 0; j < RowCount; j++)
             {
                 //如果是最后一行则循环尾数
@@ -413,25 +457,14 @@ namespace UAS_DeviceMonitor
                 }
                 for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
                 {
-                    PictureEditWithText pic = new PictureEditWithText();
-                    pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
-                    pic.Anchor = AnchorStyles.Left;
-                    pic.Anchor = AnchorStyles.Top;
-                    pic.Picedit.Properties.SizeMode = PictureSizeMode.Squeeze;
                     if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
                     {
-                        CommonTipController.SetToolTip(pic.Picedit, "离线");
-                        pic.Picedit.Image = Properties.Resources.network_offline;
+                        (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.network_offline;
                     }
                     else
                     {
-                        CommonTipController.SetToolTip(pic.Picedit, "在线");
-                        pic.Picedit.Image = Properties.Resources.net_connected;
+                        (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.net_connected;
                     }
-                    pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
-                    pic.Picedit.BorderStyle = BorderStyles.HotFlat;
-                    pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 130);
-                    PanelDeviceStatus.Controls.Add(pic);
                 }
             }
         }

+ 16 - 0
UAS_DeviceMonitor/PublicMethod/BaseUtil.cs

@@ -2,13 +2,19 @@
 using DevExpress.XtraEditors.Repository;
 using System;
 using System.Data;
+using System.Runtime.InteropServices;
 using System.Text;
+using System.Windows.Forms;
 using UAS_DeviceMonitor.DataOperate;
 
 namespace UAS_DeviceMonitor.PublicMethod
 {
     class BaseUtil
     {
+
+        [DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
+        public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
+
         public static void FillComBoxEditWidthDataTable(RepositoryItemComboBox combo, string TextField, string ValueField, DataTable dt)
         {
             combo.Items.Clear();
@@ -95,5 +101,15 @@ namespace UAS_DeviceMonitor.PublicMethod
             }
             return returnStr;
         }
+
+        public static void CleanMemory()
+        {
+            GC.Collect();
+            GC.WaitForPendingFinalizers();
+            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
+            {
+                SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
+            }
+        }
     }
 }