26ff8d9b4f
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
1018 lines
47 KiB
C#
Executable File
1018 lines
47 KiB
C#
Executable File
// ------------------------------------------------------------------------------
|
|
// <auto-generated>
|
|
// This code was generated by a tool.
|
|
// Runtime Version: 17.0.0.0
|
|
//
|
|
// Changes to this file may cause incorrect behavior and will be lost if
|
|
// the code is regenerated.
|
|
// </auto-generated>
|
|
// ------------------------------------------------------------------------------
|
|
namespace WorkerService.Templates
|
|
{
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Collections.Generic;
|
|
using WorkerService.Models.Reporting;
|
|
using WorkerService.Helpers;
|
|
using System;
|
|
|
|
/// <summary>
|
|
/// Class to produce the template output
|
|
/// </summary>
|
|
|
|
#line 1 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
|
|
public partial class QueryTemplate : QueryTemplateBase
|
|
{
|
|
#line hidden
|
|
/// <summary>
|
|
/// Create the template output
|
|
/// </summary>
|
|
public virtual string TransformText()
|
|
{
|
|
this.Write(@"--Setup flagged work order temp table
|
|
IF OBJECT_ID('tempdb.dbo.#Temp_WO', 'U') IS NOT NULL
|
|
BEGIN
|
|
DROP TABLE #Temp_WO;
|
|
END
|
|
CREATE TABLE #Temp_WO (
|
|
WorkOrderNumber BIGINT NOT NULL,
|
|
LotNumber VARCHAR(30) NULL,
|
|
BranchCode VARCHAR(12) NULL,
|
|
ShortItemNumber BIGINT NOT NULL,
|
|
ManuallySpecified BIT NOT NULL DEFAULT 0,
|
|
SplitOrder BIT NOT NULL DEFAULT 0,
|
|
CARDEX BIT NOT NULL DEFAULT 0,
|
|
PartsList BIT NOT NULL DEFAULT 0,
|
|
Flagged BIT NOT NULL DEFAULT 0,
|
|
PRIMARY KEY CLUSTERED(WorkOrderNumber)
|
|
);
|
|
CREATE INDEX TIX_Temp_WO_Lookup ON #Temp_WO(LotNumber, BranchCode, ShortItemNumber);
|
|
");
|
|
|
|
#line 26 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.WorkOrderFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"
|
|
--Add manually specified work order numbers to flagged list
|
|
WITH WOP_CTE AS(
|
|
SELECT DISTINCT wo.WorkOrderNumber,
|
|
wo.LotNumber,
|
|
wo.BranchCode,
|
|
wo.ShortItemNumber
|
|
FROM dbo.WorkOrder AS wo INNER JOIN
|
|
@p_WorkOrderFilter AS pwof ON (wo.WorkOrderNumber = pwof.WorkOrderNumber)
|
|
)
|
|
MERGE #Temp_WO AS TARGET
|
|
USING WOP_CTE AS SOURCE
|
|
ON (TARGET.WorkOrderNumber = SOURCE.WorkOrderNumber)
|
|
WHEN MATCHED THEN
|
|
UPDATE SET TARGET.ManuallySpecified = 1
|
|
WHEN NOT MATCHED BY TARGET THEN
|
|
INSERT(WorkOrderNumber, LotNumber, BranchCode, ShortItemNumber, ManuallySpecified)
|
|
VALUES(SOURCE.WorkOrderNumber, SOURCE.LotNumber, SOURCE.BranchCode, SOURCE.ShortItemNumber, 1);
|
|
|
|
");
|
|
this.Write(@"--Add any work orders split from flagged work orders
|
|
WITH SP_WO AS
|
|
(
|
|
SELECT DISTINCT wo.WorkOrderNumber,
|
|
wo.LotNumber,
|
|
wo.BranchCode,
|
|
wo.ShortItemNumber
|
|
FROM dbo.WorkOrder AS wo INNER JOIN
|
|
#Temp_WO AS tw_o ON (wo.ParentWorkOrderNumber = CAST(tw_o.WorkOrderNumber AS VARCHAR(8)) AND wo.BranchCode = tw_o.BranchCode)
|
|
)
|
|
MERGE #Temp_WO AS TARGET
|
|
USING SP_WO AS SOURCE
|
|
ON (TARGET.WorkOrderNumber = SOURCE.WorkOrderNumber AND TARGET.BranchCode = SOURCE.BranchCode)
|
|
WHEN MATCHED THEN
|
|
UPDATE SET TARGET.SplitOrder = 1
|
|
WHEN NOT MATCHED BY TARGET THEN
|
|
INSERT (WorkOrderNumber, LotNumber, BranchCode, ShortItemNumber, SplitOrder)
|
|
VALUES (SOURCE.WorkOrderNumber, SOURCE.LotNumber, SOURCE.BranchCode, SOURCE.ShortItemNumber, 1);");
|
|
this.Write("\r\n");
|
|
|
|
#line 47 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 48 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ItemNumberFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"
|
|
--Setup item number filter temp table
|
|
IF OBJECT_ID('tempdb.dbo.#P_ItemNumbers', 'U') IS NOT NULL
|
|
BEGIN
|
|
DROP TABLE #P_ItemNumbers;
|
|
END
|
|
CREATE TABLE #P_ItemNumbers (
|
|
ItemNumber VARCHAR(25) NOT NULL,
|
|
PRIMARY KEY CLUSTERED(ItemNumber)
|
|
);
|
|
|
|
INSERT INTO #P_ItemNumbers(ItemNumber)
|
|
SELECT DISTINCT LTRIM(RTRIM(pinf.ItemNumber))
|
|
FROM @p_ItemNumberFilter AS pinf
|
|
WHERE LTRIM(RTRIM(pinf.ItemNumber)) IS NOT NULL;
|
|
");
|
|
|
|
#line 64 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 65 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ProfitCenterFilterEnabled || Model.WorkCenterFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\r\n--Setup profit center / work center filter temp table\r\nIF OBJECT_ID(\'tempdb.dbo" +
|
|
".#P_WorkCenters\', \'U\') IS NOT NULL\r\nBEGIN\r\n DROP TABLE #P_WorkCenters;\r\nEND\r\n" +
|
|
"CREATE TABLE #P_WorkCenters (\r\n\tCode VARCHAR(12) NOT NULL,\r\n\tPRIMARY KEY CLUSTER" +
|
|
"ED(Code)\r\n);\r\n");
|
|
|
|
#line 76 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 77 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ProfitCenterFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"WITH WCF_CTE AS(
|
|
SELECT LTRIM(RTRIM(oh.WorkCenterCode)) AS Code
|
|
FROM @p_ProfitCenterFilter AS ppcf INNER JOIN
|
|
dbo.OrgHierarchy AS oh ON (LTRIM(RTRIM(ppcf.Code)) = oh.ProfitCenterCode)
|
|
)
|
|
MERGE INTO #P_WorkCenters AS TARGET
|
|
USING WCF_CTE AS SOURCE
|
|
ON (TARGET.Code = SOURCE.Code)
|
|
WHEN NOT MATCHED BY TARGET THEN
|
|
INSERT(Code)
|
|
VALUES(SOURCE.Code);
|
|
");
|
|
|
|
#line 89 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 90 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.WorkCenterFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"WITH WCF_CTE AS(
|
|
SELECT DISTINCT pwcf.Code
|
|
FROM @p_WorkCenterFilter AS pwcf
|
|
WHERE LTRIM(RTRIM(pwcf.Code)) IS NOT NULL
|
|
)
|
|
MERGE INTO #P_WorkCenters AS TARGET
|
|
USING WCF_CTE AS SOURCE
|
|
ON (TARGET.Code = SOURCE.Code)
|
|
WHEN NOT MATCHED BY TARGET THEN
|
|
INSERT(Code)
|
|
VALUES(SOURCE.Code);
|
|
");
|
|
|
|
#line 102 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 103 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ComponentLotFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\r\n--Add downstream product for manually specified component lots\r\nWITH CLN_CTE AS" +
|
|
"(\r\n\tSELECT DISTINCT l.LotNumber,\r\n\t\t l.ShortItemNumber,\r\n\t\t l.BranchCode\r\n\tF" +
|
|
"ROM @p_ComponentLotFilter AS pclf INNER JOIN \r\n\t\t dbo.Lot AS l ON (LTRIM(RTRIM" +
|
|
"(pclf.ComponentLotNumber)) = l.LotNumber AND LTRIM(RTRIM(pclf.ItemNumber)) = l.I" +
|
|
"temNumber)\r\n),\r\nCLN_WO AS(\r\n\tSELECT wo.WorkOrderNumber,\r\n\t\t wo.BranchCode,\r\n\t\t" +
|
|
" wo.LotNumber,\r\n\t\t wo.ShortItemNumber \r\n\tFROM CLN_CTE cln INNER JOIN\r\n\t\t " +
|
|
" dbo.WorkOrderComponent AS woc ON (cln.LotNumber = woc.LotNumber AND cln.ShortIt" +
|
|
"emNumber = woc.ShortItemNumber AND cln.BranchCode = woc.BranchCode) INNER JOIN\r\n" +
|
|
"\t\t dbo.WorkOrder AS wo ON (woc.WorkOrderNumber = wo.WorkOrderNumber)\r\n\tUNION A" +
|
|
"LL\r\n\tSELECT wo.WorkOrderNumber,\r\n\t\t wo.BranchCode,\r\n\t\t wo.LotNumber,\r\n\t\t w" +
|
|
"o.ShortItemNumber \r\n\tFROM CLN_CTE cln INNER JOIN \r\n\t\t dbo.LotUsage AS lu ON(" +
|
|
"cln.LotNumber = lu.LotNumber AND cln.ShortItemNumber = lu.ShortItemNumber AND cl" +
|
|
"n.BranchCode = lu.BranchCode) INNER JOIN\r\n\t\t dbo.WorkOrder AS wo ON(lu.WorkOrd" +
|
|
"erNumber = wo.WorkOrderNumber)\r\n),\r\nCLN_FILTERED_WO AS(\r\n\tSELECT DISTINCT cln.Wo" +
|
|
"rkOrderNumber,\r\n\t\t cln.BranchCode,\r\n\t\t cln.LotNumber,\r\n\t\t cln.ShortItemNum" +
|
|
"ber\r\n\tFROM CLN_WO cln\r\n)\r\nMERGE INTO #Temp_WO AS TARGET\r\nUSING CLN_FILTERED_WO" +
|
|
" AS SOURCE\r\nON (TARGET.WorkOrderNumber = SOURCE.WorkOrderNumber AND TARGET.Br" +
|
|
"anchCode = SOURCE.BranchCode)\r\nWHEN MATCHED THEN\r\n\tUPDATE SET TARGET.CARDEX = 1" +
|
|
"\r\nWHEN NOT MATCHED BY TARGET THEN\r\n INSERT (WorkOrderNumber, LotNumber, Bran" +
|
|
"chCode, ShortItemNumber, CARDEX)\r\n VALUES (SOURCE.WorkOrderNumber, COALESCE(S" +
|
|
"OURCE.LotNumber, CAST(SOURCE.WorkOrderNumber AS VARCHAR(8))), SOURCE.BranchCode," +
|
|
" SOURCE.ShortItemNumber, 1);\r\n");
|
|
this.Write(@"--Add any work orders split from flagged work orders
|
|
WITH SP_WO AS
|
|
(
|
|
SELECT DISTINCT wo.WorkOrderNumber,
|
|
wo.LotNumber,
|
|
wo.BranchCode,
|
|
wo.ShortItemNumber
|
|
FROM dbo.WorkOrder AS wo INNER JOIN
|
|
#Temp_WO AS tw_o ON (wo.ParentWorkOrderNumber = CAST(tw_o.WorkOrderNumber AS VARCHAR(8)) AND wo.BranchCode = tw_o.BranchCode)
|
|
)
|
|
MERGE #Temp_WO AS TARGET
|
|
USING SP_WO AS SOURCE
|
|
ON (TARGET.WorkOrderNumber = SOURCE.WorkOrderNumber AND TARGET.BranchCode = SOURCE.BranchCode)
|
|
WHEN MATCHED THEN
|
|
UPDATE SET TARGET.SplitOrder = 1
|
|
WHEN NOT MATCHED BY TARGET THEN
|
|
INSERT (WorkOrderNumber, LotNumber, BranchCode, ShortItemNumber, SplitOrder)
|
|
VALUES (SOURCE.WorkOrderNumber, SOURCE.LotNumber, SOURCE.BranchCode, SOURCE.ShortItemNumber, 1);");
|
|
this.Write("\r\n");
|
|
|
|
#line 146 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 147 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.OperatorFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"
|
|
--Setup operator filter temp table
|
|
IF OBJECT_ID('tempdb.dbo.#P_OperatorIDs', 'U') IS NOT NULL
|
|
BEGIN
|
|
DROP TABLE #P_OperatorIDs;
|
|
END
|
|
CREATE TABLE #P_OperatorIDs(
|
|
AddressNumber BIGINT NOT NULL,
|
|
UserID VARCHAR(10) NULL,
|
|
PRIMARY KEY CLUSTERED(AddressNumber)
|
|
);
|
|
|
|
WITH O_CTE AS(
|
|
SELECT ju.AddressNumber,
|
|
ju.UserID,
|
|
ROW_NUMBER() OVER(PARTITION BY ju.AddressNumber ORDER BY ju.UserID DESC) RN
|
|
FROM @p_OperatorFilter AS pof INNER JOIN
|
|
dbo.JdeUser AS ju ON (LTRIM(RTRIM(pof.UserName)) = ju.UserID)
|
|
)
|
|
INSERT INTO #P_OperatorIDs(AddressNumber, UserID)
|
|
SELECT o.AddressNumber,
|
|
o.UserID
|
|
FROM O_CTE o
|
|
WHERE o.RN = 1;
|
|
");
|
|
|
|
#line 172 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 173 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ItemOperationMisFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"
|
|
--Setup item/operation/mis filter temp table
|
|
IF OBJECT_ID('tempdb.dbo.#P_PartOperations', 'U') IS NOT NULL
|
|
BEGIN
|
|
DROP TABLE #P_PartOperations;
|
|
END
|
|
CREATE TABLE #P_PartOperations(
|
|
ItemNumber VARCHAR(32) NOT NULL,
|
|
OperationNumber VARCHAR(32) NOT NULL,
|
|
MisNumber VARCHAR(32) NOT NULL,
|
|
MisRevision VARCHAR(32) NOT NULL,
|
|
PRIMARY KEY CLUSTERED(ItemNumber,OperationNumber, MisNumber, MisRevision)
|
|
);
|
|
|
|
INSERT INTO #P_PartOperations(ItemNumber, OperationNumber, MisNumber, MisRevision)
|
|
SELECT DISTINCT LTRIM(RTRIM(piomf.ItemNumber)),
|
|
LTRIM(RTRIM(piomf.OperationNumber)),
|
|
LTRIM(RTRIM(piomf.MisNumber)),
|
|
LTRIM(RTRIM(piomf.MisRevision))
|
|
FROM @p_ItemOperationMisFilter AS piomf
|
|
WHERE LTRIM(RTRIM(piomf.ItemNumber)) IS NOT NULL AND
|
|
LTRIM(RTRIM(piomf.OperationNumber)) IS NOT NULL AND
|
|
LTRIM(RTRIM(piomf.MisNumber)) IS NOT NULL AND
|
|
LTRIM(RTRIM(piomf.MisRevision)) IS NOT NULL;
|
|
");
|
|
|
|
#line 198 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 199 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ExtractMisData) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"IF OBJECT_ID('tempdb.dbo.#TempMisData', 'U') IS NOT NULL
|
|
BEGIN
|
|
DROP TABLE #TempMisData;
|
|
END
|
|
CREATE TABLE #TempMisData (
|
|
WorkOrderNumber BIGINT,
|
|
ItemNumber VARCHAR(25),
|
|
ItemDescription VARCHAR(30),
|
|
BranchCode VARCHAR(12),
|
|
WorkCenterCode VARCHAR(12),
|
|
StepTimestamp DATETIME,
|
|
SequenceNumber DECIMAL(7, 2),
|
|
FunctionCode VARCHAR(15),
|
|
FunctionOperationDescription VARCHAR(80),
|
|
MatchedSequenceNumber DECIMAL(7, 2),
|
|
RoutingMatch BIT,
|
|
MasterMatch BIT,
|
|
MisNumber VARCHAR(32),
|
|
RevID VARCHAR(32),
|
|
CharNumber VARCHAR(32),
|
|
MisSequenceNumber VARCHAR(32),
|
|
TestDescription VARCHAR(2000),
|
|
SamplingType VARCHAR(32),
|
|
SamplingValue VARCHAR(32),
|
|
ToolsGauges VARCHAR(2000),
|
|
WorkInstructions VARCHAR(2000),
|
|
Status VARCHAR(32),
|
|
ReleaseDate DATETIME
|
|
);
|
|
");
|
|
|
|
#line 229 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 230 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ShouldSearchSteps()) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"
|
|
--Query data
|
|
WITH LU_WO AS(
|
|
SELECT DISTINCT
|
|
step.WorkOrderNumber,
|
|
step.LotNumber,
|
|
step.BranchCode,
|
|
step.ShortItemNumber
|
|
FROM (
|
|
SELECT DISTINCT
|
|
wo.WorkOrderNumber,
|
|
COALESCE(wo.LotNumber, CAST(wo.WorkOrderNumber AS VARCHAR(8))) AS LotNumber,
|
|
wo.BranchCode,
|
|
wo.ShortItemNumber
|
|
FROM dbo.WorkOrder wo INNER JOIN ");
|
|
|
|
#line 245 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ItemNumberFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" \r\n #P_ItemNumbers p_in ON (wo.ItemNumber = p_in.ItemNumber) INNER " +
|
|
"JOIN");
|
|
|
|
#line 246 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"
|
|
dbo.WorkOrderStep wos ON (wo.WorkOrderNumber = wos.WorkOrderNumber AND wo.BranchCode = wos.BranchCode) LEFT OUTER JOIN
|
|
dbo.WorkOrderTime wot ON (wos.WorkOrderNumber = wot.WorkOrderNumber AND wos.StepNumber = wot.StepNumber AND wos.BranchCode = wot.BranchCode)");
|
|
|
|
#line 248 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ProfitCenterFilterEnabled || Model.WorkCenterFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" INNER JOIN \r\n #P_WorkCenters p_wc ON (wos.WorkCenterCode = p_wc.Co" +
|
|
"de)");
|
|
|
|
#line 249 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} if(Model.OperatorFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" INNER JOIN \r\n #P_OperatorIDs p_oi ON (wot.AddressNumber = p_oi.Add" +
|
|
"ressNumber)");
|
|
|
|
#line 250 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} if(Model.ItemOperationMisFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@" CROSS APPLY
|
|
dbo.MatchMIS(wo.WorkOrderNumber, wo.ItemNumber, wo.BranchCode, wo.RoutingType, wo.IssueDate, wos.WorkCenterCode,
|
|
wos.StepNumber, wos.EndDT, wos.FunctionCode, wos.FunctionOperationDescription) AS mm INNER JOIN
|
|
#P_PartOperations p_po on (mm.ItemNumber = p_po.ItemNumber AND mm.MisSequenceNumber = p_po.OperationNumber AND mm.MisNumber = p_po.MisNumber AND mm.RevID = p_po.MisRevision) ");
|
|
|
|
#line 253 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" ");
|
|
|
|
#line 254 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
this.Write("\r\n");
|
|
if(Model.TimespanFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\t WHERE (wos.EndDT <= @p_MaximumDT AND wos.EndDT >= @p_MinimumDT) OR\r\n " +
|
|
" (wot.GlDate <= @p_MaximumDT AND wot.GlDate >= @p_MinimumDT)\r\n ");
|
|
|
|
#line 258 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} if(!Model.ItemOperationMisFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" UNION \r\n SELECT DISTINCT\r\n\t\t\t wo.WorkOrderNumber,\r\n\t\t\t COALESC" +
|
|
"E(wo.LotNumber, CAST(wo.WorkOrderNumber AS VARCHAR(8))) AS LotNumber,\r\n\t\t\t wo." +
|
|
"BranchCode,\r\n\t\t\t wo.ShortItemNumber\r\n FROM dbo.WorkOrder wo INNER JOI" +
|
|
"N ");
|
|
|
|
#line 265 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ItemNumberFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" \r\n #P_ItemNumbers p_in ON (wo.ItemNumber = p_in.ItemNumber) INNER " +
|
|
"JOIN");
|
|
|
|
#line 266 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" \r\n\t\t dbo.WorkOrderTime wot ON (wo.WorkOrderNumber = wot.WorkOrderNumber AN" +
|
|
"D wo.BranchCode = wot.BranchCode)");
|
|
|
|
#line 267 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ProfitCenterFilterEnabled || Model.WorkCenterFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" INNER JOIN \r\n #P_WorkCenters p_wc ON (wot.WorkCenterCode = p_wc.Co" +
|
|
"de)");
|
|
|
|
#line 268 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} if(Model.OperatorFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" INNER JOIN \r\n #P_OperatorIDs p_oi ON (wot.AddressNumber = p_oi.Add" +
|
|
"ressNumber)");
|
|
|
|
#line 269 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" ");
|
|
|
|
#line 270 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
this.Write("\r\n");
|
|
if(Model.MinimumDT.HasValue && Model.MaximumDT.HasValue) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\t WHERE (wot.GlDate <= @p_MaximumDT AND wot.GlDate >= @p_MinimumDT)\r\n " +
|
|
"");
|
|
|
|
#line 273 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} }
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@") step
|
|
)
|
|
MERGE INTO #Temp_WO AS TARGET
|
|
USING LU_WO AS SOURCE
|
|
ON (TARGET.WorkOrderNumber = SOURCE.WorkOrderNumber AND TARGET.BranchCode = SOURCE.BranchCode)
|
|
WHEN MATCHED THEN
|
|
UPDATE SET TARGET.Flagged = 1
|
|
WHEN NOT MATCHED BY TARGET THEN
|
|
INSERT(WorkOrderNumber, LotNumber, BranchCode, ShortItemNumber, Flagged)
|
|
VALUES(SOURCE.WorkOrderNumber, SOURCE.LotNumber, SOURCE.BranchCode, SOURCE.ShortItemNumber, 1);
|
|
");
|
|
|
|
#line 284 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\r\n--Add downlevel work orders that were issued material from flagged work orders\r" +
|
|
"\nDECLARE @c_MAX_RUNS INT = 20;\r\nDECLARE @v_NumWO INT = -1;\r\nDECLARE @v_NewNumWO " +
|
|
"INT;\r\nDECLARE @v_NumRuns INT = 0;\r\n\r\nWHILE(1 = 1) BEGIN\r\n\tSET @v_NumWO = @v_NewN" +
|
|
"umWO;\r\n\t\r\n\t");
|
|
|
|
#line 295 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
this.PushIndent(" ");
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\t");
|
|
this.Write("--Add any work orders issued material from flagged work orders\r\nWITH CWO_D AS(\r\n " +
|
|
" SELECT DISTINCT wo.WorkOrderNumber,\r\n wo.LotNumber,\r\n\t\t wo.Branch" +
|
|
"Code,\r\n\t\t wo.ShortItemNumber\r\n FROM dbo.WorkOrderComponent AS woc INNER J" +
|
|
"OIN\r\n\t\t dbo.WorkOrder AS wo ON (woc.WorkOrderNumber = wo.WorkOrderNumber) INNE" +
|
|
"R JOIN\r\n #Temp_WO AS t_wo ON (woc.LotNumber = t_wo.LotNumber AND woc.S" +
|
|
"hortItemNumber = t_wo.ShortItemNumber)\r\n)\r\nMERGE #Temp_WO AS TARGET\r\nUSING CWO_D" +
|
|
" AS SOURCE\r\nON (TARGET.WorkOrderNumber = SOURCE.WorkOrderNumber)\r\nWHEN MATCH" +
|
|
"ED THEN\r\n\tUPDATE SET TARGET.PartsList = 1\r\nWHEN NOT MATCHED THEN\r\n\tINSERT (Work" +
|
|
"OrderNumber, LotNumber, BranchCode, ShortItemNumber, PartsList)\r\n\tVALUES (SOURCE" +
|
|
".WorkOrderNumber, COALESCE(SOURCE.LotNumber, CAST(SOURCE.WorkOrderNumber AS VARC" +
|
|
"HAR(8))), SOURCE.BranchCode, SOURCE.ShortItemNumber, 1); \r\n\r\nWITH CWO_D AS(" +
|
|
"\r\n SELECT DISTINCT wo.WorkOrderNumber,\r\n wo.LotNumber,\r\n\t\t wo.Bra" +
|
|
"nchCode,\r\n\t\t wo.ShortItemNumber\r\n FROM dbo.LotUsage AS lu INNER JOIN\r\n\t\t " +
|
|
" dbo.WorkOrder AS wo ON (lu.WorkOrderNumber = wo.WorkOrderNumber) INNER JOIN\r\n " +
|
|
" #Temp_WO AS t_wo ON (lu.LotNumber = t_wo.LotNumber AND lu.ShortItemNum" +
|
|
"ber = t_wo.ShortItemNumber)\r\n)\r\nMERGE #Temp_WO AS TARGET\r\nUSING CWO_D AS SOURCE\r" +
|
|
"\nON (TARGET.WorkOrderNumber = SOURCE.WorkOrderNumber)\r\nWHEN MATCHED THEN\r\n\tU" +
|
|
"PDATE SET TARGET.CARDEX = 1\r\nWHEN NOT MATCHED THEN\r\n\tINSERT (WorkOrderNumber, L" +
|
|
"otNumber, BranchCode, ShortItemNumber, CARDEX)\r\n\tVALUES (SOURCE.WorkOrderNumber," +
|
|
" COALESCE(SOURCE.LotNumber, CAST(SOURCE.WorkOrderNumber AS VARCHAR(8))), SOURCE." +
|
|
"BranchCode, SOURCE.ShortItemNumber, 1);");
|
|
this.Write("\r\n\r\n\t");
|
|
this.Write(@"--Add any work orders split from flagged work orders
|
|
WITH SP_WO AS
|
|
(
|
|
SELECT DISTINCT wo.WorkOrderNumber,
|
|
wo.LotNumber,
|
|
wo.BranchCode,
|
|
wo.ShortItemNumber
|
|
FROM dbo.WorkOrder AS wo INNER JOIN
|
|
#Temp_WO AS tw_o ON (wo.ParentWorkOrderNumber = CAST(tw_o.WorkOrderNumber AS VARCHAR(8)) AND wo.BranchCode = tw_o.BranchCode)
|
|
)
|
|
MERGE #Temp_WO AS TARGET
|
|
USING SP_WO AS SOURCE
|
|
ON (TARGET.WorkOrderNumber = SOURCE.WorkOrderNumber AND TARGET.BranchCode = SOURCE.BranchCode)
|
|
WHEN MATCHED THEN
|
|
UPDATE SET TARGET.SplitOrder = 1
|
|
WHEN NOT MATCHED BY TARGET THEN
|
|
INSERT (WorkOrderNumber, LotNumber, BranchCode, ShortItemNumber, SplitOrder)
|
|
VALUES (SOURCE.WorkOrderNumber, SOURCE.LotNumber, SOURCE.BranchCode, SOURCE.ShortItemNumber, 1);");
|
|
this.Write("\r\n\t");
|
|
|
|
#line 299 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
this.PopIndent();
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\r\n\tSELECT @v_NewNumWO = COUNT(*) FROM #Temp_WO;\r\n\tSET @v_NumRuns = @v_NumRuns + 1" +
|
|
";\r\n\t\r\n\tIF(@v_NumWO = @v_NewNumWO OR @v_NumRuns = @c_MAX_RUNS) BEGIN\r\n\t\tBREAK;\r\n\t" +
|
|
"END\t\r\nEND;\r\n\r\n--Lookup flagged work order details\r\nWITH LAST_WOS AS\r\n(\r\n SELE" +
|
|
"CT wos.WorkOrderNumber,\r\n wos.BranchCode,\r\n wos.StepNumbe" +
|
|
"r,\r\n wos.StepDescription,\r\n wos.FunctionOperationDescripti" +
|
|
"on,\r\n wos.LastUpdateDT,\r\n ROW_NUMBER() OVER (PARTITION BY " +
|
|
"wos.WorkOrderNumber, wos.BranchCode ORDER BY wos.EndDT DESC, wos.StepNumber DESC" +
|
|
") AS RN\r\n FROM dbo.WorkOrderStep AS wos LEFT OUTER JOIN\r\n #Temp" +
|
|
"_WO t_wo ON (wos.WorkOrderNumber = t_wo.WorkOrderNumber AND wos.BranchCode = t_w" +
|
|
"o.BranchCode)\r\n)\r\nSELECT wo.WorkOrderNumber,\r\n wo.BranchCode AS WorkOrde" +
|
|
"rBranchCode,\r\n wo.LotNumber,\r\n wo.ItemNumber,\r\n i.PlanningF" +
|
|
"amily,\r\n\t\ti.StockingType,\r\n t_wo.ManuallySpecified,\r\n t_wo.SplitOr" +
|
|
"der,\r\n t_wo.CARDEX,\r\n t_wo.PartsList,\r\n t_wo.Flagged,\r\n " +
|
|
" wo.OrderQuantity,\r\n wo.HeldQuantity,\r\n COALESCE(wots.TotalScra" +
|
|
"ppedQuantity, 0) AS ScrappedQuantity,\r\n wo.ShippedQuantity,\r\n LTRI" +
|
|
"M(RTRIM(lwos.BranchCode)) AS StepBranchCode,\r\n lwos.StepNumber,\r\n " +
|
|
"lwos.StepDescription,\r\n lwos.FunctionOperationDescription,\r\n lwos." +
|
|
"LastUpdateDT AS StepUpdateDT,\r\n wo.StatusCode,\r\n sc.Description AS" +
|
|
" StatusDescription,\r\n wo.StatusCodeUpdateDT AS StatusUpdateDT\r\nFROM db" +
|
|
"o.WorkOrder AS wo INNER JOIN \r\n #Temp_WO AS t_wo ON (t_wo.WorkOrderNumber" +
|
|
" = wo.WorkOrderNumber AND t_wo.BranchCode = wo.BranchCode) LEFT OUTER JOIN\r\n " +
|
|
" dbo.Item i on (wo.ShortItemNumber = i.ShortItemNumber) INNER JOIN\r\n d" +
|
|
"bo.StatusCode AS sc ON (sc.Code = wo.StatusCode) LEFT OUTER JOIN\r\n LAST_W" +
|
|
"OS lwos ON (wo.WorkOrderNumber = lwos.WorkOrderNumber AND wo.BranchCode = lwos.B" +
|
|
"ranchCode) LEFT OUTER JOIN \r\n dbo.WorkOrderTotalScrap wots ON (wo.WorkOrd" +
|
|
"erNumber = wots.WorkOrderNumber AND wo.BranchCode = wots.BranchCode)\r\nWHERE lw" +
|
|
"os.RN IS NULL OR \r\n lwos.RN = 1;\r\n");
|
|
|
|
#line 353 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ExtractMisData) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(@"WITH MIS_CTE AS(
|
|
SELECT DISTINCT wo.WorkOrderNumber,
|
|
wo.ItemNumber,
|
|
wo.BranchCode,
|
|
wo.RoutingType,
|
|
wo.IssueDate,
|
|
wos.WorkCenterCode,
|
|
wos.StepNumber,
|
|
wos.EndDT,
|
|
wos.FunctionCode,
|
|
wos.FunctionOperationDescription
|
|
FROM dbo.WorkOrderStep AS wos INNER JOIN
|
|
dbo.WorkOrder AS wo ON (wos.WorkOrderNumber = wo.WorkOrderNumber AND LTRIM(wos.BranchCode) = wo.BranchCode) LEFT OUTER JOIN
|
|
dbo.WorkOrderTime AS wot ON (wos.WorkOrderNumber = wot.WorkOrderNumber AND LTRIM(wos.BranchCode) = wot.BranchCode AND wos.StepNumber = wot.StepNumber) ");
|
|
|
|
#line 367 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.ItemNumberFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" INNER JOIN\r\n #P_ItemNumbers p_in ON (wo.ItemNumber = p_in.ItemNumber)" +
|
|
"");
|
|
|
|
#line 368 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} if(Model.ProfitCenterFilterEnabled || Model.WorkCenterFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" INNER JOIN \r\n #P_WorkCenters p_wc ON (wos.WorkCenterCode = p_wc.Code)" +
|
|
"");
|
|
|
|
#line 369 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} if(Model.OperatorFilterEnabled) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(" INNER JOIN \r\n #P_OperatorIDs p_oi ON (wot.AddressNumber = p_oi.Addres" +
|
|
"sNumber)");
|
|
|
|
#line 370 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
|
|
#line 371 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
if(Model.MinimumDT.HasValue && Model.MaximumDT.HasValue) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\tWHERE (((wos.EndDT <= @p_MaximumDT) AND (wos.EndDT >= @p_MinimumDT)) OR \r\n\t " +
|
|
" ((wot.GlDate <= @p_MaximumDT) AND (wot.GlDate >= @p_MinimumDT)))\r\n");
|
|
|
|
#line 374 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} else if(Model.MinimumDT.HasValue && !Model.MaximumDT.HasValue) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\tWHERE (wos.EndDT >= @p_MinimumDT OR wot.GlDate >= @p_MinimumDT)\r\n");
|
|
|
|
#line 376 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
} else if(!Model.MinimumDT.HasValue && Model.MaximumDT.HasValue) {
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write("\tWHERE (wos.EndDT <= @p_MaximumDT OR wot.GlDate <= @p_MaximumDT))\r\n");
|
|
|
|
#line 378 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
this.Write(")\r\nINSERT INTO #TempMISData\r\n( \r\n WorkOrderNumber,\r\n ItemNum" +
|
|
"ber,\r\n ItemDescription,\r\n BranchCode,\r\n WorkCenterCode,\r\n StepTimest" +
|
|
"amp,\r\n SequenceNumber,\r\n FunctionCode,\r\n FunctionOperationDescription,\r" +
|
|
"\n MatchedSequenceNumber,\r\n RoutingMatch,\r\n MasterMatch,\r\n MisNumber," +
|
|
"\r\n RevID,\r\n CharNumber,\r\n MisSequenceNumber,\r\n TestDescription,\r\n " +
|
|
" SamplingType,\r\n SamplingValue,\r\n ToolsGauges,\r\n WorkInstructions,\r\n " +
|
|
" Status,\r\n ReleaseDate\r\n)\r\nSELECT mm.WorkOrderNumber,\r\n mm.ItemNumber,\r" +
|
|
"\n mm.ItemDescription,\r\n mm.BranchCode,\r\n mm.WorkCenterCode,\r\n " +
|
|
" mm.StepTimestamp,\r\n mm.SequenceNumber,\r\n mm.FunctionCode,\r\n " +
|
|
" mm.FunctionOperationDescription,\r\n mm.MatchedSequenceNumber,\r\n m" +
|
|
"m.RoutingMatch,\r\n mm.MasterMatch,\r\n mm.MisNumber,\r\n mm.RevID,\r" +
|
|
"\n mm.CharNumber,\r\n mm.MisSequenceNumber,\r\n mm.TestDescription," +
|
|
"\r\n mm.SamplingType,\r\n mm.SamplingValue,\r\n mm.ToolsGauges,\r\n " +
|
|
" mm.WorkInstructions,\r\n mm.Status,\r\n mm.ReleaseDate\r\nFROM MIS_C" +
|
|
"TE c CROSS APPLY\r\n dbo.MatchMIS(c.WorkOrderNumber, c.ItemNumber, c.BranchC" +
|
|
"ode, c.RoutingType, \r\n c.IssueDate, c.WorkCenterCode, c.StepN" +
|
|
"umber, c.EndDT,\r\n c.FunctionCode, c.FunctionOperationDescript" +
|
|
"ion) AS mm;\r\n\r\n--Get MIS search results\r\nSELECT DISTINCT tmd.ItemNumber,\r\n " +
|
|
" tmd.ItemDescription,\r\n tmd.BranchCode,\r\n tmd.MisSequenceNum" +
|
|
"ber AS SequenceNumber,\r\n tmd.FunctionCode,\r\n tmd.FunctionOperati" +
|
|
"onDescription,\r\n tmd.SequenceNumber AS JobStepSequenceNumber,\r\n " +
|
|
"tmd.MatchedSequenceNumber,\r\n tmd.RoutingMatch,\r\n tmd.MasterMatch" +
|
|
",\r\n tmd.MisNumber,\r\n tmd.RevID,\r\n tmd.CharNumber,\r\n " +
|
|
" tmd.TestDescription,\r\n tmd.SamplingType,\r\n tmd.SamplingValue" +
|
|
",\r\n tmd.ToolsGauges,\r\n tmd.WorkInstructions,\r\n tmd.Statu" +
|
|
"s,\r\n tmd.ReleaseDate\r\nFROM #TempMisData AS tmd\r\nORDER BY tmd.ItemNum" +
|
|
"ber,\r\n tmd.BranchCode,\r\n tmd.SequenceNumber,\r\n tmd.Match" +
|
|
"edSequenceNumber;\r\n\r\n--Get no-match MIS search results\r\nSELECT DISTINCT tmd.Wo" +
|
|
"rkCenterCode,\r\n tmd.WorkOrderNumber,\r\n wo.IssueDate AS WorkOrder" +
|
|
"StartDate,\r\n tmd.SequenceNumber AS JobStepNumber,\r\n tmd.Function" +
|
|
"OperationDescription AS JobStepDescription,\r\n tmd.StepTimestamp AS JobSt" +
|
|
"epEndDate,\r\n\t\t CASE WHEN wo.RoutingType=\'NMR\' OR NOT EXISTS(SELECT * FROM dbo.Wo" +
|
|
"rkOrderRouting wor WHERE tmd.WorkOrderNumber = wor.WorkOrderNumber AND wor.StepN" +
|
|
"umber = tmd.SequenceNumber) THEN 1 ELSE 0 END AS WasJobStepAdded,\r\n\t\t CASE WHEN " +
|
|
"wo.RoutingType=\'NMR\' THEN NULL ELSE (SELECT TOP 1 wor.StepNumber FROM dbo.WorkOr" +
|
|
"derRouting wor WHERE (tmd.WorkOrderNumber = wor.WorkOrderNumber AND tmd.WorkCent" +
|
|
"erCode = wor.WorkCenterCode AND tmd.FunctionCode = wor.FunctionCode) AND wor.Ste" +
|
|
"pNumber <> tmd.SequenceNumber) END AS MatchedJobStepNumber,\r\n tmd.Functi" +
|
|
"onCode,\r\n tmd.ItemNumber,\r\n i.Description AS ItemDescription,\r\n " +
|
|
" wo.RoutingType\r\nFROM #TempMisData AS tmd INNER JOIN \r\n dbo.W" +
|
|
"orkOrder AS wo ON (tmd.WorkOrderNumber = wo.WorkOrderNumber AND tmd.BranchCode =" +
|
|
" wo.BranchCode) LEFT OUTER JOIN \r\n dbo.Item AS i ON (wo.ShortItemNumber " +
|
|
"= i.ShortItemNumber)\r\nWHERE (tmd.RoutingMatch = 0 AND\r\n tmd.MasterMat" +
|
|
"ch = 0) OR \r\n tmd.MisNumber IS NULL\r\nORDER BY tmd.WorkOrderNumber,\r\n " +
|
|
" tmd.SequenceNumber;\r\n");
|
|
|
|
#line 482 "D:\SHARE\Visual Studio 2019\LotFinderJDE\WorkerService\Templates\QueryTemplate.tt"
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
return this.GenerationEnvironment.ToString();
|
|
}
|
|
}
|
|
|
|
#line default
|
|
#line hidden
|
|
#region Base class
|
|
/// <summary>
|
|
/// Base class for this transformation
|
|
/// </summary>
|
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
|
|
public class QueryTemplateBase
|
|
{
|
|
#region Fields
|
|
private global::System.Text.StringBuilder generationEnvironmentField;
|
|
private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
|
|
private global::System.Collections.Generic.List<int> indentLengthsField;
|
|
private string currentIndentField = "";
|
|
private bool endsWithNewline;
|
|
private global::System.Collections.Generic.IDictionary<string, object> sessionField;
|
|
#endregion
|
|
#region Properties
|
|
/// <summary>
|
|
/// The string builder that generation-time code is using to assemble generated output
|
|
/// </summary>
|
|
public System.Text.StringBuilder GenerationEnvironment
|
|
{
|
|
get
|
|
{
|
|
if ((this.generationEnvironmentField == null))
|
|
{
|
|
this.generationEnvironmentField = new global::System.Text.StringBuilder();
|
|
}
|
|
return this.generationEnvironmentField;
|
|
}
|
|
set
|
|
{
|
|
this.generationEnvironmentField = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// The error collection for the generation process
|
|
/// </summary>
|
|
public System.CodeDom.Compiler.CompilerErrorCollection Errors
|
|
{
|
|
get
|
|
{
|
|
if ((this.errorsField == null))
|
|
{
|
|
this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
|
|
}
|
|
return this.errorsField;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// A list of the lengths of each indent that was added with PushIndent
|
|
/// </summary>
|
|
private System.Collections.Generic.List<int> indentLengths
|
|
{
|
|
get
|
|
{
|
|
if ((this.indentLengthsField == null))
|
|
{
|
|
this.indentLengthsField = new global::System.Collections.Generic.List<int>();
|
|
}
|
|
return this.indentLengthsField;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Gets the current indent we use when adding lines to the output
|
|
/// </summary>
|
|
public string CurrentIndent
|
|
{
|
|
get
|
|
{
|
|
return this.currentIndentField;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Current transformation session
|
|
/// </summary>
|
|
public virtual global::System.Collections.Generic.IDictionary<string, object> Session
|
|
{
|
|
get
|
|
{
|
|
return this.sessionField;
|
|
}
|
|
set
|
|
{
|
|
this.sessionField = value;
|
|
}
|
|
}
|
|
#endregion
|
|
#region Transform-time helpers
|
|
/// <summary>
|
|
/// Write text directly into the generated output
|
|
/// </summary>
|
|
public void Write(string textToAppend)
|
|
{
|
|
if (string.IsNullOrEmpty(textToAppend))
|
|
{
|
|
return;
|
|
}
|
|
// If we're starting off, or if the previous text ended with a newline,
|
|
// we have to append the current indent first.
|
|
if (((this.GenerationEnvironment.Length == 0)
|
|
|| this.endsWithNewline))
|
|
{
|
|
this.GenerationEnvironment.Append(this.currentIndentField);
|
|
this.endsWithNewline = false;
|
|
}
|
|
// Check if the current text ends with a newline
|
|
if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
|
|
{
|
|
this.endsWithNewline = true;
|
|
}
|
|
// This is an optimization. If the current indent is "", then we don't have to do any
|
|
// of the more complex stuff further down.
|
|
if ((this.currentIndentField.Length == 0))
|
|
{
|
|
this.GenerationEnvironment.Append(textToAppend);
|
|
return;
|
|
}
|
|
// Everywhere there is a newline in the text, add an indent after it
|
|
textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
|
|
// If the text ends with a newline, then we should strip off the indent added at the very end
|
|
// because the appropriate indent will be added when the next time Write() is called
|
|
if (this.endsWithNewline)
|
|
{
|
|
this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
|
|
}
|
|
else
|
|
{
|
|
this.GenerationEnvironment.Append(textToAppend);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Write text directly into the generated output
|
|
/// </summary>
|
|
public void WriteLine(string textToAppend)
|
|
{
|
|
this.Write(textToAppend);
|
|
this.GenerationEnvironment.AppendLine();
|
|
this.endsWithNewline = true;
|
|
}
|
|
/// <summary>
|
|
/// Write formatted text directly into the generated output
|
|
/// </summary>
|
|
public void Write(string format, params object[] args)
|
|
{
|
|
this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
|
|
}
|
|
/// <summary>
|
|
/// Write formatted text directly into the generated output
|
|
/// </summary>
|
|
public void WriteLine(string format, params object[] args)
|
|
{
|
|
this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
|
|
}
|
|
/// <summary>
|
|
/// Raise an error
|
|
/// </summary>
|
|
public void Error(string message)
|
|
{
|
|
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
|
|
error.ErrorText = message;
|
|
this.Errors.Add(error);
|
|
}
|
|
/// <summary>
|
|
/// Raise a warning
|
|
/// </summary>
|
|
public void Warning(string message)
|
|
{
|
|
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
|
|
error.ErrorText = message;
|
|
error.IsWarning = true;
|
|
this.Errors.Add(error);
|
|
}
|
|
/// <summary>
|
|
/// Increase the indent
|
|
/// </summary>
|
|
public void PushIndent(string indent)
|
|
{
|
|
if ((indent == null))
|
|
{
|
|
throw new global::System.ArgumentNullException("indent");
|
|
}
|
|
this.currentIndentField = (this.currentIndentField + indent);
|
|
this.indentLengths.Add(indent.Length);
|
|
}
|
|
/// <summary>
|
|
/// Remove the last indent that was added with PushIndent
|
|
/// </summary>
|
|
public string PopIndent()
|
|
{
|
|
string returnValue = "";
|
|
if ((this.indentLengths.Count > 0))
|
|
{
|
|
int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
|
|
this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
|
|
if ((indentLength > 0))
|
|
{
|
|
returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
|
|
this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
|
|
}
|
|
}
|
|
return returnValue;
|
|
}
|
|
/// <summary>
|
|
/// Remove any indentation
|
|
/// </summary>
|
|
public void ClearIndent()
|
|
{
|
|
this.indentLengths.Clear();
|
|
this.currentIndentField = "";
|
|
}
|
|
#endregion
|
|
#region ToString Helpers
|
|
/// <summary>
|
|
/// Utility class to produce culture-oriented representation of an object as a string.
|
|
/// </summary>
|
|
public class ToStringInstanceHelper
|
|
{
|
|
private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
|
|
/// <summary>
|
|
/// Gets or sets format provider to be used by ToStringWithCulture method.
|
|
/// </summary>
|
|
public System.IFormatProvider FormatProvider
|
|
{
|
|
get
|
|
{
|
|
return this.formatProviderField ;
|
|
}
|
|
set
|
|
{
|
|
if ((value != null))
|
|
{
|
|
this.formatProviderField = value;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// This is called from the compile/run appdomain to convert objects within an expression block to a string
|
|
/// </summary>
|
|
public string ToStringWithCulture(object objectToConvert)
|
|
{
|
|
if ((objectToConvert == null))
|
|
{
|
|
throw new global::System.ArgumentNullException("objectToConvert");
|
|
}
|
|
System.Type t = objectToConvert.GetType();
|
|
System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
|
|
typeof(System.IFormatProvider)});
|
|
if ((method == null))
|
|
{
|
|
return objectToConvert.ToString();
|
|
}
|
|
else
|
|
{
|
|
return ((string)(method.Invoke(objectToConvert, new object[] {
|
|
this.formatProviderField })));
|
|
}
|
|
}
|
|
}
|
|
private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
|
|
/// <summary>
|
|
/// Helper to produce culture-oriented representation of an object as a string
|
|
/// </summary>
|
|
public ToStringInstanceHelper ToStringHelper
|
|
{
|
|
get
|
|
{
|
|
return this.toStringHelperField;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|