kyy
2025-08-26 facc938ef010954584569fd725869869b49f4919
service/Warehouse/MesCgthSqManager.cs
@@ -14,48 +14,72 @@
    public List<MesCgthSq> GetMesCgthSq()
    {
        return Db.Queryable<MesCgthSq>()
            .Where(s => s.Status == true)
            // .Where(s => s.Status == true)
            .Where(s => s.Status == false)
            .OrderByDescending(s => s.CreateDate)
            .ToList();
    }
    public ProductionPickDto GetSumItem(WarehouseQuery query)
    {
        if (string.IsNullOrEmpty(query.billNo)) throw new Exception("申请单号为空");
        // 验证申请单号是否为空
        if (string.IsNullOrEmpty(query.billNo))
            throw new Exception("申请单号为空");
        var mesInvItemOuts = base.GetSingle(it => it.BillNo == query.billNo && it.Status == true);
        if (mesInvItemOuts == null) throw new Exception("采购退货申请单不存在或未审核");
        // 注释:原查询逻辑(已审核状态)
        // var mesInvItemOuts = base.GetSingle(it => it.BillNo == query.billNo && it.Status == true);
        // if (mesInvItemOuts == null) throw new Exception("采购退货申请单不存在或未审核");
        var sql = string.Format(@"SELECT c.item_no ItemNo,c.item_name ItemName,c.item_model ItemModel,A.SQ_NUM FQty,A.YS_NUM SQty,A.SQ_NUM - A.YS_NUM DSQty,
       dbo.F_QX_GETRECODEPOTSE(A.ITEM_ID,'','','') as RecoKw
fROM MES_CGTH_SQ_DETAIL A
         LEFT JOIN MES_CGTH_SQ B ON A.MID = B.ID
         LEFT JOIN MES_ITEMS C ON A.ITEM_ID = C.item_id
WHERE B.BILL_NO = '{0}'", query.billNo);
        // 查询未审核状态的采购退货申请单
        var mesInvItemOuts = base.GetSingle(it => it.BillNo == query.billNo && it.Status == false);
        if (mesInvItemOuts == null)
            throw new Exception("采购退货申请单不存在或已审核");
        // 构建查询明细数据的SQL语句
        var sql = string.Format(@"
        SELECT
            c.item_no ItemNo,
            c.item_name ItemName,
            c.item_model ItemModel,
            ISNULL(A.SQ_NUM, 0) FQty,
            ISNULL(A.YS_NUM, 0) SQty,
            ISNULL(A.SQ_NUM, 0) - ISNULL(A.YS_NUM, 0) DSQty,
            dbo.F_QX_GETRECODEPOTSE(A.ITEM_ID, '', '', '') as RecoKw
        FROM
            MES_CGTH_SQ_DETAIL A
            LEFT JOIN MES_CGTH_SQ B ON A.MID = B.ID
            LEFT JOIN MES_ITEMS C ON A.ITEM_ID = C.item_id
        WHERE
            B.BILL_NO = '{0}'", query.billNo);
        // 执行SQL查询获取明细列表
        var womdabs = Db.Ado.SqlQuery<ItemDetailModel>(sql);
        if(womdabs.Count < 1)
        // 验证明细数据是否存在
        if (womdabs.Count < 1)
        {
            throw new Exception("该采购退货申请单明细不存在");
        }
        // 筛选待处理明细(DSQty > 0)
        var DS_list = womdabs.Where(s => s.DSQty > 0).ToList();
        // 筛选已处理明细(SQty > 0)
        var YS_list = womdabs.Where(s => s.SQty > 0).ToList();
        // 构建并返回DTO对象
        var dto = new ProductionPickDto
        {
            //daa001 = womdaa.Daa001,
            //PlanNo = womcaa.Caa020,
            // 注释:原计划号相关映射(当前未使用)
            // daa001 = womdaa.Daa001,
            // PlanNo = womcaa.Caa020,
            items = DS_list,
            Ysitems = YS_list
        };
        return dto;
    }
    public List<MesCgthSqDetail> GetItems(WarehouseQuery query)
    {
        // 尝试将query.id转换为Guid类型,如果转换失败,则抛出异常
@@ -165,10 +189,11 @@
    public ProductionPickDto ScanCodeCF(WarehouseQuery query)
    {
        if (query.userName.IsNullOrEmpty()) throw new Exception("用户名不允许为空");
        if (query.daa001.IsNullOrEmpty()) throw new Exception("领料单号不允许为空");
       // if (query.daa001.IsNullOrEmpty()) throw new Exception("领料单号不允许为空");
        if (query.barcode.IsNullOrEmpty()) throw new Exception("条码不允许为空");
        if (query.Num is null or 0) throw new Exception("条码拆分数不允许为空或者为0");
        if (query.billNo.IsNullOrEmpty()) throw new Exception("申请单号不允许为空");
        var _strMsg = "";
        var _intSum = "";
@@ -187,7 +212,8 @@
                        new("@outSum", SqlDbType.NVarChar, 300),
                        new("@outCfBar", SqlDbType.NVarChar, 300),
                        new("@c_User", query.userName),
                        new("@p_biLL_no", query.daa001),
                       // new("@p_biLL_no", query.daa001),
                        new("@p_biLL_no", query.billNo),
                        new("@p_item_barcode", query.barcode),
                        new("@num", query.Num)
                    };
@@ -207,7 +233,7 @@
                    var dto = new ProductionPickDto
                    {
                        daa001 = query.daa001,
                        daa001 = query.daa001,
                        barcode = query.barcode,//原条码
                        cfBarcode = _cfBar//拆分后条码
                    };