xwt
2025-09-24 f9c7f114f3eabb14532bca76671598b130f91aeb
SJ,LLJ,RKJ修改
已修改4个文件
142 ■■■■ 文件已修改
StandardInterface/MES.Service/Modes/QsItemIpiItem.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/service/QC/LljService.cs 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/service/QC/RKJService.cs 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/service/QC/SJService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Modes/QsItemIpiItem.cs
@@ -121,14 +121,12 @@
    /// <summary>
    ///     穴数
    /// </summary>
    [Column("MNUM")]
    [SugarColumn(ColumnName = "MNUM")]
    [SugarColumn(IsIgnore = true)]
    public decimal? Mnum { get; set; }
    /// <summary>
    ///     堵穴号
    /// </summary>
    [Column("DNUM")]
    [SugarColumn(ColumnName = "DNUM")]
    [SugarColumn(IsIgnore = true)]
    public string? Dnum { get; set; }
    /// <summary>
StandardInterface/MES.Service/service/QC/LljService.cs
@@ -26,7 +26,82 @@
        var totalCount = 0;
        // 使用数据库分页查询,一次查询50条,提升性能
        var pageList = db.Queryable<LtsLlj, V_LljUser>((a, v) =>
        // 判断是否为管理员账号
        bool isAdmin = queryObj.createUser == "PL017" || queryObj.createUser == "HMLYY" || queryObj.createUser == "HMCS";
        List<LtsLlj> pageList;
        if (isAdmin)
        {
            // 管理员账号:直接查询主表,避免JOIN导致的重复记录
            pageList = db.Queryable<LtsLlj>()
                .WhereIF(
                    StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                    "未完成".Equals(queryObj.result),
                    a => a.FcheckResu == null)
                .WhereIF(
                    StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                    !"未完成".Equals(queryObj.result),
                    a => a.FcheckResu != null)
                .WhereIF(id > 0, a => a.Id == id)
                //加筛选条件,根据选择的搜索字段进行精确搜索
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 1, // 物料编号搜索
                    a => a.ItemNo != null && a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 2, // 物料名称搜索
                    a => a.ItemName != null && a.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 3, // 供应商搜索
                    a => a.SuppName != null && a.SuppName.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 4, // 到货单号搜索
                    a => a.LotNo != null && a.LotNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 5, // 检验单号搜索
                    a => a.ReleaseNo != null && a.ReleaseNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 6, // 物料规格搜索
                    a => a.ItemModel != null && a.ItemModel.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .Select(a => new LtsLlj
                {
                    Id = a.Id,
                    ItemNo = a.ItemNo,
                    ItemId = a.ItemId,
                    ItemName = a.ItemName,
                    ItemModel = a.ItemModel,
                    SuppName = a.SuppName,
                    LotNo = a.LotNo,
                    ReleaseNo = a.ReleaseNo,
                    FcheckResu = a.FcheckResu,
                    CreateDate = a.CreateDate,
                    FcovertQty = a.FcovertQty,
                    DEPARTMENTNAME = a.DEPARTMENTNAME,
                    FngDesc = a.FngDesc,
                    UrgentFlag = a.UrgentFlag,
                    Ftype = a.Ftype,
                    LotNo1 = a.LotNo1,
                    EMERGENCY = a.EMERGENCY,
                    Status = a.Status,
                    IqcDate = a.IqcDate,
                    // 添加维护人员信息(管理员不需要此字段)
                    Fcode = null,
                    // 添加破坏实验数量
                    PHSY = a.PHSY,
                    // 添加不良原因
                    BLYY = a.BLYY,
                    // 添加所属车间
                    SSCJ = a.SSCJ,
                    // 添加评审状态
                    PSZT = a.PSZT,
                    // 添加检验项目维护状态
                    Jyxm = a.Jyxm
                })
                .OrderBy("IQC_DATE DESC")
                .OrderBy("CASE WHEN EMERGENCY = 1 THEN 0 ELSE 1 END")
                .OrderBy("CASE WHEN JYXM = 0 THEN 0 ELSE 1 END")
                .OrderBy("CASE WHEN STATUS = '已提交' THEN 1 ELSE 0 END")
                .OrderBy("CREATE_DATE")
                .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
        }
        else
        {
            // 普通用户:使用JOIN查询,根据维护情况判断权限
            pageList = db.Queryable<LtsLlj, V_LljUser>((a, v) =>
                new JoinQueryInfos(JoinType.Left, a.ItemNo == v.ItemNo))
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
@@ -37,14 +112,13 @@
                !"未完成".Equals(queryObj.result),
                (a, v) => a.FcheckResu != null)
            .WhereIF(id > 0, (a, v) => a.Id == id)
            // 权限控制:PL017、HMLYY、HMCS 可以看到所有单据,其他用户需要根据物料维护情况判断
            .WhereIF(queryObj.createUser != "PL017" && queryObj.createUser != "HMLYY" && queryObj.createUser != "HMCS" && queryObj.UserIndex == "0",
                // 权限控制:普通用户需要根据物料维护情况判断
                .WhereIF(queryObj.UserIndex == "0",
                (a, v) => 
                    // 如果物料被维护,只有维护人员可以看到
                    (v.Fcode != null && v.Fcode == queryObj.createUser) ||
                    // 如果物料未被维护,所有人都可以看到
                    (v.Fcode == null))
            //加筛选条件,根据选择的搜索字段进行精确搜索
            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 1, // 物料编号搜索
                (a, v) => a.ItemNo != null && a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
@@ -92,12 +166,13 @@
                // 添加检验项目维护状态
                Jyxm = a.Jyxm
            })
                .OrderBy("IQC_DATE DESC")
            .OrderBy("CASE WHEN EMERGENCY = 1 THEN 0 ELSE 1 END")
            .OrderBy("CASE WHEN JYXM = 0 THEN 0 ELSE 1 END")
            .OrderBy("CASE WHEN STATUS = '已提交' THEN 1 ELSE 0 END")
            .OrderBy("IQC_DATE DESC")
            .OrderBy("CREATE_DATE")
            .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
        }
        // 批量获取检验项目数量,避免N+1查询问题
        if (pageList.Any())
