| | |
| | | if (string.IsNullOrEmpty(ownerId)) |
| | | return "BD_OwnerOrg"; // 默认为组织类型 |
| | | |
| | | // 优先检查系统组织 |
| | | if (Db.Queryable<SysOrganization>().Any(x => x.Fid == ownerId)) |
| | | { |
| | | return "BD_OwnerOrg"; |
| | | } |
| | | else if (Db.Queryable<MesCustomer>().Any(x => x.Id == Convert.ToInt32(ownerId))) |
| | | |
| | | // 检查是否为客户或供应商(安全的数字转换) |
| | | if (int.TryParse(ownerId, out int ownerIdInt)) |
| | | { |
| | | return "BD_Customer"; |
| | | if (Db.Queryable<MesCustomer>().Any(x => x.Id == ownerIdInt)) |
| | | { |
| | | return "BD_Customer"; |
| | | } |
| | | |
| | | if (Db.Queryable<MesSupplier>().Any(x => x.Id == ownerIdInt)) |
| | | { |
| | | return "BD_Supplier"; |
| | | } |
| | | } |
| | | else if (Db.Queryable<MesSupplier>().Any(x => x.Id == Convert.ToInt32(ownerId))) |
| | | { |
| | | return "BD_Supplier"; |
| | | } |
| | | else if (Db.Queryable<SysOrganization>().Any(x => x.Fid == ownerId)) |
| | | { |
| | | return "BD_OwnerOrg"; |
| | | } |
| | | |
| | | throw new Exception("无法确定货主类型,请检查货主ID是否正确!"); |
| | | |
| | | // 如果都无法匹配,返回默认组织类型而不是抛出异常 |
| | | return "BD_OwnerOrg"; |
| | | } |
| | | |
| | | |