Productie : functii

Lasă un comentariu

18 Mai 2010 de liviustoica55


protected Hours totalHoursConsumedperPO(ProdId   _prodId)
{
    ProdRouteTrans      prodRouteTrans;
    ;

    select sum(Hours)
        from prodRouteTrans
            where prodRouteTrans.ProdId    == _prodId
                && prodRouteTrans.DateWIP  >= fromDate
                && prodRouteTrans.DateWIP  <= toDate;

    return prodRouteTrans.Hours;
}
/// <summary>
/// Return the total hours posted for all the work centers in the cost center
/// </summary>
/// <returns>
/// Total hours posted for all the work centers in the cost center
/// </returns>
protected Hours costCenterTotalUsedCapacity()
{
    ProdRouteTrans              prodRouteTransAllOrders;
    Hours                       wrkCtrUsedCapacity ;
    ProdTable                   prodTable;
    InventTable                 inventTable;
    InventModelGroup            inventModelGroup;
    ;

    select sum(Hours) from prodRouteTransAllOrders
    where prodRouteTransAllOrders.Dimension[2]  == transDimension[2]    &&
          prodRouteTransAllOrders.DateWIP       >= fromDate             &&
          prodRouteTransAllOrders.DateWIP       <= toDate               &&
          prodRouteTransAllOrders.TransType     == ProdRouteTransType::Time
    // Exclude standard cost production orders
        join prodTable
            where prodTable.ProdId == prodRouteTransAllOrders.ProdId
        join inventTable
            where inventTable.ItemId == prodTable.ItemId
        join inventModelGroup
            where inventModelGroup.ModelGroupId == inventTable.ModelGroupId &&
                inventModelGroup.InventModel != InventModel::StdCost;

    wrkCtrUsedCapacity = prodRouteTransAllOrders.Hours;

    return wrkCtrUsedCapacity;
}
protected Hours costCenterTotalCapacity()
{
    ProdRouteTrans              prodRouteTrans;
    WrkCtrTable                 wrkCtrTable;
    Hours                       total;
    ;

    while select WrkCtrId from prodRouteTrans
        group by WrkCtrId
            join wrkCtrTable
                where prodRouteTrans.WrkCtrId   == wrkCtrTable.WrkCtrId
                    && prodRouteTrans.DateWIP   >= fromDate
                    && prodRouteTrans.DateWIP   <= toDate
                    && wrkCtrTable.Dimension[2] == transDimension[2]
                    && prodRouteTrans.TransType == ProdRouteTransType::Time
    {
        total += this.wrkCtrPlannedCapacity(prodRouteTrans.WrkCtrId);
    }

    return total;
}
/// <summary>
/// Return the total hours posted for the work center
/// </summary>
/// <param name="_wrkCtrId">
/// Work center in cost center
/// </param>
/// <returns>
/// Total hours posted for work center
/// </returns>
/// <remarks>
/// Exclude production order transactions for Standard Cost items.
/// </remarks>
protected Hours wrkCtrUsedCapacity(WrkCtrId _wrkCtrId)
{
    ProdRouteTrans              prodRouteTrans;
    Hours                       wrkCtrUsedCapacity ;
    ProdTable                   prodTable;
    InventTable                 inventTable;
    InventModelGroup            inventModelGroup;

    select sum(Hours) from prodRouteTrans
    where prodRouteTrans.Dimension[2]   == transDimension[2]    &&
          prodRouteTrans.WrkCtrId       == _wrkCtrId            &&
          prodRouteTrans.DateWIP        >= fromDate             &&
          prodRouteTrans.DateWIP        <= toDate               &&
          prodRouteTrans.TransType      == ProdRouteTransType::Time
        // Exclude standard cost production orders
        join prodId from prodTable
            where prodTable.ProdId == prodRouteTrans.ProdId
        join itemId from inventTable
            where inventTable.ItemId == prodTable.ItemId
        join ModelGroupId, InventModel from inventModelGroup
            where inventModelGroup.ModelGroupId == inventTable.ModelGroupId &&
                inventModelGroup.InventModel != InventModel::StdCost;

    wrkCtrUsedCapacity  = prodRouteTrans.Hours;

    return wrkCtrUsedCapacity;
}
protected Hours wrkCtrTotalCapacity()
{
    ProdRouteTrans prodRouteTrans;
    WrkCtrTable    wrkCtrTable;
    Hours          total;
    ;

    while select prodRouteTrans
        group by WrkCtrId
            join wrkCtrTable
                where prodRouteTrans.WrkCtrId   == wrkCtrTable.WrkCtrId
                    && prodRouteTrans.DateWIP   >= fromDate
                    && prodRouteTrans.DateWIP   <= toDate
                    && wrkCtrTable.Dimension[2] == transDimension[2]
                    && prodRouteTrans.TransType == ProdRouteTransType::Time
    {
        total += this.wrkCtrPlannedCapacity(prodRouteTrans.WrkCtrId);
    }

    return total;
}
protected Hours wrkCtrPlannedCapacity(WrkCtrId _wrkCtrId)
{
    WrkCtrTable             wrkCtrTable;
    WorkCalendarDateLine    dateLine;
    Hours                   plannedCapacity;
    ;

    wrkCtrTable = WrkCtrTable::find(_wrkCtrId);

    select sum(ToTime), sum(FromTime) from dateLine
        group by CalendarId
        where dateLine.CalendarId   == wrkCtrTable.CalendarId
            && dateLine.TransDate   >= fromDate
            && dateLine.TransDate   <= toDate;

    plannedCapacity = dateLine.ToTime - dateLine.FromTime;

    return plannedCapacity / 3600;
}

Lasă un răspuns

Completează mai jos detaliile despre tine sau dă clic pe un icon pentru autentificare:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s

%d blogeri au apreciat asta: