From 1539939b27d9fd14957033225d0904c9fc88c41c Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期日, 04 一月 2026 18:20:16 +0800
Subject: [PATCH] 调整 在库检验单 日期生成 sql 语句

---
 WebAPI/Controllers/BaseSet/Xt_grdAlignment_WMESController.cs |   93 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 87 insertions(+), 6 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Xt_grdAlignment_WMESController.cs b/WebAPI/Controllers/BaseSet/Xt_grdAlignment_WMESController.cs
index 6914c54..bc0c468 100644
--- a/WebAPI/Controllers/BaseSet/Xt_grdAlignment_WMESController.cs
+++ b/WebAPI/Controllers/BaseSet/Xt_grdAlignment_WMESController.cs
@@ -948,7 +948,7 @@
                 using (StreamReader sr = new StreamReader(Path.Combine(path, $"{language}.json"), Encoding.UTF8))
                 {
                     string lines;
-                    while ((lines = sr.ReadLine()) != null)//涓�琛屼竴琛屽幓璇伙紝濡傛灉璇诲彇杩欎竴琛岃祴鍊糽ines,骞朵笖lines= null璇佹槑璇诲彇瀹屼簡
+                    while ((lines = sr.ReadLine()) != null)
 
                     {
                         JsonStr1 += lines;
@@ -981,7 +981,7 @@
                         keySelector: p => $@"{p.HModuleCode}_{p.HFieldCode}",
                         elementSelector:  p => p.rowNum
                     );
-
+                    int subIndex = 0;
                     // 鐗堟湰鍙蜂笉涓�鑷� 鍒欒鍙栨暟鎹簱涓殑瀛楁锛屽皢瀛楁鍐欏叆鍒癹son瀵硅薄涓�
                     foreach (DataRow row in ds.Tables[0].Rows)
                     {
@@ -1007,8 +1007,23 @@
                                 languagePack[HModuleCode][HFieldCode] = new JArray();
                             }
 
-                            var targetJArray = (JArray)languagePack[HModuleCode][HFieldCode];
-                            targetJArray.Add(row[lang].ToString());
+                            var targetJArray = languagePack[HModuleCode][HFieldCode] as JArray;
+                            
+                            if (subIndex < rowNum - 1)
+                            {
+                                if (targetJArray.Count < subIndex + 1)
+                                {
+                                    targetJArray.Add(row[lang].ToString());
+                                }else
+                                {
+                                    targetJArray[subIndex] = row[lang].ToString();
+                                }
+                                subIndex++;
+                            }else
+                            {
+                                subIndex = 0;
+                            }
+
                         }
                         
                     }
@@ -1019,7 +1034,7 @@
                     objJsonResult.code = "1";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "Success锛�";
-                    objJsonResult.data = languagePack.ToString();
+                    objJsonResult.data = languagePack;
                     return objJsonResult;
                 } else
                 {
@@ -1027,7 +1042,7 @@
                     objJsonResult.code = "1";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "Success锛�";
-                    objJsonResult.data = JsonStr1;
+                    objJsonResult.data = JObject.Parse(JsonStr1);
                     return objJsonResult;
                 }
             }
@@ -1036,6 +1051,72 @@
                 LogService.Write("Exception锛�" + e.ToString());
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鍗曟嵁缈昏瘧 璇█鍖呯己澶辩殑閿� 鍙嶅悜鏄犲皠鍒版暟鎹簱
+        [Route("Xt_grdAlignment_WMES/syncMissingKeyToDB")]
+        [HttpGet]
+        public Object syncMissingKeyToDB(string missingObj)
+        {
+            oCN.BeginTran();
+            try
+            {
+                // 閫掑叆鐨勫弬鏁� 缁撴瀯鏄� { 妯″潡鍚�: [瀛楁鍚�1,瀛楁鍚�2] }
+                JObject missingKeys = JObject.Parse(missingObj);
+                
+                
+                // 閬嶅巻椤跺眰JObject瀵硅薄
+                foreach(var HMouldNameKVP in missingKeys)
+                {
+                    // 鏌ヨ涓昏〃涓槸鍚﹀瓨鍦ㄨ妯″潡 瀛樺湪锛屽垯杩斿洖涓昏〃涓殑妯″潡HInterID锛屼笉瀛樺湪锛屽垯鑾峰彇鏈�澶InterID+1
+                    string HMouldCode = HMouldNameKVP.Key;
+                    ds = oCN.RunProcReturn($"Exec h_p_syncMissingKeyToDB @HModuleCode='{HMouldCode}'", "h_p_syncMissingKeyToDB");
+                    int HInterID = (int)ds.Tables[0].Rows[0]["HInterID"];
+                    int rowCount = (int)ds.Tables[0].Rows[0]["rc"];
+                    int HEntryID = (int)ds.Tables[0].Rows[0]["HEntryID"];
+
+                    // 鎻掑叆涓昏〃
+                    if (rowCount == 0)
+                    {
+                        oCN.RunProc($@"insert into Xt_LanModuleMain(HInterID, HBillType, HModuleName, HModuleCode)
+                        values({HInterID}, 3033, '', '{HMouldCode}')");
+                    }
+
+
+                    string sql = $@"insert into Xt_LanModuleSub(HInterID, HEntryID, HFieldModelType, HFieldCode, HFieldName, HTranslationText_English, HTranslationText_Spain)
+                                    values";
+                    // 鎻掑叆瀛愯〃
+                    JArray HFieldCodes = HMouldNameKVP.Value as JArray;
+                    for(int i=0;i<HFieldCodes.Count; i++)
+                    {
+
+                        sql += $@"({HInterID}, {HEntryID+i}, 'i18n', '{HFieldCodes[i]}','{HFieldCodes[i]}','{HFieldCodes[i]}','{HFieldCodes[i]}'),";
+                    }
+
+                    sql = sql.Substring(0, sql.Length - 1) + ";";
+
+                    oCN.RunProc(sql);
+                }
+
+                
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Success!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                LogService.Write("Exception锛�" + e.ToString());
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
                 objJsonResult.Message = "Exception锛�" + e.Message.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;

--
Gitblit v1.9.1