Explorar o código

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

Hcsy %!s(int64=8) %!d(string=hai) anos
pai
achega
d2182b8cca

+ 12 - 100
MES接口/DataHelper.cs

@@ -2,7 +2,6 @@
 using System;
 using System.Data;
 using System.Text;
-using System.Configuration;
 using System.Collections.Generic;
 
 namespace MES_Interface
@@ -13,12 +12,11 @@ namespace MES_Interface
     class DataHelper
     {
         //系统默认的的连接字符串
-        private string ConnectionStrings = ConfigurationManager.ConnectionStrings["MES"].ConnectionString;
+        private string ConnectionStrings = "";
         //用户选择的数据库的连接字符串
         public static OracleConnection connection = null;
         //用户选择的数据库的连接字符串
         OracleCommand command = null;
-        int ReconnectTime = 0;
         /// <summary>
         /// 执行构造函数的时候打开数据库的链接
         /// </summary>
@@ -26,13 +24,13 @@ namespace MES_Interface
         {
             try
             {
-                ftpOperater ftp = new ftpOperater();
-                if (Environment == "Formal")
+                if (Environment.ToUpper() == "FORMAl")
                 {
-                    ConnectionStrings= Encryption.DecryptStr((ftp.GetFileContent("db.config")));
+                    ConnectionStrings = "Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=117.25.180.218)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
                 }
-                else if (Environment == "Test") {
-
+                else if (Environment.ToUpper() == "TEST")
+                {
+                    ConnectionStrings = "Password=select!#%*(;User ID=MES_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=117.25.180.218)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
                 }
                 connection = new OracleConnection(ConnectionStrings);
                 connection.Open();
@@ -41,20 +39,6 @@ namespace MES_Interface
             {
             }
         }
-        /// <summary>
-        /// 根据表名获取该表字段数据类型
-        /// </summary>
-        public DataTable GetColumnDataType(string TableName)
-        {
-            DataTable dt = new DataTable();
-            command = new OracleCommand("select Column_Name,Data_Type from cols where TABLE_name=upper('" + TableName + "')", connection);
-            Reconnect(command);
-            OracleDataAdapter ad = new OracleDataAdapter(command);
-            ad.Fill(dt);
-            ad.Dispose();
-            command.Dispose();
-            return dt;
-        }
 
         /// <summary>
         /// 获取第一行第一列的信息
@@ -80,42 +64,6 @@ namespace MES_Interface
             }
         }
 
-        /// <summary>
-        /// 执行打印的SQL
-        /// </summary>
-        /// <param name="SQL">SQL语句</param>
-        /// <param name="Parameters">动态添加的参数,主要根据条码枪扫描获取</param>
-        /// <returns></returns>
-        public object ExecutePrintSQL(string SQL, params string[] Parameters)
-        {
-            //按照?拆分数据,然后以:Param替换问号,同时添加参数
-            string[] Param = SQL.Split('?');
-            int ParamNum = Param.Length - 1;
-            //条码打印必然存在需要维护的参数
-            if (ParamNum > 0)
-            {
-                StringBuilder sb = new StringBuilder();
-                for (int i = 0; i < ParamNum; i++)
-                {
-                    sb.Append(Param[i] + ":Param" + i);
-                }
-                command = new OracleCommand(sb.ToString(), connection);
-
-                for (int i = 0; i < ParamNum; i++)
-                {
-                    command.Parameters.Add("Param" + i, OracleDbType.Varchar2, Parameters[i], ParameterDirection.Input);
-                }
-
-                OracleDataAdapter ad = new OracleDataAdapter(command);
-                DataTable dt = new DataTable();
-                ad.Fill(dt);
-                ad.Dispose();
-                command.Dispose();
-                return dt;
-            }
-            return "参数错误,请检查SQL语句";
-        }
-
         /// <summary>
         /// 获取指定表的记录的条数 ,带条件
         /// </summary>
@@ -169,22 +117,6 @@ namespace MES_Interface
             return dt;
         }
 
-        /// <summary>
-        /// 将DataTable导入到指定的表中
-        /// </summary>
-        /// <param name="DataTable"></param>
-        /// <param name="TableName"></param>
-        public void InsertDataTable(DataTable DataTable, string TableName)
-        {
-            for (int i = 0; i < DataTable.Rows.Count; i++)
-            {
-                for (int j = 0; j < DataTable.Columns.Count; j++)
-                {
-
-                }
-            }
-        }
-
         /// <summary>
         /// 按分页获取数据
         /// </summary>
@@ -565,7 +497,6 @@ namespace MES_Interface
             Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             DataTable dt = new DataTable();
-            
             ad.Fill(dt);
             ad.Dispose();
             command.Dispose();
@@ -609,29 +540,13 @@ namespace MES_Interface
                 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();
-                    try
-                    {
-                        OracleDataAdapter ad = new OracleDataAdapter(command);
-                        ad.Fill((DataTable)result);
-                        ad.Dispose();
-                        //成功执行后将重复连接数置为0
-                        ReconnectTime = 0;
-                    }
-                    catch (Exception)
-                    {
-                        if (ReconnectTime == 0)
-                        {
-                            //重置的数据库链接后只执行一次
-                            ReconnectTime = ReconnectTime + 1;
-                            connection = new OracleConnection(ConnectionStrings);
-                            result = ExecuteSql(SQL, Type, names);
-                        }
-                    }
+                    OracleDataAdapter ad = new OracleDataAdapter(command);
+                    ad.Fill((DataTable)result);
+                    ad.Dispose();
                     break;
                 case "DELETE":
                     result = command.ExecuteNonQuery();
@@ -663,7 +578,6 @@ namespace MES_Interface
         {
             DataTable dt = new DataTable();
             string sql = "select distinct count('" + Field + "') from " + TableName;
-            
             command = new OracleCommand(sql, connection);
             Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
@@ -694,7 +608,6 @@ namespace MES_Interface
         public void DeleteDataByID(string TableName, string ID, string[] DeleteID)
         {
             string sql = "delete from " + TableName + " where " + ID + " =:DeleteID";
-            
             command = new OracleCommand(sql, connection);
             Reconnect(command);
             command.ArrayBindCount = DeleteID.Length;
@@ -824,7 +737,6 @@ namespace MES_Interface
             command = new OracleCommand(sql, connection);
             Reconnect(command);
             command.ArrayBindCount = names[1].Length;
-            
             //因为第一个数组保存的是参数的名称,所以循环从1而不是0开始
             //将第一个数组的下标固定为0作为循环添加的参数的名称
             for (int i = 1; i <= names[0].Length; i++)
@@ -935,7 +847,6 @@ namespace MES_Interface
         public string UpdateByCondition(string TableName, string update, string condition)
         {
             string sql = "update " + TableName + " set " + update + " where " + condition;
-            
             command = new OracleCommand(sql, connection);
             Reconnect(command);
             command.ExecuteNonQuery();
@@ -977,9 +888,8 @@ namespace MES_Interface
             {
                 foreach (string sql in SQL)
                 {
-                    if (!String.IsNullOrEmpty(sql))
+                    if (!string.IsNullOrEmpty(sql))
                     {
-                        
                         command.CommandText = sql;
                         command.ExecuteNonQuery();
                     }
@@ -1092,7 +1002,9 @@ namespace MES_Interface
         private void Reconnect(OracleCommand cmd)
         {
             if (cmd.Connection.State == ConnectionState.Closed)
+            {
                 cmd.Connection.Open();
+            }
         }
     }
 }

+ 0 - 50
MES接口/Encryption.cs

@@ -1,50 +0,0 @@
-using System;
-using System.IO;
-using System.Security.Cryptography;
-using System.Text;
-
-namespace MES_Interface
-{
-    class Encryption
-    {
-        private static string encryptKey = "DBDB";
-
-        public static string EncryptStr(string str)
-        {
-            DESCryptoServiceProvider descsp = new DESCryptoServiceProvider();   //实例化加/解密类对象   
-
-            byte[] key = Encoding.Unicode.GetBytes(encryptKey); //定义字节数组,用来存储密钥    
-
-            byte[] data = Encoding.Unicode.GetBytes(str);//定义字节数组,用来存储要加密的字符串  
-
-            MemoryStream MStream = new MemoryStream(); //实例化内存流对象      
-
-            //使用内存流实例化加密流对象   
-            CryptoStream CStream = new CryptoStream(MStream, descsp.CreateEncryptor(key, key), CryptoStreamMode.Write);
-
-            CStream.Write(data, 0, data.Length);  //向加密流中写入数据      
-
-            CStream.FlushFinalBlock();              //释放加密流      
-            return Convert.ToBase64String(MStream.ToArray());//返回加密后的字符串  
-        }
-
-        public static string DecryptStr(string str)
-        {
-            DESCryptoServiceProvider descsp = new DESCryptoServiceProvider();   //实例化加/解密类对象    
-
-            byte[] key = Encoding.Unicode.GetBytes(encryptKey); //定义字节数组,用来存储密钥    
-
-            byte[] data = Convert.FromBase64String(str);//定义字节数组,用来存储要解密的字符串  
-
-            MemoryStream MStream = new MemoryStream(); //实例化内存流对象      
-
-            //使用内存流实例化解密流对象       
-            CryptoStream CStream = new CryptoStream(MStream, descsp.CreateDecryptor(key, key), CryptoStreamMode.Write);
-            CStream.Write(data, 0, data.Length);      //向解密流中写入数据     
-
-            CStream.FlushFinalBlock();               //释放解密流      
-
-            return Encoding.Unicode.GetString(MStream.ToArray());       //返回解密后的字符串  
-        }
-    }
-}

+ 288 - 223
MES接口/LogicHandler.cs

@@ -27,24 +27,14 @@ namespace MES_Interface
         /// <returns></returns>
         public bool CheckCurrentStep(string iSnCode, string iMakeCode, string iSourceCode, out string oErrMessage)
         {
-            if (GetMakeInfo(iSnCode, out iMakeCode, out oErrMessage))
-            {
-                string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'").ToString();
-                string sourcestepcode = GetStepCodeBySource(iSourceCode);
-                if (nextstepcode == "")
-                {
-                    oErrMessage = "当前序列号已无可执行工序";
-                    return false;
-                }
-                if (nextstepcode == sourcestepcode)
-                    return true;
-                else
-                {
-                    oErrMessage = "资源" + iSourceCode + "对应的工序是" + sourcestepcode + ",序列号" + iSnCode + "当前工序是" + nextstepcode;
-                    return false;
-                }
-            }
-            else return false;
+            oErrMessage = "";
+            string[] param = new string[] { iSnCode, iMakeCode, iSourceCode, oErrMessage };
+            dh.CallProcedure("CS_CHECKSTEPSNANDMACODE", ref param);
+            oErrMessage = param[3];
+            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
+                return true;
+            else
+                return false;
         }
 
         /// <summary>
@@ -70,6 +60,78 @@ namespace MES_Interface
             }
         }
 
+
+        /// <summary>
+        /// 判断下一工序是否是送检工序
+        /// </summary>
+        /// <returns></returns>
+        public bool CheckNextStepIfQC(string iSnCode, string iMakeCode, string iStepCode, string iCraftCode, string iUserName, out string oErrorMessage)
+        {
+            oErrorMessage = "";
+            string IfQC = dh.getFieldDataByCondition("craft left join  craftdetail on cd_crid=cr_id", "cd_ifoqc", "cr_code='" + iCraftCode + "' and cd_stepcode='" + iStepCode + "'").ToString();
+            if (IfQC != "0" && IfQC != "")
+            {
+                DataTable dt = dh.getFieldsDataByCondition("make left join product on ma_prodcode=pr_code", new string[] { "ma_nowcheckqty", "pr_qcbatchqty", "ma_checkno", "ma_prodcode", "pr_qualmethod" }, "ma_code='" + iMakeCode + "'");
+                if (dt.Rows.Count > 0)
+                {
+                    string ma_nowcheckqty = dt.Rows[0]["ma_nowcheckqty"].ToString();
+                    string pr_qcbatchqty = dt.Rows[0]["pr_qcbatchqty"].ToString();
+                    string ma_checkno = dt.Rows[0]["ma_checkno"].ToString();
+                    string ma_prodcode = dt.Rows[0]["ma_prodcode"].ToString();
+                    string pr_qualmethod = dt.Rows[0]["pr_qualmethod"].ToString();
+                    if (pr_qcbatchqty != "" && pr_qcbatchqty != "0")
+                    {
+                        //当前批次的送检批数量大于物料资料中的抽检批数或者当前批次编号为空
+                        string checkno = "";
+                        if (int.Parse(ma_nowcheckqty == "" ? "0" : ma_nowcheckqty) >= int.Parse(pr_qcbatchqty) || ma_checkno == "")
+                        {
+                            //原有的抽检批次插入OQCBatch
+                            string ob_id = dh.GetSEQ("OQCBatch_SEQ");
+                            checkno = dh.GetSerialNumberByCaller("Make!CheckQC");
+                            sql.Clear();
+                            sql.Append("insert into OQCBatch  (ob_id, ob_checkno,ob_makecode,ob_source,ob_indate,ob_checkman,ob_batchqty,ob_status,ob_prodcode,ob_projectcode)");
+                            sql.Append(" values('" + ob_id + "','" + checkno + "','" + iMakeCode + "', '工序',sysdate, '" + iUserName + "','" + ma_nowcheckqty + "','UNCHECK','" + ma_prodcode + "','" + pr_qualmethod + "')");
+                            sqls.Add(sql.ToString());
+                            sqls.Add("update makeserial set ms_checkno='" + checkno + "' where ms_makecode='" + iMakeCode + "' and ms_sncode='" + iSnCode + "'");
+                            sqls.Add("update make set ma_checkno='" + checkno + "',ma_nowcheckqty=1 where ma_code='" + iMakeCode + "'");
+                        }
+                        else
+                        {
+                            sqls.Add("update makeserial set ms_checkno='" + ma_checkno + "' where ms_makecode='" + iMakeCode + "' and ms_sncode='" + iSnCode + "'");
+                            sqls.Add("update make set ma_nowcheckqty= ma_nowcheckqty+1  where ma_code='" + iMakeCode + "'");
+                        }
+                        dh.ExecuteSQLTran(sqls.ToArray());
+                        sqls.Clear();
+                        //如果制造单的ma_checkno没有值则新加入一个值
+                        string checkno1 = checkno == "" ? ma_checkno : checkno;
+                        string obd_obid = dh.getFieldDataByCondition("oqcbatch", "ob_id", "ob_checkno='" + checkno1 + "'").ToString();
+                        //插入抽检批次明细表
+                        sql.Clear();
+                        sql.Append("insert into OQCBatchDetail (obd_id,obd_obid,obd_sncode,obd_outboxcode,obd_makecode,obd_checkno,obd_builddate) ");
+                        sql.Append("select OQCBatchDetail_SEQ.nextval,'" + obd_obid + "',ms_sncode,ms_outboxcode,ms_makecode,ms_checkno,");
+                        sql.Append("sysdate from makeserial where  ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
+                        dh.ExecuteSql(sql.ToString(), "insert");
+                        return true;
+                    }
+                    else
+                    {
+                        oErrorMessage = "请维护物料资料的抽检批数";
+                        return false;
+                    }
+                }
+                else
+                {
+                    oErrorMessage = "制造单号不存在";
+                    return false;
+                }
+            }
+            else
+            {
+                oErrorMessage = "当前工序的下一工序不是OQC检测";
+                return false;
+            }
+        }
+
         /// <summary>
         /// 验证用户身份信息
         /// </summary>
@@ -80,7 +142,8 @@ namespace MES_Interface
         {
             oErrorMessage = "";
             string SQL = "select em_code from employee where em_code=:UserName and em_password =:PassWord";
-            DataTable dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode, iPassWord);
+            DataTable dt;
+            dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode, iPassWord);
             if (dt.Rows.Count > 0)
                 return true;
             else
@@ -90,6 +153,14 @@ namespace MES_Interface
             }
         }
 
