Browse Source

优化文件上传,排位图自动审核,过站处理

yhluo 6 months ago
parent
commit
6e30dbb3a7
1 changed files with 59 additions and 45 deletions
  1. 59 45
      UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

+ 59 - 45
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

@@ -431,38 +431,45 @@ namespace UAS_MES_NEW.Make
                                 LogMessage($"文件: {file},无SN信息");
                                 continue;
                             }
+                            
+                            if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
+                            {
+                                if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, SN, "日志解析", "OK", User.UserCode, out oErrorMessage))
+                                {
+                                    string sqlStr = $@"select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,ma_qty - nvl(mcd_okqty, 0) remain_qty 
+                                        from make left join makecraftdetail on mcd_maid=ma_id left join product on pr_code = ma_prodcode 
+                                        where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'";
+                                    dt = (DataTable)dh.ExecuteSql(sqlStr, "select");
+                                    BaseUtil.SetFormValue(Controls, dt);
+                                    //记录操作日志
+                                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析成功", SN, "");
+                                    LogMessage($"处理过站成功");
+                                }
+                                else
+                                {
+                                    LogMessage($"处理过站error:{oErrorMessage}");
+                                }
+                            }
+                            else
+                            {
+                                LogMessage($"处理过站核对error:{oErrorMessage}");
+                            }
+
                             LogMessage($"文件: {file},开始上传");
                             if (UploadFileToFtp(file))
                             {
                                 /*dh.ExecuteSql($@"insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class,std_testresult) 
                                                     select STEPTESTDETAIL_seq.nextval,'{SN}','{ma_code.Text}',sysdate,'思泰克SPI',
-                                                    'http://112.48.67.154:8088/ftp/mes/TestData/{DateTime.Now.ToString("yyyyMMdd")}/{Path.GetFileName(file)}.xml' from dual", "insert");*/
+                                                    'http://112.48.67.154:8088/ftp/mes/TestData/{DateTime.Now.ToString("yyyyMMdd")}/{Path.GetFileName(file)}' from dual", "insert");*/
                                 dh.ExecuteSql($@"insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class,std_testresult) 
                                                     select STEPTESTDETAIL_seq.nextval,'{SN}','{ma_code.Text}',sysdate,'思泰克SPI',
-                                                    'http://192.168.1.92:8088/ftp/mes/TestData/{DateTime.Now.ToString("yyyyMMdd")}/{Path.GetFileName(file)}.xml' from dual", "insert");
+                                                    'http://192.168.1.92:8088/ftp/mes/TestData/{DateTime.Now.ToString("yyyyMMdd")}/{Path.GetFileName(file)}' from dual", "insert");
                                 string xmlContent = File.ReadAllText(file);
                                 if (ConsoleLog(xmlContent, file))
                                 {
                                     File.Delete(file);
                                 }
                             }
-
-                            /*if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
-                            {
-                                if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, SN, "日志解析", "OK", User.UserCode, out oErrorMessage))
-                                {
-                                    
-                                }
-                                else
-                                {
-                                    LogMessage(">>" + oErrorMessage + "\n");
-                                }
-                            }
-                            else
-                            {
-                                LogMessage(">>" + oErrorMessage + "\n");
-                            }*/
-
                             #region // 20250630 M 调整对接方式 
                             /*List<SpiData> csvData; 
                             //csvData = ParseCsvFile(file);
@@ -699,8 +706,11 @@ namespace UAS_MES_NEW.Make
                             if (!dh.CheckExist("productsmt", "ps_prodcode='" + Part_ + "'"))
                             {
                                 ps_id = dh.GetSEQ("productsmt_seq");
-                                dh.ExecuteSql("insert into productsmt(ps_id,ps_prodcode,ps_status,ps_statuscode,PS_LINECODE,PS_CODE)" +
-                                    "values('" + ps_id + "','" + Part_ + "','在录入','ENTERING','" + lineId + "','" + PS_CODE + "')", "insert");
+                                /*dh.ExecuteSql("insert into productsmt(ps_id,ps_prodcode,ps_status,ps_statuscode,PS_LINECODE,PS_CODE,PS_TABLE,PS_INDATE,PS_AUDITDATE)" +
+                                    "values('" + ps_id + "','" + Part_ + "','在录入','ENTERING','" + lineId + "','" + PS_CODE + "','A',SYSDATE,SYSDATE)", "insert");*/
+
+                                dh.ExecuteSql("insert into productsmt(ps_id,ps_prodcode,ps_status,ps_statuscode,PS_LINECODE,PS_CODE,PS_TABLE,PS_INDATE,PS_AUDITDATE,PS_AUDITMAN)" +
+                                    "values('" + ps_id + "','" + Part_ + "','已审核','AUDITED','" + lineId + "','" + PS_CODE + "','A',SYSDATE,SYSDATE,'"+ User.UserName +"')", "insert");
                             }
                             else
                             {
@@ -844,7 +854,7 @@ namespace UAS_MES_NEW.Make
                 {
                     if (string.IsNullOrEmpty(item)) continue;
                     string[] currItem = item.Split(',');
-                    string res = "",wo = "";
+                    string res = "",wo = "",lineName = "";
                     if(equiType == "SPI")
                     {
                         res = currItem[1];
@@ -860,6 +870,7 @@ namespace UAS_MES_NEW.Make
                         if (dt.Rows.Count > 0 && !String.IsNullOrEmpty(dt.Rows[0]["dl_macode"].ToString()))
                         {
                             wo = dt.Rows[0]["dl_macode"].ToString();
+                            lineName = dt.Rows[0]["li_code"].ToString();
                         }
                         else
                         {
@@ -870,7 +881,8 @@ namespace UAS_MES_NEW.Make
                     Log itemLog = new Log()
                     {
                         SN = currItem[0],
-                        work_order = wo,
+                        Work_order = wo,
+                        Line = lineName,
                         Result = res,
                         Details = equiType == "SPI" ? currItem[1] : currItem[3]
                     };
@@ -878,12 +890,13 @@ namespace UAS_MES_NEW.Make
 
                 }
                 LogMessage($"文件: {PathName},共{fileNum}条记录,已解析");
-                InsertDb(logArr, PathName);
-
-                File.WriteAllText(PathName, string.Empty);
-                if (ConsoleLog(restOfStream, PathName))
+                if (InsertDb(logArr, PathName))
                 {
-                    File.Delete(PathName);
+                    if (ConsoleLog(restOfStream, PathName))
+                    {
+                        File.WriteAllText(PathName, string.Empty);
+                        File.Delete(PathName);
+                    }
                 }
             }
             catch (Exception ex)
@@ -892,7 +905,7 @@ namespace UAS_MES_NEW.Make
             }
         }
 
