Browse Source

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

Hcsy 7 years ago
parent
commit
73a65b02ce

+ 11 - 14
PLCDataReader/Main.Designer.cs

@@ -422,7 +422,6 @@ namespace UAS_PLCDataReader
             this.ComBoxDeviceListMan.Size = new System.Drawing.Size(100, 22);
             this.ComBoxDeviceListMan.TabIndex = 12;
             this.ComBoxDeviceListMan.Visible = false;
-            this.ComBoxDeviceListMan.EditValueChanged += new System.EventHandler(this.ComBoxDeviceListMan_EditValueChanged);
             // 
             // searchLookUpEdit1View
             // 
@@ -601,8 +600,6 @@ namespace UAS_PLCDataReader
             this.de_runstatus.Caption = "运行状态";
             this.de_runstatus.FieldName = "DE_RUNSTATUS";
             this.de_runstatus.Name = "de_runstatus";
-            this.de_runstatus.Visible = true;
-            this.de_runstatus.VisibleIndex = 3;
             // 
             // de_stepcode
             // 
@@ -610,7 +607,7 @@ namespace UAS_PLCDataReader
             this.de_stepcode.FieldName = "DE_STEPCODE";
             this.de_stepcode.Name = "de_stepcode";
             this.de_stepcode.Visible = true;
-            this.de_stepcode.VisibleIndex = 4;
+            this.de_stepcode.VisibleIndex = 3;
             // 
             // de_stepname
             // 
@@ -618,7 +615,7 @@ namespace UAS_PLCDataReader
             this.de_stepname.FieldName = "DE_STEPNAME";
             this.de_stepname.Name = "de_stepname";
             this.de_stepname.Visible = true;
-            this.de_stepname.VisibleIndex = 6;
+            this.de_stepname.VisibleIndex = 5;
             // 
             // de_sourcecode
             // 
@@ -626,7 +623,7 @@ namespace UAS_PLCDataReader
             this.de_sourcecode.FieldName = "DE_SOURCECODE";
             this.de_sourcecode.Name = "de_sourcecode";
             this.de_sourcecode.Visible = true;
-            this.de_sourcecode.VisibleIndex = 5;
+            this.de_sourcecode.VisibleIndex = 4;
             // 
             // de_indate
             // 
@@ -644,7 +641,7 @@ namespace UAS_PLCDataReader
             this.de_spec.FieldName = "DE_SPEC";
             this.de_spec.Name = "de_spec";
             this.de_spec.Visible = true;
-            this.de_spec.VisibleIndex = 7;
+            this.de_spec.VisibleIndex = 6;
             // 
             // de_inman
             // 
@@ -652,7 +649,7 @@ namespace UAS_PLCDataReader
             this.de_inman.FieldName = "DE_INMAN";
             this.de_inman.Name = "de_inman";
             this.de_inman.Visible = true;
-            this.de_inman.VisibleIndex = 8;
+            this.de_inman.VisibleIndex = 7;
             // 
             // de_vendcode
             // 
@@ -672,7 +669,7 @@ namespace UAS_PLCDataReader
             this.de_address.FieldName = "DE_ADDRESS";
             this.de_address.Name = "de_address";
             this.de_address.Visible = true;
-            this.de_address.VisibleIndex = 9;
+            this.de_address.VisibleIndex = 8;
             // 
             // de_linecode
             // 
@@ -680,7 +677,7 @@ namespace UAS_PLCDataReader
             this.de_linecode.FieldName = "DE_LINECODE";
             this.de_linecode.Name = "de_linecode";
             this.de_linecode.Visible = true;
-            this.de_linecode.VisibleIndex = 10;
+            this.de_linecode.VisibleIndex = 9;
             // 
             // de_wccode
             // 
@@ -688,7 +685,7 @@ namespace UAS_PLCDataReader
             this.de_wccode.FieldName = "DE_WCCODE";
             this.de_wccode.Name = "de_wccode";
             this.de_wccode.Visible = true;
-            this.de_wccode.VisibleIndex = 11;
+            this.de_wccode.VisibleIndex = 10;
             // 
             // de_item1
             // 
@@ -697,7 +694,7 @@ namespace UAS_PLCDataReader
             this.de_item1.FieldName = "DE_ITEM1";
             this.de_item1.Name = "de_item1";
             this.de_item1.Visible = true;
-            this.de_item1.VisibleIndex = 12;
+            this.de_item1.VisibleIndex = 11;
             // 
             // DataItemRepositoryItemComboBox1
             // 
@@ -713,7 +710,7 @@ namespace UAS_PLCDataReader
             this.de_item2.FieldName = "DE_ITEM2";
             this.de_item2.Name = "de_item2";
             this.de_item2.Visible = true;
