xwt
2025-10-10 0c7322109660b80e359118de04c0b9cc16a030e3
StandardInterface/MES.Service/service/QC/XJService.cs
@@ -418,8 +418,35 @@
        var xjDto = new XJDto();
        var db = SqlSugarHelper.GetInstance();
        var qsQaItemXj01 =
            db.Queryable<QsQaItemXj01>().Single(s => s.Id == id);
        // 使用JOIN查询获取子表数据和主表的ItemNo字段
        var qsQaItemXj01 = db
            .Queryable<QsQaItemXj01, QsQaItemXj>((a, b) => new JoinQueryInfos(JoinType.Left, a.Pid == b.Id))
            .Where((a, b) => a.Id == id)
            .Select((a, b) => new QsQaItemXj01
            {
                Id = a.Id,
                Pid = a.Pid,
                ProjName = a.ProjName,
                ItemMod = a.ItemMod,
                InspectionMethod = a.InspectionMethod,
                UsingInstruments = a.UsingInstruments,
                LevelNum = a.LevelNum,
                MaxValue = a.MaxValue,
                StandardValue = a.StandardValue,
                MinValue = a.MinValue,
                Notes = a.Notes,
                FcheckLevel = a.FcheckLevel,
                FacLevel = a.FacLevel,
                QsCode = a.QsCode,
                QsName = a.QsName,
                Picture = a.Picture,
                Picturename = a.Picturename,
                IsPass = a.IsPass,
                Remarks = a.Remarks,
                // 添加主表的ItemNo字段
                ItemNo = b.ItemNo
            }).Single();
        if (qsQaItemXj01.IsPass == 0)
            qsQaItemXj01.result = "不合格";
@@ -433,7 +460,6 @@
                Convert.ToBase64String(qsQaItemXj01.Picture);
        xjDto.ItemXj01 = qsQaItemXj01;
        xjDto.ItemXj02s = db.Queryable<QsQaItemXj02>().Where(s => s.Pid == id)
            .ToList();
@@ -751,15 +777,24 @@
    /// 获取附件信息
    /// </summary>
    /// <param name="itemNo">物料编码</param>
    /// <param name="projName">项目名称(可选,用于过滤)</param>
    /// <returns>附件列表</returns>
    public List<QamftpDto> GetAttachments(string itemNo)
    public List<QamftpDto> GetAttachments(string itemNo, string projName = null)
    {
        var db = SqlSugarHelper.GetInstance();
        try
        {
            return db.Queryable<MesQamftp>()
            var query = db.Queryable<MesQamftp>()
                .Where(x => x.ItemNo == itemNo)
                .OrderBy(x => x.Fdate, OrderByType.Desc)
                .Where(x => x.Ftype == "巡检");  // 添加FTYPE = '巡检'的限制
            // 如果传入了projName,则按Fversion过滤
            if (!string.IsNullOrEmpty(projName))
            {
                query = query.Where(x => x.Fversion == projName);
            }
            return query.OrderBy(x => x.Fdate, OrderByType.Desc)
                .Select(x => new QamftpDto
                {
                    Id = x.Id,
@@ -790,8 +825,9 @@
    /// <param name="itemNo">物料编码</param>
    /// <param name="fileName">文件名</param>
    /// <param name="ftpServer">FTP服务器地址</param>
    /// <param name="projName">项目名称(可选,用于路径构建)</param>
    /// <returns>文件字节数组</returns>
    public byte[] GetFtpFile(string itemNo, string fileName, string ftpServer)
    public byte[] GetFtpFile(string itemNo, string fileName, string ftpServer, string projName = null)
    {
        // 参数验证
        if (string.IsNullOrEmpty(itemNo) || string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(ftpServer))
@@ -805,8 +841,16 @@
        // 标准化FTP服务器地址
        string normalizedServer = NormalizeFtpServer(ftpServer);
        
        // 构建FTP文件路径 - 巡检使用OPC目录
        string ftpPath = $"{normalizedServer}/OPC/{itemNo}/{fileName}";
        // 构建FTP文件路径 - 巡检使用OPC目录,如果传入了projName则使用新格式
        string ftpPath;
        if (!string.IsNullOrEmpty(projName))
        {
            ftpPath = $"{normalizedServer}/OPC/{itemNo}/{projName}/{fileName}";
        }
        else
        {
            ftpPath = $"{normalizedServer}/OPC/{itemNo}/{fileName}";
        }
        
        try
        {