103 lines
6.7 KiB
MySQL
103 lines
6.7 KiB
MySQL
|
|
Alter VIEW View_HJGL_InstallData
|
|||
|
|
AS
|
|||
|
|
WITH TwOutPutData as (select distinct twRelation.PipelineId,
|
|||
|
|
outdetail.Id as TwOutputDetailId,
|
|||
|
|
twRelation.MaterialCode,
|
|||
|
|
master.Id as OutputMasterId
|
|||
|
|
from Tw_OutputMaster master
|
|||
|
|
join Tw_OutputDetail outdetail on outdetail.OutputMasterId = master.Id
|
|||
|
|
join Tw_InOutPlanMaster planmaster on planmaster.Id = master.InOutPlanMasterId
|
|||
|
|
join Tw_InOutPlanDetail_Relation twRelation
|
|||
|
|
on twRelation.InOutPlanMasterId = planmaster.Id and
|
|||
|
|
outdetail.MaterialCode = twRelation.MaterialCode
|
|||
|
|
where master.TypeInt=70),
|
|||
|
|
PrefabricatedData AS (SELECT pipe.PipeLineMatId as Id,
|
|||
|
|
line.PipelineCode,
|
|||
|
|
pipe.PrefabricatedComponents as Code,
|
|||
|
|
'Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' as TypeStr,
|
|||
|
|
'' as Matdef,
|
|||
|
|
CAST(NULL AS DECIMAL(18, 2)) as Number, -- <20><>ȷָ<C8B7><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
pack.PackagingCode,
|
|||
|
|
trainnumber.TrainNumber,
|
|||
|
|
line.FlowingSection,
|
|||
|
|
line.UnitWorkId,
|
|||
|
|
line.ProjectId,
|
|||
|
|
pack.StackingPosition
|
|||
|
|
FROM dbo.HJGL_PipeLineMat pipe
|
|||
|
|
INNER JOIN dbo.HJGL_Pipeline line -- <20><>ΪINNER JOIN<49><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ON pipe.PipelineId = line.PipelineId
|
|||
|
|
LEFT JOIN dbo.HJGL_MaterialCodeLib lib
|
|||
|
|
ON lib.MaterialCode = pipe.MaterialCode
|
|||
|
|
LEFT JOIN HJGL_Pipeline_Component comonent
|
|||
|
|
ON comonent.PipelineComponentCode = pipe.PrefabricatedComponents
|
|||
|
|
LEFT JOIN HJGL_PackagingManageDetail packdetail
|
|||
|
|
ON packdetail.PipelineComponentId = comonent.PipelineComponentId
|
|||
|
|
LEFT JOIN HJGL_PackagingManage pack
|
|||
|
|
ON packdetail.PackagingManageId = pack.PackagingManageId
|
|||
|
|
AND pack.ProjectId = line.ProjectId -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
LEFT JOIN HJGL_TrainNumberManage trainnumber
|
|||
|
|
ON pack.TrainNumberId = trainnumber.Id
|
|||
|
|
WHERE line.PipeArea = '1'
|
|||
|
|
and (pipe.PrefabricatedComponents != ''
|
|||
|
|
AND pipe.PrefabricatedComponents IS NOT NULL)),
|
|||
|
|
LooseComponentsData AS (SELECT distinct pipe.PipeLineMatId as Id,
|
|||
|
|
line.PipelineCode,
|
|||
|
|
pipe.MaterialCode as Code,
|
|||
|
|
'Ԥ<EFBFBD><EFBFBD>ɢ<EFBFBD><EFBFBD>' as TypeStr,
|
|||
|
|
lib.MaterialDef as Matdef,
|
|||
|
|
cast( packdetail.Number as DECIMAL(18, 2)) as Number,
|
|||
|
|
pack.PackagingCode,
|
|||
|
|
trainnumber.TrainNumber,
|
|||
|
|
line.FlowingSection,
|
|||
|
|
line.UnitWorkId,
|
|||
|
|
line.ProjectId,
|
|||
|
|
pack.StackingPosition
|
|||
|
|
FROM dbo.HJGL_PipeLineMat pipe
|
|||
|
|
INNER JOIN HJGL_Pipeline line -- <20><>ΪINNER JOIN
|
|||
|
|
ON pipe.PipelineId = line.PipelineId
|
|||
|
|
LEFT JOIN dbo.HJGL_MaterialCodeLib lib
|
|||
|
|
ON lib.MaterialCode = pipe.MaterialCode
|
|||
|
|
LEFT JOIN HJGL_PackagingManageDetail packdetail
|
|||
|
|
ON packdetail.MaterialCode = pipe.MaterialCode
|
|||
|
|
LEFT JOIN TwOutPutData twOutPutData
|
|||
|
|
ON twOutPutData.PipelineId = pipe.PipelineId and
|
|||
|
|
twOutPutData.MaterialCode = packdetail.MaterialCode
|
|||
|
|
LEFT JOIN HJGL_PackagingManage pack
|
|||
|
|
ON packdetail.PackagingManageId = pack.PackagingManageId
|
|||
|
|
AND pack.ProjectId = line.ProjectId -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
LEFT JOIN HJGL_TrainNumberManage trainnumber
|
|||
|
|
ON pack.TrainNumberId = trainnumber.Id
|
|||
|
|
where line.PipeArea = '1'
|
|||
|
|
and (pipe.PrefabricatedComponents is null or pipe.PrefabricatedComponents = ''))
|
|||
|
|
|
|||
|
|
-- <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
SELECT *
|
|||
|
|
FROM PrefabricatedData
|
|||
|
|
UNION ALL
|
|||
|
|
SELECT *
|
|||
|
|
FROM LooseComponentsData
|
|||
|
|
go
|
|||
|
|
|
|||
|
|
INSERT INTO HJGL_PackagingManageDetail
|
|||
|
|
SELECT NEWID(),
|
|||
|
|
p.PackagingManageId,
|
|||
|
|
HPC.PipelineId,
|
|||
|
|
s.Value,
|
|||
|
|
NULL,
|
|||
|
|
NULL,
|
|||
|
|
'2025-10-29 15:01:32.513',
|
|||
|
|
'C4A62EC0-E5D3-4EBF-A5FA-E56AA89633C0',
|
|||
|
|
NULL
|
|||
|
|
FROM HJGL_PackagingManage p
|
|||
|
|
CROSS APPLY dbo.SplitString(p.PipelineComponentId, ',', 1) s
|
|||
|
|
JOIN HJGL_Pipeline_Component HPC ON s.Value = HPC.PipelineComponentId
|
|||
|
|
WHERE p.PipelineComponentId IS NOT NULL
|
|||
|
|
AND p.PipelineComponentId != ''
|
|||
|
|
AND NOT EXISTS (
|
|||
|
|
SELECT 1
|
|||
|
|
FROM HJGL_PackagingManageDetail pmd
|
|||
|
|
WHERE pmd.PackagingManageId = p.PackagingManageId
|
|||
|
|
AND pmd.PipelineId = HPC.PipelineId
|
|||
|
|
AND pmd.PipelineComponentId = s.Value
|
|||
|
|
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>ֶΣ<D6B6><CEA3><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
)
|