-            this.de_item2.VisibleIndex = 13;
+            this.de_item2.VisibleIndex = 12;
             // 
             // de_item3
             // 
@@ -722,7 +719,7 @@ namespace UAS_PLCDataReader
             this.de_item3.FieldName = "DE_ITEM3";
             this.de_item3.Name = "de_item3";
             this.de_item3.Visible = true;
-            this.de_item3.VisibleIndex = 14;
+            this.de_item3.VisibleIndex = 13;
             // 
             // PageCommandSet
             // 

+ 11 - 8
PLCDataReader/Main.cs

@@ -137,10 +137,10 @@ namespace UAS_PLCDataReader
             //ButtonSavePolling.Grid = GridPolling;
             //ButtonAddPolling.Grid = GridPolling;
             //轮询配置界面
-            GridPollingSetting.GetDataSQL = "SELECT '' POLLSETTINGSTATUSCOLUMN,0 CHECKEDCOLUMN,DPC_MAN,DPC_ID,DPC_DECODE,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 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_ID";
             GridPollingSetting.ID = "DPC_ID";
             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_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_INTERVAL ,:DPC_DCCODE ,:DPC_FUNCTION , :DPC_ENABLE,:DPC_STATUS ,:DPC_REMARK,'" + User.UserCode + "')";
             ButtonSaveCommandSet.Grid = GridPollingSetting;
             ButtonNewCommandSet.Grid = GridPollingSetting;
             ButtonDeleteCommandSet.Grid = GridPollingSetting;
@@ -235,11 +235,6 @@ namespace UAS_PLCDataReader
             RefreshDeviceData();
         }
 
-        private void ComBoxDeviceListMan_EditValueChanged(object sender, EventArgs e)
-        {
-
-        }
-
         private void RefreshDeviceData()
         {
             GridDeviceList.GetDataSQL = DeviceListQuerySQL.ToString();
@@ -517,13 +512,21 @@ 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)
+                    //返回的参数个数和定义的参数个数相等或者小于的时候
+                    if (Arr.Length == DC.Rows.Count|| DC.Rows.Count > Arr.Length)
                     {
                         for (int i = 0; i < Arr.Length; i++)
                         {
                             ItemData.Add(DC.Rows[i]["dc_type"].ToString(), Arr[i].ToString());
                         }
                     }
+                    else
+                    {
+                        for (int i = 0; i < DC.Rows.Count; i++)
+                        {
+                            ItemData.Add(DC.Rows[i]["dc_type"].ToString(), Arr[i].ToString());
+                        }
+                    }
                     if (!ReturnData.ContainsKey(Decode))
                     {
                         //添加本地数据内容

+ 0 - 2
PLCDataReader/PublicMethod/BaseUtil.cs

@@ -14,8 +14,6 @@ namespace UAS_PLCDataReader.PublicMethod
 {
     class BaseUtil
     {
-
-
         [DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
         public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
 

+ 1 - 3
PLCDataReader/PublicMethod/ModBusTCPClient.cs

@@ -1,9 +1,7 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Net;
 using System.Net.Sockets;
-using System.Text;
 using UAS_PLCDataReader.DataOperate;
 
 namespace UAS_PLCDataReader.PublicMethod
@@ -18,7 +16,7 @@ namespace UAS_PLCDataReader.PublicMethod
 
         private bool receiveData;
 
-        private DataOperate.DataHelper dh;
+        private DataHelper dh;
 
         private Dictionary<string, string> returnvalue = new Dictionary<string, string>();
 

+ 0 - 1
PLCDataReader/PublicMethod/ModeBusTCPServer.cs

@@ -12,7 +12,6 @@ namespace UAS_PLCDataReader.PublicMethod
     class ModeBusTCPServer
     {
 
-
         private bool isOpen = false;
 
         private bool receiveData;

+ 65 - 24
UAS-出货标签管理(泽天)/PublicMethod/DataHelper.cs

@@ -53,7 +53,7 @@ namespace UAS_LabelMachine
         //泽天FTP内网
         public static readonly string FTPAdress = "ftp://10.2.10.241|uas|Lz201478c";
         //Oracle端口
-        public static readonly string OraclePort = "1521";  
+        public static readonly string OraclePort = "1521";
         //需要显示的账套
         public static readonly string Masters = "ZT_TEST,ZT";
         //用户选择的数据库的连接字符串
@@ -132,34 +132,30 @@ namespace UAS_LabelMachine
             DataTable dt = new DataTable();
             string sql = "select " + Field + " from " + TableName + " where " + Condition;
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter();
             ad.SelectCommand = command;
             try
             {
                 ad.Fill(dt);
-                ReconnectTime = 0;
             }
             catch (Exception)
             {
-                if (ReconnectTime == 0)
-                {
-                    ReconnectTime++;
-                    connection = new OracleConnection(DBConnectionString);
-                    //成功执行后将重复连接数置为0
-                    dt = (DataTable)getFieldDataByCondition(TableName, Field, Condition);
-                }
+                connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command = new OracleCommand(sql, connection);
+                ad = new OracleDataAdapter();
+                ad.SelectCommand = command;
+                ad.Fill(dt);
             }
-
+            ad.Dispose();
+            command.Dispose();
             if (dt.Rows.Count > 0)
             {
-                ad.Dispose();
-                command.Dispose();
                 return dt.Rows[0][0];
             }
             else
             {
-                ad.Dispose();
-                command.Dispose();
                 return "";
             }
         }
@@ -804,6 +800,7 @@ namespace UAS_LabelMachine
         {
             object result = null;
             command = new OracleCommand(SQL, connection);
+            Reconnect(command);
             //用来拼接参数的
             if (names.Length > 0)
             {
@@ -828,30 +825,65 @@ namespace UAS_LabelMachine
                     }
                 }
                 for (int i = 0; i < addpar.Length; i++)
-                {
                     command.Parameters.Add(new OracleParameter(addpar[i].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
-                }
             }
+
             switch (Type.ToUpper())
             {
                 case "SELECT":
-                    result = new DataTable();
                     OracleDataAdapter ad = new OracleDataAdapter(command);
-                    ad.Fill((DataTable)result);
-                    ad.Dispose();
-                    //成功执行后将重复连接数置为0
+                    result = new DataTable();
+                    try
+                    {
+                        ad.Fill((DataTable)result);
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command = new OracleCommand(SQL, connection);
+                        ad = new OracleDataAdapter();
+                        ad.SelectCommand = command;
+                        ad.Fill((DataTable)result);
+                    }
                     break;
                 case "DELETE":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        command.Connection = new OracleConnection(DBConnectionString);
+                        command.Connection.Open();
+                        result = command.ExecuteNonQuery();
+                    }
                     break;
                 case "UPDATE":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        command.Connection = new OracleConnection(DBConnectionString);
+                        command.Connection.Open();
+                        result = command.ExecuteNonQuery();
+                    }
                     break;
                 case "INSERT":
-                    command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        command.Connection = new OracleConnection(DBConnectionString);
+                        command.Connection.Open();
+                        result = command.ExecuteNonQuery();
+                    }
                     break;
             }
-
             command.Dispose();
             return result;
         }
@@ -1200,5 +1232,14 @@ namespace UAS_LabelMachine
             }
             return param;
         }
