Browse Source

北美项目抄写时,DSN用的smes接口里面的数据

chenjiangqun 2 năm trước cách đây
mục cha
commit
7cd8bd75d6

+ 58 - 0
FactoryTool_CShare/Business/V2Method.cs

@@ -19,6 +19,7 @@ namespace MOKA_Factory_Tools
 {
     internal class V2Method
     {
+        private static string url_getDSNFromSmes = "http://smes-app-prod.tclking.com:9006/api/xm/GetXMTVParts?TVSN=";
         public static MidList midList { get; set; }
 
         private static string url_getMessage = "https://cn.uc.qhmoka.com/scbc-server/clientType/getMessage.do";
@@ -955,5 +956,62 @@ namespace MOKA_Factory_Tools
 
             return true;
         }
+
+        //北美项目,不抄从idm上获取的DSN,用smse上的
+        public static bool GetDSNFromSmes(string SN, out string DSN)
+        {
+            string msg;
+            DSN = "";
+
+            HttpHelper http = new HttpHelper();
+            HttpItem item = new HttpItem()
+            {
+                Encoding = Encoding.UTF8,
+                Method = "post",
+                ContentType = "application/x-www-form-urlencoded",
+                KeepAlive = false
+            };
+            item.URL = url_getDSNFromSmes + SN;
+            HttpResult hResult = http.GetHtml(item);
+            if (hResult.StatusCode == System.Net.HttpStatusCode.OK)
+            {
+                try
+                {
+                    using (JsonTextReader reader = new JsonTextReader(new StringReader(hResult.Html)))
+                    {
+                        JObject jObject = (JObject)JToken.ReadFrom(reader);
+                        reader.Close();
+
+                        foreach (var ss in jObject["Tvparts"])  //查找某个字段与值
+                        {
+                            //如果里面的TypeCode为MA(主板),读出他的PSN                  
+                            if (ss["PartTypeCode"].Value<string>().Equals("DSN-T", StringComparison.OrdinalIgnoreCase))
+                            {
+                                DSN = ss["PartSN"].Value<string>();
+                                break;
+                            }
+                        }
+                        if (DSN == "" || DSN == null)
+                        {
+                            MessageBox.Show("查不到该SN对应的主板DSN号");
+                            return false;
+                        }
+                        Log.WriteInfoLog("PartSN" + DSN);
+                        return true;
+                    }
+                }
+                catch (Exception e)
+                {
+                    msg = e.Message;
+                    Log.WriteErrorLog("IsCuringBOM Json-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                }
+            }
+            else
+            {
+                msg = hResult.StatusDescription;
+                Log.WriteInfoLog("IsCuringBOM Http-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+            }
+            return false;
+        }
     };
 };

+ 4 - 1
FactoryTool_CShare/Models/StructList.cs

@@ -30,7 +30,7 @@ namespace MOKA_Factory_Tools
         public string whiteType { get; set; }
         public RokuCustomer rokuCustomer { get; set; }
         public Dictionary <string,string> keytype { get; set; }
-        public bool aesEncrypt { get; set; } = false;
+        public bool aesEncrypt { get; set; } = false;    
     }
 
     public class RokuData
@@ -188,6 +188,9 @@ namespace MOKA_Factory_Tools
         /// </summary>
         public int GFoolProofingCount { get; set; } = 2;
 
+        #region 北美DSN使用Smes里面的,不用输入订单号返回的
+        public bool UserDSNFromSmes { get; set; } = false;
+        #endregion
         /// <summary>
         /// 是否导出日本板卡的ACAS ID与SN号;
         /// </summary>

+ 11 - 0
FactoryTool_CShare/Views/Main.cs

@@ -933,6 +933,17 @@ namespace MOKA_Factory_Tools
                 }
                 #endregion
 
+                #region 北美DSN的配置项使用SMES里面的
+                if (jObject["UserDSNFromSmes"] == null)
+                {
+                    SaveJsonConfig("UserDSNFromSmes", functionSetting1.UserDSNFromSmes);
+                }
+                else
+                {
+                    functionSetting1.UserDSNFromSmes = jObject["UserDSNFromSmes"].Value<bool>();
+                }
+                #endregion
+
                 #region 串口重试机制;
                 if (jObject["EnableRetry"] != null)
                 {

+ 34 - 11
FactoryTool_CShare/Views/OperationPanel.cs

@@ -89,13 +89,11 @@ namespace MOKA_Factory_Tools
 
         private void SetCheckboxStatusByConfig()
         {
-#if DEBUG
 
-#else
             // 非小米的抄写,不处理.需要保证其他工厂的配置不受影响;
             if (!FunctionSettingNow.MITVEnable && !FunctionSettingNow.IndiaMITVEnable)
                 return;
-#endif
+
             #region 默认根据config启用是否抄写;
             SetCheckboxStatus(WriteDID, cfg_writedone.DIDWrite_YesNo);
             SetCheckboxStatus(WriteMac, cfg_writedone.MacWrite_YesNo);
@@ -1832,8 +1830,8 @@ namespace MOKA_Factory_Tools
             string ErrMsg = "";
             string psn = "";
             string devicecode = "";
-            //PSN
-            string GetPSNInFsn;
+
+            string GetSmesDSN = "";
 #if !SIMULATION && !OD_VER
             //进工厂
             if (!TVPort.IsOpen)
@@ -2355,6 +2353,16 @@ namespace MOKA_Factory_Tools
                                 Log.WriteErrorLog(ErrMsg);
                                 goto end;
                             }
+                            //北美DSN配置项
+                            if (FunctionSettingNow.UserDSNFromSmes)
+                            {
+                                if (!V2Method.GetDSNFromSmes(SN, out GetSmesDSN))
+                                {
+                                    ErrMsg = string.Format("GetDSNFromSmes error!\r\n{0}", keyInfo.DSN.data);
+                                    Log.WriteErrorLog(ErrMsg);
+                                    goto end;
+                                }
+                            }
 #if OD_VER
                         if (keyInfo != null)
                         {
@@ -2436,12 +2444,27 @@ namespace MOKA_Factory_Tools
                     if (midListNow.keytype.ContainsKey("DSN"))
                     {
                         // 预防切了pid后,deviceCode变化了;
-                        if (keyInfo.DSN.data != null && keyInfo.DSN.data.IndexOf(devicecode) == -1)
+                        //不是北美项目,正常运行
+                        if (!FunctionSettingNow.UserDSNFromSmes)
                         {
-                            ErrMsg = string.Format("The device code [{0}] is not included in the DSN [{1}]!\r\n", devicecode, keyInfo.DSN.data);
-                            Log.WriteErrorLog(ErrMsg);
-                            goto end;
+                            // 预防切了pid后,deviceCode变化了;
+                            if (keyInfo.DSN.data != null && keyInfo.DSN.data.IndexOf(devicecode) == -1)
+                            {
+                                ErrMsg = string.Format("The device code [{0}] is not included in the DSN [{1}]!\r\n", devicecode, keyInfo.DSN.data);
+                                Log.WriteErrorLog(ErrMsg);
+                                goto end;
+                            }
                         }
+                        else
+                        {
+                            // 用MES的DSN来判断;
+                            if (GetSmesDSN != null && GetSmesDSN.IndexOf(devicecode) == -1)
+                            {
+                                ErrMsg = string.Format("The device code [{0}] is not included in the GetSmesDSN [{1}]!\r\n", devicecode, GetSmesDSN);
+                                Log.WriteErrorLog(ErrMsg);
+                                goto end;
+                            }
+                        }                       
                     }
 
 #region EDID屏抄写是从MID中获取值;
@@ -4810,13 +4833,13 @@ namespace MOKA_Factory_Tools
                     }
                     else
                     {// 如果是G客户,要在抄写其他key前时行fsn+psn查重处理;
-                        if (!CommonMethod.IsNumberAndWord(keyInfo.DSN.data))
+                        if (!CommonMethod.IsNumberAndWord(FunctionSettingNow.UserDSNFromSmes ? GetSmesDSN : keyInfo.DSN.data))
                         {
                             ErrMsg = string.Format("DSN format error!\r\n{0}", keyInfo.DSN.data);
                             Log.WriteErrorLog(ErrMsg);
                             goto end;
                         }
-                        byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN.data);
+                        byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(FunctionSettingNow.UserDSNFromSmes ? GetSmesDSN : keyInfo.DSN.data);
                         Log.WriteInfoLog("Write DSN...");
                         if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
                         {