+        /// <summary>
+        /// 记录登陆信息
+        /// </summary>
+        public void RecordLogInfo(string iUserCode, string iUserName, string iVersion, string iType, string iIP)
+        {
+            dh.ExecuteSql("insert into LogInfo(id,sip,usname,indate,uscode,versioncode,terminaltype) values (LogInfo_seq.nextval,'" + iIP + "','" + iUserName + "',sysdate,'" + iUserCode + "','" + iVersion + "','" + iType + "')", "insert");
+        }
+
         /// <summary>
         /// 验证用户身份信息和岗位资源
         /// </summary>
@@ -97,7 +168,7 @@ namespace MES_Interface
         /// <param name="iPassWord"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool CheckUserAndSourcePassed(string iUserCode, string iSourceCode, out string oErrorMessage)
+        public bool CheckUserAndResourcePassed(string iUserCode, string iSourceCode, out string oErrorMessage)
         {
             oErrorMessage = "";
             string SQL = "select em_code,em_type,em_name from employee where em_code=:UserName ";
@@ -106,25 +177,41 @@ namespace MES_Interface
             if (dt.Rows.Count > 0)
             {
                 string em_name = dt.Rows[0]["em_name"].ToString();
+                string em_type = dt.Rows[0]["em_type"].ToString();
                 if (iSourceCode == "")
                 {
                     oErrorMessage = "岗位资源不允许为空";
                     return false;
                 }
-                dt = dh.getFieldsDatasByCondition("cs$empgroup left join cs$userresource on ur_groupcode=eg_groupcode left join source on ur_resourcecode=sc_code", new string[] { "ur_resourcecode" }, "eg_emcode = '" + iUserCode + "' and sc_statuscode='AUDITED'");
-                //如果存在该编号
-                if (dt.Rows.Count > 0)
+                if (em_type == "admin")
                 {
-                    //判断如果多个岗位资源存在,用户输入的只要在其中就行
-                    for (int i = 0; i < dt.Rows.Count; i++)
+                    if (dh.CheckExist("Source", "sc_code='" + iSourceCode + "' and sc_statuscode='AUDITED'"))
                     {
-                        if (dt.Rows[i]["ur_resourcecode"].ToString() == iSourceCode)
-                            return true;
+                        return true;
+                    }
+                    else
+                    {
+                        oErrorMessage = "岗位资源编号错误或者未审核!";
+                        return false;
                     }
-                    oErrorMessage = "岗位资源编号错误或者未审核!";
                 }
                 else
-                    oErrorMessage = "岗位资源编号错误或者未审核!";
+                {
+                    dt = dh.getFieldsDatasByCondition("cs$empgroup left join cs$userresource on ur_groupcode=eg_groupcode left join source on ur_resourcecode=sc_code", new string[] { "ur_resourcecode" }, "eg_emcode = '" + iUserCode + "' and sc_statuscode='AUDITED'");
+                    //如果存在该编号
+                    if (dt.Rows.Count > 0)
+                    {
+                        //判断如果多个岗位资源存在,用户输入的只要在其中就行
+                        for (int i = 0; i < dt.Rows.Count; i++)
+                        {
+                            if (dt.Rows[i]["ur_resourcecode"].ToString() == iSourceCode)
+                                return true;
+                        }
+                        oErrorMessage = "用户不处于当前资源所属分组!";
+                    }
+                    else
+                        oErrorMessage = "岗位资源编号错误或者未审核!";
+                }
             }
             else
                 oErrorMessage = "用户不存在!";
@@ -136,7 +223,8 @@ namespace MES_Interface
             oErrorMessage = "";
             string[] param = new string[] { iCaller, iSourceCode, oErrorMessage };
             dh.CallProcedure("CS_CHECKSTEPATTRIBUTE", ref param);
-            if (oErrorMessage == "" || oErrorMessage == null)
+            oErrorMessage = param[2];
+            if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
                 return true;
             else
                 return false;
@@ -165,79 +253,31 @@ namespace MES_Interface
         /// <param name="iMakeCode"></param>
         /// <param name="oMac"></param>
         /// <param name="oBT"></param>
-        /// <param name="oID1"></param>
-        /// <param name="oID2"></param>
-        /// <param name="oID3"></param>
+        /// <param name="oCode1"></param>
+        /// <param name="oCode2"></param>
+        /// <param name="oCdoe3"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool GetAddressRangeByMakeCode(string iSnCode, string iMakeCode, out string oMac, out string oBT, out string oID1, out string oID2, out string oID3, out string oErrorMessage)
+        public bool GetAddressRangeByMakeCode(string iSnCode, string iMakeCode, out string oMac, out string oBT, out string oCode1, out string oCode2, out string oCdoe3, out string oErrorMessage)
         {
-            string id = "";
             oMac = "";
             oBT = "";
-            oID1 = "";
-            oID2 = "";
-            oID3 = "";
+            oCode1 = "";
+            oCode2 = "";
+            oCdoe3 = "";
             oErrorMessage = "";
-            if (GetMakeInfo(iSnCode, out iMakeCode, out oErrorMessage))
-            {
-                DataTable dt = dh.getFieldsDataByCondition("MakeSerial", new string[] { "ms_mac", "ms_bt", "ms_othid1", "ms_othid2", "ms_othid3" }, "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
-                if (dt.Rows.Count > 0)
-                {
-                    if (dt.Rows[0]["ms_mac"].ToString() != "")
-                    {
-                        id = dt.Rows[0]["ms_id"].ToString();
-                        oMac = dt.Rows[0]["ms_mac"].ToString();
-                        oBT = dt.Rows[0]["ms_bt"].ToString();
-                        oID1 = dt.Rows[0]["ms_othid1"].ToString();
-                        oID2 = dt.Rows[0]["ms_othid2"].ToString();
-                        oID3 = dt.Rows[0]["ms_othid3"].ToString();
-                        return true;
-                    }
-                    //如果没有数据则从MakeIMEIList表中查询
-                    else
-                    {
-                        dt = dh.getFieldsDataByCondition("MakeIMEIList", new string[] { "mil_id", "mil_mac", "mil_bt", "mil_meid", "mil_netcode", "mil_psn", "mil_imei1", "mil_imei2", "mil_imei3", "mil_othid1", "mil_othid2", "mil_othid3" }, "mil_sncode='" + iSnCode + "' and mil_makecode='" + iMakeCode + "'");
-                        if (dt.Rows.Count > 0)
-                        {
-                            id = dt.Rows[0]["mil_id"].ToString();
-                            oMac = dt.Rows[0]["mil_mac"].ToString();
-                            oBT = dt.Rows[0]["mil_bt"].ToString();
-                            oID1 = dt.Rows[0]["mil_othid1"].ToString();
-                            oID2 = dt.Rows[0]["mil_othid2"].ToString();
-                            oID3 = dt.Rows[0]["mil_othid3"].ToString();
-                            return true;
-                        }
-                        else
-                        {
-                            dt = dh.getFieldsDataByCondition("MakeIMEIList", new string[] { "mil_id", "mil_mac", "mil_bt", "mil_meid", "mil_netcode", "mil_psn", "mil_imei1", "mil_imei2", "mil_imei3", "mil_othid1", "mil_othid2", "mil_othid3" }, "mil_sncode is null and mil_makecode is null order by mil_sncode");
-                            if (dt.Rows.Count > 0)
-                            {
-                                id = dt.Rows[0]["mil_id"].ToString();
-                                oMac = dt.Rows[0]["mil_mac"].ToString();
-                                oBT = dt.Rows[0]["mil_bt"].ToString();
-                                oID1 = dt.Rows[0]["mil_othid1"].ToString();
-                                oID2 = dt.Rows[0]["mil_othid2"].ToString();
-                                oID3 = dt.Rows[0]["mil_othid3"].ToString();
-                                //将已经分配的序列号的SN和MakeCode更新到MakeIMEIList表中
-                                dh.UpdateByCondition("MakeIMEIList", "mil_sncode='" + iSnCode + "',mil_makecode='" + iMakeCode + "',mil_status='已使用'", "mil_id=" + id);
-                                return true;
-                            }
-                            else
-                            {
-                                oErrorMessage = "当前序列号无可分配地址";
-                                return false;
-                            }
-                        }
-                    }
-                }
-                else
-                {
-                    oErrorMessage = "序列号" + iSnCode + "不存在";
-                    return false;
-                }
-            }
-            else return false;
+            string[] param = new string[] { iSnCode, iMakeCode, oMac, oBT, oCode1, oCode2, oCdoe3, oErrorMessage };
+            dh.CallProcedure("CS_GETADDRESSBYMAKECODE", ref param);
+            oMac = param[2];
+            oBT = param[3];
+            oCode1 = param[4];
+            oCode2 = param[5];
+            oCdoe3 = param[6];
+            oErrorMessage = param[7];
+            if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
+                return true;
+            else
+                return false;
         }
 
         /// <summary>
@@ -261,100 +301,34 @@ namespace MES_Interface
         /// <param name="oID3"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool GetIMEIOrNetCodeRange(string iSnCode, string iMakeCode, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oIMEI3, out string oMEID, out string oNetCode, out string oPSN, out string oMac, out string oBT, out string oID1, out string oID2, out string oID3, out string oErrorMessage)
+        public bool GetIMEIOrNetCodeRange(string iSnCode, string iMakeCode, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oIMEI3, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oErrorMessage)
         {
-            string id = "";
-            oBT = "";
-            oMEID = "";
-            oMac = "";
-            oPSN = "";
-            oNetCode = "";
             oIMEI1 = "";
             oIMEI2 = "";
             oIMEI3 = "";
+            oMEID = "";
+            oNetCode = "";
+            oPSN = "";
             oID1 = "";
             oID2 = "";
             oID3 = "";
             oErrorMessage = "";
-            //先判断MakeSerial表的数据,是否已经烧入了,如已经烧入直接从MakeSerial表取数据
-            //condition iIMEI1,iNETCode
-            if (GetMakeInfo(iSnCode, out iMakeCode, out oErrorMessage))
-            {
-                DataTable dt = dh.getFieldsDataByCondition("MakeSerial", new string[] { "ms_id", "ms_mac", "ms_bt", "ms_meid", "ms_netcode", "ms_psn", "ms_imei1", "ms_imei2", "ms_imei3", "ms_othid1", "ms_othid2", "ms_othid3" }, "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "' and ms_netcode like '%" + iNetCode + "%' and ms_imei1 like '%" + iIMEI1 + "%'");
-                if (dt.Rows.Count > 0)
-                {
-                    if (dt.Rows[0]["ms_mac"].ToString() != "")
-                    {
-                        id = dt.Rows[0]["ms_id"].ToString();
-                        oMac = dt.Rows[0]["ms_mac"].ToString();
-                        oBT = dt.Rows[0]["ms_bt"].ToString();
-                        oPSN = dt.Rows[0]["ms_psn"].ToString();
-                        oNetCode = dt.Rows[0]["ms_netcode"].ToString();
-                        oMEID = dt.Rows[0]["ms_meid"].ToString();
-                        oIMEI1 = dt.Rows[0]["ms_imei1"].ToString();
-                        oIMEI2 = dt.Rows[0]["ms_imei2"].ToString();
-                        oIMEI3 = dt.Rows[0]["ms_imei3"].ToString();
-                        oID1 = dt.Rows[0]["ms_othid1"].ToString();
-                        oID2 = dt.Rows[0]["ms_othid2"].ToString();
-                        oID3 = dt.Rows[0]["ms_othid3"].ToString();
-                        return true;
-                    }
-                    //如果没有数据则从MakeIMEIList表中查询
-                    else
-                    {
-                        dt = dh.getFieldsDataByCondition("MakeIMEIList", new string[] { "mil_id", "mil_mac", "mil_bt", "mil_meid", "mil_netcode", "mil_psn", "mil_imei1", "mil_imei2", "mil_imei3", "mil_othid1", "mil_othid2", "mil_othid3" }, "mil_sncode='" + iSnCode + "' and mil_makecode='" + iMakeCode + "'  and mil_netcode like '%" + iNetCode + "%' and mil_imei1 like '%" + iIMEI1 + "%'");
-                        if (dt.Rows.Count > 0)
-                        {
-                            id = dt.Rows[0]["mil_id"].ToString();
-                            oMac = dt.Rows[0]["mil_mac"].ToString();
-                            oBT = dt.Rows[0]["mil_bt"].ToString();
-                            oPSN = dt.Rows[0]["mil_psn"].ToString();
-                            oNetCode = dt.Rows[0]["mil_netcode"].ToString();
-                            oMEID = dt.Rows[0]["mil_meid"].ToString();
-                            oIMEI1 = dt.Rows[0]["mil_imei1"].ToString();
-                            oIMEI2 = dt.Rows[0]["mil_imei2"].ToString();
-                            oIMEI3 = dt.Rows[0]["mil_imei3"].ToString();
-                            oID1 = dt.Rows[0]["mil_othid1"].ToString();
-                            oID2 = dt.Rows[0]["mil_othid2"].ToString();
-                            oID3 = dt.Rows[0]["mil_othid3"].ToString();
-                            return true;
-                        }
-                        else
-                        {
-                            dt = dh.getFieldsDataByCondition("MakeIMEIList", new string[] { "mil_id", "mil_mac", "mil_bt", "mil_meid", "mil_netcode", "mil_psn", "mil_imei1", "mil_imei2", "mil_imei3", "mil_othid1", "mil_othid2", "mil_othid3" }, "mil_sncode is null and mil_makecode is null and mil_netcode like '%" + iNetCode + "%' and mil_imei1 like '%" + iIMEI1 + "%' order by mil_sncode ");
-                            if (dt.Rows.Count > 0)
-                            {
-                                id = dt.Rows[0]["mil_id"].ToString();
-                                oMac = dt.Rows[0]["mil_mac"].ToString();
-                                oBT = dt.Rows[0]["mil_bt"].ToString();
-                                oPSN = dt.Rows[0]["mil_psn"].ToString();
-                                oNetCode = dt.Rows[0]["mil_netcode"].ToString();
-                                oMEID = dt.Rows[0]["mil_meid"].ToString();
-                                oIMEI1 = dt.Rows[0]["mil_imei1"].ToString();
-                                oIMEI2 = dt.Rows[0]["mil_imei2"].ToString();
-                                oIMEI3 = dt.Rows[0]["mil_imei3"].ToString();
-                                oID1 = dt.Rows[0]["mil_othid1"].ToString();
-                                oID2 = dt.Rows[0]["mil_othid2"].ToString();
-                                oID3 = dt.Rows[0]["mil_othid3"].ToString();
-                                //将已经分配的序列号的SN和MakeCode更新到MakeIMEIList表中
-                                dh.UpdateByCondition("MakeIMEIList", "mil_sncode='" + iSnCode + "',mil_makecode='" + iMakeCode + "',mil_status='已使用'", "mil_id=" + id);
-                                return true;
-                            }
-                            else
-                            {
-                                oErrorMessage = "当前序列号无可分配地址";
-                                return false;
-                            }
-                        }
-                    }
-                }
-                else
-                {
-                    oErrorMessage = "序列号" + iSnCode + "不存在";
-                    return false;
-                }
-            }
-            else return false;
+            string[] param = new string[] { iSnCode, iMakeCode, iIMEI1, iNetCode, oIMEI1, oIMEI2, oIMEI3, oMEID, oNetCode, oPSN, oID1, oID2, oID3, oErrorMessage };
+            dh.CallProcedure("CS_GETIMEIORNETCODERANGE", ref param);
+            oIMEI1 = param[4];
+            oIMEI2 = param[5];
+            oIMEI3 = param[6];
+            oMEID = param[7];
+            oNetCode = param[8];
+            oPSN = param[9];
+            oID1 = param[10];
+            oID2 = param[11];
+            oID3 = param[12];
+            oErrorMessage = param[13];
+            if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
+                return true;
+            else
+                return false;
         }
 
         /// <summary>
@@ -369,7 +343,8 @@ namespace MES_Interface
             //取MakeProcess表中的执行记录ID最大的一个工单的号码
             oMakeCode = "";
             oErrorMessage = "";
-            oMakeCode = dh.getFieldDataByCondition("MakeSerial", "ms_makecode", "ms_sncode='" + iSnCode + "' and ms_indate in (select max(ms_indate) from makeserial where ms_sncode='" + iSnCode + "')").ToString();
+            string ms_id = dh.getFieldDataByCondition("MakeSerial", "max(ms_id) ms_id", "ms_sncode='" + iSnCode + "' or ms_firstsn in (select firstsn from makesnrelation where sn='" + iSnCode + "')").ToString();
+            oMakeCode = dh.getFieldDataByCondition("MakeSerial", "ms_makecode", "ms_id='" + ms_id + "'").ToString();
             if (oMakeCode != "")
                 return true;
             else
@@ -413,10 +388,10 @@ namespace MES_Interface
             oID2 = "";
             oID3 = "";
             //通过序列号获取最近操作的工单号
-            string MakeCode;
-            if (GetMakeInfo(iSnCode, out MakeCode, out oErrorMessage))
+            string ms_id = dh.getFieldDataByCondition("makeserial", "ms_id", "ms_sncode='" + iSnCode + "'").ToString();
+            if (ms_id != "")
             {
-                DataTable dt = dh.getFieldsDataByCondition("MakeSerial", new string[] { "ms_id", "ms_mac", "ms_bt", "ms_meid", "ms_netcode", "ms_psn", "ms_imei1", "ms_imei2", "ms_imei3", "ms_othcode1", "ms_othcode2", "ms_othcode3", "ms_othid1", "ms_othid2", "ms_othid3" }, "ms_sncode='" + iSnCode + "'' and ms_makecode='" + MakeCode + "' ");
+                DataTable dt = dh.getFieldsDataByCondition("MakeSerial", new string[] { "ms_id", "ms_mac", "ms_bt", "ms_meid", "ms_netcode", "ms_psn", "ms_imei1", "ms_imei2", "ms_imei3", "ms_othcode1", "ms_othcode2", "ms_othcode3", "ms_othid1", "ms_othid2", "ms_othid3" }, "ms_id='" + ms_id + "'");
                 if (dt.Rows.Count > 0)
                 {
                     oMac = dt.Rows[0]["ms_mac"].ToString();
@@ -433,6 +408,7 @@ namespace MES_Interface
                     oID1 = dt.Rows[0]["ms_othid3"].ToString();
                     oID2 = dt.Rows[0]["ms_othid3"].ToString();
                     oID3 = dt.Rows[0]["ms_othid3"].ToString();
+                    oErrorMessage = "";
                     return true;
                 }
                 else
@@ -442,18 +418,22 @@ namespace MES_Interface
                 }
             }
             else
+            {
+                oErrorMessage = "序列号" + iSnCode + "不存在";
                 return false;
+            }
         }
 
+
         /// <summary>
         /// 记录操作日志
         /// </summary>
         /// <param name="iSnCode"></param>
         /// <param name="iMakeCode"></param>
         /// <param name="iMPKind"></param>
-        /// <param name="iResult"></param>
-        /// <param name="iUserName"></param>
-        public void InsertMakeProcess(string iSnCode, string iMakeCode, string iSourceCode, string iMPKind, string iResult, string iUserName)
+        /// <param name="result"></param>
+        /// <param name="iUserCode"></param>
+        public void InsertMakeProcess(string iSnCode, string iMakeCode, string iSourceCode, string iMPKind, string result, string iUserCode)
         {
             string CurrentStep = "";
             string LineCode = "";
@@ -462,45 +442,48 @@ namespace MES_Interface
             sql.Clear();
             sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");
             sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode,mp_snstatus,mp_sncheckno,mp_snoutboxcode)");
-            sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,mcd_stepcode,mcd_stepname,");
-            sql.Append("ma_craftcode,ma_craftname,'" + iMPKind + "','" + iResult + "',sysdate,'" + iUserName + "',ma_wccode,'" + LineCode + "','" + iSourceCode + "',");
-            sql.Append("ms_status,ms_checkno,ms_outboxcode from make left join makecraftdetail on mcd_macode=ma_code left join makeserial on ms_makecode=ma_code ");
-            sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and mcd_stepcode='" + CurrentStep + "'");
+            sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,'" + CurrentStep + "','" + CurrentStepName + "',");
+            sql.Append("ma_craftcode,ma_craftname,'" + iMPKind + "','" + result + "',sysdate,'" + iUserCode + "',ma_wccode,'" + LineCode + "','" + iSourceCode + "',");
+            sql.Append("ms_status,ms_checkno,ms_outboxcode from make left join makeserial on ms_makecode=ma_code left join step on st_code=ms_stepcode ");
+            sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and st_code='" + CurrentStep + "'");
             dh.ExecuteSql(sql.ToString(), "insert");
+        }
+
+        /// <summary>
+        /// 记录一般操作日志
+        /// </summary>
+        /// <param name="inMan"></param>
+        /// <param name="Content"></param>
+        /// <param name="Result"></param>
+        /// <param name="Search"></param>
+        /// <param name="Code"></param>
+        public void InsertMessageLog(string inMan, string Content, string Result, string Search, string Code)
+        {
             sql.Clear();
+            sql.Append("insert into messagelog (ml_id,ml_date,ml_man,ml_content,ml_result,ml_search,code) ");
+            sql.Append("values (messagelog_seq.nextval,sysdate,'" + inMan + "','" + Content + "','" + Result + "','" + Search + "','" + Code + "')");
+            dh.ExecuteSql(sql.ToString(), "insert");
         }
 
         /// <summary>
         /// 保存Mac地址和BT地址
         /// </summary>
         /// <param name="iSN"></param>
