public async Task <int> Create(OrganizationCreateInput input)
        {
            try
            {
                var entity = new t_OrganizationUnit()
                {
                    Code                  = input.Code,
                    ParentId              = int.Parse(input.ParentId.ToString() == null ? "0" : input.ParentId.ToString()),
                    TenantId              = this.AbpSession.TenantId.HasValue ? this.AbpSession.TenantId.Value : 0,
                    CreationTime          = DateTime.Now,
                    CreatorUserId         = this.AbpSession.UserId.HasValue ? this.AbpSession.UserId.Value : 0,
                    DisplayName           = input.DisplayName,
                    IsDeleted             = false,
                    OrganizationType      = Enum.Parse <PublicEnum.OrganizationType>(input.OrganizationType.ToString()), //组织类型
                    DataBaseConnection    = input.DataBaseConnection,                                                    //数据库连接
                    ERPOrganizationLeader = input.ERPOrganizationLeader == null ? 0 : input.ERPOrganizationLeader,       //组织负责人
                    ERPOrganization       = input.ERPOrganization == null ? 0 : input.ERPOrganization,
                    Remark                = input.Remark,
                    FWorkshopType         = input.FWorkshopType
                };

                return(await JIT_t_OrganizationUnit.InsertAndGetIdAsync(entity));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(0);
        }
        //返回公司
        protected t_OrganizationUnit GetCompany(t_OrganizationUnit node, List <t_OrganizationUnit> terrList)
        {
            t_OrganizationUnit reslut = null;

            if (node.OrganizationType == PublicEnum.OrganizationType.公司 ||
                node.OrganizationType == PublicEnum.OrganizationType.集团)
            {
                return(node);
            }

            if (node.ParentId != 0)
            {
                var parent = terrList.SingleOrDefault(p => p.Id == node.ParentId);
                reslut = GetCompany(parent, terrList);
            }
            return(reslut);
        }
        /// <summary>
        /// 查找子点所在的公司或集团
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        protected t_OrganizationUnit GetCompany(t_OrganizationUnit node, List <t_OrganizationUnit> treeList)
        {
            //最终返回的结果
            t_OrganizationUnit result = null;

            //判断传入的节点是否是公司,如果是则返回
            if (node.OrganizationType == PublicEnum.OrganizationType.公司 || node.OrganizationType == PublicEnum.OrganizationType.集团)
            {
                return(node);
            }

            //判断传入节点是否有父节点,如果有,则执行递归
            if (node.ParentId != 0)
            {
                var parent = treeList.SingleOrDefault(p => p.Id == node.ParentId);

                result = GetCompany(parent, treeList);
            }

            return(result);
        }