Sfoglia il codice sorgente

修改OQC批判过的逻辑

章政 8 anni fa
parent
commit
d2a7c16d77

+ 6 - 5
UAS-MES/FunctionCode/OQC/OQC_BatchResultJudge.cs

@@ -229,7 +229,7 @@ namespace UAS_MES.OQC
         /// <returns></returns>
         private bool CheckBefore()
         {
-            if (ob_maxngacceptqty.Text == "" || ob_maxngacceptqty.Text=="0")
+            if (ob_maxngacceptqty.Text == "" || ob_maxngacceptqty.Text == "0")
             {
                 if (ob_aqlcode.Text == "")
                     OperateResult.AppendText(">>最大不合格允许通过数为空的时候必须填写维护AQL标准\n", Color.Red);
@@ -289,9 +289,10 @@ namespace UAS_MES.OQC
                         sql.Add("update make set ma_madeqty=ma_madeqty-" + batchqty + " where ma_code='" + ob_makecode.Text + "'");
                     }
                     //获取上一步执行的工序
-                    string[] PastCode = dh.getFieldDataByCondition("makeserial", "ms_paststep", "ms_sncode='" + ms_sncode.Text + "'").ToString().Split(',');
-                    string LastStepCode = PastCode[PastCode.Length - 1];
-                    sql.Add("update makeserial set ms_nextstepcode='" + LastStepCode + "',ms_status=1 where ms_checkno='" + ob_checkno.Text + "'");
+                    string PastCode = dh.getFieldDataByCondition("makeserial", "ms_paststep", "ms_sncode='" + ms_sncode.Text + "'").ToString();
+                    string[] LastStepCode = PastCode.Split(',');
+                    sql.Add("update makeserial set ms_paststep='" + PastCode.Substring(0, PastCode.LastIndexOf(","))+"'");
+                    sql.Add("update makeserial set ms_stepcode='" + LastStepCode[LastStepCode.Length - 2] + "',ms_nextstepcode='"+User.CurrentStepCode+"',ms_status=1 where ms_checkno='" + ob_checkno.Text + "'");
                     sql.Add("update makecraftdetail set mcd_inqty=mcd_inqty-" + batchqty + ",mcd_outqty = mcd_outqty - " + batchqty + ",mcd_okqty = mcd_okqty -" + batchqty + " where mcd_macode='" + ob_makecode.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
                     dh.ExecuteSQLTran(sql.ToArray());
                 }
@@ -299,7 +300,7 @@ namespace UAS_MES.OQC
                 {
                     //更新下一工序
                     string ErrorMessage = "";
-                    LogicHandler.UpdateMakeMessage(ms_sncode.Text, ob_makecode.Text, "OQC批判过", User.UserSourceCode, User.UserName, "批次通过", out ErrorMessage);
+                    LogicHandler.UpdateOQCMessage(ms_sncode.Text, ob_makecode.Text, "OQC批判过", User.UserSourceCode, User.UserName, "批次通过", out ErrorMessage);
                     //记录操作日志
                     LogicHandler.InsertMakeProcess(ms_sncode.Text, ob_makecode.Text, User.UserSourceCode, "批结果判定", Operate, User.UserName);
                 }

+ 65 - 6
UAS-MES/PublicMethod/LogicHandler.cs

@@ -919,19 +919,19 @@ namespace UAS_MES.PublicMethod
         /// <param name="iMPKind"></param>
         /// <param name="result"></param>
         /// <param name="iUserCode"></param>
-        public static void InsertMakeProcess(string iSnCode, string iMakeCode,string iSourceCode, string iMPKind, string result, string iUserCode)
+        public static void InsertMakeProcess(string iSnCode, string iMakeCode, string iSourceCode, string iMPKind, string result, string iUserCode)
         {
             string CurrentStep = "";
             string LineCode = "";
             string CurrentStepName = "";
-            GetStepCodeAndNameAndLineBySource(iSourceCode,ref CurrentStep,ref CurrentStepName ,ref LineCode);
+            GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
             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 + "','" + result + "',sysdate,'" + iUserCode + "',ma_wccode,'"+ LineCode + "','"+ iSourceCode + "',");
+            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 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("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and mcd_stepcode='" + CurrentStep + "'");
             dh.ExecuteSql(sql.ToString(), "insert");
             sql.Clear();
         }
@@ -1239,7 +1239,7 @@ namespace UAS_MES.PublicMethod
         /// <param name="iUserName"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public static bool SetMaterialDown(string iSnCode, string iBarCode,string iSourceCode, string iCurrentStep, string iUserName, out string oErrorMessage)
+        public static bool SetMaterialDown(string iSnCode, string iBarCode, string iSourceCode, string iCurrentStep, string iUserName, out string oErrorMessage)
         {
             //序列号不为空的时候
             oErrorMessage = "";
@@ -1277,7 +1277,7 @@ namespace UAS_MES.PublicMethod
                     string cm_stepcode = dt.Rows[0]["cm_stepcode"].ToString();
                     string cm_mccode = dt.Rows[0]["cm_mccode"].ToString();
                     dh.ExecuteSql("delete from Craftmaterial where cm_id=" + cm_id, "delete");
-                    InsertMakeProcess(ms_macode, iSnCode, iSourceCode,"下料操作", "下料成功", iUserName);
+                    InsertMakeProcess(ms_macode, iSnCode, iSourceCode, "下料操作", "下料成功", iUserName);
                     int count = dh.getRowCount("craftMaterial", "cm_mccode='" + cm_mccode + "' and cm_stepcode='" + cm_stepcode + "' and cm_sncode='" + iSnCode + "'");
                     if (count == 0)
                         dh.UpdateByCondition("makecraftdetail ", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty = mcd_okqty - 1", "mcd_mccode='" + cm_mccode + "' and mcd_stepcode='" + cm_stepcode + "'");
@@ -1288,6 +1288,65 @@ namespace UAS_MES.PublicMethod
                 return false;
         }
 
+        public static bool UpdateOQCMessage(string iSnCode, 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;
+            string checkno = "";
+            DataTable dt = (DataTable)dh.ExecuteSql("select count(ms_checkno) count,ms_checkno from makeserial where ms_checkno=(select ms_checkno from makeserial where ms_sncode='" + iSnCode + "') group by ms_checkno", "select");
+            if (dt.Rows.Count > 0)
+            {
+                batchqty = int.Parse(dt.Rows[0]["count"].ToString());
+                checkno = dt.Rows[0]["ms_checkno"].ToString();
+            }
+            object nextstepcode = dh.getFieldDataByCondition("makecraftdetail", "mcd_nextstepcode", "mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "'");
+            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.ToString() + "' where ms_checkno='" + checkno + "'");
+            }
+            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.ToString() + "' where ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
+            }
+            //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
+            dh.ExecuteSQLTran(sqls.ToArray());
+            sqls.Clear();
+            //记录操作日志
+            InsertMakeProcess(iSnCode, iMakeCode, iSourceCode, iMPKind, iResult, iUserCode);
+            //检测下道工序是否存在,不存在 更新状态为已完成
+            if (nextstepcode == null || nextstepcode.ToString() == "")
+            {
+                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='" + checkno + "'");
+                }
+                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>

+ 1 - 1
UAS-MES/UAS-MES.csproj

@@ -41,7 +41,7 @@
     <MinimumRequiredVersion>1.0.0.201</MinimumRequiredVersion>
     <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
     <WebPage>publish.htm</WebPage>
-    <ApplicationRevision>249</ApplicationRevision>
+    <ApplicationRevision>250</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>true</UseApplicationTrust>
     <CreateDesktopShortcut>true</CreateDesktopShortcut>