-        /// <param name="iWIFI"></param>
+        /// <param name="iMac"></param>
         /// <param name="iBT"></param>
         /// <param name="iCode1"></param>
         /// <param name="iCode2"></param>
         /// <param name="iCode3"></param>
-        /// <param name="oErrMessage"></param>
+        /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool SetAddressInfo(string iSN, string iWIFI, string iBT, string iCode1, string iCode2, string iCode3, out string oErrMessage)
+        public bool SetAddressInfo(string iSN, string iMac, string iBT, string iCode1, string iCode2, string iCode3, out string oErrorMessage)
         {
-            string MakeCode = "";
-            if (GetMakeInfo(iSN, out MakeCode, out oErrMessage))
-            {
-                string sql = "update MakeSerial set ms_mac=:iWifi,ms_bt=:iBT,ms_othcode1=:iCode1,ms_othcode2=:iCode2,ms_othcode3=:iCode3 where ms_sncode='" + iSN + "' and ms_makecode='" + MakeCode + "'";
-                dh.ExecuteSql(sql, "update", iWIFI, iBT, iCode1, iCode2, iCode3);
-                DataTable dt = (DataTable)dh.ExecuteSql("select si_sn from SnInfo where si_sn='" + iSN + "' or  si_sn in (select sn from makesnrelation where firstsn='" + iSN + "' or sn='" + iSN + "')", "select");
-                if (dt.Rows.Count > 0)
-                {
-                    sql = "update SnInfo set si_mac=:iMac,si_bt=:iBT,si_othcode1=:iCode1,si_othcode2=:iCode2,si_othcode3=:iCode3 where si_sn='" + dt.Rows[0]["si_sn"].ToString() + "'";
-                    dh.ExecuteSql(sql, "update", iWIFI, iBT, iCode1, iCode2, iCode3);
-                }
-                else
-                {
-                    sql = "insert into SnInfo(si_id,si_sn,si_mac,si_bt,si_othcode1,si_othcode2,si_othcode3) values(SnInfo_seq.nextval,:iSn,:iWifi,:iBt,:iCode1,:iCode2,:iCode3)";
-                    dh.ExecuteSql(sql, "insert", iSN, iWIFI, iBT, iCode1, iCode2, iCode3);
-                }
+            oErrorMessage = "";
+            string[] param = new string[] { iSN, iMac, iBT, iCode1, iCode2, iCode3, oErrorMessage };
+            dh.CallProcedure("CS_SETADDRESSINFO", ref param);
+            oErrorMessage = param[6];
+            if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
                 return true;
-            }
             else
                 return false;
         }