-        private void InsertDb(List<Log> logs, string PathName)
+        private bool InsertDb(List<Log> logs, string PathName)
         {
             try
             {
@@ -904,46 +917,46 @@ namespace UAS_MES_NEW.Make
                     {
                         if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "日志解析", "OK", User.UserCode, out oErrorMessage))
                         {
-                            if (oErrorMessage.Contains("AFTERSUCCESS")) LogMessage(">>" + oErrorMessage + "\n");
-                            sql.Clear();
-                            sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
-                            sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
-                            sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "'  and mcd_stepcode='" + User.CurrentStepCode + "'");
-                            dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                            string sqlStr = $@"select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,ma_qty - nvl(mcd_okqty, 0) remain_qty 
+                                        from make left join makecraftdetail on mcd_maid=ma_id left join product on pr_code = ma_prodcode 
+                                        where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'";
+                            dt = (DataTable)dh.ExecuteSql(sqlStr, "select");
                             BaseUtil.SetFormValue(Controls, dt);
-                            //记录日志
+                            //记录操作日志
                             LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析成功", item.SN, "");
-                            LogMessage("<<解析成功\n");
+                            LogMessage($"处理过站成功");
                         }
                         else
                         {
-                            LogMessage(">>" + oErrorMessage + "\n");
+                            LogMessage($"处理过站error:{oErrorMessage}");
                         }
                     }
                     else
                     {
-                        LogMessage(">>" + oErrorMessage + "\n");
+                        LogMessage($"处理过站核对error:{oErrorMessage}");
                     }
-
                     param.Add(item.SN);
-                    param.Add(item.work_order);
-                    param.Add(item.Result == "PASS" ? "OK" :"NG");
+                    param.Add(item.Work_order);
+                    param.Add(item.Result == "PASS" ? "OK" : "NG");
                     param.Add(equiType);
                     param.Add(item.Details);
                     param.Add(User.UserCode);
                     param.Add(User.UserSourceCode);
-                    param.Add(User.UserLineCode);
+                    param.Add(item.Line);
                     string res = "";
                     param.Add(res);
                     string[] paramList = param.ToArray();
                     dh.CallProcedure("cs_insert_testrejects", ref paramList);
                     param.Clear();
+                    return true;
                 }
             }
             catch (Exception ex)
             {
-                MessageBox.Show(this.ParentForm, ex.Message, "警告");
+                LogMessage($"处理解析写入error:{ex.Message}");
+                return false;
             }
+            return false;
         }
 
         private bool ConsoleLog(string Content, string PathName)
@@ -1260,7 +1273,8 @@ namespace UAS_MES_NEW.Make
 
         private class Log
         {
-            public string work_order {  get; set; }
+            public string Work_order {  get; set; }
+            public string Line { get; set; }
             public string SN { set; get; }
             public string Result { set; get; }
             /*public List<NgData> Details { set; get; }*/