@@ -117,7 +192,42 @@
        }
        
        // 计算所有数据的去重总数(不是当前页的去重数)
        var allDataQuery = db.Queryable<LtsLlj, V_LljUser>((a, v) =>
        int allDataQuery;
        if (isAdmin)
        {
            // 管理员账号:直接查询主表
            allDataQuery = db.Queryable<LtsLlj>()
                .WhereIF(
                    StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                    "未完成".Equals(queryObj.result),
                    a => a.FcheckResu == null)
                .WhereIF(
                    StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                    !"未完成".Equals(queryObj.result),
                    a => a.FcheckResu != null)
                .WhereIF(id > 0, a => a.Id == id)
                //加筛选条件,根据选择的搜索字段进行精确搜索
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 1, // 物料编号搜索
                    a => a.ItemNo != null && a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 2, // 物料名称搜索
                    a => a.ItemName != null && a.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 3, // 供应商搜索
                    a => a.SuppName != null && a.SuppName.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 4, // 到货单号搜索
                    a => a.LotNo != null && a.LotNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 5, // 检验单号搜索
                    a => a.ReleaseNo != null && a.ReleaseNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 6, // 物料规格搜索
                    a => a.ItemModel != null && a.ItemModel.ToLower().Contains(queryObj.SearchValue.ToLower()))
                .Select(a => a.ReleaseNo)
                .Distinct()
                .Count();
        }
        else
        {
            // 普通用户:使用JOIN查询
            allDataQuery = db.Queryable<LtsLlj, V_LljUser>((a, v) =>
                new JoinQueryInfos(JoinType.Left, a.ItemNo == v.ItemNo))
            .WhereIF(
                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
@@ -128,8 +238,8 @@
                !"未完成".Equals(queryObj.result),
                (a, v) => a.FcheckResu != null)
            .WhereIF(id > 0, (a, v) => a.Id == id)
            // 权限控制:PL017、HMLYY、HMCS 可以看到所有单据,其他用户需要根据物料维护情况判断
            .WhereIF(queryObj.createUser != "PL017" && queryObj.createUser != "HMLYY" && queryObj.createUser != "HMCS" && queryObj.UserIndex == "0",
                // 权限控制:普通用户需要根据物料维护情况判断
                .WhereIF(queryObj.UserIndex == "0",
                (a, v) => 
                    // 如果物料被维护,只有维护人员可以看到
                    (v.Fcode != null && v.Fcode == queryObj.createUser) ||
@@ -151,6 +261,7 @@
            .Select((a, v) => a.ReleaseNo)
            .Distinct()
            .Count();
        }
        
        var emergencyValues = pageList.Select(item => item.EMERGENCY).ToList(); 
        return (pageList, allDataQuery);
StandardInterface/MES.Service/service/QC/RKJService.cs
@@ -309,11 +309,8 @@
                QsCode = a.QsCode,
                QsName = a.QsName,
                isCheck = SqlFunc.AggregateCount(b.Id),
                Result = a.IsPass == 1 &&
                         a.LevelNum == SqlFunc.AggregateCount(b.Id) ? "合格"
                    : a.IsPass == 0 &&
                      a.LevelNum == SqlFunc.AggregateCount(b.Id) ? "不合格"
                    : "未完成"
                Result = SqlFunc.AggregateCount(b.Id) == 0 ? "未完成" :
                         a.IsPass == 1 ? "合格" : "不合格"
            }).OrderBy("result desc").ToList();
    }
StandardInterface/MES.Service/service/QC/SJService.cs
@@ -206,7 +206,7 @@
                IsPass = a.IsPass,
                ItemId = a.ItemId,
                Mnum = b.Mnum,  // 从主表获取MNUM
                Dnum = b.Dnum,  // 从主表获取DNUM
                Dnum = b.Dnum,  // 从子表获取DNUM
                Snum = a.Snum,  // 送检批数
                Remarks = a.Remarks
            }).ToList();