@@ -521,12 +504,29 @@ namespace MES_Interface
             }
         }
 
-        private bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, out string oErrorMessage)
+        /// <summary>
+        /// 设置测试结果
+        /// </summary>
+        /// <param name="iMakeCode"></param>
+        /// <param name="iSourceCode"></param>
+        /// <param name="iSN"></param>
+        /// <param name="iMPKind"></param>
+        /// <param name="iResult"></param>
+        /// <param name="iUserCode"></param>
+        /// <param name="oErrorMessage"></param>
+        /// <returns></returns>
+        public bool SetTestResult(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
+        {
+            return SetStepFinish(iMakeCode, iSourceCode, iSN, iMPKind, iResult, iUserCode, out oErrorMessage);
+        }
+
+        public bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, out string oErrorMessage)
         {
             oErrorMessage = "";
             string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, oErrorMessage };
             dh.CallProcedure("CS_SETSTEPFINISH", ref param);
-            if (oErrorMessage == "" || oErrorMessage == null)
+            oErrorMessage = param[4];
+            if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
                 return true;
             else
                 return false;
@@ -580,12 +580,16 @@ namespace MES_Interface
         /// <param name="iID3"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool SetIMEIInfo(string iSnCode, string iMakeCode, string iIMEI1, string iIMEI2, string iIMEI3, string iMEID, string iNetCode, string iPSN, string iID1, string iID2, string iID3, out string oErrorMessage)
