Browse Source

修改测试代码

章政 7 years ago
parent
commit
4a5e30cc77
2 changed files with 86 additions and 16 deletions
  1. 41 5
      UAS_MesInterface(4.0)/MesHelper.cs
  2. 45 11
      UAS_MesInterface/MESHelper.cs

+ 41 - 5
UAS_MesInterface(4.0)/MesHelper.cs

@@ -39,7 +39,7 @@ namespace BenQGuru.eMES.DLLService
         //用于存放批量执行的SQL
         List<string> sqls = new List<string>();
         //系统默认的的连接字符串
-        private string ConnectionStrings = "Data Source=117.25.180.218/orcl;User ID=MES_TEST;PassWord=select!#%*(;";
+        private string ConnectionStrings = "Data Source=117.25.180.218/orcl;User ID=MES;PassWord=select!#%*(;";
         //用户选择的数据库的连接字符串
         private OracleConnection connection;
         //用户选择的数据库的连接字符串
@@ -70,9 +70,23 @@ namespace BenQGuru.eMES.DLLService
             string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
             CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
             oErrMessage = param[6];
-            oErrMessage = param[6];
-            string ms_status = getFieldDataByCondition("makeserial", "ms_status", "ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')").ToString();
-            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || ms_status == "3")
+            DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')", "select");
+            string ms_status = "";
+            string ms_stepcode = "";
+            string ms_nextstepcode = "";
+            if (dt.Rows.Count > 0)
+            {
+                ms_status = dt.Rows[0]["ms_status"].ToString();
+                ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
+                ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
+            }
+            string stepcode = GetStepCodeBySource(iResCode);
+            if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
+            {
+                oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
+                return false;
+            }
+            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && stepcode == ms_stepcode))
             {
                 if (ms_status == "3")
                 {
@@ -671,8 +685,30 @@ namespace BenQGuru.eMES.DLLService
             string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
             CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
             oErrMessage = param[6];
-            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
+            DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')", "select");
+            string ms_status = "";
+            string ms_stepcode = "";
+            string ms_nextstepcode = "";
+            if (dt.Rows.Count > 0)
+            {
+                ms_status = dt.Rows[0]["ms_status"].ToString();
+                ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
+                ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
+            }
+            string stepcode = GetStepCodeBySource(iResCode);
+            if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
+            {
+                oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
+                return false;
+            }
+            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && ms_stepcode == stepcode))
+            {
+                if (ms_status == "3")
+                {
+                    oErrMessage = "";
+                }
                 return true;
+            }
             else
                 return false;
         }

+ 45 - 11
UAS_MesInterface/MESHelper.cs

@@ -18,7 +18,7 @@ namespace BenQGuru.eMES.DLLService
         bool CheckUserAndResourcePassed(string iUserCode, string iResCode, string iPassWord, out string oErrMessage);
         bool GetAddressRangeByMO(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCdoe3, out string oErrMessage);
         bool SetAddressInfo(string iSN, string iWIFI, string iBT, string iCode1, string iCode2, string iCode3, out string oErrorMessage);
-        bool SetTestDetail(string iSN, string iTestResult, string iResCode,ref string[] iTestDetail, out string oErrMessage);
+        bool SetTestDetail(string iSN, string iTestResult, string iResCode, ref string[] iTestDetail, out string oErrMessage);
         bool GetMEIOrNetCodeRange(string iSnCode, string iIMEI1, string iNetCode, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrMessage);
         bool SetIMEIInfo(string iSnCode, string iIMEI1, out string oErrMessage);
         bool GetMobileAllInfo(string iSnCode, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCode3, out string oIMEI1, out string oIMEI2, out string oMEID, out string oNetCode, out string oPSN, out string oID1, out string oID2, out string oID3, out string oID4, out string oID5, out string oErrorMessage);
@@ -68,8 +68,23 @@ namespace BenQGuru.eMES.DLLService
             string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
             CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
             oErrMessage = param[6];
