From 0c7322109660b80e359118de04c0b9cc16a030e3 Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期五, 10 十月 2025 15:45:31 +0800
Subject: [PATCH] SJ,XJ,RKJ调用FTP附件
---
StandardInterface/MES.Service/service/QC/XJService.cs | 62 ++++++++++++++++++++++++++----
1 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/StandardInterface/MES.Service/service/QC/XJService.cs b/StandardInterface/MES.Service/service/QC/XJService.cs
index 8d3ddfc..de5a9a7 100644
--- a/StandardInterface/MES.Service/service/QC/XJService.cs
+++ b/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,
+ // 娣诲姞涓昏〃鐨処temNo瀛楁
+ 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 = '宸℃'鐨勯檺鍒�
+
+ // 濡傛灉浼犲叆浜唒rojName锛屽垯鎸塅version杩囨护
+ 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 @@
// 鏍囧噯鍖朏TP鏈嶅姟鍣ㄥ湴鍧�
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
{
--
Gitblit v1.9.3