+        public bool SetIMEIInfo(string iSnCode, string iIMEI1, string iIMEI2, string iIMEI3, string iMEID, string iNetCode, string iPSN, string iID1, string iID2, string iID3, out string oErrMessage)
         {
-            oErrorMessage = "";
-            string sql = "update MakeSerial set ms_imei1=:iIMEI1 ,ms_imei2=:iIMEI2 ,ms_imei3=:iIMEI3 ,ms_netcode=:iNetCode ,ms_psn=:iPSN ,ms_othcode1=:iCode1 ,ms_othcode2=:iCode2 ,ms_othcode3=:iCode3  where ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'";
-            dh.ExecuteSql(sql, "update", iIMEI1, iIMEI2, iIMEI3, iNetCode, iPSN, iID1, iID2, iID3);
-            return true;
+            oErrMessage = "";
+            string[] param = new string[] { iSnCode, iIMEI1, iIMEI2, iIMEI3, iMEID, iNetCode, iPSN, iID1, iID2, iID3, oErrMessage };
+            dh.CallProcedure("CS_SETIMEIINFO", ref param);
+            oErrMessage = param[10];
+            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
+                return true;
+            else
+                return false;
         }
 
         /// <summary>
@@ -616,8 +620,14 @@ namespace MES_Interface
             sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + iSnCode + "'");
             dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "bg_code", "bc_remark" }, iBadCode, iBadGroupCode, iBadRemark);
             //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
