Browse Source

添加首件核对功能

callm 1 năm trước cách đây
mục cha
commit
1e1b9509cf

+ 13 - 4
UAS-MES/FunctionCode/Make/Make_PackageCollection.cs

@@ -196,7 +196,7 @@ namespace UAS_MES.Make
                     dt = (DataTable)dh.ExecuteSql("select ms_status,ms_id,ms_makecode,ms_nextstepcode,ms_craftcode,ms_prodcode,nvl(ms_checkpack,0) ms_checkpack from makeserial where ms_sncode ='" + sn_code.Text + "' order by ms_id desc", "select");
                     if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sn_code.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage) || (dt.Rows.Count > 0 && dt.Rows[0]["ms_status"].ToString() == "2"))
                     {
-                        if (oMsID == "" || oMsID == "null" || oMsID == "0"|| (dt.Rows.Count > 0 && dt.Rows[0]["ms_status"].ToString() == "2"))
+                        if (oMsID == "" || oMsID == "null" || oMsID == "0" || (dt.Rows.Count > 0 && dt.Rows[0]["ms_status"].ToString() == "2"))
                         {
                             oMsID = dt.Rows[0]["ms_id"].ToString();
                             oMsStatus = dt.Rows[0]["ms_status"].ToString();
@@ -248,7 +248,7 @@ namespace UAS_MES.Make
                         PR_CHECKCARTONW = dh.getFieldDataByCondition("craftdetail left join craft on cr_id=cd_crid left join makeserial on ms_craftcode =cr_code and cr_prodcode = ms_prodcode", "nvl(cd_ifweigh,'0') cd_ifweigh", "ms_sncode='" + sn_code.Text + "' and ms_makecode='" + oMakeCode + "' and cd_stepcode = '" + User.CurrentStepCode + "'").ToString();
                         //获取序列号信息
                         sql.Clear();
-                        sql.Append("select nvl(ms_iostatus,0) ms_iostatus,pa_salecode,ms_salecode,ms_outno,ms_makecode,ms_prodcode,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,pa_checkno,pr_packrule,");
+                        sql.Append("select nvl(ms_iostatus,0) ms_iostatus,nvl(pr_iffai_user,0)pr_iffai_user,pa_salecode,ms_salecode,ms_outno,ms_makecode,ms_prodcode,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,pa_checkno,pr_packrule,");
                         sql.Append("nvl(pr_outboxinnerqty,0)pr_outboxinnerqty,nvl(pr_sendchecktype,'LineCode')pr_sendchecktype from makeserial left join product on ms_prodcode=pr_code left join packagedetail ");
                         sql.Append("on pd_barcode=ms_sncode left join package on pa_id =pd_paid where ms_id='" + oMsID + "'");
                         dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
@@ -260,9 +260,18 @@ namespace UAS_MES.Make
                         if (dt.Rows.Count > 0)
                         {
                             StandardQTY = decimal.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
+                            string pr_iffai_user = dt.Rows[0]["pr_iffai_user"].ToString();
                             ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
                             ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
                             ms_iostatus = dt.Rows[0]["ms_iostatus"].ToString();
+                            if (pr_iffai_user == "-1")
+                            {
+                                if (!LogicHandler.CheckFirst(ms_makecode, out ErrorMessage))
+                                {
+                                    OperateResult.AppendText(">工单" + ms_makecode + "首件未通过\n", Color.Red, sn_code);
+                                    return;
+                                }
+                            }
                             ms_outno = dt.Rows[0]["ms_outno"].ToString();
                             ms_salecode_text = dt.Rows[0]["ms_salecode"].ToString();
                             if (locksalecode.Checked && ms_salecode.Text != "" && ms_salecode.Text != ms_salecode_text)
@@ -890,8 +899,8 @@ namespace UAS_MES.Make
                                 {
                                     string ma_code = dt.Rows[i]["pd_makecode"].ToString();
                                     string num = dt.Rows[i]["num"].ToString();
-                                   // SQLS1.Add("delete from makeprocess where mp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + pa_outboxcode.Text + "' and ms_makecode='" + ma_code + "') and mp_makecode='" + ma_code + "' and mp_stepcode='" + User.CurrentStepCode + "'");
-                                   // SQLS1.Add("delete from steppassed where sp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + pa_outboxcode.Text + "' and ms_makecode='" + ma_code + "') and sp_makecode='" + ma_code + "' and sp_stepcode='" + User.CurrentStepCode + "'");
+                                    // SQLS1.Add("delete from makeprocess where mp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + pa_outboxcode.Text + "' and ms_makecode='" + ma_code + "') and mp_makecode='" + ma_code + "' and mp_stepcode='" + User.CurrentStepCode + "'");
+                                    // SQLS1.Add("delete from steppassed where sp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + pa_outboxcode.Text + "' and ms_makecode='" + ma_code + "') and sp_makecode='" + ma_code + "' and sp_stepcode='" + User.CurrentStepCode + "'");
                                     SQLS1.Add("update makecraftdetail set mcd_inqty=mcd_inqty-" + num + ",mcd_outqty=mcd_outqty-" + num + ",mcd_okqty=mcd_okqty-" + num + " where mcd_macode='" + ma_code + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
                                     //扣减已完工数
                                     SQLS1.Add("update make set ma_madeqty=ma_madeqty-(select count(1) from makeserial where  ms_outboxcode='" + pa_outboxcode.Text + "' and ms_makecode='" + ma_code + "' and ms_status=2) where ma_code='" + ma_code + "'");

+ 10 - 4
UAS-MES/FunctionCode/Make/Make_PackageCollectionWeigh.cs

@@ -293,9 +293,6 @@ namespace UAS_MES.Make
                         {
                             OperateResult.AppendText(">>" + sn_code.Text + " 序列号即将送检,此序列号经过维修,提示\n", Color.Purple);
                         }
-
-
-
                         //if (dh.CheckExist("configs", "code = 'checkpack' and data = '1'"))
                         //{
                         //    if (dt.Rows[0]["ms_checkpack"].ToString() != "0")
@@ -312,7 +309,7 @@ namespace UAS_MES.Make
                         }
                         //PR_CHECKCARTONW = dh.getFieldDataByCondition("craftdetail left join craft on cr_id=cd_crid left join makeserial on ms_craftcode =cr_code", "nvl(cd_ifweigh,'0') cd_ifweigh", "ms_sncode='" + sn_code.Text + "' and ms_makecode='" + oMakeCode + "' and cd_stepcode = '" + User.CurrentStepCode + "'").ToString();
                         sql.Clear();
-                        sql.Append("select nvl(ms_iostatus,0) ms_iostatus,ms_outno,ms_salecode,ms_makecode,ms_prodcode,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,pa_checkno,pr_packrule,");
+                        sql.Append("select nvl(ms_iostatus,0) ms_iostatus,nvl(pr_iffai_user,0)pr_iffai_user,ms_outno,ms_salecode,ms_makecode,ms_prodcode,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,pa_checkno,pr_packrule,");
                         sql.Append("nvl(pr_outboxinnerqty,0)pr_outboxinnerqty,nvl(pr_sendchecktype,'LineCode')pr_sendchecktype from makeserial left join product on ms_prodcode=pr_code left join packagedetail ");
                         sql.Append("on pd_barcode=ms_sncode left join package on pa_id =pd_paid where ms_id='" + oMsID + "'");
                         dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
@@ -323,12 +320,21 @@ namespace UAS_MES.Make
                         string ms_salecode_text = "";
                         if (dt.Rows.Count > 0)
                         {
+                            string pr_iffai_user =  dt.Rows[0]["pr_iffai_user"].ToString();
                             StandardQTY = decimal.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
                             ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
                             ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
                             ms_iostatus = dt.Rows[0]["ms_iostatus"].ToString();
                             ms_outno = dt.Rows[0]["ms_outno"].ToString();
                             ms_salecode_text = dt.Rows[0]["ms_salecode"].ToString();
+                            if (pr_iffai_user == "-1")
+                            {
+                                if (!LogicHandler.CheckFirst(ms_makecode, out ErrorMessage))
+                                {
+                                    OperateResult.AppendText(">工单" + ms_makecode + "首件未通过\n", Color.Red, sn_code);
+                                    return;
+                                }
+                            }
                             if (locksalecode.Checked && ms_salecode.Text != "" && ms_salecode.Text != ms_salecode_text)
                             {
                                 OperateResult.AppendText(">>序列号" + sn_code.Text + "所属订单号" + ms_salecode_text + "与界面订单号" + ms_salecode.Text + "不同,无法采集\n", Color.Red, sn_code);

+ 46 - 0
UAS-MES/PublicMethod/BaseUtil.cs

@@ -57,6 +57,52 @@ namespace UAS_MES.PublicMethod
             return selectConetnt.Remove(selectConetnt.Length - 1, 1).ToString();
         }
 
+        public static Dictionary<string, object> ToDictionary(string JsonData)
+        {
+            object Data = null;
+            Dictionary<string, object> Dic = new Dictionary<string, object>();
+            if (JsonData.StartsWith("["))
+            {
+                //如果目标直接就为数组类型,则将会直接输出一个Key为List的List<Dictionary<string, object>>集合 
+                //使用示例List<Dictionary<string, object>> ListDic = (List<Dictionary<string, object>>)Dic["List"]; 
+                List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
+                MatchCollection ListMatch = Regex.Matches(JsonData, @"{[\s\S]+?}");//使用正则表达式匹配出JSON数组 
+                foreach (Match ListItem in ListMatch)
+                {
+                    List.Add(ToDictionary(ListItem.ToString()));//递归调用 
+                }
+                Data = List;
+                Dic.Add("List", Data);
+            }
+            else
+            {
+                MatchCollection Match = Regex.Matches(JsonData, @"""(.+?)"": {0,1}(\[[\s\S]+?\]|null|"".+?""|-{0,1}\d*)");//使用正则表达式匹配出JSON数据中的键与值 
+                foreach (Match item in Match)
+                {
+                    try
+                    {
+                        if (item.Groups[2].ToString().StartsWith("["))
+                        {
+                            //如果目标是数组,将会输出一个Key为当前Json的List<Dictionary<string, object>>集合 
+                            //使用示例List<Dictionary<string, object>> ListDic = (List<Dictionary<string, object>>)Dic["Json中的Key"]; 
+                            List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
+                            MatchCollection ListMatch = Regex.Matches(item.Groups[2].ToString(), @"{[\s\S]+?}");//使用正则表达式匹配出JSON数组 
+                            foreach (Match ListItem in ListMatch)
+                            {
+                                List.Add(ToDictionary(ListItem.ToString()));//递归调用 
+                            }
+                            Data = List;
+                        }
+                        else if (item.Groups[2].ToString().ToLower() == "null") Data = null;//如果数据为null(字符串类型),直接转换成null
+                        else Data = item.Groups[2].ToString(); //数据为数字、字符串中的一类,直接写入 
+                        Dic.Add(item.Groups[1].ToString(), Data);
+                    }
+                    catch { }
+                }
+            }
+            return Dic;
+        }
+
         /// <summary>
         /// 禁止DataGirdView排序
         /// </summary>

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

@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Data;
+using System.IO;
+using System.Net;
 using System.Text;
 using System.Windows;
 using System.Windows.Forms;
@@ -37,6 +39,67 @@ namespace UAS_MES.PublicMethod
             dh.ExecuteSql(sql.ToString(), "insert");
         }
 
+        public static bool CheckFirst(string iMakeCode, out string oMsg)
+        {
+            oMsg = "";
+            try
+            {
+                string url = "http://192.168.70.7:9999/mes-etl/ingenico/openApi/checkYrFaiByMacode?maCode=" + iMakeCode;//html调用的地址              
+                HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url);
+                if (webrequest == null)
+                {
+                    return false;
+                }
+                webrequest.Method = "GET";
+                webrequest.Timeout = 1000;
+                webrequest.ContentType = "application/json; charset=utf-8";
+                System.Collections.Hashtable pars = new System.Collections.Hashtable();
+                string buffer = "";
+                //发送POST数据 
+                if (!(pars == null || pars.Count == 0))
+                {
+                    foreach (string key in pars.Keys)
+                    {
+                        buffer = buffer + "&" + key + "=" + pars[key].ToString();
+                    }
+                    byte[] data = Encoding.UTF8.GetBytes(buffer);
+                    using (Stream stream = webrequest.GetRequestStream())
+                    {
+                        stream.Write(data, 0, data.Length);
+                    }
+                }
+
+                string[] values = webrequest.Headers.GetValues("Content-Type");
+                WebResponse myResponse = webrequest.GetResponse();
+
+                using (Stream resStream = myResponse.GetResponseStream())//得到回写的流
+                {
+                    StreamReader newReader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
+                    string Content = newReader.ReadToEnd();
+                    Dictionary<string, object> dic = new Dictionary<string, object>();
+                    dic = BaseUtil.ToDictionary(Content);
+                    if (!dic.ContainsKey("erpaccount"))
+                    {
+                        oMsg = dic["message"].ToString();
+                        if (oMsg.Contains("true"))
+                        {
+                            return true;
+                        }
+                        else
+                        {
+                            return false;
+                        }
+                    }
+                    newReader.Close();
+                }
+            }
+            catch (Exception ex)
+            {
+                LogManager.DoLog(ex.Message.ToString());
+            }
+            return true;
+        }
+
 
         public static void SendMessage(string iUserID, string iUserName, string iContext)
         {
@@ -636,7 +699,7 @@ namespace UAS_MES.PublicMethod
             {
                 if (iMakeCode != oMakeCode && oMakeCode != "" && iMakeCode != "" && oStatus != "2")
                 {
-                    string ChangeMakeCode = System.Windows.Forms.MessageBox.Show("序列号" + iSN + "所属工单不同,是否切换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question,MessageBoxDefaultButton.Button2).ToString();
+                    string ChangeMakeCode = System.Windows.Forms.MessageBox.Show("序列号" + iSN + "所属工单不同,是否切换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2).ToString();
                     //如果选择不切换赋值当前界面工单
                     if (ChangeMakeCode != "Yes")
                     {