callm 3 tygodni temu
rodzic
commit
c3b1fa6688

+ 15 - 8
UAS-出货标签管理(贸易版-正常)/UAS_出货标签管理.cs

@@ -2539,7 +2539,8 @@ namespace UAS_LabelMachine
 
             // 辅助资料明细(产地等): 使用本地已有数据(苍穹无对应查询接口, 如需更新手动导入)
 
-            // 物料查询: 调用苍穹物料批量查询接口 POST /kapi/v2/basedata/bd_material/batchQuery
+            // 物料查询: 调用苍穹物料批量查询接口 POST /kapi/v2/hc68/basedata/bd_material/batchQuery-1
+            // 该接口返回 hc68_zhrl(中盒容量) 和 hc68_cd_name(产地) 字段
             var queryBody = new Dictionary<string, object>
             {
                 { "pageSize", 1000 },
@@ -2559,7 +2560,7 @@ namespace UAS_LabelMachine
             }
             // prcode=="" 时查全部已审核物料, 后面在C#里增量过滤
 
-            DataTable table = client.BatchQuery("/kapi/v2/basedata/bd_material/batchQuery", queryBody);
+            DataTable table = client.BatchQuery("/kapi/v2/hc68/basedata/bd_material/batchQuery-1", queryBody);
 
             // 收集所有物料编码, 用于查库存信息(最小包装量在库存信息接口里, 不在物料接口里)
             var materialCodes = new List<string>();
@@ -2579,11 +2580,12 @@ namespace UAS_LabelMachine
                 var invQueryBody = new Dictionary<string, object>
                 {
                     { "createorg_number", createOrgNumber },
-                    { "numbers", batchCodes }
+                    { "numbers", batchCodes },
+                    { "pageSize", 1000 }
                 };
                 try
                 {
-                    DataTable invTable = client.BatchQuery("/kapi/v2/sbd/bd_materialinventoryinfo/materialInvQuery", invQueryBody, false);
+                    DataTable invTable = client.BatchQuery("/kapi/v2/sbd/bd_materialinventoryinfo/materialInvQuery", invQueryBody);
                     for (int i = 0; i < invTable.Rows.Count; i++)
                     {
                         string code = GetCol(invTable.Rows[i], "masterid_number", "masterid_name");
@@ -2594,8 +2596,13 @@ namespace UAS_LabelMachine
                 }
                 catch (Exception ex)
                 {
-                    // 库存信息查询失败不中断物料同步, 最小包装量留空
-                    System.Diagnostics.Debug.WriteLine("物料库存信息查询失败: " + ex.Message);
+                    // 库存信息查询失败暴露出来, 便于诊断
+                    System.Windows.Forms.MessageBox.Show(
+                        "物料库存信息查询失败:\n" + ex.Message + "\n\n" +
+                        "createOrgNumber = " + createOrgNumber + "\n" +
+                        "本批编码数 = " + batchCodes.Length + "\n" +
+                        "前3个编码 = " + string.Join(",", batchCodes.Take(3).ToArray()),
+                        "库存信息查询诊断");
                 }
             }
 
@@ -2629,12 +2636,12 @@ namespace UAS_LabelMachine
                 pr_id.Add(materialId);
                 pr_spec.Add(GetCol(row, "modelnum", "specification", "FSPECIFICATION", "model"));
                 pr_detail.Add(GetCol(row, "name", "FNAME", "materialName"));
-                pr_madein.Add(GetCol(row, "pcmAssistant5", "F_PCMN_ASSISTANT5", "assistant5", "placeOfOrigin", "origin"));
+                pr_madein.Add(GetCol(row, "hc68_cd_name", "pcmAssistant5", "F_PCMN_ASSISTANT5", "assistant5"));
                 // 最小包装量从库存信息查询结果取
                 string zxbzs = "";
                 if (minPackDict.ContainsKey(code)) zxbzs = minPackDict[code];
                 pr_zxbzs.Add(zxbzs);
-                pr_midboxcapacity_user.Add(GetCol(row, "pcmInteger", "F_PCMN_Integer", "F_PCMN_integer", "midBoxCapacity"));
+                pr_midboxcapacity_user.Add(GetCol(row, "hc68_zhrl", "pcmInteger", "F_PCMN_Integer", "midBoxCapacity"));
             }
             if (pr_code.ToArray().Length > 0)
             {

+ 5 - 0
UAS-出货标签管理(贸易版-正常)/金蝶对接改造/K3CloudApiClient.cs

@@ -211,6 +211,11 @@ namespace UAS_LabelMachine.Kingdee
             string path = apiPath.StartsWith("/") ? apiPath.Substring(1) : apiPath;
             string url = ServerUrl + path;
 
+            // 临时诊断: 把实际请求URL写入文件
+            try { System.IO.File.AppendAllText(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "debug_url.txt"),
+                "[" + System.DateTime.Now.ToString("HH:mm:ss") + "] URL=" + url + " | ServerUrl=[" + (ServerUrl ?? "null") + "] apiPath=[" + apiPath + "]\r\n",
+                System.Text.Encoding.UTF8); } catch { }
+
             if (withTokenHeader) EnsureToken();
 
             var req = (HttpWebRequest)WebRequest.Create(url);