-            dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + StepCode + "',ms_status=3", "ms_sncode='" + iSnCode + "'");
-            //判断当前采集点是否为扣料工序cd_ifreduce =-1 则为扣料工序
+            dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + StepCode + "',ms_status=3,ms_badtimes=ms_badtimes+1", "ms_sncode='" + iSnCode + "'");
+            //如果存在送检批号则进行删除
+            if (dh.CheckExist("oqcbatchdetail", "obd_sncode='" + iSnCode + "'"))
+            {
+                string checkno = dh.getFieldDataByCondition("oqcbatchdetail", "obd_checkno", "obd_sncode='" + iSnCode + "'").ToString();
+                dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + iSnCode + "'", "delete");
+                dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + checkno + "'", "update");
+            }
             //之前保存的不良就不再调用
             if (ms_status != "3")
                 SetStepFinish(iMakeCode, iSourceCode, iSnCode, "不良采集", iResult, iUserCode, out oErrorMessage);
@@ -807,6 +817,61 @@ namespace MES_Interface
                 return false;
         }
 
+        public bool UpdateOQCMessage(string iSnCode, string iCheckno, string iMakeCode, string iMPKind, string iSourceCode, string iUserCode, string iResult, out string oErrorMessage)
+        {
+            oErrorMessage = "";
+            string StepCode = "";
+            string StepName = "";
+            string LineCode = "";
+            if (iResult == "" || iResult == null)
+            {
+                iResult = "测试合格";
+            }
+            GetStepCodeAndNameAndLineBySource(iSourceCode, ref StepCode, ref StepName, ref LineCode);
+            //查询批次和批数量
+            int batchqty = 0;
+            DataTable dt = (DataTable)dh.ExecuteSql("select count(ms_checkno) count,ms_checkno from makeserial where ms_checkno='" + iCheckno + "' group by ms_checkno", "select");
+            if (dt.Rows.Count > 0)
+            {
+                batchqty = int.Parse(dt.Rows[0]["count"].ToString());
+            }
+            string nextstepcode = dh.getFieldDataByCondition("make left join craft on ma_craftcode=cr_code and ma_prodcode=cr_prodcode left join craftdetail on cr_id = cd_crid", "cd_nextstepcode", "ma_code='" + iMakeCode + "' and cd_stepcode='" + StepCode + "'").ToString();
+            if (iResult.Contains("批次通过") && dt.Rows.Count > 0)
+            {
+                //更新执行的数量
+                sqls.Add("update makecraftdetail set mcd_inqty=mcd_inqty+" + batchqty + ",mcd_outqty = mcd_outqty + " + batchqty + ",mcd_okqty = mcd_okqty + " + batchqty + " where mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "' ");
+                //更新makeSerial 的下一工序
+                sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_stepcode='" + StepCode + "',ms_nextstepcode='" + nextstepcode + "' where ms_checkno='" + iCheckno + "'");
+            }
+            else
+            {
+                //更新执行的数量
+                sqls.Add("update makecraftdetail set mcd_inqty=mcd_inqty+1,mcd_outqty = mcd_outqty + 1,mcd_okqty = mcd_okqty + 1 where mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "' ");
+                //更新makeSerial 的下一工序
+                sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_stepcode='" + StepCode + "',ms_nextstepcode='" + nextstepcode + "' where ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
+            }
+            //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
+            dh.ExecuteSQLTran(sqls.ToArray());
+            sqls.Clear();
+            //检测下道工序是否存在,不存在 更新状态为已完成
+            if (nextstepcode == null || nextstepcode == "")
+            {
+                if (iResult.Contains("批次通过"))
+                {
+                    sqls.Add("update make set ma_madeqty=ma_madeqty+" + batchqty + " where ma_code='" + iMakeCode + "'");
+                    sqls.Add("update makeserial set ms_status=2 where ms_checkno='" + iCheckno + "'");
+                }
+                else
+                {
+                    sqls.Add("update make set ma_madeqty=ma_madeqty+1  where ma_code='" + iMakeCode + "'");
+                    sqls.Add("update makeserial set ms_status=2 where ms_sncode='" + iSnCode + "'");
+                }
+                dh.ExecuteSQLTran(sqls.ToArray());
+                sqls.Clear();
+            }
+            return true;
+        }
+
         /// <summary>
         /// 设置良品采集结果,iResult含有“批次通过”按抽检批次通过
         /// </summary>

+ 2 - 3
MES接口/Properties/AssemblyInfo.cs

@@ -1,15 +1,14 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的一般信息由以下
 // 控制。更改这些特性值可修改
 // 与程序集关联的信息。
-[assembly: AssemblyTitle("MES接口")]
+[assembly: AssemblyTitle("UAS_MES")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("MES接口")]
+[assembly: AssemblyProduct("UAS_MES")]
 [assembly: AssemblyCopyright("Copyright ©  2016")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]

+ 2 - 4
MES接口/UAS-MES接口.csproj

@@ -7,8 +7,8 @@
     <ProjectGuid>{A52EFE9C-838E-4E8C-BAAA-B1C226E57A81}</ProjectGuid>
     <OutputType>Library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>MES接口</RootNamespace>
-    <AssemblyName>MES接口</AssemblyName>
+    <RootNamespace>MES_Interface</RootNamespace>
+    <AssemblyName>MES_Interface</AssemblyName>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <TargetFrameworkProfile />
@@ -61,8 +61,6 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Encryption.cs" />
-    <Compile Include="ftpOperater.cs" />
     <Compile Include="LogicHandler.cs" />
     <Compile Include="DataHelper.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 0 - 218
MES接口/ftpOperater.cs

@@ -1,218 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Text;
-using System.Windows.Forms;
-
-namespace MES_Interface
-{
-    public class ftpOperater
-    {
-        public static string FTPAddress = "";
-
-        public string DownLoadTo = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\" + "打印标签";
-
-        private string ftpServerIP;
-        private string ftpUser;
-        private string ftpPwd;
-
-
-        public ftpOperater()
-        {
-            string[] FTPInf = Properties.Settings.Default.Properties["FTPAddress"].DefaultValue.ToString().Split('|');
-            this.ftpServerIP = FTPInf[0];
-            this.ftpUser = FTPInf[1];
-            this.ftpPwd = FTPInf[2];
-        }
-
-        public void UpLoadFile(string filepath, string filename)
-        {
-            //上传之前判断文件是否存在
-            string[] filelist = GetFileList();
-            if (filelist != null)
-                for (int i = 0; i < filelist.Length; i++)
-                {
-                    if (filelist[i] == filename)
-                    {
-                        string upload = MessageBox.Show("已存在同名文件,是否覆盖", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-                        if (upload.ToString() != "Yes")
-                        {
-                            return;
-                        }
-                    }
-                }
-            FtpWebRequest reqFTP;
-            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + filename));
-            reqFTP.UseBinary = true;
-            reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
-            reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
-            FileInfo file = new FileInfo(filepath + "/" + filename);
-            const int BufferSize = 2048;
-            byte[] content = new byte[BufferSize - 1 + 1];
-            int dataRead;
-            using (FileStream fs = file.OpenRead())
-            {
-                //把上传的文件写入流
-                using (Stream rs = reqFTP.GetRequestStream())
-                {
-                    do
-                    {
-                        //每次读文件流的2KB
-                        dataRead = fs.Read(content, 0, BufferSize);
-                        rs.Write(content, 0, dataRead);
-                    } while (!(dataRead < BufferSize));
-                    rs.Close();
-                }
-                fs.Close();
-            }
-        }
-
-        //获取指定的文件的内容
-        public string GetFileContent(string filename)
-        {
-            FtpWebRequest reqFTP;
-            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + filename));
-            reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
-            reqFTP.UseBinary = true;
-            reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
-
-            FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
-
-            Stream ftpStream = response.GetResponseStream();
-
-            int bufferSize = GetFileContentLength(filename);
-            byte[] buffer = new byte[bufferSize];
-            ftpStream.Read(buffer, 0, bufferSize);
-            ftpStream.Close();
-            return Encoding.Default.GetString(buffer);
-        }
-
-
-        //获取指定文件的内容的字节长度
-        public int GetFileContentLength(string filename)
-        {
-            FtpWebRequest reqFTP;
-            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + filename));
-            reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
-            reqFTP.UseBinary = true;
-            reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
-
-            FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
-
-            Stream ftpStream = response.GetResponseStream();
-
-            List<byte> buf = new List<byte>();
-            while (ftpStream.ReadByte() != -1)
-            {
-                buf.Add((byte)ftpStream.ReadByte());
-            }
-            ftpStream.Close();
-            return buf.ToArray().Length * 2;
-        }
-
-
-        /// <summary>
-        /// 获取ftp服务器上的文件信息
-        /// </summary>
-        /// <returns>存储了所有文件信息的字符串数组</returns>
-        public string[] GetFileList()
-        {
-            string[] downloadFiles;
-            StringBuilder result = new StringBuilder();
-            FtpWebRequest reqFTP;
-            try
-            {
-                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/"));
-                reqFTP.UseBinary = true;
-                reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
-                reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
-                WebResponse response = reqFTP.GetResponse();
-                StreamReader reader = new StreamReader(response.GetResponseStream());
-
-                string line = reader.ReadLine();
-                while (line != null)
-                {
-                    result.Append(line);
-                    result.Append("\n");
-                    line = reader.ReadLine();
-                }
-                result.Remove(result.ToString().LastIndexOf('\n'), 1);
-                reader.Close();
-                response.Close();
-
-                return result.ToString().Split('\n');
-            }
-            catch (Exception ex)
-            {
-                System.Windows.Forms.MessageBox.Show("获取文件信息失败:" + ex.Message, "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
-                downloadFiles = null;
-                return downloadFiles;
-            }
-        }
-
-        /// <summary>
-        /// 获取FTP上指定文件的大小
-        /// </summary>
-        /// <param name="filename">文件名</param>
-        /// <returns>文件大小</returns>
-        public long GetFileSize(string filename)
-        {
-            FtpWebRequest reqFTP;
-            long fileSize = 0;
-            try
-            {
-                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + filename));
-                reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;
-                reqFTP.UseBinary = true;
-                reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
-                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
-                Stream ftpStream = response.GetResponseStream();
-                fileSize = response.ContentLength;
-
-                ftpStream.Close();
-                response.Close();
-            }
-            catch (Exception ex)
-            {
-                MessageBox.Show("获取文件大小时,出现异常:\n" + ex.Message, "获取文件大小失败!", MessageBoxButtons.OK, MessageBoxIcon.Error);
-            }
-            return fileSize;
-        }
-
-        /// <summary>
-        /// 实现ftp下载操作
-        /// </summary>
-        /// <param name="fileName">远程文件名</param>
-        public string Download(string fileName)
-        {
-            FtpWebRequest reqFTP;
-            //filePath = <<The full path where the file is to be created.>>, 
-            //fileName = <<Name of the file to be created(Need not be the name of the file on FTP server).>>
-            FileStream outputStream = new FileStream(DownLoadTo + @"\" + fileName, FileMode.OpenOrCreate);
-            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + fileName));
-            reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
-            reqFTP.UseBinary = true;
-            reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
-            FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
-            Stream ftpStream = response.GetResponseStream();
-            long cl = response.ContentLength;
-            int bufferSize = 2048;
-            int readCount;
-            byte[] buffer = new byte[bufferSize];
-
-            readCount = ftpStream.Read(buffer, 0, bufferSize);
-            Encoding encoding = Encoding.UTF8;
-            Console.WriteLine(encoding.GetString(buffer));
-            while (readCount > 0)
-            {
-                outputStream.Write(buffer, 0, readCount);
-                readCount = ftpStream.Read(buffer, 0, bufferSize);
-            }
-            ftpStream.Close();
-            outputStream.Close();
-            response.Close();
-            return DownLoadTo + @"\" + fileName;
-        }
-    }
-}

