From 52bd9a90e6e31eb2c458447fd7fec4e8f99a0fe7 Mon Sep 17 00:00:00 2001 From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com> Date: 星期一, 28 十月 2024 11:36:35 +0800 Subject: [PATCH] 修改班次信息的计算逻辑 --- _Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl | 220 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 167 insertions(+), 53 deletions(-) diff --git a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl index 7ed2f4f..ff4dd5e 100644 --- a/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl +++ b/_Main/BL/Type_DispatchShiftSchedulingInformation/StaticMethod_Dispatch.qbl @@ -10,7 +10,7 @@ TextBody: [* // Akari Sep-4-2024 (created) - owner.DispatchShiftSchedulingInformation( relflush ); + owner.DispatchShiftSchedulingLine( relflush ); macroPlan := offlinePlan.MacroPlan(); now := DateTime::Now(); @@ -30,26 +30,19 @@ unitIndexTree.Root().AddChild( unitHandle,i ); } - // productLines := selectuniquevalues( offlinePlan,NewOfflinePlanRow,row,row.ProductionLine() ); - productLinesQuantityNameValueTree := NamedValueTree::Create(); - traverse( offlinePlan,NewOfflinePlanRow,row ){ - traverse( row,NewOfflinePlanCell,cell, startDate <= cell.NewOfflinePlanColumn().StartDate() and endDate >= cell.NewOfflinePlanColumn().EndDate()){ - productLinesQuantityHandle := productLinesQuantityNameValueTree.GetHandle( row.ProductionLine() + cell.NewOfflinePlanColumn().StartDate().AsQUILL() ); - productLinesQuantity := guard( productLinesQuantityNameValueTree.Root().Child( productLinesQuantityHandle ),null( NamedValue )); - if( not isnull( productLinesQuantity )){ - productLinesQuantity.SetValue( productLinesQuantity.GetValueAsReal() + cell.Quantity() ); - }else{ - productLinesQuantityNameValueTree.Root().AddChild( productLinesQuantityHandle, cell.Quantity() ); - } - } - } + lines := construct( DispatchShiftSchedulingLines ); + lineIndexTree := NamedValueTree::Create(); + products := construct( DispatchShiftSchedulingProducts ); + productIndexTree := NamedValueTree::Create(); + + //productionDetails := construct( DispatchShiftSchedulingDetails ); + //productionDetailIndexTree := NamedValueTree::Create(); traverse( offlinePlan,NewOfflinePlanRow,row ){ - productID := row.ProductID(); - productLine := row.ProductionLine(); + line := null( DispatchShiftSchedulingLine ); factory := constnull( Unit ); { - unitHandle := unitIndexTree.GetHandle( productLine ); + unitHandle := unitIndexTree.GetHandle( row.ProductionLine() ); unitIndex := guard( unitIndexTree.Root().Child( unitHandle ), null( NamedValue )); if( not isnull( unitIndex )){ unit := units.Element( unitIndex.GetValueAsNumber() ); @@ -61,48 +54,169 @@ } factory := temp2; } + + lineHandle := lineIndexTree.GetHandle( row.ProductionLine() ); + lineIndex := guard( lineIndexTree.Root().Child( lineHandle ),null( NamedValue )); + if( isnull( lineIndex )){ + line := owner.DispatchShiftSchedulingLine( relnew,ID := IDHolder::GetGUID(),LineID := row.ProductionLine() ); + line.FactoryName( factory.Name() ); + line.InterfaceTime( now ); + line.VersionName( macroPlan.MDSMacroPlan().Description() ); + lines.Add( line ); + lineIndexTree.Root().AddChild( lineHandle,lines.Size() - 1 ); + }else{ + line := lines.Element( lineIndex.GetValueAsNumber() ); + } } + traverse( row,NewOfflinePlanCell,cell, startDate <= cell.NewOfflinePlanColumn().StartDate() and endDate >= cell.NewOfflinePlanColumn().EndDate()){ - productLinesQuantityHandle := productLinesQuantityNameValueTree.GetHandle( row.ProductionLine() + cell.NewOfflinePlanColumn().StartDate().AsQUILL() ); - productLinesQuantity := guard( productLinesQuantityNameValueTree.Root().Child( productLinesQuantityHandle ).GetValueAsReal(),0.0 ); - - shiftDate := cell.NewOfflinePlanColumn().StartDate(); - shiftName := cell.ShiftPatternName(); - shiftVolume := cell.Quantity(); - shiftDayTime := constnull( ShiftDayTime ); + product := null( DispatchShiftSchedulingProduct ); { - shiftPatternHandle := shiftPatternIndexTree.GetHandle( shiftName ); - shiftPatternIndex := guard( shiftPatternIndexTree.Root().Child( shiftPatternHandle ),null( NamedValue )); - if( not isnull( shiftPatternIndex )){ - shiftPattern := shiftPatterns.Element( shiftPatternIndex.GetValueAsNumber() ); - shiftDayTime := select( shiftPattern,ShiftDayTime,object,true ); + productHandle := productIndexTree.GetHandle( row.ProductionLine() + row.ProductID() + cell.NewOfflinePlanColumn().StartDate().AsQUILL() ); + productIndex := guard( productIndexTree.Root().Child( productHandle ),null( NamedValue )); + if( isnull( productIndex )){ + product := line.DispatchShiftSchedulingProduct( relnew,ProductID := row.ProductID() ); + product.ProductionQuantity( cell.Quantity() ); + line.ShiftDate( cell.NewOfflinePlanColumn().StartDate() ); + line.ShiftName( cell.ShiftPatternName() ); + products.Add( product ); + productIndexTree.Root().AddChild( productHandle,products.Size() - 1 ); + }else{ + product := products.Element( productIndex.GetValueAsNumber() ); } - } - if( shiftVolume <> 0 ){ - shiftSchedulingInformations := DispatchShiftSchedulingInformation::SplitShifts( owner,shiftName,shiftVolume,productLinesQuantity ); - - traverse( shiftSchedulingInformations,Elements,shiftSchedulingInformation ){ - shiftSchedulingInformation.InterfaceTime( now ); - shiftSchedulingInformation.VersionName( macroPlan.MDSMacroPlan().Description() ); - shiftSchedulingInformation.Product( productID ); - shiftSchedulingInformation.ProductLine( productLine ); - shiftSchedulingInformation.ShiftDate( shiftDate ); - // shiftSchedulingInformation.InterfaceTime( now ); - // shiftSchedulingInformation.InterfaceTime( now ); - // shiftSchedulingInformation.InterfaceTime( now ); - // shiftSchedulingInformation.InterfaceTime( now ); - - - if( not isnull( shiftDayTime )){ - shiftSchedulingInformation.ShiftStartDate( shiftDayTime.StartDateTime() ); - shiftSchedulingInformation.ShiftEndDate( shiftDayTime.EndDateTIme() ); - } - if( not isnull( factory )){ - shiftSchedulingInformation.FactoryName( factory.Name() ); - } - } } } } + + traverse( lines,Elements,line ){ + line.CalculateLineQuantity(); + + // 1000 + lineQuantity := line.LineQuantity(); + + tempProducts := selectsortedset( line,DispatchShiftSchedulingProduct,object,object.ProductionQuantity() ); + + if( line.ShiftName() = "3" ){ + singleShiftVolume1 := lineQuantity / 3; + singleShiftVolume2 := lineQuantity / 3; + singleShiftVolume3 := lineQuantity / 3; + traverse( tempProducts,Elements,product ){ + productionQuantity := product.ProductionQuantity(); + + if( singleShiftVolume1 > 0 and productionQuantity > 0){ + tempProductQuantity := singleShiftVolume1 - productionQuantity; + detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "鐧界彮"); + singleShiftVolume1 := singleShiftVolume1 - productionQuantity; + productionQuantity := productionQuantity - detail.ShiftVolume(); + }else if(singleShiftVolume2 > 0 and productionQuantity > 0){ + tempProductQuantity := singleShiftVolume2 - productionQuantity; + detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume2 ) ,SingleShiftName := "浜岀彮"); + singleShiftVolume2 := singleShiftVolume2 - productionQuantity; + productionQuantity := productionQuantity - detail.ShiftVolume(); + }else if(singleShiftVolume3 > 0 and productionQuantity > 0){ + tempProductQuantity := singleShiftVolume3 - productionQuantity; + detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume3 ) ,SingleShiftName := "浜岀彮"); + singleShiftVolume3 := singleShiftVolume3 - productionQuantity; + productionQuantity := productionQuantity - detail.ShiftVolume(); + } + } + + }else if( line.ShiftName() = "2" ){ + // 500 + singleShiftVolume1 := lineQuantity / 2; + singleShiftVolume2 := lineQuantity / 2; + traverse( tempProducts,Elements,product ){ + productionQuantity := product.ProductionQuantity(); + + if( singleShiftVolume1 > 0 and productionQuantity > 0){ + tempProductQuantity := singleShiftVolume1 - productionQuantity; + detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "鐧界彮"); + singleShiftVolume1 := singleShiftVolume1 - productionQuantity; + productionQuantity := productionQuantity - detail.ShiftVolume(); + }else if(singleShiftVolume2 > 0 and productionQuantity > 0){ + tempProductQuantity := singleShiftVolume2 - productionQuantity; + detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "浜岀彮"); + singleShiftVolume2 := singleShiftVolume2 - productionQuantity; + productionQuantity := productionQuantity - detail.ShiftVolume(); + } + } + + }else if( line.ShiftName() = "1" ){ + singleShiftVolume1 := lineQuantity / 1; + traverse( tempProducts,Elements,product ){ + productionQuantity := product.ProductionQuantity(); + if( singleShiftVolume1 > 0 and productionQuantity > 0){ + tempProductQuantity := singleShiftVolume1 - productionQuantity; + detail := product.DispatchShiftSchedulingDetail( relnew,ShiftVolume := ifexpr( tempProductQuantity > 0 ,productionQuantity,singleShiftVolume1 ) ,SingleShiftName := "鐧界彮"); + singleShiftVolume1 := singleShiftVolume1 - productionQuantity; + productionQuantity := productionQuantity - detail.ShiftVolume(); + } + } + + }else{ + // singleShiftVolume := lineQuantity / 1; + } + } + + //traverse( offlinePlan,NewOfflinePlanRow,row ){ + // productID := row.ProductID(); + // productLine := row.ProductionLine(); + // factory := constnull( Unit ); + // { + // unitHandle := unitIndexTree.GetHandle( productLine ); + // unitIndex := guard( unitIndexTree.Root().Child( unitHandle ), null( NamedValue )); + // if( not isnull( unitIndex )){ + // unit := units.Element( unitIndex.GetValueAsNumber() ); + // temp1 := unit; + // temp2 := unit.Parent(); + // while( not isnull( temp1.Parent())){ + // temp2 := temp1; + // temp1 := temp1.Parent(); + // } + // factory := temp2; + // } + // } + // traverse( row,NewOfflinePlanCell,cell, startDate <= cell.NewOfflinePlanColumn().StartDate() and endDate >= cell.NewOfflinePlanColumn().EndDate()){ + // productLinesQuantityHandle := productLinesQuantityNameValueTree.GetHandle( row.ProductionLine() + cell.NewOfflinePlanColumn().StartDate().AsQUILL() ); + // productLinesQuantity := guard( productLinesQuantityNameValueTree.Root().Child( productLinesQuantityHandle ).GetValueAsReal(),0.0 ); + // + // shiftDate := cell.NewOfflinePlanColumn().StartDate(); + // shiftName := cell.ShiftPatternName(); + // shiftVolume := cell.Quantity(); + // shiftDayTime := constnull( ShiftDayTime ); + // { + // shiftPatternHandle := shiftPatternIndexTree.GetHandle( shiftName ); + // shiftPatternIndex := guard( shiftPatternIndexTree.Root().Child( shiftPatternHandle ),null( NamedValue )); + // if( not isnull( shiftPatternIndex )){ + // shiftPattern := shiftPatterns.Element( shiftPatternIndex.GetValueAsNumber() ); + // shiftDayTime := select( shiftPattern,ShiftDayTime,object,true ); + // } + // } + // if( shiftVolume <> 0 ){ + // shiftSchedulingInformations := DispatchShiftSchedulingLine::SplitShifts( owner,shiftName,shiftVolume,productLinesQuantity ); + // + // traverse( shiftSchedulingInformations,Elements,shiftSchedulingInformation ){ + // shiftSchedulingInformation.InterfaceTime( now ); + // shiftSchedulingInformation.VersionName( macroPlan.MDSMacroPlan().Description() ); + // shiftSchedulingInformation.Product( productID ); + // shiftSchedulingInformation.ProductLine( productLine ); + // shiftSchedulingInformation.ShiftDate( shiftDate ); + //// shiftSchedulingInformation.InterfaceTime( now ); + //// shiftSchedulingInformation.InterfaceTime( now ); + //// shiftSchedulingInformation.InterfaceTime( now ); + //// shiftSchedulingInformation.InterfaceTime( now ); + // + // + // if( not isnull( shiftDayTime )){ + // shiftSchedulingInformation.ShiftStartDate( shiftDayTime.StartDateTime() ); + // shiftSchedulingInformation.ShiftEndDate( shiftDayTime.EndDateTIme() ); + // } + // if( not isnull( factory )){ + // shiftSchedulingInformation.FactoryName( factory.Name() ); + // } + // } + // } + // } + //} *] } -- Gitblit v1.9.3