啊鑫
昨天 00a72fff219241eb5b0405a066cc859d07cf7735
service/Warehouse/MesCgthSqManager.cs
@@ -12,49 +12,79 @@
public class MesCgthSqManager : Repository<MesCgthSq>
{
    public List<MesCgthSq> GetMesCgthSq()
    public dynamic GetMesCgthSq(dynamic RequestInfo)
    {
        return Db.Queryable<MesCgthSq>()
            .Where(s => s.Status == true)
            .OrderByDescending(s => s.CreateDate)
            .ToList();
        var orgId = RequestInfo.OrgId;
        if (orgId == null)
            throw new Exception("组织不存在!");
        // 获取未完成的退料单号列表
        var parameters = new[]
        {
        new SugarParameter("@pi_orgId", orgId),
        new SugarParameter("@inP1", null),
        new SugarParameter("@inP2", null),
        new SugarParameter("@inP3", null),
        new SugarParameter("@inP4", null)
        };
        try
        {
            // 返回单号字符串列表
            var blDetails = Db.Ado.SqlQuery<string>(
                "EXEC prc_pda_cgth_list @pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters);
            return blDetails;
        }
        catch (Exception ex)
        {
            throw new Exception($"{ex.Message}");
        }
    }
    public ProductionPickDto GetSumItem(WarehouseQuery query)
    public dynamic GetSumItem(WarehouseQuery query, dynamic RequestInfo)
    {
        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("采购退货申请单不存在或未审核");
        if (query == null)
            throw new ArgumentNullException(nameof(query), "参数对象不能为null");
        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,A.depot_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);
        if (string.IsNullOrEmpty(query.billNo?.ToString()))
            throw new ArgumentException("单据号不能为空", nameof(query.billNo));
        var womdabs = Db.Ado.SqlQuery<ItemDetailModel>(sql);
        var orgId = RequestInfo.OrgId;
        if(womdabs.Count < 1)
        if (orgId == null)
            throw new Exception("组织不存在!");
        // 获取未完成的发货通知单明细
        var parameters = new[]
{
        new SugarParameter("@billNo", query.billNo),
        new SugarParameter("@pi_orgId",orgId),
        new SugarParameter("@inP1", null),
        new SugarParameter("@inP2", null),
        new SugarParameter("@inP3", null),
        new SugarParameter("@inP4", null)
    };
        try
        {
            throw new Exception("该采购退货申请单明细不存在");
            List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>(
                "EXEC prc_pda_cgth_detailList @billNo,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters);
            var items = blDetails.Where(x => x.DSQty > 0).ToList();    // 待扫物料
            var ysitems = blDetails.Where(x => x.SQty > 0).ToList();   // 已扫物料
            return new
            {
                items = items,
                ysitems = ysitems,
                allList = blDetails
            };
        }
        var DS_list = womdabs.Where(s => s.DSQty > 0).ToList();
        var YS_list = womdabs.Where(s => s.SQty > 0).ToList();
        var dto = new ProductionPickDto
        catch (Exception ex)
        {
            //daa001 = womdaa.Daa001,
            //PlanNo = womcaa.Caa020,
            items = DS_list,
            Ysitems = YS_list
        };
        return dto;
            // 保留原有异常处理逻辑
            throw new Exception($"{ex.Message}");
        }
    }
    public List<MesCgthSqDetail> GetItems(WarehouseQuery query)