111
啊鑫
2025-09-24 4db3ba3f84456c27fdd9be76ff76c17101270914
service/Warehouse/MesItemQtrkManager.cs
@@ -93,10 +93,15 @@
             MES_DEPOTS b ON a.depot_guid = b.Guid
        WHERE a.depot_section_code = @sectionCode;";
        var depotInfo = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).First();
        if (depotInfo is  null)
        dynamic depotInfo;
        try
        {
            depotInfo = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).First();
        }
        catch
        {
            throw new Exception($"库位编码 {sectionCode} 不存在,请确认!");
        }
        // 5. 返回成功信息
        return depotInfo;
@@ -118,18 +123,23 @@
            throw new Exception("请扫库位条码!");
        // 2. 查询库位对应的仓库编码和仓库ID
        var depotInfo = Db.Queryable<MesDepotSections, MesDepots>(
                (a, b) =>
                    new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid))
            .Where((a, b) => a.DepotSectionCode == p_section_code)
            .Select((a, b) => new { b.DepotCode, b.DepotId })
            .First();
        if (depotInfo == null)
        var depotInfo2 = new { DepotCode = "", DepotId = (int?)0 }; // 匹配数据库返回的可空类型
        try
        {
            depotInfo2 = Db.Queryable<MesDepotSections, MesDepots>(
                    (a, b) =>
                        new JoinQueryInfos(JoinType.Inner, a.DepotGuid == b.Guid))
                .Where((a, b) => a.DepotSectionCode == p_section_code)
                .Select((a, b) => new { b.DepotCode, b.DepotId })
                .First();
        }
        catch
        {
            throw new Exception($"库位编码 {p_section_code} 不存在,请确认!");
        }
        var c_depot_code = depotInfo.DepotCode;
        var c_depot_id = depotInfo.DepotId;
        var c_depot_code = depotInfo2.DepotCode;
        var c_depot_id = depotInfo2.DepotId;
        var sqlParams = new List<SugarParameter> { new("@barcode", p_item_barcode), new("@billNo", p_bill_no) };
@@ -145,8 +155,16 @@
        var mesDepost = Db.Queryable<MesDepots>()
        MesDepots mesDepost;
        try
        {
            mesDepost = Db.Queryable<MesDepots>()
                .Where(s => s.DepotId == c_depot_id).First();
        }
        catch
        {
            throw new Exception($"仓库ID {c_depot_id} 对应的仓库信息不存在,请确认!");
        }