Třídová akce

Popis:
Vrátí plánovatelné dílenské úkony z požadavků na výrobu, které nemají žádný úkon zafixovaný.
Kód:
26
Tělo:
select wsid, pdid, basedjo, busid, bname, scid, sname from
(
select ws.id as wsid, Req.Id as pdid, 0 as basedjo, Req.BUSORDER_ID as busid, BO.NAME AS BNAME, ReqN.STORECARD_ID as scid, SC.NAME AS SNAME --bratri fixovanych DUKu Poz
from PLMWorkScheduleItems ws
    INNER JOIN PLMReqRoutines ReqR ON (ReqR.id = ws.ReqRoutine_id)
    INNER JOIN PLMReqOutputItems ReqO ON (ReqR.parent_id = ReqO.ID)
    INNER JOIN PLMReqNodes ReqN ON (ReqO.owner_id = ReqN.ID)
    INNER JOIN PLMProduceRequests Req ON (ReqN.parent_id = Req.ID)
    INNER JOIN PLMPQParams ReqQ ON (Req.docqueue_id = ReqQ.docqueue_id)
    INNER JOIN PLMWorkPlaces WP ON (ws.Workplace_id = WP.ID)
    LEFT JOIN BUSORDERS BO ON (Req.BUSORDER_ID = BO.ID)
    INNER JOIN STORECARDS SC ON (ReqN.STORECARD_ID = SC.ID)
where (ws.status in (0,1) and not exists(select id from PLMWorkScheduleItemFixes where Parent_ID = ws.ID))
  and (Req.joborder_id is null)
  and WP.CRPPlan > 0
  and ReqR.Planned = 'A'
  and ReqQ.InPlan = 'A'
  and ReqR.TAC+ReqR.TBC > 0
  and Req.CANCELED = 'N'
  and Req.id not In
    ( select iReq.id
      from PLMWorkScheduleItems iws
          INNER JOIN PLMReqRoutines iReqR ON (iReqR.id = iws.ReqRoutine_id)
          INNER JOIN PLMReqOutputItems iReqO ON (iReqR.parent_id = iReqO.ID)
          INNER JOIN PLMReqNodes iReqN ON (iReqO.owner_id = iReqN.ID)
          INNER JOIN PLMProduceRequests iReq ON (iReqN.parent_id = iReq.ID)
          INNER JOIN PLMPQParams iReqQ ON (iReq.docqueue_id = iReqQ.docqueue_id)
          INNER JOIN PLMWorkPlaces iWP ON (iws.Workplace_id = iWP.ID)
      where iws.status in (0,1) and exists(select id from PLMWorkScheduleItemFixes where Parent_ID = ws.ID)
        and (iws.PlannedQuantity > (SELECT COALESCE(sum(Quantity),0) from PLMOperationWSIs WHERE WorkScheduleItem_id = iws.ID))
        and iWP.CRPPlan > 0
        and iReqR.Planned = 'A'
        and iReqQ.InPlan = 'A'
        and iReqR.TAC+iReqR.TBC > 0
        and iReq.CANCELED = 'N'
    )
) A
order by basedjo, pdid, wsid

Generated by ABRA Software a.s. 27.10.2021 16:34:49