This commit is contained in:
SHM
2026-03-09 09:37:41 +09:00
parent aaf0b9f0f7
commit 38cd3d7e77
2 changed files with 67 additions and 61 deletions

View File

@ -9,6 +9,7 @@ namespace SystemX.Product.CP.TRA.Extract
public class Config public class Config
{ {
public string CPXV2Server { get; set; } public string CPXV2Server { get; set; }
public string CPXV2Database { get; set; }
public string Server { get; set; } public string Server { get; set; }
public string DataBase { get; set; } public string DataBase { get; set; }
public string SummaryTable { get; set; } public string SummaryTable { get; set; }

View File

@ -36,7 +36,7 @@ namespace SystemX.Product.CP.TRA.Extract
,[SpecMin] ,[SpecMin]
,[SpecMax] ,[SpecMax]
,[Dim] ,[Dim]
FROM [CPXV2].[dbo].[VRFY_TestListFileRelease] WITH(NOLOCK) where StepDesc = '{config.MO}'"; FROM [{config.CPXV2Database}].[dbo].[VRFY_TestListFileRelease] WITH(NOLOCK) where StepDesc = '{config.MO}'";
SqlCommand cmd = new SqlCommand(sql, conn); SqlCommand cmd = new SqlCommand(sql, conn);
// 타임아웃 설정 (600만 건은 시간이 걸릴 수 있으므로 0(무제한) 또는 넉넉하게 설정) // 타임아웃 설정 (600만 건은 시간이 걸릴 수 있으므로 0(무제한) 또는 넉넉하게 설정)
@ -79,10 +79,6 @@ namespace SystemX.Product.CP.TRA.Extract
int fileNo = 0; int fileNo = 0;
string fileName = $""; string fileName = $"";
foreach (var tl in testList)
{
Console.WriteLine($"진행중 테스트리스트(MO:{config.MO}): TestListFileNo:{tl.TestListFileNo}, StepVersion:{tl.StepVersion}");
// 1. 연결 생성 // 1. 연결 생성
using (SqlConnection conn = new SqlConnection(ConnectionString)) using (SqlConnection conn = new SqlConnection(ConnectionString))
{ {
@ -95,30 +91,29 @@ namespace SystemX.Product.CP.TRA.Extract
string sql = $@"SELECT string sql = $@"SELECT
Summary.*, Summary.*,
Result.*, Result.LogData,
TL.StepVersion AS Matched_StepVersion TL.StepVersion AS Matched_StepVersion
FROM [{config.DataBase}].[dbo].[{config.SummaryTable}] AS Summary WITH(NOLOCK) FROM [{config.DataBase}].[dbo].[{config.SummaryTable}] AS Summary WITH(NOLOCK)
JOIN [{config.DataBase}].[dbo].[{config.ResultTable}] AS Result WITH(NOLOCK) JOIN [{config.DataBase}].[dbo].[{config.ResultTable}] AS Result WITH(NOLOCK)
ON Summary.No = Result.No ON Summary.No = Result.No
OUTER APPLY ( OUTER APPLY (
SELECT TOP 1 * SELECT TOP 1 *
FROM [CPXV2].[dbo].[VRFY_TestListFileRelease] FROM [{config.CPXV2Database}].[dbo].[VRFY_TestListFileRelease]
WHERE StepVersion <= Summary.StepVersion and TestListFileNo = {tl.TestListFileNo} and StepDesc = '{config.MO}' WHERE StepVersion <= Summary.StepVersion and StepDesc = '{config.MO}'
ORDER BY StepVersion DESC ORDER BY StepVersion DESC
) AS TL ) AS TL";
WHERE Summary.TestListFileNo = {tl.TestListFileNo} and StepVersion=TL.StepVersion";
//test code
if(string.IsNullOrEmpty(config.TestCode) == false)
sql += $" and TestCode = '{config.TestCode}'";
//productNo
if(string.IsNullOrEmpty(config.ProductNo) == false)
sql += $" and ProdNo_C = '{config.ProductNo}'";
//TestDT //TestDT
DateTime endDate = Convert.ToDateTime(config.EndDate).AddDays(1); DateTime endDate = Convert.ToDateTime(config.EndDate).AddDays(1);
sql += $" and '{config.StartDate}' <= Summary.TestDT and Summary.TestDT < '{endDate.ToString("yyyy-MM-dd")}'"; sql += $" where '{config.StartDate}' <= Summary.TestDT and Summary.TestDT < '{endDate.ToString("yyyy-MM-dd")}'";
//test code
if (string.IsNullOrEmpty(config.TestCode) == false)
sql += $" and TestCode = '{config.TestCode}'";
//productNo
if (string.IsNullOrEmpty(config.ProductNo) == false)
sql += $" and ProdNo_C = '{config.ProductNo}'";
SqlCommand cmd = new SqlCommand(sql, conn); SqlCommand cmd = new SqlCommand(sql, conn);
// 타임아웃 설정 (600만 건은 시간이 걸릴 수 있으므로 0(무제한) 또는 넉넉하게 설정) // 타임아웃 설정 (600만 건은 시간이 걸릴 수 있으므로 0(무제한) 또는 넉넉하게 설정)
@ -144,6 +139,10 @@ namespace SystemX.Product.CP.TRA.Extract
// 예: 데이터 처리 로직 // 예: 데이터 처리 로직
var val = Decompression(reader["LogData"].ToString()); var val = Decompression(reader["LogData"].ToString());
var date = Convert.ToDateTime(reader["TestDT"]); var date = Convert.ToDateTime(reader["TestDT"]);
var testListFileNo = Convert.ToInt32(reader["TestListFileNo"]);
var stepVersion = Convert.ToInt32(reader["Matched_StepVersion"]);
var no = Convert.ToInt32(reader["No"]);
var productNo = reader["ProdNo_C"].ToString(); var productNo = reader["ProdNo_C"].ToString();
var testCode = reader["TestCode"].ToString(); var testCode = reader["TestCode"].ToString();
@ -151,6 +150,11 @@ namespace SystemX.Product.CP.TRA.Extract
var productID = reader["ProductID"].ToString(); var productID = reader["ProductID"].ToString();
var r = JsonConvert.DeserializeObject<List<TestResult>>(val); var r = JsonConvert.DeserializeObject<List<TestResult>>(val);
var tl = testList.Find(x => x.TestListFileNo == testListFileNo && x.StepVersion == stepVersion);
if(tl != null)
{
//Console.WriteLine($"Current No:{no}");
var findStep = r.Find(x => x.StepID == tl.StepID); var findStep = r.Find(x => x.StepID == tl.StepID);
if (rowCount % config.RowCount == 0) if (rowCount % config.RowCount == 0)
@ -164,7 +168,7 @@ namespace SystemX.Product.CP.TRA.Extract
if (string.IsNullOrEmpty(config.TestCode) == false) if (string.IsNullOrEmpty(config.TestCode) == false)
fileName += $"_{testCode}"; fileName += $"_{testCode}";
if(string.IsNullOrEmpty(config.ProductNo) == false) if (string.IsNullOrEmpty(config.ProductNo) == false)
fileName += $"_{productNo}"; fileName += $"_{productNo}";
fileName += $"_{config.StartDate}_{config.EndDate}"; fileName += $"_{config.StartDate}_{config.EndDate}";
@ -179,6 +183,8 @@ namespace SystemX.Product.CP.TRA.Extract
rowCount += 1; rowCount += 1;
} }
} }
}
} }
} }
catch (SqlException ex) catch (SqlException ex)
@ -187,7 +193,6 @@ namespace SystemX.Product.CP.TRA.Extract
} }
} }
} }
}
public static string Decompression(string compressedDataStr) public static string Decompression(string compressedDataStr)
{ {