Initial commit: JDE Scoping Tool migration project
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
namespace JdeScoping.DataAccess.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// Lookup related SQL queries (Status Codes, Function Codes)
|
||||
/// </summary>
|
||||
public static partial class JdeQueries
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all work order status codes from production schema.
|
||||
/// Status codes are stored in UDC table F0005 with SY='00' and RT='SS'.
|
||||
/// </summary>
|
||||
public const string SqlGetStatusCodes = @"
|
||||
SELECT TRIM(sc.DRKY) AS Code,
|
||||
TRIM(sc.DRDL01) AS Description,
|
||||
sc.DRUPMJ AS LastUpdateDate,
|
||||
sc.DRUPMT AS LastUpdateTime
|
||||
FROM {ProductionSchema}.F0005 sc
|
||||
WHERE TRIM(sc.DRSY) = '00' AND
|
||||
sc.DRRT = 'SS' AND
|
||||
TRIM(sc.DRKY) IS NOT NULL";
|
||||
|
||||
/// <summary>
|
||||
/// Gets status codes updated since specified date from production schema.
|
||||
/// </summary>
|
||||
public const string SqlGetStatusCodesFiltered = SqlGetStatusCodes + @"
|
||||
AND (sc.DRUPMJ > :dateUpdated OR
|
||||
(sc.DRUPMJ = :dateUpdated AND sc.DRUPMT >= :timeUpdated))";
|
||||
|
||||
/// <summary>
|
||||
/// Gets all function codes from production schema.
|
||||
/// Function codes are stored in F00192 (MES codes table).
|
||||
/// Uses LISTAGG to concatenate multiple descriptions for same code.
|
||||
/// </summary>
|
||||
public const string SqlGetFunctionCodes = @"
|
||||
SELECT Code,
|
||||
TRIM(LISTAGG(Description, ' ') WITHIN GROUP(ORDER BY Description) ||
|
||||
CASE WHEN MAX(total_lengthb) > 4000 THEN '...' ELSE '' END) AS Description,
|
||||
SYSDATE AS LastUpdateDt
|
||||
FROM (
|
||||
SELECT TRIM(fc.CFKY) AS Code,
|
||||
TRIM(ASCIISTR(fc.CFDS80)) AS Description,
|
||||
SUM(LENGTHB(TRIM(fc.CFDS80))+1) OVER(PARTITION BY TRIM(fc.CFKY) ORDER BY TRIM(fc.CFDS80)) - 1 cumul_lengthb,
|
||||
SUM(LENGTHB(TRIM(fc.CFDS80))+1) OVER(PARTITION BY TRIM(fc.CFKY)) - 1 total_lengthb,
|
||||
COUNT(*) OVER(PARTITION BY TRIM(fc.CFKY)) num_values
|
||||
FROM {ProductionSchema}.F00192 fc
|
||||
WHERE TRIM(fc.CFKY) IS NOT NULL
|
||||
)
|
||||
WHERE total_lengthb <= 4000 OR cumul_lengthb <= 4000 - length('...')
|
||||
GROUP BY Code";
|
||||
}
|
||||
Reference in New Issue
Block a user