kyy
2025-12-01 f0ac4ec65279aa31d568b933afeb8237bee73a72
WebApi/Gs.Sys/Services/FmController.cs
@@ -1,4 +1,4 @@
using Gs.Toolbox;
using Gs.Toolbox;
using Gs.Toolbox.ApiCore.Abstract.Mvc;
using Gs.Toolbox.ApiCore.Common.Mvc;
using Gs.Toolbox.ApiCore.Group;
@@ -257,6 +257,14 @@
                string keyGuid = model.keyGuid;
                string keyNo = model.keyNo;
                string idtype = model.idtype;//这个仅仅是更新工单状态的时候有
                string keyMeth = model.keyMeth;
                // 特殊处理:delete操作使用TestErpUrl101接口
                if (keyMeth != null && keyMeth.Equals("delete", StringComparison.OrdinalIgnoreCase))
                {
                    (_rtnInt, _rtnStr) = InterfaceUtil.HttpPostErp(_erpJson, keyUserGuid, keyGuid, keyNo, 101);
                }
                else
                if (string.IsNullOrEmpty(idtype))
                {
                    (_rtnInt, _rtnStr) = InterfaceUtil.HttpPostErp(_erpJson, keyUserGuid, keyGuid, keyNo);
@@ -286,6 +294,7 @@
            {
                Gs.Toolbox.LogHelper.Debug(this.ToString(), "Fm SendErp:" + ex.Message);
                return "发送erp失败:" + ex.Message;
            }
            if (_rtnInt <= 0)
            {
@@ -309,17 +318,16 @@
            string keyMeth = model.keyMeth;
            string keyNo = model.keyNo;
            string idtype = model.idtype;//这个仅仅是更新工单状态的时候有
            if (keyMeth.ToUpper() == "delete".ToUpper())
                return "";
            try
            {
                System.Data.DataSet dset = new System.Data.DataSet();
                SqlParameter[] parameters =
                      {
                       new("@inOrderGuid", keyGuid),
                       new("@inEdtUserGuid", keyUserGuid),
                       new("@keyMeth", keyMeth.ToLower()),
                   };
               new("@inOrderGuid", keyGuid),
               new("@inEdtUserGuid", keyUserGuid),
               new("@keyMeth", keyMeth.ToLower()),
           };
                dset = DbHelperSQL.RunProcedure(keyProduce, parameters, "0");
                if (dset == null)
                    return "";
@@ -327,12 +335,82 @@
                    return "";
                if (dset.Tables[0].Rows.Count <= 0)
                    return "";
                //这是普通的接口
                // 这是普通的接口
                string _mesGuid = dset.Tables[0].Rows[0][0].ToString();
                dynamic _datajson = new ExpandoObject();
                if (dset.Tables.Count > 1)
               // delete方法专属处理逻辑
                 if (keyMeth.Equals("delete", StringComparison.OrdinalIgnoreCase))
                 {
                     try
                     {
                         _datajson = new ExpandoObject();
                         List<string> deleteLst = new List<string>();
                         // 提取billType
                         try
                         {
                             if (dset.Tables.Count > 0 && dset.Tables[0]?.Rows.Count > 0)
                             {
                                 string billType = dset.Tables[0].Rows[0][0]?.ToString() ?? "";
                                 ((IDictionary<string, object>)_datajson)["billType"] = billType;
                             }
                         }
                         catch (Exception ex)
                         {
                             Gs.Toolbox.LogHelper.Debug(this.ToString(), $"提取billType异常:{ex.Message}");
                         }
                         // 提取BILLNO列表
                         if (dset.Tables.Count > 1 && dset.Tables[1]?.Rows.Count > 0)
                         {
                             DataTable table1 = dset.Tables[1];
                             string targetColumn = "BILLNO";
                             bool hasColumn = table1.Columns.Contains(targetColumn);
                             foreach (DataRow row in table1.Rows)
                             {
                                 if (row == null) continue;
                                 string billNo = "";
                                 try
                                 {
                                     if (hasColumn)
                                     {
                                         billNo = row[targetColumn]?.ToString()?.Trim() ?? "";
                                     }
                                     else if (table1.Columns.Count > 0)
                                     {
                                         billNo = row[table1.Columns[0].ColumnName]?.ToString()?.Trim() ?? "";
                                     }
                                 }
                                 catch { }
                                 if (!string.IsNullOrEmpty(billNo))
                                 {
                                     deleteLst.Add(billNo);
                                 }
                             }
                         }
                         // 挂载到keyChild或默认键
                         string targetKey = !string.IsNullOrEmpty(keyChild) ? keyChild : "billItems";
                         ((IDictionary<string, object>)_datajson)[targetKey] = deleteLst;
                       //  Gs.Toolbox.LogHelper.Debug(this.ToString(), $"delete分支:提取{deleteLst.Count}条数据");
                     }
                     catch (Exception ex)
                     {
                         Gs.Toolbox.LogHelper.Debug(this.ToString(), $"delete分支异常:{ex.Message}");
                         _datajson = new ExpandoObject();
                     }
                 }
                // 原有逻辑:非delete方法,执行历史拼接逻辑
                else if (dset.Tables.Count > 1)
                {
                    //这是这是普通的接口里的结案,结构和其它不一样
                    // 这是普通的接口里的结案,结构和其它不一样
                    if (keyMeth.ToLower() == "toclose".ToLower() || keyMeth.ToLower() == "closure".ToLower() || keyMeth.ToLower() == "unfinish")
                    {
                        _datajson = dset.Tables[1].Rows[0].RowToDynamic();
@@ -344,8 +422,10 @@
                        ((IDictionary<string, object>)_datajson)[keyChild] = _lst;
                    }
                }
                return JsonConvert.SerializeObject(_datajson);
                //这是订单回传标识
                return JsonConvert.SerializeObject(_datajson);
                // 这是订单回传标识(原有注释代码完全保留)
                /*List<dynamic> _datajson22 = new List<dynamic>();
                dynamic _ob = new ExpandoObject();
                _ob.ENTRY = dset.Tables[0].TableToDynamicList();
@@ -357,6 +437,8 @@
                    datajson = JsonConvert.SerializeObject(_datajson22),
                };
                return JsonConvert.SerializeObject(_obj22);*/
            }
            catch (Exception ex)
            {