-            string ms_status = getFieldDataByCondition("makeserial", "ms_status", "ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')").ToString();
-            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || ms_status == "3")
+            DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')", "select");
+            string ms_status = "";
+            string ms_stepcode = "";
+            string ms_nextstepcode = "";
+            if (dt.Rows.Count > 0)
+            {
+                ms_status = dt.Rows[0]["ms_status"].ToString();
+                ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
+                ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
+            }
+            string stepcode = GetStepCodeBySource(iResCode);
+            if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
+            {
+                oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
+                return false;
+            }
+            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && ms_stepcode == stepcode))
             {
                 if (ms_status == "3")
                 {
@@ -429,7 +444,6 @@ namespace BenQGuru.eMES.DLLService
 
         public bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, string iErrCode, out string oErrMessage)
         {
-            
             if (iSN == "")
             {
                 oErrMessage = "SN不能为空";
@@ -438,7 +452,7 @@ namespace BenQGuru.eMES.DLLService
             oErrMessage = "";
             string StepCode = getFieldDataByCondition("Makeserial", "ms_stepcode", "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'").ToString();
             string CurrentStep = GetStepCodeBySource(iSourceCode);
-            string BgCode = getFieldDataByCondition("step", "st_badgroupcode", "st_code='"+ CurrentStep + "'").ToString();
+            string BgCode = getFieldDataByCondition("step", "st_badgroupcode", "st_code='" + CurrentStep + "'").ToString();
             switch (iResult)
             {
                 case "OK":
@@ -456,7 +470,7 @@ namespace BenQGuru.eMES.DLLService
                         sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
                         sql.Append(",mb_sourcecode,mb_badcode,mb_badtable,mb_bgcode,mb_soncode,mb_status) select makebad_seq.nextval");
                         sql.Append(",ma_code,ms_code,ms_sncode,'" + iUserCode + "',sysdate,'" + CurrentStep + "','" + iSourceCode + "',:bc_code,'',");
-                        sql.Append("'"+BgCode+"',sp_soncode,'0' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
+                        sql.Append("'" + BgCode + "',sp_soncode,'0' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
                         sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'");
                         List<string> InsertSQL = new List<string>();
                         for (int i = 0; i < BadCode.Length; i++)
@@ -520,7 +534,6 @@ namespace BenQGuru.eMES.DLLService
 
         private bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, string iResult, out string oErrMessage)
         {
-            
             if (iSN == "")
             {
                 oErrMessage = "SN不能为空";
@@ -554,7 +567,7 @@ namespace BenQGuru.eMES.DLLService
         /// <param name="iTestResult"></param>
         /// <param name="oErrMessage"></param>                                                      
         /// <returns></returns>
-        public bool SetTestDetail(string iSN, string iTestResult, string iResCode,ref string[] iTestDetail, out string oErrMessage)
+        public bool SetTestDetail(string iSN, string iTestResult, string iResCode, ref string[] iTestDetail, out string oErrMessage)
         {
             if (iSN == "" || iSN == null)
             {
@@ -569,7 +582,7 @@ namespace BenQGuru.eMES.DLLService
             for (int i = 0; i < iTestDetail.Length; i++)
             {
                 sql.Append("Insert into STEPTESTDETAIL (STD_ID,STD_CLASS,STD_SN,STD_MAKECODE,STD_ACTUALVALUE,STD_TESTRESULT,STD_INDATE,STD_RESCODE)");
-                sql.Append("values(STEPTESTDETAIL_SEQ.nextval,'ITEM"+i+"','" + iSN + "','" + omakeCode + "','" + iTestDetail[i] + "','" + iTestResult + "',sysdate,'" + iResCode + "');");
+                sql.Append("values(STEPTESTDETAIL_SEQ.nextval,'ITEM" + i + "','" + iSN + "','" + omakeCode + "','" + iTestDetail[i] + "','" + iTestResult + "',sysdate,'" + iResCode + "');");
             }
             sql.Append("end;");
             ExecuteSql(sql.ToString(), "insert");
@@ -640,7 +653,6 @@ namespace BenQGuru.eMES.DLLService
 
         public bool GoMo(string iMO, string iSN, string iResCode, out string oErrMessage)
         {
-            
             if (iSN == "")
             {
                 oErrMessage = "SN不能为空";
@@ -651,8 +663,30 @@ namespace BenQGuru.eMES.DLLService
             string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
             CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
             oErrMessage = param[6];
-            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
+            DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')", "select");
+            string ms_status = "";
+            string ms_stepcode = "";
+            string ms_nextstepcode = "";
+            if (dt.Rows.Count > 0)
+            {
+                ms_status = dt.Rows[0]["ms_status"].ToString();
+                ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
+                ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
+            }
+            string stepcode = GetStepCodeBySource(iResCode);
+            if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
+            {
+                oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
+                return false;
+            }
+            if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && ms_stepcode == stepcode))
+            {
+                if (ms_status == "3")
+                {
+                    oErrMessage = "";
+                }
                 return true;
+            }
             else
                 return false;
         }