tjx
2025-10-17 266afcd9d3b53e97b9a81e61efd095bbdbc8de9e
service/base/WmsBaseMangeer.cs
@@ -31,20 +31,6 @@
            string barcode, string sectionCode, string stockId, string stockOrgId,
            string billNo, string transactionNo)
        {
            // 参数验证
            if (string.IsNullOrEmpty(edtUserNo))
                throw new ArgumentException("操作人工号不能为空", nameof(edtUserNo));
            if (string.IsNullOrEmpty(barcode))
                throw new ArgumentException("物料条码不能为空", nameof(barcode));
            if (string.IsNullOrEmpty(sectionCode))
                throw new ArgumentException("库位编码不能为空", nameof(sectionCode));
            if (string.IsNullOrEmpty(stockId))
                throw new ArgumentException("仓库ID不能为空", nameof(stockId));
            if (string.IsNullOrEmpty(stockOrgId))
                throw new ArgumentException("库存组织ID不能为空", nameof(stockOrgId));
            if (string.IsNullOrEmpty(transactionNo))
                throw new ArgumentException("事务类型不能为空", nameof(transactionNo));
            var outputMsg = "";
            var outputStatus = -1;
@@ -60,7 +46,7 @@
                    new("@pi_sectionCode", SqlDbType.NVarChar, 100) { Value = sectionCode },
                    new("@pi_stockId", SqlDbType.NVarChar, 100) { Value = stockId },
                    new("@pi_stockOrgId", SqlDbType.NVarChar, 100) { Value = stockOrgId },
                    new("@pi_billno", SqlDbType.NVarChar, 100) { Value = string.IsNullOrEmpty(billNo) ? DBNull.Value : billNo },
                    new("@pi_billno", SqlDbType.NVarChar, 100) { Value = billNo },
                    new("@pi_transaction_no", SqlDbType.NVarChar, 10) { Value = transactionNo },
                    new("@pi_val1", SqlDbType.NVarChar, 100) { Value = DBNull.Value }, // 预留扩展字段
                    new("@pi_val2", SqlDbType.NVarChar, 100) { Value = DBNull.Value }, // 预留扩展字段
@@ -136,32 +122,27 @@
        /// <returns>货主类型(BD_OwnerOrg/BD_Customer/BD_Supplier)</returns>
        public string GetOwnerType(string ownerId)
        {
            // 如果 ownerId 为空,返回默认的货主类型
            if (string.IsNullOrEmpty(ownerId))
                return "BD_OwnerOrg"; // 默认为组织类型
                throw new ArgumentNullException(nameof(ownerId));
            // 优先检查系统组织
            if (Db.Queryable<SysOrganization>().Any(x => x.Fid == ownerId))
            {
                return "BD_OwnerOrg";
            }
            // 检查是否为客户或供应商(安全的数字转换)
            if (int.TryParse(ownerId, out int ownerIdInt))
            else if (Db.Queryable<MesCustomer>().Any(x => x.Id == Convert.ToInt32(ownerId)))
            {
                if (Db.Queryable<MesCustomer>().Any(x => x.Id == ownerIdInt))
                {
                    return "BD_Customer";
                }
                if (Db.Queryable<MesSupplier>().Any(x => x.Id == ownerIdInt))
                {
                    return "BD_Supplier";
                }
                return "BD_Customer";
            }
            // 如果都无法匹配,返回默认组织类型而不是抛出异常
            return "BD_OwnerOrg";
            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是否正确!");
        }