南骏 池
16 小时以前 9441a216b632f9fb8f549a8278fc337367a08a4e
service/Warehouse/MesItemQtManager.cs
@@ -16,13 +16,14 @@
    /// <returns>退料单号列表</returns>
    public List<string> GetPendingQtList()
    {
        const string sql = @"SELECT qtck
                        FROM MES_ITEM_QT
                        WHERE qt015 = 1
                          AND qt026 = 1
                          AND QT029 = 1
                          AND qt032 = 1
                          AND QT014 = 0  ";
        const string sql = @"SELECT qtck
FROM MES_ITEM_QT
WHERE qt015 = 1
  AND qt026 = 1
  AND QT029 = 1
  AND qt032 = 1
  AND QT014 = 0
ORDER BY qt002";
        return Db.Ado.SqlQuery<string>(sql);
    }
@@ -51,8 +52,8 @@
        //    throw new Exception($"其他出库申请单 {p_bill_no} 未审核,请确认!");
        // 检查退料单的完结状态(Qt014),已完结则抛出异常
        if (mesItemQt.Qt014 == true)
            throw new Exception($"其他出库申请单 {p_bill_no} 已完结,请确认!");
        //if (mesItemQt.Qt014 == true)
        //    throw new Exception($"其他出库申请单 {p_bill_no} 已完结,请确认!");
        var sql = @"SELECT c.item_no ItemNo,c.item_name ItemName,c.item_model ItemModel,
                    ISNULL(A.qd007,0)  FQty,ISNULL(A.qd008,0) SQty,ISNULL(A.qd007,0) - ISNULL(A.qd008,0) DSQty,
@@ -116,6 +117,9 @@
        if (barcode == null)
            throw new Exception($"mes中不存在此条码,请核对!{p_item_barcode}");
        // 获取库存信息
        var stock = Db.Queryable<MesInvItemStocks>()
            .Where(it => it.ItemBarcode == p_item_barcode && it.Quantity > 0)
@@ -146,6 +150,9 @@
            .Where(it => it.Qtck == p_bill_no && it.Qt015 == true && it.Qt026 == true && it.Qt029 == true && it.Qt032 == true)
            .First();
        if (mesItemQt == null)
            throw new Exception($"其他出库申请单 {p_bill_no} 不存在,请确认!");
        // 获取出库单明细
        var qtDetail = Db.Queryable<MesItemQtDatall>()
            .Where(it =>
@@ -153,17 +160,20 @@
                it.ItemId == stock.ItemId.ToString())
            .First();
        if (mesItemQt == null)
            throw new Exception($"其他出库申请单 {p_bill_no} 不存在,请确认!");
        if (qtDetail == null) throw new Exception("扫码物料非本次出库申请物料,请核对!");
        if (mesItemQt.Qt014 == true)
            throw new Exception($"其他出库申请单 {p_bill_no} 已完结,请确认!");
        // 检查仓库是否一致
        if (Convert.ToInt32(qtDetail.DepotId)  != stock.DepotId)
        if (qtDetail.DepotId  != stock.DepotId)
            throw new Exception(
                $"扫码出货仓库id{qtDetail.DepotId}与其他出库申请仓库{stock.DepotId}不一致,请核对!");
        if (qtDetail == null) throw new Exception("扫码物料非本次出库申请物料,请核对!");
        // 检查剩余数量
        var remainingQty = (qtDetail.Qd007 ?? 0) - (qtDetail.Qd008 ?? 0);
@@ -194,6 +204,8 @@
            var message =
                $"请确认发料数量!!已带出满足其他出库单的发料数量 {remainingQty} 确认后请点击条码拆分";
            throw new Exception($"条码数量超出发料数量,请拆分后再扫描!");
            query.itemNo = stock.ItemNo;
            query.Num = stock.Quantity;
            query.Fum = remainingQty;