啊鑫
2025-07-10 ed05efdc17aab076146b134ebe105b6382f221d7
MES.Service/service/Warehouse/MesInvItemMovesManager.cs
@@ -15,12 +15,10 @@
    public MovesDto ScanInBarcode(WarehouseQuery query)
    {
        if (string.IsNullOrEmpty(query.sectionCode))
        {
            throw new Exception("请扫库位条码!");
        }
        int pBillTypeId = 300;
        int pTransctionNo = 301;
        var pBillTypeId = 300;
        var pTransctionNo = 301;
        var depotQuery = Db.Queryable<MesDepotSections, MesDepots>((a, b) =>
                new JoinQueryInfos(
@@ -30,9 +28,7 @@
            .First();
        if (depotQuery == null)
        {
            throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!");
        }
        var cDepotCode = depotQuery.DepotCode;
@@ -48,17 +44,15 @@
            .Select((a, b) => new { a.Id, a.BillNo, a.InvDepotsCode })
            .First();
        if (itemMoveQuery == null)
        {
            throw new Exception("条码未做调拔出库扫码,请核对!");
        }
        if (itemMoveQuery == null) throw new Exception("条码未做调拔出库扫码,请核对!");
        var cBillNo = itemMoveQuery.BillNo;
        var iDepotCode = itemMoveQuery.InvDepotsCode;
        // 验证库区与仓库
        var depotValidationQuery = Db.Queryable<MesDepotSections, MesDepots>(
                (a, b) => new JoinQueryInfos(
        var depotValidationQuery = Db
            .Queryable<MesDepotSections, MesDepots>((a, b) =>
                new JoinQueryInfos(
                    JoinType.Inner, a.Zuid.ToString() == b.Zuid))
            .Where((a, b) => a.DepotSectionCode == query.sectionCode &&
                             b.DepotCode == iDepotCode)
@@ -66,14 +60,10 @@
            .First();
        if (depotValidationQuery == null)
        {
            throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!");
        }
        if (iDepotCode != depotValidationQuery.DepotCode)
        {
            throw new Exception("实际仓库与申请调入仓库不符,请核对!");
        }
        var barcodeCount = Db.Queryable<MesInvItemMovesCDetails>()
            .Where(b =>
@@ -81,19 +71,13 @@
                b.ItemMoveId == itemMoveQuery.Id && b.MoveOk == 1)
            .Count();
        if (barcodeCount > 0)
        {
            throw new Exception("条码调拔已完成,请核对!");
        }
        if (barcodeCount > 0) throw new Exception("条码调拔已完成,请核对!");
        var barcodeInfo = Db.Queryable<MesInvItemBarcodes>()
            .Where(t => t.ItemBarcode == query.barcode)
            .First();
        if (barcodeInfo == null)
        {
            throw new Exception("条码不存在,请核对!");
        }
        if (barcodeInfo == null) throw new Exception("条码不存在,请核对!");
        var isAudit = UseTransaction(db =>
        {
@@ -140,15 +124,12 @@
                .Where(a => a.ItemMoveId == itemMoveQuery.Id && a.MoveOk == 1)
                .Sum(a => SqlFunc.IsNull(a.Quantity, 0));
            if (totalQuantity == scannedQuantity)
            {
                return 1;
            }
            if (totalQuantity == scannedQuantity) return 1;
            return 0;
        });
        MovesDto dto = new MovesDto();
        var dto = new MovesDto();
        dto.InAudit = isAudit == 1;
        dto.BarcodesInfo = barcodeInfo;
        return dto;
@@ -180,7 +161,7 @@
    public MovesDto GetItems(WarehouseQuery query)
    {
        MovesDto dto = new MovesDto();
        var dto = new MovesDto();
        dto.BarcodeList = GetItemMovesCDetails(query);
        dto.OutItems = GetItemOutItems(query);
@@ -200,13 +181,14 @@
    private List<MesInvItemMovesCDetails> GetItemMovesCDetails(
        WarehouseQuery query)
    {
        return Db.Queryable<MesInvItemMovesCDetails, MesItems, MesSupplier>(
                (b, c, f) => new JoinQueryInfos(
                    JoinType.Left,
                    b.ItemNo == c.ItemNo && b.Company == c.Company &&
                    b.Factory == c.Factory,
                    JoinType.Left, b.SuppNo == f.SuppNo
                ))
        return Db
            .Queryable<MesInvItemMovesCDetails, MesItems,
                MesSupplier>((b, c, f) => new JoinQueryInfos(
                JoinType.Left,
                b.ItemNo == c.ItemNo && b.Company == c.Company &&
                b.Factory == c.Factory,
                JoinType.Left, b.SuppNo == f.SuppNo
            ))
            .Where((b, c, f) => b.ItemMoveId == query.id)
            .Select((b, c, f) => new MesInvItemMovesCDetails
            {
@@ -250,9 +232,9 @@
        if (mesInvItemMoves == null)
            throw new Exception("出库单 " + query.billNo + "不存在,请确认!");
        var count = Db.Queryable<MesInvItemMoves, MesInvItemMovesCDetails>(
                (a, b) =>
                    new JoinQueryInfos(JoinType.Inner, a.Id == b.ItemMoveId))
        var count = Db
            .Queryable<MesInvItemMoves, MesInvItemMovesCDetails>((a, b) =>
                new JoinQueryInfos(JoinType.Inner, a.Id == b.ItemMoveId))
            .Where((a, b) => b.ItemBarcode == query.barcode
                             && a.TransactionNo == TransctionNo &&
                             SqlFunc.IsNull(a.Status, 0) == 0).Count();
@@ -288,8 +270,6 @@
            throw new Exception(
                "已扫条码数量或本次扫码数量:" + sumqty + " 大于申请数量:" + quantity + ",请核对!");
        List<InventoryItem> scanOutShowDb = null;
        UseTransaction(db =>
        {
            SaveMesInvItemMovesCDetails(db, query, mesInvItemMoves,
@@ -314,7 +294,7 @@
                    .Where(s => s.Id == mesInvItemStocks.Id)
                    .ExecuteCommand();
            scanOutShowDb = ScanOutShowDb(query);
            var scanOutShowDb = ScanOutShowDb(query);
            if (CollectionUtil.IsNullOrEmpty(scanOutShowDb))
                db.Updateable<MesInvItemMoves>()
                    .SetColumns(s => s.Status == 1)
@@ -326,7 +306,7 @@
        });
        var itemDto = new OutItemDto();
        itemDto.SumItem = scanOutShowDb;
        //itemDto.SumItem = scanOutShowDb;
        if (TransctionNo == 201) itemDto.Quantity = mesInvItemStocks.Quantity;