+ 1 - 0
UAS-MES/FunctionCode/Make/Make_TestCollection.cs

@@ -542,6 +542,7 @@ namespace UAS_MES.Make
             ob_nowcheckqty.Text = "";
             ob_batchqty.Text = "";
             SendCheck.Enabled = false;
+            OperateResult.AppendText(">>批次"+ob_checkno.Text+"送检成功\n", Color.Red);
             ms_sncode.Focus();
             LogicHandler.InsertMakeProcess(LastSncode, ma_code.Text, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
         }

+ 2 - 2
UAS-MES/FunctionCode/OQC/OQC_PlanMaintain.cs

@@ -146,9 +146,9 @@ namespace UAS_MES.OQC
         //对于最大不合格允通过数的校验
         private bool Checkob_maxngacceptqty()
         {
-            if (ob_maxngacceptqty.Text == "0" || ob_maxngacceptqty.Text == "" || int.Parse(ob_maxngacceptqty.Text) < 0)
+            if (int.Parse(ob_maxngacceptqty.Text) < 0)
             {
-                OperateResult.AppendText(">>最大不合格允通过数必须大于0\n", Color.Red);
+                OperateResult.AppendText(">>最大不合格允通过数必须大于等于0\n", Color.Red);
                 ob_maxngacceptqty.Text = null;
                 return false;
             }

+ 0 - 1
UAS-MES/PublicMethod/LogicHandler.cs

@@ -660,7 +660,6 @@ namespace UAS_MES.PublicMethod
             oID2 = "";
             oID3 = "";
             //通过序列号获取最近操作的工单号
-            string MakeCode;
             string ms_id = dh.getFieldDataByCondition("makeserial", "ms_id", "ms_sncode='" + iSnCode + "'").ToString();
             if (ms_id != "")
             {