+
+        private void Reconnect(OracleCommand cmd)
+        {
+            if (cmd.Connection.State == ConnectionState.Closed)
+            {
+                cmd.Connection.Open();
+                LogManager.DoLog("超时重连");
+            }
+        }
     }
 }

+ 2 - 2
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -1675,12 +1675,12 @@ namespace UAS_LabelMachine
                     List<string> MidBoxCode = new List<string>();
                     List<string> PIBID = new List<string>();
                     List<string> PIBOUTBOXCODE1 = new List<string>();
-                    DataTable dt1 = (DataTable)dh.ExecuteSql("select pib_id,pib_prodcode from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' and pib_outboxcode1 is null order by  to_number(pib_id)", "select");
+                    DataTable dt1 = (DataTable)dh.ExecuteSql("select pib_id,pib_prodcode,pd_custprodcode from prodiobarcode left join prodiodetail on pib_pdid=pd_id where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' and pib_outboxcode1 is null order by  to_number(pib_id)", "select");
                     //如果不是10的整数倍则为尾盒
                     int tencount = 0;
                     for (int j = 0; j < dt1.Rows.Count; j++)
                     {
-                        if (tencount % MidboxCapacity.Value == 0 || (dt1.Rows[j]["pib_prodcode"].ToString() != dt1.Rows[j - 1]["pib_prodcode"].ToString()))
+                        if (tencount % MidboxCapacity.Value == 0 || (dt1.Rows[j]["pib_prodcode"].ToString() != dt1.Rows[j - 1]["pib_prodcode"].ToString())|| (dt1.Rows[j]["pd_custprodcode"].ToString() != dt1.Rows[j - 1]["pd_custprodcode"].ToString()))
                         {
                             pib_outboxcode1 = pib_outboxcode1 + 1;
                             MaxNum = MaxNum + 1;

+ 1 - 1
UAS_CheckWork/Tools/DataHelper.cs

@@ -9,7 +9,7 @@ namespace Check.DataOperate
     class DataHelper
     {
         //系统默认的的连接字符串
-        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DOBOT_YJ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=oa.dobot.cc)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DARKEN_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=darkenergy1.gicp.net)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         //用户选择的数据库的连接字符串
         public static string DBConnectionString;
         public static OracleConnection connection = null;