chenhaozhe
2025-05-21 89793cb2f9d4eb80582d0b5dda465881ff9a8382
WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
@@ -252,6 +252,46 @@
        }
        #endregion
        #region 客户列表修改按钮方法添加审核人
        /// <summary>
        /// 客户列表修改按钮方法
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Gy_Customer/xg_extendCheckEmp")]
        [HttpGet]
        public object xg_extendCheckEmp(long HInterID)
        {
            try
            {
                string sql = string.Format(@"select  c.HItemID,c.HNumber 客户代码,c.HName 客户名称,c.HHelpCode  助记码,c.HShortName 简称,c.HAddress 地址,c.HLinkMan 联系人,c.HLinkPhone 联系电话
                                            ,c.HMobilePhone 手机,c.HFax 传真,c.HPostalCode 邮编,c.HEmail 电子邮件,c.HCorMan 法人代表,c.HBank 开户银行,c.HBankAccount 银行账号,c.HMateOutEmp 领用人,
                                            c.HTaxNum 税务登记号,c.HTaxRate 增值税率,c.HEnglishName 英文名称,c.HEngLishAddress 英文地址,c.HCountry 国家,c.HCusStatus 客户状态
                                            ,c.HStopflag 禁用标志,c.HRemark 备注,c.HAreaID 地区ID,a.HName 地区名称,c.HCurID 默认货币ID,r.HName 默认货币,
                                            c.HSSID 结算方式ID,s.HName 结算方式,c.HCusTypeID 客户分类ID,t.HName 客户分类, c.HCheckEmp 审核人 from Gy_Customer c
                                            left join Gy_AreaSet a on c.HAreaID=a.HItemID
                                            left join Gy_Currency r on c.HCurID=r.HItemID
                                            left  join Gy_SettleStyle s on c.HSSID=s.HItemID
                                            left  join Gy_CusType t on c.HCusTypeID=t.HItemID
                                            where c.HItemID='" + HInterID + "'");
                ds = oCN.RunProcReturn(sql, "Gy_Customer");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 获取当前最大的客户代码
        [Route("Gy_Customer/getMaxCusNumber")]
        [HttpGet]
@@ -1385,6 +1425,56 @@
        }
        #endregion
        // #region 客户分类属性结构 根据组织分类
        [Route("Gy_BadReason/Gy_CusTypeTreeListByOrganization")]
        [HttpGet]
        public object Gy_CusTypeTreeListByOrganization()
        {
            try
            {
                string sql1 = string.Format("select hitemid,hnumber,hname,hparentid from Xt_ORGANIZATIONS where hstopflag != 1 order by hnumber");
                ds = oCN.RunProcReturn(sql1, "Xt_ORGANIZATIONS");
                List <TreeModel> treeModels = new List<TreeModel>();
                TreeModel first = new TreeModel();
                first.title = "使用组织";
                first.id = "0";
                treeModels.Add(first);
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    int HParentID = (int)row["hparentid"];
                    int HItemID = (int)row["hitemid"];
                    //if(HParentID == 0 || HItemID == HParentID) // 父节点为0或者自引用的设置为一级几点
                    //{
                        TreeModel tree = new TreeModel();
                        tree.id = row["hitemid"].ToString();
                        tree.title = row["hname"].ToString();
                        treeModels[0].children.Add(tree);
                    //}
                }
                //getTreeByHItemID(ds.Tables[0], treeModels);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels);
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        // #endregion
        #region 根据父id和等级获得树状图递归
        [Route("Gy_BadReason/Gy_CusTypeTreeListByLevel")]
@@ -1539,6 +1629,31 @@
        #endregion
        public void getTreeByHItemID(DataTable dt, List<TreeModel> tree)
        {
            for (int m = 0; m < tree.Count; m++)
            {
                tree[m].children = new List<TreeModel>();
                for (int i = 0; i < dt.Rows.Count; i++)//第一次循环,得到所有根节点的子集
                {
                    var HParentID = dt.Rows[i]["hparentid"].ToString();
                    var HItemID = dt.Rows[i]["hitemid"].ToString();
                    if (HParentID == tree[m].id && HParentID != HItemID)
                    {
                        TreeModel tbjson = new TreeModel();
                        tbjson.id = dt.Rows[i]["hitemid"].ToString();
                        tbjson.title = dt.Rows[i]["hname"].ToString();
                        tree[m].children.Add(tbjson);
                    }
                }
                for (int i = 0; i < tree[m].children.Count; i++)
                {
                    getTreeByHItemID(dt, tree[m].children);//再次用子集去循环,拿出子集的子集
                }
            }
        }
        #region 递归函数
        /// <summary>
        /// 递归函数