cnf
2025-07-10 8f25fecab6e6a79096b9940ab3432401b9045b39
MES.Service/service/QC/RKJService.cs
@@ -54,13 +54,14 @@
    //获取工单号
    public List<RKJDaa001> GetDaa001s(string lineNo)
    public List<RkDaa002> GetDaa001s(string lineNo)
    {
        var db = SqlSugarHelper.GetInstance();
        return db.Queryable<RKJDaa001>()
            .Where(t => t.LineNo == lineNo)
            .OrderBy(t => t.BillNo, OrderByType.Desc)
            .ToList();
        // return db.Queryable<RKJDaa001>()
        //     .Where(t => t.LineNo == lineNo)
        //     .OrderBy(t => t.BillNo, OrderByType.Desc)
        //     .ToList();
        return null;
    }
    //根据检验标准来计算检验个数
@@ -453,52 +454,61 @@
    }
    public List<QsItemOqcReq> getPage(XJPageResult queryObj)
    public (List<QsItemOqcReq> items, int TotalCount) GetPage(XJPageResult queryObj)
    {
        var db = SqlSugarHelper.GetInstance();
        var totalCount = 0;
        var id = Convert.ToDecimal(queryObj.id);
        string[]? lineNo = null;
        if (StringUtil.IsNotNullOrEmpty(queryObj.createUser))
        // 获取用户关联的线体编号
        string[] lineNo = null;
        if (!string.IsNullOrEmpty(queryObj.createUser))
        {
            lineNo = _baseService.getUserLineNo(queryObj.createUser);
        }
        return db.Queryable<QsItemOqcReq, RKJDaa001>((a, b) =>
                new JoinQueryInfos(JoinType.Left, a.BillNo == b.BillNo))
            .WhereIF(lineNo != null && lineNo.Length > 0,
                (a, b) => lineNo.Contains(b.LineNo))
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                "未完成".Equals(queryObj.result),
                (a, b) => a.FcheckResu == null)
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                !"未完成".Equals(queryObj.result),
                (a, b) => a.FcheckResu != null)
            .WhereIF(id > 0, (a, b) => a.Id == id)
            .Select((a, b) => new QsItemOqcReq
        var query = db.Queryable<QsItemOqcReq, MesItems, Womdaa>((a, b, da) =>
            new JoinQueryInfos(
                JoinType.Left, a.ItemNo == b.ItemNo,       // 关联物料信息
                JoinType.Left, a.BillNo == da.Daa001        // 关联工单信息
            ))
            // 用户线体过滤条件
            //.WhereIF(lineNo != null && lineNo.Length > 0 && !"PL017".Equals(queryObj.createUser),
            //    (a, b, da) => lineNo.Contains(da.Daa015))
            // ID精确查询
            .WhereIF(!string.IsNullOrEmpty(queryObj.id),
                (a, b, da) => a.Id.ToString() == queryObj.id)
            // 完成状态过滤
            .WhereIF("未完成".Equals(queryObj.result), (a, b, da) => a.FcheckResu == null)
            .WhereIF(!"未完成".Equals(queryObj.result), (a, b, da) => a.FcheckResu != null)
            // 搜索条件(物料名称/编号)
            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue),
                (a, b, da) => b.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()) ||
                              a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
            // 查询字段
            .Select((a, b, da) => new QsItemOqcReq
            {
                Id = a.Id,
                ReleaseNo = a.ReleaseNo,
                BillNo = a.BillNo,
                LineName = b.LineNo,
                Quantity = b.Quantity,
                CreateBy = a.CreateBy,
                CreateDate = a.CreateDate,
                ItemNo = a.ItemNo,
                Mocode = b.Mocode,
                BoardModel = b.BoardModel,
                TaskNo = b.TaskNo,
                ItemName = b.ItemName,
                ItemModel = b.ItemModel,
                CreateDate = a.CreateDate,
                CreateBy = a.CreateBy,
                FcheckResu = a.FcheckResu,
                FcheckBy = a.FcheckBy,
                FcheckDate = a.FcheckDate,
                MoidNum = a.MoidNum,
                BoardName = b.BoardName,
                ColorName = b.ColorName,
                Remarks = a.Remarks
            }).OrderBy(a => a.CreateDate, OrderByType.Desc)
            .ToPageList(queryObj.PageIndex, queryObj.Limit);
                ReleaseNo = a.ReleaseNo,
                Remarks = a.Remarks,
                Daa015 = da.Daa015,  // 工单线体
                Fsubmit = a.Fsubmit
            })
            // 排序
            .OrderBy(a => a.CreateDate, OrderByType.Desc);
        // 分页查询
        var result = query.ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
        return (result, totalCount);
    }
    //删除主表并且连级删除子表和孙表